blob: 4f07fdf8e221ab56ea047a927efab3722c0d4f6f [file] [log] [blame]
Ralf S. Engelschall58964a41998-12-21 10:56:39 +00001#!/bin/sh
2#
Ulf Möller5d3bb221999-04-22 19:23:56 +00003# OpenSSL config: determine the operating system and run ./Configure
Ralf S. Engelschall58964a41998-12-21 10:56:39 +00004#
Ulf Möller5d3bb221999-04-22 19:23:56 +00005# "config -h" for usage information.
Ralf S. Engelschall58964a41998-12-21 10:56:39 +00006#
Ulf Möller5d3bb221999-04-22 19:23:56 +00007# this is a merge of minarch and GuessOS from the Apache Group.
8# Originally written by Tim Hudson <tjh@cryptsoft.com>.
Ralf S. Engelschall58964a41998-12-21 10:56:39 +00009
10# Original Apache Group comments on GuessOS
11
12# Simple OS/Platform guesser. Similar to config.guess but
13# much, much smaller. Since it was developed for use with
14# Apache, it follows under Apache's regular licensing
15# with one specific addition: Any changes or additions
16# to this script should be Emailed to the Apache
17# group (apache@apache.org) in general and to
18# Jim Jagielski (jim@jaguNET.com) in specific.
19#
20# Be as similar to the output of config.guess/config.sub
21# as possible.
22
23# First get uname entries that we use below
24
25MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
26RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
27SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown"
28VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
29
Ralf S. Engelschall58964a41998-12-21 10:56:39 +000030# Now test for ISC and SCO, since it is has a braindamaged uname.
31#
32# We need to work around FreeBSD 1.1.5.1
33(
34XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
35if [ "x$XREL" != "x" ]; then
36 if [ -f /etc/kconfig ]; then
37 case "$XREL" in
38 4.0|4.1)
39 echo "${MACHINE}-whatever-isc4"; exit 0
40 ;;
41 esac
42 else
43 case "$XREL" in
44 3.2v4.2)
45 echo "whatever-whatever-sco3"; exit 0
46 ;;
47 3.2v5.0*)
48 echo "whatever-whatever-sco5"; exit 0
49 ;;
50 4.2MP)
51 if [ "x$VERSION" = "x2.1.1" ]; then
52 echo "${MACHINE}-whatever-unixware211"; exit 0
53 else
54 echo "${MACHINE}-whatever-unixware2"; exit 0
55 fi
56 ;;
57 4.2)
58 echo "whatever-whatever-unixware1"; exit 0
59 ;;
60 esac
61 fi
62fi
63# Now we simply scan though... In most cases, the SYSTEM info is enough
64#
65case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
66 A/UX:*)
67 echo "m68k-apple-aux3"; exit 0
68 ;;
69
70 AIX:*)
71 echo "${MACHINE}-ibm-aix"; exit 0
72 ;;
73
74 dgux:*)
75 echo "${MACHINE}-dg-dgux"; exit 0
76 ;;
77
78 HI-UX:*)
79 echo "${MACHINE}-hi-hiux"; exit 0
80 ;;
81
82 HP-UX:*)
83 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
84 case "$HPUXVER" in
Ulf Möllerafd1f9e1999-05-04 11:52:26 +000085 11.*)
86 echo "${MACHINE}-hp-hpux11"; exit 0
87 ;;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +000088 10.*)
Ulf Möllerafd1f9e1999-05-04 11:52:26 +000089 echo "${MACHINE}-hp-hpux10"; exit 0
Ralf S. Engelschall58964a41998-12-21 10:56:39 +000090 ;;
91 *)
92 echo "${MACHINE}-hp-hpux"; exit 0
93 ;;
94 esac
95 ;;
96
97 IRIX:*)
98 echo "${MACHINE}-sgi-irix"; exit 0
99 ;;
100
101 IRIX64:*)
102 echo "${MACHINE}-sgi-irix64"; exit 0
103 ;;
104
105 Linux:[2-9].*)
106 echo "${MACHINE}-whatever-linux2"; exit 0
107 ;;
108
109 Linux:1.*)
110 echo "${MACHINE}-whatever-linux1"; exit 0
111 ;;
112
113 LynxOS:*)
114 echo "${MACHINE}-lynx-lynxos"; exit 0
115 ;;
116
Bodo Möller0cceb1c1999-05-30 23:54:52 +0000117 BSD/OS:4.*)
118 echo "${MACHINE}-whatever-bsdi4"; exit 0
119 ;;
120
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000121 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
122 echo "i486-whatever-bsdi"; exit 0
123 ;;
124
125 BSD/386:*|BSD/OS:*)
126 echo "${MACHINE}-whatever-bsdi"; exit 0
127 ;;
128
Ben Laurie5dcdcd41998-12-28 17:14:28 +0000129 FreeBSD:3*:*:*)
130 echo "${MACHINE}-whatever-freebsd3"; exit 0
131 ;;
132
Ulf Möllerc6fdd7d1999-04-23 16:32:04 +0000133 FreeBSD:*:*:*386*)
134 case `sysctl -n hw.model` in
135 Pentium*)
136 echo "i586-whatever-freebsd"; exit 0
137 ;;
138 *)
139 echo "i386-whatever-freebsd"; exit 0
140 ;;
141 esac;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000142 ;;
143
144 FreeBSD:*)
145 echo "${MACHINE}-whatever-freebsd"; exit 0
146 ;;
147
Ulf Möllerc6fdd7d1999-04-23 16:32:04 +0000148 NetBSD:*:*:*386*)
149 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000150 ;;
151
152 NetBSD:*)
153 echo "${MACHINE}-whatever-netbsd"; exit 0
154 ;;
155
156 OpenBSD:*)
157 echo "${MACHINE}-whatever-openbsd"; exit 0
158 ;;
159
160 OSF1:*:*:*alpha*)
161 echo "${MACHINE}-dec-osf"; exit 0
162 ;;
163
164 QNX:*)
165 case "$VERSION" in
166 423)
167 echo "${MACHINE}-qssl-qnx32"
168 ;;
169 *)
170 echo "${MACHINE}-qssl-qnx"
171 ;;
172 esac
173 exit 0
174 ;;
175
176 Paragon*:*:*:*)
177 echo "i860-intel-osf1"; exit 0
178 ;;
179
180 SunOS:5.*)
181 echo "${MACHINE}-sun-solaris2"; exit 0
182 ;;
183
184 SunOS:*)
185 echo "${MACHINE}-sun-sunos4"; exit 0
186 ;;
187
188 UNIX_System_V:4.*:*)
189 echo "${MACHINE}-whatever-sysv4"; exit 0
190 ;;
191
192 *:4*:R4*:m88k)
193 echo "${MACHINE}-whatever-sysv4"; exit 0
194 ;;
195
196 DYNIX/ptx:4*:*)
197 echo "${MACHINE}-whatever-sysv4"; exit 0
198 ;;
199
200 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
201 echo "i486-ncr-sysv4"; exit 0
202 ;;
203
204 ULTRIX:*)
205 echo "${MACHINE}-unknown-ultrix"; exit 0
206 ;;
207
Ulf Möller1fac96e1999-05-20 17:28:19 +0000208 SINIX*|ReliantUNIX*)
209 echo "${MACHINE}-siemens-sysv4"; exit 0
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000210 ;;
211
212 machten:*)
213 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
214 ;;
215
216 library:*)
217 echo "${MACHINE}-ncr-sysv4"; exit 0
218 ;;
219
220 ConvexOS:*:11.0:*)
221 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
222 ;;
223
224esac
225
226#
227# Ugg. These are all we can determine by what we know about
228# the output of uname. Be more creative:
229#
230
231# Do the Apollo stuff first. Here, we just simply assume
232# that the existance of the /usr/apollo directory is proof
233# enough
234if [ -d /usr/apollo ]; then
235 echo "whatever-apollo-whatever"
236 exit 0
237fi
238
239# Now NeXT
240ISNEXT=`hostinfo 2>/dev/null`
241case "$ISNEXT" in
242 *NeXT*)
243 echo "whatever-next-nextstep"; exit 0
244 ;;
245esac
246
247# At this point we gone through all the one's
248# we know of: Punt
249
Ulf Möllerb1fe6b41999-04-30 18:22:59 +0000250echo "${MACHINE}-whatever-${SYSTEM}"
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000251exit 0
252) 2>/dev/null | (
253
254# ---------------------------------------------------------------------------
255# this is where the translation occurs into SSLeay terms
256# ---------------------------------------------------------------------------
257
258PREFIX=""
259SUFFIX=""
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000260TEST="false"
261
262# pick up any command line args to config
263for i
264do
265case "$i" in
266-d*) PREFIX="debug-";;
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +0000267-t*) TEST="true";;
Ulf Möller5d3bb221999-04-22 19:23:56 +0000268-h*) TEST="true"; cat <<EOF
269Usage: config [options]
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +0000270 -d Add a debug- prefix to machine choice.
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +0000271 -t Test mode, do not run the Configure perl script.
272 -h This help.
273
Ulf Möller71308061999-03-30 16:17:03 +0000274Any other text will be passed to the Configure perl script.
Ulf Möller462ba4f1999-04-24 22:59:36 +0000275See INSTALL for instructions.
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +0000276
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +0000277EOF
278;;
279*) options=$options" $i" ;;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000280esac
281done
282
283# figure out if gcc is available and if so we use it otherwise
284# we fallback to whatever cc does on the system
Ulf Möller44a25701999-04-08 19:51:16 +0000285GCCVER=`(gcc -v) 2>&1`
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000286if [ $? = "0" ]; then
287 CC=gcc
288else
289 CC=cc
Ulf Möller744029c1999-05-04 23:18:24 +0000290 if [ "$SYSTEM" = "SunOS" ]
291 then
292 case `cc -V 2>&1` in
Ulf Möllere14d4441999-05-20 01:43:07 +0000293 *4*) CC=cc;;
294 *5*) CC=cc;;
295 *) CC=sc3;;
Ulf Möller744029c1999-05-04 23:18:24 +0000296 esac
297 fi
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000298fi
299
300# read the output of the embedded GuessOS
301read GUESSOS
302
Ulf Möllerb1fe6b41999-04-30 18:22:59 +0000303echo Operating system: $GUESSOS
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000304
305# now map the output into SSLeay terms ... really should hack into the
306# script above so we end up with values in vars but that would take
307# more time that I want to waste at the moment
308case "$GUESSOS" in
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +0000309 alpha-*-linux2) OUT="alpha-gcc" ;;
Ben Laurieba423ad1999-03-27 13:03:37 +0000310 ppc-*-linux2) OUT="linux-ppc" ;;
Bodo Möller38424741999-05-23 13:49:51 +0000311 mips-*-linux?) OUT="linux-mips" ;;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000312 *-*-linux2) OUT="linux-elf" ;;
Ben Lauriedabba111999-01-17 14:20:20 +0000313 *-*-linux1) OUT="linux-aout" ;;
Ulf Möller744029c1999-05-04 23:18:24 +0000314 sun4u-sun-solaris2) OUT="solaris-usparc-$CC" ;;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000315 sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;;
316 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
317 *-*-sunos4) OUT="sunos-$CC" ;;
Ulf Möllera2b21731999-05-18 16:04:03 +0000318 alpha*-*-freebsd3) OUT="FreeBSD-alpha" ;;
Ben Laurie5dcdcd41998-12-28 17:14:28 +0000319 *-freebsd3) OUT="FreeBSD-elf" ;;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000320 *-freebsd) OUT="FreeBSD" ;;
321 *86*-*-netbsd) OUT="NetBSD-x86" ;;
322 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
323 *-*-netbsd) OUT="NetBSD-sparc" ;;
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +0000324 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
325 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
326 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
327 *-*-openbsd) OUT="OpenBSD" ;;
Bodo Möller0cceb1c1999-05-30 23:54:52 +0000328 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +0000329 *-*-osf) OUT="alpha-cc" ;;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000330 *-*-unixware*) OUT="unixware-2.0" ;;
Ulf Möller1fac96e1999-05-20 17:28:19 +0000331 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
332 *-siemens-sysv4) OUT="SINIX" ;;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000333 # these are all covered by the catchall below
Ulf Möllerafd1f9e1999-05-04 11:52:26 +0000334 # *-hpux*) OUT="hpux-$CC" ;;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000335 # *-aix) OUT="aix-$CC" ;;
336 # *-dgux) OUT="dgux" ;;
337 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
338esac
339
Ulf Möllerb6735831999-05-18 23:44:38 +0000340# gcc < 2.8 does not support -mcpu=ultrasparc
341if [ "$OUT" = solaris-usparc-gcc ]
342then
Bodo Möller15a99e31999-05-19 16:50:16 +0000343 GCCVERMAJOR="`echo $GCCVER | sed 's/.*version \([^.]*\).*/\1/`"
344 GCCVERMINOR="`echo $GCCVER | sed 's/.*version[^.]*\.\([^.]*\).*/\1/`"
345 echo "gcc version $GCCVERMAJOR.$GCCVERMINOR.x"
346 if [ $GCCVERMAJOR$GCCVERMINOR -lt 28 ]
Ulf Möllerb6735831999-05-18 23:44:38 +0000347 then
Bodo Möller054810e1999-05-19 12:27:33 +0000348 OUT=solaris-usparc-oldgcc
Ulf Möllerb6735831999-05-18 23:44:38 +0000349 fi
350fi
351
Ulf Möller5d3bb221999-04-22 19:23:56 +0000352case "$GUESSOS" in
353 i386-*) options="$options 386" ;;
354esac
355
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000356if [ -z "$OUT" ]; then
357 OUT="$CC"
358fi
359
Ulf Möller99aab161999-04-01 12:34:33 +0000360if [ ".$PERL" = . ] ; then
361 for i in . `echo $PATH | sed 's/:/ /g'`; do
362 if [ -f "$i/perl5" ] ; then
363 PERL="$i/perl5"
364 break;
365 fi;
366 done
367fi
368
369if [ ".$PERL" = . ] ; then
370 for i in . `echo $PATH | sed 's/:/ /g'`; do
371 if [ -f "$i/perl" ] ; then
Ulf Möllera5a47e41999-04-09 16:25:25 +0000372 if "$i/perl" -e 'exit($]<5.0)'; then
373 PERL="$i/perl"
374 break;
375 fi;
Ulf Möller99aab161999-04-01 12:34:33 +0000376 fi;
377 done
378fi
379
Ulf Möllera5a47e41999-04-09 16:25:25 +0000380if [ ".$PERL" = . ] ; then
Ulf Möller99aab161999-04-01 12:34:33 +0000381 echo "You need Perl 5."
382 exit 1
383fi
384
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000385# run Configure to check to see if we need to specify the
386# compiler for the platform ... in which case we add it on
387# the end ... otherwise we leave it off
Ulf Möller99aab161999-04-01 12:34:33 +0000388
389$PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000390if [ $? = "0" ]; then
391 OUT="$OUT-$CC"
392fi
393
394OUT="$PREFIX$OUT"
395
Ulf Möllerb1fe6b41999-04-30 18:22:59 +0000396$PERL ./Configure 2>&1 | grep "$OUT" > /dev/null
397if [ $? = "0" ]; then
398 echo Configuring for $OUT
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000399
Ulf Möllerb1fe6b41999-04-30 18:22:59 +0000400 if [ "$TEST" = "true" ]; then
401 echo $PERL ./Configure $OUT $options
402 else
403 $PERL ./Configure $OUT $options
404 fi
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000405else
Ulf Möller744029c1999-05-04 23:18:24 +0000406 echo "This system ($OUT) is not supported. See file INSTALL for details."
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000407fi
Ralf S. Engelschall58964a41998-12-21 10:56:39 +0000408)