property: Move global default properties to the library context.
[openssl.git] / config
1 #!/bin/sh
2 # Copyright 1998-2020 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the Apache License 2.0 (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 # 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 (
64 XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
65 if [ "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
104 fi
105 # Now we simply scan though... In most cases, the SYSTEM info is enough
106 #
107 case "${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             x86_64)
257                 echo "x86_64-apple-darwin${VERSION}"
258                 ;;
259             *)
260                 echo "i686-apple-darwin${VERSION}"
261                 ;;
262         esac
263         exit 0
264         ;;
265
266     SunOS:5.*)
267         echo "${MACHINE}-whatever-solaris2"; exit 0
268         ;;
269
270     SunOS:*)
271         echo "${MACHINE}-sun-sunos4"; exit 0
272         ;;
273
274     UNIX_System_V:4.*:*)
275         echo "${MACHINE}-whatever-sysv4"; exit 0
276         ;;
277
278     VOS:*:*:i786)
279      echo "i386-stratus-vos"; exit 0
280      ;;
281
282     VOS:*:*:*)
283      echo "hppa1.1-stratus-vos"; exit 0
284      ;;
285
286     *:4*:R4*:m88k)
287         echo "${MACHINE}-whatever-sysv4"; exit 0
288         ;;
289
290     DYNIX/ptx:4*:*)
291         echo "${MACHINE}-whatever-sysv4"; exit 0
292         ;;
293
294     *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
295         echo "i486-ncr-sysv4"; exit 0
296         ;;
297
298     ULTRIX:*)
299         echo "${MACHINE}-unknown-ultrix"; exit 0
300         ;;
301
302     POSIX-BC*)
303         echo "${MACHINE}-siemens-sysv4"; exit 0   # Here, $MACHINE == "BS2000"
304         ;;
305
306     machten:*)
307        echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
308        ;;
309
310     library:*)
311         echo "${MACHINE}-ncr-sysv4"; exit 0
312         ;;
313
314     ConvexOS:*:11.0:*)
315         echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
316         ;;
317
318     # The following combinations are supported
319     # MINGW64* on x86_64 => mingw64
320     # MINGW32* on x86_64 => mingw
321     # MINGW32* on i?86 => mingw
322     #
323     # MINGW64* on i?86 isn't expected to work...
324     MINGW64*:*:*:x86_64)
325         echo "${MACHINE}-whatever-mingw64"; exit 0;
326         ;;
327     MINGW*)
328         echo "${MACHINE}-whatever-mingw"; exit 0;
329         ;;
330     CYGWIN*)
331         echo "${MACHINE}-pc-cygwin"; exit 0
332         ;;
333
334     vxworks*)
335        echo "${MACHINE}-whatever-vxworks"; exit 0;
336        ;;
337 esac
338
339 #
340 # Ugg. These are all we can determine by what we know about
341 # the output of uname. Be more creative:
342 #
343
344 # Do the Apollo stuff first. Here, we just simply assume
345 # that the existence of the /usr/apollo directory is proof
346 # enough
347 if [ -d /usr/apollo ]; then
348     echo "whatever-apollo-whatever"
349     exit 0
350 fi
351
352 # At this point we gone through all the one's
353 # we know of: Punt
354
355 echo "${MACHINE}-whatever-${SYSTEM}"
356 exit 0
357 ) 2>/dev/null | (
358
359 # ---------------------------------------------------------------------------
360 # this is where the translation occurs into SSLeay terms
361 # ---------------------------------------------------------------------------
362
363 # Only set CC if not supplied already
364 if [ -z "$CROSS_COMPILE$CC" ]; then
365   GCCVER=`sh -c "gcc -dumpversion" 2>/dev/null`
366   if [ "$GCCVER" != "" ]; then
367     # then strip off whatever prefix egcs prepends the number with...
368     # Hopefully, this will work for any future prefixes as well.
369     GCCVER=`echo $GCCVER | LC_ALL=C sed 's/^[a-zA-Z]*\-//'`
370     # Since gcc 3.1 gcc --version behaviour has changed.  gcc -dumpversion
371     # does give us what we want though, so we use that.  We just just the
372     # major and minor version numbers.
373     # peak single digit before and after first dot, e.g. 2.95.1 gives 29
374     GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
375     CC=gcc
376   else
377     CC=cc
378   fi
379 fi
380 GCCVER=${GCCVER:-0}
381 if [ "$SYSTEM" = "HP-UX" ];then
382   # By default gcc is a ILP32 compiler (with long long == 64).
383   GCC_BITS="32"
384   if [ $GCCVER -ge 30 ]; then
385     # PA64 support only came in with gcc 3.0.x.
386     # We check if the preprocessor symbol __LP64__ is defined...
387     if echo "__LP64__" | gcc -v -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null; then
388       : # __LP64__ has slipped through, it therefore is not defined
389     else
390       GCC_BITS="64"
391     fi
392   fi
393 fi
394 if [ "$SYSTEM" = "SunOS" ]; then
395   if [ $GCCVER -ge 30 ]; then
396     # 64-bit ABI isn't officially supported in gcc 3.0, but it appears
397     # to be working, at the very least 'make test' passes...
398     if gcc -v -E -x c /dev/null 2>&1 | grep __arch64__ > /dev/null; then
399       GCC_ARCH="-m64"
400     else
401       GCC_ARCH="-m32"
402     fi
403   fi
404   # check for WorkShop C, expected output is "cc: blah-blah C x.x"
405   CCVER=`(cc -V 2>&1) 2>/dev/null | \
406         egrep -e '^cc: .* C [0-9]\.[0-9]' | \
407         sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
408   CCVER=${CCVER:-0}
409   if [ $MACHINE != i86pc -a $CCVER -gt 40 ]; then
410     CC=cc       # overrides gcc!!!
411     if [ $CCVER -eq 50 ]; then
412       echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
413       echo "         patch #107357-01 or later applied."
414       sleep 5
415     fi
416   fi
417 fi
418
419 if [ "${SYSTEM}" = "AIX" ]; then        # favor vendor cc over gcc
420     (cc) 2>&1 | grep -iv "not found" > /dev/null && CC=cc
421 fi
422
423 CCVER=${CCVER:-0}
424
425 # read the output of the embedded GuessOS
426 read GUESSOS
427
428 echo Operating system: $GUESSOS
429
430 # now map the output into SSLeay terms ... really should hack into the
431 # script above so we end up with values in vars but that would take
432 # more time that I want to waste at the moment
433 case "$GUESSOS" in
434   uClinux*64*)
435     OUT=uClinux-dist64
436         ;;
437   uClinux*)
438     OUT=uClinux-dist
439         ;;
440   mips3-sgi-irix)
441         OUT="irix-mips3-$CC"
442         ;;
443   mips4-sgi-irix64)
444         echo "WARNING! If you wish to build 64-bit library, then you have to"
445         echo "         invoke '$THERE/Configure irix64-mips4-$CC' *manually*."
446         if [ "$DRYRUN" = "false" -a -t 1 ]; then
447           echo "         You have about 5 seconds to press Ctrl-C to abort."
448           (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
449         fi
450         OUT="irix-mips3-$CC"
451         ;;
452   ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
453   ppc-apple-darwin*)
454         ISA64=`(sysctl -n hw.optional.64bitops) 2>/dev/null`
455         if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
456             echo "WARNING! If you wish to build 64-bit library, then you have to"
457             echo "         invoke '$THERE/Configure darwin64-ppc-cc' *manually*."
458             if [ "$DRYRUN" = "false" -a -t 1 ]; then
459               echo "         You have about 5 seconds to press Ctrl-C to abort."
460               (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
461             fi
462         fi
463         if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
464             OUT="darwin64-ppc-cc"
465         else
466             OUT="darwin-ppc-cc"
467         fi ;;
468   i?86-apple-darwin*)
469         ISA64=`(sysctl -n hw.optional.x86_64) 2>/dev/null`
470         if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
471             echo "WARNING! If you wish to build 64-bit library, then you have to"
472             echo "         invoke 'KERNEL_BITS=64 $THERE/config $options'."
473             if [ "$DRYRUN" = "false" -a -t 1 ]; then
474               echo "         You have about 5 seconds to press Ctrl-C to abort."
475               (trap "stty `stty -g`; exit 1" 2; stty -icanon min 0 time 50; read waste; exit 0) <&1 || exit
476             fi
477         fi
478         if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
479             OUT="darwin64-x86_64-cc"
480         else
481             OUT="darwin-i386-cc"
482         fi ;;
483   x86_64-apple-darwin*)
484         if [ "$KERNEL_BITS" = "32" ]; then
485             OUT="darwin-i386-cc"
486         else
487             OUT="darwin64-x86_64-cc"
488         fi ;;
489   armv6+7-*-iphoneos)
490         __CNF_CFLAGS="$__CNF_CFLAGS -arch armv6 -arch armv7"
491         __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch armv6 -arch armv7"
492         OUT="iphoneos-cross" ;;
493   *-*-iphoneos)
494         __CNF_CFLAGS="$__CNF_CFLAGS -arch ${MACHINE}"
495         __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch ${MACHINE}"
496         OUT="iphoneos-cross" ;;
497   arm64-*-iphoneos|*-*-ios64)
498         OUT="ios64-cross" ;;
499   alpha-*-linux2)
500         ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo`
501         OUT="linux-alpha-$CC"
502         if [ "$CC" = "gcc" ]; then
503             case ${ISA:-generic} in
504             EV5|EV45)           __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev5"
505                                 __CNF_CXXFLAGS="$__CNF_CFLAGS -mcpu=ev5";;
506             EV56|PCA56)         __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev56"
507                                 __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mcpu=ev56";;
508             *)                  __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev6"
509                                 __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mcpu=ev6";;
510             esac
511         fi
512         ;;
513   ppc64-*-linux2)
514         if [ -z "$KERNEL_BITS" ]; then
515             echo "WARNING! If you wish to build 64-bit library, then you have to"
516             echo "         invoke '$THERE/Configure linux-ppc64' *manually*."
517             if [ "$DRYRUN" = "false" -a -t 1 ]; then
518                 echo "         You have about 5 seconds to press Ctrl-C to abort."
519                 (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
520             fi
521         fi
522         if [ "$KERNEL_BITS" = "64" ]; then
523             OUT="linux-ppc64"
524         else
525             OUT="linux-ppc"
526             if (echo "__LP64__" | gcc -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null); then
527                 :;
528             else
529                 __CNF_CFLAGS="$__CNF_CFLAGS -m32"
530                 __CNF_CXXFLAGS="$__CNF_CXXFLAGS -m32"
531             fi
532         fi
533         ;;
534   ppc64le-*-linux2) OUT="linux-ppc64le" ;;
535   ppc-*-linux2) OUT="linux-ppc" ;;
536   mips64*-*-linux2)
537         echo "WARNING! If you wish to build 64-bit library, then you have to"
538         echo "         invoke '$THERE/Configure linux64-mips64' *manually*."
539         if [ "$DRYRUN" = "false" -a -t 1 ]; then
540             echo "         You have about 5 seconds to press Ctrl-C to abort."
541             (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
542         fi
543         OUT="linux-mips64"
544         ;;
545   mips*-*-linux2) OUT="linux-mips32" ;;
546   ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
547   ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
548   pentium-*-vxworks*) OUT="vxworks-pentium" ;;
549   simlinux-*-vxworks*) OUT="vxworks-simlinux" ;;
550   mips-*-vxworks*) OUT="vxworks-mips";;
551   e2k-*-linux*) OUT="linux-generic64 -DL_ENDIAN" ;;
552   ia64-*-linux?) OUT="linux-ia64" ;;
553   sparc64-*-linux2)
554         echo "WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI"
555         echo "         and wish to build 64-bit library, then you have to"
556         echo "         invoke '$THERE/Configure linux64-sparcv9' *manually*."
557         if [ "$DRYRUN" = "false" -a -t 1 ]; then
558           echo "          You have about 5 seconds to press Ctrl-C to abort."
559           (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
560         fi
561         OUT="linux-sparcv9" ;;
562   sparc-*-linux2)
563         KARCH=`awk '/^type/{print$3;exit(0);}' /proc/cpuinfo`
564         case ${KARCH:-sun4} in
565         sun4u*) OUT="linux-sparcv9" ;;
566         sun4m)  OUT="linux-sparcv8" ;;
567         sun4d)  OUT="linux-sparcv8" ;;
568         *)      OUT="linux-generic32";
569                 __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
570         esac ;;
571   parisc*-*-linux2)
572         # 64-bit builds under parisc64 linux are not supported and
573         # compiler is expected to generate 32-bit objects...
574         CPUARCH=`awk '/cpu family/{print substr($5,1,3); exit(0);}' /proc/cpuinfo`
575         CPUSCHEDULE=`awk '/^cpu.[       ]*: PA/{print substr($3,3); exit(0);}' /proc/cpuinfo`
576
577         # ??TODO ??  Model transformations
578         # 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
579         #    assuming no further arch. identification will ever be used by GCC.
580         # 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
581         # 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
582         #    for these chips in the future.
583         #         PA7300LC -> 7100LC (1.1)
584         #         PA8200   -> 8000   (2.0)
585         #         PA8500   -> 8000   (2.0)
586         #         PA8600   -> 8000   (2.0)
587
588         CPUSCHEDULE=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8.00/8000/'`
589         # Finish Model transformations
590
591         __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN"
592         __CNF_CFLAGS="$__CNF_CFLAGS -mschedule=$CPUSCHEDULE -march=$CPUARCH"
593         __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mschedule=$CPUSCHEDULE -march=$CPUARCH"
594         OUT="linux-generic32" ;;
595   armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
596   armv[7-9]*-*-linux2) OUT="linux-armv4"
597                        __CNF_CFLAGS="$__CNF_CFLAGS -march=armv7-a"
598                        __CNF_CXXFLAGS="$__CNF_CXXFLAGS -march=armv7-a"
599                        ;;
600   arm*-*-linux2) OUT="linux-armv4" ;;
601   aarch64-*-linux2) OUT="linux-aarch64" ;;
602   sh*b-*-linux2) OUT="linux-generic32";
603                  __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
604   sh*-*-linux2)  OUT="linux-generic32";
605                  __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DL_ENDIAN" ;;
606   m68k*-*-linux2) OUT="linux-generic32";
607                   __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
608   s390-*-linux2) OUT="linux-generic32";
609                  __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
610   s390x-*-linux2)
611         # To be uncommented when glibc bug is fixed, see Configure...
612         #if egrep -e '^features.* highgprs' /proc/cpuinfo >/dev/null ; then
613         #  echo "WARNING! If you wish to build \"highgprs\" 32-bit library, then you"
614         #  echo "         have to invoke './Configure linux32-s390x' *manually*."
615         #  if [ "$DRYRUN" = "false" -a -t -1 ]; then
616         #    echo "         You have about 5 seconds to press Ctrl-C to abort."
617         #    (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
618         #  fi
619         #fi
620         OUT="linux64-s390x"
621         ;;
622   x86_64-*-linux?)
623         if $CC -dM -E -x c /dev/null 2>&1 | grep -q ILP32 > /dev/null; then
624             OUT="linux-x32"
625         else
626             OUT="linux-x86_64"
627         fi ;;
628   *86-*-linux2)
629         # On machines where the compiler understands -m32, prefer a
630         # config target that uses it
631         if $CC -m32 -E -x c /dev/null > /dev/null 2>&1; then
632             OUT="linux-x86"
633         else
634             OUT="linux-elf"
635         fi ;;
636   *86-*-linux1) OUT="linux-aout" ;;
637   *-*-linux?) OUT="linux-generic32" ;;
638   sun4[uv]*-*-solaris2)
639         OUT="solaris-sparcv9-$CC"
640         ISA64=`(isainfo) 2>/dev/null | grep sparcv9`
641         if [ "$ISA64" != "" -a "$KERNEL_BITS" = "" ]; then
642             if [ "$CC" = "cc" -a $CCVER -ge 50 ]; then
643                 echo "WARNING! If you wish to build 64-bit library, then you have to"
644                 echo "         invoke '$THERE/Configure solaris64-sparcv9-cc' *manually*."
645                 if [ "$DRYRUN" = "false" -a -t 1 ]; then
646                   echo "         You have about 5 seconds to press Ctrl-C to abort."
647                   (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
648                 fi
649             elif [ "$CC" = "gcc" -a "$GCC_ARCH" = "-m64" ]; then
650                 # $GCC_ARCH denotes default ABI chosen by compiler driver
651                 # (first one found on the $PATH). I assume that user
652                 # expects certain consistency with the rest of his builds
653                 # and therefore switch over to 64-bit. <appro>
654                 OUT="solaris64-sparcv9-gcc"
655                 echo "WARNING! If you wish to build 32-bit library, then you have to"
656                 echo "         invoke '$THERE/Configure solaris-sparcv9-gcc' *manually*."
657                 if [ "$DRYRUN" = "false" -a -t 1 ]; then
658                   echo "         You have about 5 seconds to press Ctrl-C to abort."
659                   (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
660                 fi
661             elif [ "$GCC_ARCH" = "-m32" ]; then
662                 echo "NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI"
663                 echo "        and wish to build 64-bit library, then you have to"
664                 echo "        invoke '$THERE/Configure solaris64-sparcv9-gcc' *manually*."
665                 if [ "$DRYRUN" = "false" -a -t 1 ]; then
666                   echo "         You have about 5 seconds to press Ctrl-C to abort."
667                   (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
668                 fi
669             fi
670         fi
671         if [ "$ISA64" != "" -a "$KERNEL_BITS" = "64" ]; then
672             OUT="solaris64-sparcv9-$CC"
673         fi
674         ;;
675   sun4m-*-solaris2)     OUT="solaris-sparcv8-$CC" ;;
676   sun4d-*-solaris2)     OUT="solaris-sparcv8-$CC" ;;
677   sun4*-*-solaris2)     OUT="solaris-sparcv7-$CC" ;;
678   *86*-*-solaris2)
679         ISA64=`(isainfo) 2>/dev/null | grep amd64`
680         if [ "$ISA64" != "" -a ${KERNEL_BITS:-64} -eq 64 ]; then
681             OUT="solaris64-x86_64-$CC"
682         else
683             OUT="solaris-x86-$CC"
684             if [ `uname -r | sed -e 's/5\.//'` -lt 10 ]; then
685                 options="$options no-sse2"
686             fi
687         fi
688         ;;
689   *-*-sunos4)           OUT="sunos-$CC" ;;
690
691   *86*-*-bsdi4)         OUT="BSD-x86-elf"; options="$options no-sse2";
692                         __CNF_LDFLAGS="$__CNF_LDFLAGS -ldl" ;;
693   alpha*-*-*bsd*)       OUT="BSD-generic64";
694                         __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DL_ENDIAN" ;;
695   powerpc64-*-*bsd*)    OUT="BSD-generic64";
696                         __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
697   sparc64-*-*bsd*)      OUT="BSD-sparc64" ;;
698   ia64-*-*bsd*)         OUT="BSD-ia64" ;;
699   x86_64-*-dragonfly*)  OUT="BSD-x86_64" ;;
700   amd64-*-*bsd*)        OUT="BSD-x86_64" ;;
701   *86*-*-*bsd*)         # mimic ld behaviour when it's looking for libc...
702                         if [ -L /usr/lib/libc.so ]; then        # [Free|Net]BSD
703                             libc=/usr/lib/libc.so
704                         else                                    # OpenBSD
705                             # ld searches for highest libc.so.* and so do we
706                             libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
707                         fi
708                         case "`(file -L $libc) 2>/dev/null`" in
709                         *ELF*)  OUT="BSD-x86-elf" ;;
710                         *)      OUT="BSD-x86"; options="$options no-sse2" ;;
711                         esac ;;
712   *-*-*bsd*)            OUT="BSD-generic32" ;;
713
714   x86_64-*-haiku)       OUT="haiku-x86_64" ;;
715   *-*-haiku)            OUT="haiku-x86" ;;
716
717   *-*-osf)              OUT="osf1-alpha-cc" ;;
718   *-*-tru64)            OUT="tru64-alpha-cc" ;;
719   *-*-[Uu]nix[Ww]are7)
720         if [ "$CC" = "gcc" ]; then
721           OUT="unixware-7-gcc" ; options="$options no-sse2"
722         else
723           OUT="unixware-7" ; options="$options no-sse2"
724           __CNF_CPPFLAGS="$__CNF_CPPFLAGS -D__i386__"
725         fi
726         ;;
727   *-*-[Uu]nix[Ww]are20*) OUT="unixware-2.0"; options="$options no-sse2 no-sha512" ;;
728   *-*-[Uu]nix[Ww]are21*) OUT="unixware-2.1"; options="$options no-sse2 no-sha512" ;;
729   *-*-vos)
730         options="$options no-threads no-shared no-asm no-dso"
731         EXE=".pm"
732         OUT="vos-$CC" ;;
733   BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
734   *-hpux1*)
735         if [ $CC = "gcc" -a $GCC_BITS = "64" ]; then
736             OUT="hpux64-parisc2-gcc"
737         fi
738         [ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITS) 2>/dev/null`
739         KERNEL_BITS=${KERNEL_BITS:-32}
740         CPU_VERSION=`(getconf CPU_VERSION) 2>/dev/null`
741         CPU_VERSION=${CPU_VERSION:-0}
742         # See <sys/unistd.h> for further info on CPU_VERSION.
743         if   [ $CPU_VERSION -ge 768 ]; then     # IA-64 CPU
744              if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
745                 OUT="hpux64-ia64-cc"
746              else
747                 OUT="hpux-ia64-cc"
748              fi
749         elif [ $CPU_VERSION -ge 532 ]; then     # PA-RISC 2.x CPU
750              # PA-RISC 2.0 is no longer supported as separate 32-bit
751              # target. This is compensated for by run-time detection
752              # in most critical assembly modules and taking advantage
753              # of 2.0 architecture in PA-RISC 1.1 build.
754              OUT=${OUT:-"hpux-parisc1_1-${CC}"}
755              if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
756                 echo "WARNING! If you wish to build 64-bit library then you have to"
757                 echo "         invoke '$THERE/Configure hpux64-parisc2-cc' *manually*."
758                 if [ "$DRYRUN" = "false" -a -t 1 ]; then
759                   echo "         You have about 5 seconds to press Ctrl-C to abort."
760                   (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
761                 fi
762              fi
763         elif [ $CPU_VERSION -ge 528 ]; then     # PA-RISC 1.1+ CPU
764              OUT="hpux-parisc1_1-${CC}"
765         elif [ $CPU_VERSION -ge 523 ]; then     # PA-RISC 1.0 CPU
766              OUT="hpux-parisc-${CC}"
767         else                                    # Motorola(?) CPU
768              OUT="hpux-$CC"
769         fi
770         __CNF_CPPFLAGS="$__CNF_CPPFLAGS -D_REENTRANT" ;;
771   *-hpux)       OUT="hpux-parisc-$CC" ;;
772   *-aix)
773         [ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITMODE) 2>/dev/null`
774         KERNEL_BITS=${KERNEL_BITS:-32}
775         OBJECT_MODE=${OBJECT_MODE:-32}
776         if [ "$CC" = "gcc" ]; then
777             OUT="aix-gcc"
778           if [ $OBJECT_MODE -eq 64 ]; then
779             echo 'Your $OBJECT_MODE was found to be set to 64'
780             OUT="aix64-gcc"
781           fi
782         elif [ $OBJECT_MODE -eq 64 ]; then
783             echo 'Your $OBJECT_MODE was found to be set to 64'
784             OUT="aix64-cc"
785         else
786             OUT="aix-cc"
787             if [ $KERNEL_BITS -eq 64 ]; then
788                 echo "WARNING! If you wish to build 64-bit kit, then you have to"
789                 echo "         invoke '$THERE/Configure aix64-cc' *manually*."
790                 if [ "$DRYRUN" = "false" -a -t 1 ]; then
791                     echo "         You have ~5 seconds to press Ctrl-C to abort."
792                     (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
793                 fi
794             fi
795         fi
796         if (lsattr -E -O -l `lsdev -c processor|awk '{print$1;exit}'` | grep -i powerpc) >/dev/null 2>&1; then
797             :   # this applies even to Power3 and later, as they return PowerPC_POWER[345]
798         else
799             options="$options no-asm"
800         fi
801         ;;
802   # these are all covered by the catchall below
803   i[3456]86-*-cygwin) OUT="Cygwin-x86" ;;
804   *-*-cygwin) OUT="Cygwin-${MACHINE}" ;;
805   x86-*-android|i?86-*-android) OUT="android-x86" ;;
806   armv[7-9]*-*-android)
807       OUT="android-armeabi"
808       __CNF_CFLAGS="$__CNF_CFLAGS -march=armv7-a"
809       __CNF_CXXFLAGS="$__CNF_CXXFLAGS -march=armv7-a";;
810   arm*-*-android) OUT="android-armeabi" ;;
811   *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
812 esac
813
814 # NB: This atalla support has been superseded by the ENGINE support
815 # That contains its own header and definitions anyway. Support can
816 # be enabled or disabled on any supported platform without external
817 # headers, eg. by adding the "hw-atalla" switch to ./config or
818 # perl Configure
819 #
820 # See whether we can compile Atalla support
821 #if [ -f /usr/include/atasi.h ]
822 #then
823 #  __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DATALLA"
824 #fi
825
826 if [ -n "$CONFIG_OPTIONS" ]; then
827   options="$options $CONFIG_OPTIONS"
828 fi
829
830 # gcc < 2.8 does not support -march=ultrasparc
831 if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
832 then
833   echo "WARNING! Falling down to 'solaris-sparcv8-gcc'."
834   echo "         Upgrade to gcc-2.8 or later."
835   sleep 5
836   OUT=solaris-sparcv8-gcc
837 fi
838 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
839 then
840   echo "WARNING! Falling down to 'linux-sparcv8'."
841   echo "         Upgrade to gcc-2.8 or later."
842   sleep 5
843   OUT=linux-sparcv8
844 fi
845
846 case "$GUESSOS" in
847   i386-*) options="$options 386" ;;
848 esac
849
850 if [ -z "$OUT" ]; then
851   OUT="$CC"
852 fi
853
854 if [ ".$PERL" = . ] ; then
855         for i in . `echo $PATH | sed 's/:/ /g'`; do
856                 if [ -f "$i/perl5$EXE" ] ; then
857                         PERL="$i/perl5$EXE"
858                         break;
859                 fi;
860         done
861 fi
862
863 if [ ".$PERL" = . ] ; then
864         for i in . `echo $PATH | sed 's/:/ /g'`; do
865                 if [ -f "$i/perl$EXE" ] ; then
866                         if "$i/perl$EXE" -e 'exit($]<5.0)'; then
867                                 PERL="$i/perl$EXE"
868                                 break;
869                         fi;
870                 fi;
871         done
872 fi
873
874 if [ ".$PERL" = . ] ; then
875         echo "You need Perl 5."
876         exit 1
877 fi
878
879 # run Configure to check to see if we need to specify the
880 # compiler for the platform ... in which case we add it on
881 # the end ... otherwise we leave it off
882
883 $PERL $THERE/Configure LIST | grep "$OUT-$CC" > /dev/null
884 if [ $? = "0" ]; then
885   OUT="$OUT-$CC"
886 fi
887
888 OUT="$OUT"
889
890 if [ "$OUT" = "darwin64-x86_64-cc" ]; then
891     echo "WARNING! If you wish to build 32-bit libraries, then you have to"
892     echo "         invoke 'KERNEL_BITS=32 $THERE/config $options'."
893 fi
894
895 if $PERL $THERE/Configure LIST | grep "$OUT" > /dev/null; then
896   if [ "$VERBOSE" = "true" ]; then
897     echo /usr/bin/env \
898          __CNF_CPPDEFINES="'$__CNF_CPPDEFINES'" \
899          __CNF_CPPINCLUDES="'$__CNF_CPPINCLUDES'" \
900          __CNF_CPPFLAGS="'$__CNF_CPPFLAGS'" \
901          __CNF_CFLAGS="'$__CNF_CFLAGS'" \
902          __CNF_CXXFLAGS="'$__CNF_CXXFLAGS'" \
903          __CNF_LDFLAGS="'$__CNF_LDFLAGS'" \
904          __CNF_LDLIBS="'$__CNF_LDLIBS'" \
905          $PERL $THERE/Configure $OUT $options
906   fi
907   if [ "$DRYRUN" = "false" ]; then
908     # eval to make sure quoted options, possibly with spaces inside,
909     # are treated right
910     eval /usr/bin/env \
911          __CNF_CPPDEFINES="'$__CNF_CPPDEFINES'" \
912          __CNF_CPPINCLUDES="'$__CNF_CPPINCLUDES'" \
913          __CNF_CPPFLAGS="'$__CNF_CPPFLAGS'" \
914          __CNF_CFLAGS="'$__CNF_CFLAGS'" \
915          __CNF_CXXFLAGS="'$__CNF_CXXFLAGS'" \
916          __CNF_LDFLAGS="'$__CNF_LDFLAGS'" \
917          __CNF_LDLIBS="'$__CNF_LDLIBS'" \
918          $PERL $THERE/Configure $OUT $options
919   fi
920 else
921   echo "This system ($OUT) is not supported. See file INSTALL for details."
922   exit 1
923 fi
924
925 # Do not add anothing from here on, so we don't lose the Configure exit code
926 )