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
27 # pick up any command line args to config
31 -d*) PREFIX="debug-";;
33 -h*) TEST="true"; cat <<EOF
34 Usage: config [options]
35 -d Add a debug- prefix to machine choice.
36 -t Test mode, do not run the Configure perl script.
39 Any other text will be passed to the Configure perl script.
40 See INSTALL for instructions.
44 *) options=$options" $i" ;;
48 # First get uname entries that we use below
50 MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
51 RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
52 SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown"
53 VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
56 # Now test for ISC and SCO, since it is has a braindamaged uname.
58 # We need to work around FreeBSD 1.1.5.1
60 XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
61 if [ "x$XREL" != "x" ]; then
62 if [ -f /etc/kconfig ]; then
65 echo "${MACHINE}-whatever-isc4"; exit 0
71 echo "whatever-whatever-sco3"; exit 0
74 echo "whatever-whatever-sco5"; exit 0
77 if [ "x$VERSION" = "x2.01" ]; then
78 echo "${MACHINE}-whatever-unixware201"; exit 0
79 elif [ "x$VERSION" = "x2.02" ]; then
80 echo "${MACHINE}-whatever-unixware202"; exit 0
81 elif [ "x$VERSION" = "x2.03" ]; then
82 echo "${MACHINE}-whatever-unixware203"; exit 0
83 elif [ "x$VERSION" = "x2.1.1" ]; then
84 echo "${MACHINE}-whatever-unixware211"; exit 0
85 elif [ "x$VERSION" = "x2.1.2" ]; then
86 echo "${MACHINE}-whatever-unixware212"; exit 0
87 elif [ "x$VERSION" = "x2.1.3" ]; then
88 echo "${MACHINE}-whatever-unixware213"; exit 0
90 echo "${MACHINE}-whatever-unixware2"; exit 0
94 echo "whatever-whatever-unixware1"; exit 0
97 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then
98 echo "${MACHINE}-sco-unixware7"; exit 0
104 # Now we simply scan though... In most cases, the SYSTEM info is enough
106 case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
108 MACHINE=`echo "$MACHINE" | sed -e 's/-/_/g'`
109 echo "parisc-hp-MPE/iX"; exit 0
112 echo "m68k-apple-aux3"; exit 0
116 echo "${MACHINE}-ibm-aix43"; exit 0
120 echo "${MACHINE}-ibm-aix43"; exit 0
124 echo "${MACHINE}-ibm-aix"; exit 0
128 echo "${MACHINE}-dg-dgux"; exit 0
132 echo "${MACHINE}-hi-hiux"; exit 0
136 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
139 echo "${MACHINE}-hp-hpux11"; exit 0
142 echo "${MACHINE}-hp-hpux10"; exit 0
145 echo "${MACHINE}-hp-hpux"; exit 0
151 echo "mips2-sgi-irix"; exit 0
155 echo "mips3-sgi-irix"; exit 0
159 echo "mips4-sgi-irix64"; exit 0
163 echo "${MACHINE}-whatever-linux2"; exit 0
167 echo "${MACHINE}-whatever-linux1"; exit 0
171 echo "hurd-x86"; exit 0;
175 echo "${MACHINE}-lynx-lynxos"; exit 0
178 BSD/OS:4.*) # BSD/OS always says 386
179 echo "i486-whatever-bsdi4"; exit 0
182 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
183 case `/sbin/sysctl -n hw.model` in
185 echo "i586-whatever-bsdi"; exit 0
188 echo "i386-whatever-bsdi"; exit 0
194 echo "${MACHINE}-whatever-bsdi"; exit 0
198 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
199 MACH=`sysctl -n hw.model`
202 *386* ) MACH="i386" ;;
203 *486* ) MACH="i486" ;;
204 Pentium\ II*) MACH="i686" ;;
205 Pentium* ) MACH="i586" ;;
206 Alpha* ) MACH="alpha" ;;
207 * ) MACH="$MACHINE" ;;
210 i[0-9]86 ) ARCH="pc" ;;
212 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
216 echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
220 echo "${MACHINE}-whatever-netbsd"; exit 0
224 echo "${MACHINE}-whatever-openbsd"; exit 0
228 echo "${MACHINE}-dec-osf"; exit 0
234 echo "${MACHINE}-whatever-qnx4"
237 echo "${MACHINE}-whatever-qnx"
244 echo "i860-intel-osf1"; exit 0
248 echo "ppc-apple-rhapsody"; exit 0
254 echo "ppc-apple-darwin${VERSION}"
257 echo "i386-apple-darwin${VERSION}"
264 echo "${MACHINE}-whatever-solaris2"; exit 0
268 echo "${MACHINE}-sun-sunos4"; exit 0
272 echo "${MACHINE}-whatever-sysv4"; exit 0
276 echo "${MACHINE}-whatever-sysv4"; exit 0
280 echo "${MACHINE}-whatever-sysv4"; exit 0
283 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
284 echo "i486-ncr-sysv4"; exit 0
288 echo "${MACHINE}-unknown-ultrix"; exit 0
292 echo "${MACHINE}-siemens-sysv4"; exit 0
296 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
300 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
304 echo "${MACHINE}-ncr-sysv4"; exit 0
308 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
312 echo "mips-sony-newsos4"; exit 0;
318 # Ugg. These are all we can determine by what we know about
319 # the output of uname. Be more creative:
322 # Do the Apollo stuff first. Here, we just simply assume
323 # that the existance of the /usr/apollo directory is proof
325 if [ -d /usr/apollo ]; then
326 echo "whatever-apollo-whatever"
331 ISNEXT=`hostinfo 2>/dev/null`
334 echo "whatever-next-nextstep3.3"; exit 0
337 echo "whatever-next-nextstep"; exit 0
341 # At this point we gone through all the one's
344 echo "${MACHINE}-whatever-${SYSTEM}"
348 # ---------------------------------------------------------------------------
349 # this is where the translation occurs into SSLeay terms
350 # ---------------------------------------------------------------------------
352 # figure out if gcc is available and if so we use it otherwise
353 # we fallback to whatever cc does on the system
354 GCCVER=`(gcc --version) 2>/dev/null`
355 if [ "$GCCVER" != "" ]; then
357 # then strip off whatever prefix Cygnus prepends the number with...
358 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
359 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
360 GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
365 if [ "$SYSTEM" = "SunOS" ]; then
366 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
367 CCVER=`(cc -V 2>&1) 2>/dev/null | \
368 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
369 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
371 if [ $CCVER -gt 40 ]; then
372 CC=cc # overrides gcc!!!
373 if [ $CCVER -eq 50 ]; then
374 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
375 echo " patch #107357-01 or later applied."
378 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
383 if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
384 # check for Compaq C, expected output is "blah-blah C Vx.x"
385 CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
386 egrep -e '.* C V[0-9]\.[0-9]' | \
387 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
389 if [ $CCCVER -gt 60 ]; then
390 CC=ccc # overrides gcc!!! well, ccc outperforms inoticeably
391 # only on hash routines and des, otherwise gcc (2.95)
392 # keeps along rather tight...
399 # read the output of the embedded GuessOS
402 echo Operating system: $GUESSOS
404 # now map the output into SSLeay terms ... really should hack into the
405 # script above so we end up with values in vars but that would take
406 # more time that I want to waste at the moment
409 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
411 if [ $CPU -ge 4000 ]; then
412 options="$options -mips2"
417 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
419 if [ $CPU -ge 5000 ]; then
420 options="$options -mips4"
422 options="$options -mips3"
427 echo "WARNING! If you wish to build 64-bit library, then you have to"
428 echo " invoke './Configure irix64-mips4-$CC' *manually*."
429 echo " Type return if you want to continue, Ctrl-C to abort."
430 if [ "$TEST" = "false" ]; then
431 read waste < /dev/tty
433 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
435 if [ $CPU -ge 5000 ]; then
436 options="$options -mips4"
438 options="$options -mips3"
443 ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
444 case ${ISA:-generic} in
445 *[67]) OUT="linux-alpha+bwx-$CC" ;;
446 *) OUT="linux-alpha-$CC" ;;
448 if [ "$CC" = "gcc" ]; then
449 case ${ISA:-generic} in
450 EV5|EV45) options="$options -mcpu=ev5";;
451 EV56|PCA56) options="$options -mcpu=ev56";;
452 EV6|EV67|PCA57) options="$options -mcpu=ev6";;
458 #include <stdio.h> /* for printf() prototype */
459 int main (argc, argv) int argc; char *argv[]; {
461 printf ("linux-%s\n", argv[1]);
464 printf ("linux-%sel\n", argv[1]);
469 ${CC} -o dummy dummy.c && OUT=`./dummy ${MACHINE}`
472 ppc-*-linux2) OUT="linux-ppc" ;;
473 m68k-*-linux*) OUT="linux-m68k" ;;
474 ia64-*-linux?) OUT="linux-ia64" ;;
475 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
476 ppc-apple-darwin*) OUT="darwin-ppc-cc" ;;
477 i386-apple-darwin*) OUT="darwin-i386-cc" ;;
479 #Before we can uncomment following lines we have to wait at least
480 #till 64-bit glibc for SPARC is operational:-(
481 #echo "WARNING! If you wish to build 64-bit library, then you have to"
482 #echo " invoke './Configure linux64-sparcv9' *manually*."
483 #echo " Type return if you want to continue, Ctrl-C to abort."
484 #read waste < /dev/tty
485 OUT="linux-sparcv9" ;;
487 KARCH=`awk '/^type/{print$3}' /proc/cpuinfo`
488 case ${KARCH:-sun4} in
489 sun4u*) OUT="linux-sparcv9" ;;
490 sun4m) OUT="linux-sparcv8" ;;
491 sun4d) OUT="linux-sparcv8" ;;
492 *) OUT="linux-sparcv7" ;;
494 arm*-*-linux2) OUT="linux-elf-arm" ;;
495 s390-*-linux2) OUT="linux-s390" ;;
496 *-*-linux2) OUT="linux-elf" ;;
497 *-*-linux1) OUT="linux-aout" ;;
499 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
500 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
501 echo "WARNING! If you wish to build 64-bit library, then you have to"
502 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
503 echo " Type return if you want to continue, Ctrl-C to abort."
504 if [ "$TEST" = "false" ]; then
505 read waste < /dev/tty
508 OUT="solaris-sparcv9-$CC" ;;
509 sun4m-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
510 sun4d-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
511 sun4*-*-solaris2) OUT="solaris-sparcv7-$CC" ;;
512 *86*-*-solaris2) OUT="solaris-x86-$CC" ;;
513 *-*-sunos4) OUT="sunos-$CC" ;;
514 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
515 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
516 *-freebsd[1-2]*) OUT="FreeBSD" ;;
517 *86*-*-netbsd) OUT="NetBSD-x86" ;;
518 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
519 *-*-netbsd) OUT="NetBSD-sparc" ;;
520 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
521 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
522 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
523 *-*-openbsd) OUT="OpenBSD" ;;
524 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
525 *-*-osf) OUT="alpha-cc" ;;
526 *-*-unixware7) OUT="unixware-7" ;;
527 *-*-UnixWare7) OUT="unixware-7" ;;
528 *-*-Unixware7) OUT="unixware-7" ;;
529 *-*-unixware20*) OUT="unixware-2.0" ;;
530 *-*-unixware21*) OUT="unixware-2.1" ;;
531 *-*-UnixWare20*) OUT="unixware-2.0" ;;
532 *-*-UnixWare21*) OUT="unixware-2.1" ;;
533 *-*-Unixware20*) OUT="unixware-2.0" ;;
534 *-*-Unixware21*) OUT="unixware-2.1" ;;
535 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
536 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
537 *-siemens-sysv4) OUT="SINIX" ;;
538 *-hpux1*) OUT="hpux-parisc-$CC"
539 options="$options -D_REENTRANT" ;;
540 *-hpux) OUT="hpux-parisc-$CC" ;;
541 # these are all covered by the catchall below
542 # *-aix) OUT="aix-$CC" ;;
543 # *-dgux) OUT="dgux" ;;
544 mips-sony-newsos4) OUT="newsos4-gcc" ;;
545 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
548 # NB: This atalla support has been superceded by the ENGINE support
549 # That contains its own header and definitions anyway. Support can
550 # be enabled or disabled on any supported platform without external
551 # headers, eg. by adding the "hw-atalla" switch to ./config or
554 # See whether we can compile Atalla support
555 #if [ -f /usr/include/atasi.h ]
557 # options="$options -DATALLA"
560 # gcc < 2.8 does not support -mcpu=ultrasparc
561 if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
563 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
565 OUT=solaris-sparcv9-gcc27
567 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
569 echo "WARNING! Falling down to 'linux-sparcv8'."
570 echo " Upgrade to gcc-2.8 or later."
576 i386-*) options="$options 386" ;;
579 for i in bf cast des dh dsa ec hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
581 if [ ! -d crypto/$i ]
583 options="$options no-$i"
587 # Discover Kerberos 5 (since it's still a prototype, we don't
588 # do any guesses yet, that's why this section is commented away.
589 #if [ -d /usr/kerberos ]; then
590 # krb5_dir=/usr/kerberos
591 # if [ \( -f $krb5_dir/lib/libgssapi_krb5.a -o -f $krb5_dir/lib/libgssapi_krb5.so* \)\
592 # -a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
593 # -a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
594 # -a \( -f $krb5_dir/lib/libk5crypto.a -o -f $krb5_dir/lib/libk5crypto.so* \)\
595 # -a \( -f $krb5_dir/include/krb5.h \) ]; then
596 # options="$options --with-krb5-flavor=MIT"
598 #elif [ -d /usr/heimdal ]; then
599 # krb5_dir=/usr/heimdal
600 # if [ \( -f $krb5_dir/lib/libgssapi.a -o -f $krb5_dir/lib/libgssapi.so* \)\
601 # -a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
602 # -a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
603 # -a \( -f $krb5_dir/include/krb5.h \) ]; then
604 # options="$options --with-krb5-flavor=Heimdal"
608 if [ -z "$OUT" ]; then
612 if [ ".$PERL" = . ] ; then
613 for i in . `echo $PATH | sed 's/:/ /g'`; do
614 if [ -f "$i/perl5" ] ; then
621 if [ ".$PERL" = . ] ; then
622 for i in . `echo $PATH | sed 's/:/ /g'`; do
623 if [ -f "$i/perl" ] ; then
624 if "$i/perl" -e 'exit($]<5.0)'; then
632 if [ ".$PERL" = . ] ; then
633 echo "You need Perl 5."
637 # run Configure to check to see if we need to specify the
638 # compiler for the platform ... in which case we add it on
639 # the end ... otherwise we leave it off
641 $PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
642 if [ $? = "0" ]; then
648 $PERL ./Configure LIST | grep "$OUT" > /dev/null
649 if [ $? = "0" ]; then
650 echo Configuring for $OUT
652 if [ "$TEST" = "true" ]; then
653 echo $PERL ./Configure $OUT $options
655 $PERL ./Configure $OUT $options
658 echo "This system ($OUT) is not supported. See file INSTALL for details."