Incorporation of RSEs assembled patches
[openssl.git] / config
1 #!/bin/sh
2 #
3 # config - this is a merge of minarch and GuessOS from the Apache Group
4 #          which then automatically runs Configure from SSLeay after
5 #          mapping the Apache names for OSs into SSLeay names
6 #
7 # 29-May-97 eay         Added no-asm option
8 # 27-May-97 eay         Alpha linux mods
9 # ??-May-97 eay         IRIX mods
10 # 16-Sep-97 tjh         first cut of merged version
11 #
12 # Tim Hudson
13 # tjh@cryptsoft.com
14 #
15
16 # Original Apache Group comments on GuessOS
17
18 # Simple OS/Platform guesser. Similar to config.guess but
19 # much, much smaller. Since it was developed for use with
20 # Apache, it follows under Apache's regular licensing
21 # with one specific addition: Any changes or additions
22 # to this script should be Emailed to the Apache
23 # group (apache@apache.org) in general and to
24 # Jim Jagielski (jim@jaguNET.com) in specific.
25 #
26 # Be as similar to the output of config.guess/config.sub
27 # as possible.
28
29 # First get uname entries that we use below
30
31 MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
32 RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
33 SYSTEM=`(uname -s) 2>/dev/null`  || SYSTEM="unknown"
34 VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
35
36 # Now test for ISC and SCO, since it is has a braindamaged uname.
37 #
38 # We need to work around FreeBSD 1.1.5.1 
39 (
40 XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
41 if [ "x$XREL" != "x" ]; then
42     if [ -f /etc/kconfig ]; then
43         case "$XREL" in
44             4.0|4.1)
45                     echo "${MACHINE}-whatever-isc4"; exit 0
46                 ;;
47         esac
48     else
49         case "$XREL" in
50             3.2v4.2)
51                 echo "whatever-whatever-sco3"; exit 0
52                 ;;
53             3.2v5.0*)
54                 echo "whatever-whatever-sco5"; exit 0
55                 ;;
56             4.2MP)
57                 if [ "x$VERSION" = "x2.1.1" ]; then
58                     echo "${MACHINE}-whatever-unixware211"; exit 0
59                 else
60                     echo "${MACHINE}-whatever-unixware2"; exit 0
61                 fi
62                 ;;
63             4.2)
64                 echo "whatever-whatever-unixware1"; exit 0
65                 ;;
66         esac
67     fi
68 fi
69 # Now we simply scan though... In most cases, the SYSTEM info is enough
70 #
71 case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
72     A/UX:*)
73         echo "m68k-apple-aux3"; exit 0
74         ;;
75
76     AIX:*)
77         echo "${MACHINE}-ibm-aix"; exit 0
78         ;;
79
80     dgux:*)
81         echo "${MACHINE}-dg-dgux"; exit 0
82         ;;
83
84     HI-UX:*)
85         echo "${MACHINE}-hi-hiux"; exit 0
86         ;;
87
88     HP-UX:*)
89         HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
90         case "$HPUXVER" in
91             10.*)
92                 echo "${MACHINE}-hp-hpux10."; exit 0
93                 ;;
94             *)
95                 echo "${MACHINE}-hp-hpux"; exit 0
96                 ;;
97         esac
98         ;;
99
100     IRIX:*)
101         echo "${MACHINE}-sgi-irix"; exit 0
102         ;;
103
104     IRIX64:*)
105         echo "${MACHINE}-sgi-irix64"; exit 0
106         ;;
107
108     Linux:[2-9].*)
109         echo "${MACHINE}-whatever-linux2"; exit 0
110         ;;
111
112     Linux:1.*)
113         echo "${MACHINE}-whatever-linux1"; exit 0
114         ;;
115
116     LynxOS:*)
117         echo "${MACHINE}-lynx-lynxos"; exit 0
118         ;;
119
120     BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
121         echo "i486-whatever-bsdi"; exit 0
122         ;;
123
124     BSD/386:*|BSD/OS:*)
125         echo "${MACHINE}-whatever-bsdi"; exit 0
126         ;;
127
128     FreeBSD:*:*:*486*)
129         echo "i486-whatever-freebsd"; exit 0
130         ;;
131
132     FreeBSD:*)
133         echo "${MACHINE}-whatever-freebsd"; exit 0
134         ;;
135
136     NetBSD:*:*:*486*)
137         echo "i486-whatever-netbsd"; exit 0
138         ;;
139
140     NetBSD:*)
141         echo "${MACHINE}-whatever-netbsd"; exit 0
142         ;;
143
144     OpenBSD:*)
145         echo "${MACHINE}-whatever-openbsd"; exit 0
146         ;;
147
148     OSF1:*:*:*alpha*)
149         echo "${MACHINE}-dec-osf"; exit 0
150         ;;
151
152     QNX:*)
153         case "$VERSION" in
154             423)
155                 echo "${MACHINE}-qssl-qnx32"
156                 ;;
157             *)
158                 echo "${MACHINE}-qssl-qnx"
159                 ;;
160         esac
161         exit 0
162         ;;
163
164     Paragon*:*:*:*)
165         echo "i860-intel-osf1"; exit 0
166         ;;
167
168     SunOS:5.*)
169         echo "${MACHINE}-sun-solaris2"; exit 0
170         ;;
171
172     SunOS:*)
173         echo "${MACHINE}-sun-sunos4"; exit 0
174         ;;
175
176     UNIX_System_V:4.*:*)
177         echo "${MACHINE}-whatever-sysv4"; exit 0
178         ;;
179
180     *:4*:R4*:m88k)
181         echo "${MACHINE}-whatever-sysv4"; exit 0
182         ;;
183
184     DYNIX/ptx:4*:*)
185         echo "${MACHINE}-whatever-sysv4"; exit 0
186         ;;
187
188     *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
189         echo "i486-ncr-sysv4"; exit 0
190         ;;
191
192     ULTRIX:*)
193         echo "${MACHINE}-unknown-ultrix"; exit 0
194         ;;
195
196     SINIX*)
197         echo "${MACHINE}-sni-sysv4"; exit 0
198         ;;
199
200     machten:*)
201        echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
202        ;;
203
204     library:*)
205         echo "${MACHINE}-ncr-sysv4"; exit 0
206         ;;
207
208     ConvexOS:*:11.0:*)
209         echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
210         ;;
211
212 esac
213
214 #
215 # Ugg. These are all we can determine by what we know about
216 # the output of uname. Be more creative:
217 #
218
219 # Do the Apollo stuff first. Here, we just simply assume
220 # that the existance of the /usr/apollo directory is proof
221 # enough
222 if [ -d /usr/apollo ]; then
223     echo "whatever-apollo-whatever"
224     exit 0
225 fi
226
227 # Now NeXT
228 ISNEXT=`hostinfo 2>/dev/null`
229 case "$ISNEXT" in
230     *NeXT*)
231         echo "whatever-next-nextstep"; exit 0
232         ;;
233 esac
234
235 # At this point we gone through all the one's
236 # we know of: Punt
237
238 echo "${MACHINE}-whatever-${SYSTEM}|${RELEASE}|${VERSION}" 
239 exit 0
240 ) 2>/dev/null | (
241
242 # ---------------------------------------------------------------------------
243 # this is where the translation occurs into SSLeay terms
244 # ---------------------------------------------------------------------------
245
246 PREFIX=""
247 SUFFIX=""
248 VERBOSE="false"
249 TEST="false"
250
251 # pick up any command line args to config
252 for i
253 do
254 case "$i" in 
255 -d*) PREFIX="debug-";;
256 -v*) VERBOSE="true";;
257 -t*) TEST="true";;
258 -h*) cat <<EOF
259 usage: config [options]
260  -d     Add a debug- prefix to machine choice.
261  -v     Verbose mode.
262  -t     Test mode, do not run the Configure perl script.
263  -h     This help.
264
265 Any other text will be passed to ther Configure perl script.
266 Usefull options include
267  no-asm Build with no assember code.
268  -Dxxx  Add xxx define to compilation.
269  -Lxxx  Add xxx library include path to build.
270  -lxxx  Add xxx library to build.
271
272 eg, to build using RSAref, without assember, building to allow anon-DH
273 ciphers and null encryption ciphers,
274  config no-asm -DRSAref -DSSL_ALLOW_ADH -DSSL_ALLOW_ENULL -lrsaref
275 EOF
276 ;;
277 *) options=$options" $i" ;;
278 esac
279 done
280
281 # figure out if gcc is available and if so we use it otherwise
282 # we fallback to whatever cc does on the system
283 GCCVER=`gcc -v 2>&1`
284 if [ $? = "0" ]; then
285   CC=gcc
286 else
287   CC=cc
288 fi
289
290 # read the output of the embedded GuessOS 
291 read GUESSOS
292
293 if [ "$VERBOSE" = "true" ]; then
294   echo GUESSOS $GUESSOS
295 fi
296
297 # now map the output into SSLeay terms ... really should hack into the
298 # script above so we end up with values in vars but that would take
299 # more time that I want to waste at the moment
300 case "$GUESSOS" in
301   alpha-*-linux2) OUT="alpha-gcc" ;;
302   *-*-linux2) OUT="linux-elf" ;;
303   *-*-linux) OUT="linux-aout" ;;
304   sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;;
305   *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
306   *-*-sunos4) OUT="sunos-$CC" ;;
307   *-freebsd) OUT="FreeBSD" ;;
308   *86*-*-netbsd) OUT="NetBSD-x86" ;;
309   sun3*-*-netbsd) OUT="NetBSD-m68" ;;
310   *-*-netbsd) OUT="NetBSD-sparc" ;;
311   *86*-*-openbsd) OUT="OpenBSD-x86" ;;
312   alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
313   pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
314   *-*-openbsd) OUT="OpenBSD" ;;
315   *-*-osf) OUT="alpha-cc" ;;
316   *-*-unixware*) OUT="unixware-2.0" ;;
317   *-sni-sysv4) OUT="SINIX" ;;
318   *-hpux*) OUT="hpux-$CC" ;;
319   # these are all covered by the catchall below
320   # *-aix) OUT="aix-$CC" ;;
321   # *-dgux) OUT="dgux" ;;
322   *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
323 esac
324
325 if [ -z "$OUT" ]; then
326   OUT="$CC"
327 fi
328
329 # run Configure to check to see if we need to specify the 
330 # compiler for the platform ... in which case we add it on
331 # the end ... otherwise we leave it off
332 perl ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
333 if [ $? = "0" ]; then
334   OUT="$OUT-$CC"
335 fi
336
337 OUT="$PREFIX$OUT"
338
339 # at this point we have the answer ... which we could check again
340 # and then fallback to a vanilla SSLeay build but then this script
341 # wouldn't get updated
342 echo Configuring for $OUT
343
344 if [ "$TEST" = "true" ]; then
345   echo ./Configure $OUT $options
346 else
347   perl ./Configure $OUT $options
348 fi
349
350 )
351