Navigation Menu

Skip to content

Latest commit

 

History

History
executable file
·
111 lines (103 loc) · 2.95 KB

gcc-fat.sh

File metadata and controls

executable file
·
111 lines (103 loc) · 2.95 KB
 
1
2
3
4
#!/bin/sh
#
# Build Universal binaries on Mac OS X, thanks Ryan!
#
Aug 15, 2011
Aug 15, 2011
5
# Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf x86 x64
Sep 20, 2009
Sep 20, 2009
6
7
# Intel 32-bit compiler flags (10.4 runtime compatibility)
8
9
10
11
GCC_COMPILE_X86="gcc-4.0 -arch i386 -mmacosx-version-min=10.4 \
-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
-nostdinc \
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
Sep 20, 2009
Sep 20, 2009
12
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/include \
13
14
15
-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
GCC_LINK_X86="\
Sep 20, 2009
Sep 20, 2009
16
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1 \
17
18
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
Sep 20, 2009
Sep 20, 2009
19
20
21
22
23
24
25
26
27
28
29
30
# Intel 64-bit compiler flags (10.5 runtime compatibility)
GCC_COMPILE_X64="gcc-4.0 -arch x86_64 -mmacosx-version-min=10.5 \
-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \
-nostdinc \
-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks \
-I/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/include \
-isystem /Developer/SDKs/MacOSX10.5.sdk/usr/include"
GCC_LINK_X64="\
-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/x86_64 \
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
31
32
33
34
35
36
37
38
39
40
41
# Output both PowerPC and Intel object files
args="$*"
compile=yes
link=yes
while test x$1 != x; do
case $1 in
--version) exec gcc $1;;
-v) exec gcc $1;;
-V) exec gcc $1;;
-print-prog-name=*) exec gcc $1;;
-print-search-dirs) exec gcc $1;;
Aug 15, 2011
Aug 15, 2011
42
-E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
Sep 20, 2009
Sep 20, 2009
43
GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
44
45
46
compile=no; link=no;;
-c) link=no;;
-o) output=$2;;
May 1, 2006
May 1, 2006
47
*.c|*.cc|*.cpp|*.S) source=$1;;
48
49
50
51
52
esac
shift
done
if test x$link = xyes; then
GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
Sep 20, 2009
Sep 20, 2009
53
GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
54
55
56
57
58
fi
if test x"$output" = x; then
if test x$link = xyes; then
output=a.out
elif test x$compile = xyes; then
May 1, 2006
May 1, 2006
59
output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
Sep 20, 2009
Sep 20, 2009
63
# Compile X86 32-bit
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
if test x"$output" != x; then
dir=x86/`dirname $output`
if test -d $dir; then
:
else
mkdir -p $dir
fi
fi
set -- $args
while test x$1 != x; do
if test -f "x86/$1" && test "$1" != "$output"; then
x86_args="$x86_args x86/$1"
else
x86_args="$x86_args $1"
fi
shift
done
$GCC_COMPILE_X86 $x86_args || exit $?
if test x"$output" != x; then
cp $output x86/$output
fi
Sep 20, 2009
Sep 20, 2009
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Compile X86 32-bit
if test x"$output" != x; then
dir=x64/`dirname $output`
if test -d $dir; then
:
else
mkdir -p $dir
fi
fi
set -- $args
while test x$1 != x; do
if test -f "x64/$1" && test "$1" != "$output"; then
x64_args="$x64_args x64/$1"
else
x64_args="$x64_args $1"
fi
shift
done
$GCC_COMPILE_X64 $x64_args || exit $?
if test x"$output" != x; then
cp $output x64/$output
fi
109
if test x"$output" != x; then
Aug 15, 2011
Aug 15, 2011
110
lipo -create -o $output x86/$output x64/$output