]> git.ipfire.org Git - thirdparty/openssl.git/blame - config
Get rid of ASN1_UTCTIME_get, which cannot work with time_t
[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
8f6dc9c5 30
58964a49
RE
31# Now test for ISC and SCO, since it is has a braindamaged uname.
32#
33# We need to work around FreeBSD 1.1.5.1
34(
35XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
36if [ "x$XREL" != "x" ]; then
37 if [ -f /etc/kconfig ]; then
38 case "$XREL" in
39 4.0|4.1)
40 echo "${MACHINE}-whatever-isc4"; exit 0
41 ;;
42 esac
43 else
44 case "$XREL" in
45 3.2v4.2)
46 echo "whatever-whatever-sco3"; exit 0
47 ;;
48 3.2v5.0*)
49 echo "whatever-whatever-sco5"; exit 0
50 ;;
51 4.2MP)
52 if [ "x$VERSION" = "x2.1.1" ]; then
53 echo "${MACHINE}-whatever-unixware211"; exit 0
8f6dc9c5
RL
54 elif [ "x$VERSION" = "x2.1.2" ]; then
55 echo "${MACHINE}-whatever-unixware212"; exit 0
58964a49
RE
56 else
57 echo "${MACHINE}-whatever-unixware2"; exit 0
58 fi
59 ;;
60 4.2)
61 echo "whatever-whatever-unixware1"; exit 0
62 ;;
8f6dc9c5 63 5)
2eb5bc5c 64 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then
8f6dc9c5
RL
65 echo "${MACHINE}-sco-unixware7"; exit 0
66 fi
9a5a7401 67 ;;
58964a49
RE
68 esac
69 fi
70fi
71# Now we simply scan though... In most cases, the SYSTEM info is enough
72#
73case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
74 A/UX:*)
75 echo "m68k-apple-aux3"; exit 0
76 ;;
77
78 AIX:*)
79 echo "${MACHINE}-ibm-aix"; exit 0
80 ;;
81
82 dgux:*)
83 echo "${MACHINE}-dg-dgux"; exit 0
84 ;;
85
86 HI-UX:*)
87 echo "${MACHINE}-hi-hiux"; exit 0
88 ;;
89
90 HP-UX:*)
91 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
92 case "$HPUXVER" in
afd1f9e8
UM
93 11.*)
94 echo "${MACHINE}-hp-hpux11"; exit 0
95 ;;
58964a49 96 10.*)
afd1f9e8 97 echo "${MACHINE}-hp-hpux10"; exit 0
58964a49
RE
98 ;;
99 *)
100 echo "${MACHINE}-hp-hpux"; exit 0
101 ;;
102 esac
103 ;;
104
da8fa72f
AP
105 IRIX:5.*)
106 echo "mips2-sgi-irix"; exit 0
107 ;;
108
1656ef29 109 IRIX:6.*)
da8fa72f 110 echo "mips3-sgi-irix"; exit 0
58964a49
RE
111 ;;
112
113 IRIX64:*)
da8fa72f 114 echo "mips4-sgi-irix64"; exit 0
58964a49
RE
115 ;;
116
117 Linux:[2-9].*)
118 echo "${MACHINE}-whatever-linux2"; exit 0
119 ;;
120
121 Linux:1.*)
122 echo "${MACHINE}-whatever-linux1"; exit 0
123 ;;
124
125 LynxOS:*)
126 echo "${MACHINE}-lynx-lynxos"; exit 0
127 ;;
128
a9ffce0a
BM
129 BSD/OS:4.*) # BSD/OS always says 386
130 echo "i486-whatever-bsdi4"; exit 0
0cceb1c7
BM
131 ;;
132
58964a49 133 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
9c789ad1
UM
134 case `/sbin/sysctl -n hw.model` in
135 Pentium*)
8050bc79 136 echo "i586-whatever-bsdi"; exit 0
9c789ad1
UM
137 ;;
138 *)
8050bc79 139 echo "i386-whatever-bsdi"; exit 0
9c789ad1
UM
140 ;;
141 esac;
58964a49
RE
142 ;;
143
144 BSD/386:*|BSD/OS:*)
145 echo "${MACHINE}-whatever-bsdi"; exit 0
146 ;;
147
58964a49 148 FreeBSD:*)
44717474
RE
149 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
150 MACH=`sysctl -n hw.model`
151 ARCH='whatever'
152 case ${MACH} in
153 *386* ) MACH="i386" ;;
154 *486* ) MACH="i486" ;;
155 Pentium\ II*) MACH="i686" ;;
156 Pentium* ) MACH="i586" ;;
157 Alpha* ) MACH="alpha" ;;
158 * ) MACH="$MACHINE" ;;
159 esac
160 case ${MACH} in
161 i[0-9]86 ) ARCH="pc" ;;
162 esac
163 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
164 ;;
58964a49 165
c6fdd7dc 166 NetBSD:*:*:*386*)
e871dcbc 167 echo "`/usr/sbin/sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
58964a49
RE
168 ;;
169
170 NetBSD:*)
171 echo "${MACHINE}-whatever-netbsd"; exit 0
172 ;;
173
174 OpenBSD:*)
175 echo "${MACHINE}-whatever-openbsd"; exit 0
176 ;;
177
178 OSF1:*:*:*alpha*)
179 echo "${MACHINE}-dec-osf"; exit 0
180 ;;
181
182 QNX:*)
183 case "$VERSION" in
36124b10
BM
184 4*)
185 echo "${MACHINE}-whatever-qnx4"
58964a49
RE
186 ;;
187 *)
36124b10 188 echo "${MACHINE}-whatever-qnx"
58964a49
RE
189 ;;
190 esac
191 exit 0
192 ;;
193
194 Paragon*:*:*:*)
195 echo "i860-intel-osf1"; exit 0
196 ;;
197
0fad6cb7
AP
198 Rhapsody:*)
199 echo "ppc-apple-rhapsody"; exit 0
200 ;;
201
58964a49
RE
202 SunOS:5.*)
203 echo "${MACHINE}-sun-solaris2"; exit 0
204 ;;
205
206 SunOS:*)
207 echo "${MACHINE}-sun-sunos4"; exit 0
208 ;;
209
210 UNIX_System_V:4.*:*)
211 echo "${MACHINE}-whatever-sysv4"; exit 0
212 ;;
213
214 *:4*:R4*:m88k)
215 echo "${MACHINE}-whatever-sysv4"; exit 0
216 ;;
217
218 DYNIX/ptx:4*:*)
219 echo "${MACHINE}-whatever-sysv4"; exit 0
220 ;;
221
222 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
223 echo "i486-ncr-sysv4"; exit 0
224 ;;
225
226 ULTRIX:*)
227 echo "${MACHINE}-unknown-ultrix"; exit 0
228 ;;
229
1fac96e4
UM
230 SINIX*|ReliantUNIX*)
231 echo "${MACHINE}-siemens-sysv4"; exit 0
58964a49
RE
232 ;;
233
9231f477
UM
234 POSIX-BC*)
235 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
236 ;;
237
58964a49
RE
238 machten:*)
239 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
240 ;;
241
242 library:*)
243 echo "${MACHINE}-ncr-sysv4"; exit 0
244 ;;
245
246 ConvexOS:*:11.0:*)
247 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
248 ;;
249
250esac
251
252#
253# Ugg. These are all we can determine by what we know about
254# the output of uname. Be more creative:
255#
256
257# Do the Apollo stuff first. Here, we just simply assume
258# that the existance of the /usr/apollo directory is proof
259# enough
260if [ -d /usr/apollo ]; then
261 echo "whatever-apollo-whatever"
262 exit 0
263fi
264
265# Now NeXT
266ISNEXT=`hostinfo 2>/dev/null`
267case "$ISNEXT" in
8e9eae0f 268 *'NeXT Mach 3.3'*)
74a6c7f3
BM
269 echo "whatever-next-nextstep3.3"; exit 0
270 ;;
58964a49
RE
271 *NeXT*)
272 echo "whatever-next-nextstep"; exit 0
273 ;;
274esac
275
276# At this point we gone through all the one's
277# we know of: Punt
278
b1fe6b43 279echo "${MACHINE}-whatever-${SYSTEM}"
58964a49
RE
280exit 0
281) 2>/dev/null | (
282
283# ---------------------------------------------------------------------------
284# this is where the translation occurs into SSLeay terms
285# ---------------------------------------------------------------------------
286
287PREFIX=""
288SUFFIX=""
58964a49
RE
289TEST="false"
290
291# pick up any command line args to config
292for i
293do
294case "$i" in
295-d*) PREFIX="debug-";;
dfeab068 296-t*) TEST="true";;
5d3bb220
UM
297-h*) TEST="true"; cat <<EOF
298Usage: config [options]
dfeab068 299 -d Add a debug- prefix to machine choice.
dfeab068
RE
300 -t Test mode, do not run the Configure perl script.
301 -h This help.
302
71308064 303Any other text will be passed to the Configure perl script.
462ba4f6 304See INSTALL for instructions.
dfeab068 305
dfeab068
RE
306EOF
307;;
308*) options=$options" $i" ;;
58964a49
RE
309esac
310done
311
312# figure out if gcc is available and if so we use it otherwise
313# we fallback to whatever cc does on the system
a0618e3e
AP
314GCCVER=`(gcc --version) 2>/dev/null`
315if [ "$GCCVER" != "" ]; then
58964a49 316 CC=gcc
a0618e3e
AP
317 # then strip off whatever prefix Cygnus prepends the number with...
318 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
1656ef29 319 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
da8fa72f 320 GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
58964a49
RE
321else
322 CC=cc
1656ef29
AP
323fi
324
325if [ "$SYSTEM" = "SunOS" ]; then
bdf5e183 326 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
1656ef29
AP
327 CCVER=`(cc -V 2>&1) 2>/dev/null | \
328 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
329 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
330 CCVER=${CCVER:-0}
331 if [ $CCVER -gt 40 ]; then
332 CC=cc # overrides gcc!!!
333 if [ $CCVER -eq 50 ]; then
334 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
335 echo " patch #107357-01 or later applied."
336 sleep 5
337 fi
338 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
339 CC=sc3
744029c1 340 fi
58964a49
RE
341fi
342
bdf5e183
AP
343if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
344 # check for Compaq C, expected output is "blah-blah C Vx.x"
345 CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
346 egrep -e '.* C V[0-9]\.[0-9]' | \
347 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
348 CCCVER=${CCCVER:-0}
349 if [ $CCCVER -gt 60 ]; then
350 CC=ccc # overrides gcc!!! well, ccc outperforms inoticeably
351 # only on hash routines and des, otherwise gcc (2.95)
352 # keeps along rather tight...
353 fi
354fi
355
da8fa72f
AP
356GCCVER=${GCCVER:-0}
357CCVER=${CCVER:-0}
358
58964a49
RE
359# read the output of the embedded GuessOS
360read GUESSOS
361
b1fe6b43 362echo Operating system: $GUESSOS
58964a49
RE
363
364# now map the output into SSLeay terms ... really should hack into the
365# script above so we end up with values in vars but that would take
366# more time that I want to waste at the moment
367case "$GUESSOS" in
da8fa72f
AP
368 mips2-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 4000 ]; then
372 options="$options -mips2"
373 fi
374 OUT="irix-$CC"
375 ;;
376 mips3-sgi-irix)
377 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
378 CPU=${CPU:-0}
379 if [ $CPU -ge 5000 ]; then
380 options="$options -mips4"
381 else
382 options="$options -mips3"
383 fi
384 OUT="irix-mips3-$CC"
385 ;;
386 mips4-sgi-irix64)
387 echo "WARNING! If you wish to build 64-bit library, then you have to"
388 echo " invoke './Configre irix64-mips4-$CC' *manually*."
389 echo " Type Ctrl-C if you don't want to continue."
390 read waste < /dev/tty
391 options="$options -mips4"
392 OUT="irix-mips3-$CC"
393 ;;
bdf5e183
AP
394 alpha-*-linux2)
395 ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
396 case ${ISA:-generic} in
397 *[67]) OUT="linux-alpha+bwx-$CC" ;;
398 *) OUT="linux-alpha-$CC" ;;
399 esac
400 if [ "$CC" = "gcc" ]; then
401 case ${ISA:-generic} in
402 EV5|EV45) options="$options -mcpu=ev5";;
403 EV56|PCA56) options="$options -mcpu=ev56";;
404 EV6|EV67|PCA57) options="$options -mcpu=ev6";;
405 esac
406 fi
407 ;;
408 mips-*-linux?) OUT="linux-mips" ;;
409 ppc-*-linux2) OUT="linux-ppc" ;;
2933ed4d 410 m68k-*-linux*) OUT="linux-m68k" ;;
010712ff 411 ia64-*-linux?) OUT="linux-ia64" ;;
0fad6cb7 412 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
a0618e3e 413 sparc64-*-linux2)
1656ef29
AP
414 #Before we can uncomment following lines we have to wait at least
415 #till 64-bit glibc for SPARC is operational:-(
416 #echo "WARNING! If you wish to build 64-bit library, then you have to"
a0618e3e
AP
417 #echo " invoke './Configure linux64-sparcv9' *manually*."
418 #echo " Type Ctrl-C if you don't want to continue."
419 #read waste < /dev/tty
420 OUT="linux-sparcv9" ;;
da8fa72f 421 sparc-*-linux2)
a0618e3e
AP
422 KARCH=`awk '/type/{print$3}' /proc/cpuinfo`
423 case ${KARCH:-sun4} in
424 sun4u*) OUT="linux-sparcv9" ;;
425 sun4m) OUT="linux-sparcv8" ;;
426 sun4d) OUT="linux-sparcv8" ;;
427 *) OUT="linux-sparcv7" ;;
428 esac ;;
b1086116 429 arm*-*-linux2) OUT="linux-elf-arm" ;;
58964a49 430 *-*-linux2) OUT="linux-elf" ;;
dabba110 431 *-*-linux1) OUT="linux-aout" ;;
1656ef29
AP
432 sun4u*-sun-solaris2)
433 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
434 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
435 echo "WARNING! If you wish to build 64-bit library, then you have to"
436 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
437 echo " Type Ctrl-C if you don't want to continue."
438 read waste < /dev/tty
439 fi
440 OUT="solaris-sparcv9-$CC" ;;
441 sun4m-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
442 sun4d-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
443 sun4*-sun-solaris2) OUT="solaris-sparcv7-$CC" ;;
58964a49
RE
444 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
445 *-*-sunos4) OUT="sunos-$CC" ;;
44717474
RE
446 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
447 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
448 *-freebsd[1-2]*) OUT="FreeBSD" ;;
58964a49
RE
449 *86*-*-netbsd) OUT="NetBSD-x86" ;;
450 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
451 *-*-netbsd) OUT="NetBSD-sparc" ;;
dfeab068
RE
452 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
453 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
454 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
455 *-*-openbsd) OUT="OpenBSD" ;;
0cceb1c7 456 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
dfeab068 457 *-*-osf) OUT="alpha-cc" ;;
9a5a7401
RL
458 *-*-unixware7) OUT="unixware-7" ;;
459 *-*-UnixWare7) OUT="unixware-7" ;;
460 *-*-Unixware7) OUT="unixware-7" ;;
461 *-*-unixware[1-2]*) OUT="unixware-2.0" ;;
462 *-*-UnixWare[1-2]*) OUT="unixware-2.0" ;;
463 *-*-Unixware[1-2]*) OUT="unixware-2.0" ;;
9231f477 464 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
1fac96e4
UM
465 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
466 *-siemens-sysv4) OUT="SINIX" ;;
bcba6cc6
AP
467 *-hpux1*) OUT="hpux-parisc-$CC"
468 options="$options -D_REENTRANT" ;;
469 *-hpux) OUT="hpux-parisc-$CC" ;;
58964a49 470 # these are all covered by the catchall below
58964a49
RE
471 # *-aix) OUT="aix-$CC" ;;
472 # *-dgux) OUT="dgux" ;;
473 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
5d3bb220
UM
474esac
475
bd03b99b
BL
476# See whether we can compile Atalla support
477if [ -f /usr/include/atasi.h ]
478then
479 options="$options -DATALLA"
480fi
481
b6735832 482# gcc < 2.8 does not support -mcpu=ultrasparc
1656ef29 483if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
b6735832 484then
a0618e3e 485 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
1656ef29
AP
486 sleep 5
487 OUT=solaris-sparcv9-gcc27
a0618e3e
AP
488fi
489if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
490then
491 echo "WARNING! Falling down to 'linux-sparcv8'."
492 echo " Upgrade to gcc-2.8 or later."
1656ef29 493 sleep 5
a0618e3e 494 OUT=linux-sparcv8
b6735832 495fi
f8bbcf3a
AP
496# To start with $OUT is never i86pc-sun-solaris2. Secondly why
497# ban *all* assembler implementation if it can't stand only one,
498# SHA-0 implementation.
499#if [ "$OUT" = "i86pc-sun-solaris2" ]
500#then
501# ASM=`as -V /dev/null 2>&1`
502# case "$ASM" in
503# GNU*) ;;
504# *) 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." ;;
505# esac
506#fi
b6735832 507
5d3bb220
UM
508case "$GUESSOS" in
509 i386-*) options="$options 386" ;;
58964a49
RE
510esac
511
5676d8cb 512for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
9231f477
UM
513do
514 if [ ! -d crypto/$i ]
515 then
516 options="$options no-$i"
517 fi
518done
519
58964a49
RE
520if [ -z "$OUT" ]; then
521 OUT="$CC"
522fi
523
99aab161
UM
524if [ ".$PERL" = . ] ; then
525 for i in . `echo $PATH | sed 's/:/ /g'`; do
526 if [ -f "$i/perl5" ] ; then
527 PERL="$i/perl5"
528 break;
529 fi;
530 done
531fi
532
533if [ ".$PERL" = . ] ; then
534 for i in . `echo $PATH | sed 's/:/ /g'`; do
535 if [ -f "$i/perl" ] ; then
a5a47e4a
UM
536 if "$i/perl" -e 'exit($]<5.0)'; then
537 PERL="$i/perl"
538 break;
539 fi;
99aab161
UM
540 fi;
541 done
542fi
543
a5a47e4a 544if [ ".$PERL" = . ] ; then
99aab161
UM
545 echo "You need Perl 5."
546 exit 1
547fi
548
58964a49
RE
549# run Configure to check to see if we need to specify the
550# compiler for the platform ... in which case we add it on
551# the end ... otherwise we leave it off
99aab161 552
10a926c1 553$PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
58964a49
RE
554if [ $? = "0" ]; then
555 OUT="$OUT-$CC"
556fi
557
558OUT="$PREFIX$OUT"
559
10a926c1 560$PERL ./Configure LIST | grep "$OUT" > /dev/null
b1fe6b43 561if [ $? = "0" ]; then
c59cb511 562 #echo Configuring for $OUT
58964a49 563
b1fe6b43
UM
564 if [ "$TEST" = "true" ]; then
565 echo $PERL ./Configure $OUT $options
566 else
567 $PERL ./Configure $OUT $options
568 fi
58964a49 569else
744029c1 570 echo "This system ($OUT) is not supported. See file INSTALL for details."
58964a49 571fi
58964a49 572)