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