forked from mackyle/blocksruntime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildlib-osx
executable file
·108 lines (102 loc) · 2.85 KB
/
buildlib-osx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
# Attempt to build a universal library for OSX
set -e
done=
dp="$(xcode-select -print-path 2>/dev/null)"
: "${dp:=/Developer}"
gc40="$(command -v gcc-4.0 2>/dev/null)"
gc42="$(command -v gcc-4.2 2>/dev/null)"
mp42="$(command -v gcc-apple-4.2 2>/dev/null)"
lv42="$(command -v llvm-gcc-4.2 2>/dev/null)"
gca0=
gca2=
if [ -n "$gc42" ]; then
gca2="$gc42"
elif [ -n "$mp42" ]; then
gca2="$mp42"
elif [ -n "$lv42" ]; then
gca2="$lv42"
fi
if [ -n "$gc40" ]; then
gca0="$gc40"
elif [ -n "$gca2" ]; then
gca0="$gca2"
fi
if [ -d "$dp/SDKs" ]; then
# First see if 10.4u is available and gcc-4.0
if [ -z "$done" -a -r "$dp/SDKs/MacOSX10.4u.sdk/SDKSettings.plist" -a -n "$gc40" ]; then
done=1
NEWCC="$gc40"
NEWCFLAGS="-arch x86_64 -arch ppc64 -arch i386 -arch ppc"
NEWCFLAGS="$NEWCFLAGS -isysroot$dp/SDKs/MacOSX10.4u.sdk"
fi
# Or see if 10.5 is available, any compiler will do
if [ -z "$done" -a -r "$dp/SDKs/MacOSX10.5.sdk/SDKSettings.plist" -a -n "$gca0" ]; then
done=1
NEWCC="$gca0"
NEWCFLAGS="-arch x86_64 -arch ppc64 -arch i386 -arch ppc"
NEWCFLAGS="$NEWCFLAGS -isysroot$dp/SDKs/MacOSX10.5.sdk"
fi
# Or see if 10.6 is available, any 4.2 compiler will do
if [ -z "$done" -a -r "$dp/SDKs/MacOSX10.6.sdk/SDKSettings.plist" -a -n "$gca2" ]; then
done=1
NEWCC="$gca2"
NEWCFLAGS="-arch x86_64 -arch i386 -arch ppc"
NEWCFLAGS="$NEWCFLAGS -isysroot$dp/SDKs/MacOSX10.6.sdk"
fi
# Or see if 10.7 is available, any 4.2 compiler will do
if [ -z "$done" -a -r "$dp/SDKs/MacOSX10.7.sdk/SDKSettings.plist" -a -n "$gca2" ]; then
done=1
NEWCC="$gca2"
NEWCFLAGS="-arch x86_64 -arch i386"
NEWCFLAGS="$NEWCFLAGS -isysroot$dp/SDKs/MacOSX10.7.sdk"
fi
fi
if [ -z "$done" ]; then
# Select by OS version as we have no SDKs
dv="$(sysctl -n kern.osrelease 2>/dev/null | cut -d. -f1 2>/dev/null)"
if [ -z "$done" -a "$dv" = "8" ]; then
# Tiger 10.4.x
done=1
NEWCC="$gca0"
# Tiger's system libraries are not guaranteed to be universal
fi
if [ -z "$done" -a "$dv" = "9" ]; then
# Leopard 10.5.x
done=1
NEWCC="$gca0"
NEWCFLAGS="-arch x86_64 -arch ppc64 -arch i386 -arch ppc"
fi
if [ -z "$done" -a "$dv" = "10" ]; then
# Snow Leopard 10.6.x
done=1
NEWCC="$gca2"
NEWCFLAGS="-arch x86_64 -arch i386 -arch ppc"
fi
if [ -z "$done" -a "$dv" = "11" ]; then
# Lion 10.7.x
done=1
NEWCC="$gca2"
NEWCFLAGS="-arch x86_64 -arch i386"
fi
fi
if [ -n "$NEWCC" -a -z "$CC" ]; then
CC="$NEWCC" && export CC
fi
if [ -n "$done" ]; then
if [ -z "$MACOSX_DEPLOYMENT_TARGET" ]; then
MACOSX_DEPLOYMENT_TARGET=10.4 && export MACOSX_DEPLOYMENT_TARGET
fi
fi
if [ -n "$NEWCFLAGS" ]; then
if [ -z "$CFLAGS" ]; then
CFLAGS="-O2 $NEWCFLAGS" && export CFLAGS
else
CFLAGS="$CFLAGS $NEWCFLAGS" && export CFLAGS
fi
fi
build="$(dirname "$0")/buildlib"
if [ -n "$MACOSX_DEPLOYMENT_TARGET" ]; then
echo "MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET"
fi
exec "$build" "$@"