-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildsunos
executable file
·216 lines (200 loc) · 4.69 KB
/
buildsunos
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/sh
if [ ! -f netinet/done ] ; then
echo "Do NOT run this script directly, do 'make solaris'!"
exit 1
fi
# $Id$
:
rev=`uname -r | sed -e 's/^\([^\.]*\)\..*/\1/'`
if [ -d /usr/ccs/bin ] ; then
PATH=/usr/ccs/bin:${PATH}
export PATH
fi
testcc()
{
if echo '' | $1 -E - >/dev/null 2>&1 ; then
CC=$1
return 0
fi
return 1
}
if [ -f /usr/include/sys/neti.h ] ; then
INST='-DINSTANCES=1'
fi
if [ $rev = 5 ] ; then
if [ ! -f /usr/include/sys/neti.h -a ! -d ../pfil ] ; then
cat << __EOF__
pfil directory in .. missing, please download pfil package and extract that
into the parent directory.
See INSTALL.Sol2 for more instructions.
__EOF__
exit 1
fi
#
# /usr/ucb/cc will not work
#
PATH=`echo $PATH | sed -e s:/usr/ucb::g -e s/::/:/g`
export PATH
cpu=`uname -p`
cpudir=${cpu}-`uname -r`
solrev=`uname -r | sh -c 'IFS=. read j n x; echo $n'`
if [ ! -d SunOS5/${cpudir} -a ! -h SunOS5/${cpudir} ] ; then
mkdir -p SunOS5/${cpudir}
fi
/bin/rm -f SunOS5/${cpudir}/Makefile
ln -s `pwd`/SunOS5/Makefile SunOS5/${cpudir}/Makefile
#
# Default C compiler is "cc", override on make commandline
#
if [ "x$CC" = "x" ] ; then
testcc cc
if [ $? -ne 0 ] ; then
testcc gcc
if [ $? -ne 0 ] ; then
echo 'No working compiler found'
exit 1
fi
fi
else
testcc $CC
if [ $? -ne 0 ] ; then
case $CC in
*gcc*)
echo 'No working compiler found'
exit 1
;;
*)
testcc gcc
if [ $? -ne 0 ] ; then
echo 'No working compiler found'
exit 1
fi
;;
esac
fi
fi
v=`echo '__GNUC__' 2>&1 | ${CC} -E - 2>&1 | sed -ne '/^[0-9]* *$/p'`
if [ x$v != x ] ; then
CC=gcc
fi
case "$CC" in
*gcc*) # gcc
XARCH32_i386=""
XARCH32_sparc=""
XARCH64_sparc="-m64 -mcmodel=medlow"
XARCH64_i386="-m64 -mcmodel=kernel -mno-red-zone -ffreestanding"
;;
*) # Sun C
XARCH32_i386="-Xa -xildoff"
XARCH32_sparc="-Xa -xildoff -xarch=v8 -xmemalign=8s"
if [ `cc -xarch=amd64 -xarch=v9 2>&1 | grep -c deprec` -eq 1 ] ; then
XARCH64_sparc="-Xa -xildoff -m64 -xmemalign=8s"
XARCH64_i386="$XARCH32 -m64"
else
XARCH64_sparc="-Xa -xildoff -xarch=v9 -xchip=ultra -xmemalign=8s -xcode=abs32"
XARCH64_i386="$XARCH32 -xarch=amd64 -xcode=abs32"
fi
;;
esac
XARCH32="`eval echo '$XARCH32_'$cpu`"
XARCH64="`eval echo '$XARCH64_'$cpu`"
OBJ32_sparc=sparcv7
OBJ64_sparc=sparcv9
OBJ32_i386=i86
OBJ64_i386=amd64
export CC
ISABITS=32
OBJ32=`eval echo '$OBJ32_'$cpu`
OBJ64=`eval echo '$OBJ64_'$cpu`
ARCHINC32=
ARCHINC64_sparc="-I/usr/include/v9"
ARCHINC64_i386=""
ARCHINC64="`eval echo '$ARCHINC_'$cpu`"
if [ $solrev -ge 10 ] && /bin/optisa sparcv8plus amd64 > /dev/null
then
# Introducing amd64
BUILDBOTH=true
elif [ $solrev -ge 7 ] && /bin/optisa sparcv8plus > /dev/null
then
# We run Solaris 7+ on 64 bit capable hardware.
BUILDBOTH=true
else
BUILDBOTH=false
OBJ32=.
fi
if $BUILDBOTH
then
echo Testing compiler $CC for 64 bit object file generation.
t=conftest$$.c
trap 'rm -f $t 32.out 64.out; exit 1' 0 1 2 3 15
cat > $t <<-EOF
#include <stdio.h>
int main(void)
{
printf("%ld\n", (long) sizeof(long));
exit(0);
}
EOF
# Is it perhaps a 64 bit only compiler?
if $CC $XARCH32 $t -o 32.out >/dev/null 2>&1 &&
[ "`./32.out`" = 4 ]
then :; else
echo $CC $XARCH32 cannot create 32 bit executables. 1>&2
exit 1
fi
if $CC $XARCH64 $t -o 64.out >/dev/null 2>&1 &&
{ out64=`./64.out 2>/dev/null` ;
[ "$out64" = 8 -o "`isainfo -b`" = 32 -a "$out64" = "" ]
}
then
echo "found 32/64 bit compiler" 1>&2
CC64=true
else
CC64=false
fi
rm -f $t 32.out 64.out
trap 0 1 2 3 15
fi
# If we're running 64 bit, we *must* build 64 bit.
if ([ "`isainfo -b`" = 64 ]) 2>/dev/null ; then
if $CC64 ; then :; else
echo "No 64 bit capable compiler was found" 1>&2
exit 1
fi
ISABITS="32 64"
elif $BUILDBOTH && $CC64
then
ISABITS="32 64"
else
OBJ32=.
fi
else
cpu=`uname -m`
cpudir=${cpu}-`uname -r`
fi
# Default $MAKE to make
: ${MAKE:=make}
if [ $cpu = i386 -a $solrev -lt 10 ] ; then
if [ -n "$BPFILTER" ] ; then
BPF="BPFILTER=./$BPFILTER"
fi
$MAKE $MAKEFLAGS ${1+"$@"} sunos5 SOLARIS2="-DSOLARIS2=$solrev" CPU= CPUDIR=${cpudir} CC="$CC $XARCH32" XARCH="$XARCH32" ARCHINC="$ARCHINC32" BITS=32 OBJ=. $BPF
exit $?
fi
if [ x$solrev = x ] ; then
make ${1+"$@"} sunos$rev "TOP=.." "ARCH=`uname -m`"
exit $?
fi
for b in $ISABITS
do
echo build $b bit binaries.
for v in OBJ ARCHINC XARCH
do
eval $v=\"\$$v$b\"
done
eval B=\"\$OBJ${b}_`uname -p`\"
if [ -n "$BPFILTER" ] ; then
BPF="BPFILTER=$OBJ/$BPFILTER"
fi
$MAKE $MAKEFLAGS ${1+"$@"} sunos$rev SOLARIS2="-DSOLARIS2=$solrev" CPU= CPUDIR=${cpudir} CC="$CC $XARCH" XARCH="$XARCH" INSTANCE="$INST" ARCHINC="$ARCHINC" BITS=$b OBJ=$B $BPF || exit $?
done