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 "${MACHINE}-sgi-irix"; exit 0
102 echo "${MACHINE}-sgi-irix64"; exit 0
106 echo "${MACHINE}-whatever-linux2"; exit 0
110 echo "${MACHINE}-whatever-linux1"; exit 0
114 echo "${MACHINE}-lynx-lynxos"; exit 0
117 BSD/OS:4.*) # BSD/OS always says 386
118 echo "i486-whatever-bsdi4"; exit 0
121 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
122 case `/sbin/sysctl -n hw.model` in
124 echo "i586-whatever-bsdi"; exit 0
127 echo "i386-whatever-bsdi"; exit 0
133 echo "${MACHINE}-whatever-bsdi"; exit 0
137 case `sysctl -n hw.model` in
139 echo "i586-whatever-freebsd"; exit 0
142 echo "i386-whatever-freebsd"; exit 0
148 echo "${MACHINE}-whatever-freebsd"; exit 0
152 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
156 echo "${MACHINE}-whatever-netbsd"; exit 0
160 echo "${MACHINE}-whatever-openbsd"; exit 0
164 echo "${MACHINE}-dec-osf"; exit 0
170 echo "${MACHINE}-qssl-qnx32"
173 echo "${MACHINE}-qssl-qnx"
180 echo "i860-intel-osf1"; exit 0
184 echo "${MACHINE}-sun-solaris2"; exit 0
188 echo "${MACHINE}-sun-sunos4"; exit 0
192 echo "${MACHINE}-whatever-sysv4"; exit 0
196 echo "${MACHINE}-whatever-sysv4"; exit 0
200 echo "${MACHINE}-whatever-sysv4"; exit 0
203 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
204 echo "i486-ncr-sysv4"; exit 0
208 echo "${MACHINE}-unknown-ultrix"; exit 0
212 echo "${MACHINE}-siemens-sysv4"; exit 0
216 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
220 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
224 echo "${MACHINE}-ncr-sysv4"; exit 0
228 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
234 # Ugg. These are all we can determine by what we know about
235 # the output of uname. Be more creative:
238 # Do the Apollo stuff first. Here, we just simply assume
239 # that the existance of the /usr/apollo directory is proof
241 if [ -d /usr/apollo ]; then
242 echo "whatever-apollo-whatever"
247 ISNEXT=`hostinfo 2>/dev/null`
250 echo "whatever-next-nextstep3.3"; exit 0
253 echo "whatever-next-nextstep"; exit 0
257 # At this point we gone through all the one's
260 echo "${MACHINE}-whatever-${SYSTEM}"
264 # ---------------------------------------------------------------------------
265 # this is where the translation occurs into SSLeay terms
266 # ---------------------------------------------------------------------------
272 # pick up any command line args to config
276 -d*) PREFIX="debug-";;
278 -h*) TEST="true"; cat <<EOF
279 Usage: config [options]
280 -d Add a debug- prefix to machine choice.
281 -t Test mode, do not run the Configure perl script.
284 Any other text will be passed to the Configure perl script.
285 See INSTALL for instructions.
289 *) options=$options" $i" ;;
293 # figure out if gcc is available and if so we use it otherwise
294 # we fallback to whatever cc does on the system
295 GCCVER=`(gcc --version) 2>/dev/null`
296 if [ "$GCCVER" != "" ]; then
298 # then strip off whatever prefix Cygnus prepends the number with...
299 GCCVER=`echo $GCCVER | sed 's/^[a-z]*\-//'`
300 # peak only digits before and after first dot, e.g. 2.95.1 gives 29
301 GCCVER=`echo $GCCVER | sed '/\([0-9]\)\.\([0-9]\).*/\1\2/'`
304 if [ "$SYSTEM" = "SunOS" ]
314 # read the output of the embedded GuessOS
317 echo Operating system: $GUESSOS
319 # now map the output into SSLeay terms ... really should hack into the
320 # script above so we end up with values in vars but that would take
321 # more time that I want to waste at the moment
323 alpha-*-linux2) OUT="alpha-gcc" ;;
324 ppc-*-linux2) OUT="linux-ppc" ;;
325 mips-*-linux?) OUT="linux-mips" ;;
327 #Before we uncomment following line we have to wait at least till
328 #64-bit glibc for SPARC is available:-(
329 #echo "WARNING! If you wish to build 64-bit library, then you have to"
330 #echo " invoke './Configure linux64-sparcv9' *manually*."
331 #echo " Type Ctrl-C if you don't want to continue."
332 #read waste < /dev/tty
333 OUT="linux-sparcv9" ;;
334 sparc-*-linux2) OUT="linux-sparc" ;;
335 KARCH=`awk '/type/{print$3}' /proc/cpuinfo`
336 case ${KARCH:-sun4} in
337 sun4u*) OUT="linux-sparcv9" ;;
338 sun4m) OUT="linux-sparcv8" ;;
339 sun4d) OUT="linux-sparcv8" ;;
340 *) OUT="linux-sparcv7" ;;
342 *-*-linux2) OUT="linux-elf" ;;
343 *-*-linux1) OUT="linux-aout" ;;
344 sun4u-sun-solaris2) OUT="solaris-usparc-$CC" ;;
345 sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;;
346 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
347 *-*-sunos4) OUT="sunos-$CC" ;;
348 alpha*-*-freebsd) OUT="FreeBSD-alpha" ;;
349 *-freebsd) OUT="FreeBSD" ;;
350 *86*-*-netbsd) OUT="NetBSD-x86" ;;
351 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
352 *-*-netbsd) OUT="NetBSD-sparc" ;;
353 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
354 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
355 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
356 *-*-openbsd) OUT="OpenBSD" ;;
357 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
358 *-*-osf) OUT="alpha-cc" ;;
359 *-*-unixware*) OUT="unixware-2.0" ;;
360 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
361 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
362 *-siemens-sysv4) OUT="SINIX" ;;
363 # these are all covered by the catchall below
364 # *-hpux*) OUT="hpux-$CC" ;;
365 # *-aix) OUT="aix-$CC" ;;
366 # *-dgux) OUT="dgux" ;;
367 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
370 # gcc < 2.8 does not support -mcpu=ultrasparc
371 if [ "$OUT" = solaris-usparc-gcc -a $GCCVER -lt 28 ]
373 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
374 OUT=solaris-usparc-oldgcc
376 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
378 echo "WARNING! Falling down to 'linux-sparcv8'."
379 echo " Upgrade to gcc-2.8 or later."
384 i386-*) options="$options 386" ;;
387 for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
389 if [ ! -d crypto/$i ]
391 options="$options no-$i"
395 if [ -z "$OUT" ]; then
399 if [ ".$PERL" = . ] ; then
400 for i in . `echo $PATH | sed 's/:/ /g'`; do
401 if [ -f "$i/perl5" ] ; then
408 if [ ".$PERL" = . ] ; then
409 for i in . `echo $PATH | sed 's/:/ /g'`; do
410 if [ -f "$i/perl" ] ; then
411 if "$i/perl" -e 'exit($]<5.0)'; then
419 if [ ".$PERL" = . ] ; then
420 echo "You need Perl 5."
424 # run Configure to check to see if we need to specify the
425 # compiler for the platform ... in which case we add it on
426 # the end ... otherwise we leave it off
428 $PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
429 if [ $? = "0" ]; then
435 $PERL ./Configure 2>&1 | grep "$OUT" > /dev/null
436 if [ $? = "0" ]; then
437 echo Configuring for $OUT
439 if [ "$TEST" = "true" ]; then
440 echo $PERL ./Configure $OUT $options
442 $PERL ./Configure $OUT $options
445 echo "This system ($OUT) is not supported. See file INSTALL for details."