3 # Attempt to build a universal library for OSX
6 dp
="$(xcode-select -print-path 2>/dev/null)"
9 gc40
="$(type -P gcc-4.0 2>/dev/null)"
10 gc42
="$(type -P gcc-4.2 2>/dev/null)"
11 mp42
="$(type -P gcc-apple-4.2 2>/dev/null)"
12 lv42
="$(type -P llvm-gcc-4.2 2>/dev/null)"
15 if [ -n "$gc42" ]; then
17 elif [ -n "$mp42" ]; then
19 elif [ -n "$lv42" ]; then
22 if [ -n "$gc40" ]; then
24 elif [ -n "$gca2" ]; then
28 if [ -d "$dp/SDKs" ]; then
29 # First see if 10.4u is available and gcc-4.0
30 if [ -z "$done" -a -r "$dp/SDKs/MacOSX10.4u.sdk/SDKSettings.plist" -a -n "$gc40" ]; then
33 NEWCFLAGS
="-arch x86_64 -arch ppc64 -arch i386 -arch ppc"
34 NEWCFLAGS
="$NEWCFLAGS -isysroot$dp/SDKs/MacOSX10.4u.sdk"
36 # Or see if 10.5 is available, any compiler will do
37 if [ -z "$done" -a -r "$dp/SDKs/MacOSX10.5.sdk/SDKSettings.plist" -a -n "$gca0" ]; then
40 NEWCFLAGS
="-arch x86_64 -arch ppc64 -arch i386 -arch ppc"
41 NEWCFLAGS
="$NEWCFLAGS -isysroot$dp/SDKs/MacOSX10.5.sdk"
43 # Or see if 10.6 is available, any 4.2 compiler will do
44 if [ -z "$done" -a -r "$dp/SDKs/MacOSX10.6.sdk/SDKSettings.plist" -a -n "$gca2" ]; then
47 NEWCFLAGS
="-arch x86_64 -arch i386 -arch ppc"
48 NEWCFLAGS
="$NEWCFLAGS -isysroot$dp/SDKs/MacOSX10.6.sdk"
50 # Or see if 10.7 is available, any 4.2 compiler will do
51 if [ -z "$done" -a -r "$dp/SDKs/MacOSX10.7.sdk/SDKSettings.plist" -a -n "$gca2" ]; then
54 NEWCFLAGS
="-arch x86_64 -arch i386"
55 NEWCFLAGS
="$NEWCFLAGS -isysroot$dp/SDKs/MacOSX10.7.sdk"
58 if [ -z "$done" ]; then
59 # Select by OS version as we have no SDKs
60 dv
="$(sysctl -n kern.osrelease 2>/dev/null | cut -d. -f1 2>/dev/null)"
61 if [ -z "$done" -a "$dv" = "8" ]; then
65 # Tiger's system libraries are not guaranteed to be universal
67 if [ -z "$done" -a "$dv" = "9" ]; then
71 NEWCFLAGS
="-arch x86_64 -arch ppc64 -arch i386 -arch ppc"
73 if [ -z "$done" -a "$dv" = "10" ]; then
77 NEWCFLAGS
="-arch x86_64 -arch i386 -arch ppc"
79 if [ -z "$done" -a "$dv" = "11" ]; then
83 NEWCFLAGS
="-arch x86_64 -arch i386"
86 if [ -n "$NEWCC" -a -z "$CC" ]; then
89 if [ -n "$done" ]; then
90 if [ -z "$MACOSX_DEPLOYMENT_TARGET" ]; then
91 export MACOSX_DEPLOYMENT_TARGET
=10.4
94 if [ -n "$NEWCFLAGS" ]; then
95 if [ -z "$CFLAGS" ]; then
96 export CFLAGS
="-O2 $NEWCFLAGS"
98 export CFLAGS
="$CFLAGS $NEWCFLAGS"
101 build
="$(dirname "$0")/buildlib"
102 if [ -n "$MACOSX_DEPLOYMENT_TARGET" ]; then
103 echo "MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET"