2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-06-06 22:54:52 +00:00
|
|
|
|
2010-07-24 03:19:08 +00:00
|
|
|
def build_tests?; ARGV.include? '--test'; end
|
2009-09-17 19:10:15 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Glib < Formula
|
2011-12-01 05:40:31 +00:00
|
|
|
homepage 'http://developer.gnome.org/glib/'
|
2012-03-12 20:07:15 +00:00
|
|
|
url 'ftp://ftp.gnome.org/pub/gnome/sources/glib/2.30/glib-2.30.3.tar.xz'
|
|
|
|
sha256 'e6cbb27c71c445993346e785e8609cc75cea2941e32312e544872feba572dd27'
|
2009-06-06 22:54:52 +00:00
|
|
|
|
2012-03-12 20:07:15 +00:00
|
|
|
depends_on 'xz' => :build
|
2009-09-18 18:16:39 +00:00
|
|
|
depends_on 'gettext'
|
2011-12-01 05:40:31 +00:00
|
|
|
depends_on 'libffi'
|
2009-08-11 00:31:47 +00:00
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
|
|
|
build 2334
|
|
|
|
cause "Undefined symbol errors while linking"
|
|
|
|
end
|
2011-08-05 12:38:32 +00:00
|
|
|
|
2012-04-11 03:52:15 +00:00
|
|
|
fails_with :clang do
|
|
|
|
build 318
|
|
|
|
cause <<-EOS.undent
|
|
|
|
Software that links against a clang-built glib experiences runtime errors:
|
|
|
|
GLib-ERROR (recursed) **: The thread system is not yet initialized.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2010-07-24 03:19:08 +00:00
|
|
|
def patches
|
2012-03-13 17:13:53 +00:00
|
|
|
{ :p0 => %W[
|
|
|
|
https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-configure.diff
|
|
|
|
https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-glib-2.0.pc.in.diff
|
|
|
|
https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-glib_gunicollate.c.diff
|
|
|
|
https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-gi18n.h.diff
|
|
|
|
https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-gio_xdgmime_xdgmime.c.diff
|
|
|
|
https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-gio_gdbusprivate.c.diff
|
2012-03-12 20:07:15 +00:00
|
|
|
]}
|
2010-07-24 03:19:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def options
|
2011-06-05 00:11:45 +00:00
|
|
|
[
|
|
|
|
['--universal', 'Build universal binaries.'],
|
|
|
|
['--test', 'Build a debug build and run tests. NOTE: Tests may hang on "unix-streams".']
|
|
|
|
]
|
2010-07-24 03:19:08 +00:00
|
|
|
end
|
|
|
|
|
2009-06-06 22:54:52 +00:00
|
|
|
def install
|
2011-06-05 00:11:45 +00:00
|
|
|
ENV.universal_binary if ARGV.build_universal?
|
|
|
|
|
2009-08-07 14:41:43 +00:00
|
|
|
# indeed, amazingly, -w causes gcc to emit spurious errors for this package!
|
|
|
|
ENV.enable_warnings
|
2009-06-06 22:54:52 +00:00
|
|
|
|
2010-07-24 03:19:08 +00:00
|
|
|
args = ["--disable-dependency-tracking", "--disable-rebuilds",
|
|
|
|
"--prefix=#{prefix}",
|
2011-09-13 08:24:51 +00:00
|
|
|
"--disable-dtrace"]
|
2010-07-24 03:19:08 +00:00
|
|
|
|
|
|
|
args << "--disable-debug" unless build_tests?
|
|
|
|
|
2012-01-13 06:15:36 +00:00
|
|
|
# MacPorts puts "@@PREFIX@@" in patches and does inreplace on the files,
|
|
|
|
# so we must follow suit if we use their patches
|
|
|
|
inreplace ['gio/xdgmime/xdgmime.c', 'gio/gdbusprivate.c'] do |s|
|
|
|
|
s.gsub! '@@PREFIX@@', HOMEBREW_PREFIX
|
|
|
|
end
|
|
|
|
|
2011-12-09 15:33:47 +00:00
|
|
|
# glib and pkg-config <= 0.26 have circular dependencies, so we should build glib without pkg-config
|
|
|
|
# The pkg-config dependency can be eliminated if certain env variables are set
|
|
|
|
# Note that this *may* need to be updated if any new dependencies are added in the future
|
|
|
|
# See http://permalink.gmane.org/gmane.comp.package-management.pkg-config/627
|
2011-08-21 13:28:37 +00:00
|
|
|
ENV['ZLIB_CFLAGS'] = ''
|
2012-02-07 05:48:05 +00:00
|
|
|
ENV['ZLIB_LIBS'] = '-lz'
|
2011-12-09 15:33:47 +00:00
|
|
|
# libffi include paths are dramatically ugly
|
|
|
|
libffi = Formula.factory('libffi')
|
|
|
|
ENV['LIBFFI_CFLAGS'] = "-I #{libffi.lib}/libffi-#{libffi.version}/include"
|
|
|
|
ENV['LIBFFI_LIBS'] = '-lffi'
|
2011-08-21 13:28:37 +00:00
|
|
|
|
2010-07-24 03:19:08 +00:00
|
|
|
system "./configure", *args
|
|
|
|
|
|
|
|
# Fix for 64-bit support, from MacPorts
|
2012-03-13 17:13:53 +00:00
|
|
|
curl "https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/config.h.ed", "-O"
|
2010-07-24 03:19:08 +00:00
|
|
|
system "ed - config.h < config.h.ed"
|
|
|
|
|
2009-06-06 22:54:52 +00:00
|
|
|
system "make"
|
2012-01-04 06:14:52 +00:00
|
|
|
# Suppress a folder already exists warning during install
|
2010-07-24 03:19:08 +00:00
|
|
|
# Also needed for running tests
|
|
|
|
ENV.j1
|
|
|
|
system "make test" if build_tests?
|
2009-06-06 22:54:52 +00:00
|
|
|
system "make install"
|
2009-09-24 22:35:10 +00:00
|
|
|
|
2010-02-19 19:19:01 +00:00
|
|
|
# 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.
|
|
|
|
gettext = Formula.factory('gettext')
|
|
|
|
inreplace lib+'pkgconfig/glib-2.0.pc' do |s|
|
|
|
|
s.gsub! 'Libs: -L${libdir} -lglib-2.0 -lintl',
|
2009-09-24 22:35:10 +00:00
|
|
|
"Libs: -L${libdir} -lglib-2.0 -L#{gettext.lib} -lintl"
|
2010-04-07 05:58:35 +00:00
|
|
|
|
2010-02-19 19:19:01 +00:00
|
|
|
s.gsub! 'Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include',
|
2010-02-19 17:37:19 +00:00
|
|
|
"Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -I#{gettext.include}"
|
2010-02-19 19:19:01 +00:00
|
|
|
end
|
2009-09-24 22:35:10 +00:00
|
|
|
|
2010-08-08 17:20:15 +00:00
|
|
|
(share+'gtk-doc').rmtree
|
2009-06-06 22:54:52 +00:00
|
|
|
end
|
2012-03-12 22:51:27 +00:00
|
|
|
|
|
|
|
def test
|
2012-03-13 04:28:23 +00:00
|
|
|
unless Formula.factory("pkg-config").installed?
|
|
|
|
puts "pkg-config is required to run this test, but is not installed"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2012-03-12 22:51:27 +00:00
|
|
|
mktemp do
|
|
|
|
(Pathname.pwd/'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
|
2012-03-13 04:28:23 +00:00
|
|
|
system ENV.cc, "-o", "test", "test.c",
|
2012-03-12 22:51:27 +00:00
|
|
|
*`pkg-config --cflags --libs glib-2.0`.split
|
|
|
|
system "./test"
|
|
|
|
end
|
|
|
|
end
|
2009-06-06 22:54:52 +00:00
|
|
|
end
|