Permalink
Browse files

Static build script contributed by Nick Humfrey

Changes to mac build scripts to use new static binaries
  • Loading branch information...
1 parent e8141dc commit fc74ed43882665867095a3266f94e4496c4ec1d7 Steve Harris committed Sep 19, 2011
Showing with 769 additions and 20 deletions.
  1. +2 −0 .gitignore
  2. +1 −0 Makefile.am
  3. +2 −11 app-aux/build-app.sh
  4. +326 −0 app-aux/build-static.pl
  5. +1 −1 app-aux/bundle-version
  6. +24 −0 app-aux/gettext.patch
  7. +89 −0 app-aux/glib2-config.h.ed
  8. +316 −0 app-aux/glib2.patch
  9. +8 −8 docs/release
View
@@ -30,3 +30,5 @@ config.guess
config.sub
libtool
4store-0.pc
+build
+root
View
@@ -7,6 +7,7 @@ test: all
(cd tests && $(MAKE) -w $@)
macapp: all
+ app-aux/build-static.pl
app-aux/build-app.sh
macdmg: macapp
View
@@ -1,7 +1,7 @@
#!/bin/bash
rm -rf 4store.app
-mkdir -p 4store.app/Contents/Resources 4store.app/Contents/MacOS/{bin,lib}
+mkdir -p 4store.app/Contents/Resources 4store.app/Contents/MacOS/bin
bv=`cat app-aux/bundle-version`
bv=`expr $bv + 1`
echo $bv > app-aux/bundle-version
@@ -11,17 +11,8 @@ version=`git describe --tags --always | sed 's/^v//; s/-.*//'`
sed -e 's/${AV}/'$version'/' -i "" 4store.app/Contents/Info.plist
cp -r app-aux/Resources/* 4store.app/Contents/Resources/
cp app-aux/MacOS/* 4store.app/Contents/MacOS/
-for i in src/frontend/4s-* src/backend/4s-* src/utilities/4s-{backend,cluster}-* src/utilities/4s-{dump,restore} src/http/4s-*; do
+for i in root/bin/4s-*; do
if test -x $i ; then
cp $i 4store.app/Contents/MacOS/bin/
fi
done
-cp -p /usr/local/lib/librasqal*.dylib /usr/local/lib/libraptor2*.dylib \
- /sw/lib/libxslt.1*.dylib \
- /sw/lib/libgthread-2*.dylib \
- /sw/lib/libglib-2*.dylib \
- /sw/lib/libintl.3*.dylib \
- /sw/lib/libpcre.0*.dylib \
- /sw/lib/libreadline.5*.dylib \
- /sw/lib/ncurses/libncurses*.dylib \
- 4store.app/Contents/MacOS/lib/
View
@@ -0,0 +1,326 @@
+#!/usr/bin/perl
+
+use File::Basename;
+use Cwd;
+use strict;
+use warnings;
+
+my $TOP_DIR = Cwd::realpath(dirname(__FILE__).'/..');
+my $BUILD_DIR = "$TOP_DIR/build";
+my $ROOT_DIR = "$TOP_DIR/root";
+my $DEFAULT_CONFIGURE_ARGS = "--enable-static --disable-shared --prefix=$ROOT_DIR ".
+ "--disable-gtk-doc --disable-dependency-tracking ".
+ "--disable-rebuilds";
+
+my $packages = [
+ {
+ 'url' => 'http://pkgconfig.freedesktop.org/releases/pkg-config-0.25.tar.gz',
+ 'config' => "./configure $DEFAULT_CONFIGURE_ARGS --with-pc-path=${ROOT_DIR}/lib/pkgconfig",
+ 'checkfor' => 'bin/pkg-config',
+ },
+ {
+ 'url' => 'http://curl.haxx.se/download/curl-7.21.7.tar.gz',
+ 'config' => "./configure $DEFAULT_CONFIGURE_ARGS ".
+ "--disable-ssh --disable-ldap --disable-ldaps --disable-rtsp ".
+ "--without-librtmp --disable-dict --disable-telnet --disable-pop3 ".
+ "--disable-imap --disable-smtp --disable-manual --without-libssh2",
+ 'checkfor' => 'lib/pkgconfig/libcurl.pc',
+ },
+ {
+ 'url' => 'http://kent.dl.sourceforge.net/project/pcre/pcre/8.12/pcre-8.12.tar.bz2',
+ 'config' => "./configure $DEFAULT_CONFIGURE_ARGS --enable-utf8 ".
+ "--enable-unicode-properties --enable-pcregrep-libz ".
+ "--enable-pcregrep-libbz2",
+ 'checkfor' => 'lib/pkgconfig/libpcre.pc'
+ },
+ {
+ # NOTE: libxml2-2.7.8 doesn't seem to work with Mac OS 10.6 zlib
+ 'url' => 'http://xmlsoft.org/sources/libxml2-2.7.6.tar.gz',
+ 'checkfor' => 'lib/pkgconfig/libxml-2.0.pc',
+ },
+ {
+ 'url' => 'http://xmlsoft.org/sources/libxslt-1.1.26.tar.gz',
+ 'checkfor' => 'lib/pkgconfig/libxslt.pc',
+ },
+ {
+ 'url' => 'http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz',
+ 'patch' => 'gettext.patch',
+ 'config' => "./configure $DEFAULT_CONFIGURE_ARGS --disable-debug ".
+ "--without-included-gettext --without-included-glib ".
+ "--without-included-libcroco --without-included-libxml ".
+ "--without-emacs --disable-java",
+ 'checkfor' => 'lib/libgettextlib.la',
+ },
+# {
+# 'url' => 'http://ftp.gnu.org/gnu/readline/readline-6.2.tar.gz',
+# 'checkfor' => 'lib/libreadline.a',
+# },
+ {
+ 'url' => 'ftp://ftp.gnome.org/pub/gnome/sources/glib/2.28/glib-2.28.8.tar.bz2',
+ 'patch' => 'glib2.patch',
+ 'config' => "./configure $DEFAULT_CONFIGURE_ARGS --disable-selinux && ".
+ "ed - config.h < ${TOP_DIR}/app-aux/glib2-config.h.ed",
+ 'checkfor' => 'lib/pkgconfig/glib-2.0.pc',
+ },
+ {
+ 'url' => 'http://github.com/lloyd/yajl/tarball/1.0.12',
+ 'dirname' => 'lloyd-yajl-17b1790',
+ 'tarname' => 'yajl-1.0.12.tar.gz',
+ 'config' => "mkdir build && cd build && /usr/local/bin/cmake ..",
+ 'make' => "cd build && make yajl_s",
+ 'install' => "cd build/yajl-1.0.12 && ".
+ "cp -Rfv include/yajl ${ROOT_DIR}/include/ && ".
+ "cp -fv lib/libyajl_s.a ${ROOT_DIR}/lib/libyajl.a",
+ 'checkfor' => 'lib/libyajl.a',
+ },
+ {
+ 'url' => 'http://download.librdf.org/source/raptor2-2.0.4.tar.gz',
+ 'config' => "./configure $DEFAULT_CONFIGURE_ARGS --with-yajl=${ROOT_DIR}",
+ 'checkfor' => 'lib/pkgconfig/raptor2.pc',
+ },
+ {
+ 'url' => 'http://download.librdf.org/source/rasqal-0.9.27.tar.gz',
+ 'config' => "./configure $DEFAULT_CONFIGURE_ARGS --enable-raptor2",
+ 'checkfor' => 'lib/pkgconfig/rasqal.pc',
+ },
+ {
+ 'name' => '4store',
+ 'dirpath' => $TOP_DIR,
+ 'test' => 'make check',
+ 'checkfor' => 'lib/pkgconfig/4store-0.pc',
+ 'alwaysbuild' => 1,
+ },
+];
+
+# Reset environment variables
+$ENV{'CFLAGS'} = "-O2 -I${ROOT_DIR}/include";
+$ENV{'CPPFLAGS'} = "-I${ROOT_DIR}/include";
+$ENV{'ASFLAGS'} = "-I${ROOT_DIR}/include";
+$ENV{'LDFLAGS'} = "-L${ROOT_DIR}/lib";
+$ENV{'INFOPATH'} = "${ROOT_DIR}/share/info";
+$ENV{'MANPATH'} = "${ROOT_DIR}/share/man";
+$ENV{'M4PATH'} = "${ROOT_DIR}/share/aclocal";
+$ENV{'PATH'} = "${ROOT_DIR}/bin:/usr/bin:/bin";
+$ENV{'PKG_CONFIG_PATH'} = "${ROOT_DIR}/lib/pkgconfig";
+$ENV{'CLASSPATH'} = '';
+
+# Add extra CFLAGS if this is Mac OS X
+if (`uname` =~ /^Darwin/) {
+ die "Mac OS X Developer Tools are not available." unless (-e '/Developer/');
+
+ # Build x86_64 only binary against 10.5+
+ my $SDK;
+ my $SDKver;
+ for my $ver ('10.5', '10.6') {
+ if (-d "/Developer/SDKs/MacOSX${ver}.sdk") {
+ $SDKver = $ver;
+ $SDK = "/Developer/SDKs/MacOSX${ver}.sdk";
+ last;
+ }
+ }
+ die "Mac OS X SDK is not available." unless ($SDK);
+ my $ARCHES = '-arch x86_64';
+ my $MINVER = "-mmacosx-version-min=$SDKver";
+
+ $ENV{'CFLAGS'} .= " -isysroot $SDK $ARCHES $MINVER";
+ $ENV{'LDFLAGS'} .= " -Wl,-syslibroot,$SDK $ARCHES $MINVER";
+ $ENV{'CFLAGS'} .= " -force_cpusubtype_ALL";
+ $ENV{'LDFLAGS'} .= " -Wl,-headerpad_max_install_names";
+ $ENV{'MACOSX_DEPLOYMENT_TARGET'} = $SDKver;
+ $ENV{'CMAKE_OSX_ARCHITECTURES'} = 'x86_64';
+
+ my $GCC_VER = '4.2';
+ $ENV{'CC'} = "/Developer/usr/bin/gcc-$GCC_VER";
+ $ENV{"CPP"} = "/Developer/usr/bin/cpp-$GCC_VER";
+ $ENV{"CXX"} = "/Developer/usr/bin/g++-$GCC_VER";
+ die "gcc version $GCC_VER is not available." unless (-e $ENV{'CC'});
+}
+
+$ENV{'CXXFLAGS'} = $ENV{'CFLAGS'};
+
+print "Build directory: $BUILD_DIR\n";
+mkdir($BUILD_DIR);
+
+print "Root directory: $ROOT_DIR\n";
+mkdir($ROOT_DIR);
+mkdir($ROOT_DIR.'/bin');
+mkdir($ROOT_DIR.'/include');
+mkdir($ROOT_DIR.'/lib');
+mkdir($ROOT_DIR.'/share');
+
+gtkdoc_hack($ROOT_DIR);
+
+
+foreach my $pkg (@$packages) {
+ if (defined $pkg->{'url'} and !defined $pkg->{'tarname'}) {
+ ($pkg->{'tarname'}) = ($pkg->{'url'} =~ /([^\/]+)$/);
+ }
+ if (defined $pkg->{'tarname'} and !defined $pkg->{'tarpath'}) {
+ $pkg->{'tarpath'} = $BUILD_DIR.'/'.$pkg->{'tarname'};
+ }
+ if (defined $pkg->{'tarname'} and !defined $pkg->{'dirname'}) {
+ ($pkg->{'dirname'}) = ($pkg->{'tarname'} =~ /^([\w\.\-]+[\d\.\-]+\d)/);
+ $pkg->{'dirname'} =~ s/_/\-/g;
+ }
+ if (defined $pkg->{'dirname'} and !defined $pkg->{'dirpath'}) {
+ $pkg->{'dirpath'} = $BUILD_DIR.'/'.$pkg->{'dirname'};
+ }
+ if (defined $pkg->{'dirname'} and !defined $pkg->{'name'}) {
+ $pkg->{'name'} = $pkg->{'dirname'};
+ }
+
+ unless ($pkg->{'alwaysbuild'} or defined $pkg->{'checkfor'}) {
+ die "Don't know how to check if ".$pkg->{'name'}." is already built.";
+ }
+
+ if ($pkg->{'alwaysbuild'} or !-e $ROOT_DIR.'/'.$pkg->{'checkfor'}) {
+ download_package($pkg) if (defined $pkg->{'url'});
+ extract_package($pkg) if (defined $pkg->{'tarpath'});
+ clean_package($pkg);
+ patch_package($pkg);
+ config_package($pkg);
+ make_package($pkg);
+ test_package($pkg);
+ install_package($pkg);
+
+ if (defined $pkg->{'checkfor'} && !-e $ROOT_DIR.'/'.$pkg->{'checkfor'}) {
+ die "Installing $pkg->{'name'} failed.";
+ }
+ }
+}
+
+print "Finished compiling:\n";
+foreach my $pkg (sort {$a->{'name'} cmp $b->{'name'}} @$packages) {
+ print " * ".$pkg->{'name'}."\n";
+}
+
+
+sub extract_package {
+ my ($pkg) = @_;
+ if (-e $pkg->{'dirpath'}) {
+ print "Deleting old: $pkg->{'dirpath'}\n";
+ safe_system('rm', '-Rf', $pkg->{'dirpath'});
+ }
+
+ safe_chdir();
+ print "Extracting: $pkg->{'tarname'} into $pkg->{'dirpath'}\n";
+ if ($pkg->{'tarname'} =~ /bz2$/) {
+ safe_system('tar', '-jxf', $pkg->{'tarpath'});
+ } elsif ($pkg->{'tarname'} =~ /gz$/) {
+ safe_system('tar', '-zxf', $pkg->{'tarpath'});
+ } else {
+ die "Don't know how to decomress archive.";
+ }
+}
+
+sub download_package {
+ my ($pkg) = @_;
+
+ unless (-e $pkg->{'tarpath'}) {
+ safe_chdir();
+ print "Downloading: ".$pkg->{'tarname'}."\n";
+ safe_system('curl', '-L', '-k', '-o', $pkg->{'tarpath'}, $pkg->{'url'});
+ }
+}
+
+sub clean_package {
+ my ($pkg) = @_;
+
+ safe_chdir($pkg->{'dirpath'});
+ print "Cleaning: ".$pkg->{'name'}."\n";
+ if ($pkg->{'clean'}) {
+ system($pkg->{'clean'});
+ } else {
+ # this is allowed to fail
+ system('make', 'clean') if (-e 'Makefile');
+ }
+}
+
+sub patch_package {
+ my ($pkg) = @_;
+ if ($pkg->{'patch'}) {
+ safe_chdir($pkg->{'dirpath'});
+ my $patchfile = $TOP_DIR.'/app-aux/'.$pkg->{'patch'};
+ safe_system("patch -p0 < $patchfile");
+ }
+}
+
+sub config_package {
+ my ($pkg) = @_;
+
+ safe_chdir($pkg->{'dirpath'});
+ print "Configuring: ".$pkg->{'name'}."\n";
+ if ($pkg->{'config'}) {
+ safe_system($pkg->{'config'});
+ } else {
+ if (-e "./configure") {
+ safe_system("./configure $DEFAULT_CONFIGURE_ARGS");
+ } elsif (-e "./autogen.sh") {
+ safe_system("./autogen.sh $DEFAULT_CONFIGURE_ARGS");
+ } else {
+ die "Don't know how to configure ".$pkg->{'name'};
+ }
+ }
+}
+
+sub make_package {
+ my ($pkg) = @_;
+
+ safe_chdir($pkg->{'dirpath'});
+ print "Making: ".$pkg->{'name'}."\n";
+ if ($pkg->{'make'}) {
+ safe_system($pkg->{'make'});
+ } else {
+ safe_system('make');
+ }
+}
+
+sub test_package {
+ my ($pkg) = @_;
+
+ safe_chdir($pkg->{'dirpath'});
+ if ($pkg->{'test'}) {
+ print "Testing: ".$pkg->{'name'}."\n";
+ safe_system($pkg->{'test'});
+ }
+}
+
+sub install_package {
+ my ($pkg) = @_;
+
+ safe_chdir($pkg->{'dirpath'});
+ print "Installing: ".$pkg->{'name'}."\n";
+ if ($pkg->{'install'}) {
+ safe_system($pkg->{'install'});
+ } else {
+ safe_system('make','install');
+ }
+}
+
+sub safe_chdir {
+ my ($dir) = @_;
+ $dir = $BUILD_DIR unless defined $dir;
+ print "Changing to: $dir\n";
+ chdir($dir) or die "Failed to change directory: $!";
+}
+
+sub safe_system {
+ my (@cmd) = @_;
+ print "Running: ".join(' ',@cmd)."\n";
+ if (system(@cmd)) {
+ die "Command failed";
+ }
+}
+
+
+# HACK to fix bad gtkdoc detection
+sub gtkdoc_hack {
+ my ($dir) = @_;
+ my $script = "$dir/bin/gtkdoc-rebase";
+
+ open(SCRIPT, ">$script") or die "Failed to open $script: $!";
+ print SCRIPT "#/bin/sh\n";
+ close(SCRIPT);
+
+ chmod(0755, $script) or die "Failed to chmod 0755 $script: $!";
+}
View
@@ -1 +1 @@
-162
+165
View
@@ -0,0 +1,24 @@
+--- gettext-tools/Makefile.in.orig 2010-06-03 16:38:55.000000000 -0500
++++ gettext-tools/Makefile.in 2010-06-04 01:16:07.000000000 -0500
+@@ -1248,7 +1248,7 @@
+ top_srcdir = @top_srcdir@
+ AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies
+ ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4
+-SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4 tests gnulib-tests examples
++SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4 tests gnulib-tests
+
+ # Allow users to use "gnulib-tool --update".
+
+diff -Naurp gettext-0.18.1.1.orig/gettext-tools/configure gettext-0.18.1.1/gettext-tools/configure
+--- gettext-tools/configure 2010-06-06 13:12:20.000000000 -0700
++++ gettext-tools/configure 2010-08-13 23:24:09.000000000 -0700
+@@ -40606,7 +40606,9 @@ else
+ #include <stdlib.h>
+ #include <string.h> /* for strcpy */
+ /* The stpncpy prototype is missing in <string.h> on AIX 4. */
++#ifndef stpncpy
+ extern char *stpncpy (char *dest, const char *src, size_t n);
++#endif
+ int main () {
+ const char *src = "Hello";
+ char dest[10];
Oops, something went wrong.

0 comments on commit fc74ed4

Please sign in to comment.