3 # OpenSSL config: determine the operating system and run ./Configure
5 # "config -h" for usage information.
7 # this is a merge of minarch and GuessOS from the Apache Group.
8 # Originally written by Tim Hudson <tjh@cryptsoft.com>.
10 # Original Apache Group comments on GuessOS
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.
20 # Be as similar to the output of config.guess/config.sub
23 # First get uname entries that we use below
25 MACHINE
=`(uname -m) 2>/dev/null` || MACHINE
="unknown"
26 RELEASE
=`(uname -r) 2>/dev/null` || RELEASE
="unknown"
27 SYSTEM
=`(uname -s) 2>/dev/null` || SYSTEM
="unknown"
28 VERSION
=`(uname -v) 2>/dev/null` || VERSION
="unknown"
31 # Now test for ISC and SCO, since it is has a braindamaged uname.
33 # We need to work around FreeBSD 1.1.5.1
35 XREL
=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
36 if [ "x$XREL" != "x" ]; then
37 if [ -f /etc
/kconfig
]; then
40 echo "${MACHINE}-whatever-isc4"; exit 0
46 echo "whatever-whatever-sco3"; exit 0
49 echo "whatever-whatever-sco5"; exit 0
52 if [ "x$VERSION" = "x2.01" ]; then
53 echo "${MACHINE}-whatever-unixware201"; exit 0
54 elif [ "x$VERSION" = "x2.02" ]; then
55 echo "${MACHINE}-whatever-unixware202"; exit 0
56 elif [ "x$VERSION" = "x2.03" ]; then
57 echo "${MACHINE}-whatever-unixware203"; exit 0
58 elif [ "x$VERSION" = "x2.1.1" ]; then
59 echo "${MACHINE}-whatever-unixware211"; exit 0
60 elif [ "x$VERSION" = "x2.1.2" ]; then
61 echo "${MACHINE}-whatever-unixware212"; exit 0
62 elif [ "x$VERSION" = "x2.1.3" ]; then
63 echo "${MACHINE}-whatever-unixware213"; exit 0
65 echo "${MACHINE}-whatever-unixware2"; exit 0
69 echo "whatever-whatever-unixware1"; exit 0
72 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x8" ]; then
73 echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
77 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then
78 echo "${MACHINE}-sco-unixware7"; exit 0
84 # Now we simply scan though... In most cases, the SYSTEM info is enough
86 case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
88 MACHINE
=`echo "$MACHINE" | sed -e 's/-/_/g'`
89 echo "parisc-hp-MPE/iX"; exit 0
92 echo "m68k-apple-aux3"; exit 0
96 echo "${MACHINE}-ibm-aix43"; exit 0
100 echo "${MACHINE}-ibm-aix43"; exit 0
104 echo "${MACHINE}-ibm-aix"; exit 0
108 echo "${MACHINE}-dg-dgux"; exit 0
112 echo "${MACHINE}-hi-hiux"; exit 0
116 HPUXVER
=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
119 echo "${MACHINE}-hp-hpux11"; exit 0
122 echo "${MACHINE}-hp-hpux10"; exit 0
125 echo "${MACHINE}-hp-hpux"; exit 0
131 echo "mips2-sgi-irix"; exit 0
135 echo "mips3-sgi-irix"; exit 0
139 echo "mips4-sgi-irix64"; exit 0
143 echo "${MACHINE}-whatever-linux2"; exit 0
147 echo "${MACHINE}-whatever-linux1"; exit 0
151 echo "${MACHINE}-lynx-lynxos"; exit 0
154 BSD
/OS
:4.
*) # BSD/OS always says 386
155 echo "i486-whatever-bsdi4"; exit 0
158 BSD
/386:*:*:*486*|BSD
/OS
:*:*:*:*486*)
159 case `/sbin/sysctl -n hw.model` in
161 echo "i586-whatever-bsdi"; exit 0
164 echo "i386-whatever-bsdi"; exit 0
170 echo "${MACHINE}-whatever-bsdi"; exit 0
174 VERS
=`echo ${RELEASE} | sed -e 's/[-(].*//'`
175 MACH
=`sysctl -n hw.model`
178 *386* ) MACH
="i386" ;;
179 *486* ) MACH
="i486" ;;
180 Pentium\ II
*) MACH
="i686" ;;
181 Pentium
* ) MACH
="i586" ;;
182 Alpha
* ) MACH
="alpha" ;;
183 * ) MACH
="$MACHINE" ;;
186 i
[0-9]86 ) ARCH
="pc" ;;
188 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
192 echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
196 echo "${MACHINE}-whatever-netbsd"; exit 0
200 echo "${MACHINE}-whatever-openbsd"; exit 0
204 echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
208 OSFMAJOR
=`echo ${RELEASE}| sed -e 's/^V\([0-9]*\)\..*$/\1/'`
211 echo "${MACHINE}-dec-tru64"; exit 0
214 echo "${MACHINE}-dec-osf"; exit 0
217 echo "${MACHINE}-dec-osf"; exit 0
225 echo "${MACHINE}-whatever-qnx4"
228 echo "${MACHINE}-whatever-qnx6"
231 echo "${MACHINE}-whatever-qnx"
238 echo "i860-intel-osf1"; exit 0
242 echo "ppc-apple-rhapsody"; exit 0
246 echo "ppc-apple-darwin"; exit 0
250 echo "${MACHINE}-whatever-solaris2"; exit 0
254 echo "${MACHINE}-sun-sunos4"; exit 0
258 echo "${MACHINE}-whatever-sysv4"; exit 0
262 echo "${MACHINE}-whatever-sysv4"; exit 0
266 echo "${MACHINE}-whatever-sysv4"; exit 0
269 *:4.0:3.0:3[34]?? |
*:4.0:3.0:3[34]??
,*)
270 echo "i486-ncr-sysv4"; exit 0
274 echo "${MACHINE}-unknown-ultrix"; exit 0
278 echo "${MACHINE}-siemens-sysv4"; exit 0
282 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
286 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
290 echo "${MACHINE}-ncr-sysv4"; exit 0
294 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
298 echo "mips-sony-newsos4"; exit 0;
304 echo "${MACHINE}-whatever-cygwin_pre1.3"
307 echo "${MACHINE}-whatever-cygwin"
314 echo "t3e-cray-unicosmk"; exit 0;
318 echo "j90-cray-unicos"; exit 0;
323 # Ugg. These are all we can determine by what we know about
324 # the output of uname. Be more creative:
327 # Do the Apollo stuff first. Here, we just simply assume
328 # that the existance of the /usr/apollo directory is proof
330 if [ -d /usr
/apollo
]; then
331 echo "whatever-apollo-whatever"
336 ISNEXT
=`hostinfo 2>/dev/null`
339 echo "whatever-next-nextstep3.3"; exit 0
342 echo "whatever-next-nextstep"; exit 0
346 # At this point we gone through all the one's
349 echo "${MACHINE}-whatever-${SYSTEM}"
353 # ---------------------------------------------------------------------------
354 # this is where the translation occurs into SSLeay terms
355 # ---------------------------------------------------------------------------
361 # pick up any command line args to config
365 -d*) PREFIX
="debug-";;
367 -h*) TEST
="true"; cat <<EOF
368 Usage: config [options]
369 -d Add a debug- prefix to machine choice.
370 -t Test mode, do not run the Configure perl script.
373 Any other text will be passed to the Configure perl script.
374 See INSTALL for instructions.
378 *) options
=$options" $i" ;;
382 # figure out if gcc is available and if so we use it otherwise
383 # we fallback to whatever cc does on the system
384 GCCVER
=`(gcc --version) 2>/dev/null`
385 if [ "$GCCVER" != "" ]; then
387 # then strip off whatever prefix Cygnus prepends the number with...
388 GCCVER
=`echo $GCCVER | sed 's/^[a-z]*\-//'`
389 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
390 GCCVER
=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
395 if [ "$SYSTEM" = "SunOS" ]; then
396 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
397 CCVER
=`(cc -V 2>&1) 2>/dev/null | \
398 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
399 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
401 if [ $CCVER -gt 40 ]; then
402 CC
=cc
# overrides gcc!!!
403 if [ $CCVER -eq 50 ]; then
404 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
405 echo " patch #107357-01 or later applied."
408 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
413 if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
414 # check for Compaq C, expected output is "blah-blah C Vx.x"
415 CCCVER
=`(ccc -V 2>&1) 2>/dev/null | \
416 egrep -e '.* C V[0-9]\.[0-9]' | \
417 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
419 if [ $CCCVER -gt 60 ]; then
420 CC
=ccc
# overrides gcc!!! well, ccc outperforms inoticeably
421 # only on hash routines and des, otherwise gcc (2.95)
422 # keeps along rather tight...
429 # read the output of the embedded GuessOS
432 echo Operating system
: $GUESSOS
434 # now map the output into SSLeay terms ... really should hack into the
435 # script above so we end up with values in vars but that would take
436 # more time that I want to waste at the moment
439 CPU
=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
441 if [ $CPU -ge 4000 ]; then
442 options
="$options -mips2"
447 CPU
=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
449 if [ $CPU -ge 5000 ]; then
450 options
="$options -mips4"
452 options
="$options -mips3"
457 echo "WARNING! If you wish to build 64-bit library, then you have to"
458 echo " invoke './Configure irix64-mips4-$CC' *manually*."
459 echo " Type return if you want to continue, Ctrl-C to abort."
460 read waste
< /dev
/tty
461 CPU
=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
463 if [ $CPU -ge 5000 ]; then
464 options
="$options -mips4"
466 options
="$options -mips3"
471 ISA
=`awk '/cpu model/{print$4}' /proc/cpuinfo`
472 case ${ISA:-generic} in
473 *[67]) OUT
="linux-alpha+bwx-$CC" ;;
474 *) OUT
="linux-alpha-$CC" ;;
476 if [ "$CC" = "gcc" ]; then
477 case ${ISA:-generic} in
478 EV5|EV45
) options
="$options -mcpu=ev5";;
479 EV56|PCA56
) options
="$options -mcpu=ev56";;
480 EV6|EV67|PCA57
) options
="$options -mcpu=ev6";;
486 #include <stdio.h> /* for printf() prototype */
487 int main (argc, argv) int argc; char *argv[]; {
489 printf ("linux-%s\n", argv[1]);
492 printf ("linux-%sel\n", argv[1]);
497 ${CC} -o dummy dummy.c
&& OUT
=`./dummy ${MACHINE}`
500 ppc-
*-linux2) OUT
="linux-ppc" ;;
501 m68k-
*-linux*) OUT
="linux-m68k" ;;
502 ia64-
*-linux?
) OUT
="linux-ia64" ;;
503 ppc-apple-rhapsody
) OUT
="rhapsody-ppc-cc" ;;
504 ppc-apple-darwin
) OUT
="darwin-ppc-cc" ;;
506 #Before we can uncomment following lines we have to wait at least
507 #till 64-bit glibc for SPARC is operational:-(
508 #echo "WARNING! If you wish to build 64-bit library, then you have to"
509 #echo " invoke './Configure linux64-sparcv9' *manually*."
510 #echo " Type return if you want to continue, Ctrl-C to abort."
511 #read waste < /dev/tty
512 OUT
="linux-sparcv9" ;;
514 KARCH
=`awk '/^type/{print$3}' /proc/cpuinfo`
515 case ${KARCH:-sun4} in
516 sun4u
*) OUT
="linux-sparcv9" ;;
517 sun4m
) OUT
="linux-sparcv8" ;;
518 sun4d
) OUT
="linux-sparcv8" ;;
519 *) OUT
="linux-sparcv7" ;;
522 CPUARCH
=`awk '/cpu family/{print substr($5,1,3)}' /proc/cpuinfo`
523 CPUSCHEDULE
=`awk '/^cpu.[ ]: PA/{print substr($3,3)}' /proc/cpuinfo`
525 # ??TODO ?? Model transformations
526 # 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
527 # assuming no further arch. identification will ever be used by GCC.
528 # 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
529 # 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
530 # for these chips in the future.
531 # PA7300LC -> 7100LC (1.1)
532 # PA8200 -> 8000 (2.0)
533 # PA8500 -> 8000 (2.0)
534 # PA8600 -> 8000 (2.0)
536 CPUSCHEDULE
=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8?00/8000/'`
537 # Finish Model transformations
539 options
="$options -mschedule=$CPUSCHEDULE -march=$CPUARCH"
540 OUT
="linux-parisc" ;;
541 arm
*-*-linux2) OUT
="linux-elf-arm" ;;
542 s390-
*-linux2) OUT
="linux-s390" ;;
543 s390x-
*-linux?
) OUT
="linux-s390x" ;;
544 *-*-linux2) OUT
="linux-elf" ;;
545 *-*-linux1) OUT
="linux-aout" ;;
547 ISA64
=`(isalist) 2>/dev/null | grep sparcv9`
548 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
549 echo "WARNING! If you wish to build 64-bit library, then you have to"
550 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
551 echo " Type return if you want to continue, Ctrl-C to abort."
552 read waste
< /dev
/tty
554 OUT
="solaris-sparcv9-$CC" ;;
555 sun4m-
*-solaris2) OUT
="solaris-sparcv8-$CC" ;;
556 sun4d-
*-solaris2) OUT
="solaris-sparcv8-$CC" ;;
557 sun4
*-*-solaris2) OUT
="solaris-sparcv7-$CC" ;;
558 *86*-*-solaris2) OUT
="solaris-x86-$CC" ;;
559 *-*-sunos4) OUT
="sunos-$CC" ;;
560 alpha
*-*-freebsd*) OUT
="FreeBSD-alpha" ;;
561 *-freebsd[3-9]*) OUT
="FreeBSD-elf" ;;
562 *-freebsd[1-2]*) OUT
="FreeBSD" ;;
563 *86*-*-netbsd) OUT
="NetBSD-x86" ;;
564 sun3
*-*-netbsd) OUT
="NetBSD-m68" ;;
565 *-*-netbsd) OUT
="NetBSD-sparc" ;;
566 *86*-*-openbsd) OUT
="OpenBSD-x86" ;;
567 alpha
*-*-openbsd) OUT
="OpenBSD-alpha" ;;
568 pmax
*-*-openbsd) OUT
="OpenBSD-mips" ;;
569 *-*-openbsd) OUT
="OpenBSD" ;;
570 *86*-*-bsdi4) OUT
="bsdi-elf-gcc" ;;
571 *-*-osf) OUT
="alphaold-cc" ;;
572 *-*-tru64) OUT
="alpha-cc" ;;
574 if [ "$CC" = "gcc" ]; then
580 *-*-unixware7) OUT
="unixware-7" ;;
581 *-*-UnixWare7) OUT
="unixware-7" ;;
582 *-*-Unixware7) OUT
="unixware-7" ;;
583 *-*-unixware20*) OUT
="unixware-2.0" ;;
584 *-*-unixware21*) OUT
="unixware-2.1" ;;
585 *-*-UnixWare20*) OUT
="unixware-2.0" ;;
586 *-*-UnixWare21*) OUT
="unixware-2.1" ;;
587 *-*-Unixware20*) OUT
="unixware-2.0" ;;
588 *-*-Unixware21*) OUT
="unixware-2.1" ;;
589 BS2000-siemens-sysv4
) OUT
="BS2000-OSD" ;;
590 RM
*-siemens-sysv4) OUT
="ReliantUNIX" ;;
591 *-siemens-sysv4) OUT
="SINIX" ;;
592 *-hpux1*) OUT
="hpux-parisc-$CC"
593 options
="$options -D_REENTRANT" ;;
594 *-hpux) OUT
="hpux-parisc-$CC" ;;
595 # these are all covered by the catchall below
596 # *-aix) OUT="aix-$CC" ;;
597 # *-dgux) OUT="dgux" ;;
598 mips-sony-newsos4
) OUT
="newsos4-gcc" ;;
599 *-*-cygwin_pre1.3
) OUT
="Cygwin-pre1.3" ;;
600 *-*-cygwin) OUT
="Cygwin" ;;
601 t3e-cray-unicosmk
) OUT
="cray-t3e" ;;
602 j90-cray-unicos
) OUT
="cray-j90" ;;
603 *) OUT
=`echo $GUESSOS | awk -F- '{print $3}'`;;
606 # See whether we can compile Atalla support
607 if [ -f /usr
/include
/atasi.h
]
609 options
="$options -DATALLA"
612 # gcc < 2.8 does not support -mcpu=ultrasparc
613 if [ "$OUT" = solaris-sparcv9-gcc
-a $GCCVER -lt 28 ]
615 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
617 OUT
=solaris-sparcv9-gcc27
619 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
621 echo "WARNING! Falling down to 'linux-sparcv8'."
622 echo " Upgrade to gcc-2.8 or later."
628 i386-
*) options
="$options 386" ;;
631 for i
in bf cast des dh dsa hmac idea md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
633 if [ ! -d crypto
/$i ]
635 options
="$options no-$i"
639 if [ -z "$OUT" ]; then
643 if [ ".$PERL" = .
] ; then
644 for i
in .
`echo $PATH | sed 's/:/ /g'`; do
645 if [ -f "$i/perl5" ] ; then
652 if [ ".$PERL" = .
] ; then
653 for i
in .
`echo $PATH | sed 's/:/ /g'`; do
654 if [ -f "$i/perl" ] ; then
655 if "$i/perl" -e 'exit($]<5.0)'; then
663 if [ ".$PERL" = .
] ; then
664 echo "You need Perl 5."
668 # run Configure to check to see if we need to specify the
669 # compiler for the platform ... in which case we add it on
670 # the end ... otherwise we leave it off
672 $PERL .
/Configure LIST |
grep "$OUT-$CC" > /dev
/null
673 if [ $?
= "0" ]; then
679 $PERL .
/Configure LIST |
grep "$OUT" > /dev
/null
680 if [ $?
= "0" ]; then
681 echo Configuring
for $OUT
683 if [ "$TEST" = "true" ]; then
684 echo $PERL .
/Configure
$OUT $options
686 $PERL .
/Configure
$OUT $options
689 echo "This system ($OUT) is not supported. See file INSTALL for details."