1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/build-scripts/g++-fat.sh Mon Jun 23 11:29:53 2014 -0400
1.3 @@ -0,0 +1,101 @@
1.4 +#!/bin/sh
1.5 +#
1.6 +# Build Universal binaries on Mac OS X, thanks Ryan!
1.7 +#
1.8 +# Usage: ./configure CXX="sh g++-fat.sh" && make && rm -rf x86 x64
1.9 +
1.10 +DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
1.11 +
1.12 +# Intel 32-bit compiler flags (10.6 runtime compatibility)
1.13 +GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.5 \
1.14 +-I/usr/local/include"
1.15 +
1.16 +GCC_LINK_X86="-mmacosx-version-min=10.5"
1.17 +
1.18 +# Intel 64-bit compiler flags (10.6 runtime compatibility)
1.19 +GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
1.20 +-I/usr/local/include"
1.21 +
1.22 +GCC_LINK_X64="-mmacosx-version-min=10.6"
1.23 +
1.24 +# Output both PowerPC and Intel object files
1.25 +args="$*"
1.26 +compile=yes
1.27 +link=yes
1.28 +while test x$1 != x; do
1.29 + case $1 in
1.30 + --version) exec g++ $1;;
1.31 + -v) exec g++ $1;;
1.32 + -V) exec g++ $1;;
1.33 + -print-prog-name=*) exec g++ $1;;
1.34 + -print-search-dirs) exec g++ $1;;
1.35 + -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
1.36 + GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
1.37 + compile=no; link=no;;
1.38 + -c) link=no;;
1.39 + -o) output=$2;;
1.40 + *.c|*.cc|*.cpp|*.S) source=$1;;
1.41 + esac
1.42 + shift
1.43 +done
1.44 +if test x$link = xyes; then
1.45 + GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
1.46 + GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
1.47 +fi
1.48 +if test x"$output" = x; then
1.49 + if test x$link = xyes; then
1.50 + output=a.out
1.51 + elif test x$compile = xyes; then
1.52 + output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
1.53 + fi
1.54 +fi
1.55 +
1.56 +# Compile X86 32-bit
1.57 +if test x"$output" != x; then
1.58 + dir=x86/`dirname $output`
1.59 + if test -d $dir; then
1.60 + :
1.61 + else
1.62 + mkdir -p $dir
1.63 + fi
1.64 +fi
1.65 +set -- $args
1.66 +while test x$1 != x; do
1.67 + if test -f "x86/$1" && test "$1" != "$output"; then
1.68 + x86_args="$x86_args x86/$1"
1.69 + else
1.70 + x86_args="$x86_args $1"
1.71 + fi
1.72 + shift
1.73 +done
1.74 +$GCC_COMPILE_X86 $x86_args || exit $?
1.75 +if test x"$output" != x; then
1.76 + cp $output x86/$output
1.77 +fi
1.78 +
1.79 +# Compile X86 32-bit
1.80 +if test x"$output" != x; then
1.81 + dir=x64/`dirname $output`
1.82 + if test -d $dir; then
1.83 + :
1.84 + else
1.85 + mkdir -p $dir
1.86 + fi
1.87 +fi
1.88 +set -- $args
1.89 +while test x$1 != x; do
1.90 + if test -f "x64/$1" && test "$1" != "$output"; then
1.91 + x64_args="$x64_args x64/$1"
1.92 + else
1.93 + x64_args="$x64_args $1"
1.94 + fi
1.95 + shift
1.96 +done
1.97 +$GCC_COMPILE_X64 $x64_args || exit $?
1.98 +if test x"$output" != x; then
1.99 + cp $output x64/$output
1.100 +fi
1.101 +
1.102 +if test x"$output" != x; then
1.103 + lipo -create -o $output x86/$output x64/$output
1.104 +fi