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 echo "m68k-apple-aux3"; exit 0
79 echo "${MACHINE}-ibm-aix"; exit 0
83 echo "${MACHINE}-dg-dgux"; exit 0
87 echo "${MACHINE}-hi-hiux"; exit 0
91 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
94 echo "${MACHINE}-hp-hpux11"; exit 0
97 echo "${MACHINE}-hp-hpux10"; exit 0
100 echo "${MACHINE}-hp-hpux"; exit 0
106 echo "mips2-sgi-irix"; exit 0
110 echo "mips3-sgi-irix"; exit 0
114 echo "mips4-sgi-irix64"; exit 0
118 echo "${MACHINE}-whatever-linux2"; exit 0
122 echo "${MACHINE}-whatever-linux1"; exit 0
126 echo "${MACHINE}-lynx-lynxos"; exit 0
129 BSD/OS:4.*) # BSD/OS always says 386
130 echo "i486-whatever-bsdi4"; exit 0
133 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
134 case `/sbin/sysctl -n hw.model` in
136 echo "i586-whatever-bsdi"; exit 0
139 echo "i386-whatever-bsdi"; exit 0
145 echo "${MACHINE}-whatever-bsdi"; exit 0
149 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
150 MACH=`sysctl -n hw.model`
153 *386* ) MACH="i386" ;;
154 *486* ) MACH="i486" ;;
155 Pentium\ II*) MACH="i686" ;;
156 Pentium* ) MACH="i586" ;;
157 Alpha* ) MACH="alpha" ;;
158 * ) MACH="$MACHINE" ;;
161 i[0-9]86 ) ARCH="pc" ;;
163 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
167 echo "`/usr/sbin/sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
171 echo "${MACHINE}-whatever-netbsd"; exit 0
175 echo "${MACHINE}-whatever-openbsd"; exit 0
179 echo "${MACHINE}-dec-osf"; exit 0
185 echo "${MACHINE}-whatever-qnx4"
188 echo "${MACHINE}-whatever-qnx"
195 echo "i860-intel-osf1"; exit 0
199 echo "ppc-apple-rhapsody"; exit 0
203 echo "${MACHINE}-whatever-solaris2"; exit 0
207 echo "${MACHINE}-sun-sunos4"; exit 0
211 echo "${MACHINE}-whatever-sysv4"; exit 0
215 echo "${MACHINE}-whatever-sysv4"; exit 0
219 echo "${MACHINE}-whatever-sysv4"; exit 0
222 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
223 echo "i486-ncr-sysv4"; exit 0
227 echo "${MACHINE}-unknown-ultrix"; exit 0
231 echo "${MACHINE}-siemens-sysv4"; exit 0
235 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
239 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
243 echo "${MACHINE}-ncr-sysv4"; exit 0
247 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
251 echo "mips-sony-newsos4"; exit 0;
257 # Ugg. These are all we can determine by what we know about
258 # the output of uname. Be more creative:
261 # Do the Apollo stuff first. Here, we just simply assume
262 # that the existance of the /usr/apollo directory is proof
264 if [ -d /usr/apollo ]; then
265 echo "whatever-apollo-whatever"
270 ISNEXT=`hostinfo 2>/dev/null`
273 echo "whatever-next-nextstep3.3"; exit 0
276 echo "whatever-next-nextstep"; exit 0
280 # At this point we gone through all the one's
283 echo "${MACHINE}-whatever-${SYSTEM}"
287 # ---------------------------------------------------------------------------
288 # this is where the translation occurs into SSLeay terms
289 # ---------------------------------------------------------------------------
295 # pick up any command line args to config
299 -d*) PREFIX="debug-";;
301 -h*) TEST="true"; cat <<EOF
302 Usage: config [options]
303 -d Add a debug- prefix to machine choice.
304 -t Test mode, do not run the Configure perl script.
307 Any other text will be passed to the Configure perl script.
308 See INSTALL for instructions.
312 *) options=$options" $i" ;;
316 # figure out if gcc is available and if so we use it otherwise
317 # we fallback to whatever cc does on the system
318 GCCVER=`(gcc --version) 2>/dev/null`
319 if [ "$GCCVER" != "" ]; then
321 # then strip off whatever prefix Cygnus prepends the number with...
322 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
323 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
324 GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
329 if [ "$SYSTEM" = "SunOS" ]; then
330 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
331 CCVER=`(cc -V 2>&1) 2>/dev/null | \
332 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
333 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
335 if [ $CCVER -gt 40 ]; then
336 CC=cc # overrides gcc!!!
337 if [ $CCVER -eq 50 ]; then
338 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
339 echo " patch #107357-01 or later applied."
342 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
347 if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
348 # check for Compaq C, expected output is "blah-blah C Vx.x"
349 CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
350 egrep -e '.* C V[0-9]\.[0-9]' | \
351 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
353 if [ $CCCVER -gt 60 ]; then
354 CC=ccc # overrides gcc!!! well, ccc outperforms inoticeably
355 # only on hash routines and des, otherwise gcc (2.95)
356 # keeps along rather tight...
363 # read the output of the embedded GuessOS
366 echo Operating system: $GUESSOS
368 # now map the output into SSLeay terms ... really should hack into the
369 # script above so we end up with values in vars but that would take
370 # more time that I want to waste at the moment
373 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
375 if [ $CPU -ge 4000 ]; then
376 options="$options -mips2"
381 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
383 if [ $CPU -ge 5000 ]; then
384 options="$options -mips4"
386 options="$options -mips3"
391 echo "WARNING! If you wish to build 64-bit library, then you have to"
392 echo " invoke './Configre irix64-mips4-$CC' *manually*."
393 echo " Type Ctrl-C if you don't want to continue."
394 read waste < /dev/tty
395 options="$options -mips4"
399 ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
400 case ${ISA:-generic} in
401 *[67]) OUT="linux-alpha+bwx-$CC" ;;
402 *) OUT="linux-alpha-$CC" ;;
404 if [ "$CC" = "gcc" ]; then
405 case ${ISA:-generic} in
406 EV5|EV45) options="$options -mcpu=ev5";;
407 EV56|PCA56) options="$options -mcpu=ev56";;
408 EV6|EV67|PCA57) options="$options -mcpu=ev6";;
412 mips-*-linux?) OUT="linux-mips" ;;
413 ppc-*-linux2) OUT="linux-ppc" ;;
414 m68k-*-linux*) OUT="linux-m68k" ;;
415 ia64-*-linux?) OUT="linux-ia64" ;;
416 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
418 #Before we can uncomment following lines we have to wait at least
419 #till 64-bit glibc for SPARC is operational:-(
420 #echo "WARNING! If you wish to build 64-bit library, then you have to"
421 #echo " invoke './Configure linux64-sparcv9' *manually*."
422 #echo " Type Ctrl-C if you don't want to continue."
423 #read waste < /dev/tty
424 OUT="linux-sparcv9" ;;
426 KARCH=`awk '/type/{print$3}' /proc/cpuinfo`
427 case ${KARCH:-sun4} in
428 sun4u*) OUT="linux-sparcv9" ;;
429 sun4m) OUT="linux-sparcv8" ;;
430 sun4d) OUT="linux-sparcv8" ;;
431 *) OUT="linux-sparcv7" ;;
433 arm*-*-linux2) OUT="linux-elf-arm" ;;
434 *-*-linux2) OUT="linux-elf" ;;
435 *-*-linux1) OUT="linux-aout" ;;
437 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
438 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
439 echo "WARNING! If you wish to build 64-bit library, then you have to"
440 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
441 echo " Type Ctrl-C if you don't want to continue."
442 read waste < /dev/tty
444 OUT="solaris-sparcv9-$CC" ;;
445 sun4m-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
446 sun4d-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
447 sun4*-*-solaris2) OUT="solaris-sparcv7-$CC" ;;
448 *86*-*-solaris2) OUT="solaris-x86-$CC" ;;
449 *-*-sunos4) OUT="sunos-$CC" ;;
450 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
451 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
452 *-freebsd[1-2]*) OUT="FreeBSD" ;;
453 *86*-*-netbsd) OUT="NetBSD-x86" ;;
454 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
455 *-*-netbsd) OUT="NetBSD-sparc" ;;
456 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
457 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
458 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
459 *-*-openbsd) OUT="OpenBSD" ;;
460 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
461 *-*-osf) OUT="alpha-cc" ;;
462 *-*-unixware7) OUT="unixware-7" ;;
463 *-*-UnixWare7) OUT="unixware-7" ;;
464 *-*-Unixware7) OUT="unixware-7" ;;
465 *-*-unixware[1-2]*) OUT="unixware-2.0" ;;
466 *-*-UnixWare[1-2]*) OUT="unixware-2.0" ;;
467 *-*-Unixware[1-2]*) OUT="unixware-2.0" ;;
468 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
469 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
470 *-siemens-sysv4) OUT="SINIX" ;;
471 *-hpux1*) OUT="hpux-parisc-$CC"
472 options="$options -D_REENTRANT" ;;
473 *-hpux) OUT="hpux-parisc-$CC" ;;
474 # these are all covered by the catchall below
475 # *-aix) OUT="aix-$CC" ;;
476 # *-dgux) OUT="dgux" ;;
477 mips-sony-newsos4) OUT="newsos4-gcc" ;;
478 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
481 # See whether we can compile Atalla support
482 if [ -f /usr/include/atasi.h ]
484 options="$options -DATALLA"
487 # gcc < 2.8 does not support -mcpu=ultrasparc
488 if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
490 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
492 OUT=solaris-sparcv9-gcc27
494 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
496 echo "WARNING! Falling down to 'linux-sparcv8'."
497 echo " Upgrade to gcc-2.8 or later."
503 i386-*) options="$options 386" ;;
506 for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
508 if [ ! -d crypto/$i ]
510 options="$options no-$i"
514 if [ -z "$OUT" ]; then
518 if [ ".$PERL" = . ] ; then
519 for i in . `echo $PATH | sed 's/:/ /g'`; do
520 if [ -f "$i/perl5" ] ; then
527 if [ ".$PERL" = . ] ; then
528 for i in . `echo $PATH | sed 's/:/ /g'`; do
529 if [ -f "$i/perl" ] ; then
530 if "$i/perl" -e 'exit($]<5.0)'; then
538 if [ ".$PERL" = . ] ; then
539 echo "You need Perl 5."
543 # run Configure to check to see if we need to specify the
544 # compiler for the platform ... in which case we add it on
545 # the end ... otherwise we leave it off
547 $PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
548 if [ $? = "0" ]; then
554 $PERL ./Configure LIST | grep "$OUT" > /dev/null
555 if [ $? = "0" ]; then
556 #echo Configuring for $OUT
558 if [ "$TEST" = "true" ]; then
559 echo $PERL ./Configure $OUT $options
561 $PERL ./Configure $OUT $options
564 echo "This system ($OUT) is not supported. See file INSTALL for details."