]> git.ipfire.org Git - thirdparty/openssl.git/blame - config
HP-UX tune-up: new unified configs, HP C compiler bug workaround.
[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
58964a49 140 FreeBSD:*)
44717474
RE
141 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
142 MACH=`sysctl -n hw.model`
143 ARCH='whatever'
144 case ${MACH} in
145 *386* ) MACH="i386" ;;
146 *486* ) MACH="i486" ;;
147 Pentium\ II*) MACH="i686" ;;
148 Pentium* ) MACH="i586" ;;
149 Alpha* ) MACH="alpha" ;;
150 * ) MACH="$MACHINE" ;;
151 esac
152 case ${MACH} in
153 i[0-9]86 ) ARCH="pc" ;;
154 esac
155 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
156 ;;
58964a49 157
c6fdd7dc
UM
158 NetBSD:*:*:*386*)
159 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
58964a49
RE
160 ;;
161
162 NetBSD:*)
163 echo "${MACHINE}-whatever-netbsd"; exit 0
164 ;;
165
166 OpenBSD:*)
167 echo "${MACHINE}-whatever-openbsd"; exit 0
168 ;;
169
170 OSF1:*:*:*alpha*)
171 echo "${MACHINE}-dec-osf"; exit 0
172 ;;
173
174 QNX:*)
175 case "$VERSION" in
176 423)
177 echo "${MACHINE}-qssl-qnx32"
178 ;;
179 *)
180 echo "${MACHINE}-qssl-qnx"
181 ;;
182 esac
183 exit 0
184 ;;
185
186 Paragon*:*:*:*)
187 echo "i860-intel-osf1"; exit 0
188 ;;
189
0fad6cb7
AP
190 Rhapsody:*)
191 echo "ppc-apple-rhapsody"; exit 0
192 ;;
193
58964a49
RE
194 SunOS:5.*)
195 echo "${MACHINE}-sun-solaris2"; exit 0
196 ;;
197
198 SunOS:*)
199 echo "${MACHINE}-sun-sunos4"; exit 0
200 ;;
201
202 UNIX_System_V:4.*:*)
203 echo "${MACHINE}-whatever-sysv4"; exit 0
204 ;;
205
206 *:4*:R4*:m88k)
207 echo "${MACHINE}-whatever-sysv4"; exit 0
208 ;;
209
210 DYNIX/ptx:4*:*)
211 echo "${MACHINE}-whatever-sysv4"; exit 0
212 ;;
213
214 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
215 echo "i486-ncr-sysv4"; exit 0
216 ;;
217
218 ULTRIX:*)
219 echo "${MACHINE}-unknown-ultrix"; exit 0
220 ;;
221
1fac96e4
UM
222 SINIX*|ReliantUNIX*)
223 echo "${MACHINE}-siemens-sysv4"; exit 0
58964a49
RE
224 ;;
225
9231f477
UM
226 POSIX-BC*)
227 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
228 ;;
229
58964a49
RE
230 machten:*)
231 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
232 ;;
233
234 library:*)
235 echo "${MACHINE}-ncr-sysv4"; exit 0
236 ;;
237
238 ConvexOS:*:11.0:*)
239 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
240 ;;
241
242esac
243
244#
245# Ugg. These are all we can determine by what we know about
246# the output of uname. Be more creative:
247#
248
249# Do the Apollo stuff first. Here, we just simply assume
250# that the existance of the /usr/apollo directory is proof
251# enough
252if [ -d /usr/apollo ]; then
253 echo "whatever-apollo-whatever"
254 exit 0
255fi
256
257# Now NeXT
258ISNEXT=`hostinfo 2>/dev/null`
259case "$ISNEXT" in
8e9eae0f 260 *'NeXT Mach 3.3'*)
74a6c7f3
BM
261 echo "whatever-next-nextstep3.3"; exit 0
262 ;;
58964a49
RE
263 *NeXT*)
264 echo "whatever-next-nextstep"; exit 0
265 ;;
266esac
267
268# At this point we gone through all the one's
269# we know of: Punt
270
b1fe6b43 271echo "${MACHINE}-whatever-${SYSTEM}"
58964a49
RE
272exit 0
273) 2>/dev/null | (
274
275# ---------------------------------------------------------------------------
276# this is where the translation occurs into SSLeay terms
277# ---------------------------------------------------------------------------
278
279PREFIX=""
280SUFFIX=""
58964a49
RE
281TEST="false"
282
283# pick up any command line args to config
284for i
285do
286case "$i" in
287-d*) PREFIX="debug-";;
dfeab068 288-t*) TEST="true";;
5d3bb220
UM
289-h*) TEST="true"; cat <<EOF
290Usage: config [options]
dfeab068 291 -d Add a debug- prefix to machine choice.
dfeab068
RE
292 -t Test mode, do not run the Configure perl script.
293 -h This help.
294
71308064 295Any other text will be passed to the Configure perl script.
462ba4f6 296See INSTALL for instructions.
dfeab068 297
dfeab068
RE
298EOF
299;;
300*) options=$options" $i" ;;
58964a49
RE
301esac
302done
303
304# figure out if gcc is available and if so we use it otherwise
305# we fallback to whatever cc does on the system
a0618e3e
AP
306GCCVER=`(gcc --version) 2>/dev/null`
307if [ "$GCCVER" != "" ]; then
58964a49 308 CC=gcc
a0618e3e
AP
309 # then strip off whatever prefix Cygnus prepends the number with...
310 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
1656ef29 311 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
da8fa72f 312 GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
58964a49
RE
313else
314 CC=cc
1656ef29
AP
315fi
316
317if [ "$SYSTEM" = "SunOS" ]; then
bdf5e183 318 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
1656ef29
AP
319 CCVER=`(cc -V 2>&1) 2>/dev/null | \
320 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
321 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
322 CCVER=${CCVER:-0}
323 if [ $CCVER -gt 40 ]; then
324 CC=cc # overrides gcc!!!
325 if [ $CCVER -eq 50 ]; then
326 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
327 echo " patch #107357-01 or later applied."
328 sleep 5
329 fi
330 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
331 CC=sc3
744029c1 332 fi
58964a49
RE
333fi
334
bdf5e183
AP
335if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
336 # check for Compaq C, expected output is "blah-blah C Vx.x"
337 CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
338 egrep -e '.* C V[0-9]\.[0-9]' | \
339 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
340 CCCVER=${CCCVER:-0}
341 if [ $CCCVER -gt 60 ]; then
342 CC=ccc # overrides gcc!!! well, ccc outperforms inoticeably
343 # only on hash routines and des, otherwise gcc (2.95)
344 # keeps along rather tight...
345 fi
346fi
347
da8fa72f
AP
348GCCVER=${GCCVER:-0}
349CCVER=${CCVER:-0}
350
58964a49
RE
351# read the output of the embedded GuessOS
352read GUESSOS
353
b1fe6b43 354echo Operating system: $GUESSOS
58964a49
RE
355
356# now map the output into SSLeay terms ... really should hack into the
357# script above so we end up with values in vars but that would take
358# more time that I want to waste at the moment
359case "$GUESSOS" in
da8fa72f
AP
360 mips2-sgi-irix)
361 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
362 CPU=${CPU:-0}
363 if [ $CPU -ge 4000 ]; then
364 options="$options -mips2"
365 fi
366 OUT="irix-$CC"
367 ;;
368 mips3-sgi-irix)
369 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
370 CPU=${CPU:-0}
371 if [ $CPU -ge 5000 ]; then
372 options="$options -mips4"
373 else
374 options="$options -mips3"
375 fi
376 OUT="irix-mips3-$CC"
377 ;;
378 mips4-sgi-irix64)
379 echo "WARNING! If you wish to build 64-bit library, then you have to"
380 echo " invoke './Configre irix64-mips4-$CC' *manually*."
381 echo " Type Ctrl-C if you don't want to continue."
382 read waste < /dev/tty
383 options="$options -mips4"
384 OUT="irix-mips3-$CC"
385 ;;
bdf5e183
AP
386 alpha-*-linux2)
387 ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
388 case ${ISA:-generic} in
389 *[67]) OUT="linux-alpha+bwx-$CC" ;;
390 *) OUT="linux-alpha-$CC" ;;
391 esac
392 if [ "$CC" = "gcc" ]; then
393 case ${ISA:-generic} in
394 EV5|EV45) options="$options -mcpu=ev5";;
395 EV56|PCA56) options="$options -mcpu=ev56";;
396 EV6|EV67|PCA57) options="$options -mcpu=ev6";;
397 esac
398 fi
399 ;;
400 mips-*-linux?) OUT="linux-mips" ;;
401 ppc-*-linux2) OUT="linux-ppc" ;;
0fad6cb7 402 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
a0618e3e 403 sparc64-*-linux2)
1656ef29
AP
404 #Before we can uncomment following lines we have to wait at least
405 #till 64-bit glibc for SPARC is operational:-(
406 #echo "WARNING! If you wish to build 64-bit library, then you have to"
a0618e3e
AP
407 #echo " invoke './Configure linux64-sparcv9' *manually*."
408 #echo " Type Ctrl-C if you don't want to continue."
409 #read waste < /dev/tty
410 OUT="linux-sparcv9" ;;
da8fa72f 411 sparc-*-linux2)
a0618e3e
AP
412 KARCH=`awk '/type/{print$3}' /proc/cpuinfo`
413 case ${KARCH:-sun4} in
414 sun4u*) OUT="linux-sparcv9" ;;
415 sun4m) OUT="linux-sparcv8" ;;
416 sun4d) OUT="linux-sparcv8" ;;
417 *) OUT="linux-sparcv7" ;;
418 esac ;;
58964a49 419 *-*-linux2) OUT="linux-elf" ;;
dabba110 420 *-*-linux1) OUT="linux-aout" ;;
1656ef29
AP
421 sun4u*-sun-solaris2)
422 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
423 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
424 echo "WARNING! If you wish to build 64-bit library, then you have to"
425 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
426 echo " Type Ctrl-C if you don't want to continue."
427 read waste < /dev/tty
428 fi
429 OUT="solaris-sparcv9-$CC" ;;
430 sun4m-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
431 sun4d-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
432 sun4*-sun-solaris2) OUT="solaris-sparcv7-$CC" ;;
58964a49
RE
433 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
434 *-*-sunos4) OUT="sunos-$CC" ;;
44717474
RE
435 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
436 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
437 *-freebsd[1-2]*) OUT="FreeBSD" ;;
58964a49
RE
438 *86*-*-netbsd) OUT="NetBSD-x86" ;;
439 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
440 *-*-netbsd) OUT="NetBSD-sparc" ;;
dfeab068
RE
441 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
442 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
443 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
444 *-*-openbsd) OUT="OpenBSD" ;;
0cceb1c7 445 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
dfeab068 446 *-*-osf) OUT="alpha-cc" ;;
58964a49 447 *-*-unixware*) OUT="unixware-2.0" ;;
add9e254 448 *-*-UnixWare*) OUT="unixware-2.0" ;;
9231f477 449 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
1fac96e4
UM
450 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
451 *-siemens-sysv4) OUT="SINIX" ;;
bcba6cc6
AP
452 *-hpux1*) OUT="hpux-parisc-$CC"
453 options="$options -D_REENTRANT" ;;
454 *-hpux) OUT="hpux-parisc-$CC" ;;
58964a49 455 # these are all covered by the catchall below
58964a49
RE
456 # *-aix) OUT="aix-$CC" ;;
457 # *-dgux) OUT="dgux" ;;
458 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
5d3bb220
UM
459esac
460
b6735832 461# gcc < 2.8 does not support -mcpu=ultrasparc
1656ef29 462if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
b6735832 463then
a0618e3e 464 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
1656ef29
AP
465 sleep 5
466 OUT=solaris-sparcv9-gcc27
a0618e3e
AP
467fi
468if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
469then
470 echo "WARNING! Falling down to 'linux-sparcv8'."
471 echo " Upgrade to gcc-2.8 or later."
1656ef29 472 sleep 5
a0618e3e 473 OUT=linux-sparcv8
b6735832 474fi
b82ccbb7
UM
475if [ "$OUT" = "i86pc-sun-solaris2" ]
476then
9bb2560c 477 ASM=`as -V /dev/null 2>&1`
b82ccbb7
UM
478 case "$ASM" in
479 GNU*) ;;
480 *) options="$options no-asm" ; echo "WARNING: You need the GNU assembler to use OpenSSL assembler code." ; echo "Sun as is not supported on Solaris x86." ;;
481 esac
482fi
b6735832 483
5d3bb220
UM
484case "$GUESSOS" in
485 i386-*) options="$options 386" ;;
58964a49
RE
486esac
487
5676d8cb 488for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
9231f477
UM
489do
490 if [ ! -d crypto/$i ]
491 then
492 options="$options no-$i"
493 fi
494done
495
58964a49
RE
496if [ -z "$OUT" ]; then
497 OUT="$CC"
498fi
499
99aab161
UM
500if [ ".$PERL" = . ] ; then
501 for i in . `echo $PATH | sed 's/:/ /g'`; do
502 if [ -f "$i/perl5" ] ; then
503 PERL="$i/perl5"
504 break;
505 fi;
506 done
507fi
508
509if [ ".$PERL" = . ] ; then
510 for i in . `echo $PATH | sed 's/:/ /g'`; do
511 if [ -f "$i/perl" ] ; then
a5a47e4a
UM
512 if "$i/perl" -e 'exit($]<5.0)'; then
513 PERL="$i/perl"
514 break;
515 fi;
99aab161
UM
516 fi;
517 done
518fi
519
a5a47e4a 520if [ ".$PERL" = . ] ; then
99aab161
UM
521 echo "You need Perl 5."
522 exit 1
523fi
524
58964a49
RE
525# run Configure to check to see if we need to specify the
526# compiler for the platform ... in which case we add it on
527# the end ... otherwise we leave it off
99aab161
UM
528
529$PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
58964a49
RE
530if [ $? = "0" ]; then
531 OUT="$OUT-$CC"
532fi
533
534OUT="$PREFIX$OUT"
535
b1fe6b43
UM
536$PERL ./Configure 2>&1 | grep "$OUT" > /dev/null
537if [ $? = "0" ]; then
538 echo Configuring for $OUT
58964a49 539
b1fe6b43
UM
540 if [ "$TEST" = "true" ]; then
541 echo $PERL ./Configure $OUT $options
542 else
543 $PERL ./Configure $OUT $options
544 fi
58964a49 545else
744029c1 546 echo "This system ($OUT) is not supported. See file INSTALL for details."
58964a49 547fi
58964a49 548)