3 # Build Universal binaries on Mac OS X, thanks Ryan!
5 # Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf ppc x86
7 # PowerPC compiler flags (10.2 runtime compatibility)
8 GCC_COMPILE_PPC="gcc-3.3 -arch ppc \
9 -DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
11 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
12 -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
13 -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
16 -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
17 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
18 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
20 # Intel compiler flags (10.4 runtime compatibility)
21 GCC_COMPILE_X86="gcc-4.0 -arch i386 -mmacosx-version-min=10.4 \
22 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
24 -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
25 -I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
26 -isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
29 -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \
30 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
32 # Output both PowerPC and Intel object files
36 while test x$1 != x; do
38 --version) exec gcc $1;;
41 -print-prog-name=*) exec gcc $1;;
42 -print-search-dirs) exec gcc $1;;
43 -E) GCC_COMPILE_PPC="$GCC_COMPILE_PPC -E"
44 GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
48 *.c|*.cc|*.cpp|*.S) source=$1;;
52 if test x$link = xyes; then
53 GCC_COMPILE_PPC="$GCC_COMPILE_PPC $GCC_LINK_PPC"
54 GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
56 if test x"$output" = x; then
57 if test x$link = xyes; then
59 elif test x$compile = xyes; then
60 output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
64 if test x"$output" != x; then
65 dir=ppc/`dirname $output`
73 while test x$1 != x; do
74 if test -f "ppc/$1" && test "$1" != "$output"; then
75 ppc_args="$ppc_args ppc/$1"
77 ppc_args="$ppc_args $1"
81 $GCC_COMPILE_PPC $ppc_args || exit $?
82 if test x"$output" != x; then
83 cp $output ppc/$output
86 if test x"$output" != x; then
87 dir=x86/`dirname $output`
95 while test x$1 != x; do
96 if test -f "x86/$1" && test "$1" != "$output"; then
97 x86_args="$x86_args x86/$1"
99 x86_args="$x86_args $1"
103 $GCC_COMPILE_X86 $x86_args || exit $?
104 if test x"$output" != x; then
105 cp $output x86/$output
108 if test x"$output" != x; then
109 lipo -create -o $output ppc/$output x86/$output