class Libgsf < Formula
  homepage "https://developer.gnome.org/gsf/"
  url "http://ftp.acc.umu.se/pub/GNOME/sources/libgsf/1.14/libgsf-1.14.33.tar.xz"
  sha256 "82dd38e0c1f497704bf3b43682fca2768886058f004b14e9b5d103596f8c6e6b"

  head do
    url "https://github.com/GNOME/libgsf.git"
    depends_on "automake" => :build
    depends_on "autoconf" => :build
    depends_on "gnome-common" => :build
    depends_on "gtk-doc" => :build
    depends_on "libtool" => :build
  end

  bottle do
    sha256 "14271c2772c66337c0e2a745ee5ff0ede489e0d98241d72f33d2ac0f14a54491" => :yosemite
    sha256 "f9ee5d95f63ab462e12bf94e27578e1fe8d12c5deb5fd690feec49e4140f8828" => :mavericks
    sha256 "2074d7a6866bcf220595784683c6669822b018d660da6300bb840106fb7edd26" => :mountain_lion
  end

  depends_on "pkg-config" => :build
  depends_on "intltool" => :build
  depends_on "gdk-pixbuf" => :optional
  depends_on "gettext"
  depends_on "glib"

  def install
    args = %W[--disable-dependency-tracking --prefix=#{prefix}]
    if build.head?
      system "./autogen.sh", *args
    else
      system "./configure", *args
    end
    system "make", "install"
  end

  test do
    system bin/"gsf", "--help"
    (testpath/"test.c").write <<-EOS.undent
      #include <gsf/gsf-utils.h>
      int main()
      {
          void
          gsf_init (void);
          return 0;
      }
    EOS
    system ENV.cc, "-I#{include}/libgsf-1",
           "-I#{Formula["glib"].opt_include}/glib-2.0",
           "-I#{Formula["glib"].opt_lib}/glib-2.0/include",
           testpath/"test.c", "-o", testpath/"test"
    system "./test"
  end
end
