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-hpux10."; exit 0
89 echo "${MACHINE}-hp-hpux"; exit 0
95 echo "${MACHINE}-sgi-irix"; exit 0
99 echo "${MACHINE}-sgi-irix64"; exit 0
103 echo "${MACHINE}-whatever-linux2"; exit 0
107 echo "${MACHINE}-whatever-linux1"; exit 0
111 echo "${MACHINE}-lynx-lynxos"; exit 0
114 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
115 echo "i486-whatever-bsdi"; exit 0
119 echo "${MACHINE}-whatever-bsdi"; exit 0
123 echo "${MACHINE}-whatever-freebsd3"; exit 0
127 case `sysctl -n hw.model` in
129 echo "i586-whatever-freebsd"; exit 0
132 echo "i386-whatever-freebsd"; exit 0
138 echo "${MACHINE}-whatever-freebsd"; exit 0
142 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
146 echo "${MACHINE}-whatever-netbsd"; exit 0
150 echo "${MACHINE}-whatever-openbsd"; exit 0
154 echo "${MACHINE}-dec-osf"; exit 0
160 echo "${MACHINE}-qssl-qnx32"
163 echo "${MACHINE}-qssl-qnx"
170 echo "i860-intel-osf1"; exit 0
174 echo "${MACHINE}-sun-solaris2"; exit 0
178 echo "${MACHINE}-sun-sunos4"; exit 0
182 echo "${MACHINE}-whatever-sysv4"; exit 0
186 echo "${MACHINE}-whatever-sysv4"; exit 0
190 echo "${MACHINE}-whatever-sysv4"; exit 0
193 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
194 echo "i486-ncr-sysv4"; exit 0
198 echo "${MACHINE}-unknown-ultrix"; exit 0
202 echo "${MACHINE}-sni-sysv4"; exit 0
206 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
210 echo "${MACHINE}-ncr-sysv4"; exit 0
214 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
220 # Ugg. These are all we can determine by what we know about
221 # the output of uname. Be more creative:
224 # Do the Apollo stuff first. Here, we just simply assume
225 # that the existance of the /usr/apollo directory is proof
227 if [ -d /usr/apollo ]; then
228 echo "whatever-apollo-whatever"
233 ISNEXT=`hostinfo 2>/dev/null`
236 echo "whatever-next-nextstep"; exit 0
240 # At this point we gone through all the one's
243 echo "${MACHINE}-whatever-${SYSTEM}|${RELEASE}|${VERSION}"
247 # ---------------------------------------------------------------------------
248 # this is where the translation occurs into SSLeay terms
249 # ---------------------------------------------------------------------------
256 # pick up any command line args to config
260 -d*) PREFIX="debug-";;
261 -v*) VERBOSE="true";;
263 -h*) TEST="true"; cat <<EOF
264 Usage: config [options]
265 -d Add a debug- prefix to machine choice.
267 -t Test mode, do not run the Configure perl script.
270 Any other text will be passed to the Configure perl script.
271 Useful options include
272 no-asm Build with no assember code.
273 -Dxxx Add xxx define to compilation.
274 -Lxxx Add xxx library include path to build.
275 -lxxx Add xxx library to build.
279 *) options=$options" $i" ;;
283 # figure out if gcc is available and if so we use it otherwise
284 # we fallback to whatever cc does on the system
285 GCCVER=`(gcc -v) 2>&1`
286 if [ $? = "0" ]; then
292 # read the output of the embedded GuessOS
295 if [ "$VERBOSE" = "true" ]; then
296 echo GUESSOS $GUESSOS
299 # now map the output into SSLeay terms ... really should hack into the
300 # script above so we end up with values in vars but that would take
301 # more time that I want to waste at the moment
303 alpha-*-linux2) OUT="alpha-gcc" ;;
304 ppc-*-linux2) OUT="linux-ppc" ;;
305 *-*-linux2) OUT="linux-elf" ;;
306 *-*-linux1) OUT="linux-aout" ;;
307 sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;;
308 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
309 *-*-sunos4) OUT="sunos-$CC" ;;
310 *-freebsd3) OUT="FreeBSD-elf" ;;
311 *-freebsd) OUT="FreeBSD" ;;
312 *86*-*-netbsd) OUT="NetBSD-x86" ;;
313 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
314 *-*-netbsd) OUT="NetBSD-sparc" ;;
315 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
316 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
317 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
318 *-*-openbsd) OUT="OpenBSD" ;;
319 *-*-osf) OUT="alpha-cc" ;;
320 *-*-unixware*) OUT="unixware-2.0" ;;
321 *-sni-sysv4) OUT="SINIX" ;;
322 *-hpux*) OUT="hpux-$CC" ;;
323 # these are all covered by the catchall below
324 # *-aix) OUT="aix-$CC" ;;
325 # *-dgux) OUT="dgux" ;;
326 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
330 i386-*) options="$options 386" ;;
333 if [ -z "$OUT" ]; then
337 if [ ".$PERL" = . ] ; then
338 for i in . `echo $PATH | sed 's/:/ /g'`; do
339 if [ -f "$i/perl5" ] ; then
346 if [ ".$PERL" = . ] ; then
347 for i in . `echo $PATH | sed 's/:/ /g'`; do
348 if [ -f "$i/perl" ] ; then
349 if "$i/perl" -e 'exit($]<5.0)'; then
357 if [ ".$PERL" = . ] ; then
358 echo "You need Perl 5."
362 # run Configure to check to see if we need to specify the
363 # compiler for the platform ... in which case we add it on
364 # the end ... otherwise we leave it off
366 $PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
367 if [ $? = "0" ]; then
373 # at this point we have the answer ... which we could check again
374 # and then fallback to a vanilla SSLeay build but then this script
375 # wouldn't get updated
376 echo Configuring for $OUT
378 if [ "$TEST" = "true" ]; then
379 echo $PERL ./Configure $OUT $options
381 $PERL ./Configure $OUT $options