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.1.1" ]; then
78 echo "${MACHINE}-whatever-unixware211"; exit 0
79 elif [ "x$VERSION" = "x2.1.2" ]; then
80 echo "${MACHINE}-whatever-unixware212"; exit 0
82 echo "${MACHINE}-whatever-unixware2"; exit 0
86 echo "whatever-whatever-unixware1"; exit 0
89 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then
90 echo "${MACHINE}-sco-unixware7"; exit 0
96 # Now we simply scan though... In most cases, the SYSTEM info is enough
98 case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
100 MACHINE=`echo "$MACHINE" | sed -e 's/-/_/g'`
101 echo "parisc-hp-MPE/iX"; exit 0
104 echo "m68k-apple-aux3"; exit 0
108 echo "${MACHINE}-ibm-aix43"; exit 0
112 echo "${MACHINE}-ibm-aix43"; exit 0
116 echo "${MACHINE}-ibm-aix"; exit 0
120 echo "${MACHINE}-dg-dgux"; exit 0
124 echo "${MACHINE}-hi-hiux"; exit 0
128 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
131 echo "${MACHINE}-hp-hpux11"; exit 0
134 echo "${MACHINE}-hp-hpux10"; exit 0
137 echo "${MACHINE}-hp-hpux"; exit 0
143 echo "mips2-sgi-irix"; exit 0
147 echo "mips3-sgi-irix"; exit 0
151 echo "mips4-sgi-irix64"; exit 0
155 echo "${MACHINE}-whatever-linux2"; exit 0
159 echo "${MACHINE}-whatever-linux1"; exit 0
163 echo "hurd-x86"; exit 0;
167 echo "${MACHINE}-lynx-lynxos"; exit 0
170 BSD/OS:4.*) # BSD/OS always says 386
171 echo "i486-whatever-bsdi4"; exit 0
174 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
175 case `/sbin/sysctl -n hw.model` in
177 echo "i586-whatever-bsdi"; exit 0
180 echo "i386-whatever-bsdi"; exit 0
186 echo "${MACHINE}-whatever-bsdi"; exit 0
190 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
191 MACH=`sysctl -n hw.model`
194 *386* ) MACH="i386" ;;
195 *486* ) MACH="i486" ;;
196 Pentium\ II*) MACH="i686" ;;
197 Pentium* ) MACH="i586" ;;
198 Alpha* ) MACH="alpha" ;;
199 * ) MACH="$MACHINE" ;;
202 i[0-9]86 ) ARCH="pc" ;;
204 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
208 echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
212 echo "${MACHINE}-whatever-netbsd"; exit 0
216 echo "${MACHINE}-whatever-openbsd"; exit 0
220 echo "${MACHINE}-dec-osf"; exit 0
226 echo "${MACHINE}-whatever-qnx4"
229 echo "${MACHINE}-whatever-qnx"
236 echo "i860-intel-osf1"; exit 0
240 echo "ppc-apple-rhapsody"; exit 0
246 echo "ppc-apple-darwin${VERSION}"
249 echo "i386-apple-darwin${VERSION}"
256 echo "${MACHINE}-whatever-solaris2"; exit 0
260 echo "${MACHINE}-sun-sunos4"; exit 0
264 echo "${MACHINE}-whatever-sysv4"; exit 0
268 echo "${MACHINE}-whatever-sysv4"; exit 0
272 echo "${MACHINE}-whatever-sysv4"; exit 0
275 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
276 echo "i486-ncr-sysv4"; exit 0
280 echo "${MACHINE}-unknown-ultrix"; exit 0
284 echo "${MACHINE}-siemens-sysv4"; exit 0
288 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
292 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
296 echo "${MACHINE}-ncr-sysv4"; exit 0
300 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
304 echo "mips-sony-newsos4"; exit 0;
310 # Ugg. These are all we can determine by what we know about
311 # the output of uname. Be more creative:
314 # Do the Apollo stuff first. Here, we just simply assume
315 # that the existance of the /usr/apollo directory is proof
317 if [ -d /usr/apollo ]; then
318 echo "whatever-apollo-whatever"
323 ISNEXT=`hostinfo 2>/dev/null`
326 echo "whatever-next-nextstep3.3"; exit 0
329 echo "whatever-next-nextstep"; exit 0
333 # At this point we gone through all the one's
336 echo "${MACHINE}-whatever-${SYSTEM}"
340 # ---------------------------------------------------------------------------
341 # this is where the translation occurs into SSLeay terms
342 # ---------------------------------------------------------------------------
344 # figure out if gcc is available and if so we use it otherwise
345 # we fallback to whatever cc does on the system
346 GCCVER=`(gcc --version) 2>/dev/null`
347 if [ "$GCCVER" != "" ]; then
349 # then strip off whatever prefix Cygnus prepends the number with...
350 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
351 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
352 GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
357 if [ "$SYSTEM" = "SunOS" ]; then
358 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
359 CCVER=`(cc -V 2>&1) 2>/dev/null | \
360 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
361 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
363 if [ $CCVER -gt 40 ]; then
364 CC=cc # overrides gcc!!!
365 if [ $CCVER -eq 50 ]; then
366 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
367 echo " patch #107357-01 or later applied."
370 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
375 if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
376 # check for Compaq C, expected output is "blah-blah C Vx.x"
377 CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
378 egrep -e '.* C V[0-9]\.[0-9]' | \
379 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
381 if [ $CCCVER -gt 60 ]; then
382 CC=ccc # overrides gcc!!! well, ccc outperforms inoticeably
383 # only on hash routines and des, otherwise gcc (2.95)
384 # keeps along rather tight...
391 # read the output of the embedded GuessOS
394 echo Operating system: $GUESSOS
396 # now map the output into SSLeay terms ... really should hack into the
397 # script above so we end up with values in vars but that would take
398 # more time that I want to waste at the moment
401 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
403 if [ $CPU -ge 4000 ]; then
404 options="$options -mips2"
409 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
411 if [ $CPU -ge 5000 ]; then
412 options="$options -mips4"
414 options="$options -mips3"
419 echo "WARNING! If you wish to build 64-bit library, then you have to"
420 echo " invoke './Configure irix64-mips4-$CC' *manually*."
421 echo " Type return if you want to continue, Ctrl-C to abort."
422 if [ "$TEST" = "false" ]; then
423 read waste < /dev/tty
425 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
427 if [ $CPU -ge 5000 ]; then
428 options="$options -mips4"
430 options="$options -mips3"
435 ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
436 case ${ISA:-generic} in
437 *[67]) OUT="linux-alpha+bwx-$CC" ;;
438 *) OUT="linux-alpha-$CC" ;;
440 if [ "$CC" = "gcc" ]; then
441 case ${ISA:-generic} in
442 EV5|EV45) options="$options -mcpu=ev5";;
443 EV56|PCA56) options="$options -mcpu=ev56";;
444 EV6|EV67|PCA57) options="$options -mcpu=ev6";;
450 #include <stdio.h> /* for printf() prototype */
451 int main (argc, argv) int argc; char *argv[]; {
453 printf ("linux-%s\n", argv[1]);
456 printf ("linux-%sel\n", argv[1]);
461 ${CC} -o dummy dummy.c && OUT=`./dummy ${MACHINE}`
464 ppc-*-linux2) OUT="linux-ppc" ;;
465 m68k-*-linux*) OUT="linux-m68k" ;;
466 ia64-*-linux?) OUT="linux-ia64" ;;
467 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
468 ppc-apple-darwin*) OUT="darwin-ppc-cc" ;;
469 i386-apple-darwin*) OUT="darwin-i386-cc" ;;
471 #Before we can uncomment following lines we have to wait at least
472 #till 64-bit glibc for SPARC is operational:-(
473 #echo "WARNING! If you wish to build 64-bit library, then you have to"
474 #echo " invoke './Configure linux64-sparcv9' *manually*."
475 #echo " Type return if you want to continue, Ctrl-C to abort."
476 #read waste < /dev/tty
477 OUT="linux-sparcv9" ;;
479 KARCH=`awk '/^type/{print$3}' /proc/cpuinfo`
480 case ${KARCH:-sun4} in
481 sun4u*) OUT="linux-sparcv9" ;;
482 sun4m) OUT="linux-sparcv8" ;;
483 sun4d) OUT="linux-sparcv8" ;;
484 *) OUT="linux-sparcv7" ;;
486 arm*-*-linux2) OUT="linux-elf-arm" ;;
487 s390-*-linux2) OUT="linux-s390" ;;
488 *-*-linux2) OUT="linux-elf" ;;
489 *-*-linux1) OUT="linux-aout" ;;
491 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
492 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
493 echo "WARNING! If you wish to build 64-bit library, then you have to"
494 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
495 echo " Type return if you want to continue, Ctrl-C to abort."
496 if [ "$TEST" = "false" ]; then
497 read waste < /dev/tty
500 OUT="solaris-sparcv9-$CC" ;;
501 sun4m-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
502 sun4d-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
503 sun4*-*-solaris2) OUT="solaris-sparcv7-$CC" ;;
504 *86*-*-solaris2) OUT="solaris-x86-$CC" ;;
505 *-*-sunos4) OUT="sunos-$CC" ;;
506 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
507 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
508 *-freebsd[1-2]*) OUT="FreeBSD" ;;
509 *86*-*-netbsd) OUT="NetBSD-x86" ;;
510 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
511 *-*-netbsd) OUT="NetBSD-sparc" ;;
512 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
513 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
514 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
515 *-*-openbsd) OUT="OpenBSD" ;;
516 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
517 *-*-osf) OUT="alpha-cc" ;;
518 *-*-unixware7) OUT="unixware-7" ;;
519 *-*-UnixWare7) OUT="unixware-7" ;;
520 *-*-Unixware7) OUT="unixware-7" ;;
521 *-*-unixware[1-2]*) OUT="unixware-2.0" ;;
522 *-*-UnixWare[1-2]*) OUT="unixware-2.0" ;;
523 *-*-Unixware[1-2]*) OUT="unixware-2.0" ;;
524 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
525 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
526 *-siemens-sysv4) OUT="SINIX" ;;
527 *-hpux1*) OUT="hpux-parisc-$CC"
528 options="$options -D_REENTRANT" ;;
529 *-hpux) OUT="hpux-parisc-$CC" ;;
530 # these are all covered by the catchall below
531 # *-aix) OUT="aix-$CC" ;;
532 # *-dgux) OUT="dgux" ;;
533 mips-sony-newsos4) OUT="newsos4-gcc" ;;
534 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
537 # NB: This atalla support has been superceded by the ENGINE support
538 # That contains its own header and definitions anyway. Support can
539 # be enabled or disabled on any supported platform without external
540 # headers, eg. by adding the "hw-atalla" switch to ./config or
543 # See whether we can compile Atalla support
544 #if [ -f /usr/include/atasi.h ]
546 # options="$options -DATALLA"
549 # gcc < 2.8 does not support -mcpu=ultrasparc
550 if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
552 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
554 OUT=solaris-sparcv9-gcc27
556 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
558 echo "WARNING! Falling down to 'linux-sparcv8'."
559 echo " Upgrade to gcc-2.8 or later."
565 i386-*) options="$options 386" ;;
568 for i in bf cast des dh dsa ec hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
570 if [ ! -d crypto/$i ]
572 options="$options no-$i"
576 # Discover Kerberos 5 (since it's still a prototype, we don't
577 # do any guesses yet, that's why this section is commented away.
578 #if [ -d /usr/kerberos ]; then
579 # krb5_dir=/usr/kerberos
580 # if [ \( -f $krb5_dir/lib/libgssapi_krb5.a -o -f $krb5_dir/lib/libgssapi_krb5.so* \)\
581 # -a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
582 # -a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
583 # -a \( -f $krb5_dir/lib/libk5crypto.a -o -f $krb5_dir/lib/libk5crypto.so* \)\
584 # -a \( -f $krb5_dir/include/krb5.h \) ]; then
585 # options="$options --with-krb5-flavor=MIT"
587 #elif [ -d /usr/heimdal ]; then
588 # krb5_dir=/usr/heimdal
589 # if [ \( -f $krb5_dir/lib/libgssapi.a -o -f $krb5_dir/lib/libgssapi.so* \)\
590 # -a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
591 # -a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
592 # -a \( -f $krb5_dir/include/krb5.h \) ]; then
593 # options="$options --with-krb5-flavor=Heimdal"
597 if [ -z "$OUT" ]; then
601 if [ ".$PERL" = . ] ; then
602 for i in . `echo $PATH | sed 's/:/ /g'`; do
603 if [ -f "$i/perl5" ] ; then
610 if [ ".$PERL" = . ] ; then
611 for i in . `echo $PATH | sed 's/:/ /g'`; do
612 if [ -f "$i/perl" ] ; then
613 if "$i/perl" -e 'exit($]<5.0)'; then
621 if [ ".$PERL" = . ] ; then
622 echo "You need Perl 5."
626 # run Configure to check to see if we need to specify the
627 # compiler for the platform ... in which case we add it on
628 # the end ... otherwise we leave it off
630 $PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
631 if [ $? = "0" ]; then
637 $PERL ./Configure LIST | grep "$OUT" > /dev/null
638 if [ $? = "0" ]; then
639 echo Configuring for $OUT
641 if [ "$TEST" = "true" ]; then
642 echo $PERL ./Configure $OUT $options
644 $PERL ./Configure $OUT $options
647 echo "This system ($OUT) is not supported. See file INSTALL for details."