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.1.1" ]; then
53 echo "${MACHINE}-whatever-unixware211"; exit 0
54 elif [ "x$VERSION" = "x2.1.2" ]; then
55 echo "${MACHINE}-whatever-unixware212"; exit 0
57 echo "${MACHINE}-whatever-unixware2"; exit 0
61 echo "whatever-whatever-unixware1"; exit 0
64 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then
65 echo "${MACHINE}-sco-unixware7"; exit 0
71 # Now we simply scan though... In most cases, the SYSTEM info is enough
73 case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
75 MACHINE=`echo "$MACHINE" | sed -e 's/-/_/g'`
76 echo "parisc-hp-MPE/iX"; exit 0
79 echo "m68k-apple-aux3"; exit 0
83 echo "${MACHINE}-ibm-aix"; exit 0
87 echo "${MACHINE}-dg-dgux"; exit 0
91 echo "${MACHINE}-hi-hiux"; exit 0
95 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
98 echo "${MACHINE}-hp-hpux11"; exit 0
101 echo "${MACHINE}-hp-hpux10"; exit 0
104 echo "${MACHINE}-hp-hpux"; exit 0
110 echo "mips2-sgi-irix"; exit 0
114 echo "mips3-sgi-irix"; exit 0
118 echo "mips4-sgi-irix64"; exit 0
122 echo "${MACHINE}-whatever-linux2"; exit 0
126 echo "${MACHINE}-whatever-linux1"; exit 0
130 echo "hurd-x86"; exit 0;
134 echo "${MACHINE}-lynx-lynxos"; exit 0
137 BSD/OS:4.*) # BSD/OS always says 386
138 echo "i486-whatever-bsdi4"; exit 0
141 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
142 case `/sbin/sysctl -n hw.model` in
144 echo "i586-whatever-bsdi"; exit 0
147 echo "i386-whatever-bsdi"; exit 0
153 echo "${MACHINE}-whatever-bsdi"; exit 0
157 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
158 MACH=`sysctl -n hw.model`
161 *386* ) MACH="i386" ;;
162 *486* ) MACH="i486" ;;
163 Pentium\ II*) MACH="i686" ;;
164 Pentium* ) MACH="i586" ;;
165 Alpha* ) MACH="alpha" ;;
166 * ) MACH="$MACHINE" ;;
169 i[0-9]86 ) ARCH="pc" ;;
171 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
175 echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
179 echo "${MACHINE}-whatever-netbsd"; exit 0
183 echo "${MACHINE}-whatever-openbsd"; exit 0
187 echo "${MACHINE}-dec-osf"; exit 0
193 echo "${MACHINE}-whatever-qnx4"
196 echo "${MACHINE}-whatever-qnx"
203 echo "i860-intel-osf1"; exit 0
207 echo "ppc-apple-rhapsody"; exit 0
211 echo "ppc-apple-darwin"; exit 0
215 echo "${MACHINE}-whatever-solaris2"; exit 0
219 echo "${MACHINE}-sun-sunos4"; exit 0
223 echo "${MACHINE}-whatever-sysv4"; exit 0
227 echo "${MACHINE}-whatever-sysv4"; exit 0
231 echo "${MACHINE}-whatever-sysv4"; exit 0
234 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
235 echo "i486-ncr-sysv4"; exit 0
239 echo "${MACHINE}-unknown-ultrix"; exit 0
243 echo "${MACHINE}-siemens-sysv4"; exit 0
247 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
251 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
255 echo "${MACHINE}-ncr-sysv4"; exit 0
259 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
263 echo "mips-sony-newsos4"; exit 0;
269 # Ugg. These are all we can determine by what we know about
270 # the output of uname. Be more creative:
273 # Do the Apollo stuff first. Here, we just simply assume
274 # that the existance of the /usr/apollo directory is proof
276 if [ -d /usr/apollo ]; then
277 echo "whatever-apollo-whatever"
282 ISNEXT=`hostinfo 2>/dev/null`
285 echo "whatever-next-nextstep3.3"; exit 0
288 echo "whatever-next-nextstep"; exit 0
292 # At this point we gone through all the one's
295 echo "${MACHINE}-whatever-${SYSTEM}"
299 # ---------------------------------------------------------------------------
300 # this is where the translation occurs into SSLeay terms
301 # ---------------------------------------------------------------------------
307 # pick up any command line args to config
311 -d*) PREFIX="debug-";;
313 -h*) TEST="true"; cat <<EOF
314 Usage: config [options]
315 -d Add a debug- prefix to machine choice.
316 -t Test mode, do not run the Configure perl script.
319 Any other text will be passed to the Configure perl script.
320 See INSTALL for instructions.
324 *) options=$options" $i" ;;
328 # figure out if gcc is available and if so we use it otherwise
329 # we fallback to whatever cc does on the system
330 GCCVER=`(gcc --version) 2>/dev/null`
331 if [ "$GCCVER" != "" ]; then
333 # then strip off whatever prefix Cygnus prepends the number with...
334 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
335 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
336 GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
341 if [ "$SYSTEM" = "SunOS" ]; then
342 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
343 CCVER=`(cc -V 2>&1) 2>/dev/null | \
344 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
345 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
347 if [ $CCVER -gt 40 ]; then
348 CC=cc # overrides gcc!!!
349 if [ $CCVER -eq 50 ]; then
350 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
351 echo " patch #107357-01 or later applied."
354 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
359 if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
360 # check for Compaq C, expected output is "blah-blah C Vx.x"
361 CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
362 egrep -e '.* C V[0-9]\.[0-9]' | \
363 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
365 if [ $CCCVER -gt 60 ]; then
366 CC=ccc # overrides gcc!!! well, ccc outperforms inoticeably
367 # only on hash routines and des, otherwise gcc (2.95)
368 # keeps along rather tight...
375 # read the output of the embedded GuessOS
378 echo Operating system: $GUESSOS
380 # now map the output into SSLeay terms ... really should hack into the
381 # script above so we end up with values in vars but that would take
382 # more time that I want to waste at the moment
385 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
387 if [ $CPU -ge 4000 ]; then
388 options="$options -mips2"
393 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
395 if [ $CPU -ge 5000 ]; then
396 options="$options -mips4"
398 options="$options -mips3"
403 echo "WARNING! If you wish to build 64-bit library, then you have to"
404 echo " invoke './Configure irix64-mips4-$CC' *manually*."
405 echo " Type return if you want to continue, Ctrl-C to abort."
406 read waste < /dev/tty
407 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
409 if [ $CPU -ge 5000 ]; then
410 options="$options -mips4"
412 options="$options -mips3"
417 ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
418 case ${ISA:-generic} in
419 *[67]) OUT="linux-alpha+bwx-$CC" ;;
420 *) OUT="linux-alpha-$CC" ;;
422 if [ "$CC" = "gcc" ]; then
423 case ${ISA:-generic} in
424 EV5|EV45) options="$options -mcpu=ev5";;
425 EV56|PCA56) options="$options -mcpu=ev56";;
426 EV6|EV67|PCA57) options="$options -mcpu=ev6";;
432 #include <stdio.h> /* for printf() prototype */
433 int main (argc, argv) int argc; char *argv[]; {
435 printf ("linux-%s\n", argv[1]);
438 printf ("linux-%sel\n", argv[1]);
443 ${CC} -o dummy dummy.c && OUT=`./dummy ${MACHINE}`
446 ppc-*-linux2) OUT="linux-ppc" ;;
447 m68k-*-linux*) OUT="linux-m68k" ;;
448 ia64-*-linux?) OUT="linux-ia64" ;;
449 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
450 ppc-apple-darwin) OUT="darwin-ppc-cc" ;;
452 #Before we can uncomment following lines we have to wait at least
453 #till 64-bit glibc for SPARC is operational:-(
454 #echo "WARNING! If you wish to build 64-bit library, then you have to"
455 #echo " invoke './Configure linux64-sparcv9' *manually*."
456 #echo " Type return if you want to continue, Ctrl-C to abort."
457 #read waste < /dev/tty
458 OUT="linux-sparcv9" ;;
460 KARCH=`awk '/^type/{print$3}' /proc/cpuinfo`
461 case ${KARCH:-sun4} in
462 sun4u*) OUT="linux-sparcv9" ;;
463 sun4m) OUT="linux-sparcv8" ;;
464 sun4d) OUT="linux-sparcv8" ;;
465 *) OUT="linux-sparcv7" ;;
467 arm*-*-linux2) OUT="linux-elf-arm" ;;
468 s390-*-linux2) OUT="linux-s390" ;;
469 *-*-linux2) OUT="linux-elf" ;;
470 *-*-linux1) OUT="linux-aout" ;;
472 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
473 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
474 echo "WARNING! If you wish to build 64-bit library, then you have to"
475 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
476 echo " Type return if you want to continue, Ctrl-C to abort."
477 read waste < /dev/tty
479 OUT="solaris-sparcv9-$CC" ;;
480 sun4m-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
481 sun4d-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
482 sun4*-*-solaris2) OUT="solaris-sparcv7-$CC" ;;
483 *86*-*-solaris2) OUT="solaris-x86-$CC" ;;
484 *-*-sunos4) OUT="sunos-$CC" ;;
485 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
486 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
487 *-freebsd[1-2]*) OUT="FreeBSD" ;;
488 *86*-*-netbsd) OUT="NetBSD-x86" ;;
489 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
490 *-*-netbsd) OUT="NetBSD-sparc" ;;
491 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
492 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
493 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
494 *-*-openbsd) OUT="OpenBSD" ;;
495 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
496 *-*-osf) OUT="alpha-cc" ;;
497 *-*-unixware7) OUT="unixware-7" ;;
498 *-*-UnixWare7) OUT="unixware-7" ;;
499 *-*-Unixware7) OUT="unixware-7" ;;
500 *-*-unixware[1-2]*) OUT="unixware-2.0" ;;
501 *-*-UnixWare[1-2]*) OUT="unixware-2.0" ;;
502 *-*-Unixware[1-2]*) OUT="unixware-2.0" ;;
503 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
504 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
505 *-siemens-sysv4) OUT="SINIX" ;;
506 *-hpux1*) OUT="hpux-parisc-$CC"
507 options="$options -D_REENTRANT" ;;
508 *-hpux) OUT="hpux-parisc-$CC" ;;
509 # these are all covered by the catchall below
510 # *-aix) OUT="aix-$CC" ;;
511 # *-dgux) OUT="dgux" ;;
512 mips-sony-newsos4) OUT="newsos4-gcc" ;;
513 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
516 # NB: This atalla support has been superceded by the ENGINE support
517 # That contains its own header and definitions anyway. Support can
518 # be enabled or disabled on any supported platform without external
519 # headers, eg. by adding the "hw-atalla" switch to ./config or
522 # See whether we can compile Atalla support
523 #if [ -f /usr/include/atasi.h ]
525 # options="$options -DATALLA"
528 # gcc < 2.8 does not support -mcpu=ultrasparc
529 if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
531 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
533 OUT=solaris-sparcv9-gcc27
535 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
537 echo "WARNING! Falling down to 'linux-sparcv8'."
538 echo " Upgrade to gcc-2.8 or later."
544 i386-*) options="$options 386" ;;
547 for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
549 if [ ! -d crypto/$i ]
551 options="$options no-$i"
555 # Discover Kerberos 5 (since it's still a prototype, we don't
556 # do any guesses yet, that's why this section is commented away.
557 #if [ -d /usr/kerberos ]; then
558 # krb5_dir=/usr/kerberos
559 # if [ \( -f $krb5_dir/lib/libgssapi_krb5.a -o -f $krb5_dir/lib/libgssapi_krb5.so* \)\
560 # -a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
561 # -a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
562 # -a \( -f $krb5_dir/lib/libk5crypto.a -o -f $krb5_dir/lib/libk5crypto.so* \)\
563 # -a \( -f $krb5_dir/include/krb5.h \) ]; then
564 # options="$options --with-krb5-flavor=MIT"
566 #elif [ -d /usr/heimdal ]; then
567 # krb5_dir=/usr/heimdal
568 # if [ \( -f $krb5_dir/lib/libgssapi.a -o -f $krb5_dir/lib/libgssapi.so* \)\
569 # -a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
570 # -a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
571 # -a \( -f $krb5_dir/include/krb5.h \) ]; then
572 # options="$options --with-krb5-flavor=Heimdal"
576 if [ -z "$OUT" ]; then
580 if [ ".$PERL" = . ] ; then
581 for i in . `echo $PATH | sed 's/:/ /g'`; do
582 if [ -f "$i/perl5" ] ; then
589 if [ ".$PERL" = . ] ; then
590 for i in . `echo $PATH | sed 's/:/ /g'`; do
591 if [ -f "$i/perl" ] ; then
592 if "$i/perl" -e 'exit($]<5.0)'; then
600 if [ ".$PERL" = . ] ; then
601 echo "You need Perl 5."
605 # run Configure to check to see if we need to specify the
606 # compiler for the platform ... in which case we add it on
607 # the end ... otherwise we leave it off
609 $PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
610 if [ $? = "0" ]; then
616 $PERL ./Configure LIST | grep "$OUT" > /dev/null
617 if [ $? = "0" ]; then
618 echo Configuring for $OUT
620 if [ "$TEST" = "true" ]; then
621 echo $PERL ./Configure $OUT $options
623 $PERL ./Configure $OUT $options
626 echo "This system ($OUT) is not supported. See file INSTALL for details."