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
347325335Sjkim    # The following combinations are supported
348325335Sjkim    # MINGW64* on x86_64 => mingw64
349325335Sjkim    # MINGW32* on x86_64 => mingw
350325335Sjkim    # MINGW32* on i?86 => mingw
351325335Sjkim    #
352325335Sjkim    # MINGW64* on i?86 isn't expected to work...
353325335Sjkim    MINGW64*:*:*:x86_64)
354325335Sjkim	echo "${MACHINE}-whatever-mingw64"; exit 0;
355325335Sjkim	;;
356160814Ssimon    MINGW*)
357160814Ssimon	echo "${MACHINE}-whatever-mingw"; exit 0;
358160814Ssimon	;;
35989837Skris    CYGWIN*)
360100928Snectar	case "$RELEASE" in
361100928Snectar	    [bB]*|1.0|1.[12].*)
362100928Snectar		echo "${MACHINE}-whatever-cygwin_pre1.3"
363100928Snectar		;;
364100928Snectar	    *)
365100928Snectar		echo "${MACHINE}-whatever-cygwin"
366100928Snectar		;;
367100928Snectar	esac
368100928Snectar	exit 0
36989837Skris	;;
37089837Skris
371100928Snectar    *"CRAY T3E")
372100928Snectar       echo "t3e-cray-unicosmk"; exit 0;
373100928Snectar       ;;
374100928Snectar
375100928Snectar    *CRAY*)
376100928Snectar       echo "j90-cray-unicos"; exit 0;
377100928Snectar       ;;
378109998Smarkm
379109998Smarkm    NONSTOP_KERNEL*)
380109998Smarkm       echo "nsr-tandem-nsk"; exit 0;
381109998Smarkm       ;;
382238405Sjkim
383238405Sjkim    vxworks*)
384238405Sjkim       echo "${MACHINE}-whatever-vxworks"; exit 0;
385238405Sjkim       ;;
38655714Skrisesac
38755714Skris
38855714Skris#
38955714Skris# Ugg. These are all we can determine by what we know about
39055714Skris# the output of uname. Be more creative:
39155714Skris#
39255714Skris
39355714Skris# Do the Apollo stuff first. Here, we just simply assume
39455714Skris# that the existance of the /usr/apollo directory is proof
39555714Skris# enough
39655714Skrisif [ -d /usr/apollo ]; then
39755714Skris    echo "whatever-apollo-whatever"
39855714Skris    exit 0
39955714Skrisfi
40055714Skris
40155714Skris# Now NeXT
40255714SkrisISNEXT=`hostinfo 2>/dev/null`
40355714Skriscase "$ISNEXT" in
40455714Skris    *'NeXT Mach 3.3'*)
40555714Skris	echo "whatever-next-nextstep3.3"; exit 0
40655714Skris	;;
40755714Skris    *NeXT*)
40855714Skris	echo "whatever-next-nextstep"; exit 0
40955714Skris	;;
41055714Skrisesac
41155714Skris
41255714Skris# At this point we gone through all the one's
41355714Skris# we know of: Punt
41455714Skris
41555714Skrisecho "${MACHINE}-whatever-${SYSTEM}" 
41655714Skrisexit 0
41755714Skris) 2>/dev/null | (
41855714Skris
41955714Skris# ---------------------------------------------------------------------------
42055714Skris# this is where the translation occurs into SSLeay terms
42155714Skris# ---------------------------------------------------------------------------
42255714Skris
423194206Ssimon# Only set CC if not supplied already
424238405Sjkimif [ -z "$CROSS_COMPILE$CC" ]; then
425238405Sjkim  GCCVER=`sh -c "gcc -dumpversion" 2>/dev/null`
426194206Ssimon  if [ "$GCCVER" != "" ]; then
427238405Sjkim    # then strip off whatever prefix egcs prepends the number with...
428238405Sjkim    # Hopefully, this will work for any future prefixes as well.
429238405Sjkim    GCCVER=`echo $GCCVER | LC_ALL=C sed 's/^[a-zA-Z]*\-//'`
430238405Sjkim    # Since gcc 3.1 gcc --version behaviour has changed.  gcc -dumpversion
431238405Sjkim    # does give us what we want though, so we use that.  We just just the
432238405Sjkim    # major and minor version numbers.
433238405Sjkim    # peak single digit before and after first dot, e.g. 2.95.1 gives 29
434238405Sjkim    GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
435194206Ssimon    CC=gcc
436194206Ssimon  else
437194206Ssimon    CC=cc
438194206Ssimon  fi
439194206Ssimonfi
440101613SnectarGCCVER=${GCCVER:-0}
441100936Snectarif [ "$SYSTEM" = "HP-UX" ];then
442100936Snectar  # By default gcc is a ILP32 compiler (with long long == 64).
443100936Snectar  GCC_BITS="32"
444100936Snectar  if [ $GCCVER -ge 30 ]; then
445100936Snectar    # PA64 support only came in with gcc 3.0.x.
446127128Snectar    # We check if the preprocessor symbol __LP64__ is defined...
447127128Snectar    if echo "__LP64__" | gcc -v -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null; then
448127128Snectar      : # __LP64__ has slipped through, it therefore is not defined
449127128Snectar    else
450100936Snectar      GCC_BITS="64"
451100936Snectar    fi
452100936Snectar  fi
453100936Snectarfi
45455714Skrisif [ "$SYSTEM" = "SunOS" ]; then
455109998Smarkm  if [ $GCCVER -ge 30 ]; then
456109998Smarkm    # 64-bit ABI isn't officially supported in gcc 3.0, but it appears
457109998Smarkm    # to be working, at the very least 'make test' passes...
458109998Smarkm    if gcc -v -E -x c /dev/null 2>&1 | grep __arch64__ > /dev/null; then
459109998Smarkm      GCC_ARCH="-m64"
460109998Smarkm    else
461109998Smarkm      GCC_ARCH="-m32"
462109998Smarkm    fi
463109998Smarkm  fi
46459191Skris  # check for WorkShop C, expected output is "cc: blah-blah C x.x"
46555714Skris  CCVER=`(cc -V 2>&1) 2>/dev/null | \
46655714Skris  	egrep -e '^cc: .* C [0-9]\.[0-9]' | \
46755714Skris	sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
46855714Skris  CCVER=${CCVER:-0}
469160814Ssimon  if [ $MACHINE != i86pc -a $CCVER -gt 40 ]; then
47055714Skris    CC=cc	# overrides gcc!!!
47155714Skris    if [ $CCVER -eq 50 ]; then
47255714Skris      echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
47355714Skris      echo "         patch #107357-01 or later applied."
47455714Skris      sleep 5
47555714Skris    fi
47655714Skris  fi
47755714Skrisfi
47855714Skris
47959191Skrisif [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
48059191Skris  # check for Compaq C, expected output is "blah-blah C Vx.x"
48159191Skris  CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
48259191Skris	egrep -e '.* C V[0-9]\.[0-9]' | \
48359191Skris	sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
48459191Skris  CCCVER=${CCCVER:-0}
48559191Skris  if [ $CCCVER -gt 60 ]; then
48659191Skris    CC=ccc	# overrides gcc!!! well, ccc outperforms inoticeably
48759191Skris		# only on hash routines and des, otherwise gcc (2.95)
48859191Skris		# keeps along rather tight...
48959191Skris  fi
49059191Skrisfi
49159191Skris
492111147Snectarif [ "${SYSTEM}" = "AIX" ]; then	# favor vendor cc over gcc
493120631Snectar    (cc) 2>&1 | grep -iv "not found" > /dev/null && CC=cc
494111147Snectarfi
495111147Snectar
49655714SkrisCCVER=${CCVER:-0}
49755714Skris
49855714Skris# read the output of the embedded GuessOS 
49955714Skrisread GUESSOS
50055714Skris
50155714Skrisecho Operating system: $GUESSOS
50255714Skris
50355714Skris# now map the output into SSLeay terms ... really should hack into the
50455714Skris# script above so we end up with values in vars but that would take
50555714Skris# more time that I want to waste at the moment
50655714Skriscase "$GUESSOS" in
507238405Sjkim  uClinux*64*)
508238405Sjkim    OUT=uClinux-dist64
509238405Sjkim	;;
510238405Sjkim  uClinux*)
511238405Sjkim    OUT=uClinux-dist
512238405Sjkim	;;
51355714Skris  mips2-sgi-irix)
514120631Snectar	CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
51555714Skris	CPU=${CPU:-0}
51655714Skris	if [ $CPU -ge 4000 ]; then
51755714Skris		options="$options -mips2"
51855714Skris	fi
51955714Skris	OUT="irix-$CC"
52055714Skris	;;
52155714Skris  mips3-sgi-irix)
522160814Ssimon	#CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
523160814Ssimon	#CPU=${CPU:-0}
524160814Ssimon	#if [ $CPU -ge 5000 ]; then
525160814Ssimon	#	options="$options -mips4"
526160814Ssimon	#else
527160814Ssimon	#	options="$options -mips3"
528160814Ssimon	#fi
52955714Skris	OUT="irix-mips3-$CC"
53055714Skris	;;
53155714Skris  mips4-sgi-irix64)
53255714Skris	echo "WARNING! If you wish to build 64-bit library, then you have to"
53376866Skris	echo "         invoke './Configure irix64-mips4-$CC' *manually*."
534160814Ssimon	if [ "$TEST" = "false" -a -t 1 ]; then
535109998Smarkm	  echo "         You have about 5 seconds to press Ctrl-C to abort."
536160814Ssimon	  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
537109998Smarkm	fi
538160814Ssimon        #CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
539160814Ssimon        #CPU=${CPU:-0}
540160814Ssimon        #if [ $CPU -ge 5000 ]; then
541160814Ssimon        #        options="$options -mips4"
542160814Ssimon        #else
543160814Ssimon        #        options="$options -mips3"
544160814Ssimon        #fi
54555714Skris	OUT="irix-mips3-$CC"
54655714Skris	;;
547160814Ssimon  ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
548238405Sjkim  ppc-apple-darwin*)
549238405Sjkim	ISA64=`(sysctl -n hw.optional.64bitops) 2>/dev/null`
550238405Sjkim	if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
551238405Sjkim	    echo "WARNING! If you wish to build 64-bit library, then you have to"
552238405Sjkim	    echo "         invoke './Configure darwin64-ppc-cc' *manually*."
553238405Sjkim	    if [ "$TEST" = "false" -a -t 1 ]; then
554238405Sjkim	      echo "         You have about 5 seconds to press Ctrl-C to abort."
555238405Sjkim	      (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
556238405Sjkim	    fi
557238405Sjkim	fi
558238405Sjkim	if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
559238405Sjkim	    OUT="darwin64-ppc-cc"
560238405Sjkim	else
561238405Sjkim	    OUT="darwin-ppc-cc"
562238405Sjkim	fi ;;
563238405Sjkim  i?86-apple-darwin*)
564238405Sjkim	ISA64=`(sysctl -n hw.optional.x86_64) 2>/dev/null`
565238405Sjkim	if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
566238405Sjkim	    echo "WARNING! If you wish to build 64-bit library, then you have to"
567238405Sjkim	    echo "         invoke './Configure darwin64-x86_64-cc' *manually*."
568238405Sjkim	    if [ "$TEST" = "false" -a -t 1 ]; then
569238405Sjkim	      echo "         You have about 5 seconds to press Ctrl-C to abort."
570238405Sjkim	      (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
571238405Sjkim	    fi
572238405Sjkim	fi
573238405Sjkim	if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
574238405Sjkim	    OUT="darwin64-x86_64-cc"
575238405Sjkim	else
576238405Sjkim	    OUT="darwin-i386-cc"
577238405Sjkim	fi ;;
578238405Sjkim  armv6+7-*-iphoneos)
579238405Sjkim	options="$options -arch%20armv6 -arch%20armv7"
580238405Sjkim	OUT="iphoneos-cross" ;;
581238405Sjkim  *-*-iphoneos)
582238405Sjkim	options="$options -arch%20${MACHINE}"
583238405Sjkim	OUT="iphoneos-cross" ;;
58459191Skris  alpha-*-linux2)
585160814Ssimon        ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo`
58659191Skris	case ${ISA:-generic} in
587160814Ssimon	*[678])	OUT="linux-alpha+bwx-$CC" ;;
58859191Skris	*)	OUT="linux-alpha-$CC" ;;
58959191Skris	esac
59059191Skris	if [ "$CC" = "gcc" ]; then
59159191Skris	    case ${ISA:-generic} in
592194206Ssimon	    EV5|EV45)		options="$options -mcpu=ev5";;
593194206Ssimon	    EV56|PCA56)		options="$options -mcpu=ev56";;
594194206Ssimon	    *)			options="$options -mcpu=ev6";;
59559191Skris	    esac
59659191Skris	fi
59759191Skris	;;
598160814Ssimon  ppc64-*-linux2)
599290207Sjkim	if [ -z "$KERNEL_BITS" ]; then
600290207Sjkim	    echo "WARNING! If you wish to build 64-bit library, then you have to"
601290207Sjkim	    echo "         invoke './Configure linux-ppc64' *manually*."
602290207Sjkim	    if [ "$TEST" = "false" -a -t 1 ]; then
603290207Sjkim		echo "         You have about 5 seconds to press Ctrl-C to abort."
604290207Sjkim		(trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
605290207Sjkim	    fi
606290207Sjkim	fi
607290207Sjkim	if [ "$KERNEL_BITS" = "64" ]; then
608290207Sjkim	    OUT="linux-ppc64"
609290207Sjkim	else
610290207Sjkim	    OUT="linux-ppc"
611290207Sjkim	    (echo "__LP64__" | gcc -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null) || options="$options -m32"
612290207Sjkim	fi
613290207Sjkim	;;
614290207Sjkim  ppc64le-*-linux2) OUT="linux-ppc64le" ;;
615290207Sjkim  ppc-*-linux2) OUT="linux-ppc" ;;
616290207Sjkim  mips64*-*-linux2)
617160814Ssimon	echo "WARNING! If you wish to build 64-bit library, then you have to"
618290207Sjkim	echo "         invoke './Configure linux64-mips64' *manually*."
619160814Ssimon	if [ "$TEST" = "false" -a -t 1 ]; then
620160814Ssimon	    echo "         You have about 5 seconds to press Ctrl-C to abort."
621160814Ssimon	    (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
622160814Ssimon	fi
623290207Sjkim	OUT="linux-mips64"
62489837Skris	;;
625290207Sjkim  mips*-*-linux2) OUT="linux-mips32" ;;
626238405Sjkim  ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
627238405Sjkim  ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
628238405Sjkim  pentium-*-vxworks*) OUT="vxworks-pentium" ;;
629238405Sjkim  simlinux-*-vxworks*) OUT="vxworks-simlinux" ;;
630238405Sjkim  mips-*-vxworks*) OUT="vxworks-mips";;
63159191Skris  ia64-*-linux?) OUT="linux-ia64" ;;
63255714Skris  sparc64-*-linux2)
633111147Snectar	echo "WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI"
634109998Smarkm	echo "         and wish to build 64-bit library, then you have to"
635109998Smarkm	echo "         invoke './Configure linux64-sparcv9' *manually*."
636160814Ssimon	if [ "$TEST" = "false" -a -t 1 ]; then
637109998Smarkm	  echo "          You have about 5 seconds to press Ctrl-C to abort."
638160814Ssimon	  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
639109998Smarkm	fi
64055714Skris	OUT="linux-sparcv9" ;;
64155714Skris  sparc-*-linux2)
642160814Ssimon	KARCH=`awk '/^type/{print$3;exit(0);}' /proc/cpuinfo`
64355714Skris	case ${KARCH:-sun4} in
64455714Skris	sun4u*)	OUT="linux-sparcv9" ;;
64555714Skris	sun4m)	OUT="linux-sparcv8" ;;
64655714Skris	sun4d)	OUT="linux-sparcv8" ;;
647160814Ssimon	*)	OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
64855714Skris	esac ;;
649160814Ssimon  parisc*-*-linux2)
650160814Ssimon	# 64-bit builds under parisc64 linux are not supported and
651160814Ssimon	# compiler is expected to generate 32-bit objects...
652160814Ssimon	CPUARCH=`awk '/cpu family/{print substr($5,1,3); exit(0);}' /proc/cpuinfo`
653160814Ssimon	CPUSCHEDULE=`awk '/^cpu.[ 	]*: PA/{print substr($3,3); exit(0);}' /proc/cpuinfo`
654100928Snectar
655100928Snectar	# ??TODO ??  Model transformations
656100928Snectar	# 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
657100928Snectar	#    assuming no further arch. identification will ever be used by GCC.
658100928Snectar	# 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
659100928Snectar	# 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
660100928Snectar	#    for these chips in the future.
661100928Snectar	#         PA7300LC -> 7100LC (1.1)
662100928Snectar	#         PA8200   -> 8000   (2.0)
663100928Snectar	#         PA8500   -> 8000   (2.0)
664100928Snectar	#         PA8600   -> 8000   (2.0)
665100928Snectar
666160814Ssimon	CPUSCHEDULE=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8.00/8000/'`
667100928Snectar	# Finish Model transformations
668100928Snectar
669160814Ssimon	options="$options -DB_ENDIAN -mschedule=$CPUSCHEDULE -march=$CPUARCH"
670160814Ssimon	OUT="linux-generic32" ;;
671238405Sjkim  armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
672238405Sjkim  armv[7-9]*-*-linux2) OUT="linux-armv4"; options="$options -march=armv7-a" ;;
673238405Sjkim  arm*-*-linux2) OUT="linux-armv4" ;;
674290207Sjkim  aarch64-*-linux2) OUT="linux-aarch64" ;;
675167612Ssimon  sh*b-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
676167612Ssimon  sh*-*-linux2)  OUT="linux-generic32"; options="$options -DL_ENDIAN" ;;
677167612Ssimon  m68k*-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
678238405Sjkim  s390-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
679238405Sjkim  s390x-*-linux2)
680238405Sjkim	# To be uncommented when glibc bug is fixed, see Configure...
681238405Sjkim	#if egrep -e '^features.* highgprs' /proc/cpuinfo >/dev/null ; then
682238405Sjkim	#  echo "WARNING! If you wish to build \"highgprs\" 32-bit library, then you"
683238405Sjkim	#  echo "         have to invoke './Configure linux32-s390x' *manually*."
684238405Sjkim	#  if [ "$TEST" = "false" -a -t -1 ]; then
685238405Sjkim	#    echo "         You have about 5 seconds to press Ctrl-C to abort."
686238405Sjkim	#    (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
687238405Sjkim	#  fi
688238405Sjkim	#fi
689238405Sjkim	OUT="linux64-s390x"
690238405Sjkim	;;
691109998Smarkm  x86_64-*-linux?) OUT="linux-x86_64" ;;
692160814Ssimon  *86-*-linux2) OUT="linux-elf"
693109998Smarkm	if [ "$GCCVER" -gt 28 ]; then
694109998Smarkm          if grep '^model.*Pentium' /proc/cpuinfo >/dev/null ; then
695167612Ssimon	    options="$options -march=pentium"
696109998Smarkm          fi
697109998Smarkm          if grep '^model.*Pentium Pro' /proc/cpuinfo >/dev/null ; then
698167612Ssimon	    options="$options -march=pentiumpro"
699109998Smarkm          fi
700109998Smarkm          if grep '^model.*K6' /proc/cpuinfo >/dev/null ; then
701167612Ssimon	    options="$options -march=k6"
702109998Smarkm          fi
703109998Smarkm        fi ;;
70455714Skris  *-*-linux1) OUT="linux-aout" ;;
705160814Ssimon  *-*-linux2) OUT="linux-generic32" ;;
706194206Ssimon  sun4[uv]*-*-solaris2)
707109998Smarkm	OUT="solaris-sparcv9-$CC"
70855714Skris	ISA64=`(isalist) 2>/dev/null | grep sparcv9`
709238405Sjkim	if [ "$ISA64" != "" -a "$KERNEL_BITS" = "" ]; then
710109998Smarkm	    if [ "$CC" = "cc" -a $CCVER -ge 50 ]; then
71155714Skris		echo "WARNING! If you wish to build 64-bit library, then you have to"
71255714Skris		echo "         invoke './Configure solaris64-sparcv9-cc' *manually*."
713160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
714109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
715160814Ssimon		  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
716109998Smarkm		fi
717109998Smarkm	    elif [ "$CC" = "gcc" -a "$GCC_ARCH" = "-m64" ]; then
718109998Smarkm		# $GCC_ARCH denotes default ABI chosen by compiler driver
719109998Smarkm		# (first one found on the $PATH). I assume that user
720109998Smarkm		# expects certain consistency with the rest of his builds
721109998Smarkm		# and therefore switch over to 64-bit. <appro>
722109998Smarkm		OUT="solaris64-sparcv9-gcc"
723109998Smarkm		echo "WARNING! If you wish to build 32-bit library, then you have to"
724109998Smarkm		echo "         invoke './Configure solaris-sparcv9-gcc' *manually*."
725160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
726109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
727160814Ssimon		  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
728109998Smarkm		fi
729109998Smarkm	    elif [ "$GCC_ARCH" = "-m32" ]; then
730109998Smarkm		echo "NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI"
731109998Smarkm		echo "        and wish to build 64-bit library, then you have to"
732109998Smarkm		echo "        invoke './Configure solaris64-sparcv9-gcc' *manually*."
733160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
734109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
735160814Ssimon		  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
736109998Smarkm		fi
737109998Smarkm	    fi
73855714Skris	fi
739238405Sjkim	if [ "$ISA64" != "" -a "$KERNEL_BITS" = "64" ]; then
740238405Sjkim	    OUT="solaris64-sparcv9-$CC"
741238405Sjkim	fi
742109998Smarkm	;;
74368651Skris  sun4m-*-solaris2)	OUT="solaris-sparcv8-$CC" ;;
74468651Skris  sun4d-*-solaris2)	OUT="solaris-sparcv8-$CC" ;;
74568651Skris  sun4*-*-solaris2)	OUT="solaris-sparcv7-$CC" ;;
746160814Ssimon  *86*-*-solaris2)
747160814Ssimon	ISA64=`(isalist) 2>/dev/null | grep amd64`
748238405Sjkim	if [ "$ISA64" != "" -a ${KERNEL_BITS:-64} -eq 64 ]; then
749160814Ssimon	    OUT="solaris64-x86_64-$CC"
750160814Ssimon	else
751160814Ssimon	    OUT="solaris-x86-$CC"
752160814Ssimon	    if [ `uname -r | sed -e 's/5\.//'` -lt 10 ]; then
753160814Ssimon		options="$options no-sse2"
754160814Ssimon	    fi
755160814Ssimon	fi
756160814Ssimon	;;
757160814Ssimon  *-*-sunos4)		OUT="sunos-$CC" ;;
758160814Ssimon
759160814Ssimon  *86*-*-bsdi4)		OUT="BSD-x86-elf"; options="$options no-sse2 -ldl" ;;
760194206Ssimon  alpha*-*-*bsd*)	OUT="BSD-generic64"; options="$options -DL_ENDIAN" ;;
761194206Ssimon  powerpc64-*-*bsd*)	OUT="BSD-generic64"; options="$options -DB_ENDIAN" ;;
762160814Ssimon  sparc64-*-*bsd*)	OUT="BSD-sparc64" ;;
763160814Ssimon  ia64-*-*bsd*)		OUT="BSD-ia64" ;;
764160814Ssimon  amd64-*-*bsd*)	OUT="BSD-x86_64" ;;
765160814Ssimon  *86*-*-*bsd*)		# mimic ld behaviour when it's looking for libc...
766160814Ssimon			if [ -L /usr/lib/libc.so ]; then	# [Free|Net]BSD
767160814Ssimon			    libc=/usr/lib/libc.so
768160814Ssimon			else					# OpenBSD
769160814Ssimon			    # ld searches for highest libc.so.* and so do we
770261037Sjkim			    libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
771160814Ssimon			fi
772160814Ssimon			case "`(file -L $libc) 2>/dev/null`" in
773160814Ssimon			*ELF*)	OUT="BSD-x86-elf" ;;
774160814Ssimon			*)	OUT="BSD-x86"; options="$options no-sse2" ;;
775160814Ssimon			esac ;;
776160814Ssimon  *-*-*bsd*)		OUT="BSD-generic32" ;;
777160814Ssimon
778160814Ssimon  *-*-osf)		OUT="osf1-alpha-cc" ;;
779160814Ssimon  *-*-tru64)		OUT="tru64-alpha-cc" ;;
780160814Ssimon  *-*-[Uu]nix[Ww]are7)
78189837Skris	if [ "$CC" = "gcc" ]; then
782160814Ssimon	  OUT="unixware-7-gcc" ; options="$options no-sse2"
78389837Skris	else    
784160814Ssimon	  OUT="unixware-7" ; options="$options no-sse2 -D__i386__"
78589837Skris	fi
78689837Skris	;;
787160814Ssimon  *-*-[Uu]nix[Ww]are20*) OUT="unixware-2.0"; options="$options no-sse2 no-sha512" ;;
788160814Ssimon  *-*-[Uu]nix[Ww]are21*) OUT="unixware-2.1"; options="$options no-sse2 no-sha512" ;;
789142425Snectar  *-*-vos)
790142425Snectar	options="$options no-threads no-shared no-asm no-dso"
791142425Snectar	EXE=".pm"
792142425Snectar	OUT="vos-$CC" ;;
79355714Skris  BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
79455714Skris  RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
79555714Skris  *-siemens-sysv4) OUT="SINIX" ;;
796100936Snectar  *-hpux1*)
797160814Ssimon	if [ $CC = "gcc" -a $GCC_BITS = "64" ]; then
798127128Snectar	    OUT="hpux64-parisc2-gcc"
799100936Snectar	fi
800238405Sjkim	[ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITS) 2>/dev/null`
801109998Smarkm	KERNEL_BITS=${KERNEL_BITS:-32}
802109998Smarkm	CPU_VERSION=`(getconf CPU_VERSION) 2>/dev/null`
803109998Smarkm	CPU_VERSION=${CPU_VERSION:-0}
804109998Smarkm	# See <sys/unistd.h> for further info on CPU_VERSION.
805109998Smarkm	if   [ $CPU_VERSION -ge 768 ]; then	# IA-64 CPU
806238405Sjkim	     if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
807238405Sjkim	        OUT="hpux64-ia64-cc"
808238405Sjkim             else
809238405Sjkim	        OUT="hpux-ia64-cc"
810238405Sjkim             fi
811109998Smarkm	elif [ $CPU_VERSION -ge 532 ]; then	# PA-RISC 2.x CPU
812160814Ssimon	     OUT=${OUT:-"hpux-parisc2-${CC}"}
813109998Smarkm	     if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
814109998Smarkm		echo "WARNING! If you wish to build 64-bit library then you have to"
815109998Smarkm		echo "         invoke './Configure hpux64-parisc2-cc' *manually*."
816160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
817109998Smarkm		  echo "         You have about 5 seconds to press Ctrl-C to abort."
818160814Ssimon		  (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
819109998Smarkm		fi
820109998Smarkm	     fi
821109998Smarkm	elif [ $CPU_VERSION -ge 528 ]; then	# PA-RISC 1.1+ CPU
822162911Ssimon	     OUT="hpux-parisc-${CC}"
823109998Smarkm	elif [ $CPU_VERSION -ge 523 ]; then	# PA-RISC 1.0 CPU
824162911Ssimon	     OUT="hpux-parisc-${CC}"
825109998Smarkm	else					# Motorola(?) CPU
826109998Smarkm	     OUT="hpux-$CC"
827109998Smarkm	fi
828100936Snectar	options="$options -D_REENTRANT" ;;
82959191Skris  *-hpux)	OUT="hpux-parisc-$CC" ;;
830160814Ssimon  *-aix)
831238405Sjkim	[ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITMODE) 2>/dev/null`
832160814Ssimon	KERNEL_BITS=${KERNEL_BITS:-32}
833160814Ssimon	OBJECT_MODE=${OBJECT_MODE:-32}
834160814Ssimon	if [ "$CC" = "gcc" ]; then
835160814Ssimon	    OUT="aix-gcc"
836206046Ssimon          if [ $OBJECT_MODE -eq 64 ]; then
837206046Ssimon            echo 'Your $OBJECT_MODE was found to be set to 64'
838206046Ssimon            OUT="aix64-gcc"
839206046Ssimon          fi
840160814Ssimon	elif [ $OBJECT_MODE -eq 64 ]; then
841160814Ssimon	    echo 'Your $OBJECT_MODE was found to be set to 64' 
842160814Ssimon	    OUT="aix64-cc"
843160814Ssimon	else
844160814Ssimon	    OUT="aix-cc"
845160814Ssimon	    if [ $KERNEL_BITS -eq 64 ]; then
846160814Ssimon		echo "WARNING! If you wish to build 64-bit kit, then you have to"
847160814Ssimon		echo "         invoke './Configure aix64-cc' *manually*."
848160814Ssimon		if [ "$TEST" = "false" -a -t 1 ]; then
849160814Ssimon		    echo "         You have ~5 seconds to press Ctrl-C to abort."
850160814Ssimon		    (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
851160814Ssimon		fi
852160814Ssimon	    fi
853160814Ssimon	fi
854194206Ssimon	if (lsattr -E -O -l `lsdev -c processor|awk '{print$1;exit}'` | grep -i powerpc) >/dev/null 2>&1; then
855160814Ssimon	    :	# this applies even to Power3 and later, as they return PowerPC_POWER[345]
856160814Ssimon	else
857160814Ssimon	    options="$options no-asm"
858160814Ssimon	fi
859160814Ssimon	;;
86055714Skris  # these are all covered by the catchall below
86155714Skris  # *-dgux) OUT="dgux" ;;
86268651Skris  mips-sony-newsos4) OUT="newsos4-gcc" ;;
863100928Snectar  *-*-cygwin_pre1.3) OUT="Cygwin-pre1.3" ;;
864296279Sjkim  i[3456]86-*-cygwin) OUT="Cygwin" ;;
865296279Sjkim  *-*-cygwin) OUT="Cygwin-${MACHINE}" ;;
866100928Snectar  t3e-cray-unicosmk) OUT="cray-t3e" ;;
867100928Snectar  j90-cray-unicos) OUT="cray-j90" ;;
868109998Smarkm  nsr-tandem-nsk) OUT="tandem-c89" ;;
869238405Sjkim  beos-*) OUT="$GUESSOS" ;;
870205128Ssimon  x86pc-*-qnx6) OUT="QNX6-i386" ;;
871205128Ssimon  *-*-qnx6) OUT="QNX6" ;;
872238405Sjkim  x86-*-android|i?86-*-android) OUT="android-x86" ;;
873238405Sjkim  armv[7-9]*-*-android) OUT="android-armv7" ;;
874348343Sjkim  aarch64-*-android) OUT="android64-aarch64" ;;
87555714Skris  *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
87655714Skrisesac
87755714Skris
878109998Smarkm# NB: This atalla support has been superceded by the ENGINE support
879109998Smarkm# That contains its own header and definitions anyway. Support can
880109998Smarkm# be enabled or disabled on any supported platform without external
881109998Smarkm# headers, eg. by adding the "hw-atalla" switch to ./config or
882109998Smarkm# perl Configure
883109998Smarkm#
88459191Skris# See whether we can compile Atalla support
885109998Smarkm#if [ -f /usr/include/atasi.h ]
886109998Smarkm#then
887109998Smarkm#  options="$options -DATALLA"
888109998Smarkm#fi
88959191Skris
890238405Sjkimif expr "$options" : '.*no\-asm' > /dev/null; then :; else
891238405Sjkim  sh -c "$CROSS_COMPILE${CC:-gcc} -Wa,--help -c -o /tmp/null.$$.o -x assembler /dev/null && rm /tmp/null.$$.o" 2>&1 | \
892238405Sjkim  grep \\--noexecstack >/dev/null && \
893237657Sjkim  options="$options -Wa,--noexecstack"
894238405Sjkimfi
895237657Sjkim
896167612Ssimon# gcc < 2.8 does not support -march=ultrasparc
89755714Skrisif [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
89855714Skristhen
899160814Ssimon  echo "WARNING! Falling down to 'solaris-sparcv8-gcc'."
900160814Ssimon  echo "         Upgrade to gcc-2.8 or later."
90155714Skris  sleep 5
902160814Ssimon  OUT=solaris-sparcv8-gcc
90355714Skrisfi
90455714Skrisif [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
90555714Skristhen
90655714Skris  echo "WARNING! Falling down to 'linux-sparcv8'."
90755714Skris  echo "         Upgrade to gcc-2.8 or later."
90855714Skris  sleep 5
90955714Skris  OUT=linux-sparcv8
91055714Skrisfi
91155714Skris
91255714Skriscase "$GUESSOS" in
91355714Skris  i386-*) options="$options 386" ;;
91455714Skrisesac
91555714Skris
916194206Ssimonfor i in aes bf camellia cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa seed sha
91755714Skrisdo
91855714Skris  if [ ! -d crypto/$i ]
91955714Skris  then
92055714Skris    options="$options no-$i"
92155714Skris  fi
92255714Skrisdone
92355714Skris
924109998Smarkm# Discover Kerberos 5 (since it's still a prototype, we don't
925109998Smarkm# do any guesses yet, that's why this section is commented away.
926109998Smarkm#if [ -d /usr/kerberos ]; then
927109998Smarkm#    krb5_dir=/usr/kerberos
928109998Smarkm#    if [ \( -f $krb5_dir/lib/libgssapi_krb5.a -o -f $krb5_dir/lib/libgssapi_krb5.so* \)\
929109998Smarkm#	-a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
930109998Smarkm#	-a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
931109998Smarkm#	-a \( -f $krb5_dir/lib/libk5crypto.a -o -f $krb5_dir/lib/libk5crypto.so* \)\
932109998Smarkm#	-a \( -f $krb5_dir/include/krb5.h \) ]; then
933109998Smarkm#	options="$options --with-krb5-flavor=MIT"
934109998Smarkm#    fi
935109998Smarkm#elif [ -d /usr/heimdal ]; then
936109998Smarkm#    krb5_dir=/usr/heimdal
937109998Smarkm#    if [ \( -f $krb5_dir/lib/libgssapi.a -o -f $krb5_dir/lib/libgssapi.so* \)\
938109998Smarkm#	-a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
939109998Smarkm#	-a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
940109998Smarkm#	-a \( -f $krb5_dir/include/krb5.h \) ]; then
941109998Smarkm#	options="$options --with-krb5-flavor=Heimdal"
942109998Smarkm#    fi
943109998Smarkm#fi
944109998Smarkm
94555714Skrisif [ -z "$OUT" ]; then
94655714Skris  OUT="$CC"
94755714Skrisfi
94855714Skris
94955714Skrisif [ ".$PERL" = . ] ; then
95055714Skris	for i in . `echo $PATH | sed 's/:/ /g'`; do
951142425Snectar		if [ -f "$i/perl5$EXE" ] ; then
952142425Snectar			PERL="$i/perl5$EXE"
95355714Skris			break;
95455714Skris		fi;
95555714Skris	done
95655714Skrisfi
95755714Skris
95855714Skrisif [ ".$PERL" = . ] ; then
95955714Skris	for i in . `echo $PATH | sed 's/:/ /g'`; do
960142425Snectar		if [ -f "$i/perl$EXE" ] ; then
961142425Snectar			if "$i/perl$EXE" -e 'exit($]<5.0)'; then
962142425Snectar				PERL="$i/perl$EXE"
96355714Skris				break;
96455714Skris			fi;
96555714Skris		fi;
96655714Skris	done
96755714Skrisfi
96855714Skris
96955714Skrisif [ ".$PERL" = . ] ; then
97055714Skris	echo "You need Perl 5."
97155714Skris	exit 1
97255714Skrisfi
97355714Skris
97455714Skris# run Configure to check to see if we need to specify the 
97555714Skris# compiler for the platform ... in which case we add it on
97655714Skris# the end ... otherwise we leave it off
97755714Skris
97859191Skris$PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
97955714Skrisif [ $? = "0" ]; then
98055714Skris  OUT="$OUT-$CC"
98155714Skrisfi
98255714Skris
98355714SkrisOUT="$PREFIX$OUT"
98455714Skris
98559191Skris$PERL ./Configure LIST | grep "$OUT" > /dev/null
98655714Skrisif [ $? = "0" ]; then
98772613Skris  echo Configuring for $OUT
98855714Skris
98955714Skris  if [ "$TEST" = "true" ]; then
99055714Skris    echo $PERL ./Configure $OUT $options
99155714Skris  else
99255714Skris    $PERL ./Configure $OUT $options
99355714Skris  fi
99455714Skriselse
99555714Skris  echo "This system ($OUT) is not supported. See file INSTALL for details."
996340704Sjkim  exit 1
99755714Skrisfi
99855714Skris)
999