annotate test/gcc-fat.sh @ 2173:26233707bc94

indent
author Sam Lantinga <slouken@libsdl.org>
date Wed, 11 Jul 2007 14:51:49 +0000
parents 783b9409baa0
children 6cb18cf1777e
rev   line source
1797
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 #!/bin/sh
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 #
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 # Build Universal binaries on Mac OS X, thanks Ryan!
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 #
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 # Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf ppc x86
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 # PowerPC compiler flags (10.2 runtime compatibility)
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 GCC_COMPILE_PPC="gcc-3.3 -arch ppc \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 -DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 -nostdinc \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 GCC_LINK_PPC="\
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 # Intel compiler flags (10.4 runtime compatibility)
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 GCC_COMPILE_X86="gcc-4.0 -arch i386 -mmacosx-version-min=10.4 \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 -nostdinc \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 -I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 -isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 GCC_LINK_X86="\
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 # Output both PowerPC and Intel object files
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 args="$*"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 compile=yes
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 link=yes
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 while test x$1 != x; do
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 case $1 in
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 --version) exec gcc $1;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 -v) exec gcc $1;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 -V) exec gcc $1;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 -print-prog-name=*) exec gcc $1;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 -print-search-dirs) exec gcc $1;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 -E) GCC_COMPILE_PPC="$GCC_COMPILE_PPC -E"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 compile=no; link=no;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 -c) link=no;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 -o) output=$2;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 *.c|*.cc|*.cpp|*.S) source=$1;;
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 esac
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 shift
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 done
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 if test x$link = xyes; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 GCC_COMPILE_PPC="$GCC_COMPILE_PPC $GCC_LINK_PPC"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 if test x"$output" = x; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 if test x$link = xyes; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 output=a.out
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 elif test x$compile = xyes; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 if test x"$output" != x; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 dir=ppc/`dirname $output`
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 if test -d $dir; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 :
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 else
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 mkdir -p $dir
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 set -- $args
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 while test x$1 != x; do
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 if test -f "ppc/$1" && test "$1" != "$output"; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 ppc_args="$ppc_args ppc/$1"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 else
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 ppc_args="$ppc_args $1"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 shift
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 done
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 $GCC_COMPILE_PPC $ppc_args || exit $?
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 if test x"$output" != x; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 cp $output ppc/$output
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 if test x"$output" != x; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 dir=x86/`dirname $output`
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 if test -d $dir; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 :
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 else
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 mkdir -p $dir
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 set -- $args
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 while test x$1 != x; do
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 if test -f "x86/$1" && test "$1" != "$output"; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 x86_args="$x86_args x86/$1"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 else
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 x86_args="$x86_args $1"
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 shift
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 done
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 $GCC_COMPILE_X86 $x86_args || exit $?
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 if test x"$output" != x; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 cp $output x86/$output
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 fi
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 if test x"$output" != x; then
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 lipo -create -o $output ppc/$output x86/$output
783b9409baa0 Fat test programs! :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 fi