summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfig926
-rwxr-xr-xutil/perl/OpenSSL/config.pm922
2 files changed, 928 insertions, 920 deletions
diff --git a/config b/config
index 2e149ded7c..3f288f3740 100755
--- a/config
+++ b/config
@@ -1,926 +1,12 @@
-#!/bin/sh
-# Copyright 1998-2020 The OpenSSL Project Authors. All Rights Reserved.
+#! /usr/bin/env perl
+# -*- mode: perl; -*-
+# Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
-# OpenSSL config: determine the operating system and run ./Configure
-# Derived from minarch and GuessOS from Apache.
-#
-# Do "config -h" for usage information.
-SUFFIX=""
-DRYRUN="false"
-VERBOSE="false"
-EXE=""
-THERE=`dirname $0`
-
-# pick up any command line args to config
-for i
-do
-case "$i" in
--d*) options=$options" --debug";;
--t*) DRYRUN="true" VERBOSE="true";;
--v*) VERBOSE="true";;
--h*) DRYRUN="true"; cat <<EOF
-Usage: config [options]
- -d Build with debugging when possible.
- -t Test mode, do not run the Configure perl script.
- -v Verbose mode, show the exact Configure call that is being made.
- -h This help.
-
-Any other text will be passed to the Configure perl script.
-See INSTALL for instructions.
-
-EOF
-;;
-*) i=`echo "$i" | sed -e "s|'|'\\\\\\''|g"`
- options="$options '$i'" ;;
-esac
-done
-
-# Environment that's being passed to Configure
-__CNF_CPPDEFINES=
-__CNF_CPPINCLUDES=
-__CNF_CPPFLAGS=
-__CNF_CFLAGS=
-__CNF_CXXFLAGS=
-__CNF_LDFLAGS=
-__CNF_LDLIBS=
-
-# First get uname entries that we use below
-
-[ "$MACHINE" ] || MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
-[ "$RELEASE" ] || RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
-[ "$SYSTEM" ] || SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown"
-[ "$BUILD" ] || VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
-
-
-# Now test for ISC and SCO, since it is has a braindamaged uname.
-#
-# We need to work around FreeBSD 1.1.5.1
-(
-XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
-if [ "x$XREL" != "x" ]; then
- if [ -f /etc/kconfig ]; then
- case "$XREL" in
- 4.0|4.1)
- echo "${MACHINE}-whatever-isc4"; exit 0
- ;;
- esac
- else
- case "$XREL" in
- 3.2v4.2)
- echo "whatever-whatever-sco3"; exit 0
- ;;
- 3.2v5.0*)
- echo "whatever-whatever-sco5"; exit 0
- ;;
- 4.2MP)
- case "x${VERSION}" in
- x2.0*) echo "whatever-whatever-unixware20"; exit 0 ;;
- x2.1*) echo "whatever-whatever-unixware21"; exit 0 ;;
- x2*) echo "whatever-whatever-unixware2"; exit 0 ;;
- esac
- ;;
- 4.2)
- echo "whatever-whatever-unixware1"; exit 0
- ;;
- 5*)
- case "x${VERSION}" in
- # We hardcode i586 in place of ${MACHINE} for the
- # following reason. The catch is that even though Pentium
- # is minimum requirement for platforms in question,
- # ${MACHINE} gets always assigned to i386. Now, problem
- # with i386 is that it makes ./config pass 386 to
- # ./Configure, which in turn makes make generate
- # inefficient SHA-1 (for this moment) code.
- x[678]*) echo "i586-sco-unixware7"; exit 0 ;;
- esac
- ;;
- esac
- fi
-fi
-# Now we simply scan though... In most cases, the SYSTEM info is enough
-#
-case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
- A/UX:*)
- echo "m68k-apple-aux3"; exit 0
- ;;
-
- AIX:[3-9]:4:*)
- echo "${MACHINE}-ibm-aix"; exit 0
- ;;
-
- AIX:*:[5-9]:*)
- echo "${MACHINE}-ibm-aix"; exit 0
- ;;
-
- AIX:*)
- echo "${MACHINE}-ibm-aix3"; exit 0
- ;;
-
- HI-UX:*)
- echo "${MACHINE}-hi-hiux"; exit 0
- ;;
-
- HP-UX:*)
- HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- case "$HPUXVER" in
- 1[0-9].*) # HPUX 10 and 11 targets are unified
- echo "${MACHINE}-hp-hpux1x"; exit 0
- ;;
- *)
- echo "${MACHINE}-hp-hpux"; exit 0
- ;;
- esac
- ;;
-
- IRIX:6.*)
- echo "mips3-sgi-irix"; exit 0
- ;;
-
- IRIX64:*)
- echo "mips4-sgi-irix64"; exit 0
- ;;
-
- Linux:[2-9].*)
- echo "${MACHINE}-whatever-linux2"; exit 0
- ;;
-
- Linux:1.*)
- echo "${MACHINE}-whatever-linux1"; exit 0
- ;;
-
- GNU*)
- echo "hurd-x86"; exit 0;
- ;;
-
- LynxOS:*)
- echo "${MACHINE}-lynx-lynxos"; exit 0
- ;;
-
- BSD/OS:4.*) # BSD/OS always says 386
- echo "i486-whatever-bsdi4"; exit 0
- ;;
-
- BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
- case `/sbin/sysctl -n hw.model` in
- Pentium*)
- echo "i586-whatever-bsdi"; exit 0
- ;;
- *)
- echo "i386-whatever-bsdi"; exit 0
- ;;
- esac;
- ;;
-
- BSD/386:*|BSD/OS:*)
- echo "${MACHINE}-whatever-bsdi"; exit 0
- ;;
-
- FreeBSD:*:*:*386*)
- VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
- MACH=`sysctl -n hw.model`
- ARCH='whatever'
- case ${MACH} in
- *386* ) MACH="i386" ;;
- *486* ) MACH="i486" ;;
- Pentium\ II*) MACH="i686" ;;
- Pentium* ) MACH="i586" ;;
- * ) MACH="$MACHINE" ;;
- esac
- case ${MACH} in
- i[0-9]86 ) ARCH="pc" ;;
- esac
- echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
- ;;
-
- DragonFly:*)
- echo "${MACHINE}-whatever-dragonfly"; exit 0
- ;;
-
- FreeBSD:*)
- echo "${MACHINE}-whatever-freebsd"; exit 0
- ;;
-
- Haiku:*)
- echo "${MACHINE}-whatever-haiku"; exit 0
- ;;
-
- NetBSD:*:*:*386*)
- echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
- ;;
-
- NetBSD:*)
- echo "${MACHINE}-whatever-netbsd"; exit 0
- ;;
-
- OpenBSD:*)
- echo "${MACHINE}-whatever-openbsd"; exit 0
- ;;
-
- OpenUNIX:*)
- echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
- ;;
-
- OSF1:*:*:*alpha*)
- OSFMAJOR=`echo ${RELEASE}| sed -e 's/^V\([0-9]*\)\..*$/\1/'`
- case "$OSFMAJOR" in
- 4|5)
- echo "${MACHINE}-dec-tru64"; exit 0
- ;;
- 1|2|3)
- echo "${MACHINE}-dec-osf"; exit 0
- ;;
- *)
- echo "${MACHINE}-dec-osf"; exit 0
- ;;
- esac
- ;;
-
- Paragon*:*:*:*)
- echo "i860-intel-osf1"; exit 0
- ;;
-
- Rhapsody:*)
- echo "ppc-apple-rhapsody"; exit 0
- ;;
-
- Darwin:*)
- case "$MACHINE" in
- Power*)
- echo "ppc-apple-darwin${VERSION}"
- ;;
- x86_64)
- echo "x86_64-apple-darwin${VERSION}"
- ;;
- *)
- echo "i686-apple-darwin${VERSION}"
- ;;
- esac
- exit 0
- ;;
-
- SunOS:5.*)
- echo "${MACHINE}-whatever-solaris2"; exit 0
- ;;
-
- SunOS:*)
- echo "${MACHINE}-sun-sunos4"; exit 0
- ;;
-
- UNIX_System_V:4.*:*)
- echo "${MACHINE}-whatever-sysv4"; exit 0
- ;;
-
- VOS:*:*:i786)
- echo "i386-stratus-vos"; exit 0
- ;;
-
- VOS:*:*:*)
- echo "hppa1.1-stratus-vos"; exit 0
- ;;
-
- *:4*:R4*:m88k)
- echo "${MACHINE}-whatever-sysv4"; exit 0
- ;;
-
- DYNIX/ptx:4*:*)
- echo "${MACHINE}-whatever-sysv4"; exit 0
- ;;
-
- *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
- echo "i486-ncr-sysv4"; exit 0
- ;;
-
- ULTRIX:*)
- echo "${MACHINE}-unknown-ultrix"; exit 0
- ;;
-
- POSIX-BC*)
- echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
- ;;
-
- machten:*)
- echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
- ;;
-
- library:*)
- echo "${MACHINE}-ncr-sysv4"; exit 0
- ;;
-
- ConvexOS:*:11.0:*)
- echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
- ;;
-
- # The following combinations are supported
- # MINGW64* on x86_64 => mingw64
- # MINGW32* on x86_64 => mingw
- # MINGW32* on i?86 => mingw
- #
- # MINGW64* on i?86 isn't expected to work...
- MINGW64*:*:*:x86_64)
- echo "${MACHINE}-whatever-mingw64"; exit 0;
- ;;
- MINGW*)
- echo "${MACHINE}-whatever-mingw"; exit 0;
- ;;
- CYGWIN*)
- echo "${MACHINE}-pc-cygwin"; exit 0
- ;;
-
- vxworks*)
- echo "${MACHINE}-whatever-vxworks"; exit 0;
- ;;
-esac
-
-#
-# Ugg. These are all we can determine by what we know about
-# the output of uname. Be more creative:
-#
-
-# Do the Apollo stuff first. Here, we just simply assume
-# that the existence of the /usr/apollo directory is proof
-# enough
-if [ -d /usr/apollo ]; then
- echo "whatever-apollo-whatever"
- exit 0
-fi
-
-# At this point we gone through all the one's
-# we know of: Punt
-
-echo "${MACHINE}-whatever-${SYSTEM}"
-exit 0
-) 2>/dev/null | (
-
-# ---------------------------------------------------------------------------
-# this is where the translation occurs into SSLeay terms
-# ---------------------------------------------------------------------------
-
-# Only set CC if not supplied already
-if [ -z "$CROSS_COMPILE$CC" ]; then
- GCCVER=`sh -c "gcc -dumpversion" 2>/dev/null`
- if [ "$GCCVER" != "" ]; then
- # then strip off whatever prefix egcs prepends the number with...
- # Hopefully, this will work for any future prefixes as well.
- GCCVER=`echo $GCCVER | LC_ALL=C sed 's/^[a-zA-Z]*\-//'`
- # Since gcc 3.1 gcc --version behaviour has changed. gcc -dumpversion
- # does give us what we want though, so we use that. We just just the
- # major and minor version numbers.
- # peak single digit before and after first dot, e.g. 2.95.1 gives 29
- GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
- CC=gcc
- else
- CC=cc
- fi
-fi
-GCCVER=${GCCVER:-0}
-if [ "$SYSTEM" = "HP-UX" ];then
- # By default gcc is a ILP32 compiler (with long long == 64).
- GCC_BITS="32"
- if [ $GCCVER -ge 30 ]; then
- # PA64 support only came in with gcc 3.0.x.
- # We check if the preprocessor symbol __LP64__ is defined...
- if echo "__LP64__" | gcc -v -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null; then
- : # __LP64__ has slipped through, it therefore is not defined
- else
- GCC_BITS="64"
- fi
- fi
-fi
-if [ "$SYSTEM" = "SunOS" ]; then
- if [ $GCCVER -ge 30 ]; then
- # 64-bit ABI isn't officially supported in gcc 3.0, but it appears
- # to be working, at the very least 'make test' passes...
- if gcc -v -E -x c /dev/null 2>&1 | grep __arch64__ > /dev/null; then
- GCC_ARCH="-m64"
- else
- GCC_ARCH="-m32"
- fi
- fi
- # check for WorkShop C, expected output is "cc: blah-blah C x.x"
- CCVER=`(cc -V 2>&1) 2>/dev/null | \
- egrep -e '^cc: .* C [0-9]\.[0-9]' | \
- sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
- CCVER=${CCVER:-0}
- if [ $MACHINE != i86pc -a $CCVER -gt 40 ]; then
- CC=cc # overrides gcc!!!
- if [ $CCVER -eq 50 ]; then
- echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
- echo " patch #107357-01 or later applied."
- sleep 5
- fi
- fi
-fi
-
-if [ "${SYSTEM}" = "AIX" ]; then # favor vendor cc over gcc
- (cc) 2>&1 | grep -iv "not found" > /dev/null && CC=cc
-fi
-
-CCVER=${CCVER:-0}
-
-# read the output of the embedded GuessOS
-read GUESSOS
-
-echo Operating system: $GUESSOS
-
-# now map the output into SSLeay terms ... really should hack into the
-# script above so we end up with values in vars but that would take
-# more time that I want to waste at the moment
-case "$GUESSOS" in
- uClinux*64*)
- OUT=uClinux-dist64
- ;;
- uClinux*)
- OUT=uClinux-dist
- ;;
- mips3-sgi-irix)
- OUT="irix-mips3-$CC"
- ;;
- mips4-sgi-irix64)
- echo "WARNING! If you wish to build 64-bit library, then you have to"
- echo " invoke '$THERE/Configure irix64-mips4-$CC' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- OUT="irix-mips3-$CC"
- ;;
- ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
- ppc-apple-darwin*)
- ISA64=`(sysctl -n hw.optional.64bitops) 2>/dev/null`
- if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
- echo "WARNING! If you wish to build 64-bit library, then you have to"
- echo " invoke '$THERE/Configure darwin64-ppc-cc' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- fi
- if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
- OUT="darwin64-ppc-cc"
- else
- OUT="darwin-ppc-cc"
- fi ;;
- i?86-apple-darwin*)
- ISA64=`(sysctl -n hw.optional.x86_64) 2>/dev/null`
- if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
- echo "WARNING! If you wish to build 64-bit library, then you have to"
- echo " invoke 'KERNEL_BITS=64 $THERE/config $options'."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 1" 2; stty -icanon min 0 time 50; read waste; exit 0) <&1 || exit
- fi
- fi
- if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
- OUT="darwin64-x86_64-cc"
- else
- OUT="darwin-i386-cc"
- fi ;;
- x86_64-apple-darwin*)
- if [ "$KERNEL_BITS" = "32" ]; then
- OUT="darwin-i386-cc"
- else
- OUT="darwin64-x86_64-cc"
- fi ;;
- armv6+7-*-iphoneos)
- __CNF_CFLAGS="$__CNF_CFLAGS -arch armv6 -arch armv7"
- __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch armv6 -arch armv7"
- OUT="iphoneos-cross" ;;
- *-*-iphoneos)
- __CNF_CFLAGS="$__CNF_CFLAGS -arch ${MACHINE}"
- __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch ${MACHINE}"
- OUT="iphoneos-cross" ;;
- arm64-*-iphoneos|*-*-ios64)
- OUT="ios64-cross" ;;
- alpha-*-linux2)
- ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo`
- OUT="linux-alpha-$CC"
- if [ "$CC" = "gcc" ]; then
- case ${ISA:-generic} in
- EV5|EV45) __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev5"
- __CNF_CXXFLAGS="$__CNF_CFLAGS -mcpu=ev5";;
- EV56|PCA56) __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev56"
- __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mcpu=ev56";;
- *) __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev6"
- __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mcpu=ev6";;
- esac
- fi
- ;;
- ppc64-*-linux2)
- if [ -z "$KERNEL_BITS" ]; then
- echo "WARNING! If you wish to build 64-bit library, then you have to"
- echo " invoke '$THERE/Configure linux-ppc64' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- fi
- if [ "$KERNEL_BITS" = "64" ]; then
- OUT="linux-ppc64"
- else
- OUT="linux-ppc"
- if (echo "__LP64__" | gcc -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null); then
- :;
- else
- __CNF_CFLAGS="$__CNF_CFLAGS -m32"
- __CNF_CXXFLAGS="$__CNF_CXXFLAGS -m32"
- fi
- fi
- ;;
- ppc64le-*-linux2) OUT="linux-ppc64le" ;;
- ppc-*-linux2) OUT="linux-ppc" ;;
- mips64*-*-linux2)
- echo "WARNING! If you wish to build 64-bit library, then you have to"
- echo " invoke '$THERE/Configure linux64-mips64' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- OUT="linux-mips64"
- ;;
- mips*-*-linux2) OUT="linux-mips32" ;;
- ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
- ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
- pentium-*-vxworks*) OUT="vxworks-pentium" ;;
- simlinux-*-vxworks*) OUT="vxworks-simlinux" ;;
- mips-*-vxworks*) OUT="vxworks-mips";;
- e2k-*-linux*) OUT="linux-generic64 -DL_ENDIAN" ;;
- ia64-*-linux?) OUT="linux-ia64" ;;
- sparc64-*-linux2)
- echo "WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI"
- echo " and wish to build 64-bit library, then you have to"
- echo " invoke '$THERE/Configure linux64-sparcv9' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- OUT="linux-sparcv9" ;;
- sparc-*-linux2)
- KARCH=`awk '/^type/{print$3;exit(0);}' /proc/cpuinfo`
- case ${KARCH:-sun4} in
- sun4u*) OUT="linux-sparcv9" ;;
- sun4m) OUT="linux-sparcv8" ;;
- sun4d) OUT="linux-sparcv8" ;;
- *) OUT="linux-generic32";
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
- esac ;;
- parisc*-*-linux2)
- # 64-bit builds under parisc64 linux are not supported and
- # compiler is expected to generate 32-bit objects...
- CPUARCH=`awk '/cpu family/{print substr($5,1,3); exit(0);}' /proc/cpuinfo`
- CPUSCHEDULE=`awk '/^cpu.[ ]*: PA/{print substr($3,3); exit(0);}' /proc/cpuinfo`
-
- # ??TODO ?? Model transformations
- # 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
- # assuming no further arch. identification will ever be used by GCC.
- # 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
- # 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
- # for these chips in the future.
- # PA7300LC -> 7100LC (1.1)
- # PA8200 -> 8000 (2.0)
- # PA8500 -> 8000 (2.0)
- # PA8600 -> 8000 (2.0)
-
- CPUSCHEDULE=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8.00/8000/'`
- # Finish Model transformations
-
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN"
- __CNF_CFLAGS="$__CNF_CFLAGS -mschedule=$CPUSCHEDULE -march=$CPUARCH"
- __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mschedule=$CPUSCHEDULE -march=$CPUARCH"
- OUT="linux-generic32" ;;
- armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
- armv[7-9]*-*-linux2) OUT="linux-armv4"
- __CNF_CFLAGS="$__CNF_CFLAGS -march=armv7-a"
- __CNF_CXXFLAGS="$__CNF_CXXFLAGS -march=armv7-a"
- ;;
- arm*-*-linux2) OUT="linux-armv4" ;;
- aarch64-*-linux2) OUT="linux-aarch64" ;;
- sh*b-*-linux2) OUT="linux-generic32";
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
- sh*-*-linux2) OUT="linux-generic32";
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DL_ENDIAN" ;;
- m68k*-*-linux2) OUT="linux-generic32";
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
- s390-*-linux2) OUT="linux-generic32";
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
- s390x-*-linux2)
- # To be uncommented when glibc bug is fixed, see Configure...
- #if egrep -e '^features.* highgprs' /proc/cpuinfo >/dev/null ; then
- # echo "WARNING! If you wish to build \"highgprs\" 32-bit library, then you"
- # echo " have to invoke './Configure linux32-s390x' *manually*."
- # if [ "$DRYRUN" = "false" -a -t -1 ]; then
- # echo " You have about 5 seconds to press Ctrl-C to abort."
- # (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- # fi
- #fi
- OUT="linux64-s390x"
- ;;
- x86_64-*-linux?)
- if $CC -dM -E -x c /dev/null 2>&1 | grep -q ILP32 > /dev/null; then
- OUT="linux-x32"
- else
- OUT="linux-x86_64"
- fi ;;
- *86-*-linux2)
- # On machines where the compiler understands -m32, prefer a
- # config target that uses it
- if $CC -m32 -E -x c /dev/null > /dev/null 2>&1; then
- OUT="linux-x86"
- else
- OUT="linux-elf"
- fi ;;
- *86-*-linux1) OUT="linux-aout" ;;
- *-*-linux?) OUT="linux-generic32" ;;
- sun4[uv]*-*-solaris2)
- OUT="solaris-sparcv9-$CC"
- ISA64=`(isainfo) 2>/dev/null | grep sparcv9`
- if [ "$ISA64" != "" -a "$KERNEL_BITS" = "" ]; then
- if [ "$CC" = "cc" -a $CCVER -ge 50 ]; then
- echo "WARNING! If you wish to build 64-bit library, then you have to"
- echo " invoke '$THERE/Configure solaris64-sparcv9-cc' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- elif [ "$CC" = "gcc" -a "$GCC_ARCH" = "-m64" ]; then
- # $GCC_ARCH denotes default ABI chosen by compiler driver
- # (first one found on the $PATH). I assume that user
- # expects certain consistency with the rest of his builds
- # and therefore switch over to 64-bit. <appro>
- OUT="solaris64-sparcv9-gcc"
- echo "WARNING! If you wish to build 32-bit library, then you have to"
- echo " invoke '$THERE/Configure solaris-sparcv9-gcc' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- elif [ "$GCC_ARCH" = "-m32" ]; then
- echo "NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI"
- echo " and wish to build 64-bit library, then you have to"
- echo " invoke '$THERE/Configure solaris64-sparcv9-gcc' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- fi
- fi
- if [ "$ISA64" != "" -a "$KERNEL_BITS" = "64" ]; then
- OUT="solaris64-sparcv9-$CC"
- fi
- ;;
- sun4m-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
- sun4d-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
- sun4*-*-solaris2) OUT="solaris-sparcv7-$CC" ;;
- *86*-*-solaris2)
- ISA64=`(isainfo) 2>/dev/null | grep amd64`
- if [ "$ISA64" != "" -a ${KERNEL_BITS:-64} -eq 64 ]; then
- OUT="solaris64-x86_64-$CC"
- else
- OUT="solaris-x86-$CC"
- if [ `uname -r | sed -e 's/5\.//'` -lt 10 ]; then
- options="$options no-sse2"
- fi
- fi
- ;;
- *-*-sunos4) OUT="sunos-$CC" ;;
-
- *86*-*-bsdi4) OUT="BSD-x86-elf"; options="$options no-sse2";
- __CNF_LDFLAGS="$__CNF_LDFLAGS -ldl" ;;
- alpha*-*-*bsd*) OUT="BSD-generic64";
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DL_ENDIAN" ;;
- powerpc64-*-*bsd*) OUT="BSD-generic64";
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
- sparc64-*-*bsd*) OUT="BSD-sparc64" ;;
- ia64-*-*bsd*) OUT="BSD-ia64" ;;
- x86_64-*-dragonfly*) OUT="BSD-x86_64" ;;
- amd64-*-*bsd*) OUT="BSD-x86_64" ;;
- *86*-*-*bsd*) # mimic ld behaviour when it's looking for libc...
- if [ -L /usr/lib/libc.so ]; then # [Free|Net]BSD
- libc=/usr/lib/libc.so
- else # OpenBSD
- # ld searches for highest libc.so.* and so do we
- libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
- fi
- case "`(file -L $libc) 2>/dev/null`" in
- *ELF*) OUT="BSD-x86-elf" ;;
- *) OUT="BSD-x86"; options="$options no-sse2" ;;
- esac ;;
- *-*-*bsd*) OUT="BSD-generic32" ;;
-
- x86_64-*-haiku) OUT="haiku-x86_64" ;;
- *-*-haiku) OUT="haiku-x86" ;;
-
- *-*-osf) OUT="osf1-alpha-cc" ;;
- *-*-tru64) OUT="tru64-alpha-cc" ;;
- *-*-[Uu]nix[Ww]are7)
- if [ "$CC" = "gcc" ]; then
- OUT="unixware-7-gcc" ; options="$options no-sse2"
- else
- OUT="unixware-7" ; options="$options no-sse2"
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -D__i386__"
- fi
- ;;
- *-*-[Uu]nix[Ww]are20*) OUT="unixware-2.0"; options="$options no-sse2 no-sha512" ;;
- *-*-[Uu]nix[Ww]are21*) OUT="unixware-2.1"; options="$options no-sse2 no-sha512" ;;
- *-*-vos)
- options="$options no-threads no-shared no-asm no-dso"
- EXE=".pm"
- OUT="vos-$CC" ;;
- BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
- *-hpux1*)
- if [ $CC = "gcc" -a $GCC_BITS = "64" ]; then
- OUT="hpux64-parisc2-gcc"
- fi
- [ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITS) 2>/dev/null`
- KERNEL_BITS=${KERNEL_BITS:-32}
- CPU_VERSION=`(getconf CPU_VERSION) 2>/dev/null`
- CPU_VERSION=${CPU_VERSION:-0}
- # See <sys/unistd.h> for further info on CPU_VERSION.
- if [ $CPU_VERSION -ge 768 ]; then # IA-64 CPU
- if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
- OUT="hpux64-ia64-cc"
- else
- OUT="hpux-ia64-cc"
- fi
- elif [ $CPU_VERSION -ge 532 ]; then # PA-RISC 2.x CPU
- # PA-RISC 2.0 is no longer supported as separate 32-bit
- # target. This is compensated for by run-time detection
- # in most critical assembly modules and taking advantage
- # of 2.0 architecture in PA-RISC 1.1 build.
- OUT=${OUT:-"hpux-parisc1_1-${CC}"}
- if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
- echo "WARNING! If you wish to build 64-bit library then you have to"
- echo " invoke '$THERE/Configure hpux64-parisc2-cc' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have about 5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- fi
- elif [ $CPU_VERSION -ge 528 ]; then # PA-RISC 1.1+ CPU
- OUT="hpux-parisc1_1-${CC}"
- elif [ $CPU_VERSION -ge 523 ]; then # PA-RISC 1.0 CPU
- OUT="hpux-parisc-${CC}"
- else # Motorola(?) CPU
- OUT="hpux-$CC"
- fi
- __CNF_CPPFLAGS="$__CNF_CPPFLAGS -D_REENTRANT" ;;
- *-hpux) OUT="hpux-parisc-$CC" ;;
- *-aix)
- [ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITMODE) 2>/dev/null`
- KERNEL_BITS=${KERNEL_BITS:-32}
- OBJECT_MODE=${OBJECT_MODE:-32}
- if [ "$CC" = "gcc" ]; then
- OUT="aix-gcc"
- if [ $OBJECT_MODE -eq 64 ]; then
- echo 'Your $OBJECT_MODE was found to be set to 64'
- OUT="aix64-gcc"
- fi
- elif [ $OBJECT_MODE -eq 64 ]; then
- echo 'Your $OBJECT_MODE was found to be set to 64'
- OUT="aix64-cc"
- else
- OUT="aix-cc"
- if [ $KERNEL_BITS -eq 64 ]; then
- echo "WARNING! If you wish to build 64-bit kit, then you have to"
- echo " invoke '$THERE/Configure aix64-cc' *manually*."
- if [ "$DRYRUN" = "false" -a -t 1 ]; then
- echo " You have ~5 seconds to press Ctrl-C to abort."
- (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
- fi
- fi
- fi
- if (lsattr -E -O -l `lsdev -c processor|awk '{print$1;exit}'` | grep -i powerpc) >/dev/null 2>&1; then
- : # this applies even to Power3 and later, as they return PowerPC_POWER[345]
- else
- options="$options no-asm"
- fi
- ;;
- # these are all covered by the catchall below
- i[3456]86-*-cygwin) OUT="Cygwin-x86" ;;
- *-*-cygwin) OUT="Cygwin-${MACHINE}" ;;
- x86-*-android|i?86-*-android) OUT="android-x86" ;;
- armv[7-9]*-*-android)
- OUT="android-armeabi"
- __CNF_CFLAGS="$__CNF_CFLAGS -march=armv7-a"
- __CNF_CXXFLAGS="$__CNF_CXXFLAGS -march=armv7-a";;
- arm*-*-android) OUT="android-armeabi" ;;
- *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
-esac
-
-# NB: This atalla support has been superseded by the ENGINE support
-# That contains its own header and definitions anyway. Support can
-# be enabled or disabled on any supported platform without external
-# headers, eg. by adding the "hw-atalla" switch to ./config or
-# perl Configure
-#
-# See whether we can compile Atalla support
-#if [ -f /usr/include/atasi.h ]
-#then
-# __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DATALLA"
-#fi
-
-if [ -n "$CONFIG_OPTIONS" ]; then
- options="$options $CONFIG_OPTIONS"
-fi
-
-# gcc < 2.8 does not support -march=ultrasparc
-if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
-then
- echo "WARNING! Falling down to 'solaris-sparcv8-gcc'."
- echo " Upgrade to gcc-2.8 or later."
- sleep 5
- OUT=solaris-sparcv8-gcc
-fi
-if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
-then
- echo "WARNING! Falling down to 'linux-sparcv8'."
- echo " Upgrade to gcc-2.8 or later."
- sleep 5
- OUT=linux-sparcv8
-fi
-
-case "$GUESSOS" in
- i386-*) options="$options 386" ;;
-esac
-
-if [ -z "$OUT" ]; then
- OUT="$CC"
-fi
-
-if [ ".$PERL" = . ] ; then
- for i in . `echo $PATH | sed 's/:/ /g'`; do
- if [ -f "$i/perl5$EXE" ] ; then
- PERL="$i/perl5$EXE"
- break;
- fi;
- done
-fi
-
-if [ ".$PERL" = . ] ; then
- for i in . `echo $PATH | sed 's/:/ /g'`; do
- if [ -f "$i/perl$EXE" ] ; then
- if "$i/perl$EXE" -e 'exit($]<5.0)'; then
- PERL="$i/perl$EXE"
- break;
- fi;
- fi;
- done
-fi
-
-if [ ".$PERL" = . ] ; then
- echo "You need Perl 5."
- exit 1
-fi
-
-# run Configure to check to see if we need to specify the
-# compiler for the platform ... in which case we add it on
-# the end ... otherwise we leave it off
-
-$PERL $THERE/Configure LIST | grep "$OUT-$CC" > /dev/null
-if [ $? = "0" ]; then
- OUT="$OUT-$CC"
-fi
-
-OUT="$OUT"
-
-if [ "$OUT" = "darwin64-x86_64-cc" ]; then
- echo "WARNING! If you wish to build 32-bit libraries, then you have to"
- echo " invoke 'KERNEL_BITS=32 $THERE/config $options'."
-fi
-
-if $PERL $THERE/Configure LIST | grep "$OUT" > /dev/null; then
- if [ "$VERBOSE" = "true" ]; then
- echo /usr/bin/env \
- __CNF_CPPDEFINES="'$__CNF_CPPDEFINES'" \
- __CNF_CPPINCLUDES="'$__CNF_CPPINCLUDES'" \
- __CNF_CPPFLAGS="'$__CNF_CPPFLAGS'" \
- __CNF_CFLAGS="'$__CNF_CFLAGS'" \
- __CNF_CXXFLAGS="'$__CNF_CXXFLAGS'" \
- __CNF_LDFLAGS="'$__CNF_LDFLAGS'" \
- __CNF_LDLIBS="'$__CNF_LDLIBS'" \
- $PERL $THERE/Configure $OUT $options
- fi
- if [ "$DRYRUN" = "false" ]; then
- # eval to make sure quoted options, possibly with spaces inside,
- # are treated right
- eval /usr/bin/env \
- __CNF_CPPDEFINES="'$__CNF_CPPDEFINES'" \
- __CNF_CPPINCLUDES="'$__CNF_CPPINCLUDES'" \
- __CNF_CPPFLAGS="'$__CNF_CPPFLAGS'" \
- __CNF_CFLAGS="'$__CNF_CFLAGS'" \
- __CNF_CXXFLAGS="'$__CNF_CXXFLAGS'" \
- __CNF_LDFLAGS="'$__CNF_LDFLAGS'" \
- __CNF_LDLIBS="'$__CNF_LDLIBS'" \
- $PERL $THERE/Configure $OUT $options
- fi
-else
- echo "This system ($OUT) is not supported. See file INSTALL for details."
- exit 1
-fi
-
-# Do not add anothing from here on, so we don't lose the Configure exit code
-)
+use lib "util/perl";
+use OpenSSL::config;
+OpenSSL::config::main();
diff --git a/util/perl/OpenSSL/config.pm b/util/perl/OpenSSL/config.pm
new file mode 100755
index 0000000000..c1bbd32fbf
--- /dev/null
+++ b/util/perl/OpenSSL/config.pm
@@ -0,0 +1,922 @@
+#! /usr/bin/env perl
+# Copyright 1998-2020 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the Apache License 2.0 (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+# Determine the operating system and run ./Configure. Far descendant from
+# Apache's minarch and GuessOS.
+
+package OpenSSL::config;
+
+use strict;
+use warnings;
+use Getopt::Std;
+use File::Basename;
+
+# These control our behavior.
+my $DRYRUN;
+my $VERBOSE;
+my $WAIT = 1;
+my $WHERE = dirname($0);
+
+# Machine type, etc., used to determine the platform
+my $MACHINE;
+my $RELEASE;
+my $SYSTEM;
+my $VERSION;
+my $CCVER;
+my $GCCVER;
+my $GCC_BITS;
+my $GCC_ARCH;
+
+# Some environment variables; they will affect Configure
+my $PERL = $ENV{PERL} // $^X // 'perl';
+my $CONFIG_OPTIONS = $ENV{CONFIG_OPTIONS} // '';
+my $CC = $ENV{CC} // 'cc';
+my $CROSS_COMPILE = $ENV{CROSS_COMPILE} // "";
+my $KERNEL_BITS = $ENV{KERNEL_BITS} // '';
+
+# This is what we will set as the target for calling Configure.
+my $options = '';
+
+# Environment that will be passed to Configure
+my $__CNF_CPPDEFINES = '';
+my $__CNF_CPPINCLUDES = '';
+my $__CNF_CPPFLAGS = '';
+my $__CNF_CFLAGS = '';
+my $__CNF_CXXFLAGS = '';
+my $__CNF_LDFLAGS = '';
+my $__CNF_LDLIBS = '';
+
+# Pattern matches against "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}"
+my $simple_guess_patterns = [
+ [ 'A\/UX:', 'm68k-apple-aux3' ],
+ [ 'AIX:[3-9]:4:', '${MACHINE}-ibm-aix' ],
+ [ 'AIX:.*:[5-9]:', '${MACHINE}-ibm-aix' ],
+ [ 'AIX:', '${MACHINE}-ibm-aix3' ],
+ [ 'HI-UX:', '${MACHINE}-hi-hiux' ],
+ [ 'IRIX:6.', 'mips3-sgi-irix' ],
+ [ 'IRIX64:', 'mips4-sgi-irix64' ],
+ [ 'Linux:[2-9]', '${MACHINE}-whatever-linux2' ],
+ [ 'Linux:1', '${MACHINE}-whatever-linux1' ],
+ [ 'GNU', 'hurd-x86' ],
+ [ 'LynxOS:', '${MACHINE}-lynx-lynxos' ],
+ # BSD/OS always says 386
+ [ 'BSD\/OS:4.*', 'i486-whatever-bsdi4' ],
+ [ 'BSD\/386:.*|BSD\/OS:', '${MACHINE}-whatever-bsdi' ],
+ [ 'DragonFly:', '${MACHINE}-whatever-dragonfly' ],
+ [ 'FreeBSD:', '${MACHINE}-whatever-freebsd' ],
+ [ 'Haiku:', '${MACHINE}-whatever-haiku' ],
+ [ 'NetBSD:', '${MACHINE}-whatever-netbsd' ],
+ [ 'OpenBSD:', '${MACHINE}-whatever-openbsd' ],
+ [ 'OpenUNIX:', '${MACHINE}-unknown-OpenUNIX${VERSION}' ],
+ [ 'Paragon.*:', 'i860-intel-osf1' ],
+ [ 'Rhapsody:', 'ppc-apple-rhapsody' ],
+ [ 'SunOS:5.', '${MACHINE}-whatever-solaris2' ],
+ [ 'SunOS:', '${MACHINE}-sun-sunos4' ],
+ [ 'UNIX_System_V:4.*:', '${MACHINE}-whatever-sysv4' ],
+ [ 'VOS:.*:.*:i786', 'i386-stratus-vos' ],
+ [ 'VOS:.*:.*:', 'hppa1.1-stratus-vos' ],
+ [ '.*:4.*:R4.*:m88k', '${MACHINE}-whatever-sysv4' ],
+ [ 'DYNIX\/ptx:4.*:', '${MACHINE}-whatever-sysv4' ],
+ [ ':4.0:3.0:3[34]', 'i486-ncr-sysv4' ],
+ [ 'ULTRIX:', '${MACHINE}-unknown-ultrix' ],
+ [ 'POSIX-BC', 'BS2000-siemens-sysv4' ],
+ [ 'machten:', '${MACHINE}-tenon-${SYSTEM}' ],
+ [ 'library:', '${MACHINE}-ncr-sysv4' ],
+ [ 'ConvexOS:.*:11.0:', '${MACHINE}-v11-${SYSTEM}' ],
+ [ 'MINGW64.*:.*x86_64', '${MACHINE}-whatever-mingw64' ],
+ [ 'MINGW', '${MACHINE}-whatever-mingw' ],
+ [ 'CYGWIN', '${MACHINE}-pc-cygwin' ],
+ [ 'vxworks', '${MACHINE}-whatever-vxworks' ],
+ [ 'Darwin:.*Power', 'ppc-apple-darwin' ],
+ [ 'Darwin:.*x86_64', 'x86_64-apple-darwin' ],
+ [ 'Darwin:', 'i686-apple-darwin' ],
+];
+
+# More complex cases that require run-time code.
+my $complex_sys_list = [
+ [ 'HP-UX:', sub {
+ my $HPUXVER = $RELEASE;
+ $HPUXVER = s/[^.]*.[0B]*//;
+ # HPUX 10 and 11 targets are unified
+ return "${MACHINE}-hp-hpux1x" if $HPUXVER =~ m@1[0-9]@;
+ return "${MACHINE}-hp-hpux";
+ } ],
+
+ [ 'BSD/386:.*:.*:.*486.*|BSD/OS:.*:.*:.*:.*486', sub {
+ my $BSDVAR = `/sbin/sysctl -n hw.model`;
+ return "i586-whatever-bsdi" if $BSDVAR =~ m@Pentium@;
+ return "i386-whatever-bsdi";
+ } ],
+
+ [ 'FreeBSD:.*:.*:.*386', sub {
+ my $VERS = $RELEASE;
+ $VERS =~ s/[-(].*//;
+ my $MACH = `sysctl -n hw.model`;
+ $MACH = "i386" if $MACH =~ m@386@;
+ $MACH = "i486" if $MACH =~ m@486@;
+ $MACH = "i686" if $MACH =~ m@Pentium II@;
+ $MACH = "i586" if $MACH =~ m@Pentium@;
+ $MACH = "$MACHINE" if $MACH !~ /i.86/;
+ my $ARCH = 'whatever';
+ $ARCH = "pc" if $MACH =~ m@i[0-9]86@;
+ return "${MACH}-${ARCH}-freebsd${VERS}";
+ } ],
+
+ [ 'NetBSD:.*:.*:.*386', sub {
+ my $hw = `/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model`;
+ $hw =~ s@.*(.)86-class.*@i${1}86@;
+ return "${hw}-whatever-netbsd";
+ } ],
+
+ [ 'OSF1:.*:.*:.*alpha', sub {
+ my $OSFMAJOR = $RELEASE;
+ $OSFMAJOR =~ 's/^V([0-9]*)\..*$/\1/';
+ return "${MACHINE}-dec-tru64" if $OSFMAJOR =~ m@[45]@;
+ return "${MACHINE}-dec-osf";
+ } ],
+];
+
+
+# Run a command, return true if exit zero else false.
+# Multiple args are glued together into a pipeline.
+# Name comes from OpenSSL tests, often written as "ok(run(...."
+sub okrun {
+ my $command = join(' | ', @_);
+ my $status = system($command) >> 8;
+ return $status == 0;
+}
+
+# Give user a chance to abort/interrupt if interactive if interactive.
+sub maybe_abort {
+ if ( $WAIT && -t 1 ) {
+ eval {
+ local $SIG{ALRM} = sub { die "Timeout"; };
+ local $| = 1;
+ alarm(5);
+ print "You have about five seconds to abort: ";
+ my $ignored = <STDIN>;
+ alarm(0);
+ };
+ print "\n" if $@ =~ /Timeout/;
+ }
+}
+
+# Parse options.
+sub call_getopt {
+ our($opt_d);
+ our($opt_h);
+ our($opt_t);
+ our($opt_v);
+ our($opt_w);
+ getopts("dhtvw");
+
+ # Building on windows needs a VisualC target.
+ my $iswin = $^O eq 'MSWin32';
+ my $foundvc = 0;
+
+ if ( $opt_h ) {
+ print <<'EOF';
+Usage: config [options] [args...]
+ -d Build with debugging when possible.
+ -t Test mode, do not run the Configure perl script.
+ -v Verbose mode, show the exact Configure call that is being made.
+ -w Do not wait after displaying any warnings.
+ -h This help.
+All other arguments are passed to the Configure script.
+See INSTALL for instructions.
+EOF
+ exit;
+ }
+ # All other parameters are passed to Configure
+ foreach my $opt ( @ARGV ) {
+ # Could make the VC- part optional, but that might cause
+ # confusion.
+ if ( $iswin && $opt =~ /^VC-(WIN32|WIN64A|WIN64I|CE)$/i ) {
+ $opt = tr/a-z/A-Z/;
+ $opt = "VC-$opt" unless $opt =~ /^VC-/;
+ $foundvc = 1;
+ }
+ $options .= " $opt";
+ }
+ if ( $iswin && !$foundvc ) {
+ print <<EOF;
+WARNING: Did not find VisualC target. See INSTALL for details.
+EOF
+ maybe_abort();
+ }
+ $options = " --debug" if $opt_d;
+ $DRYRUN = $opt_t;
+ $VERBOSE = $opt_v || $opt_t;
+ $WAIT = 0 if $opt_w;
+}
+
+# call uname with specified arg, return result.
+sub uname {
+ my $arg = shift;
+ open UNAME, "uname $arg 2>/dev/null|" or return "unknown";
+ my $line = <UNAME>;
+ close UNAME;
+ $line =~ s/[\r\n]+$//;
+ return "unknown" if $line eq '';
+ return $line;
+}
+
+# Set machine type, release, etc., variables.
+sub get_machine_etc {
+ $MACHINE = $ENV{MACHINE} // uname('-m');
+ $RELEASE = $ENV{RELEASE} // uname('-r');
+ $SYSTEM = $ENV{SYSTEM} // uname("-s");
+ $VERSION = uname('-v');
+}
+
+# Expand variable references in a string.
+sub expand {
+ my $var = shift;
+ $var =~ s/\$\{MACHINE\}/${MACHINE}/;
+ return $var;
+}
+
+# Add no-xxx if someone removed a crypto algorithm directory.
+# TODO: This should be moved to Configure.
+my @cryptodir = (
+ 'aes', 'aria', 'bf', 'camellia', 'cast', 'des', 'dh', 'dsa', 'ec', 'hmac',
+ 'idea', 'md2', 'md5', 'mdc2', 'rc2', 'rc4', 'rc5', 'ripemd', 'rsa',
+ 'seed', 'sha', 'sm2', 'sm3', 'sm4'
+);
+sub remove_removed_crypto_directories {
+ foreach my $d ( @cryptodir ) {
+ $options .= " no-$d" if ! -d "$WHERE/crypto/$d";
+ }
+}
+
+# Look for ISC/SCO with its unique uname program
+sub is_sco_uname {
+ open UNAME, "uname -X 2>/dev/null|" or return '';
+ my $line = "";
+ while ( <UNAME> ) {
+ chop;
+ $line = $_ if m@^Release@;
+ }
+ close UNAME;
+ return "" if $line eq '';
+ my @fields = split($line);
+ return $fields[2];
+}
+
+sub get_sco_type {
+ my $REL = shift;
+
+ if ( -f "/etc/kconfig" ) {
+ return "${MACHINE}-whatever-isc4" if $REL eq '4.0' || $REL eq '4.1';
+ } else {
+ return "whatever-whatever-sco3" if $REL eq '3.2v4.2';
+ return "whatever-whatever-sco5" if $REL =~ m@3\.2v5\.0.*@;
+ if ( $REL eq "4.2MP" ) {
+ return "whatever-whatever-unixware20" if $VERSION =~ m@2\.0.*@;
+ return "whatever-whatever-unixware21" if $VERSION =~ m@2\.1.*@;
+ return "whatever-whatever-unixware2" if $VERSION =~ m@2.*@;
+ }
+ return "whatever-whatever-unixware1" if $REL eq "4.2";
+ if ( $REL =~ m@5.*@ ) {
+ # We hardcode i586 in place of ${MACHINE} for the following
+ # reason: even though Pentium is minimum requirement for
+ # platforms in question, ${MACHINE} gets always assigned to
+ # i386. This means i386 gets passed to Configure, which will
+ # cause bad assembler code to be generated.
+ return "i586-sco-unixware7" if $VERSION =~ m@[678].*@;
+ }
+ }
+}
+
+# Return the cputype-vendor-osversion
+sub guess_system {
+ # Special-cases for ISC, SCO, Unixware
+ my $REL = is_sco_uname();
+ if ( $REL ne "" ) {
+ my $result = get_sco_type($REL);
+ return expand($result) if $result ne '';
+ }
+
+ # Now pattern-match
+ my $sys = "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}";
+
+ # Simple cases
+ foreach my $tuple ( @$simple_guess_patterns ) {
+ my $pat = @$tuple[0];
+ # Trailing $ omitted on purpose.
+ next if $sys !~ /^$pat/;
+ my $result = @$tuple[1];
+ return expand($result);
+ }
+
+ # Complex cases.
+ foreach my $tuple ( @$complex_sys_list ) {
+ my $pat = @$tuple[0];
+ # Trailing $ omitted on purpose.
+ next if $sys !~ /^$pat/;
+ my $ref = @$tuple[1];
+ my $result = &$ref;
+ return expand($result);
+ }
+
+ # Oh well.
+ return "${MACHINE}-whatever-${SYSTEM}";
+}
+
+# Figure out CC, GCCVAR, etc.
+sub determine_compiler_settings {
+ if ( "$CROSS_COMPILE$CC" eq '' ) {
+ $GCCVER = `gcc -dumpversion 2>/dev/null`;
+ if ( $GCCVER ne "" ) {
+ # Strip off whatever prefix egcs prepends the number with.
+ # Hopefully, this will work for any future prefixes as well.
+ $GCCVER =~ s/^[a-zA-Z]*\-//;
+ # Since gcc 3.1 gcc --version behaviour has changed, but
+ # -dumpversion gives us what we want though, so use that.
+ # We only want the major and minor version numbers. The
+ # pattern is deliberate; single digit before and after first
+ # dot, e.g. 2.95.1 gives 29
+ $GCCVER =~ s/([0-9])\.([0-9]).*/$1$2/;
+ $GCCVER = int($GCCVER);
+ $CC = 'gcc';
+ }
+ }
+
+ $GCCVER //= 0;
+
+ if ( $SYSTEM eq "HP-UX" ) {
+ # By default gcc is a ILP32 compiler (with long long == 64).
+ $GCC_BITS = "32";
+ if ( $GCCVER >= 30 ) {
+ # PA64 support only came in with gcc 3.0.x.
+ # We check if the preprocessor symbol __LP64__ is defined.
+ if ( okrun('echo __LP64__',
+ 'gcc -v -E -x c - 2>/dev/null',
+ 'grep "^__LP64__" 2>&1 >/dev/null') ) {
+ # __LP64__ has slipped through, it therefore is not defined
+ } else {
+ $GCC_BITS = '64';
+ }
+ }
+ return;
+ }
+
+ if ( ${SYSTEM} eq 'AIX' ) {
+ # favor vendor cc over gcc
+ if ( okrun('(cc) 2>&1',
+ 'grep -iv "not found" >/dev/null') ) {
+ $CC = 'cc';
+ }
+ return;
+ }
+
+ if ( $SYSTEM eq "SunOS" ) {
+ if ( $GCCVER >= 30 ) {
+ # 64-bit ABI isn't officially supported in gcc 3.0, but seems
+ # to be working; at the very least 'make test' passes.
+ if ( okrun('gcc -v -E -x c /dev/null 2>&1',
+ 'grep __arch64__ >/dev/null') ) {
+ $GCC_ARCH = "-m64"
+ } else {
+ $GCC_ARCH = "-m32"
+ }
+ }
+ # check for WorkShop C, expected output is "cc: blah-blah C x.x"
+ $CCVER = `(cc -V 2>&1) 2>/dev/null | egrep -e '^cc: .* C [0-9]\.[0-9]'`;
+ $CCVER =~ s/.* C \([0-9]\)\.\([0-9]\).*/$1$2/;
+ $CCVER //= 0;
+ if ( $MACHINE ne 'i86pc' && $CCVER > 40 ) {
+ # overrides gcc!!!
+ $CC = 'cc';
+ if ( $CCVER == 50 ) {
+ print <<'EOF';
+WARNING! Found WorkShop C 5.0.
+ Make sure you have patch #107357-01 or later applied.
+EOF
+ maybe_abort();
+ }
+ }
+ }
+}
+
+# Map GUESSOS into OpenSSL terminology. Also sets some of variables
+# like $options, $__CNX_xxx. And uses some, like the KERNEL flags
+# and MACHINE.
+# It would be nice to fix this so that this weren't necessary. :( XXX
+sub map_guess {
+ my $GUESSOS = shift;
+ my $OUT;
+ return 'uClinux-dist64' if $GUESSOS =~ 'uClinux.*64.*';
+ return 'uClinux-dist' if $GUESSOS =~ 'uClinux.*';
+ return "irix-mips3-$CC" if $GUESSOS =~ 'mips3-sgi-irix';
+ if ( $GUESSOS =~ 'mips4-sgi-irix64' ) {
+ print <<EOF;
+WARNING! To build 64-bit package, do this:
+ $WHERE/Configure irix64-mips4-$CC
+EOF
+ maybe_abort();
+ return "irix-mips3-$CC";
+ }
+ return "rhapsody-ppc-cc" if $GUESSOS =~ 'ppc-apple-rhapsody';
+ if ( $GUESSOS =~ 'ppc-apple-darwin' ) {
+ my $ISA64 = `sysctl -n hw.optional.64bitops 2>/dev/null`;
+ if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
+ print <<EOF;
+WARNING! To build 64-bit package, do this:
+ $WHERE/Configure darwin64-ppc-cc
+EOF
+ maybe_abort();
+ }
+ return "darwin64-ppc-cc" if $ISA64 == 1 && $KERNEL_BITS eq '64';
+ return "darwin-ppc-cc";
+ }
+ if ( $GUESSOS =~ 'i.86-apple-darwin' ) {
+ my $ISA64 = `sysctl -n hw.optional.x86_64 2>/dev/null`;
+ if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
+ print <<EOF;
+WARNING! To build 64-bit package, do this:
+ KERNEL_BITS=64 $WHERE/config $options
+EOF
+ maybe_abort();
+ }
+ return "darwin64-x86_64-cc" if $ISA64 == 1 && $KERNEL_BITS eq '64';
+ return "darwin-i386-cc";
+ }
+ if ( $GUESSOS =~ 'x86_64-apple-darwin' ) {
+ return "darwin-i386-cc" if $KERNEL_BITS eq '32';
+
+ print <<EOF;
+WARNING! To build 32-bit package, do this:
+ KERNEL_BITS=32 $WHERE/config $options
+EOF
+ maybe_abort();
+ return "darwin64-x86_64-cc"
+ }
+ if ( $GUESSOS =~ 'armv6+7-.*-iphoneos' ) {
+ $__CNF_CFLAGS .= " -arch armv6 -arch armv7";
+ $__CNF_CXXFLAGS .= " -arch armv6 -arch armv7";
+ return "iphoneos-cross";
+ }
+ if ( $GUESSOS =~ '.*-.*-iphoneos' ) {
+ $__CNF_CFLAGS .= " -arch ${MACHINE}";
+ $__CNF_CXXFLAGS .= " -arch ${MACHINE}";
+ return "iphoneos-cross";
+ }
+ return "ios64-cross" if $GUESSOS =~ 'arm64-.*-iphoneos|.*-.*-ios64';
+ if ( $GUESSOS =~ 'alpha-.*-linux2' ) {
+ my $ISA = `awk '/cpu model/{print \$4;exit(0);}' /proc/cpuinfo`;
+ $ISA //= 'generic';
+ if ( $CC eq "gcc" ) {
+ if ( $ISA =~ 'EV5|EV45' ) {
+ $__CNF_CFLAGS .= " -mcpu=ev5";
+ $__CNF_CFLAGS .= " -mcpu=ev5";
+ } elsif ( $ISA =~ 'EV56|PCA56' ) {
+ $__CNF_CFLAGS .= " -mcpu=ev56";
+ $__CNF_CXXFLAGS .= " -mcpu=ev56";
+ } else {
+ $__CNF_CFLAGS .= "-mcpu=ev6";
+ $__CNF_CXXFLAGS .= "-mcpu=ev6";
+ }
+ }
+ return "linux-alpha-$CC";
+ }
+ if ( $GUESSOS =~ 'ppc64-.*-linux2' ) {
+ if ( $KERNEL_BITS eq '' ) {
+ print <<EOF;
+WARNING! To build 64-bit package, do this:
+ $WHERE/Configure linux-ppc64
+EOF
+ maybe_abort();
+ }
+ return "linux-ppc64" if $KERNEL_BITS eq '64';
+ if (!okrun('echo __LP64__',
+ 'gcc -E -x c - 2>/dev/null',
+ 'grep "^__LP64__" 2>&1 >/dev/null') ) {
+ $__CNF_CFLAGS .= " -m32";
+ $__CNF_CXXFLAGS .= " -m32";
+ }
+ return "linux-ppc";
+ }
+ return "linux-ppc64le" if $GUESSOS =~ 'ppc64le-.*-linux2';
+ return "linux-ppc" if $GUESSOS =~ 'ppc-.*-linux2';
+ if ( $GUESSOS =~ 'mips64.*-*-linux2' ) {
+ print <<EOF;
+WARNING! To build 64-bit package, do this:
+ $WHERE/Configure linux64-mips64
+EOF
+ maybe_abort();
+ return "linux-mips64";
+ }
+ return "linux-mips32" if $GUESSOS =~ 'mips.*-.*-linux2';
+ return "vxworks-ppc60x" if $GUESSOS =~ 'ppc60x-.*-vxworks*';
+ return "vxworks-ppcgen" if $GUESSOS =~ 'ppcgen-.*-vxworks*';
+ return "vxworks-pentium" if $GUESSOS =~ 'pentium-.*-vxworks*';
+ return "vxworks-simlinux" if $GUESSOS =~ 'simlinux-.*-vxworks*';
+ return "vxworks-mips" if $GUESSOS =~ 'mips-.*-vxworks*';
+ return "linux-generic64 -DL_ENDIAN" if $GUESSOS =~ 'e2k-.*-linux*';
+ return "linux-ia64" if $GUESSOS =~ 'ia64-.*-linux.';
+ if ( $GUESSOS =~ 'sparc64-.*-linux2' ) {
+ print <<EOF;
+WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI and you
+ want to build 64-bit library, do this:
+ $WHERE/Configure linux64-sparcv9
+EOF
+ maybe_abort();
+ return "linux-sparcv9";
+ }
+ if ( $GUESSOS =~ 'sparc-.*-linux2' ) {
+ my $KARCH = `awk '/^type/{print \$3;exit(0);}' /proc/cpuinfo`;
+ $KARCH //= "sun4";
+ return "linux-sparcv9" if $KARCH =~ 'sun4u*';
+ return "linux-sparcv8" if $KARCH =~ 'sun4[md]';
+ $__CNF_CPPFLAGS .= " -DB_ENDIAN";
+ return "linux-generic32";
+ }
+ if ( $GUESSOS =~ 'parisc.*-.*-linux2' ) {
+ # 64-bit builds under parisc64 linux are not supported and
+ # compiler is expected to generate 32-bit objects...
+ my $CPUARCH =
+ `awk '/cpu family/{print substr(\$5,1,3); exit(0);}' /proc/cpuinfo`;
+ my $CPUSCHEDULE =
+ `awk '/^cpu.[ ]*: PA/{print substr(\$3,3); exit(0);}' /proc/cpuinfo`;
+ # TODO XXX Model transformations
+ # 0. CPU Architecture for the 1.1 processor has letter suffixes. We
+ # strip that off assuming no further arch. identification will ever
+ # be used by GCC.
+ # 1. I'm most concerned about whether is a 7300LC is closer to a 7100
+ # versus a 7100LC.
+ # 2. The variant 64-bit processors cause concern should GCC support
+ # explicit schedulers for these chips in the future.
+ # PA7300LC -> 7100LC (1.1)
+ # PA8200 -> 8000 (2.0)
+ # PA8500 -> 8000 (2.0)
+ # PA8600 -> 8000 (2.0)
+ $CPUSCHEDULE =~ s/7300LC/7100LC/;
+ $CPUSCHEDULE =~ s/8.00/8000/;
+ # Finish Model transformations
+ $__CNF_CPPFLAGS .= " -DB_ENDIAN";
+ $__CNF_CFLAGS .= " -mschedule=$CPUSCHEDULE -march=$CPUARCH";
+ $__CNF_CXXFLAGS .= " -mschedule=$CPUSCHEDULE -march=$CPUARCH";
+ return "linux-generic32";
+ }
+ return "linux-generic32" if $GUESSOS =~ 'armv[1-3].*-.*-linux2';
+ if ( $GUESSOS =~ 'armv[7-9].*-.*-linux2' ) {
+ $__CNF_CFLAGS .= " -march=armv7-a";
+ $__CNF_CXXFLAGS .= " -march=armv7-a";
+ return "linux-armv4";
+ }
+ return "linux-armv4" if $GUESSOS =~ 'arm.*-.*-linux2';
+ return "linux-aarch64" if $GUESSOS =~ 'aarch64-.*-linux2';
+ if ( $GUESSOS =~ 'sh.*b-.*-linux2' ) {
+ $__CNF_CPPFLAGS .= " -DB_ENDIAN";
+ return "linux-generic32";
+ }
+ if ( $GUESSOS =~ 'sh.*-.*-linux2' ) {
+ $__CNF_CPPFLAGS .= " -DL_ENDIAN";
+ return "linux-generic32";
+ }
+ if ( $GUESSOS =~ 'm68k.*-.*-linux2' || $GUESSOS =~ 's390-.*-linux2' ) {
+ $__CNF_CPPFLAGS .= " -DB_ENDIAN";
+ return "linux-generic32";
+ }
+ if ( $GUESSOS =~ 's390x-.*-linux2' ) {
+ # Disabled until a glibc bug is fixed; see Configure.
+ if (0 || okrun(
+ 'egrep -e \'^features.* highgprs\' /proc/cpuinfo >/dev/null') )
+ {
+ print <<EOF;
+WARNING! To build "highgprs" 32-bit package, do this:
+ $WHERE/Configure linux32-s390x
+EOF
+ maybe_abort();
+ }
+ return "linux64-s390x";
+ }
+ if ( $GUESSOS =~ 'x86_64-.*-linux.' ) {
+ return "linux-x32"
+ if okrun("$CC -dM -E -x c /dev/null 2>&1",
+ 'grep -q ILP32 >/dev/null');
+ return "linux-x86_64";
+ }
+ if ( $GUESSOS =~ '.*86-.*-linux2' ) {
+ # On machines where the compiler understands -m32, prefer a
+ # config target that uses it
+ return "linux-x86"
+ if okrun("$CC -m32 -E -x c /dev/null >/dev/null 2>&1");
+ return "linux-elf"
+ }
+ return "linux-aout" if $GUESSOS =~ '.*86-.*-linux1';
+ return "linux-generic32" if $GUESSOS =~ '.*-.*-linux.';
+ if ( $GUESSOS =~ 'sun4[uv].*-.*-solaris2' ) {
+ my $ISA64 = `isainfo 2>/dev/null | grep sparcv9`;
+ if ( $ISA64 ne "" && $KERNEL_BITS eq '' ) {
+ if ( $CC eq "cc" && $CCVER >= 50 ) {
+ print <<EOF;
+WARNING! To build 64-bit package, do this:
+ $WHERE/Configure solaris64-sparcv9-cc
+EOF
+ maybe_abort();
+ } elsif ( $CC eq "gcc" && $GCC_ARCH eq "-m64" ) {
+ # $GCC_ARCH denotes default ABI chosen by compiler driver
+ # (first one found on the $PATH). I assume that user
+ # expects certain consistency with the rest of his builds
+ # and therefore switch over to 64-bit. <appro>
+ print <<EOF;
+WARNING! To build 32-bit package, do this:
+ $WHERE/Configure solaris-sparcv9-gcc
+EOF
+ maybe_abort();
+ return "solaris64-sparcv9-gcc";
+ } elsif ( $GCC_ARCH eq "-m32" ) {
+ print <<EOF;
+NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI and you wish
+ to build 64-bit library, do this:
+ $WHERE/Configure solaris64-sparcv9-gcc
+EOF
+ maybe_abort();
+ }
+ }
+ return "solaris64-sparcv9-$CC" if $ISA64 ne "" && $KERNEL_BITS eq '64';
+ return "solaris-sparcv9-$CC";
+ }
+ return "solaris-sparcv8-$CC" if $GUESSOS =~ 'sun4m-.*-solaris2';
+ return "solaris-sparcv8-$CC" if $GUESSOS =~ 'sun4d-.*-solaris2';
+ return "solaris-sparcv7-$CC" if $GUESSOS =~ 'sun4.*-.*-solaris2';
+ if ( $GUESSOS =~ '.*86.*-.*-solaris2' ) {
+ my $ISA64 = `isainfo 2>/dev/null | grep amd64`;
+ my $KB = $KERNEL_BITS // '64';
+ return "solaris64-x86_64-$CC" if $ISA64 ne "" && $KB eq '64';
+ my $REL = uname('-r');
+ $REL =~ s/5\.//;
+ $options .= " no-sse2" if int($REL) < 10;
+ return "solaris-x86-$CC";
+ }
+ return "sunos-$CC" if $GUESSOS =~ '.*-.*-sunos4';
+ if ( $GUESSOS =~ '.*86.*-.*-bsdi4' ) {
+ $options .= " no-sse2";
+ $__CNF_LDFLAGS .= " -ldl";
+ return "BSD-x86-elf";
+ }
+ if ( $GUESSOS =~ 'alpha.*-.*-.*bsd.*' ) {
+ $__CNF_CPPFLAGS .= " -DL_ENDIAN";
+ return "BSD-generic64";
+ }
+ if ( $GUESSOS =~ 'powerpc64-.*-.*bsd.*' ) {
+ $__CNF_CPPFLAGS .= " -DB_ENDIAN";
+ return "BSD-generic64";
+ }
+ return "BSD-sparc64" if $GUESSOS =~ 'sparc64-.*-.*bsd.*';
+ return "BSD-ia64" if $GUESSOS =~ 'ia64-.*-.*bsd.*';
+ return "BSD-x86_64" if $GUESSOS =~ 'x86_64-.*-dragonfly.*';
+ return "BSD-x86_64" if $GUESSOS =~ 'amd64-.*-.*bsd.*';
+ if ( $GUESSOS =~ '.*86.*-.*-.*bsd.*' ) {
+ # mimic ld behaviour when it's looking for libc...
+ my $libc;
+ if ( -l "/usr/lib/libc.so" ) {
+ $libc = "/usr/lib/libc.so";
+ } else {
+ # ld searches for highest libc.so.* and so do we
+ $libc =
+ `(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`;
+ }
+ my $what = `file -L $libc 2>/dev/null`;
+ return "BSD-x86-elf" if $what =~ /ELF/;
+ $options .= " no-sse2";
+ return "BSD-x86";
+ }
+ return "BSD-generic32" if $GUESSOS =~ '.*-.*-.*bsd.*';
+ return "haiku-x86_64" if $GUESSOS =~ 'x86_64-.*-haiku';
+ return "haiku-x86" if $GUESSOS =~ '.*-.*-haiku';
+ return "osf1-alpha-cc" if $GUESSOS =~ '.*-.*-osf';
+ return "tru64-alpha-cc" if $GUESSOS =~ '.*-.*-tru64';
+ if ( $GUESSOS =~ '.*-.*-[Uu]nix[Ww]are7' ) {
+ $options .= "no-sse2";
+ return "unixware-7-gcc" if $CC eq "gcc";
+ $__CNF_CPPFLAGS .= " -D__i386__";
+ return "unixware-7";
+ }
+ if ( $GUESSOS =~ '.*-.*-[Uu]nix[Ww]are20*' ) {
+ $options .= " no-sse2 no-sha512";
+ return "unixware-2.0";
+ }
+ if ( $GUESSOS =~ '.*-.*-[Uu]nix[Ww]are21*' ) {
+ $options .= " no-sse2 no-sha512";
+ return "unixware-2.1";
+ }
+ if ( $GUESSOS =~ '.*-.*-vos' ) {
+ $options .= " no-threads no-shared no-asm no-dso";
+ return "vos-$CC";
+ }
+ return "BS2000-OSD" if $GUESSOS =~ 'BS2000-siemens-sysv4';
+ return "Cygwin-x86" if $GUESSOS =~ 'i[3456]86-.*-cygwin';
+ return "Cygwin-${MACHINE}" if $GUESSOS =~ '.*-.*-cygwin';
+ return "android-x86" if $GUESSOS =~ 'x86-.*-android|i.86-.*-android';
+ if ( $GUESSOS =~ 'armv[7-9].*-.*-android' ) {
+ $__CNF_CFLAGS .= " -march=armv7-a";
+ $__CNF_CXXFLAGS .= " -march=armv7-a";
+ return "android-armeabi";
+ }
+ return "android-armeabi" if $GUESSOS =~ 'arm.*-.*-android';
+ if ( $GUESSOS =~ '.*-hpux1.*' ) {
+ $OUT = "hpux64-parisc2-gcc" if $CC = "gcc" && $GCC_BITS eq '64';
+ $KERNEL_BITS //= `getconf KERNEL_BITS 2>/dev/null` // '32';
+ # See <sys/unistd.h> for further info on CPU_VERSION.
+ my $CPU_VERSION = `getconf CPU_VERSION 2>/dev/null` // 0;
+ $__CNF_CPPFLAGS .= " -D_REENTRANT";
+ if ( $CPU_VERSION >= 768 ) {
+ # IA-64 CPU
+ return "hpux64-ia64-cc" if $KERNEL_BITS eq '64' && $CC eq "cc";
+ return "hpux-ia64-cc"
+ }
+ if ( $CPU_VERSION >= 532 ) {
+ # PA-RISC 2.x CPU
+ # PA-RISC 2.0 is no longer supported as separate 32-bit
+ # target. This is compensated for by run-time detection
+ # in most critical assembly modules and taking advantage
+ # of 2.0 architecture in PA-RISC 1.1 build.
+ $OUT //= "hpux-parisc1_1-${CC}";
+ if ( $KERNEL_BITS eq '64' && $CC eq "cc" ) {
+ print <<EOF;
+WARNING! To build 64-bit package, do this:
+ $WHERE/Configure hpux64-parisc2-cc
+EOF
+ maybe_abort();
+ }
+ return $OUT;
+ }
+ # PA-RISC 1.1+ CPU?
+ return "hpux-parisc1_1-${CC}" if $CPU_VERSION >= 528;
+ # PA-RISC 1.0 CPU
+ return "hpux-parisc-${CC}" if $CPU_VERSION >= 523;
+ # Motorola(?) CPU
+ return "hpux-$CC";
+ return $OUT;
+ }
+ return "hpux-parisc-$CC" if $GUESSOS =~ '.*-hpux';
+ if ( $GUESSOS =~ '.*-aix' ) {
+ $KERNEL_BITS //= `getconf KERNEL_BITMODE 2>/dev/null`;
+ $KERNEL_BITS //= '32';
+ my $OBJECT_MODE //= 32;
+ if ( $CC eq "gcc" ) {
+ $OUT = "aix-gcc";
+ if ( $OBJECT_MODE == 64 ) {
+ print 'Your $OBJECT_MODE was found to be set to 64';
+ $OUT = "aix64-gcc"
+ }
+ } elsif ( $OBJECT_MODE == 64 ) {
+ print 'Your $OBJECT_MODE was found to be set to 64';
+ $OUT = "aix64-cc";
+ } else {
+ $OUT = "aix-cc";
+ if ( $KERNEL_BITS eq '64' ) {
+ print <<EOF;
+WARNING! To build 64-bit package, do this:
+ $WHERE/Configure aix64-cc
+EOF
+ maybe_abort();
+ }
+ }
+ if ( okrun(
+ "lsattr -E -O -l `lsdev -c processor|awk '{print \$1;exit}'`",
+ 'grep -i powerpc) >/dev/null 2>&1') ) {
+ # this applies even to Power3 and later, as they return
+ # PowerPC_POWER[345]
+ } else {
+ $options .= " no-asm";
+ }
+ return $OUT;
+ }
+
+ # Last case, return "z" from x-y-z
+ my @fields = split(/-/, $GUESSOS);
+ return $fields[2];
+}
+
+# gcc < 2.8 does not support -march=ultrasparc
+sub check_solaris_sparc8 {
+ my $OUT = shift;
+ if ( $OUT eq 'solaris-sparcv9-gcc' && $GCCVER < 28 ) {
+ print <<EOF;
+WARNING! Downgrading to solaris-sparcv8-gcc
+ Upgrade to gcc-2.8 or later.
+EOF
+ maybe_abort();
+ return 'solaris-sparcv8-gcc';
+ }
+ if ( $OUT eq "linux-sparcv9" && $GCCVER < 28 ) {
+ print <<EOF;
+WARNING! Downgrading to linux-sparcv8
+ Upgrade to gcc-2.8 or later.
+EOF
+ maybe_abort();
+ return 'linux-sparcv8';
+ }
+ return $OUT;
+}
+
+# Append $CC to the target if that's in the Config list.
+sub check_target_exists {
+ my $OUT = shift;
+ my %table;
+
+ open T, "$PERL $WHERE/Configure LIST|" or die "Can't get LIST, $!";
+ while ( <T> ) {
+ chop;
+ $table{$_} = 1;
+ }
+ close T;
+ return "$OUT-$CC" if defined $table{"$OUT-$CC"};
+ return "$OUT" if defined $table{$OUT};
+ print "This system ($OUT) is not supported. See INSTALL for details.\n";
+ exit 1;
+}
+
+
+###
+### MAIN PROCESSING
+###
+
+# Common part, does all the real work.
+sub common {
+ my $showguess = shift;
+
+ get_machine_etc();
+ my $GUESSOS = guess_system();
+ print "Operating system: $GUESSOS\n" if $VERBOSE || $showguess;
+ $options .= " 386" if $GUESSOS =~ /i386-/;
+ remove_removed_crypto_directories();
+ determine_compiler_settings();
+ my $TARGET = map_guess($GUESSOS) // $CC;
+ $TARGET = check_solaris_sparc8($TARGET);
+ $TARGET = check_target_exists($TARGET);
+ $options .= " $CONFIG_OPTIONS" if $CONFIG_OPTIONS ne '';
+ return $TARGET;
+}
+
+## If called from Configure
+sub get_platform {
+ my $ref = shift;
+ my %options = %{$ref};
+ $VERBOSE = 1 if defined $options{verbose};
+ $options .= " --debug" if defined $options{debug};
+ $WAIT = 0 if defined $options{nowait};
+
+ my $TARGET = common(0);
+
+ # Populate the environment settings.
+ my %env;
+ $env{__CNF_CPPDEFINES} = $__CNF_CPPDEFINES;
+ $env{__CNF_CPPINCLUDES} = $__CNF_CPPINCLUDES;
+ $env{__CNF_CPPFLAGS} = $__CNF_CPPFLAGS;
+ $env{__CNF_CFLAGS} = $__CNF_CFLAGS;
+ $env{__CNF_CXXFLAGS} = $__CNF_CXXFLAGS;
+
+ # Prepare results and return them
+ my %ret = {
+ 'target' => $TARGET,
+ 'options' => $options,
+ 'envvars' => %env,
+ };
+ return %ret;
+}
+
+
+# If running tandlone (via the "config" shell script)
+sub main {
+ call_getopt();
+
+ my $TARGET = common(1);
+
+ if ( $VERBOSE ) {
+ print <<EOF;
+
+export __CNF_CPPDEFINES="$__CNF_CPPDEFINES"
+export __CNF_CPPINCLUDES="$__CNF_CPPINCLUDES"
+export __CNF_CPPFLAGS="$__CNF_CPPFLAGS"
+export __CNF_CFLAGS="$__CNF_CFLAGS"
+export __CNF_CXXFLAGS="$__CNF_CXXFLAGS"
+export __CNF_LDFLAGS="$__CNF_LDFLAGS"
+export __CNF_LDLIBS="$__CNF_LDLIBS"
+$PERL $WHERE/Configure $TARGET $options
+EOF
+ }
+
+ return if $DRYRUN;
+
+ print "\n";
+ $ENV{__CNF_CPPDEFINES} = $__CNF_CPPDEFINES;
+ $ENV{__CNF_CPPINCLUDES} = $__CNF_CPPINCLUDES;
+ $ENV{__CNF_CPPFLAGS} = $__CNF_CPPFLAGS;
+ $ENV{__CNF_CFLAGS} = $__CNF_CFLAGS;
+ $ENV{__CNF_CXXFLAGS} = $__CNF_CXXFLAGS;
+ $ENV{__CNF_LDFLAGS} = $__CNF_LDFLAGS;
+ $ENV{__CNF_LDLIBS} = $__CNF_LDLIBS;
+ exit 1 if ! okrun("$PERL $WHERE/Configure $TARGET $options");
+}
+
+1;