Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
executable file
·
296 lines (279 loc) · 7.02 KB

fatbuild.sh

File metadata and controls

executable file
·
296 lines (279 loc) · 7.02 KB
 
Jun 22, 2011
Jun 22, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
#
# Build a fat binary on Mac OS X, thanks Ryan!
# Number of CPUs (for make -j)
NCPU=`sysctl -n hw.ncpu`
if test x$NJOB = x; then
NJOB=$NCPU
fi
# SDK path
if test x$SDK_PATH = x; then
SDK_PATH=/Developer/SDKs
fi
# Generic, cross-platform CFLAGS you always want go here.
CFLAGS="-O3 -g -pipe"
# We dynamically load X11, so using the system X11 headers is fine.
Sep 19, 2011
Sep 19, 2011
20
BASE_CONFIG_FLAGS="--build=`uname -p`-apple-darwin \
Jun 22, 2011
Jun 22, 2011
21
22
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
Sep 19, 2011
Sep 19, 2011
23
24
25
26
27
# PowerPC 32-bit compiler flags
CONFIG_PPC="--host=powerpc-apple-darwin"
CC_PPC="gcc-4.0"
CXX_PPC="g++-4.0"
BUILD_FLAGS_PPC="-arch ppc -mmacosx-version-min=10.4"
Jun 22, 2011
Jun 22, 2011
28
29
# Intel 32-bit compiler flags
Sep 19, 2011
Sep 19, 2011
30
31
32
33
CONFIG_X86="--host=i386-apple-darwin"
CC_X86="gcc"
CXX_X86="g++"
BUILD_FLAGS_X86="-arch i386 -mmacosx-version-min=10.4"
Jun 22, 2011
Jun 22, 2011
34
35
# Intel 64-bit compiler flags
Sep 19, 2011
Sep 19, 2011
36
37
38
39
CONFIG_X64="--host=x86_64-apple-darwin"
CC_X64="gcc"
CXX_X64="g++"
BUILD_FLAGS_X64="-arch x86_64 -mmacosx-version-min=10.6"
Jun 22, 2011
Jun 22, 2011
40
41
42
43
44
#
# Find the configure script
#
srcdir=`dirname $0`/..
Oct 20, 2011
Oct 20, 2011
45
srcdir=`cd $srcdir && pwd`
Jun 22, 2011
Jun 22, 2011
46
47
48
auxdir=$srcdir/build-scripts
cd $srcdir
Sep 19, 2011
Sep 19, 2011
49
50
51
52
53
54
55
56
allow_ppc="yes"
which gcc-4.0 >/dev/null 2>/dev/null
if [ "x$?" = "x1" ]; then
#echo "WARNING: Can't find gcc-4.0, which means you don't have Xcode 3."
#echo "WARNING: Therefore, we can't do PowerPC support."
allow_ppc="no"
fi
Jun 22, 2011
Jun 22, 2011
57
58
59
#
# Figure out which phase to build:
# all,
Sep 19, 2011
Sep 19, 2011
60
61
# configure, configure-ppc, configure-x86, configure-x64
# make, make-ppc, make-x86, make-x64, merge
Jun 22, 2011
Jun 22, 2011
62
63
64
65
66
67
68
69
70
# install
# clean
if test x"$1" = x; then
phase=all
else
phase="$1"
fi
case $phase in
all)
Sep 19, 2011
Sep 19, 2011
71
configure_ppc="$allow_ppc"
Jun 22, 2011
Jun 22, 2011
72
73
configure_x86="yes"
configure_x64="yes"
Sep 19, 2011
Sep 19, 2011
74
make_ppc="$allow_ppc"
Jun 22, 2011
Jun 22, 2011
75
76
77
78
79
make_x86="yes"
make_x64="yes"
merge="yes"
;;
configure)
Sep 19, 2011
Sep 19, 2011
80
configure_ppc="$allow_ppc"
Jun 22, 2011
Jun 22, 2011
81
82
83
configure_x86="yes"
configure_x64="yes"
;;
Sep 19, 2011
Sep 19, 2011
84
85
86
configure-ppc)
configure_ppc="$allow_ppc"
;;
Jun 22, 2011
Jun 22, 2011
87
88
89
90
91
92
93
configure-x86)
configure_x86="yes"
;;
configure-x64)
configure_x64="yes"
;;
make)
Sep 19, 2011
Sep 19, 2011
94
make_ppc="$allow_ppc"
Jun 22, 2011
Jun 22, 2011
95
96
97
98
make_x86="yes"
make_x64="yes"
merge="yes"
;;
Sep 19, 2011
Sep 19, 2011
99
100
101
make-ppc)
make_ppc="$allow_ppc"
;;
Jun 22, 2011
Jun 22, 2011
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
make-x86)
make_x86="yes"
;;
make-x64)
make_x64="yes"
;;
merge)
merge="yes"
;;
install)
install_bin="yes"
install_hdrs="yes"
install_lib="yes"
install_data="yes"
;;
install-bin)
install_bin="yes"
;;
install-hdrs)
install_hdrs="yes"
;;
install-lib)
install_lib="yes"
;;
install-data)
install_data="yes"
;;
clean)
Sep 19, 2011
Sep 19, 2011
130
clean_ppc="yes"
Jun 22, 2011
Jun 22, 2011
131
132
133
clean_x86="yes"
clean_x64="yes"
;;
Sep 19, 2011
Sep 19, 2011
134
135
136
clean-ppc)
clean_ppc="yes"
;;
Jun 22, 2011
Jun 22, 2011
137
138
139
140
141
142
143
clean-x86)
clean_x86="yes"
;;
clean-x64)
clean_x64="yes"
;;
*)
Sep 19, 2011
Sep 19, 2011
144
echo "Usage: $0 [all|configure[-ppc|-x86|-x64]|make[-ppc|-x86|-x64]|merge|install|clean[-ppc|-x86|-x64]]"
Jun 22, 2011
Jun 22, 2011
145
146
147
148
149
150
151
exit 1
;;
esac
case `uname -p` in
*86)
native_path=x86
;;
Sep 19, 2011
Sep 19, 2011
152
153
154
*powerpc)
native_path=ppc
;;
Jun 22, 2011
Jun 22, 2011
155
156
157
158
159
160
161
162
163
164
165
166
x86_64)
native_path=x64
;;
*)
echo "Couldn't figure out native architecture path"
exit 1
;;
esac
#
# Create the build directories
#
Sep 19, 2011
Sep 19, 2011
167
for dir in build build/ppc build/x86 build/x64; do
Jun 22, 2011
Jun 22, 2011
168
169
170
171
172
173
174
if test -d $dir; then
:
else
mkdir $dir || exit 1
fi
done
Sep 19, 2011
Sep 19, 2011
175
176
177
178
179
180
181
182
183
184
185
#
# Build the PowerPC 32-bit binary
#
if test x$configure_ppc = xyes; then
(cd build/ppc && \
sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_PPC CC="$CC_PPC" CXX="$CXX_PPC" CFLAGS="$CFLAGS $BUILD_FLAGS_PPC $CFLAGS_PPC" LDFLAGS="$BUILD_FLAGS_PPC $LFLAGS_PPC") || exit 2
fi
if test x$make_ppc = xyes; then
(cd build/ppc && make -j$NJOB) || exit 3
fi
Jun 22, 2011
Jun 22, 2011
186
187
188
189
190
#
# Build the Intel 32-bit binary
#
if test x$configure_x86 = xyes; then
(cd build/x86 && \
Sep 19, 2011
Sep 19, 2011
191
sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_X86 CC="$CC_X86" CXX="$CXX_X86" CFLAGS="$CFLAGS $BUILD_FLAGS_X86 $CFLAGS_X86" LDFLAGS="$BUILD_FLAGS_X86 $LFLAGS_X86") || exit 2
Jun 22, 2011
Jun 22, 2011
192
193
194
195
196
197
fi
if test x$make_x86 = xyes; then
(cd build/x86 && make -j$NJOB) || exit 3
fi
#
Sep 19, 2011
Sep 19, 2011
198
# Build the Intel 64-bit binary
Jun 22, 2011
Jun 22, 2011
199
200
201
#
if test x$configure_x64 = xyes; then
(cd build/x64 && \
Sep 19, 2011
Sep 19, 2011
202
sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_X64 CC="$CC_X64" CXX="$CXX_X64" CFLAGS="$CFLAGS $BUILD_FLAGS_X64 $CFLAGS_X64" LDFLAGS="$BUILD_FLAGS_X64 $LFLAGS_X64") || exit 2
Jun 22, 2011
Jun 22, 2011
203
204
205
206
207
208
209
210
211
212
213
214
215
216
fi
if test x$make_x64 = xyes; then
(cd build/x64 && make -j$NJOB) || exit 3
fi
#
# Combine into fat binary
#
if test x$merge = xyes; then
output=.libs
sh $auxdir/mkinstalldirs build/$output
cd build
target=`find . -mindepth 4 -maxdepth 4 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
(lipo -create -o $output/$target `find . -mindepth 4 -maxdepth 4 -type f -name "*.dylib"` &&
Feb 4, 2012
Feb 4, 2012
217
218
219
220
221
222
ln -sf $target $output/libSDL2.dylib &&
lipo -create -o $output/libSDL2.a */build/.libs/libSDL2.a &&
cp $native_path/build/.libs/libSDL2.la $output &&
cp $native_path/build/.libs/libSDL2.lai $output &&
cp $native_path/build/libSDL2.la . &&
lipo -create -o libSDL2main.a */build/libSDL2main.a &&
Jun 22, 2011
Jun 22, 2011
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
echo "Build complete!" &&
echo "Files can be found in the build directory.") || exit 4
cd ..
fi
#
# Install
#
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
Feb 4, 2012
Feb 4, 2012
259
do_install /usr/bin/install -c -m 755 build/$native_path/sdl2-config $bindir/sdl2-config
Jun 22, 2011
Jun 22, 2011
260
261
fi
if test x$install_hdrs = xyes; then
Feb 4, 2012
Feb 4, 2012
262
do_install sh $auxdir/mkinstalldirs $includedir/SDL2
Jun 22, 2011
Jun 22, 2011
263
264
for src in $srcdir/include/*.h; do \
file=`echo $src | sed -e 's|^.*/||'`; \
Feb 4, 2012
Feb 4, 2012
265
do_install /usr/bin/install -c -m 644 $src $includedir/SDL2/$file; \
Jun 22, 2011
Jun 22, 2011
266
done
Feb 4, 2012
Feb 4, 2012
267
do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL2/SDL_config.h
Jun 22, 2011
Jun 22, 2011
268
269
270
fi
if test x$install_lib = xyes; then
do_install sh $auxdir/mkinstalldirs $libdir
Feb 4, 2012
Feb 4, 2012
271
272
273
do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c build/libSDL2.la $libdir/libSDL2.la
do_install /usr/bin/install -c -m 644 build/libSDL2main.a $libdir/libSDL2main.a
do_install ranlib $libdir/libSDL2main.a
Jun 22, 2011
Jun 22, 2011
274
275
276
fi
if test x$install_data = xyes; then
do_install sh $auxdir/mkinstalldirs $datadir/aclocal
Feb 4, 2012
Feb 4, 2012
277
do_install /usr/bin/install -c -m 644 $srcdir/sdl2.m4 $datadir/aclocal/sdl2.m4
Jun 22, 2011
Jun 22, 2011
278
279
280
281
282
283
284
285
286
287
fi
#
# Clean up
#
do_clean()
{
echo $*
$* || exit 6
}
Sep 19, 2011
Sep 19, 2011
288
289
290
if test x$clean_ppc = xyes; then
do_clean rm -r build/ppc
fi
Jun 22, 2011
Jun 22, 2011
291
292
293
if test x$clean_x86 = xyes; then
do_clean rm -r build/x86
fi
Aug 14, 2011
Aug 14, 2011
294
295
if test x$clean_x64 = xyes; then
do_clean rm -r build/x64
Jun 22, 2011
Jun 22, 2011
296
fi