config revision 109998
155714Skris#!/bin/sh
255714Skris#
355714Skris# OpenSSL config: determine the operating system and run ./Configure
455714Skris#
555714Skris# "config -h" for usage information.
655714Skris#
755714Skris#          this is a merge of minarch and GuessOS from the Apache Group.
855714Skris#          Originally written by Tim Hudson <tjh@cryptsoft.com>.
955714Skris
1055714Skris# Original Apache Group comments on GuessOS
1155714Skris
1255714Skris# Simple OS/Platform guesser. Similar to config.guess but
1355714Skris# much, much smaller. Since it was developed for use with
1455714Skris# Apache, it follows under Apache's regular licensing
1555714Skris# with one specific addition: Any changes or additions
1655714Skris# to this script should be Emailed to the Apache
1755714Skris# group (apache@apache.org) in general and to
1855714Skris# Jim Jagielski (jim@jaguNET.com) in specific.
1955714Skris#
2055714Skris# Be as similar to the output of config.guess/config.sub
2155714Skris# as possible.
2255714Skris
23109998SmarkmPREFIX=""
24109998SmarkmSUFFIX=""
25109998SmarkmTEST="false"
26109998Smarkm
27109998Smarkm# pick up any command line args to config
28109998Smarkmfor i
29109998Smarkmdo
30109998Smarkmcase "$i" in 
31109998Smarkm-d*) PREFIX="debug-";;
32109998Smarkm-t*) TEST="true";;
33109998Smarkm-h*) TEST="true"; cat <<EOF
34109998SmarkmUsage: config [options]
35109998Smarkm -d	Add a debug- prefix to machine choice.
36109998Smarkm -t	Test mode, do not run the Configure perl script.
37109998Smarkm -h	This help.
38109998Smarkm
39109998SmarkmAny other text will be passed to the Configure perl script.
40109998SmarkmSee INSTALL for instructions.
41109998Smarkm
42109998SmarkmEOF
43109998Smarkm;;
44109998Smarkm*) options=$options" $i" ;;
45109998Smarkmesac
46109998Smarkmdone
47109998Smarkm
4855714Skris# First get uname entries that we use below
4955714Skris
5055714SkrisMACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
5155714SkrisRELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
5255714SkrisSYSTEM=`(uname -s) 2>/dev/null`  || SYSTEM="unknown"
5355714SkrisVERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
5455714Skris
5559191Skris
5655714Skris# Now test for ISC and SCO, since it is has a braindamaged uname.
5755714Skris#
5855714Skris# We need to work around FreeBSD 1.1.5.1 
5955714Skris(
6055714SkrisXREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
6155714Skrisif [ "x$XREL" != "x" ]; then
6255714Skris    if [ -f /etc/kconfig ]; then
6355714Skris	case "$XREL" in
6455714Skris	    4.0|4.1)
6555714Skris		    echo "${MACHINE}-whatever-isc4"; exit 0
6655714Skris		;;
6755714Skris	esac
6855714Skris    else
6955714Skris	case "$XREL" in
7055714Skris	    3.2v4.2)
7155714Skris		echo "whatever-whatever-sco3"; exit 0
7255714Skris		;;
7355714Skris	    3.2v5.0*)
7455714Skris		echo "whatever-whatever-sco5"; exit 0
7555714Skris		;;
7655714Skris	    4.2MP)
7776866Skris		if [ "x$VERSION" = "x2.01" ]; then
7876866Skris		    echo "${MACHINE}-whatever-unixware201"; exit 0
7976866Skris		elif [ "x$VERSION" = "x2.02" ]; then
8076866Skris		    echo "${MACHINE}-whatever-unixware202"; exit 0
8176866Skris		elif [ "x$VERSION" = "x2.03" ]; then
8276866Skris		    echo "${MACHINE}-whatever-unixware203"; exit 0
8376866Skris		elif [ "x$VERSION" = "x2.1.1" ]; then
8455714Skris		    echo "${MACHINE}-whatever-unixware211"; exit 0
8559191Skris		elif [ "x$VERSION" = "x2.1.2" ]; then
8659191Skris		    echo "${MACHINE}-whatever-unixware212"; exit 0
8776866Skris		elif [ "x$VERSION" = "x2.1.3" ]; then
8876866Skris		    echo "${MACHINE}-whatever-unixware213"; exit 0
8955714Skris		else
9055714Skris		    echo "${MACHINE}-whatever-unixware2"; exit 0
9155714Skris		fi
9255714Skris		;;
9355714Skris	    4.2)
9455714Skris		echo "whatever-whatever-unixware1"; exit 0
9555714Skris		;;
96109998Smarkm	    OpenUNIX)
9789837Skris		if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x8" ]; then
9889837Skris		    echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
9989837Skris		fi
10089837Skris		;;
10159191Skris	    5)
10259191Skris		if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then
10359191Skris		    echo "${MACHINE}-sco-unixware7"; exit 0
10459191Skris		fi
10559191Skris		;;
10655714Skris	esac
10755714Skris    fi
10855714Skrisfi
10955714Skris# Now we simply scan though... In most cases, the SYSTEM info is enough
11055714Skris#
11155714Skriscase "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
11268651Skris    MPE/iX:*)
11368651Skris	MACHINE=`echo "$MACHINE" | sed -e 's/-/_/g'`
11468651Skris	echo "parisc-hp-MPE/iX"; exit 0
11568651Skris	;;
11655714Skris    A/UX:*)
11755714Skris	echo "m68k-apple-aux3"; exit 0
11855714Skris	;;
11955714Skris
12076866Skris    AIX:[3456789]:4:*)
12176866Skris	echo "${MACHINE}-ibm-aix43"; exit 0
12276866Skris	;;
12376866Skris
12476866Skris    AIX:*:[56789]:*)
12576866Skris	echo "${MACHINE}-ibm-aix43"; exit 0
12676866Skris	;;
12776866Skris
12855714Skris    AIX:*)
12955714Skris	echo "${MACHINE}-ibm-aix"; exit 0
13055714Skris	;;
13155714Skris
13255714Skris    dgux:*)
13355714Skris	echo "${MACHINE}-dg-dgux"; exit 0
13455714Skris	;;
13555714Skris
13655714Skris    HI-UX:*)
13755714Skris	echo "${MACHINE}-hi-hiux"; exit 0
13855714Skris	;;
13955714Skris
14055714Skris    HP-UX:*)
14155714Skris	HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
14255714Skris	case "$HPUXVER" in
143109998Smarkm	    1[0-9].*)	# HPUX 10 and 11 targets are unified
14455714Skris		echo "${MACHINE}-hp-hpux10"; exit 0
14555714Skris		;;
14655714Skris	    *)
14755714Skris		echo "${MACHINE}-hp-hpux"; exit 0
14855714Skris		;;
14955714Skris	esac
15055714Skris	;;
15155714Skris
15255714Skris    IRIX:5.*)
15355714Skris	echo "mips2-sgi-irix"; exit 0
15455714Skris	;;
15555714Skris
15655714Skris    IRIX:6.*)
15755714Skris	echo "mips3-sgi-irix"; exit 0
15855714Skris	;;
15955714Skris
16055714Skris    IRIX64:*)
16155714Skris	echo "mips4-sgi-irix64"; exit 0
16255714Skris	;;
16355714Skris
16455714Skris    Linux:[2-9].*)
16555714Skris	echo "${MACHINE}-whatever-linux2"; exit 0
16655714Skris	;;
16755714Skris
16855714Skris    Linux:1.*)
16955714Skris	echo "${MACHINE}-whatever-linux1"; exit 0
17055714Skris	;;
17155714Skris
172109998Smarkm    GNU*)
173109998Smarkm	echo "hurd-x86"; exit 0;
174109998Smarkm	;;
175109998Smarkm
17655714Skris    LynxOS:*)
17755714Skris	echo "${MACHINE}-lynx-lynxos"; exit 0
17855714Skris	;;
17955714Skris
18055714Skris    BSD/OS:4.*)  # BSD/OS always says 386
18155714Skris	echo "i486-whatever-bsdi4"; exit 0
18255714Skris	;;
18355714Skris
18455714Skris    BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
18555714Skris        case `/sbin/sysctl -n hw.model` in
18655714Skris	    Pentium*)
18755714Skris                echo "i586-whatever-bsdi"; exit 0
18855714Skris                ;;
18955714Skris            *)
19055714Skris                echo "i386-whatever-bsdi"; exit 0
19155714Skris                ;;
19255714Skris            esac;
19355714Skris	;;
19455714Skris
19555714Skris    BSD/386:*|BSD/OS:*)
19655714Skris	echo "${MACHINE}-whatever-bsdi"; exit 0
19755714Skris	;;
19855714Skris
19955714Skris    FreeBSD:*)
20055714Skris        VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
20155714Skris        MACH=`sysctl -n hw.model`
20255714Skris        ARCH='whatever'
20355714Skris        case ${MACH} in
20455714Skris           *386*       ) MACH="i386"     ;;
20555714Skris           *486*       ) MACH="i486"     ;;
20655714Skris           Pentium\ II*) MACH="i686"     ;;
20755714Skris           Pentium*    ) MACH="i586"     ;;
20855714Skris           Alpha*      ) MACH="alpha"    ;;
20955714Skris           *           ) MACH="$MACHINE" ;;
21055714Skris        esac
21155714Skris        case ${MACH} in
21255714Skris           i[0-9]86 ) ARCH="pc" ;;
21355714Skris        esac
21455714Skris        echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
21555714Skris        ;;
21655714Skris
21755714Skris    NetBSD:*:*:*386*)
21872613Skris        echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
21955714Skris	;;
22055714Skris
22155714Skris    NetBSD:*)
22255714Skris	echo "${MACHINE}-whatever-netbsd"; exit 0
22355714Skris	;;
22455714Skris
22555714Skris    OpenBSD:*)
22655714Skris	echo "${MACHINE}-whatever-openbsd"; exit 0
22755714Skris	;;
22855714Skris
22989837Skris    OpenUNIX:*)
23089837Skris	echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
23189837Skris	;;
23289837Skris
23355714Skris    OSF1:*:*:*alpha*)
23489837Skris	OSFMAJOR=`echo ${RELEASE}| sed -e 's/^V\([0-9]*\)\..*$/\1/'`
23589837Skris	case "$OSFMAJOR" in
23689837Skris	    4|5)
23789837Skris		echo "${MACHINE}-dec-tru64"; exit 0
23889837Skris		;;
23989837Skris	    1|2|3)
24089837Skris		echo "${MACHINE}-dec-osf"; exit 0
24189837Skris		;;
24289837Skris	    *)
24389837Skris		echo "${MACHINE}-dec-osf"; exit 0
24489837Skris		;;
24589837Skris	esac
24655714Skris	;;
24755714Skris
24855714Skris    QNX:*)
24989837Skris	case "$RELEASE" in
25068651Skris	    4*)
25168651Skris		echo "${MACHINE}-whatever-qnx4"
25255714Skris		;;
25389837Skris	    6*)
25489837Skris		echo "${MACHINE}-whatever-qnx6"
25589837Skris		;;
25655714Skris	    *)
25768651Skris		echo "${MACHINE}-whatever-qnx"
25855714Skris		;;
25955714Skris	esac
26055714Skris	exit 0
26155714Skris	;;
26255714Skris
26355714Skris    Paragon*:*:*:*)
26455714Skris	echo "i860-intel-osf1"; exit 0
26555714Skris	;;
26655714Skris
26759191Skris    Rhapsody:*)
26859191Skris	echo "ppc-apple-rhapsody"; exit 0
26959191Skris	;;
27059191Skris
27189837Skris    Darwin:*)
272109998Smarkm	case "$MACHINE" in
273109998Smarkm	    Power*)
274109998Smarkm		echo "ppc-apple-darwin${VERSION}"
275109998Smarkm		;;
276109998Smarkm	    *)
277109998Smarkm		echo "i386-apple-darwin${VERSION}"
278109998Smarkm		;;
279109998Smarkm	esac
280109998Smarkm	exit 0
28189837Skris	;;
28289837Skris
28355714Skris    SunOS:5.*)
28468651Skris	echo "${MACHINE}-whatever-solaris2"; exit 0
28555714Skris	;;
28655714Skris
28755714Skris    SunOS:*)
28855714Skris	echo "${MACHINE}-sun-sunos4"; exit 0
28955714Skris	;;
29055714Skris
29155714Skris    UNIX_System_V:4.*:*)
29255714Skris	echo "${MACHINE}-whatever-sysv4"; exit 0
29355714Skris	;;
29455714Skris
29555714Skris    *:4*:R4*:m88k)
29655714Skris	echo "${MACHINE}-whatever-sysv4"; exit 0
29755714Skris	;;
29855714Skris
29955714Skris    DYNIX/ptx:4*:*)
30055714Skris	echo "${MACHINE}-whatever-sysv4"; exit 0
30155714Skris	;;
30255714Skris
30355714Skris    *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
30455714Skris	echo "i486-ncr-sysv4"; exit 0
30555714Skris	;;
30655714Skris
30755714Skris    ULTRIX:*)
30855714Skris	echo "${MACHINE}-unknown-ultrix"; exit 0
30955714Skris	;;
31055714Skris
31155714Skris    SINIX*|ReliantUNIX*)
31255714Skris	echo "${MACHINE}-siemens-sysv4"; exit 0
31355714Skris	;;
31455714Skris
31555714Skris    POSIX-BC*)
31655714Skris	echo "${MACHINE}-siemens-sysv4"; exit 0   # Here, $MACHINE == "BS2000"
31755714Skris	;;
31855714Skris
31955714Skris    machten:*)
32055714Skris       echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
32155714Skris       ;;
32255714Skris
32355714Skris    library:*)
32455714Skris	echo "${MACHINE}-ncr-sysv4"; exit 0
32555714Skris	;;
32655714Skris
32755714Skris    ConvexOS:*:11.0:*)
32855714Skris	echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
32955714Skris	;;
33055714Skris
33168651Skris    NEWS-OS:4.*)
33268651Skris	echo "mips-sony-newsos4"; exit 0;
33368651Skris	;;
33468651Skris
33589837Skris    CYGWIN*)
336100928Snectar	case "$RELEASE" in
337100928Snectar	    [bB]*|1.0|1.[12].*)
338100928Snectar		echo "${MACHINE}-whatever-cygwin_pre1.3"
339100928Snectar		;;
340100928Snectar	    *)
341100928Snectar		echo "${MACHINE}-whatever-cygwin"
342100928Snectar		;;
343100928Snectar	esac
344100928Snectar	exit 0
34589837Skris	;;
34689837Skris
347100928Snectar    *"CRAY T3E")
348100928Snectar       echo "t3e-cray-unicosmk"; exit 0;
349100928Snectar       ;;
350100928Snectar
351100928Snectar    *CRAY*)
352100928Snectar       echo "j90-cray-unicos"; exit 0;
353100928Snectar       ;;
354109998Smarkm
355109998Smarkm    NONSTOP_KERNEL*)
356109998Smarkm       echo "nsr-tandem-nsk"; exit 0;
357109998Smarkm       ;;
35855714Skrisesac
35955714Skris
36055714Skris#
36155714Skris# Ugg. These are all we can determine by what we know about
36255714Skris# the output of uname. Be more creative:
36355714Skris#
36455714Skris
36555714Skris# Do the Apollo stuff first. Here, we just simply assume
36655714Skris# that the existance of the /usr/apollo directory is proof
36755714Skris# enough
36855714Skrisif [ -d /usr/apollo ]; then
36955714Skris    echo "whatever-apollo-whatever"
37055714Skris    exit 0
37155714Skrisfi
37255714Skris
37355714Skris# Now NeXT
37455714SkrisISNEXT=`hostinfo 2>/dev/null`
37555714Skriscase "$ISNEXT" in
37655714Skris    *'NeXT Mach 3.3'*)
37755714Skris	echo "whatever-next-nextstep3.3"; exit 0
37855714Skris	;;
37955714Skris    *NeXT*)
38055714Skris	echo "whatever-next-nextstep"; exit 0
38155714Skris	;;
38255714Skrisesac
38355714Skris
38455714Skris# At this point we gone through all the one's
38555714Skris# we know of: Punt
38655714Skris
38755714Skrisecho "${MACHINE}-whatever-${SYSTEM}" 
38855714Skrisexit 0
38955714Skris) 2>/dev/null | (
39055714Skris
39155714Skris# ---------------------------------------------------------------------------
39255714Skris# this is where the translation occurs into SSLeay terms
39355714Skris# ---------------------------------------------------------------------------
39455714Skris
39555714Skris# figure out if gcc is available and if so we use it otherwise
39655714Skris# we fallback to whatever cc does on the system
397100936SnectarGCCVER=`(gcc -dumpversion) 2>/dev/null`
39855714Skrisif [ "$GCCVER" != "" ]; then
39955714Skris  CC=gcc
400101618Snectar  # then strip off whatever prefix egcs prepends the number with...
401101618Snectar  # Hopefully, this will work for any future prefixes as well.
402101618Snectar  GCCVER=`echo $GCCVER | sed 's/^[a-zA-Z]*\-//'`
403100936Snectar  # Since gcc 3.1 gcc --version behaviour has changed.  gcc -dumpversion
404100936Snectar  # does give us what we want though, so we use that.  We just just the
405100936Snectar  # major and minor version numbers.
40655714Skris  # peak single digit before and after first dot, e.g. 2.95.1 gives 29
40755714Skris  GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
40855714Skriselse
40955714Skris  CC=cc
41055714Skrisfi
411101613SnectarGCCVER=${GCCVER:-0}
412100936Snectarif [ "$SYSTEM" = "HP-UX" ];then
413100936Snectar  # By default gcc is a ILP32 compiler (with long long == 64).
414100936Snectar  GCC_BITS="32"
415100936Snectar  if [ $GCCVER -ge 30 ]; then
416100936Snectar    # PA64 support only came in with gcc 3.0.x.
417100936Snectar    # We look for the preprocessor symbol __LP64__ indicating
418100936Snectar    # 64bit bit long and pointer.  sizeof(int) == 32 on HPUX64.
419100936Snectar    if gcc -v -E -x c /dev/null 2>&1 | grep __LP64__ > /dev/null; then
420100936Snectar      GCC_BITS="64"
421100936Snectar    fi
422100936Snectar  fi
423100936Snectarfi
42455714Skrisif [ "$SYSTEM" = "SunOS" ]; then
425109998Smarkm  if [ $GCCVER -ge 30 ]; then
426109998Smarkm    # 64-bit ABI isn't officially supported in gcc 3.0, but it appears
427109998Smarkm    # to be working, at the very least 'make test' passes...
428109998Smarkm    if gcc -v -E -x c /dev/null 2>&1 | grep __arch64__ > /dev/null; then
429109998Smarkm      GCC_ARCH="-m64"
430109998Smarkm    else
431109998Smarkm      GCC_ARCH="-m32"
432109998Smarkm    fi
433109998Smarkm  fi
43459191Skris  # check for WorkShop C, expected output is "cc: blah-blah C x.x"
43555714Skris  CCVER=`(cc -V 2>&1) 2>/dev/null | \
43655714Skris  	egrep -e '^cc: .* C [0-9]\.[0-9]' | \
43755714Skris	sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
43855714Skris  CCVER=${CCVER:-0}
43955714Skris  if [ $CCVER -gt 40 ]; then
44055714Skris    CC=cc	# overrides gcc!!!
44155714Skris    if [ $CCVER -eq 50 ]; then
44255714Skris      echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
44355714Skris      echo "         patch #107357-01 or later applied."
44455714Skris      sleep 5
44555714Skris    fi
44655714Skris  elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
44755714Skris    CC=sc3
44855714Skris  fi
44955714Skrisfi
45055714Skris
45159191Skrisif [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
45259191Skris  # check for Compaq C, expected output is "blah-blah C Vx.x"
45359191Skris  CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
45459191Skris	egrep -e '.* C V[0-9]\.[0-9]' | \
45559191Skris	sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
45659191Skris  CCCVER=${CCCVER:-0}
45759191Skris  if [ $CCCVER -gt 60 ]; then
45859191Skris    CC=ccc	# overrides gcc!!! well, ccc outperforms inoticeably
45959191Skris		# only on hash routines and des, otherwise gcc (2.95)
46059191Skris		# keeps along rather tight...
46159191Skris  fi
46259191Skrisfi
46359191Skris
46455714SkrisCCVER=${CCVER:-0}
46555714Skris
46655714Skris# read the output of the embedded GuessOS 
46755714Skrisread GUESSOS
46855714Skris
46955714Skrisecho Operating system: $GUESSOS
47055714Skris
47155714Skris# now map the output into SSLeay terms ... really should hack into the
47255714Skris# script above so we end up with values in vars but that would take
47355714Skris# more time that I want to waste at the moment
47455714Skriscase "$GUESSOS" in
47555714Skris  mips2-sgi-irix)
47655714Skris	CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
47755714Skris	CPU=${CPU:-0}
47855714Skris	if [ $CPU -ge 4000 ]; then
47955714Skris		options="$options -mips2"
48055714Skris	fi
48155714Skris	OUT="irix-$CC"
48255714Skris	;;
48355714Skris  mips3-sgi-irix)
48455714Skris	CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
48555714Skris	CPU=${CPU:-0}
48655714Skris	if [ $CPU -ge 5000 ]; then
48755714Skris		options="$options -mips4"
48855714Skris	else
48955714Skris		options="$options -mips3"
49055714Skris	fi
49155714Skris	OUT="irix-mips3-$CC"
49255714Skris	;;
49355714Skris  mips4-sgi-irix64)
49455714Skris	echo "WARNING! If you wish to build 64-bit library, then you have to"
49576866Skris	echo "         invoke './Configure irix64-mips4-$CC' *manually*."
496109998Smarkm	if [ "$TEST" = "false" ]; then
497109998Smarkm	  echo "         You have about 5 seconds to press Ctrl-C to abort."
498109998Smarkm	  (stty -icanon min 0 time 50; read waste) < /dev/tty
499109998Smarkm	fi
50076866Skris        CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
50176866Skris        CPU=${CPU:-0}
50276866Skris        if [ $CPU -ge 5000 ]; then
50376866Skris                options="$options -mips4"
50476866Skris        else
50576866Skris                options="$options -mips3"
50676866Skris        fi
50755714Skris	OUT="irix-mips3-$CC"
50855714Skris	;;
50959191Skris  alpha-*-linux2)
51059191Skris        ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
51159191Skris	case ${ISA:-generic} in
51259191Skris	*[67])	OUT="linux-alpha+bwx-$CC" ;;
51359191Skris	*)	OUT="linux-alpha-$CC" ;;
51459191Skris	esac
51559191Skris	if [ "$CC" = "gcc" ]; then
51659191Skris	    case ${ISA:-generic} in
51759191Skris	    EV5|EV45)		options="$options -mcpu=ev5";;
51859191Skris	    EV56|PCA56)		options="$options -mcpu=ev56";;
51959191Skris	    EV6|EV67|PCA57)	options="$options -mcpu=ev6";;
52059191Skris	    esac
52159191Skris	fi
52259191Skris	;;
52389837Skris  mips-*-linux?)
52489837Skris          cat >dummy.c <<EOF
52589837Skris#include <stdio.h>  /* for printf() prototype */
52689837Skris        int main (argc, argv) int argc; char *argv[]; {
52789837Skris#ifdef __MIPSEB__
52889837Skris  printf ("linux-%s\n", argv[1]);
52989837Skris#endif
53089837Skris#ifdef __MIPSEL__
53189837Skris  printf ("linux-%sel\n", argv[1]);
53289837Skris#endif
53389837Skris  return 0;
53489837Skris}
53589837SkrisEOF
53689837Skris	${CC} -o dummy dummy.c && OUT=`./dummy ${MACHINE}`
53789837Skris	rm dummy dummy.c
53889837Skris	;;
539100936Snectar  ppc64-*-linux2)
540100936Snectar	#Use the standard target for PPC architecture until we create a
541100936Snectar	#special one for the 64bit architecture.
542100936Snectar	OUT="linux-ppc" ;;
54359191Skris  ppc-*-linux2) OUT="linux-ppc" ;;
54468651Skris  m68k-*-linux*) OUT="linux-m68k" ;;
54559191Skris  ia64-*-linux?) OUT="linux-ia64" ;;
54659191Skris  ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
547109998Smarkm  ppc-apple-darwin*) OUT="darwin-ppc-cc" ;;
548109998Smarkm  i386-apple-darwin*) OUT="darwin-i386-cc" ;;
54955714Skris  sparc64-*-linux2)
550109998Smarkm	echo "WARNING! If *know* that your GNU C supports 64-bit/V9 ABI"
551109998Smarkm	echo "         and wish to build 64-bit library, then you have to"
552109998Smarkm	echo "         invoke './Configure linux64-sparcv9' *manually*."
553109998Smarkm	if [ "$TEST" = "false" ]; then
554109998Smarkm	  echo "          You have about 5 seconds to press Ctrl-C to abort."
555109998Smarkm	  (stty -icanon min 0 time 50; read waste) < /dev/tty
556109998Smarkm	fi
55755714Skris	OUT="linux-sparcv9" ;;
55855714Skris  sparc-*-linux2)
55972613Skris	KARCH=`awk '/^type/{print$3}' /proc/cpuinfo`
56055714Skris	case ${KARCH:-sun4} in
56155714Skris	sun4u*)	OUT="linux-sparcv9" ;;
56255714Skris	sun4m)	OUT="linux-sparcv8" ;;
56355714Skris	sun4d)	OUT="linux-sparcv8" ;;
56455714Skris	*)	OUT="linux-sparcv7" ;;
56555714Skris	esac ;;
566100928Snectar  parisc-*-linux2)
567100928Snectar        CPUARCH=`awk '/cpu family/{print substr($5,1,3)}' /proc/cpuinfo`
568100928Snectar	CPUSCHEDULE=`awk '/^cpu.[ 	]: PA/{print substr($3,3)}' /proc/cpuinfo`
569100928Snectar
570100928Snectar	# ??TODO ??  Model transformations
571100928Snectar	# 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
572100928Snectar	#    assuming no further arch. identification will ever be used by GCC.
573100928Snectar	# 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
574100928Snectar	# 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
575100928Snectar	#    for these chips in the future.
576100928Snectar	#         PA7300LC -> 7100LC (1.1)
577100928Snectar	#         PA8200   -> 8000   (2.0)
578100928Snectar	#         PA8500   -> 8000   (2.0)
579100928Snectar	#         PA8600   -> 8000   (2.0)
580100928Snectar
581100928Snectar	CPUSCHEDULE=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8?00/8000/'`
582100928Snectar	# Finish Model transformations
583100928Snectar
584100928Snectar	options="$options -mschedule=$CPUSCHEDULE -march=$CPUARCH"
585100928Snectar	OUT="linux-parisc" ;;
58668651Skris  arm*-*-linux2) OUT="linux-elf-arm" ;;
58772613Skris  s390-*-linux2) OUT="linux-s390" ;;
588100928Snectar  s390x-*-linux?) OUT="linux-s390x" ;;
589109998Smarkm  x86_64-*-linux?) OUT="linux-x86_64" ;;
590109998Smarkm  *-*-linux2) OUT="linux-elf"
591109998Smarkm	if [ "$GCCVER" -gt 28 ]; then
592109998Smarkm          if grep '^model.*Pentium' /proc/cpuinfo >/dev/null ; then
593109998Smarkm            OUT="linux-pentium"
594109998Smarkm          fi
595109998Smarkm          if grep '^model.*Pentium Pro' /proc/cpuinfo >/dev/null ; then
596109998Smarkm            OUT="linux-ppro"
597109998Smarkm          fi
598109998Smarkm          if grep '^model.*K6' /proc/cpuinfo >/dev/null ; then
599109998Smarkm            OUT="linux-k6"
600109998Smarkm          fi
601109998Smarkm        fi ;;
60255714Skris  *-*-linux1) OUT="linux-aout" ;;
60368651Skris  sun4u*-*-solaris2)
604109998Smarkm	OUT="solaris-sparcv9-$CC"
60555714Skris	ISA64=`(isalist) 2>/dev/null | grep sparcv9`
606109998Smarkm	if [ "$ISA64" != "" ]; then
607109998Smarkm	    if [ "$CC" = "cc" -a $CCVER -ge 50 ]; then
60855714Skris		echo "WARNING! If you wish to build 64-bit library, then you have to"
60955714Skris		echo "         invoke './Configure solaris64-sparcv9-cc' *manually*."
610109998Smarkm		if [ "$TEST" = "false" ]; then
611109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
612109998Smarkm		  (stty -icanon min 0 time 50; read waste) < /dev/tty
613109998Smarkm		fi
614109998Smarkm	    elif [ "$CC" = "gcc" -a "$GCC_ARCH" = "-m64" ]; then
615109998Smarkm		# $GCC_ARCH denotes default ABI chosen by compiler driver
616109998Smarkm		# (first one found on the $PATH). I assume that user
617109998Smarkm		# expects certain consistency with the rest of his builds
618109998Smarkm		# and therefore switch over to 64-bit. <appro>
619109998Smarkm		OUT="solaris64-sparcv9-gcc"
620109998Smarkm		echo "WARNING! If you wish to build 32-bit library, then you have to"
621109998Smarkm		echo "         invoke './Configure solaris-sparcv9-gcc' *manually*."
622109998Smarkm		if [ "$TEST" = "false" ]; then
623109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
624109998Smarkm		  (stty -icanon min 0 time 50; read waste) < /dev/tty
625109998Smarkm		fi
626109998Smarkm	    elif [ "$GCC_ARCH" = "-m32" ]; then
627109998Smarkm		echo "NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI"
628109998Smarkm		echo "        and wish to build 64-bit library, then you have to"
629109998Smarkm		echo "        invoke './Configure solaris64-sparcv9-gcc' *manually*."
630109998Smarkm		if [ "$TEST" = "false" ]; then
631109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
632109998Smarkm		  (stty -icanon min 0 time 50; read waste) < /dev/tty
633109998Smarkm		fi
634109998Smarkm	    fi
63555714Skris	fi
636109998Smarkm	;;
63768651Skris  sun4m-*-solaris2)	OUT="solaris-sparcv8-$CC" ;;
63868651Skris  sun4d-*-solaris2)	OUT="solaris-sparcv8-$CC" ;;
63968651Skris  sun4*-*-solaris2)	OUT="solaris-sparcv7-$CC" ;;
64068651Skris  *86*-*-solaris2) OUT="solaris-x86-$CC" ;;
64155714Skris  *-*-sunos4) OUT="sunos-$CC" ;;
64255714Skris  alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
64355714Skris  *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
64455714Skris  *-freebsd[1-2]*) OUT="FreeBSD" ;;
64555714Skris  *86*-*-netbsd) OUT="NetBSD-x86" ;;
64655714Skris  sun3*-*-netbsd) OUT="NetBSD-m68" ;;
64755714Skris  *-*-netbsd) OUT="NetBSD-sparc" ;;
64855714Skris  alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
649109998Smarkm  *86*-*-openbsd) OUT="OpenBSD-i386" ;;
650109998Smarkm  m68k*-*-openbsd) OUT="OpenBSD-m68k" ;;
651109998Smarkm  m88k*-*-openbsd) OUT="OpenBSD-m88k" ;;
652109998Smarkm  mips*-*-openbsd) OUT="OpenBSD-mips" ;;
65355714Skris  pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
654109998Smarkm  powerpc*-*-openbsd) OUT="OpenBSD-powerpc" ;;
655109998Smarkm  sparc64*-*-openbsd) OUT="OpenBSD-sparc64" ;;
656109998Smarkm  sparc*-*-openbsd) OUT="OpenBSD-sparc" ;;
657109998Smarkm  vax*-*-openbsd) OUT="OpenBSD-vax" ;;
658109998Smarkm  hppa*-*-openbsd) OUT="OpenBSD-hppa" ;;
65955714Skris  *-*-openbsd) OUT="OpenBSD" ;;
66055714Skris  *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
66189837Skris  *-*-osf) OUT="alphaold-cc" ;;
66289837Skris  *-*-tru64) OUT="alpha-cc" ;;
66389837Skris  *-*-OpenUNIX*)
66489837Skris	if [ "$CC" = "gcc" ]; then
66589837Skris	  OUT="OpenUNIX-8-gcc" 
66689837Skris	else    
66789837Skris	  OUT="OpenUNIX-8" 
66889837Skris	fi
66989837Skris	;;
67059191Skris  *-*-unixware7) OUT="unixware-7" ;;
67159191Skris  *-*-UnixWare7) OUT="unixware-7" ;;
67259191Skris  *-*-Unixware7) OUT="unixware-7" ;;
67376866Skris  *-*-unixware20*) OUT="unixware-2.0" ;;
67476866Skris  *-*-unixware21*) OUT="unixware-2.1" ;;
67576866Skris  *-*-UnixWare20*) OUT="unixware-2.0" ;;
67676866Skris  *-*-UnixWare21*) OUT="unixware-2.1" ;;
67776866Skris  *-*-Unixware20*) OUT="unixware-2.0" ;;
67876866Skris  *-*-Unixware21*) OUT="unixware-2.1" ;;
67955714Skris  BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
68055714Skris  RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
68155714Skris  *-siemens-sysv4) OUT="SINIX" ;;
682100936Snectar  *-hpux1*)
683100936Snectar	if [ $CC = "gcc" ];
684100936Snectar	then
685100936Snectar	  if [ $GCC_BITS = "64" ]; then
686100936Snectar	    OUT="hpux64-parisc-gcc"
687100936Snectar	  else
688100936Snectar	    OUT="hpux-parisc-gcc"
689100936Snectar	  fi
690100936Snectar	else
691100936Snectar	  OUT="hpux-parisc-$CC"
692100936Snectar	fi
693109998Smarkm	KERNEL_BITS=`(getconf KERNEL_BITS) 2>/dev/null`
694109998Smarkm	KERNEL_BITS=${KERNEL_BITS:-32}
695109998Smarkm	CPU_VERSION=`(getconf CPU_VERSION) 2>/dev/null`
696109998Smarkm	CPU_VERSION=${CPU_VERSION:-0}
697109998Smarkm	# See <sys/unistd.h> for further info on CPU_VERSION.
698109998Smarkm	if   [ $CPU_VERSION -ge 768 ]; then	# IA-64 CPU
699109998Smarkm	     echo "NOTICE! 64-bit is the only ABI currently operational on HP-UXi."
700109998Smarkm	     echo "        Post request to openssl-dev@openssl.org for 32-bit support."
701109998Smarkm	     if [ "$TEST" = "false" ]; then
702109998Smarkm		(stty -icanon min 0 time 50; read waste) < /dev/tty
703109998Smarkm	     fi
704109998Smarkm	     OUT="hpux64-ia64-cc"
705109998Smarkm	elif [ $CPU_VERSION -ge 532 ]; then	# PA-RISC 2.x CPU
706109998Smarkm	     if [ "$CC" = "cc" ]; then
707109998Smarkm		OUT="hpux-parisc2-cc" # can't we have hpux-parisc2-gcc?
708109998Smarkm	     fi
709109998Smarkm	     if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
710109998Smarkm		echo "WARNING! If you wish to build 64-bit library then you have to"
711109998Smarkm		echo "         invoke './Configure hpux64-parisc2-cc' *manually*."
712109998Smarkm		if [ "$TEST" = "false" ]; then
713109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
714109998Smarkm		  (stty -icanon min 0 time 50; read waste) < /dev/tty
715109998Smarkm		fi
716109998Smarkm	     fi
717109998Smarkm	elif [ $CPU_VERSION -ge 528 ]; then	# PA-RISC 1.1+ CPU
718109998Smarkm	     :
719109998Smarkm	elif [ $CPU_VERSION -ge 523 ]; then	# PA-RISC 1.0 CPU
720109998Smarkm	     :
721109998Smarkm	else					# Motorola(?) CPU
722109998Smarkm	     OUT="hpux-$CC"
723109998Smarkm	fi
724100936Snectar	options="$options -D_REENTRANT" ;;
72559191Skris  *-hpux)	OUT="hpux-parisc-$CC" ;;
72655714Skris  # these are all covered by the catchall below
72755714Skris  # *-aix) OUT="aix-$CC" ;;
72855714Skris  # *-dgux) OUT="dgux" ;;
72968651Skris  mips-sony-newsos4) OUT="newsos4-gcc" ;;
730100928Snectar  *-*-cygwin_pre1.3) OUT="Cygwin-pre1.3" ;;
731100928Snectar  *-*-cygwin) OUT="Cygwin" ;;
732100928Snectar  t3e-cray-unicosmk) OUT="cray-t3e" ;;
733100928Snectar  j90-cray-unicos) OUT="cray-j90" ;;
734109998Smarkm  nsr-tandem-nsk) OUT="tandem-c89" ;;
73555714Skris  *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
73655714Skrisesac
73755714Skris
738109998Smarkm# NB: This atalla support has been superceded by the ENGINE support
739109998Smarkm# That contains its own header and definitions anyway. Support can
740109998Smarkm# be enabled or disabled on any supported platform without external
741109998Smarkm# headers, eg. by adding the "hw-atalla" switch to ./config or
742109998Smarkm# perl Configure
743109998Smarkm#
74459191Skris# See whether we can compile Atalla support
745109998Smarkm#if [ -f /usr/include/atasi.h ]
746109998Smarkm#then
747109998Smarkm#  options="$options -DATALLA"
748109998Smarkm#fi
74959191Skris
75055714Skris# gcc < 2.8 does not support -mcpu=ultrasparc
75155714Skrisif [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
75255714Skristhen
75355714Skris  echo "WARNING! Do consider upgrading to gcc-2.8 or later."
75455714Skris  sleep 5
75555714Skris  OUT=solaris-sparcv9-gcc27
75655714Skrisfi
75755714Skrisif [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
75855714Skristhen
75955714Skris  echo "WARNING! Falling down to 'linux-sparcv8'."
76055714Skris  echo "         Upgrade to gcc-2.8 or later."
76155714Skris  sleep 5
76255714Skris  OUT=linux-sparcv8
76355714Skrisfi
76455714Skris
76555714Skriscase "$GUESSOS" in
76655714Skris  i386-*) options="$options 386" ;;
76755714Skrisesac
76855714Skris
769109998Smarkmfor i in bf cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 aes ripemd rsa sha
77055714Skrisdo
77155714Skris  if [ ! -d crypto/$i ]
77255714Skris  then
77355714Skris    options="$options no-$i"
77455714Skris  fi
77555714Skrisdone
77655714Skris
777109998Smarkm# Discover Kerberos 5 (since it's still a prototype, we don't
778109998Smarkm# do any guesses yet, that's why this section is commented away.
779109998Smarkm#if [ -d /usr/kerberos ]; then
780109998Smarkm#    krb5_dir=/usr/kerberos
781109998Smarkm#    if [ \( -f $krb5_dir/lib/libgssapi_krb5.a -o -f $krb5_dir/lib/libgssapi_krb5.so* \)\
782109998Smarkm#	-a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
783109998Smarkm#	-a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
784109998Smarkm#	-a \( -f $krb5_dir/lib/libk5crypto.a -o -f $krb5_dir/lib/libk5crypto.so* \)\
785109998Smarkm#	-a \( -f $krb5_dir/include/krb5.h \) ]; then
786109998Smarkm#	options="$options --with-krb5-flavor=MIT"
787109998Smarkm#    fi
788109998Smarkm#elif [ -d /usr/heimdal ]; then
789109998Smarkm#    krb5_dir=/usr/heimdal
790109998Smarkm#    if [ \( -f $krb5_dir/lib/libgssapi.a -o -f $krb5_dir/lib/libgssapi.so* \)\
791109998Smarkm#	-a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
792109998Smarkm#	-a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
793109998Smarkm#	-a \( -f $krb5_dir/include/krb5.h \) ]; then
794109998Smarkm#	options="$options --with-krb5-flavor=Heimdal"
795109998Smarkm#    fi
796109998Smarkm#fi
797109998Smarkm
79855714Skrisif [ -z "$OUT" ]; then
79955714Skris  OUT="$CC"
80055714Skrisfi
80155714Skris
80255714Skrisif [ ".$PERL" = . ] ; then
80355714Skris	for i in . `echo $PATH | sed 's/:/ /g'`; do
80455714Skris		if [ -f "$i/perl5" ] ; then
80555714Skris			PERL="$i/perl5"
80655714Skris			break;
80755714Skris		fi;
80855714Skris	done
80955714Skrisfi
81055714Skris
81155714Skrisif [ ".$PERL" = . ] ; then
81255714Skris	for i in . `echo $PATH | sed 's/:/ /g'`; do
81355714Skris		if [ -f "$i/perl" ] ; then
81455714Skris			if "$i/perl" -e 'exit($]<5.0)'; then
81555714Skris				PERL="$i/perl"
81655714Skris				break;
81755714Skris			fi;
81855714Skris		fi;
81955714Skris	done
82055714Skrisfi
82155714Skris
82255714Skrisif [ ".$PERL" = . ] ; then
82355714Skris	echo "You need Perl 5."
82455714Skris	exit 1
82555714Skrisfi
82655714Skris
82755714Skris# run Configure to check to see if we need to specify the 
82855714Skris# compiler for the platform ... in which case we add it on
82955714Skris# the end ... otherwise we leave it off
83055714Skris
83159191Skris$PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
83255714Skrisif [ $? = "0" ]; then
83355714Skris  OUT="$OUT-$CC"
83455714Skrisfi
83555714Skris
83655714SkrisOUT="$PREFIX$OUT"
83755714Skris
83859191Skris$PERL ./Configure LIST | grep "$OUT" > /dev/null
83955714Skrisif [ $? = "0" ]; then
84072613Skris  echo Configuring for $OUT
84155714Skris
84255714Skris  if [ "$TEST" = "true" ]; then
84355714Skris    echo $PERL ./Configure $OUT $options
84455714Skris  else
84555714Skris    $PERL ./Configure $OUT $options
84655714Skris  fi
84755714Skriselse
84855714Skris  echo "This system ($OUT) is not supported. See file INSTALL for details."
84955714Skrisfi
85055714Skris)
851