3 # OpenSSL config: determine the operating system and run ./Configure
5 # "config -h" for usage information.
7 # this is a merge of minarch and GuessOS from the Apache Group.
8 # Originally written by Tim Hudson <tjh@cryptsoft.com>.
10 # Original Apache Group comments on GuessOS
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.
20 # Be as similar to the output of config.guess/config.sub
23 # First get uname entries that we use below
25 MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
26 RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
27 SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown"
28 VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
30 # Now test for ISC and SCO, since it is has a braindamaged uname.
32 # We need to work around FreeBSD 1.1.5.1
34 XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
35 if [ "x$XREL" != "x" ]; then
36 if [ -f /etc/kconfig ]; then
39 echo "${MACHINE}-whatever-isc4"; exit 0
45 echo "whatever-whatever-sco3"; exit 0
48 echo "whatever-whatever-sco5"; exit 0
51 if [ "x$VERSION" = "x2.1.1" ]; then
52 echo "${MACHINE}-whatever-unixware211"; exit 0
54 echo "${MACHINE}-whatever-unixware2"; exit 0
58 echo "whatever-whatever-unixware1"; exit 0
63 # Now we simply scan though... In most cases, the SYSTEM info is enough
65 case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
67 echo "m68k-apple-aux3"; exit 0
71 echo "${MACHINE}-ibm-aix"; exit 0
75 echo "${MACHINE}-dg-dgux"; exit 0
79 echo "${MACHINE}-hi-hiux"; exit 0
83 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
86 echo "${MACHINE}-hp-hpux11"; exit 0
89 echo "${MACHINE}-hp-hpux10"; exit 0
92 echo "${MACHINE}-hp-hpux"; exit 0
98 echo "mips2-sgi-irix"; exit 0
102 echo "mips3-sgi-irix"; exit 0
106 echo "mips4-sgi-irix64"; exit 0
110 echo "${MACHINE}-whatever-linux2"; exit 0
114 echo "${MACHINE}-whatever-linux1"; exit 0
118 echo "${MACHINE}-lynx-lynxos"; exit 0
121 BSD/OS:4.*) # BSD/OS always says 386
122 echo "i486-whatever-bsdi4"; exit 0
125 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
126 case `/sbin/sysctl -n hw.model` in
128 echo "i586-whatever-bsdi"; exit 0
131 echo "i386-whatever-bsdi"; exit 0
137 echo "${MACHINE}-whatever-bsdi"; exit 0
141 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
142 MACH=`sysctl -n hw.model`
145 *386* ) MACH="i386" ;;
146 *486* ) MACH="i486" ;;
147 Pentium\ II*) MACH="i686" ;;
148 Pentium* ) MACH="i586" ;;
149 Alpha* ) MACH="alpha" ;;
150 * ) MACH="$MACHINE" ;;
153 i[0-9]86 ) ARCH="pc" ;;
155 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
159 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
163 echo "${MACHINE}-whatever-netbsd"; exit 0
167 echo "${MACHINE}-whatever-openbsd"; exit 0
171 echo "${MACHINE}-dec-osf"; exit 0
177 echo "${MACHINE}-qssl-qnx32"
180 echo "${MACHINE}-qssl-qnx"
187 echo "i860-intel-osf1"; exit 0
191 echo "${MACHINE}-sun-solaris2"; exit 0
195 echo "${MACHINE}-sun-sunos4"; exit 0
199 echo "${MACHINE}-whatever-sysv4"; exit 0
203 echo "${MACHINE}-whatever-sysv4"; exit 0
207 echo "${MACHINE}-whatever-sysv4"; exit 0
210 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
211 echo "i486-ncr-sysv4"; exit 0
215 echo "${MACHINE}-unknown-ultrix"; exit 0
219 echo "${MACHINE}-siemens-sysv4"; exit 0
223 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
227 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
231 echo "${MACHINE}-ncr-sysv4"; exit 0
235 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
241 # Ugg. These are all we can determine by what we know about
242 # the output of uname. Be more creative:
245 # Do the Apollo stuff first. Here, we just simply assume
246 # that the existance of the /usr/apollo directory is proof
248 if [ -d /usr/apollo ]; then
249 echo "whatever-apollo-whatever"
254 ISNEXT=`hostinfo 2>/dev/null`
257 echo "whatever-next-nextstep3.3"; exit 0
260 echo "whatever-next-nextstep"; exit 0
264 # At this point we gone through all the one's
267 echo "${MACHINE}-whatever-${SYSTEM}"
271 # ---------------------------------------------------------------------------
272 # this is where the translation occurs into SSLeay terms
273 # ---------------------------------------------------------------------------
279 # pick up any command line args to config
283 -d*) PREFIX="debug-";;
285 -h*) TEST="true"; cat <<EOF
286 Usage: config [options]
287 -d Add a debug- prefix to machine choice.
288 -t Test mode, do not run the Configure perl script.
291 Any other text will be passed to the Configure perl script.
292 See INSTALL for instructions.
296 *) options=$options" $i" ;;
300 # figure out if gcc is available and if so we use it otherwise
301 # we fallback to whatever cc does on the system
302 GCCVER=`(gcc --version) 2>/dev/null`
303 if [ "$GCCVER" != "" ]; then
305 # then strip off whatever prefix Cygnus prepends the number with...
306 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
307 # peak single digit before and after first dot, e.g. 2.95.1 gives 29
308 GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
313 if [ "$SYSTEM" = "SunOS" ]; then
314 # assume output is "blah-blah C x.x"
315 CCVER=`(cc -V 2>&1) 2>/dev/null | \
316 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
317 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
319 if [ $CCVER -gt 40 ]; then
320 CC=cc # overrides gcc!!!
321 if [ $CCVER -eq 50 ]; then
322 echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
323 echo " patch #107357-01 or later applied."
326 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
334 # read the output of the embedded GuessOS
337 echo Operating system: $GUESSOS
339 # now map the output into SSLeay terms ... really should hack into the
340 # script above so we end up with values in vars but that would take
341 # more time that I want to waste at the moment
343 alpha-*-linux2) OUT="alpha-gcc" ;;
344 ppc-*-linux2) OUT="linux-ppc" ;;
345 mips-*-linux?) OUT="linux-mips" ;;
347 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
349 if [ $CPU -ge 4000 ]; then
350 options="$options -mips2"
355 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
357 if [ $CPU -ge 5000 ]; then
358 options="$options -mips4"
360 options="$options -mips3"
365 echo "WARNING! If you wish to build 64-bit library, then you have to"
366 echo " invoke './Configre irix64-mips4-$CC' *manually*."
367 echo " Type Ctrl-C if you don't want to continue."
368 read waste < /dev/tty
369 options="$options -mips4"
373 #Before we can uncomment following lines we have to wait at least
374 #till 64-bit glibc for SPARC is operational:-(
375 #echo "WARNING! If you wish to build 64-bit library, then you have to"
376 #echo " invoke './Configure linux64-sparcv9' *manually*."
377 #echo " Type Ctrl-C if you don't want to continue."
378 #read waste < /dev/tty
379 OUT="linux-sparcv9" ;;
381 KARCH=`awk '/type/{print$3}' /proc/cpuinfo`
382 case ${KARCH:-sun4} in
383 sun4u*) OUT="linux-sparcv9" ;;
384 sun4m) OUT="linux-sparcv8" ;;
385 sun4d) OUT="linux-sparcv8" ;;
386 *) OUT="linux-sparcv7" ;;
388 *-*-linux2) OUT="linux-elf" ;;
389 *-*-linux1) OUT="linux-aout" ;;
391 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
392 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
393 echo "WARNING! If you wish to build 64-bit library, then you have to"
394 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
395 echo " Type Ctrl-C if you don't want to continue."
396 read waste < /dev/tty
398 OUT="solaris-sparcv9-$CC" ;;
399 sun4m-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
400 sun4d-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
401 sun4*-sun-solaris2) OUT="solaris-sparcv7-$CC" ;;
402 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
403 *-*-sunos4) OUT="sunos-$CC" ;;
404 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
405 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
406 *-freebsd[1-2]*) OUT="FreeBSD" ;;
407 *86*-*-netbsd) OUT="NetBSD-x86" ;;
408 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
409 *-*-netbsd) OUT="NetBSD-sparc" ;;
410 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
411 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
412 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
413 *-*-openbsd) OUT="OpenBSD" ;;
414 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
415 *-*-osf) OUT="alpha-cc" ;;
416 *-*-unixware*) OUT="unixware-2.0" ;;
417 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
418 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
419 *-siemens-sysv4) OUT="SINIX" ;;
420 # these are all covered by the catchall below
421 # *-hpux*) OUT="hpux-$CC" ;;
422 # *-aix) OUT="aix-$CC" ;;
423 # *-dgux) OUT="dgux" ;;
424 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
427 # gcc < 2.8 does not support -mcpu=ultrasparc
428 if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
430 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
432 OUT=solaris-sparcv9-gcc27
434 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
436 echo "WARNING! Falling down to 'linux-sparcv8'."
437 echo " Upgrade to gcc-2.8 or later."
441 if [ "$OUT" = "i86pc-sun-solaris2" ]
443 ASM=`as -V /dev/null 2>&1`
446 *) options="$options no-asm" ; echo "WARNING: You need the GNU assembler to use OpenSSL assembler code." ; echo "Sun as is not supported on Solaris x86." ;;
451 i386-*) options="$options 386" ;;
454 for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
456 if [ ! -d crypto/$i ]
458 options="$options no-$i"
462 if [ -z "$OUT" ]; then
466 if [ ".$PERL" = . ] ; then
467 for i in . `echo $PATH | sed 's/:/ /g'`; do
468 if [ -f "$i/perl5" ] ; then
475 if [ ".$PERL" = . ] ; then
476 for i in . `echo $PATH | sed 's/:/ /g'`; do
477 if [ -f "$i/perl" ] ; then
478 if "$i/perl" -e 'exit($]<5.0)'; then
486 if [ ".$PERL" = . ] ; then
487 echo "You need Perl 5."
491 # run Configure to check to see if we need to specify the
492 # compiler for the platform ... in which case we add it on
493 # the end ... otherwise we leave it off
495 $PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
496 if [ $? = "0" ]; then
502 $PERL ./Configure 2>&1 | grep "$OUT" > /dev/null
503 if [ $? = "0" ]; then
504 echo Configuring for $OUT
506 if [ "$TEST" = "true" ]; then
507 echo $PERL ./Configure $OUT $options
509 $PERL ./Configure $OUT $options
512 echo "This system ($OUT) is not supported. See file INSTALL for details."