homebrew-core/Formula/glib.rb

94 lines
3.0 KiB
Ruby
Raw Normal View History

require 'formula'
2011-03-10 05:11:03 +00:00
class Glib < Formula
homepage 'http://developer.gnome.org/glib/'
2013-08-08 00:36:27 +00:00
url 'http://ftp.gnome.org/pub/gnome/sources/glib/2.36/glib-2.36.4.tar.xz'
sha256 'f654d2542329012d8475736a165dfbf82fadf3ee940c2e0e6ddd4b2fde5cad7e'
2012-08-10 05:00:06 +00:00
option :universal
option 'test', 'Build a debug build and run tests. NOTE: Not all tests succeed yet'
depends_on 'pkg-config' => :build
depends_on 'xz' => :build
depends_on 'gettext'
depends_on 'libffi'
2009-08-11 00:31:47 +00:00
fails_with :llvm do
build 2334
cause "Undefined symbol errors while linking"
end
def patches
2013-03-28 15:40:34 +00:00
p = {}
# https://bugzilla.gnome.org/show_bug.cgi?id=673135 Resolved as wontfix.
2013-04-16 06:03:11 +00:00
p[:p1] = "https://raw.github.com/gist/5393707/5a9047ab7838709084b36242a44471b02d036386/glib-configurable-paths.patch"
2013-03-28 15:40:34 +00:00
p[:p0] = "https://trac.macports.org/export/95596/trunk/dports/devel/glib2/files/patch-configure.diff" if build.universal?
p
end
def install
2012-08-10 05:00:06 +00:00
ENV.universal_binary if build.universal?
2011-06-05 00:11:45 +00:00
# -w is said to causes gcc to emit spurious errors for this package
ENV.enable_warnings if ENV.compiler == :gcc
# Disable dtrace; see https://trac.macports.org/ticket/30413
args = %W[
--disable-maintainer-mode
--disable-dependency-tracking
--disable-dtrace
--disable-modular-tests
2013-04-13 06:54:52 +00:00
--disable-libelf
--prefix=#{prefix}
--localstatedir=#{var}
--with-gio-module-dir=#{HOMEBREW_PREFIX}/lib/gio/modules
]
system "./configure", *args
2012-08-10 05:00:06 +00:00
if build.universal?
system "curl 'https://trac.macports.org/export/95596/trunk/dports/devel/glib2/files/config.h.ed' | ed - config.h"
end
system "make"
# the spawn-multithreaded tests require more open files
2012-08-10 05:00:06 +00:00
system "ulimit -n 1024; make check" if build.include? 'test'
system "make install"
# This sucks; gettext is Keg only to prevent conflicts with the wider
# system, but pkg-config or glib is not smart enough to have determined
# that libintl.dylib isn't in the DYLIB_PATH so we have to add it
# manually.
2013-03-28 15:40:34 +00:00
gettext = Formula.factory('gettext').opt_prefix
inreplace lib+'pkgconfig/glib-2.0.pc' do |s|
s.gsub! 'Libs: -L${libdir} -lglib-2.0 -lintl',
2013-03-28 15:40:34 +00:00
"Libs: -L${libdir} -lglib-2.0 -L#{gettext}/lib -lintl"
s.gsub! 'Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include',
2013-03-28 15:40:34 +00:00
"Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -I#{gettext}/include"
end
2010-08-08 17:20:15 +00:00
(share+'gtk-doc').rmtree
end
2013-02-02 05:12:36 +00:00
test do
(testpath/'test.c').write <<-EOS.undent
#include <string.h>
#include <glib.h>
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
2013-03-28 15:40:34 +00:00
flags = `pkg-config --cflags --libs glib-2.0`.split + ENV.cflags.split
2013-02-02 05:12:36 +00:00
system ENV.cc, "-o", "test", "test.c", *flags
system "./test"
end
end