xref: /freebsd/crypto/openssl/config (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1#!/bin/sh
2# Copyright 1998-2022 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the OpenSSL license (the "License").  You may not use
5# this file except in compliance with the License.  You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9# OpenSSL config: determine the operating system and run ./Configure
10# Derived from minarch and GuessOS from Apache.
11#
12# Do "config -h" for usage information.
13SUFFIX=""
14DRYRUN="false"
15VERBOSE="false"
16EXE=""
17THERE=`dirname $0`
18
19# pick up any command line args to config
20for i
21do
22case "$i" in
23-d*) options=$options" --debug";;
24-t*) DRYRUN="true" VERBOSE="true";;
25-v*) VERBOSE="true";;
26-h*) DRYRUN="true"; cat <<EOF
27Usage: config [options]
28 -d	Build with debugging when possible.
29 -t	Test mode, do not run the Configure perl script.
30 -v	Verbose mode, show the exact Configure call that is being made.
31 -h	This help.
32
33Any other text will be passed to the Configure perl script.
34See INSTALL for instructions.
35
36EOF
37;;
38*)  i=`echo "$i" | sed -e "s|'|'\\\\\\''|g"`
39    options="$options '$i'" ;;
40esac
41done
42
43# Environment that's being passed to Configure
44__CNF_CPPDEFINES=
45__CNF_CPPINCLUDES=
46__CNF_CPPFLAGS=
47__CNF_CFLAGS=
48__CNF_CXXFLAGS=
49__CNF_LDFLAGS=
50__CNF_LDLIBS=
51
52# First get uname entries that we use below
53
54[ "$MACHINE" ] || MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
55[ "$RELEASE" ] || RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
56[ "$SYSTEM" ] || SYSTEM=`(uname -s) 2>/dev/null`  || SYSTEM="unknown"
57[ "$BUILD" ] || VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
58
59
60# Now test for ISC and SCO, since it is has a braindamaged uname.
61#
62# We need to work around FreeBSD 1.1.5.1
63(
64XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
65if [ "x$XREL" != "x" ]; then
66    if [ -f /etc/kconfig ]; then
67	case "$XREL" in
68	    4.0|4.1)
69		    echo "${MACHINE}-whatever-isc4"; exit 0
70		;;
71	esac
72    else
73	case "$XREL" in
74	    3.2v4.2)
75		echo "whatever-whatever-sco3"; exit 0
76		;;
77	    3.2v5.0*)
78		echo "whatever-whatever-sco5"; exit 0
79		;;
80	    4.2MP)
81		case "x${VERSION}" in
82		    x2.0*) echo "whatever-whatever-unixware20"; exit 0 ;;
83		    x2.1*) echo "whatever-whatever-unixware21"; exit 0 ;;
84		    x2*)   echo "whatever-whatever-unixware2";  exit 0 ;;
85		esac
86		;;
87	    4.2)
88		echo "whatever-whatever-unixware1"; exit 0
89		;;
90	    5*)
91		case "x${VERSION}" in
92		    # We hardcode i586 in place of ${MACHINE} for the
93		    # following reason. The catch is that even though Pentium
94		    # is minimum requirement for platforms in question,
95		    # ${MACHINE} gets always assigned to i386. Now, problem
96		    # with i386 is that it makes ./config pass 386 to
97		    # ./Configure, which in turn makes make generate
98		    # inefficient SHA-1 (for this moment) code.
99		    x[678]*)  echo "i586-sco-unixware7"; exit 0 ;;
100		esac
101		;;
102	esac
103    fi
104fi
105# Now we simply scan though... In most cases, the SYSTEM info is enough
106#
107case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
108    A/UX:*)
109	echo "m68k-apple-aux3"; exit 0
110	;;
111
112    AIX:[3-9]:4:*)
113	echo "${MACHINE}-ibm-aix"; exit 0
114	;;
115
116    AIX:*:[5-9]:*)
117	echo "${MACHINE}-ibm-aix"; exit 0
118	;;
119
120    AIX:*)
121	echo "${MACHINE}-ibm-aix3"; exit 0
122	;;
123
124    HI-UX:*)
125	echo "${MACHINE}-hi-hiux"; exit 0
126	;;
127
128    HP-UX:*)
129	HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
130	case "$HPUXVER" in
131	    1[0-9].*)	# HPUX 10 and 11 targets are unified
132		echo "${MACHINE}-hp-hpux1x"; exit 0
133		;;
134	    *)
135		echo "${MACHINE}-hp-hpux"; exit 0
136		;;
137	esac
138	;;
139
140    IRIX:6.*)
141	echo "mips3-sgi-irix"; exit 0
142	;;
143
144    IRIX64:*)
145	echo "mips4-sgi-irix64"; exit 0
146	;;
147
148    Linux:[2-9].*)
149	echo "${MACHINE}-whatever-linux2"; exit 0
150	;;
151
152    Linux:1.*)
153	echo "${MACHINE}-whatever-linux1"; exit 0
154	;;
155
156    GNU*)
157	echo "hurd-x86"; exit 0;
158	;;
159
160    LynxOS:*)
161	echo "${MACHINE}-lynx-lynxos"; exit 0
162	;;
163
164    BSD/OS:4.*)  # BSD/OS always says 386
165	echo "i486-whatever-bsdi4"; exit 0
166	;;
167
168    BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
169        case `/sbin/sysctl -n hw.model` in
170	    Pentium*)
171                echo "i586-whatever-bsdi"; exit 0
172                ;;
173            *)
174                echo "i386-whatever-bsdi"; exit 0
175                ;;
176            esac;
177	;;
178
179    BSD/386:*|BSD/OS:*)
180	echo "${MACHINE}-whatever-bsdi"; exit 0
181	;;
182
183    FreeBSD:*:*:*386*)
184        VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
185        MACH=`sysctl -n hw.model`
186        ARCH='whatever'
187        case ${MACH} in
188           *386*       ) MACH="i386"     ;;
189           *486*       ) MACH="i486"     ;;
190           Pentium\ II*) MACH="i686"     ;;
191           Pentium*    ) MACH="i586"     ;;
192           *           ) MACH="$MACHINE" ;;
193        esac
194        case ${MACH} in
195           i[0-9]86 ) ARCH="pc" ;;
196        esac
197        echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
198        ;;
199
200    DragonFly:*)
201	echo "${MACHINE}-whatever-dragonfly"; exit 0
202	;;
203
204    FreeBSD:*)
205	echo "${MACHINE}-whatever-freebsd"; exit 0
206	;;
207
208    Haiku:*)
209	echo "${MACHINE}-whatever-haiku"; exit 0
210	;;
211
212    NetBSD:*:*:*386*)
213        echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
214	;;
215
216    NetBSD:*)
217	echo "${MACHINE}-whatever-netbsd"; exit 0
218	;;
219
220    OpenBSD:*)
221	echo "${MACHINE}-whatever-openbsd"; exit 0
222	;;
223
224    OpenUNIX:*)
225	echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
226	;;
227
228    OSF1:*:*:*alpha*)
229	OSFMAJOR=`echo ${RELEASE}| sed -e 's/^V\([0-9]*\)\..*$/\1/'`
230	case "$OSFMAJOR" in
231	    4|5)
232		echo "${MACHINE}-dec-tru64"; exit 0
233		;;
234	    1|2|3)
235		echo "${MACHINE}-dec-osf"; exit 0
236		;;
237	    *)
238		echo "${MACHINE}-dec-osf"; exit 0
239		;;
240	esac
241	;;
242
243    Paragon*:*:*:*)
244	echo "i860-intel-osf1"; exit 0
245	;;
246
247    Rhapsody:*)
248	echo "ppc-apple-rhapsody"; exit 0
249	;;
250
251    Darwin:*)
252	case "$MACHINE" in
253	    Power*)
254		echo "ppc-apple-darwin${VERSION}"
255		;;
256	    *)
257		echo "${MACHINE}-apple-darwin${VERSION}"
258		;;
259	esac
260	exit 0
261	;;
262
263    SunOS:5.*)
264	echo "${MACHINE}-whatever-solaris2"; exit 0
265	;;
266
267    SunOS:*)
268	echo "${MACHINE}-sun-sunos4"; exit 0
269	;;
270
271    UNIX_System_V:4.*:*)
272	echo "${MACHINE}-whatever-sysv4"; exit 0
273	;;
274
275    VOS:*:*:i786)
276     echo "i386-stratus-vos"; exit 0
277     ;;
278
279    VOS:*:*:*)
280     echo "hppa1.1-stratus-vos"; exit 0
281     ;;
282
283    *:4*:R4*:m88k)
284	echo "${MACHINE}-whatever-sysv4"; exit 0
285	;;
286
287    DYNIX/ptx:4*:*)
288	echo "${MACHINE}-whatever-sysv4"; exit 0
289	;;
290
291    *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
292	echo "i486-ncr-sysv4"; exit 0
293	;;
294
295    ULTRIX:*)
296	echo "${MACHINE}-unknown-ultrix"; exit 0
297	;;
298
299    POSIX-BC*)
300	echo "${MACHINE}-siemens-sysv4"; exit 0   # Here, $MACHINE == "BS2000"
301	;;
302
303    machten:*)
304       echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
305       ;;
306
307    library:*)
308	echo "${MACHINE}-ncr-sysv4"; exit 0
309	;;
310
311    ConvexOS:*:11.0:*)
312	echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
313	;;
314
315    # The following combinations are supported
316    # MINGW64* on x86_64 => mingw64
317    # MINGW32* on x86_64 => mingw
318    # MINGW32* on i?86 => mingw
319    #
320    # MINGW64* on i?86 isn't expected to work...
321    MINGW64*:*:*:x86_64)
322	echo "${MACHINE}-whatever-mingw64"; exit 0;
323	;;
324    MINGW*)
325	echo "${MACHINE}-whatever-mingw"; exit 0;
326	;;
327    CYGWIN*)
328	echo "${MACHINE}-pc-cygwin"; exit 0
329	;;
330
331    vxworks*)
332       echo "${MACHINE}-whatever-vxworks"; exit 0;
333       ;;
334esac
335
336#
337# Ugg. These are all we can determine by what we know about
338# the output of uname. Be more creative:
339#
340
341# Do the Apollo stuff first. Here, we just simply assume
342# that the existence of the /usr/apollo directory is proof
343# enough
344if [ -d /usr/apollo ]; then
345    echo "whatever-apollo-whatever"
346    exit 0
347fi
348
349# Now NeXT
350ISNEXT=`hostinfo 2>/dev/null`
351case "$ISNEXT" in
352    *'NeXT Mach 3.3'*)
353	echo "whatever-next-nextstep3.3"; exit 0
354	;;
355    *NeXT*)
356	echo "whatever-next-nextstep"; exit 0
357	;;
358esac
359
360# At this point we gone through all the one's
361# we know of: Punt
362
363echo "${MACHINE}-whatever-${SYSTEM}"
364exit 0
365) 2>/dev/null | (
366
367# ---------------------------------------------------------------------------
368# this is where the translation occurs into SSLeay terms
369# ---------------------------------------------------------------------------
370
371# Only set CC if not supplied already
372if [ -z "$CROSS_COMPILE$CC" ]; then
373  GCCVER=`sh -c "gcc -dumpversion" 2>/dev/null`
374  if [ "$GCCVER" != "" ]; then
375    # then strip off whatever prefix egcs prepends the number with...
376    # Hopefully, this will work for any future prefixes as well.
377    GCCVER=`echo $GCCVER | LC_ALL=C sed 's/^[a-zA-Z]*\-//'`
378    # Since gcc 3.1 gcc --version behaviour has changed.  gcc -dumpversion
379    # does give us what we want though, so we use that.  We just just the
380    # major and minor version numbers.
381    # peak single digit before and after first dot, e.g. 2.95.1 gives 29
382    GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
383    CC=gcc
384  else
385    CC=cc
386  fi
387fi
388GCCVER=${GCCVER:-0}
389if [ "$SYSTEM" = "HP-UX" ];then
390  # By default gcc is a ILP32 compiler (with long long == 64).
391  GCC_BITS="32"
392  if [ $GCCVER -ge 30 ]; then
393    # PA64 support only came in with gcc 3.0.x.
394    # We check if the preprocessor symbol __LP64__ is defined...
395    if echo "__LP64__" | gcc -v -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null; then
396      : # __LP64__ has slipped through, it therefore is not defined
397    else
398      GCC_BITS="64"
399    fi
400  fi
401fi
402if [ "$SYSTEM" = "SunOS" ]; then
403  if [ $GCCVER -ge 30 ]; then
404    # 64-bit ABI isn't officially supported in gcc 3.0, but it appears
405    # to be working, at the very least 'make test' passes...
406    if gcc -v -E -x c /dev/null 2>&1 | grep __arch64__ > /dev/null; then
407      GCC_ARCH="-m64"
408    else
409      GCC_ARCH="-m32"
410    fi
411  fi
412  # check for WorkShop C, expected output is "cc: blah-blah C x.x"
413  CCVER=`(cc -V 2>&1) 2>/dev/null | \
414  	egrep -e '^cc: .* C [0-9]\.[0-9]' | \
415	sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
416  CCVER=${CCVER:-0}
417  if [ $MACHINE != i86pc -a $CCVER -gt 40 ]; then
418    CC=cc	# overrides gcc!!!
419    if [ $CCVER -eq 50 ]; then
420      echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
421      echo "         patch #107357-01 or later applied."
422      sleep 5
423    fi
424  fi
425fi
426
427if [ "${SYSTEM}" = "AIX" ]; then	# favor vendor cc over gcc
428    (cc) 2>&1 | grep -iv "not found" > /dev/null && CC=cc
429fi
430
431CCVER=${CCVER:-0}
432
433# read the output of the embedded GuessOS
434read GUESSOS
435
436echo Operating system: $GUESSOS
437
438# now map the output into SSLeay terms ... really should hack into the
439# script above so we end up with values in vars but that would take
440# more time that I want to waste at the moment
441case "$GUESSOS" in
442  uClinux*64*)
443    OUT=uClinux-dist64
444	;;
445  uClinux*)
446    OUT=uClinux-dist
447	;;
448  mips3-sgi-irix)
449	OUT="irix-mips3-$CC"
450	;;
451  mips4-sgi-irix64)
452	echo "WARNING! If you wish to build 64-bit library, then you have to"
453	echo "         invoke '$THERE/Configure irix64-mips4-$CC' *manually*."
454	if [ "$DRYRUN" = "false" -a -t 1 ]; then
455	  echo "         You have about 5 seconds to press Ctrl-C to abort."
456	  (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
457	fi
458	OUT="irix-mips3-$CC"
459	;;
460  ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
461  ppc-apple-darwin*)
462	ISA64=`(sysctl -n hw.optional.64bitops) 2>/dev/null`
463	if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
464	    echo "WARNING! If you wish to build 64-bit library, then you have to"
465	    echo "         invoke '$THERE/Configure darwin64-ppc-cc' *manually*."
466	    if [ "$DRYRUN" = "false" -a -t 1 ]; then
467	      echo "         You have about 5 seconds to press Ctrl-C to abort."
468	      (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
469	    fi
470	fi
471	if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
472	    OUT="darwin64-ppc-cc"
473	else
474	    OUT="darwin-ppc-cc"
475	fi ;;
476  i?86-apple-darwin*)
477	ISA64=`(sysctl -n hw.optional.x86_64) 2>/dev/null`
478	if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
479	    echo "WARNING! If you wish to build 64-bit library, then you have to"
480	    echo "         invoke 'KERNEL_BITS=64 $THERE/config $options'."
481	    if [ "$DRYRUN" = "false" -a -t 1 ]; then
482	      echo "         You have about 5 seconds to press Ctrl-C to abort."
483	      (trap "stty `stty -g`; exit 1" 2; stty -icanon min 0 time 50; read waste; exit 0) <&1 || exit
484	    fi
485	fi
486	if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
487	    OUT="darwin64-x86_64-cc"
488	else
489	    OUT="darwin-i386-cc"
490	fi ;;
491  x86_64-apple-darwin*)
492	if [ "$KERNEL_BITS" = "32" ]; then
493	    OUT="darwin-i386-cc"
494	else
495	    OUT="darwin64-x86_64-cc"
496	fi ;;
497  $MACHINE-apple-darwin*)
498	OUT="darwin64-$MACHINE-cc"
499	;;
500  armv6+7-*-iphoneos)
501	__CNF_CFLAGS="$__CNF_CFLAGS -arch armv6 -arch armv7"
502	__CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch armv6 -arch armv7"
503	OUT="iphoneos-cross" ;;
504  *-*-iphoneos)
505	__CNF_CFLAGS="$__CNF_CFLAGS -arch ${MACHINE}"
506	__CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch ${MACHINE}"
507	OUT="iphoneos-cross" ;;
508  arm64-*-iphoneos|*-*-ios64)
509	OUT="ios64-cross" ;;
510  alpha-*-linux2)
511        ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo`
512	OUT="linux-alpha-$CC"
513	if [ "$CC" = "gcc" ]; then
514	    case ${ISA:-generic} in
515	    EV5|EV45)		__CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev5"
516				__CNF_CXXFLAGS="$__CNF_CFLAGS -mcpu=ev5";;
517	    EV56|PCA56)		__CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev56"
518				__CNF_CXXFLAGS="$__CNF_CXXFLAGS -mcpu=ev56";;
519	    *)			__CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev6"
520				__CNF_CXXFLAGS="$__CNF_CXXFLAGS -mcpu=ev6";;
521	    esac
522	fi
523	;;
524  ppc64-*-linux2)
525	if [ -z "$KERNEL_BITS" ]; then
526	    echo "WARNING! If you wish to build 64-bit library, then you have to"
527	    echo "         invoke '$THERE/Configure linux-ppc64' *manually*."
528	    if [ "$DRYRUN" = "false" -a -t 1 ]; then
529		echo "         You have about 5 seconds to press Ctrl-C to abort."
530		(trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
531	    fi
532	fi
533	if [ "$KERNEL_BITS" = "64" ]; then
534	    OUT="linux-ppc64"
535	else
536	    OUT="linux-ppc"
537	    if (echo "__LP64__" | gcc -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null); then
538		:;
539	    else
540		__CNF_CFLAGS="$__CNF_CFLAGS -m32"
541		__CNF_CXXFLAGS="$__CNF_CXXFLAGS -m32"
542	    fi
543	fi
544	;;
545  ppc64le-*-linux2) OUT="linux-ppc64le" ;;
546  ppc-*-linux2) OUT="linux-ppc" ;;
547  mips64*-*-linux2)
548	echo "WARNING! If you wish to build 64-bit library, then you have to"
549	echo "         invoke '$THERE/Configure linux64-mips64' *manually*."
550	if [ "$DRYRUN" = "false" -a -t 1 ]; then
551	    echo "         You have about 5 seconds to press Ctrl-C to abort."
552	    (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
553	fi
554	OUT="linux-mips64"
555	;;
556  mips*-*-linux2) OUT="linux-mips32" ;;
557  ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
558  ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
559  pentium-*-vxworks*) OUT="vxworks-pentium" ;;
560  simlinux-*-vxworks*) OUT="vxworks-simlinux" ;;
561  mips-*-vxworks*) OUT="vxworks-mips";;
562  ia64-*-linux?) OUT="linux-ia64" ;;
563  sparc64-*-linux2)
564	echo "WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI"
565	echo "         and wish to build 64-bit library, then you have to"
566	echo "         invoke '$THERE/Configure linux64-sparcv9' *manually*."
567	if [ "$DRYRUN" = "false" -a -t 1 ]; then
568	  echo "          You have about 5 seconds to press Ctrl-C to abort."
569	  (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
570	fi
571	OUT="linux-sparcv9" ;;
572  sparc-*-linux2)
573	KARCH=`awk '/^type/{print$3;exit(0);}' /proc/cpuinfo`
574	case ${KARCH:-sun4} in
575	sun4u*)	OUT="linux-sparcv9" ;;
576	sun4m)	OUT="linux-sparcv8" ;;
577	sun4d)	OUT="linux-sparcv8" ;;
578	*)	OUT="linux-generic32";
579		__CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
580	esac ;;
581  parisc*-*-linux2)
582	# 64-bit builds under parisc64 linux are not supported and
583	# compiler is expected to generate 32-bit objects...
584	CPUARCH=`awk '/cpu family/{print substr($5,1,3); exit(0);}' /proc/cpuinfo`
585	CPUSCHEDULE=`awk '/^cpu.[ 	]*: PA/{print substr($3,3); exit(0);}' /proc/cpuinfo`
586
587	# ??TODO ??  Model transformations
588	# 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
589	#    assuming no further arch. identification will ever be used by GCC.
590	# 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
591	# 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
592	#    for these chips in the future.
593	#         PA7300LC -> 7100LC (1.1)
594	#         PA8200   -> 8000   (2.0)
595	#         PA8500   -> 8000   (2.0)
596	#         PA8600   -> 8000   (2.0)
597
598	CPUSCHEDULE=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8.00/8000/'`
599	# Finish Model transformations
600
601	__CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN"
602	__CNF_CFLAGS="$__CNF_CFLAGS -mschedule=$CPUSCHEDULE -march=$CPUARCH"
603	__CNF_CXXFLAGS="$__CNF_CXXFLAGS -mschedule=$CPUSCHEDULE -march=$CPUARCH"
604	OUT="linux-generic32" ;;
605  armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
606  armv[7-9]*-*-linux2) OUT="linux-armv4"
607		       __CNF_CFLAGS="$__CNF_CFLAGS -march=armv7-a"
608		       __CNF_CXXFLAGS="$__CNF_CXXFLAGS -march=armv7-a"
609		       ;;
610  arm*-*-linux2) OUT="linux-armv4" ;;
611  aarch64-*-linux2) OUT="linux-aarch64" ;;
612  sh*b-*-linux2) OUT="linux-generic32";
613		 __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
614  sh*-*-linux2)	 OUT="linux-generic32";
615		 __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DL_ENDIAN" ;;
616  m68k*-*-linux2) OUT="linux-generic32";
617		  __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
618  s390-*-linux2) OUT="linux-generic32";
619		 __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
620  s390x-*-linux2)
621	# To be uncommented when glibc bug is fixed, see Configure...
622	#if egrep -e '^features.* highgprs' /proc/cpuinfo >/dev/null ; then
623	#  echo "WARNING! If you wish to build \"highgprs\" 32-bit library, then you"
624	#  echo "         have to invoke './Configure linux32-s390x' *manually*."
625	#  if [ "$DRYRUN" = "false" -a -t -1 ]; then
626	#    echo "         You have about 5 seconds to press Ctrl-C to abort."
627	#    (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
628	#  fi
629	#fi
630	OUT="linux64-s390x"
631	;;
632  x86_64-*-linux?)
633	if $CC -dM -E -x c /dev/null 2>&1 | grep -q ILP32 > /dev/null; then
634	    OUT="linux-x32"
635	else
636	    OUT="linux-x86_64"
637	fi ;;
638  *86-*-linux2)
639        # On machines where the compiler understands -m32, prefer a
640        # config target that uses it
641        if $CC -m32 -E -x c /dev/null > /dev/null 2>&1; then
642            OUT="linux-x86"
643        else
644            OUT="linux-elf"
645        fi ;;
646  *86-*-linux1) OUT="linux-aout" ;;
647  *-*-linux?) OUT="linux-generic32" ;;
648  sun4[uv]*-*-solaris2)
649	OUT="solaris-sparcv9-$CC"
650	ISA64=`(isainfo) 2>/dev/null | grep sparcv9`
651	if [ "$ISA64" != "" -a "$KERNEL_BITS" = "" ]; then
652	    if [ "$CC" = "cc" -a $CCVER -ge 50 ]; then
653		echo "WARNING! If you wish to build 64-bit library, then you have to"
654		echo "         invoke '$THERE/Configure solaris64-sparcv9-cc' *manually*."
655		if [ "$DRYRUN" = "false" -a -t 1 ]; then
656		  echo "         You have about 5 seconds to press Ctrl-C to abort."
657		  (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
658		fi
659	    elif [ "$CC" = "gcc" -a "$GCC_ARCH" = "-m64" ]; then
660		# $GCC_ARCH denotes default ABI chosen by compiler driver
661		# (first one found on the $PATH). I assume that user
662		# expects certain consistency with the rest of his builds
663		# and therefore switch over to 64-bit. <appro>
664		OUT="solaris64-sparcv9-gcc"
665		echo "WARNING! If you wish to build 32-bit library, then you have to"
666		echo "         invoke '$THERE/Configure solaris-sparcv9-gcc' *manually*."
667		if [ "$DRYRUN" = "false" -a -t 1 ]; then
668		  echo "         You have about 5 seconds to press Ctrl-C to abort."
669		  (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
670		fi
671	    elif [ "$GCC_ARCH" = "-m32" ]; then
672		echo "NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI"
673		echo "        and wish to build 64-bit library, then you have to"
674		echo "        invoke '$THERE/Configure solaris64-sparcv9-gcc' *manually*."
675		if [ "$DRYRUN" = "false" -a -t 1 ]; then
676		  echo "         You have about 5 seconds to press Ctrl-C to abort."
677		  (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
678		fi
679	    fi
680	fi
681	if [ "$ISA64" != "" -a "$KERNEL_BITS" = "64" ]; then
682	    OUT="solaris64-sparcv9-$CC"
683	fi
684	;;
685  sun4m-*-solaris2)	OUT="solaris-sparcv8-$CC" ;;
686  sun4d-*-solaris2)	OUT="solaris-sparcv8-$CC" ;;
687  sun4*-*-solaris2)	OUT="solaris-sparcv7-$CC" ;;
688  *86*-*-solaris2)
689	ISA64=`(isainfo) 2>/dev/null | grep amd64`
690	if [ "$ISA64" != "" -a ${KERNEL_BITS:-64} -eq 64 ]; then
691	    OUT="solaris64-x86_64-$CC"
692	else
693	    OUT="solaris-x86-$CC"
694	    if [ `uname -r | sed -e 's/5\.//'` -lt 10 ]; then
695		options="$options no-sse2"
696	    fi
697	fi
698	;;
699  *-*-sunos4)		OUT="sunos-$CC" ;;
700
701  *86*-*-bsdi4)		OUT="BSD-x86-elf"; options="$options no-sse2";
702			__CNF_LDFLAGS="$__CNF_LDFLAGS -ldl" ;;
703  alpha*-*-*bsd*)	OUT="BSD-generic64";
704			__CNF_CPPFLAGS="$__CNF_CPPFLAGS -DL_ENDIAN" ;;
705  powerpc64-*-*bsd*)	OUT="BSD-generic64";
706			__CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
707  riscv64-*-*bsd*)	OUT="BSD-riscv64" ;;
708  sparc64-*-*bsd*)	OUT="BSD-sparc64" ;;
709  ia64-*-*bsd*)		OUT="BSD-ia64" ;;
710  x86_64-*-dragonfly*)  OUT="BSD-x86_64" ;;
711  amd64-*-*bsd*)	OUT="BSD-x86_64" ;;
712  arm64-*-*bsd*)	OUT="BSD-aarch64" ;;
713  *86*-*-*bsd*)		# mimic ld behaviour when it's looking for libc...
714			if [ -L /usr/lib/libc.so ]; then	# [Free|Net]BSD
715			    libc=/usr/lib/libc.so
716			else					# OpenBSD
717			    # ld searches for highest libc.so.* and so do we
718			    libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
719			fi
720			case "`(file -L $libc) 2>/dev/null`" in
721			*ELF*)	OUT="BSD-x86-elf" ;;
722			*)	OUT="BSD-x86"; options="$options no-sse2" ;;
723			esac ;;
724  *-*-*bsd*)		OUT="BSD-generic32" ;;
725
726  x86_64-*-haiku)	OUT="haiku-x86_64" ;;
727  *-*-haiku)		OUT="haiku-x86" ;;
728
729  *-*-osf)		OUT="osf1-alpha-cc" ;;
730  *-*-tru64)		OUT="tru64-alpha-cc" ;;
731  *-*-[Uu]nix[Ww]are7)
732	if [ "$CC" = "gcc" ]; then
733	  OUT="unixware-7-gcc" ; options="$options no-sse2"
734	else
735	  OUT="unixware-7" ; options="$options no-sse2"
736	  __CNF_CPPFLAGS="$__CNF_CPPFLAGS -D__i386__"
737	fi
738	;;
739  *-*-[Uu]nix[Ww]are20*) OUT="unixware-2.0"; options="$options no-sse2 no-sha512" ;;
740  *-*-[Uu]nix[Ww]are21*) OUT="unixware-2.1"; options="$options no-sse2 no-sha512" ;;
741  *-*-vos)
742	options="$options no-threads no-shared no-asm no-dso"
743	EXE=".pm"
744	OUT="vos-$CC" ;;
745  BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
746  *-hpux1*)
747	if [ $CC = "gcc" -a $GCC_BITS = "64" ]; then
748	    OUT="hpux64-parisc2-gcc"
749	fi
750	[ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITS) 2>/dev/null`
751	KERNEL_BITS=${KERNEL_BITS:-32}
752	CPU_VERSION=`(getconf CPU_VERSION) 2>/dev/null`
753	CPU_VERSION=${CPU_VERSION:-0}
754	# See <sys/unistd.h> for further info on CPU_VERSION.
755	if   [ $CPU_VERSION -ge 768 ]; then	# IA-64 CPU
756	     if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
757	        OUT="hpux64-ia64-cc"
758             else
759	        OUT="hpux-ia64-cc"
760             fi
761	elif [ $CPU_VERSION -ge 532 ]; then	# PA-RISC 2.x CPU
762	     # PA-RISC 2.0 is no longer supported as separate 32-bit
763	     # target. This is compensated for by run-time detection
764	     # in most critical assembly modules and taking advantage
765	     # of 2.0 architecture in PA-RISC 1.1 build.
766	     OUT=${OUT:-"hpux-parisc1_1-${CC}"}
767	     if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
768		echo "WARNING! If you wish to build 64-bit library then you have to"
769		echo "         invoke '$THERE/Configure hpux64-parisc2-cc' *manually*."
770		if [ "$DRYRUN" = "false" -a -t 1 ]; then
771		  echo "         You have about 5 seconds to press Ctrl-C to abort."
772		  (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
773		fi
774	     fi
775	elif [ $CPU_VERSION -ge 528 ]; then	# PA-RISC 1.1+ CPU
776	     OUT="hpux-parisc1_1-${CC}"
777	elif [ $CPU_VERSION -ge 523 ]; then	# PA-RISC 1.0 CPU
778	     OUT="hpux-parisc-${CC}"
779	else					# Motorola(?) CPU
780	     OUT="hpux-$CC"
781	fi
782	__CNF_CPPFLAGS="$__CNF_CPPFLAGS -D_REENTRANT" ;;
783  *-hpux)	OUT="hpux-parisc-$CC" ;;
784  *-aix)
785	[ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITMODE) 2>/dev/null`
786	KERNEL_BITS=${KERNEL_BITS:-32}
787	OBJECT_MODE=${OBJECT_MODE:-32}
788	if [ "$CC" = "gcc" ]; then
789	    OUT="aix-gcc"
790          if [ $OBJECT_MODE -eq 64 ]; then
791            echo 'Your $OBJECT_MODE was found to be set to 64'
792            OUT="aix64-gcc"
793          fi
794	elif [ $OBJECT_MODE -eq 64 ]; then
795	    echo 'Your $OBJECT_MODE was found to be set to 64'
796	    OUT="aix64-cc"
797	else
798	    OUT="aix-cc"
799	    if [ $KERNEL_BITS -eq 64 ]; then
800		echo "WARNING! If you wish to build 64-bit kit, then you have to"
801		echo "         invoke '$THERE/Configure aix64-cc' *manually*."
802		if [ "$DRYRUN" = "false" -a -t 1 ]; then
803		    echo "         You have ~5 seconds to press Ctrl-C to abort."
804		    (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
805		fi
806	    fi
807	fi
808	if (lsattr -E -O -l `lsdev -c processor|awk '{print$1;exit}'` | grep -i powerpc) >/dev/null 2>&1; then
809	    :	# this applies even to Power3 and later, as they return PowerPC_POWER[345]
810	else
811	    options="$options no-asm"
812	fi
813	;;
814  # these are all covered by the catchall below
815  i[3456]86-*-cygwin) OUT="Cygwin-x86" ;;
816  *-*-cygwin) OUT="Cygwin-${MACHINE}" ;;
817  x86-*-android|i?86-*-android) OUT="android-x86" ;;
818  armv[7-9]*-*-android)
819      OUT="android-armeabi"
820      __CNF_CFLAGS="$__CNF_CFLAGS -march=armv7-a"
821      __CNF_CXXFLAGS="$__CNF_CXXFLAGS -march=armv7-a";;
822  arm*-*-android) OUT="android-armeabi" ;;
823  *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
824esac
825
826# NB: This atalla support has been superseded by the ENGINE support
827# That contains its own header and definitions anyway. Support can
828# be enabled or disabled on any supported platform without external
829# headers, eg. by adding the "hw-atalla" switch to ./config or
830# perl Configure
831#
832# See whether we can compile Atalla support
833#if [ -f /usr/include/atasi.h ]
834#then
835#  __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DATALLA"
836#fi
837
838if [ -n "$CONFIG_OPTIONS" ]; then
839  options="$options $CONFIG_OPTIONS"
840fi
841
842# gcc < 2.8 does not support -march=ultrasparc
843if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
844then
845  echo "WARNING! Falling down to 'solaris-sparcv8-gcc'."
846  echo "         Upgrade to gcc-2.8 or later."
847  sleep 5
848  OUT=solaris-sparcv8-gcc
849fi
850if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
851then
852  echo "WARNING! Falling down to 'linux-sparcv8'."
853  echo "         Upgrade to gcc-2.8 or later."
854  sleep 5
855  OUT=linux-sparcv8
856fi
857
858case "$GUESSOS" in
859  i386-*) options="$options 386" ;;
860esac
861
862for i in aes aria bf camellia cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa seed sha sm2 sm3 sm4
863do
864  if [ ! -d $THERE/crypto/$i ]
865  then
866    options="$options no-$i"
867  fi
868done
869
870if [ -z "$OUT" ]; then
871  OUT="$CC"
872fi
873
874if [ ".$PERL" = . ] ; then
875	for i in . `echo $PATH | sed 's/:/ /g'`; do
876		if [ -f "$i/perl5$EXE" ] ; then
877			PERL="$i/perl5$EXE"
878			break;
879		fi;
880	done
881fi
882
883if [ ".$PERL" = . ] ; then
884	for i in . `echo $PATH | sed 's/:/ /g'`; do
885		if [ -f "$i/perl$EXE" ] ; then
886			if "$i/perl$EXE" -e 'exit($]<5.0)'; then
887				PERL="$i/perl$EXE"
888				break;
889			fi;
890		fi;
891	done
892fi
893
894if [ ".$PERL" = . ] ; then
895	echo "You need Perl 5."
896	exit 1
897fi
898
899# run Configure to check to see if we need to specify the
900# compiler for the platform ... in which case we add it on
901# the end ... otherwise we leave it off
902
903$PERL $THERE/Configure LIST | grep "$OUT-$CC" > /dev/null
904if [ $? = "0" ]; then
905  OUT="$OUT-$CC"
906fi
907
908OUT="$OUT"
909
910if [ "$OUT" = "darwin64-x86_64-cc" ]; then
911    echo "WARNING! If you wish to build 32-bit libraries, then you have to"
912    echo "         invoke 'KERNEL_BITS=32 $THERE/config $options'."
913fi
914
915if $PERL $THERE/Configure LIST | grep "$OUT" > /dev/null; then
916  if [ "$VERBOSE" = "true" ]; then
917    echo /usr/bin/env \
918	 __CNF_CPPDEFINES="'$__CNF_CPPDEFINES'" \
919	 __CNF_CPPINCLUDES="'$__CNF_CPPINCLUDES'" \
920	 __CNF_CPPFLAGS="'$__CNF_CPPFLAGS'" \
921	 __CNF_CFLAGS="'$__CNF_CFLAGS'" \
922	 __CNF_CXXFLAGS="'$__CNF_CXXFLAGS'" \
923	 __CNF_LDFLAGS="'$__CNF_LDFLAGS'" \
924	 __CNF_LDLIBS="'$__CNF_LDLIBS'" \
925	 $PERL $THERE/Configure $OUT $options
926  fi
927  if [ "$DRYRUN" = "false" ]; then
928    # eval to make sure quoted options, possibly with spaces inside,
929    # are treated right
930    eval /usr/bin/env \
931	 __CNF_CPPDEFINES="'$__CNF_CPPDEFINES'" \
932	 __CNF_CPPINCLUDES="'$__CNF_CPPINCLUDES'" \
933	 __CNF_CPPFLAGS="'$__CNF_CPPFLAGS'" \
934	 __CNF_CFLAGS="'$__CNF_CFLAGS'" \
935	 __CNF_CXXFLAGS="'$__CNF_CXXFLAGS'" \
936	 __CNF_LDFLAGS="'$__CNF_LDFLAGS'" \
937	 __CNF_LDLIBS="'$__CNF_LDLIBS'" \
938	 $PERL $THERE/Configure $OUT $options
939  fi
940else
941  echo "This system ($OUT) is not supported. See file INSTALL for details."
942  exit 1
943fi
944
945# Do not add anothing from here on, so we don't lose the Configure exit code
946)
947