3 # Build Universal binaries on Mac OS X, thanks Ryan!
5 # Usage: ./configure CXX="sh g++-fat.sh" && make && rm -rf x86 x64
7 DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
9 # Intel 32-bit compiler flags (10.5 runtime compatibility)
10 GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.5 \
13 GCC_LINK_X86="-mmacosx-version-min=10.5"
15 # Intel 64-bit compiler flags (10.6 runtime compatibility)
16 GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
19 GCC_LINK_X64="-mmacosx-version-min=10.6"
21 # Output both PowerPC and Intel object files
25 while test x$1 != x; do
27 --version) exec g++ $1;;
30 -print-prog-name=*) exec g++ $1;;
31 -print-search-dirs) exec g++ $1;;
32 -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
33 GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
37 *.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
41 if test x$link = xyes; then
42 GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
43 GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
45 if test x"$output" = x; then
46 if test x$link = xyes; then
48 elif test x$compile = xyes; then
49 output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
54 if test x"$output" != x; then
55 dir=x86/`dirname $output`
63 while test x$1 != x; do
64 if test -f "x86/$1" && test "$1" != "$output"; then
65 x86_args="$x86_args x86/$1"
67 x86_args="$x86_args $1"
71 $GCC_COMPILE_X86 $x86_args || exit $?
72 if test x"$output" != x; then
73 cp $output x86/$output
77 if test x"$output" != x; then
78 dir=x64/`dirname $output`
86 while test x$1 != x; do
87 if test -f "x64/$1" && test "$1" != "$output"; then
88 x64_args="$x64_args x64/$1"
90 x64_args="$x64_args $1"
94 $GCC_COMPILE_X64 $x64_args || exit $?
95 if test x"$output" != x; then
96 cp $output x64/$output
99 if test x"$output" != x; then
100 lipo -create -o $output x86/$output x64/$output