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