]> git.ipfire.org Git - thirdparty/openssl.git/blame - config
Avoid path separator problems.
[thirdparty/openssl.git] / config
CommitLineData
58964a49
RE
1#!/bin/sh
2#
5d3bb220 3# OpenSSL config: determine the operating system and run ./Configure
58964a49 4#
5d3bb220 5# "config -h" for usage information.
58964a49 6#
5d3bb220
UM
7# this is a merge of minarch and GuessOS from the Apache Group.
8# Originally written by Tim Hudson <tjh@cryptsoft.com>.
58964a49
RE
9
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
58964a49
RE
30# 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
afd1f9e8
UM
85 11.*)
86 echo "${MACHINE}-hp-hpux11"; exit 0
87 ;;
58964a49 88 10.*)
afd1f9e8 89 echo "${MACHINE}-hp-hpux10"; exit 0
58964a49
RE
90 ;;
91 *)
92 echo "${MACHINE}-hp-hpux"; exit 0
93 ;;
94 esac
95 ;;
96
da8fa72f
AP
97 IRIX:5.*)
98 echo "mips2-sgi-irix"; exit 0
99 ;;
100
1656ef29 101 IRIX:6.*)
da8fa72f 102 echo "mips3-sgi-irix"; exit 0
58964a49
RE
103 ;;
104
105 IRIX64:*)
da8fa72f 106 echo "mips4-sgi-irix64"; exit 0
58964a49
RE
107 ;;
108
109 Linux:[2-9].*)
110 echo "${MACHINE}-whatever-linux2"; exit 0
111 ;;
112
113 Linux:1.*)
114 echo "${MACHINE}-whatever-linux1"; exit 0
115 ;;
116
117 LynxOS:*)
118 echo "${MACHINE}-lynx-lynxos"; exit 0
119 ;;
120
a9ffce0a
BM
121 BSD/OS:4.*) # BSD/OS always says 386
122 echo "i486-whatever-bsdi4"; exit 0
0cceb1c7
BM
123 ;;
124
58964a49 125 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
9c789ad1
UM
126 case `/sbin/sysctl -n hw.model` in
127 Pentium*)
8050bc79 128 echo "i586-whatever-bsdi"; exit 0
9c789ad1
UM
129 ;;
130 *)
8050bc79 131 echo "i386-whatever-bsdi"; exit 0
9c789ad1
UM
132 ;;
133 esac;
58964a49
RE
134 ;;
135
136 BSD/386:*|BSD/OS:*)
137 echo "${MACHINE}-whatever-bsdi"; exit 0
138 ;;
139
c6fdd7dc
UM
140 FreeBSD:*:*:*386*)
141 case `sysctl -n hw.model` in
142 Pentium*)
143 echo "i586-whatever-freebsd"; exit 0
144 ;;
145 *)
146 echo "i386-whatever-freebsd"; exit 0
147 ;;
148 esac;
58964a49
RE
149 ;;
150
151 FreeBSD:*)
152 echo "${MACHINE}-whatever-freebsd"; exit 0
153 ;;
154
c6fdd7dc
UM
155 NetBSD:*:*:*386*)
156 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
58964a49
RE
157 ;;
158
159 NetBSD:*)
160 echo "${MACHINE}-whatever-netbsd"; exit 0
161 ;;
162
163 OpenBSD:*)
164 echo "${MACHINE}-whatever-openbsd"; exit 0
165 ;;
166
167 OSF1:*:*:*alpha*)
168 echo "${MACHINE}-dec-osf"; exit 0
169 ;;
170
171 QNX:*)
172 case "$VERSION" in
173 423)
174 echo "${MACHINE}-qssl-qnx32"
175 ;;
176 *)
177 echo "${MACHINE}-qssl-qnx"
178 ;;
179 esac
180 exit 0
181 ;;
182
183 Paragon*:*:*:*)
184 echo "i860-intel-osf1"; exit 0
185 ;;
186
187 SunOS:5.*)
188 echo "${MACHINE}-sun-solaris2"; exit 0
189 ;;
190
191 SunOS:*)
192 echo "${MACHINE}-sun-sunos4"; exit 0
193 ;;
194
195 UNIX_System_V:4.*:*)
196 echo "${MACHINE}-whatever-sysv4"; exit 0
197 ;;
198
199 *:4*:R4*:m88k)
200 echo "${MACHINE}-whatever-sysv4"; exit 0
201 ;;
202
203 DYNIX/ptx:4*:*)
204 echo "${MACHINE}-whatever-sysv4"; exit 0
205 ;;
206
207 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
208 echo "i486-ncr-sysv4"; exit 0
209 ;;
210
211 ULTRIX:*)
212 echo "${MACHINE}-unknown-ultrix"; exit 0
213 ;;
214
1fac96e4
UM
215 SINIX*|ReliantUNIX*)
216 echo "${MACHINE}-siemens-sysv4"; exit 0
58964a49
RE
217 ;;
218
9231f477
UM
219 POSIX-BC*)
220 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
221 ;;
222
58964a49
RE
223 machten:*)
224 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
225 ;;
226
227 library:*)
228 echo "${MACHINE}-ncr-sysv4"; exit 0
229 ;;
230
231 ConvexOS:*:11.0:*)
232 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
233 ;;
234
235esac
236
237#
238# Ugg. These are all we can determine by what we know about
239# the output of uname. Be more creative:
240#
241
242# Do the Apollo stuff first. Here, we just simply assume
243# that the existance of the /usr/apollo directory is proof
244# enough
245if [ -d /usr/apollo ]; then
246 echo "whatever-apollo-whatever"
247 exit 0
248fi
249
250# Now NeXT
251ISNEXT=`hostinfo 2>/dev/null`
252case "$ISNEXT" in
8e9eae0f 253 *'NeXT Mach 3.3'*)
74a6c7f3
BM
254 echo "whatever-next-nextstep3.3"; exit 0
255 ;;
58964a49
RE
256 *NeXT*)
257 echo "whatever-next-nextstep"; exit 0
258 ;;
259esac
260
261# At this point we gone through all the one's
262# we know of: Punt
263
b1fe6b43 264echo "${MACHINE}-whatever-${SYSTEM}"
58964a49
RE
265exit 0
266) 2>/dev/null | (
267
268# ---------------------------------------------------------------------------
269# this is where the translation occurs into SSLeay terms
270# ---------------------------------------------------------------------------
271
272PREFIX=""
273SUFFIX=""
58964a49
RE
274TEST="false"
275
276# pick up any command line args to config
277for i
278do
279case "$i" in
280-d*) PREFIX="debug-";;
dfeab068 281-t*) TEST="true";;
5d3bb220
UM
282-h*) TEST="true"; cat <<EOF
283Usage: config [options]
dfeab068 284 -d Add a debug- prefix to machine choice.
dfeab068
RE
285 -t Test mode, do not run the Configure perl script.
286 -h This help.
287
71308064 288Any other text will be passed to the Configure perl script.
462ba4f6 289See INSTALL for instructions.
dfeab068 290
dfeab068
RE
291EOF
292;;
293*) options=$options" $i" ;;
58964a49
RE
294esac
295done
296
297# figure out if gcc is available and if so we use it otherwise
298# we fallback to whatever cc does on the system
a0618e3e
AP
299GCCVER=`(gcc --version) 2>/dev/null`
300if [ "$GCCVER" != "" ]; then
58964a49 301 CC=gcc
a0618e3e
AP
302 # then strip off whatever prefix Cygnus prepends the number with...
303 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
1656ef29 304 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
da8fa72f 305 GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
58964a49
RE
306else
307 CC=cc
1656ef29
AP
308fi
309
310if [ "$SYSTEM" = "SunOS" ]; then
311 # assume output is "blah-blah C x.x"
312 CCVER=`(cc -V 2>&1) 2>/dev/null | \
313 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
314 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
315 CCVER=${CCVER:-0}
316 if [ $CCVER -gt 40 ]; then
317 CC=cc # overrides gcc!!!
318 if [ $CCVER -eq 50 ]; then
319 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
320 echo " patch #107357-01 or later applied."
321 sleep 5
322 fi
323 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
324 CC=sc3
744029c1 325 fi
58964a49
RE
326fi
327
da8fa72f
AP
328GCCVER=${GCCVER:-0}
329CCVER=${CCVER:-0}
330
58964a49
RE
331# read the output of the embedded GuessOS
332read GUESSOS
333
b1fe6b43 334echo Operating system: $GUESSOS
58964a49
RE
335
336# now map the output into SSLeay terms ... really should hack into the
337# script above so we end up with values in vars but that would take
338# more time that I want to waste at the moment
339case "$GUESSOS" in
dfeab068 340 alpha-*-linux2) OUT="alpha-gcc" ;;
ba423add 341 ppc-*-linux2) OUT="linux-ppc" ;;
38424743 342 mips-*-linux?) OUT="linux-mips" ;;
da8fa72f
AP
343 mips2-sgi-irix)
344 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
345 CPU=${CPU:-0}
346 if [ $CPU -ge 4000 ]; then
347 options="$options -mips2"
348 fi
349 OUT="irix-$CC"
350 ;;
351 mips3-sgi-irix)
352 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
353 CPU=${CPU:-0}
354 if [ $CPU -ge 5000 ]; then
355 options="$options -mips4"
356 else
357 options="$options -mips3"
358 fi
359 OUT="irix-mips3-$CC"
360 ;;
361 mips4-sgi-irix64)
362 echo "WARNING! If you wish to build 64-bit library, then you have to"
363 echo " invoke './Configre irix64-mips4-$CC' *manually*."
364 echo " Type Ctrl-C if you don't want to continue."
365 read waste < /dev/tty
366 options="$options -mips4"
367 OUT="irix-mips3-$CC"
368 ;;
a0618e3e 369 sparc64-*-linux2)
1656ef29
AP
370 #Before we can uncomment following lines we have to wait at least
371 #till 64-bit glibc for SPARC is operational:-(
372 #echo "WARNING! If you wish to build 64-bit library, then you have to"
a0618e3e
AP
373 #echo " invoke './Configure linux64-sparcv9' *manually*."
374 #echo " Type Ctrl-C if you don't want to continue."
375 #read waste < /dev/tty
376 OUT="linux-sparcv9" ;;
da8fa72f 377 sparc-*-linux2)
a0618e3e
AP
378 KARCH=`awk '/type/{print$3}' /proc/cpuinfo`
379 case ${KARCH:-sun4} in
380 sun4u*) OUT="linux-sparcv9" ;;
381 sun4m) OUT="linux-sparcv8" ;;
382 sun4d) OUT="linux-sparcv8" ;;
383 *) OUT="linux-sparcv7" ;;
384 esac ;;
58964a49 385 *-*-linux2) OUT="linux-elf" ;;
dabba110 386 *-*-linux1) OUT="linux-aout" ;;
1656ef29
AP
387 sun4u*-sun-solaris2)
388 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
389 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
390 echo "WARNING! If you wish to build 64-bit library, then you have to"
391 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
392 echo " Type Ctrl-C if you don't want to continue."
393 read waste < /dev/tty
394 fi
395 OUT="solaris-sparcv9-$CC" ;;
396 sun4m-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
397 sun4d-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
398 sun4*-sun-solaris2) OUT="solaris-sparcv7-$CC" ;;
58964a49
RE
399 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
400 *-*-sunos4) OUT="sunos-$CC" ;;
9b67b4b3 401 alpha*-*-freebsd) OUT="FreeBSD-alpha" ;;
58964a49
RE
402 *-freebsd) OUT="FreeBSD" ;;
403 *86*-*-netbsd) OUT="NetBSD-x86" ;;
404 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
405 *-*-netbsd) OUT="NetBSD-sparc" ;;
dfeab068
RE
406 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
407 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
408 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
409 *-*-openbsd) OUT="OpenBSD" ;;
0cceb1c7 410 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
dfeab068 411 *-*-osf) OUT="alpha-cc" ;;
58964a49 412 *-*-unixware*) OUT="unixware-2.0" ;;
9231f477 413 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
1fac96e4
UM
414 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
415 *-siemens-sysv4) OUT="SINIX" ;;
58964a49 416 # these are all covered by the catchall below
afd1f9e8 417 # *-hpux*) OUT="hpux-$CC" ;;
58964a49
RE
418 # *-aix) OUT="aix-$CC" ;;
419 # *-dgux) OUT="dgux" ;;
420 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
5d3bb220
UM
421esac
422
b6735832 423# gcc < 2.8 does not support -mcpu=ultrasparc
1656ef29 424if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
b6735832 425then
a0618e3e 426 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
1656ef29
AP
427 sleep 5
428 OUT=solaris-sparcv9-gcc27
a0618e3e
AP
429fi
430if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
431then
432 echo "WARNING! Falling down to 'linux-sparcv8'."
433 echo " Upgrade to gcc-2.8 or later."
1656ef29 434 sleep 5
a0618e3e 435 OUT=linux-sparcv8
b6735832
UM
436fi
437
5d3bb220
UM
438case "$GUESSOS" in
439 i386-*) options="$options 386" ;;
58964a49
RE
440esac
441
5676d8cb 442for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
9231f477
UM
443do
444 if [ ! -d crypto/$i ]
445 then
446 options="$options no-$i"
447 fi
448done
449
58964a49
RE
450if [ -z "$OUT" ]; then
451 OUT="$CC"
452fi
453
99aab161
UM
454if [ ".$PERL" = . ] ; then
455 for i in . `echo $PATH | sed 's/:/ /g'`; do
456 if [ -f "$i/perl5" ] ; then
457 PERL="$i/perl5"
458 break;
459 fi;
460 done
461fi
462
463if [ ".$PERL" = . ] ; then
464 for i in . `echo $PATH | sed 's/:/ /g'`; do
465 if [ -f "$i/perl" ] ; then
a5a47e4a
UM
466 if "$i/perl" -e 'exit($]<5.0)'; then
467 PERL="$i/perl"
468 break;
469 fi;
99aab161
UM
470 fi;
471 done
472fi
473
a5a47e4a 474if [ ".$PERL" = . ] ; then
99aab161
UM
475 echo "You need Perl 5."
476 exit 1
477fi
478
58964a49
RE
479# run Configure to check to see if we need to specify the
480# compiler for the platform ... in which case we add it on
481# the end ... otherwise we leave it off
99aab161
UM
482
483$PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
58964a49
RE
484if [ $? = "0" ]; then
485 OUT="$OUT-$CC"
486fi
487
488OUT="$PREFIX$OUT"
489
b1fe6b43
UM
490$PERL ./Configure 2>&1 | grep "$OUT" > /dev/null
491if [ $? = "0" ]; then
492 echo Configuring for $OUT
58964a49 493
b1fe6b43
UM
494 if [ "$TEST" = "true" ]; then
495 echo $PERL ./Configure $OUT $options
496 else
497 $PERL ./Configure $OUT $options
498 fi
58964a49 499else
744029c1 500 echo "This system ($OUT) is not supported. See file INSTALL for details."
58964a49 501fi
58964a49 502)