3 # Build Universal binaries on Mac OS X, thanks Ryan!
5 # Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf x86 x64
7 # Intel 32-bit compiler flags (10.4 runtime compatibility)
8 GCC_COMPILE_X86="gcc-4.0 -arch i386 -mmacosx-version-min=10.4 \
9 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
11 -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
12 -I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/include \
13 -isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
16 -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1 \
17 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
19 # Intel 64-bit compiler flags (10.5 runtime compatibility)
20 GCC_COMPILE_X64="gcc-4.0 -arch x86_64 -mmacosx-version-min=10.5 \
21 -DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \
23 -F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks \
24 -I/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/include \
25 -isystem /Developer/SDKs/MacOSX10.5.sdk/usr/include"
28 -L/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/x86_64 \
29 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
31 # Output both PowerPC and Intel object files
35 while test x$1 != x; do
37 --version) exec gcc $1;;
40 -print-prog-name=*) exec gcc $1;;
41 -print-search-dirs) exec gcc $1;;
42 -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
43 GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
47 *.c|*.cc|*.cpp|*.S) source=$1;;
51 if test x$link = xyes; then
52 GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
53 GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
55 if test x"$output" = x; then
56 if test x$link = xyes; then
58 elif test x$compile = xyes; then
59 output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
64 if test x"$output" != x; then
65 dir=x86/`dirname $output`
73 while test x$1 != x; do
74 if test -f "x86/$1" && test "$1" != "$output"; then
75 x86_args="$x86_args x86/$1"
77 x86_args="$x86_args $1"
81 $GCC_COMPILE_X86 $x86_args || exit $?
82 if test x"$output" != x; then
83 cp $output x86/$output
87 if test x"$output" != x; then
88 dir=x64/`dirname $output`
96 while test x$1 != x; do
97 if test -f "x64/$1" && test "$1" != "$output"; then
98 x64_args="$x64_args x64/$1"
100 x64_args="$x64_args $1"
104 $GCC_COMPILE_X64 $x64_args || exit $?
105 if test x"$output" != x; then
106 cp $output x64/$output
109 if test x"$output" != x; then
110 lipo -create -o $output x86/$output x64/$output