require 'formula' class Glib < Formula homepage "http://developer.gnome.org/glib/" url "http://ftp.gnome.org/pub/gnome/sources/glib/2.40/glib-2.40.0.tar.xz" sha256 "0d27f195966ecb1995dcce0754129fd66ebe820c7cd29200d264b02af1aa28b5" bottle do sha1 "85f199d88dd10459de8752a42bd25a6092046d14" => :mavericks sha1 "6c7aada5d49452943a59949ae71a51a8dce627b3" => :mountain_lion sha1 "ab9fe14888599a51f45afc91a4af007f1311a67c" => :lion end option :universal option 'test', 'Build a debug build and run tests. NOTE: Not all tests succeed yet' option 'with-static', 'Build glib with a static archive.' depends_on 'pkg-config' => :build depends_on 'gettext' depends_on 'libffi' fails_with :llvm do build 2334 cause "Undefined symbol errors while linking" end resource 'config.h.ed' do url 'https://trac.macports.org/export/111532/trunk/dports/devel/glib2/files/config.h.ed' version '111532' sha1 '0926f19d62769dfd3ff91a80ade5eff2c668ec54' end if build.universal? # https://bugzilla.gnome.org/show_bug.cgi?id=673135 Resolved as wontfix, # but needed to fix an assumption about the location of the d-bus machine # id file. patch do url "https://gist.githubusercontent.com/jacknagel/6700436/raw/2d790a8bd0c59ef66835866523988fbf9f680443/glib-configurable-paths.patch" sha1 "7b89ce26c256e43cfdc11bae0c4498ec8529bcd4" end # Fixes compilation with FSF GCC. Doesn't fix it on every platform, due # to unrelated issues in GCC, but improves the situation. # Patch submitted upstream: https://bugzilla.gnome.org/show_bug.cgi?id=672777 patch do url "https://gist.githubusercontent.com/jacknagel/9835034/raw/b0388e86f74286f4271f9b0dca8219fdecafd5e3/gio.patch" sha1 "32158fffbfb305296f7665ede6185a47d6f6b389" end patch do url "https://gist.githubusercontent.com/jacknagel/9726139/raw/9d5635480d96d6b5c717d2c0d5d24de38b68ffbd/universal.patch" sha1 "7f38cab550571b39989275362995ade214b44490" end if build.universal? def install ENV.universal_binary if build.universal? # Disable dtrace; see https://trac.macports.org/ticket/30413 args = %W[ --disable-maintainer-mode --disable-dependency-tracking --disable-silent-rules --disable-dtrace --disable-libelf --prefix=#{prefix} --localstatedir=#{var} --with-gio-module-dir=#{HOMEBREW_PREFIX}/lib/gio/modules ] args << '--enable-static' if build.with? 'static' system "./configure", *args if build.universal? buildpath.install resource('config.h.ed') system "ed -s - config.h #include int main(void) { gchar *result_1, *result_2; char *str = "string"; result_1 = g_convert(str, strlen(str), "ASCII", "UTF-8", NULL, NULL, NULL); result_2 = g_convert(result_1, strlen(result_1), "UTF-8", "ASCII", NULL, NULL, NULL); return (strcmp(str, result_2) == 0) ? 0 : 1; } EOS flags = ["-I#{include}/glib-2.0", "-I#{lib}/glib-2.0/include", "-lglib-2.0"] system ENV.cc, "-o", "test", "test.c", *(flags + ENV.cflags.split) system "./test" end end