comparison build-scripts/fatbuild.sh @ 1648:9f59d4c5aaea

Mac OS X fat build works! :)
author Sam Lantinga <slouken@libsdl.org>
date Sat, 22 Apr 2006 19:17:14 +0000
parents 7c53bb4b1db4
children 5b0805ceb50f 3a3e847aadb9
comparison
equal deleted inserted replaced
1647:2af911d41a08 1648:9f59d4c5aaea
1 #!/bin/sh 1 #!/bin/sh
2 # 2 #
3 # Build a fat binary on Mac OS X, thanks Ryan! 3 # Build a fat binary on Mac OS X, thanks Ryan!
4 4
5 # PowerPC compiler flags (10.2 runtime compatibility) 5 # PowerPC compiler flags (10.2 runtime compatibility)
6 CFLAGS_PPC="-arch ppc \ 6 CC_PPC="gcc-3.3"
7 CFLAGS_PPC="-arch ppc"
8 CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
9 -nostdinc \
7 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \ 10 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
8 -I/Developer/SDKs/MacOSX10.2.8.sdk/Developer/Headers/FlatCarbon \
9 -DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
10 -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \ 11 -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
11 -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++ \
12 -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin \
13 -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include" 12 -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
14 13
15 # PowerPC linker flags 14 # PowerPC linker flags
16 LFLAGS_PPC="-arch ppc -mmacosx-version-min=10.2 \ 15 LFLAGS_PPC="-arch ppc \
17 -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \ 16 -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
18 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \ 17 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
19 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk" 18 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
20 19
21 # Intel compiler flags (10.4 runtime compatibility) 20 # Intel compiler flags (10.4 runtime compatibility)
22 CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \ 21 CC_X86="gcc-4.0"
23 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" 22 CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4"
23 CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
24 -nostdinc \
25 -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
26 -I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
27 -isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
24 28
25 # Intel linker flags 29 # Intel linker flags
26 LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \ 30 LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
27 -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \ 31 -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \
28 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" 32 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
29 33
30 # 34 #
31 # Find the configure script 35 # Find the configure script
32 # 36 #
33 cd `dirname $0`/.. 37 srcdir=`dirname $0`/..
38 auxdir=$srcdir/build-scripts
39 cd $srcdir
34 40
35 # 41 #
36 # Figure out which phase to build: 42 # Figure out which phase to build:
37 # all, 43 # all,
38 # configure, configure-ppc, configure-x86, 44 # configure, configure-ppc, configure-x86,
74 ;; 80 ;;
75 merge) 81 merge)
76 merge="yes" 82 merge="yes"
77 ;; 83 ;;
78 install) 84 install)
79 make_x86="yes" 85 install_bin="yes"
86 install_hdrs="yes"
87 install_lib="yes"
88 install_data="yes"
89 install_man="yes"
90 ;;
91 install-bin)
92 install_bin="yes"
93 ;;
94 install-hdrs)
95 install_hdrs="yes"
96 ;;
97 install-lib)
98 install_lib="yes"
99 ;;
100 install-data)
101 install_data="yes"
102 ;;
103 install-man)
104 install_man="yes"
105 ;;
106 *)
107 echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge]"
108 exit 1
109 ;;
110 esac
111 case `uname -p` in
112 powerpc)
113 native_path=ppc
114 ;;
115 *86)
116 native_path=x86
117 ;;
118 *)
119 echo "Couldn't figure out native architecture path"
120 exit 1
80 ;; 121 ;;
81 esac 122 esac
82 123
83 # 124 #
84 # Create the build directories 125 # Create the build directories
94 # 135 #
95 # Build the PowerPC binary 136 # Build the PowerPC binary
96 # 137 #
97 if test x$configure_ppc = xyes; then 138 if test x$configure_ppc = xyes; then
98 (cd build/ppc && \ 139 (cd build/ppc && \
99 sh ../../configure CFLAGS="$CFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2 140 sh ../../configure --build=`uname -p`-apple-darwin --host=powerpc-apple-darwin CC="$CC_PPC" CFLAGS="$CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
100 fi 141 fi
101 if test x$make_ppc = xyes; then 142 if test x$make_ppc = xyes; then
102 (cd build/ppc && make) || exit 3 143 (cd build/ppc && make) || exit 3
103 fi 144 fi
104 145
105 # 146 #
106 # Build the Intel binary 147 # Build the Intel binary
107 # 148 #
108 if test x$configure_x86 = xyes; then 149 if test x$configure_x86 = xyes; then
109 (cd build/x86 && \ 150 (cd build/x86 && \
110 sh ../../configure CFLAGS="$CFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2 151 sh ../../configure --build=`uname -p`-apple-darwin --host=i686-apple-darwin CC="$CC_X86" CFLAGS="$CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
111 fi 152 fi
112 if test x$make_x86 = xyes; then 153 if test x$make_x86 = xyes; then
113 (cd build/x86 && make) || exit 3 154 (cd build/x86 && make) || exit 3
114 fi 155 fi
115 156
116 # 157 #
117 # Combine into fat binary 158 # Combine into fat binary
118 # 159 #
119 target=`find x86 -type f -name '*.dylib' | sed 's|.*/||'`
120 if test x$merge = xyes; then 160 if test x$merge = xyes; then
121 (cd build && \ 161 output=.libs
122 lipo -create -o $target `find ppc x86 -type f -name "*.dylib"` && 162 sh $auxdir/mkinstalldirs build/$output
123 ln -s $target libSDL-1.2.0.dylib 163 cd build
124 ln -s $target libSDL.dylib 164 target=`find . -mindepth 3 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
125 lipo -create -o SDLMain.o */build/SDLMain.o && 165 (lipo -create -o $output/$target `find . -mindepth 3 -type f -name "*.dylib"` &&
126 ar cru libSDLmain.a SDLMain.o && ranlib libSDLmain.a && 166 ln -sf $target $output/libSDL-1.2.0.dylib &&
167 ln -sf $target $output/libSDL.dylib &&
168 lipo -create -o $output/libSDL.a */build/.libs/libSDL.a &&
169 cp $native_path/build/.libs/libSDL.la $output &&
170 cp $native_path/build/.libs/libSDL.lai $output &&
171 cp $native_path/build/libSDL.la . &&
172 lipo -create -o libSDLmain.a */build/libSDLmain.a &&
127 echo "Build complete!" && 173 echo "Build complete!" &&
128 echo "Files can be found in the build directory.") || exit 4 174 echo "Files can be found in the build directory.") || exit 4
175 cd ..
129 fi 176 fi
130 177
131 # 178 #
132 # Install 179 # Install
133 # 180 #
134 if test x$install = xyes; then 181 do_install()
135 echo "Install not implemented" 182 {
136 exit 1 183 echo $*
137 fi 184 $* || exit 5
185 }
186 if test x$prefix = x; then
187 prefix=/usr/local
188 fi
189 if test x$exec_prefix = x; then
190 exec_prefix=$prefix
191 fi
192 if test x$bindir = x; then
193 bindir=$exec_prefix/bin
194 fi
195 if test x$libdir = x; then
196 libdir=$exec_prefix/lib
197 fi
198 if test x$includedir = x; then
199 includedir=$prefix/include
200 fi
201 if test x$datadir = x; then
202 datadir=$prefix/share
203 fi
204 if test x$mandir = x; then
205 mandir=$prefix/man
206 fi
207 if test x$install_bin = xyes; then
208 do_install sh $auxdir/mkinstalldirs $bindir
209 do_install /usr/bin/install -c -m 755 build/$native_path/sdl-config $bindir/sdl-config
210 fi
211 if test x$install_hdrs = xyes; then
212 do_install sh $auxdir/mkinstalldirs $includedir/SDL
213 for src in $srcdir/include/*.h; do \
214 file=`echo $src | sed -e 's|^.*/||'`; \
215 do_install /usr/bin/install -c -m 644 $src $includedir/SDL/$file; \
216 done
217 do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL/SDL_config.h
218 fi
219 if test x$install_lib = xyes; then
220 do_install sh $auxdir/mkinstalldirs $libdir
221 do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c build/libSDL.la $libdir/libSDL.la
222 do_install /usr/bin/install -c -m 644 build/libSDLmain.a $libdir/libSDLmain.a
223 do_install ranlib $libdir/libSDLmain.a
224 fi
225 if test x$install_data = xyes; then
226 do_install sh $auxdir/mkinstalldirs $datadir/aclocal
227 do_install /usr/bin/install -c -m 644 $srcdir/sdl.m4 $datadir/aclocal/sdl.m4
228 fi
229 if test x$install_man = xyes; then
230 do_install sh $auxdir/mkinstalldirs $mandir/man3
231 for src in $srcdir/docs/man3/*.3; do \
232 file=`echo $src | sed -e 's|^.*/||'`; \
233 do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
234 done
235 fi