blob: 48936d1073ebd3a0f7f9c412a640dbc3996f669d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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
140
141
142
143
|
#!/bin/sh
COMPILER='@@@'
SUFFIX='---'
PREFIX='&&&'
OUTPUT_O='NO'
OUTPUT=''
NAMED_OUTPUT=''
LASTFILE=''
INTEL='NO'
SIZE32='NO'
SIZE64='NO'
NEWARGS=''
SKIP='NO'
for arg in $@
do
if [ $SKIP = 'ARCH' ]; then
# intercept -arch option and set SIZEXX
SKIP='NO'
if [ $arg = 'x86_64' ] || [ $arg = 'ppc64' ]; then
SIZE64='YES'
else
SIZE32='YES'
fi
# which architecture are we compiling for?
if [ $arg = 'x86_64' ] || [ $arg = 'i386' ]; then
INTEL='YES'
fi
elif [ $arg = '-arch' ]; then
SKIP='ARCH'
elif [ $arg = '--version' ]; then
${COMPILER} --version
exit 0
else
NEWARGS+="$arg "
# if the -c option is given, the output is .o
if [ $arg = '-c' ]; then
OUTPUT_O='YES'
fi
# if the output file is given by a -o option, record it
if [ $SKIP = 'O' ]; then
SKIP='NO'
NAMED_OUTPUT=$arg
fi
if [ $arg = '-o' ]; then
SKIP='O'
fi
# Note each file ending by ${SUFFIX} and remember the last one
# Transform them in .o
if `echo $arg | grep -q "${SUFFIX}$"`; then
LASTFILE=$arg
OUTPUT+=`echo $arg | sed "s/${SUFFIX}/\.o/"`
OUTPUT+=' '
fi
fi
done
# What is the output?
if [ ${NAMED_OUTPUT}"X" != "X" ]; then
OUTPUT=$NAMED_OUTPUT
elif [ $OUTPUT_O = 'NO' ]; then
# It is an executable whose is name is the LASTFILE without suffix
OUTPUT=`echo ${LASTFILE} | sed "s/${SUFFIX}//"`
fi
# Othewise, the output is just the ${OUTPUT} variable as computed before
# For some reason, -dynamiclib and -lpython2.6 are missing when linking
# .so files. Add them, except if -bundle is set (incompatible switches)
if [ `echo $OUTPUT | sed -E 's|.*\.||'` = "so" ] && \
! `echo $NEWARGS | grep -q bundle`; then
NEWARGS="${NEWARGS} ${PREFIX}/lib/libpython2.6.dylib -dynamiclib"
fi
# Now, compile
if [ $SIZE32 = 'NO' ] && [ $SIZE64 = 'NO' ]; then
# No size indication given, just proceed with default
if `${COMPILER} $NEWARGS`; then
exit 0
else
exit 1
fi
elif [ $SIZE32 = 'YES' ] && [ $SIZE64 = 'NO' ]; then
# 32-bit
if `${COMPILER} -m32 $NEWARGS`; then
exit 0
else
exit 1
fi
elif [ $SIZE32 = 'NO' ] && [ $SIZE64 = 'YES' ]; then
# 64-bit
if `${COMPILER} -m64 $NEWARGS`; then
exit 0
else
exit 1
fi
else
# Universal case
if `${COMPILER} -m32 $NEWARGS`; then
for filename in ${OUTPUT}
do
mv ${filename} ${filename}.32
done
if `${COMPILER} -m64 $NEWARGS`; then
for filename in ${OUTPUT}
do
mv ${filename} ${filename}.64
if [ $INTEL = 'YES' ]; then
lipo -create -arch x86_64 ${filename}.64 \
-arch i386 ${filename}.32 \
-output ${filename}
else
lipo -create -arch ppc64 ${filename}.64 \
-arch ppc ${filename}.32 \
-output ${filename}
fi
rm -f ${filename}.32 ${filename}.64
done
else
exit 1
fi
else
exit 1
fi
fi
exit 0
|