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"
26142425SnectarEXE=""
27109998Smarkm
28109998Smarkm# pick up any command line args to config
29109998Smarkmfor i
30109998Smarkmdo
31109998Smarkmcase "$i" in 
32238405Sjkim-d*) PREFIX="debug-";;
33109998Smarkm-t*) TEST="true";;
34109998Smarkm-h*) TEST="true"; cat <<EOF
35109998SmarkmUsage: config [options]
36109998Smarkm -d	Add a debug- prefix to machine choice.
37109998Smarkm -t	Test mode, do not run the Configure perl script.
38109998Smarkm -h	This help.
39109998Smarkm
40109998SmarkmAny other text will be passed to the Configure perl script.
41109998SmarkmSee INSTALL for instructions.
42109998Smarkm
43109998SmarkmEOF
44109998Smarkm;;
45109998Smarkm*) options=$options" $i" ;;
46109998Smarkmesac
47109998Smarkmdone
48109998Smarkm
4955714Skris# First get uname entries that we use below
5055714Skris
51205128Ssimon[ "$MACHINE" ] || MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
52205128Ssimon[ "$RELEASE" ] || RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
53205128Ssimon[ "$SYSTEM" ] || SYSTEM=`(uname -s) 2>/dev/null`  || SYSTEM="unknown"
54205128Ssimon[ "$BUILD" ] || VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
5555714Skris
5659191Skris
5755714Skris# Now test for ISC and SCO, since it is has a braindamaged uname.
5855714Skris#
5955714Skris# We need to work around FreeBSD 1.1.5.1 
6055714Skris(
6155714SkrisXREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
6255714Skrisif [ "x$XREL" != "x" ]; then
6355714Skris    if [ -f /etc/kconfig ]; then
6455714Skris	case "$XREL" in
6555714Skris	    4.0|4.1)
6655714Skris		    echo "${MACHINE}-whatever-isc4"; exit 0
6755714Skris		;;
6855714Skris	esac
6955714Skris    else
7055714Skris	case "$XREL" in
7155714Skris	    3.2v4.2)
7255714Skris		echo "whatever-whatever-sco3"; exit 0
7355714Skris		;;
7455714Skris	    3.2v5.0*)
7555714Skris		echo "whatever-whatever-sco5"; exit 0
7655714Skris		;;
7755714Skris	    4.2MP)
78111147Snectar		case "x${VERSION}" in
79111147Snectar		    x2.0*) echo "whatever-whatever-unixware20"; exit 0 ;;
80111147Snectar		    x2.1*) echo "whatever-whatever-unixware21"; exit 0 ;;
81111147Snectar		    x2*)   echo "whatever-whatever-unixware2";  exit 0 ;;
82111147Snectar		esac
8355714Skris		;;
8455714Skris	    4.2)
85160814Ssimon		echo "whatever-whatever-unixware1"; exit 0
8655714Skris		;;
87160814Ssimon	    5*)
88111147Snectar		case "x${VERSION}" in
89111147Snectar		    # We hardcode i586 in place of ${MACHINE} for the
90111147Snectar		    # following reason. The catch is that even though Pentium
91111147Snectar		    # is minimum requirement for platforms in question,
92111147Snectar		    # ${MACHINE} gets always assigned to i386. Now, problem
93111147Snectar		    # with i386 is that it makes ./config pass 386 to
94111147Snectar		    # ./Configure, which in turn makes make generate
95111147Snectar		    # inefficient SHA-1 (for this moment) code.
96160814Ssimon		    x[678]*)  echo "i586-sco-unixware7"; exit 0 ;;
97111147Snectar		esac
9859191Skris		;;
9955714Skris	esac
10055714Skris    fi
10155714Skrisfi
10255714Skris# Now we simply scan though... In most cases, the SYSTEM info is enough
10355714Skris#
10455714Skriscase "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
10568651Skris    MPE/iX:*)
10668651Skris	MACHINE=`echo "$MACHINE" | sed -e 's/-/_/g'`
10768651Skris	echo "parisc-hp-MPE/iX"; exit 0
10868651Skris	;;
10955714Skris    A/UX:*)
11055714Skris	echo "m68k-apple-aux3"; exit 0
11155714Skris	;;
11255714Skris
113160814Ssimon    AIX:[3-9]:4:*)
114160814Ssimon	echo "${MACHINE}-ibm-aix"; exit 0
11576866Skris	;;
11676866Skris
117160814Ssimon    AIX:*:[5-9]:*)
118160814Ssimon	echo "${MACHINE}-ibm-aix"; exit 0
11976866Skris	;;
12076866Skris
12155714Skris    AIX:*)
122160814Ssimon	echo "${MACHINE}-ibm-aix3"; exit 0
12355714Skris	;;
12455714Skris
125238405Sjkim    BeOS:*:BePC)
126238405Sjkim    if [ -e /boot/develop/headers/be/bone ]; then
127238405Sjkim		echo "beos-x86-bone"; exit 0
128238405Sjkim	else
129238405Sjkim		echo "beos-x86-r5"; exit 0
130238405Sjkim	fi
131238405Sjkim	;;
132238405Sjkim
13355714Skris    dgux:*)
13455714Skris	echo "${MACHINE}-dg-dgux"; exit 0
13555714Skris	;;
13655714Skris
13755714Skris    HI-UX:*)
13855714Skris	echo "${MACHINE}-hi-hiux"; exit 0
13955714Skris	;;
14055714Skris
14155714Skris    HP-UX:*)
14255714Skris	HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
14355714Skris	case "$HPUXVER" in
144109998Smarkm	    1[0-9].*)	# HPUX 10 and 11 targets are unified
145127128Snectar		echo "${MACHINE}-hp-hpux1x"; exit 0
14655714Skris		;;
14755714Skris	    *)
14855714Skris		echo "${MACHINE}-hp-hpux"; exit 0
14955714Skris		;;
15055714Skris	esac
15155714Skris	;;
15255714Skris
15355714Skris    IRIX:5.*)
15455714Skris	echo "mips2-sgi-irix"; exit 0
15555714Skris	;;
15655714Skris
15755714Skris    IRIX:6.*)
15855714Skris	echo "mips3-sgi-irix"; exit 0
15955714Skris	;;
16055714Skris
16155714Skris    IRIX64:*)
16255714Skris	echo "mips4-sgi-irix64"; exit 0
16355714Skris	;;
16455714Skris
16555714Skris    Linux:[2-9].*)
16655714Skris	echo "${MACHINE}-whatever-linux2"; exit 0
16755714Skris	;;
16855714Skris
16955714Skris    Linux:1.*)
17055714Skris	echo "${MACHINE}-whatever-linux1"; exit 0
17155714Skris	;;
17255714Skris
173109998Smarkm    GNU*)
174109998Smarkm	echo "hurd-x86"; exit 0;
175109998Smarkm	;;
176109998Smarkm
17755714Skris    LynxOS:*)
17855714Skris	echo "${MACHINE}-lynx-lynxos"; exit 0
17955714Skris	;;
18055714Skris
18155714Skris    BSD/OS:4.*)  # BSD/OS always says 386
18255714Skris	echo "i486-whatever-bsdi4"; exit 0
18355714Skris	;;
18455714Skris
18555714Skris    BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
18655714Skris        case `/sbin/sysctl -n hw.model` in
18755714Skris	    Pentium*)
18855714Skris                echo "i586-whatever-bsdi"; exit 0
18955714Skris                ;;
19055714Skris            *)
19155714Skris                echo "i386-whatever-bsdi"; exit 0
19255714Skris                ;;
19355714Skris            esac;
19455714Skris	;;
19555714Skris
19655714Skris    BSD/386:*|BSD/OS:*)
19755714Skris	echo "${MACHINE}-whatever-bsdi"; exit 0
19855714Skris	;;
19955714Skris
200111147Snectar    FreeBSD:*:*:*386*)
20155714Skris        VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
20255714Skris        MACH=`sysctl -n hw.model`
20355714Skris        ARCH='whatever'
20455714Skris        case ${MACH} in
20555714Skris           *386*       ) MACH="i386"     ;;
20655714Skris           *486*       ) MACH="i486"     ;;
20755714Skris           Pentium\ II*) MACH="i686"     ;;
20855714Skris           Pentium*    ) MACH="i586"     ;;
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
217111147Snectar    FreeBSD:*)
218111147Snectar	echo "${MACHINE}-whatever-freebsd"; exit 0
219111147Snectar	;;
220111147Snectar
22155714Skris    NetBSD:*:*:*386*)
22272613Skris        echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
22355714Skris	;;
22455714Skris
22555714Skris    NetBSD:*)
22655714Skris	echo "${MACHINE}-whatever-netbsd"; exit 0
22755714Skris	;;
22855714Skris
22955714Skris    OpenBSD:*)
23055714Skris	echo "${MACHINE}-whatever-openbsd"; exit 0
23155714Skris	;;
23255714Skris
23389837Skris    OpenUNIX:*)
23489837Skris	echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
23589837Skris	;;
23689837Skris
23755714Skris    OSF1:*:*:*alpha*)
23889837Skris	OSFMAJOR=`echo ${RELEASE}| sed -e 's/^V\([0-9]*\)\..*$/\1/'`
23989837Skris	case "$OSFMAJOR" in
24089837Skris	    4|5)
24189837Skris		echo "${MACHINE}-dec-tru64"; exit 0
24289837Skris		;;
24389837Skris	    1|2|3)
24489837Skris		echo "${MACHINE}-dec-osf"; exit 0
24589837Skris		;;
24689837Skris	    *)
24789837Skris		echo "${MACHINE}-dec-osf"; exit 0
24889837Skris		;;
24989837Skris	esac
25055714Skris	;;
25155714Skris
25255714Skris    QNX:*)
25389837Skris	case "$RELEASE" in
25468651Skris	    4*)
25568651Skris		echo "${MACHINE}-whatever-qnx4"
25655714Skris		;;
25789837Skris	    6*)
25889837Skris		echo "${MACHINE}-whatever-qnx6"
25989837Skris		;;
26055714Skris	    *)
26168651Skris		echo "${MACHINE}-whatever-qnx"
26255714Skris		;;
26355714Skris	esac
26455714Skris	exit 0
26555714Skris	;;
26655714Skris
26755714Skris    Paragon*:*:*:*)
26855714Skris	echo "i860-intel-osf1"; exit 0
26955714Skris	;;
27055714Skris
27159191Skris    Rhapsody:*)
27259191Skris	echo "ppc-apple-rhapsody"; exit 0
27359191Skris	;;
27459191Skris
27589837Skris    Darwin:*)
276109998Smarkm	case "$MACHINE" in
277109998Smarkm	    Power*)
278109998Smarkm		echo "ppc-apple-darwin${VERSION}"
279109998Smarkm		;;
280109998Smarkm	    *)
281238405Sjkim		echo "i686-apple-darwin${VERSION}"
282109998Smarkm		;;
283109998Smarkm	esac
284109998Smarkm	exit 0
28589837Skris	;;
28689837Skris
28755714Skris    SunOS:5.*)
28868651Skris	echo "${MACHINE}-whatever-solaris2"; exit 0
28955714Skris	;;
29055714Skris
29155714Skris    SunOS:*)
29255714Skris	echo "${MACHINE}-sun-sunos4"; exit 0
29355714Skris	;;
29455714Skris
29555714Skris    UNIX_System_V:4.*:*)
29655714Skris	echo "${MACHINE}-whatever-sysv4"; exit 0
29755714Skris	;;
29855714Skris
299142425Snectar    VOS:*:*:i786)
300142425Snectar     echo "i386-stratus-vos"; exit 0
301142425Snectar     ;;
302142425Snectar
303142425Snectar    VOS:*:*:*)
304142425Snectar     echo "hppa1.1-stratus-vos"; exit 0
305142425Snectar     ;;
306142425Snectar
30755714Skris    *:4*:R4*:m88k)
30855714Skris	echo "${MACHINE}-whatever-sysv4"; exit 0
30955714Skris	;;
31055714Skris
31155714Skris    DYNIX/ptx:4*:*)
31255714Skris	echo "${MACHINE}-whatever-sysv4"; exit 0
31355714Skris	;;
31455714Skris
31555714Skris    *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
31655714Skris	echo "i486-ncr-sysv4"; exit 0
31755714Skris	;;
31855714Skris
31955714Skris    ULTRIX:*)
32055714Skris	echo "${MACHINE}-unknown-ultrix"; exit 0
32155714Skris	;;
32255714Skris
32355714Skris    SINIX*|ReliantUNIX*)
32455714Skris	echo "${MACHINE}-siemens-sysv4"; exit 0
32555714Skris	;;
32655714Skris
32755714Skris    POSIX-BC*)
32855714Skris	echo "${MACHINE}-siemens-sysv4"; exit 0   # Here, $MACHINE == "BS2000"
32955714Skris	;;
33055714Skris
33155714Skris    machten:*)
33255714Skris       echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
33355714Skris       ;;
33455714Skris
33555714Skris    library:*)
33655714Skris	echo "${MACHINE}-ncr-sysv4"; exit 0
33755714Skris	;;
33855714Skris
33955714Skris    ConvexOS:*:11.0:*)
34055714Skris	echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
34155714Skris	;;
34255714Skris
34368651Skris    NEWS-OS:4.*)
34468651Skris	echo "mips-sony-newsos4"; exit 0;
34568651Skris	;;
34668651Skris
347160814Ssimon    MINGW*)
348160814Ssimon	echo "${MACHINE}-whatever-mingw"; exit 0;
349160814Ssimon	;;
35089837Skris    CYGWIN*)
351100928Snectar	case "$RELEASE" in
352100928Snectar	    [bB]*|1.0|1.[12].*)
353100928Snectar		echo "${MACHINE}-whatever-cygwin_pre1.3"
354100928Snectar		;;
355100928Snectar	    *)
356100928Snectar		echo "${MACHINE}-whatever-cygwin"
357100928Snectar		;;
358100928Snectar	esac
359100928Snectar	exit 0
36089837Skris	;;
36189837Skris
362100928Snectar    *"CRAY T3E")
363100928Snectar       echo "t3e-cray-unicosmk"; exit 0;
364100928Snectar       ;;
365100928Snectar
366100928Snectar    *CRAY*)
367100928Snectar       echo "j90-cray-unicos"; exit 0;
368100928Snectar       ;;
369109998Smarkm
370109998Smarkm    NONSTOP_KERNEL*)
371109998Smarkm       echo "nsr-tandem-nsk"; exit 0;
372109998Smarkm       ;;
373238405Sjkim
374238405Sjkim    vxworks*)
375238405Sjkim       echo "${MACHINE}-whatever-vxworks"; exit 0;
376238405Sjkim       ;;
37755714Skrisesac
37855714Skris
37955714Skris#
38055714Skris# Ugg. These are all we can determine by what we know about
38155714Skris# the output of uname. Be more creative:
38255714Skris#
38355714Skris
38455714Skris# Do the Apollo stuff first. Here, we just simply assume
38555714Skris# that the existance of the /usr/apollo directory is proof
38655714Skris# enough
38755714Skrisif [ -d /usr/apollo ]; then
38855714Skris    echo "whatever-apollo-whatever"
38955714Skris    exit 0
39055714Skrisfi
39155714Skris
39255714Skris# Now NeXT
39355714SkrisISNEXT=`hostinfo 2>/dev/null`
39455714Skriscase "$ISNEXT" in
39555714Skris    *'NeXT Mach 3.3'*)
39655714Skris	echo "whatever-next-nextstep3.3"; exit 0
39755714Skris	;;
39855714Skris    *NeXT*)
39955714Skris	echo "whatever-next-nextstep"; exit 0
40055714Skris	;;
40155714Skrisesac
40255714Skris
40355714Skris# At this point we gone through all the one's
40455714Skris# we know of: Punt
40555714Skris
40655714Skrisecho "${MACHINE}-whatever-${SYSTEM}" 
40755714Skrisexit 0
40855714Skris) 2>/dev/null | (
40955714Skris
41055714Skris# ---------------------------------------------------------------------------
41155714Skris# this is where the translation occurs into SSLeay terms
41255714Skris# ---------------------------------------------------------------------------
41355714Skris
414194206Ssimon# Only set CC if not supplied already
415238405Sjkimif [ -z "$CROSS_COMPILE$CC" ]; then
416238405Sjkim  GCCVER=`sh -c "gcc -dumpversion" 2>/dev/null`
417194206Ssimon  if [ "$GCCVER" != "" ]; then
418238405Sjkim    # then strip off whatever prefix egcs prepends the number with...
419238405Sjkim    # Hopefully, this will work for any future prefixes as well.
420238405Sjkim    GCCVER=`echo $GCCVER | LC_ALL=C sed 's/^[a-zA-Z]*\-//'`
421238405Sjkim    # Since gcc 3.1 gcc --version behaviour has changed.  gcc -dumpversion
422238405Sjkim    # does give us what we want though, so we use that.  We just just the
423238405Sjkim    # major and minor version numbers.
424238405Sjkim    # peak single digit before and after first dot, e.g. 2.95.1 gives 29
425238405Sjkim    GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
426194206Ssimon    CC=gcc
427194206Ssimon  else
428194206Ssimon    CC=cc
429194206Ssimon  fi
430194206Ssimonfi
431101613SnectarGCCVER=${GCCVER:-0}
432100936Snectarif [ "$SYSTEM" = "HP-UX" ];then
433100936Snectar  # By default gcc is a ILP32 compiler (with long long == 64).
434100936Snectar  GCC_BITS="32"
435100936Snectar  if [ $GCCVER -ge 30 ]; then
436100936Snectar    # PA64 support only came in with gcc 3.0.x.
437127128Snectar    # We check if the preprocessor symbol __LP64__ is defined...
438127128Snectar    if echo "__LP64__" | gcc -v -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null; then
439127128Snectar      : # __LP64__ has slipped through, it therefore is not defined
440127128Snectar    else
441100936Snectar      GCC_BITS="64"
442100936Snectar    fi
443100936Snectar  fi
444100936Snectarfi
44555714Skrisif [ "$SYSTEM" = "SunOS" ]; then
446109998Smarkm  if [ $GCCVER -ge 30 ]; then
447109998Smarkm    # 64-bit ABI isn't officially supported in gcc 3.0, but it appears
448109998Smarkm    # to be working, at the very least 'make test' passes...
449109998Smarkm    if gcc -v -E -x c /dev/null 2>&1 | grep __arch64__ > /dev/null; then
450109998Smarkm      GCC_ARCH="-m64"
451109998Smarkm    else
452109998Smarkm      GCC_ARCH="-m32"
453109998Smarkm    fi
454109998Smarkm  fi
45559191Skris  # check for WorkShop C, expected output is "cc: blah-blah C x.x"
45655714Skris  CCVER=`(cc -V 2>&1) 2>/dev/null | \
45755714Skris  	egrep -e '^cc: .* C [0-9]\.[0-9]' | \
45855714Skris	sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
45955714Skris  CCVER=${CCVER:-0}
460160814Ssimon  if [ $MACHINE != i86pc -a $CCVER -gt 40 ]; then
46155714Skris    CC=cc	# overrides gcc!!!
46255714Skris    if [ $CCVER -eq 50 ]; then
46355714Skris      echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
46455714Skris      echo "         patch #107357-01 or later applied."
46555714Skris      sleep 5
46655714Skris    fi
46755714Skris  fi
46855714Skrisfi
46955714Skris
47059191Skrisif [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
47159191Skris  # check for Compaq C, expected output is "blah-blah C Vx.x"
47259191Skris  CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
47359191Skris	egrep -e '.* C V[0-9]\.[0-9]' | \
47459191Skris	sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
47559191Skris  CCCVER=${CCCVER:-0}
47659191Skris  if [ $CCCVER -gt 60 ]; then
47759191Skris    CC=ccc	# overrides gcc!!! well, ccc outperforms inoticeably
47859191Skris		# only on hash routines and des, otherwise gcc (2.95)
47959191Skris		# keeps along rather tight...
48059191Skris  fi
48159191Skrisfi
48259191Skris
483111147Snectarif [ "${SYSTEM}" = "AIX" ]; then	# favor vendor cc over gcc
484120631Snectar    (cc) 2>&1 | grep -iv "not found" > /dev/null && CC=cc
485111147Snectarfi
486111147Snectar
48755714SkrisCCVER=${CCVER:-0}
48855714Skris
48955714Skris# read the output of the embedded GuessOS 
49055714Skrisread GUESSOS
49155714Skris
49255714Skrisecho Operating system: $GUESSOS
49355714Skris
49455714Skris# now map the output into SSLeay terms ... really should hack into the
49555714Skris# script above so we end up with values in vars but that would take
49655714Skris# more time that I want to waste at the moment
49755714Skriscase "$GUESSOS" in
498238405Sjkim  uClinux*64*)
499238405Sjkim    OUT=uClinux-dist64
500238405Sjkim	;;
501238405Sjkim  uClinux*)
502238405Sjkim    OUT=uClinux-dist
503238405Sjkim	;;
50455714Skris  mips2-sgi-irix)
505120631Snectar	CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
50655714Skris	CPU=${CPU:-0}
50755714Skris	if [ $CPU -ge 4000 ]; then
50855714Skris		options="$options -mips2"
50955714Skris	fi
51055714Skris	OUT="irix-$CC"
51155714Skris	;;
51255714Skris  mips3-sgi-irix)
513160814Ssimon	#CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
514160814Ssimon	#CPU=${CPU:-0}
515160814Ssimon	#if [ $CPU -ge 5000 ]; then
516160814Ssimon	#	options="$options -mips4"
517160814Ssimon	#else
518160814Ssimon	#	options="$options -mips3"
519160814Ssimon	#fi
52055714Skris	OUT="irix-mips3-$CC"
52155714Skris	;;
52255714Skris  mips4-sgi-irix64)
52355714Skris	echo "WARNING! If you wish to build 64-bit library, then you have to"
52476866Skris	echo "         invoke './Configure irix64-mips4-$CC' *manually*."
525160814Ssimon	if [ "$TEST" = "false" -a -t 1 ]; then
526109998Smarkm	  echo "         You have about 5 seconds to press Ctrl-C to abort."
527160814Ssimon	  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
528109998Smarkm	fi
529160814Ssimon        #CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
530160814Ssimon        #CPU=${CPU:-0}
531160814Ssimon        #if [ $CPU -ge 5000 ]; then
532160814Ssimon        #        options="$options -mips4"
533160814Ssimon        #else
534160814Ssimon        #        options="$options -mips3"
535160814Ssimon        #fi
53655714Skris	OUT="irix-mips3-$CC"
53755714Skris	;;
538160814Ssimon  ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
539238405Sjkim  ppc-apple-darwin*)
540238405Sjkim	ISA64=`(sysctl -n hw.optional.64bitops) 2>/dev/null`
541238405Sjkim	if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
542238405Sjkim	    echo "WARNING! If you wish to build 64-bit library, then you have to"
543238405Sjkim	    echo "         invoke './Configure darwin64-ppc-cc' *manually*."
544238405Sjkim	    if [ "$TEST" = "false" -a -t 1 ]; then
545238405Sjkim	      echo "         You have about 5 seconds to press Ctrl-C to abort."
546238405Sjkim	      (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
547238405Sjkim	    fi
548238405Sjkim	fi
549238405Sjkim	if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
550238405Sjkim	    OUT="darwin64-ppc-cc"
551238405Sjkim	else
552238405Sjkim	    OUT="darwin-ppc-cc"
553238405Sjkim	fi ;;
554238405Sjkim  i?86-apple-darwin*)
555238405Sjkim	ISA64=`(sysctl -n hw.optional.x86_64) 2>/dev/null`
556238405Sjkim	if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
557238405Sjkim	    echo "WARNING! If you wish to build 64-bit library, then you have to"
558238405Sjkim	    echo "         invoke './Configure darwin64-x86_64-cc' *manually*."
559238405Sjkim	    if [ "$TEST" = "false" -a -t 1 ]; then
560238405Sjkim	      echo "         You have about 5 seconds to press Ctrl-C to abort."
561238405Sjkim	      (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
562238405Sjkim	    fi
563238405Sjkim	fi
564238405Sjkim	if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
565238405Sjkim	    OUT="darwin64-x86_64-cc"
566238405Sjkim	else
567238405Sjkim	    OUT="darwin-i386-cc"
568238405Sjkim	fi ;;
569238405Sjkim  armv6+7-*-iphoneos)
570238405Sjkim	options="$options -arch%20armv6 -arch%20armv7"
571238405Sjkim	OUT="iphoneos-cross" ;;
572238405Sjkim  *-*-iphoneos)
573238405Sjkim	options="$options -arch%20${MACHINE}"
574238405Sjkim	OUT="iphoneos-cross" ;;
57559191Skris  alpha-*-linux2)
576160814Ssimon        ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo`
57759191Skris	case ${ISA:-generic} in
578160814Ssimon	*[678])	OUT="linux-alpha+bwx-$CC" ;;
57959191Skris	*)	OUT="linux-alpha-$CC" ;;
58059191Skris	esac
58159191Skris	if [ "$CC" = "gcc" ]; then
58259191Skris	    case ${ISA:-generic} in
583194206Ssimon	    EV5|EV45)		options="$options -mcpu=ev5";;
584194206Ssimon	    EV56|PCA56)		options="$options -mcpu=ev56";;
585194206Ssimon	    *)			options="$options -mcpu=ev6";;
58659191Skris	    esac
58759191Skris	fi
58859191Skris	;;
589160814Ssimon  ppc64-*-linux2)
590160814Ssimon	echo "WARNING! If you wish to build 64-bit library, then you have to"
591160814Ssimon	echo "         invoke './Configure linux-ppc64' *manually*."
592160814Ssimon	if [ "$TEST" = "false" -a -t 1 ]; then
593160814Ssimon	    echo "         You have about 5 seconds to press Ctrl-C to abort."
594160814Ssimon	    (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
595160814Ssimon	fi
596160814Ssimon	OUT="linux-ppc"
59789837Skris	;;
59859191Skris  ppc-*-linux2) OUT="linux-ppc" ;;
599238405Sjkim  ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
600238405Sjkim  ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
601238405Sjkim  pentium-*-vxworks*) OUT="vxworks-pentium" ;;
602238405Sjkim  simlinux-*-vxworks*) OUT="vxworks-simlinux" ;;
603238405Sjkim  mips-*-vxworks*) OUT="vxworks-mips";;
60459191Skris  ia64-*-linux?) OUT="linux-ia64" ;;
60555714Skris  sparc64-*-linux2)
606111147Snectar	echo "WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI"
607109998Smarkm	echo "         and wish to build 64-bit library, then you have to"
608109998Smarkm	echo "         invoke './Configure linux64-sparcv9' *manually*."
609160814Ssimon	if [ "$TEST" = "false" -a -t 1 ]; then
610109998Smarkm	  echo "          You have about 5 seconds to press Ctrl-C to abort."
611160814Ssimon	  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
612109998Smarkm	fi
61355714Skris	OUT="linux-sparcv9" ;;
61455714Skris  sparc-*-linux2)
615160814Ssimon	KARCH=`awk '/^type/{print$3;exit(0);}' /proc/cpuinfo`
61655714Skris	case ${KARCH:-sun4} in
61755714Skris	sun4u*)	OUT="linux-sparcv9" ;;
61855714Skris	sun4m)	OUT="linux-sparcv8" ;;
61955714Skris	sun4d)	OUT="linux-sparcv8" ;;
620160814Ssimon	*)	OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
62155714Skris	esac ;;
622160814Ssimon  parisc*-*-linux2)
623160814Ssimon	# 64-bit builds under parisc64 linux are not supported and
624160814Ssimon	# compiler is expected to generate 32-bit objects...
625160814Ssimon	CPUARCH=`awk '/cpu family/{print substr($5,1,3); exit(0);}' /proc/cpuinfo`
626160814Ssimon	CPUSCHEDULE=`awk '/^cpu.[ 	]*: PA/{print substr($3,3); exit(0);}' /proc/cpuinfo`
627100928Snectar
628100928Snectar	# ??TODO ??  Model transformations
629100928Snectar	# 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
630100928Snectar	#    assuming no further arch. identification will ever be used by GCC.
631100928Snectar	# 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
632100928Snectar	# 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
633100928Snectar	#    for these chips in the future.
634100928Snectar	#         PA7300LC -> 7100LC (1.1)
635100928Snectar	#         PA8200   -> 8000   (2.0)
636100928Snectar	#         PA8500   -> 8000   (2.0)
637100928Snectar	#         PA8600   -> 8000   (2.0)
638100928Snectar
639160814Ssimon	CPUSCHEDULE=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8.00/8000/'`
640100928Snectar	# Finish Model transformations
641100928Snectar
642160814Ssimon	options="$options -DB_ENDIAN -mschedule=$CPUSCHEDULE -march=$CPUARCH"
643160814Ssimon	OUT="linux-generic32" ;;
644238405Sjkim  armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
645238405Sjkim  armv[7-9]*-*-linux2) OUT="linux-armv4"; options="$options -march=armv7-a" ;;
646238405Sjkim  arm*-*-linux2) OUT="linux-armv4" ;;
647167612Ssimon  sh*b-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
648167612Ssimon  sh*-*-linux2)  OUT="linux-generic32"; options="$options -DL_ENDIAN" ;;
649167612Ssimon  m68k*-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
650238405Sjkim  s390-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
651238405Sjkim  s390x-*-linux2)
652238405Sjkim	# To be uncommented when glibc bug is fixed, see Configure...
653238405Sjkim	#if egrep -e '^features.* highgprs' /proc/cpuinfo >/dev/null ; then
654238405Sjkim	#  echo "WARNING! If you wish to build \"highgprs\" 32-bit library, then you"
655238405Sjkim	#  echo "         have to invoke './Configure linux32-s390x' *manually*."
656238405Sjkim	#  if [ "$TEST" = "false" -a -t -1 ]; then
657238405Sjkim	#    echo "         You have about 5 seconds to press Ctrl-C to abort."
658238405Sjkim	#    (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
659238405Sjkim	#  fi
660238405Sjkim	#fi
661238405Sjkim	OUT="linux64-s390x"
662238405Sjkim	;;
663109998Smarkm  x86_64-*-linux?) OUT="linux-x86_64" ;;
664160814Ssimon  *86-*-linux2) OUT="linux-elf"
665109998Smarkm	if [ "$GCCVER" -gt 28 ]; then
666109998Smarkm          if grep '^model.*Pentium' /proc/cpuinfo >/dev/null ; then
667167612Ssimon	    options="$options -march=pentium"
668109998Smarkm          fi
669109998Smarkm          if grep '^model.*Pentium Pro' /proc/cpuinfo >/dev/null ; then
670167612Ssimon	    options="$options -march=pentiumpro"
671109998Smarkm          fi
672109998Smarkm          if grep '^model.*K6' /proc/cpuinfo >/dev/null ; then
673167612Ssimon	    options="$options -march=k6"
674109998Smarkm          fi
675109998Smarkm        fi ;;
67655714Skris  *-*-linux1) OUT="linux-aout" ;;
677160814Ssimon  *-*-linux2) OUT="linux-generic32" ;;
678194206Ssimon  sun4[uv]*-*-solaris2)
679109998Smarkm	OUT="solaris-sparcv9-$CC"
68055714Skris	ISA64=`(isalist) 2>/dev/null | grep sparcv9`
681238405Sjkim	if [ "$ISA64" != "" -a "$KERNEL_BITS" = "" ]; then
682109998Smarkm	    if [ "$CC" = "cc" -a $CCVER -ge 50 ]; then
68355714Skris		echo "WARNING! If you wish to build 64-bit library, then you have to"
68455714Skris		echo "         invoke './Configure solaris64-sparcv9-cc' *manually*."
685160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
686109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
687160814Ssimon		  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
688109998Smarkm		fi
689109998Smarkm	    elif [ "$CC" = "gcc" -a "$GCC_ARCH" = "-m64" ]; then
690109998Smarkm		# $GCC_ARCH denotes default ABI chosen by compiler driver
691109998Smarkm		# (first one found on the $PATH). I assume that user
692109998Smarkm		# expects certain consistency with the rest of his builds
693109998Smarkm		# and therefore switch over to 64-bit. <appro>
694109998Smarkm		OUT="solaris64-sparcv9-gcc"
695109998Smarkm		echo "WARNING! If you wish to build 32-bit library, then you have to"
696109998Smarkm		echo "         invoke './Configure solaris-sparcv9-gcc' *manually*."
697160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
698109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
699160814Ssimon		  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
700109998Smarkm		fi
701109998Smarkm	    elif [ "$GCC_ARCH" = "-m32" ]; then
702109998Smarkm		echo "NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI"
703109998Smarkm		echo "        and wish to build 64-bit library, then you have to"
704109998Smarkm		echo "        invoke './Configure solaris64-sparcv9-gcc' *manually*."
705160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
706109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
707160814Ssimon		  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
708109998Smarkm		fi
709109998Smarkm	    fi
71055714Skris	fi
711238405Sjkim	if [ "$ISA64" != "" -a "$KERNEL_BITS" = "64" ]; then
712238405Sjkim	    OUT="solaris64-sparcv9-$CC"
713238405Sjkim	fi
714109998Smarkm	;;
71568651Skris  sun4m-*-solaris2)	OUT="solaris-sparcv8-$CC" ;;
71668651Skris  sun4d-*-solaris2)	OUT="solaris-sparcv8-$CC" ;;
71768651Skris  sun4*-*-solaris2)	OUT="solaris-sparcv7-$CC" ;;
718160814Ssimon  *86*-*-solaris2)
719160814Ssimon	ISA64=`(isalist) 2>/dev/null | grep amd64`
720238405Sjkim	if [ "$ISA64" != "" -a ${KERNEL_BITS:-64} -eq 64 ]; then
721160814Ssimon	    OUT="solaris64-x86_64-$CC"
722160814Ssimon	else
723160814Ssimon	    OUT="solaris-x86-$CC"
724160814Ssimon	    if [ `uname -r | sed -e 's/5\.//'` -lt 10 ]; then
725160814Ssimon		options="$options no-sse2"
726160814Ssimon	    fi
727160814Ssimon	fi
728160814Ssimon	;;
729160814Ssimon  *-*-sunos4)		OUT="sunos-$CC" ;;
730160814Ssimon
731160814Ssimon  *86*-*-bsdi4)		OUT="BSD-x86-elf"; options="$options no-sse2 -ldl" ;;
732194206Ssimon  alpha*-*-*bsd*)	OUT="BSD-generic64"; options="$options -DL_ENDIAN" ;;
733194206Ssimon  powerpc64-*-*bsd*)	OUT="BSD-generic64"; options="$options -DB_ENDIAN" ;;
734160814Ssimon  sparc64-*-*bsd*)	OUT="BSD-sparc64" ;;
735160814Ssimon  ia64-*-*bsd*)		OUT="BSD-ia64" ;;
736160814Ssimon  amd64-*-*bsd*)	OUT="BSD-x86_64" ;;
737160814Ssimon  *86*-*-*bsd*)		# mimic ld behaviour when it's looking for libc...
738160814Ssimon			if [ -L /usr/lib/libc.so ]; then	# [Free|Net]BSD
739160814Ssimon			    libc=/usr/lib/libc.so
740160814Ssimon			else					# OpenBSD
741160814Ssimon			    # ld searches for highest libc.so.* and so do we
742264331Sjkim			    libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
743160814Ssimon			fi
744160814Ssimon			case "`(file -L $libc) 2>/dev/null`" in
745160814Ssimon			*ELF*)	OUT="BSD-x86-elf" ;;
746160814Ssimon			*)	OUT="BSD-x86"; options="$options no-sse2" ;;
747160814Ssimon			esac ;;
748160814Ssimon  *-*-*bsd*)		OUT="BSD-generic32" ;;
749160814Ssimon
750160814Ssimon  *-*-osf)		OUT="osf1-alpha-cc" ;;
751160814Ssimon  *-*-tru64)		OUT="tru64-alpha-cc" ;;
752160814Ssimon  *-*-[Uu]nix[Ww]are7)
75389837Skris	if [ "$CC" = "gcc" ]; then
754160814Ssimon	  OUT="unixware-7-gcc" ; options="$options no-sse2"
75589837Skris	else    
756160814Ssimon	  OUT="unixware-7" ; options="$options no-sse2 -D__i386__"
75789837Skris	fi
75889837Skris	;;
759160814Ssimon  *-*-[Uu]nix[Ww]are20*) OUT="unixware-2.0"; options="$options no-sse2 no-sha512" ;;
760160814Ssimon  *-*-[Uu]nix[Ww]are21*) OUT="unixware-2.1"; options="$options no-sse2 no-sha512" ;;
761142425Snectar  *-*-vos)
762142425Snectar	options="$options no-threads no-shared no-asm no-dso"
763142425Snectar	EXE=".pm"
764142425Snectar	OUT="vos-$CC" ;;
76555714Skris  BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
76655714Skris  RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
76755714Skris  *-siemens-sysv4) OUT="SINIX" ;;
768100936Snectar  *-hpux1*)
769160814Ssimon	if [ $CC = "gcc" -a $GCC_BITS = "64" ]; then
770127128Snectar	    OUT="hpux64-parisc2-gcc"
771100936Snectar	fi
772238405Sjkim	[ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITS) 2>/dev/null`
773109998Smarkm	KERNEL_BITS=${KERNEL_BITS:-32}
774109998Smarkm	CPU_VERSION=`(getconf CPU_VERSION) 2>/dev/null`
775109998Smarkm	CPU_VERSION=${CPU_VERSION:-0}
776109998Smarkm	# See <sys/unistd.h> for further info on CPU_VERSION.
777109998Smarkm	if   [ $CPU_VERSION -ge 768 ]; then	# IA-64 CPU
778238405Sjkim	     if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
779238405Sjkim	        OUT="hpux64-ia64-cc"
780238405Sjkim             else
781238405Sjkim	        OUT="hpux-ia64-cc"
782238405Sjkim             fi
783109998Smarkm	elif [ $CPU_VERSION -ge 532 ]; then	# PA-RISC 2.x CPU
784160814Ssimon	     OUT=${OUT:-"hpux-parisc2-${CC}"}
785109998Smarkm	     if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
786109998Smarkm		echo "WARNING! If you wish to build 64-bit library then you have to"
787109998Smarkm		echo "         invoke './Configure hpux64-parisc2-cc' *manually*."
788160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
789109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
790160814Ssimon		  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
791109998Smarkm		fi
792109998Smarkm	     fi
793109998Smarkm	elif [ $CPU_VERSION -ge 528 ]; then	# PA-RISC 1.1+ CPU
794162911Ssimon	     OUT="hpux-parisc-${CC}"
795109998Smarkm	elif [ $CPU_VERSION -ge 523 ]; then	# PA-RISC 1.0 CPU
796162911Ssimon	     OUT="hpux-parisc-${CC}"
797109998Smarkm	else					# Motorola(?) CPU
798109998Smarkm	     OUT="hpux-$CC"
799109998Smarkm	fi
800100936Snectar	options="$options -D_REENTRANT" ;;
80159191Skris  *-hpux)	OUT="hpux-parisc-$CC" ;;
802160814Ssimon  *-aix)
803238405Sjkim	[ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITMODE) 2>/dev/null`
804160814Ssimon	KERNEL_BITS=${KERNEL_BITS:-32}
805160814Ssimon	OBJECT_MODE=${OBJECT_MODE:-32}
806160814Ssimon	if [ "$CC" = "gcc" ]; then
807160814Ssimon	    OUT="aix-gcc"
808206046Ssimon          if [ $OBJECT_MODE -eq 64 ]; then
809206046Ssimon            echo 'Your $OBJECT_MODE was found to be set to 64'
810206046Ssimon            OUT="aix64-gcc"
811206046Ssimon          fi
812160814Ssimon	elif [ $OBJECT_MODE -eq 64 ]; then
813160814Ssimon	    echo 'Your $OBJECT_MODE was found to be set to 64' 
814160814Ssimon	    OUT="aix64-cc"
815160814Ssimon	else
816160814Ssimon	    OUT="aix-cc"
817160814Ssimon	    if [ $KERNEL_BITS -eq 64 ]; then
818160814Ssimon		echo "WARNING! If you wish to build 64-bit kit, then you have to"
819160814Ssimon		echo "         invoke './Configure aix64-cc' *manually*."
820160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
821160814Ssimon		    echo "         You have ~5 seconds to press Ctrl-C to abort."
822160814Ssimon		    (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
823160814Ssimon		fi
824160814Ssimon	    fi
825160814Ssimon	fi
826194206Ssimon	if (lsattr -E -O -l `lsdev -c processor|awk '{print$1;exit}'` | grep -i powerpc) >/dev/null 2>&1; then
827160814Ssimon	    :	# this applies even to Power3 and later, as they return PowerPC_POWER[345]
828160814Ssimon	else
829160814Ssimon	    options="$options no-asm"
830160814Ssimon	fi
831160814Ssimon	;;
83255714Skris  # these are all covered by the catchall below
83355714Skris  # *-dgux) OUT="dgux" ;;
83468651Skris  mips-sony-newsos4) OUT="newsos4-gcc" ;;
835100928Snectar  *-*-cygwin_pre1.3) OUT="Cygwin-pre1.3" ;;
836100928Snectar  *-*-cygwin) OUT="Cygwin" ;;
837100928Snectar  t3e-cray-unicosmk) OUT="cray-t3e" ;;
838100928Snectar  j90-cray-unicos) OUT="cray-j90" ;;
839109998Smarkm  nsr-tandem-nsk) OUT="tandem-c89" ;;
840238405Sjkim  beos-*) OUT="$GUESSOS" ;;
841205128Ssimon  x86pc-*-qnx6) OUT="QNX6-i386" ;;
842205128Ssimon  *-*-qnx6) OUT="QNX6" ;;
843238405Sjkim  x86-*-android|i?86-*-android) OUT="android-x86" ;;
844238405Sjkim  armv[7-9]*-*-android) OUT="android-armv7" ;;
84555714Skris  *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
84655714Skrisesac
84755714Skris
848109998Smarkm# NB: This atalla support has been superceded by the ENGINE support
849109998Smarkm# That contains its own header and definitions anyway. Support can
850109998Smarkm# be enabled or disabled on any supported platform without external
851109998Smarkm# headers, eg. by adding the "hw-atalla" switch to ./config or
852109998Smarkm# perl Configure
853109998Smarkm#
85459191Skris# See whether we can compile Atalla support
855109998Smarkm#if [ -f /usr/include/atasi.h ]
856109998Smarkm#then
857109998Smarkm#  options="$options -DATALLA"
858109998Smarkm#fi
85959191Skris
860238405Sjkimif expr "$options" : '.*no\-asm' > /dev/null; then :; else
861238405Sjkim  sh -c "$CROSS_COMPILE${CC:-gcc} -Wa,--help -c -o /tmp/null.$$.o -x assembler /dev/null && rm /tmp/null.$$.o" 2>&1 | \
862238405Sjkim  grep \\--noexecstack >/dev/null && \
863237657Sjkim  options="$options -Wa,--noexecstack"
864238405Sjkimfi
865237657Sjkim
866167612Ssimon# gcc < 2.8 does not support -march=ultrasparc
86755714Skrisif [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
86855714Skristhen
869160814Ssimon  echo "WARNING! Falling down to 'solaris-sparcv8-gcc'."
870160814Ssimon  echo "         Upgrade to gcc-2.8 or later."
87155714Skris  sleep 5
872160814Ssimon  OUT=solaris-sparcv8-gcc
87355714Skrisfi
87455714Skrisif [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
87555714Skristhen
87655714Skris  echo "WARNING! Falling down to 'linux-sparcv8'."
87755714Skris  echo "         Upgrade to gcc-2.8 or later."
87855714Skris  sleep 5
87955714Skris  OUT=linux-sparcv8
88055714Skrisfi
88155714Skris
88255714Skriscase "$GUESSOS" in
88355714Skris  i386-*) options="$options 386" ;;
88455714Skrisesac
88555714Skris
886194206Ssimonfor i in aes bf camellia cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa seed sha
88755714Skrisdo
88855714Skris  if [ ! -d crypto/$i ]
88955714Skris  then
89055714Skris    options="$options no-$i"
89155714Skris  fi
89255714Skrisdone
89355714Skris
894109998Smarkm# Discover Kerberos 5 (since it's still a prototype, we don't
895109998Smarkm# do any guesses yet, that's why this section is commented away.
896109998Smarkm#if [ -d /usr/kerberos ]; then
897109998Smarkm#    krb5_dir=/usr/kerberos
898109998Smarkm#    if [ \( -f $krb5_dir/lib/libgssapi_krb5.a -o -f $krb5_dir/lib/libgssapi_krb5.so* \)\
899109998Smarkm#	-a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
900109998Smarkm#	-a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
901109998Smarkm#	-a \( -f $krb5_dir/lib/libk5crypto.a -o -f $krb5_dir/lib/libk5crypto.so* \)\
902109998Smarkm#	-a \( -f $krb5_dir/include/krb5.h \) ]; then
903109998Smarkm#	options="$options --with-krb5-flavor=MIT"
904109998Smarkm#    fi
905109998Smarkm#elif [ -d /usr/heimdal ]; then
906109998Smarkm#    krb5_dir=/usr/heimdal
907109998Smarkm#    if [ \( -f $krb5_dir/lib/libgssapi.a -o -f $krb5_dir/lib/libgssapi.so* \)\
908109998Smarkm#	-a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
909109998Smarkm#	-a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
910109998Smarkm#	-a \( -f $krb5_dir/include/krb5.h \) ]; then
911109998Smarkm#	options="$options --with-krb5-flavor=Heimdal"
912109998Smarkm#    fi
913109998Smarkm#fi
914109998Smarkm
91555714Skrisif [ -z "$OUT" ]; then
91655714Skris  OUT="$CC"
91755714Skrisfi
91855714Skris
91955714Skrisif [ ".$PERL" = . ] ; then
92055714Skris	for i in . `echo $PATH | sed 's/:/ /g'`; do
921142425Snectar		if [ -f "$i/perl5$EXE" ] ; then
922142425Snectar			PERL="$i/perl5$EXE"
92355714Skris			break;
92455714Skris		fi;
92555714Skris	done
92655714Skrisfi
92755714Skris
92855714Skrisif [ ".$PERL" = . ] ; then
92955714Skris	for i in . `echo $PATH | sed 's/:/ /g'`; do
930142425Snectar		if [ -f "$i/perl$EXE" ] ; then
931142425Snectar			if "$i/perl$EXE" -e 'exit($]<5.0)'; then
932142425Snectar				PERL="$i/perl$EXE"
93355714Skris				break;
93455714Skris			fi;
93555714Skris		fi;
93655714Skris	done
93755714Skrisfi
93855714Skris
93955714Skrisif [ ".$PERL" = . ] ; then
94055714Skris	echo "You need Perl 5."
94155714Skris	exit 1
94255714Skrisfi
94355714Skris
94455714Skris# run Configure to check to see if we need to specify the 
94555714Skris# compiler for the platform ... in which case we add it on
94655714Skris# the end ... otherwise we leave it off
94755714Skris
94859191Skris$PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
94955714Skrisif [ $? = "0" ]; then
95055714Skris  OUT="$OUT-$CC"
95155714Skrisfi
95255714Skris
95355714SkrisOUT="$PREFIX$OUT"
95455714Skris
95559191Skris$PERL ./Configure LIST | grep "$OUT" > /dev/null
95655714Skrisif [ $? = "0" ]; then
95772613Skris  echo Configuring for $OUT
95855714Skris
95955714Skris  if [ "$TEST" = "true" ]; then
96055714Skris    echo $PERL ./Configure $OUT $options
96155714Skris  else
96255714Skris    $PERL ./Configure $OUT $options
96355714Skris  fi
96455714Skriselse
96555714Skris  echo "This system ($OUT) is not supported. See file INSTALL for details."
96655714Skrisfi
96755714Skris)
968