Skip to content

Latest commit

 

History

History
executable file
·
316 lines (293 loc) · 8.32 KB

fatbuild.sh

File metadata and controls

executable file
·
316 lines (293 loc) · 8.32 KB
 
1
2
3
4
#!/bin/sh
#
# Build a fat binary on Mac OS X, thanks Ryan!
Apr 27, 2006
Apr 27, 2006
5
6
# Number of CPUs (for make -j)
NCPU=`sysctl -n hw.ncpu`
Apr 28, 2006
Apr 28, 2006
7
8
NJOB=$NCPU
#NJOB=`expr $NCPU + 1`
Apr 27, 2006
Apr 27, 2006
9
10
11
12
# Generic, cross-platform CFLAGS you always want go here.
CFLAGS="-O3 -g -pipe"
Dec 29, 2007
Dec 29, 2007
13
14
15
16
17
18
19
20
21
22
23
24
# Locate Xcode SDK path
SDK_PATH=/Developer/SDKs
if [ ! -d $SDK_PATH ]; then
echo "Couldn't find SDK path"
exit 1
fi
# See if we can use 10.2 or 10.3 runtime compatibility
if [ -d "$SDK_PATH/MacOSX10.2.8.sdk" ]; then
# PowerPC configure flags (10.2 runtime compatibility)
# We dynamically load X11, so using the system X11 headers is fine.
CONFIG_PPC="--build=`uname -p`-apple-darwin --host=powerpc-apple-darwin \
May 10, 2006
May 10, 2006
25
26
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
Dec 29, 2007
Dec 29, 2007
27
28
29
30
31
# PowerPC compiler flags
CC_PPC="gcc-3.3 -arch ppc"
CXX_PPC="g++-3.3 -arch ppc"
CFLAGS_PPC=""
CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
Apr 22, 2006
Apr 22, 2006
32
-nostdinc \
Dec 29, 2007
Dec 29, 2007
33
34
35
36
37
-F$SDK_PATH/MacOSX10.2.8.sdk/System/Library/Frameworks \
-I$SDK_PATH/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
-isystem $SDK_PATH/MacOSX10.2.8.sdk/usr/include"
# PowerPC linker flags
Jul 25, 2008
Jul 25, 2008
38
LFLAGS_PPC="-Wl,-headerpad_max_install_names -arch ppc \
Dec 29, 2007
Dec 29, 2007
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-L$SDK_PATH/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
-F$SDK_PATH/MacOSX10.2.8.sdk/System/Library/Frameworks \
-Wl,-syslibroot,$SDK_PATH/MacOSX10.2.8.sdk"
else # 10.2 or 10.3 SDK
# PowerPC configure flags (10.3 runtime compatibility)
# We dynamically load X11, so using the system X11 headers is fine.
CONFIG_PPC="--build=`uname -p`-apple-darwin --host=powerpc-apple-darwin \
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
# PowerPC compiler flags
CC_PPC="gcc-4.0 -arch ppc"
CXX_PPC="g++-4.0 -arch ppc"
CFLAGS_PPC=""
CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1030 \
-nostdinc \
-F$SDK_PATH/MacOSX10.3.9.sdk/System/Library/Frameworks \
-I$SDK_PATH/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1/include \
-isystem $SDK_PATH/MacOSX10.3.9.sdk/usr/include"
# PowerPC linker flags
Jul 25, 2008
Jul 25, 2008
61
LFLAGS_PPC="-Wl,-headerpad_max_install_names -arch ppc -mmacosx-version-min=10.3 \
Dec 29, 2007
Dec 29, 2007
62
63
64
-L$SDK_PATH/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1 \
-F$SDK_PATH/MacOSX10.3.9.sdk/System/Library/Frameworks \
-Wl,-syslibroot,$SDK_PATH/MacOSX10.3.9.sdk"
Dec 29, 2007
Dec 29, 2007
66
fi # 10.2 or 10.3 SDK
May 10, 2006
May 10, 2006
68
69
70
71
72
73
# Intel configure flags (10.4 runtime compatibility)
# We dynamically load X11, so using the system X11 headers is fine.
CONFIG_X86="--build=`uname -p`-apple-darwin --host=i386-apple-darwin \
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
# Intel compiler flags
Apr 27, 2006
Apr 27, 2006
74
CC_X86="gcc-4.0 -arch i386"
Apr 28, 2006
Apr 28, 2006
75
CXX_X86="g++-4.0 -arch i386"
Apr 27, 2006
Apr 27, 2006
76
CFLAGS_X86="-mmacosx-version-min=10.4"
Apr 22, 2006
Apr 22, 2006
77
CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
Apr 28, 2006
Apr 28, 2006
78
-nostdinc \
Dec 29, 2007
Dec 29, 2007
79
80
81
-F$SDK_PATH/MacOSX10.4u.sdk/System/Library/Frameworks \
-I$SDK_PATH/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include \
-isystem $SDK_PATH/MacOSX10.4u.sdk/usr/include"
82
83
# Intel linker flags
Jul 25, 2008
Jul 25, 2008
84
LFLAGS_X86="-Wl,-headerpad_max_install_names -arch i386 -mmacosx-version-min=10.4 \
Dec 29, 2007
Dec 29, 2007
85
86
-L$SDK_PATH/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1 \
-Wl,-syslibroot,$SDK_PATH/MacOSX10.4u.sdk"
87
88
89
90
#
# Find the configure script
#
Apr 22, 2006
Apr 22, 2006
91
92
93
srcdir=`dirname $0`/..
auxdir=$srcdir/build-scripts
cd $srcdir
94
95
96
97
98
99
100
#
# Figure out which phase to build:
# all,
# configure, configure-ppc, configure-x86,
# make, make-ppc, make-x86, merge
# install
Apr 27, 2006
Apr 27, 2006
101
# clean
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
if test x"$1" = x; then
phase=all
else
phase="$1"
fi
case $phase in
all)
configure_ppc="yes"
configure_x86="yes"
make_ppc="yes"
make_x86="yes"
merge="yes"
;;
configure)
configure_ppc="yes"
configure_x86="yes"
;;
configure-ppc)
configure_ppc="yes"
;;
configure-x86)
configure_x86="yes"
;;
make)
make_ppc="yes"
make_x86="yes"
merge="yes"
;;
make-ppc)
make_ppc="yes"
;;
make-x86)
make_x86="yes"
;;
merge)
merge="yes"
;;
install)
Apr 22, 2006
Apr 22, 2006
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
install_bin="yes"
install_hdrs="yes"
install_lib="yes"
install_data="yes"
install_man="yes"
;;
install-bin)
install_bin="yes"
;;
install-hdrs)
install_hdrs="yes"
;;
install-lib)
install_lib="yes"
;;
install-data)
install_data="yes"
;;
install-man)
install_man="yes"
;;
Apr 27, 2006
Apr 27, 2006
161
162
163
164
165
166
167
168
169
170
clean)
clean_ppc="yes"
clean_x86="yes"
;;
clean-ppc)
clean_ppc="yes"
;;
clean-x86)
clean_x86="yes"
;;
Apr 22, 2006
Apr 22, 2006
171
*)
Apr 27, 2006
Apr 27, 2006
172
echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge|install|clean]"
Apr 22, 2006
Apr 22, 2006
173
174
175
176
177
178
179
180
181
182
183
184
185
exit 1
;;
esac
case `uname -p` in
powerpc)
native_path=ppc
;;
*86)
native_path=x86
;;
*)
echo "Couldn't figure out native architecture path"
exit 1
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
;;
esac
#
# Create the build directories
#
for dir in build build/ppc build/x86; do
if test -d $dir; then
:
else
mkdir $dir || exit 1
fi
done
#
# Build the PowerPC binary
#
if test x$configure_ppc = xyes; then
(cd build/ppc && \
May 10, 2006
May 10, 2006
205
sh ../../configure $CONFIG_PPC CC="$CC_PPC" CXX="$CXX_PPC" CFLAGS="$CFLAGS $CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
206
207
fi
if test x$make_ppc = xyes; then
Apr 28, 2006
Apr 28, 2006
208
(cd build/ppc && ls include && make -j$NJOB) || exit 3
209
210
211
212
213
214
215
fi
#
# Build the Intel binary
#
if test x$configure_x86 = xyes; then
(cd build/x86 && \
May 10, 2006
May 10, 2006
216
sh ../../configure $CONFIG_X86 CC="$CC_X86" CXX="$CXX_X86" CFLAGS="$CFLAGS $CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
217
218
fi
if test x$make_x86 = xyes; then
Apr 28, 2006
Apr 28, 2006
219
(cd build/x86 && make -j$NJOB) || exit 3
220
221
222
223
224
225
fi
#
# Combine into fat binary
#
if test x$merge = xyes; then
Apr 22, 2006
Apr 22, 2006
226
227
228
229
230
231
232
233
234
235
236
237
output=.libs
sh $auxdir/mkinstalldirs build/$output
cd build
target=`find . -mindepth 3 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
(lipo -create -o $output/$target `find . -mindepth 3 -type f -name "*.dylib"` &&
ln -sf $target $output/libSDL-1.2.0.dylib &&
ln -sf $target $output/libSDL.dylib &&
lipo -create -o $output/libSDL.a */build/.libs/libSDL.a &&
cp $native_path/build/.libs/libSDL.la $output &&
cp $native_path/build/.libs/libSDL.lai $output &&
cp $native_path/build/libSDL.la . &&
lipo -create -o libSDLmain.a */build/libSDLmain.a &&
238
239
echo "Build complete!" &&
echo "Files can be found in the build directory.") || exit 4
Apr 22, 2006
Apr 22, 2006
240
cd ..
241
242
243
244
245
fi
#
# Install
#
Apr 22, 2006
Apr 22, 2006
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
do_install()
{
echo $*
$* || exit 5
}
if test x$prefix = x; then
prefix=/usr/local
fi
if test x$exec_prefix = x; then
exec_prefix=$prefix
fi
if test x$bindir = x; then
bindir=$exec_prefix/bin
fi
if test x$libdir = x; then
libdir=$exec_prefix/lib
fi
if test x$includedir = x; then
includedir=$prefix/include
fi
if test x$datadir = x; then
datadir=$prefix/share
fi
if test x$mandir = x; then
mandir=$prefix/man
fi
if test x$install_bin = xyes; then
do_install sh $auxdir/mkinstalldirs $bindir
do_install /usr/bin/install -c -m 755 build/$native_path/sdl-config $bindir/sdl-config
fi
if test x$install_hdrs = xyes; then
do_install sh $auxdir/mkinstalldirs $includedir/SDL
for src in $srcdir/include/*.h; do \
file=`echo $src | sed -e 's|^.*/||'`; \
do_install /usr/bin/install -c -m 644 $src $includedir/SDL/$file; \
done
do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL/SDL_config.h
fi
if test x$install_lib = xyes; then
do_install sh $auxdir/mkinstalldirs $libdir
do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c build/libSDL.la $libdir/libSDL.la
do_install /usr/bin/install -c -m 644 build/libSDLmain.a $libdir/libSDLmain.a
do_install ranlib $libdir/libSDLmain.a
fi
if test x$install_data = xyes; then
do_install sh $auxdir/mkinstalldirs $datadir/aclocal
do_install /usr/bin/install -c -m 644 $srcdir/sdl.m4 $datadir/aclocal/sdl.m4
fi
if test x$install_man = xyes; then
do_install sh $auxdir/mkinstalldirs $mandir/man3
for src in $srcdir/docs/man3/*.3; do \
file=`echo $src | sed -e 's|^.*/||'`; \
do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
done
Apr 27, 2006
Apr 27, 2006
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#
# Clean up
#
do_clean()
{
echo $*
$* || exit 6
}
if test x$clean_x86 = xyes; then
do_clean rm -r build/x86
fi
if test x$clean_ppc = xyes; then
do_clean rm -r build/ppc
fi