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
118 echo "${MACHINE}-whatever-bsdi4"; exit 0
121 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
122 echo "i486-whatever-bsdi"; exit 0
126 echo "${MACHINE}-whatever-bsdi"; exit 0
130 echo "${MACHINE}-whatever-freebsd3"; exit 0
134 case `sysctl -n hw.model` in
136 echo "i586-whatever-freebsd"; exit 0
139 echo "i386-whatever-freebsd"; exit 0
145 echo "${MACHINE}-whatever-freebsd"; exit 0
149 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
153 echo "${MACHINE}-whatever-netbsd"; exit 0
157 echo "${MACHINE}-whatever-openbsd"; exit 0
161 echo "${MACHINE}-dec-osf"; exit 0
167 echo "${MACHINE}-qssl-qnx32"
170 echo "${MACHINE}-qssl-qnx"
177 echo "i860-intel-osf1"; exit 0
181 echo "${MACHINE}-sun-solaris2"; exit 0
185 echo "${MACHINE}-sun-sunos4"; exit 0
189 echo "${MACHINE}-whatever-sysv4"; exit 0
193 echo "${MACHINE}-whatever-sysv4"; exit 0
197 echo "${MACHINE}-whatever-sysv4"; exit 0
200 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
201 echo "i486-ncr-sysv4"; exit 0
205 echo "${MACHINE}-unknown-ultrix"; exit 0
209 echo "${MACHINE}-siemens-sysv4"; exit 0
213 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
217 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
221 echo "${MACHINE}-ncr-sysv4"; exit 0
225 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
231 # Ugg. These are all we can determine by what we know about
232 # the output of uname. Be more creative:
235 # Do the Apollo stuff first. Here, we just simply assume
236 # that the existance of the /usr/apollo directory is proof
238 if [ -d /usr/apollo ]; then
239 echo "whatever-apollo-whatever"
244 ISNEXT=`hostinfo 2>/dev/null`
247 echo "whatever-next-nextstep3.3"; exit 0
250 echo "whatever-next-nextstep"; exit 0
254 # At this point we gone through all the one's
257 echo "${MACHINE}-whatever-${SYSTEM}"
261 # ---------------------------------------------------------------------------
262 # this is where the translation occurs into SSLeay terms
263 # ---------------------------------------------------------------------------
269 # pick up any command line args to config
273 -d*) PREFIX="debug-";;
275 -h*) TEST="true"; cat <<EOF
276 Usage: config [options]
277 -d Add a debug- prefix to machine choice.
278 -t Test mode, do not run the Configure perl script.
281 Any other text will be passed to the Configure perl script.
282 See INSTALL for instructions.
286 *) options=$options" $i" ;;
290 # figure out if gcc is available and if so we use it otherwise
291 # we fallback to whatever cc does on the system
292 GCCVER=`(gcc -v) 2>&1`
293 if [ $? = "0" ]; then
297 if [ "$SYSTEM" = "SunOS" ]
307 # read the output of the embedded GuessOS
310 echo Operating system: $GUESSOS
312 # now map the output into SSLeay terms ... really should hack into the
313 # script above so we end up with values in vars but that would take
314 # more time that I want to waste at the moment
316 alpha-*-linux2) OUT="alpha-gcc" ;;
317 ppc-*-linux2) OUT="linux-ppc" ;;
318 mips-*-linux?) OUT="linux-mips" ;;
319 sparc-*-linux2) OUT="linux-sparc" ;;
320 sparc64-*-linux2) OUT="linux-sparc64" ;;
321 *-*-linux2) OUT="linux-elf" ;;
322 *-*-linux1) OUT="linux-aout" ;;
323 sun4u-sun-solaris2) OUT="solaris-usparc-$CC" ;;
324 sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;;
325 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
326 *-*-sunos4) OUT="sunos-$CC" ;;
327 alpha*-*-freebsd3) OUT="FreeBSD-alpha" ;;
328 *-freebsd3) OUT="FreeBSD-elf" ;;
329 *-freebsd) OUT="FreeBSD" ;;
330 *86*-*-netbsd) OUT="NetBSD-x86" ;;
331 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
332 *-*-netbsd) OUT="NetBSD-sparc" ;;
333 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
334 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
335 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
336 *-*-openbsd) OUT="OpenBSD" ;;
337 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
338 *-*-osf) OUT="alpha-cc" ;;
339 *-*-unixware*) OUT="unixware-2.0" ;;
340 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
341 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
342 *-siemens-sysv4) OUT="SINIX" ;;
343 # these are all covered by the catchall below
344 # *-hpux*) OUT="hpux-$CC" ;;
345 # *-aix) OUT="aix-$CC" ;;
346 # *-dgux) OUT="dgux" ;;
347 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
350 # gcc < 2.8 does not support -mcpu=ultrasparc
351 if [ "$OUT" = solaris-usparc-gcc ]
353 GCCVERMAJOR="`echo $GCCVER | sed 's/.*version \([^.]*\).*/\1/`"
354 GCCVERMINOR="`echo $GCCVER | sed 's/.*version[^.]*\.\([^.]*\).*/\1/`"
355 echo "gcc version $GCCVERMAJOR.$GCCVERMINOR.x"
356 if [ $GCCVERMAJOR$GCCVERMINOR -lt 28 ]
358 OUT=solaris-usparc-oldgcc
363 i386-*) options="$options 386" ;;
366 for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 rsa sha
368 if [ ! -d crypto/$i ]
370 options="$options no-$i"
374 if [ -z "$OUT" ]; then
378 if [ ".$PERL" = . ] ; then
379 for i in . `echo $PATH | sed 's/:/ /g'`; do
380 if [ -f "$i/perl5" ] ; then
387 if [ ".$PERL" = . ] ; then
388 for i in . `echo $PATH | sed 's/:/ /g'`; do
389 if [ -f "$i/perl" ] ; then
390 if "$i/perl" -e 'exit($]<5.0)'; then
398 if [ ".$PERL" = . ] ; then
399 echo "You need Perl 5."
403 # run Configure to check to see if we need to specify the
404 # compiler for the platform ... in which case we add it on
405 # the end ... otherwise we leave it off
407 $PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
408 if [ $? = "0" ]; then
414 $PERL ./Configure 2>&1 | grep "$OUT" > /dev/null
415 if [ $? = "0" ]; then
416 echo Configuring for $OUT
418 if [ "$TEST" = "true" ]; then
419 echo $PERL ./Configure $OUT $options
421 $PERL ./Configure $OUT $options
424 echo "This system ($OUT) is not supported. See file INSTALL for details."