homebrew-core/Formula/glib.rb

121 lines
4.1 KiB
Ruby
Raw Normal View History

require 'formula'
2011-03-10 05:11:03 +00:00
class Glib < Formula
2014-03-28 16:34:40 +00:00
homepage "http://developer.gnome.org/glib/"
url "http://ftp.gnome.org/pub/gnome/sources/glib/2.40/glib-2.40.0.tar.xz"
2014-03-28 16:34:40 +00:00
sha256 "0d27f195966ecb1995dcce0754129fd66ebe820c7cd29200d264b02af1aa28b5"
revision 1
2014-02-22 12:30:30 +00:00
bottle do
2014-05-11 21:15:46 +00:00
sha1 "744e1082ceb6840c320e2df02d7aed1c9cd1ae7c" => :mavericks
sha1 "ab53e313c471f4112dc3966b543756b40e8c3a2b" => :mountain_lion
sha1 "0ff3d77f6205d79189d84e1ec2500dbce2528acc" => :lion
2014-02-22 12:30:30 +00:00
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'
option 'with-static', 'Build glib with a static archive.'
2012-08-10 05:00:06 +00:00
depends_on 'pkg-config' => :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
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.githubusercontent.com/jacknagel/af332f42fae80c570a77/raw/a738786e0f7ea46c4a93a36a3d9d569017cca7f2/glib-hardcoded-paths.diff"
sha1 "ce54abdbb4386902a33dbad7cb6c8f1b0cbdab0d"
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
2014-03-28 16:34:40 +00:00
url "https://gist.githubusercontent.com/jacknagel/9835034/raw/b0388e86f74286f4271f9b0dca8219fdecafd5e3/gio.patch"
sha1 "32158fffbfb305296f7665ede6185a47d6f6b389"
2014-03-08 23:02:38 +00:00
end
2014-03-23 17:04:21 +00:00
patch do
2014-03-28 16:34:40 +00:00
url "https://gist.githubusercontent.com/jacknagel/9726139/raw/9d5635480d96d6b5c717d2c0d5d24de38b68ffbd/universal.patch"
sha1 "7f38cab550571b39989275362995ade214b44490"
2014-03-08 23:02:38 +00:00
end if build.universal?
def install
2012-08-10 05:00:06 +00:00
ENV.universal_binary if build.universal?
2011-06-05 00:11:45 +00:00
inreplace %w[gio/gdbusprivate.c gio/xdgmime/xdgmime.c glib/gutils.c],
"@@HOMEBREW_PREFIX@@", HOMEBREW_PREFIX
# Disable dtrace; see https://trac.macports.org/ticket/30413
args = %W[
--disable-maintainer-mode
--disable-dependency-tracking
--disable-silent-rules
--disable-dtrace
2013-04-13 06:54:52 +00:00
--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
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"
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"
# `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
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
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
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.to_s.split)
2013-02-02 05:12:36 +00:00
system "./test"
end
end