2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-06-06 22:54:52 +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/'
|
2013-11-12 16:29:33 +00:00
|
|
|
url 'http://ftp.gnome.org/pub/gnome/sources/glib/2.38/glib-2.38.2.tar.xz'
|
|
|
|
sha256 '056a9854c0966a0945e16146b3345b7a82562a5ba4d5516fd10398732aea5734'
|
2009-06-06 22:54:52 +00:00
|
|
|
|
2014-02-22 12:30:30 +00:00
|
|
|
bottle do
|
|
|
|
sha1 "4859364747094843599c19a42d7d150f91629f6c" => :mavericks
|
|
|
|
sha1 "bd656d91c1641f0f12a0c509c60a7cb7b10416de" => :mountain_lion
|
|
|
|
sha1 "2530552dce455e85f109ebeb090843cd9d7c4630" => :lion
|
|
|
|
end
|
|
|
|
|
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'
|
2013-12-28 01:38:48 +00:00
|
|
|
option 'with-static', 'Build glib with a static archive.'
|
2012-08-10 05:00:06 +00:00
|
|
|
|
2012-07-17 17:37:10 +00:00
|
|
|
depends_on 'pkg-config' => :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
|
|
|
|
2013-10-01 21:53:08 +00:00
|
|
|
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?
|
|
|
|
|
2014-03-08 23:02:38 +00:00
|
|
|
# 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.github.com/jacknagel/6700436/raw/a94f21a9c5ccd10afa0a61b11455c880640f3133/glib-configurable-paths.patch"
|
|
|
|
sha1 "911df7b09452c52ee3e0d269775d546cf7c077d1"
|
2010-07-24 03:19:08 +00:00
|
|
|
end
|
|
|
|
|
2014-03-08 23:02:38 +00:00
|
|
|
# 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.github.com/mistydemeo/8c7eaf0940b6b9159779/raw/11b3b1f09d15ccf805b0914a15eece11685ea8a5/gio.diff"
|
|
|
|
sha1 "5afea1a284747d31039449ca970376430951ec55"
|
|
|
|
end
|
|
|
|
|
|
|
|
patch :p0 do
|
|
|
|
url "https://trac.macports.org/export/111532/trunk/dports/devel/glib2/files/patch-configure.diff"
|
|
|
|
sha1 "5afea1a284747d31039449ca970376430951ec55"
|
|
|
|
end if build.universal?
|
|
|
|
|
2009-06-06 22:54:52 +00:00
|
|
|
def install
|
2012-08-10 05:00:06 +00:00
|
|
|
ENV.universal_binary if build.universal?
|
2011-06-05 00:11:45 +00:00
|
|
|
|
2012-05-01 00:29:16 +00:00
|
|
|
# Disable dtrace; see https://trac.macports.org/ticket/30413
|
2012-04-21 10:58:50 +00:00
|
|
|
args = %W[
|
|
|
|
--disable-maintainer-mode
|
|
|
|
--disable-dependency-tracking
|
2013-09-15 10:55:32 +00:00
|
|
|
--disable-silent-rules
|
2012-05-01 00:29:16 +00:00
|
|
|
--disable-dtrace
|
2013-04-13 06:54:52 +00:00
|
|
|
--disable-libelf
|
2012-04-21 10:58:50 +00:00
|
|
|
--prefix=#{prefix}
|
2012-05-06 22:25:25 +00:00
|
|
|
--localstatedir=#{var}
|
2013-03-24 20:39:27 +00:00
|
|
|
--with-gio-module-dir=#{HOMEBREW_PREFIX}/lib/gio/modules
|
2012-04-21 10:58:50 +00:00
|
|
|
]
|
2010-07-24 03:19:08 +00:00
|
|
|
|
2013-12-28 01:38:48 +00:00
|
|
|
args << '--enable-static' if build.with? 'static'
|
|
|
|
|
2010-07-24 03:19:08 +00:00
|
|
|
system "./configure", *args
|
|
|
|
|
2012-08-10 05:00:06 +00:00
|
|
|
if build.universal?
|
2013-10-01 21:53:08 +00:00
|
|
|
buildpath.install resource('config.h.ed')
|
|
|
|
system "ed -s - config.h <config.h.ed"
|
2012-04-21 10:58:50 +00:00
|
|
|
end
|
2010-07-24 03:19:08 +00:00
|
|
|
|
2009-06-06 22:54:52 +00:00
|
|
|
system "make"
|
2012-04-21 10:58:50 +00:00
|
|
|
# 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'
|
2009-06-06 22:54:52 +00:00
|
|
|
system "make install"
|
2009-09-24 22:35:10 +00:00
|
|
|
|
2013-12-05 07:37:52 +00:00
|
|
|
# `pkg-config --libs glib-2.0` includes -lintl, and gettext itself does not
|
|
|
|
# have a pkgconfig file, so we add gettext lib and include paths here.
|
2014-02-25 14:27:54 +00:00
|
|
|
gettext = Formula["gettext"].opt_prefix
|
2013-12-05 07:37:52 +00:00
|
|
|
inreplace lib+'pkgconfig/glib-2.0.pc' do |s|
|
|
|
|
s.gsub! 'Libs: -L${libdir} -lglib-2.0 -lintl',
|
|
|
|
"Libs: -L${libdir} -lglib-2.0 -L#{gettext}/lib -lintl"
|
|
|
|
s.gsub! 'Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include',
|
|
|
|
"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
|
2009-06-06 22:54:52 +00:00
|
|
|
end
|
2012-03-12 22:51:27 +00:00
|
|
|
|
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
|
2014-02-22 12:48:41 +00:00
|
|
|
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)
|
2013-02-02 05:12:36 +00:00
|
|
|
system "./test"
|
2012-03-12 22:51:27 +00:00
|
|
|
end
|
2009-06-06 22:54:52 +00:00
|
|
|
end
|