Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
Ulf Möller | 5d3bb22 | 1999-04-22 19:23:56 +0000 | [diff] [blame] | 3 | # OpenSSL config: determine the operating system and run ./Configure |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 4 | # |
Ulf Möller | 5d3bb22 | 1999-04-22 19:23:56 +0000 | [diff] [blame] | 5 | # "config -h" for usage information. |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 6 | # |
Ulf Möller | 5d3bb22 | 1999-04-22 19:23:56 +0000 | [diff] [blame] | 7 | # this is a merge of minarch and GuessOS from the Apache Group. |
| 8 | # Originally written by Tim Hudson <tjh@cryptsoft.com>. |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 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 | # First get uname entries that we use below |
| 24 | |
| 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" |
| 29 | |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 30 | # Now test for ISC and SCO, since it is has a braindamaged uname. |
| 31 | # |
| 32 | # We need to work around FreeBSD 1.1.5.1 |
| 33 | ( |
| 34 | XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'` |
| 35 | if [ "x$XREL" != "x" ]; then |
| 36 | if [ -f /etc/kconfig ]; then |
| 37 | case "$XREL" in |
| 38 | 4.0|4.1) |
| 39 | echo "${MACHINE}-whatever-isc4"; exit 0 |
| 40 | ;; |
| 41 | esac |
| 42 | else |
| 43 | case "$XREL" in |
| 44 | 3.2v4.2) |
| 45 | echo "whatever-whatever-sco3"; exit 0 |
| 46 | ;; |
| 47 | 3.2v5.0*) |
| 48 | echo "whatever-whatever-sco5"; exit 0 |
| 49 | ;; |
| 50 | 4.2MP) |
| 51 | if [ "x$VERSION" = "x2.1.1" ]; then |
| 52 | echo "${MACHINE}-whatever-unixware211"; exit 0 |
| 53 | else |
| 54 | echo "${MACHINE}-whatever-unixware2"; exit 0 |
| 55 | fi |
| 56 | ;; |
| 57 | 4.2) |
| 58 | echo "whatever-whatever-unixware1"; exit 0 |
| 59 | ;; |
| 60 | esac |
| 61 | fi |
| 62 | fi |
| 63 | # Now we simply scan though... In most cases, the SYSTEM info is enough |
| 64 | # |
| 65 | case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in |
| 66 | A/UX:*) |
| 67 | echo "m68k-apple-aux3"; exit 0 |
| 68 | ;; |
| 69 | |
| 70 | AIX:*) |
| 71 | echo "${MACHINE}-ibm-aix"; exit 0 |
| 72 | ;; |
| 73 | |
| 74 | dgux:*) |
| 75 | echo "${MACHINE}-dg-dgux"; exit 0 |
| 76 | ;; |
| 77 | |
| 78 | HI-UX:*) |
| 79 | echo "${MACHINE}-hi-hiux"; exit 0 |
| 80 | ;; |
| 81 | |
| 82 | HP-UX:*) |
| 83 | HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'` |
| 84 | case "$HPUXVER" in |
| 85 | 10.*) |
| 86 | echo "${MACHINE}-hp-hpux10."; exit 0 |
| 87 | ;; |
| 88 | *) |
| 89 | echo "${MACHINE}-hp-hpux"; exit 0 |
| 90 | ;; |
| 91 | esac |
| 92 | ;; |
| 93 | |
| 94 | IRIX:*) |
| 95 | echo "${MACHINE}-sgi-irix"; exit 0 |
| 96 | ;; |
| 97 | |
| 98 | IRIX64:*) |
| 99 | echo "${MACHINE}-sgi-irix64"; exit 0 |
| 100 | ;; |
| 101 | |
| 102 | Linux:[2-9].*) |
| 103 | echo "${MACHINE}-whatever-linux2"; exit 0 |
| 104 | ;; |
| 105 | |
| 106 | Linux:1.*) |
| 107 | echo "${MACHINE}-whatever-linux1"; exit 0 |
| 108 | ;; |
| 109 | |
| 110 | LynxOS:*) |
| 111 | echo "${MACHINE}-lynx-lynxos"; exit 0 |
| 112 | ;; |
| 113 | |
| 114 | BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*) |
| 115 | echo "i486-whatever-bsdi"; exit 0 |
| 116 | ;; |
| 117 | |
| 118 | BSD/386:*|BSD/OS:*) |
| 119 | echo "${MACHINE}-whatever-bsdi"; exit 0 |
| 120 | ;; |
| 121 | |
Ben Laurie | 5dcdcd4 | 1998-12-28 17:14:28 +0000 | [diff] [blame] | 122 | FreeBSD:3*:*:*) |
| 123 | echo "${MACHINE}-whatever-freebsd3"; exit 0 |
| 124 | ;; |
| 125 | |
Ulf Möller | c6fdd7d | 1999-04-23 16:32:04 +0000 | [diff] [blame^] | 126 | FreeBSD:*:*:*386*) |
| 127 | case `sysctl -n hw.model` in |
| 128 | Pentium*) |
| 129 | echo "i586-whatever-freebsd"; exit 0 |
| 130 | ;; |
| 131 | *) |
| 132 | echo "i386-whatever-freebsd"; exit 0 |
| 133 | ;; |
| 134 | esac; |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 135 | ;; |
| 136 | |
| 137 | FreeBSD:*) |
| 138 | echo "${MACHINE}-whatever-freebsd"; exit 0 |
| 139 | ;; |
| 140 | |
Ulf Möller | c6fdd7d | 1999-04-23 16:32:04 +0000 | [diff] [blame^] | 141 | NetBSD:*:*:*386*) |
| 142 | echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0 |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 143 | ;; |
| 144 | |
| 145 | NetBSD:*) |
| 146 | echo "${MACHINE}-whatever-netbsd"; exit 0 |
| 147 | ;; |
| 148 | |
| 149 | OpenBSD:*) |
| 150 | echo "${MACHINE}-whatever-openbsd"; exit 0 |
| 151 | ;; |
| 152 | |
| 153 | OSF1:*:*:*alpha*) |
| 154 | echo "${MACHINE}-dec-osf"; exit 0 |
| 155 | ;; |
| 156 | |
| 157 | QNX:*) |
| 158 | case "$VERSION" in |
| 159 | 423) |
| 160 | echo "${MACHINE}-qssl-qnx32" |
| 161 | ;; |
| 162 | *) |
| 163 | echo "${MACHINE}-qssl-qnx" |
| 164 | ;; |
| 165 | esac |
| 166 | exit 0 |
| 167 | ;; |
| 168 | |
| 169 | Paragon*:*:*:*) |
| 170 | echo "i860-intel-osf1"; exit 0 |
| 171 | ;; |
| 172 | |
| 173 | SunOS:5.*) |
| 174 | echo "${MACHINE}-sun-solaris2"; exit 0 |
| 175 | ;; |
| 176 | |
| 177 | SunOS:*) |
| 178 | echo "${MACHINE}-sun-sunos4"; exit 0 |
| 179 | ;; |
| 180 | |
| 181 | UNIX_System_V:4.*:*) |
| 182 | echo "${MACHINE}-whatever-sysv4"; exit 0 |
| 183 | ;; |
| 184 | |
| 185 | *:4*:R4*:m88k) |
| 186 | echo "${MACHINE}-whatever-sysv4"; exit 0 |
| 187 | ;; |
| 188 | |
| 189 | DYNIX/ptx:4*:*) |
| 190 | echo "${MACHINE}-whatever-sysv4"; exit 0 |
| 191 | ;; |
| 192 | |
| 193 | *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*) |
| 194 | echo "i486-ncr-sysv4"; exit 0 |
| 195 | ;; |
| 196 | |
| 197 | ULTRIX:*) |
| 198 | echo "${MACHINE}-unknown-ultrix"; exit 0 |
| 199 | ;; |
| 200 | |
| 201 | SINIX*) |
| 202 | echo "${MACHINE}-sni-sysv4"; exit 0 |
| 203 | ;; |
| 204 | |
| 205 | machten:*) |
| 206 | echo "${MACHINE}-tenon-${SYSTEM}"; exit 0; |
| 207 | ;; |
| 208 | |
| 209 | library:*) |
| 210 | echo "${MACHINE}-ncr-sysv4"; exit 0 |
| 211 | ;; |
| 212 | |
| 213 | ConvexOS:*:11.0:*) |
| 214 | echo "${MACHINE}-v11-${SYSTEM}"; exit 0; |
| 215 | ;; |
| 216 | |
| 217 | esac |
| 218 | |
| 219 | # |
| 220 | # Ugg. These are all we can determine by what we know about |
| 221 | # the output of uname. Be more creative: |
| 222 | # |
| 223 | |
| 224 | # Do the Apollo stuff first. Here, we just simply assume |
| 225 | # that the existance of the /usr/apollo directory is proof |
| 226 | # enough |
| 227 | if [ -d /usr/apollo ]; then |
| 228 | echo "whatever-apollo-whatever" |
| 229 | exit 0 |
| 230 | fi |
| 231 | |
| 232 | # Now NeXT |
| 233 | ISNEXT=`hostinfo 2>/dev/null` |
| 234 | case "$ISNEXT" in |
| 235 | *NeXT*) |
| 236 | echo "whatever-next-nextstep"; exit 0 |
| 237 | ;; |
| 238 | esac |
| 239 | |
| 240 | # At this point we gone through all the one's |
| 241 | # we know of: Punt |
| 242 | |
| 243 | echo "${MACHINE}-whatever-${SYSTEM}|${RELEASE}|${VERSION}" |
| 244 | exit 0 |
| 245 | ) 2>/dev/null | ( |
| 246 | |
| 247 | # --------------------------------------------------------------------------- |
| 248 | # this is where the translation occurs into SSLeay terms |
| 249 | # --------------------------------------------------------------------------- |
| 250 | |
| 251 | PREFIX="" |
| 252 | SUFFIX="" |
| 253 | VERBOSE="false" |
| 254 | TEST="false" |
| 255 | |
| 256 | # pick up any command line args to config |
| 257 | for i |
| 258 | do |
| 259 | case "$i" in |
| 260 | -d*) PREFIX="debug-";; |
| 261 | -v*) VERBOSE="true";; |
Ralf S. Engelschall | dfeab06 | 1998-12-21 11:00:56 +0000 | [diff] [blame] | 262 | -t*) TEST="true";; |
Ulf Möller | 5d3bb22 | 1999-04-22 19:23:56 +0000 | [diff] [blame] | 263 | -h*) TEST="true"; cat <<EOF |
| 264 | Usage: config [options] |
Ralf S. Engelschall | dfeab06 | 1998-12-21 11:00:56 +0000 | [diff] [blame] | 265 | -d Add a debug- prefix to machine choice. |
| 266 | -v Verbose mode. |
| 267 | -t Test mode, do not run the Configure perl script. |
| 268 | -h This help. |
| 269 | |
Ulf Möller | 7130806 | 1999-03-30 16:17:03 +0000 | [diff] [blame] | 270 | Any other text will be passed to the Configure perl script. |
Ulf Möller | 5d3bb22 | 1999-04-22 19:23:56 +0000 | [diff] [blame] | 271 | Useful options include |
Ralf S. Engelschall | dfeab06 | 1998-12-21 11:00:56 +0000 | [diff] [blame] | 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. |
| 276 | |
Ralf S. Engelschall | dfeab06 | 1998-12-21 11:00:56 +0000 | [diff] [blame] | 277 | EOF |
| 278 | ;; |
| 279 | *) options=$options" $i" ;; |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 280 | esac |
| 281 | done |
| 282 | |
| 283 | # figure out if gcc is available and if so we use it otherwise |
| 284 | # we fallback to whatever cc does on the system |
Ulf Möller | 44a2570 | 1999-04-08 19:51:16 +0000 | [diff] [blame] | 285 | GCCVER=`(gcc -v) 2>&1` |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 286 | if [ $? = "0" ]; then |
| 287 | CC=gcc |
| 288 | else |
| 289 | CC=cc |
| 290 | fi |
| 291 | |
| 292 | # read the output of the embedded GuessOS |
| 293 | read GUESSOS |
| 294 | |
| 295 | if [ "$VERBOSE" = "true" ]; then |
| 296 | echo GUESSOS $GUESSOS |
| 297 | fi |
| 298 | |
| 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 |
| 302 | case "$GUESSOS" in |
Ralf S. Engelschall | dfeab06 | 1998-12-21 11:00:56 +0000 | [diff] [blame] | 303 | alpha-*-linux2) OUT="alpha-gcc" ;; |
Ben Laurie | ba423ad | 1999-03-27 13:03:37 +0000 | [diff] [blame] | 304 | ppc-*-linux2) OUT="linux-ppc" ;; |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 305 | *-*-linux2) OUT="linux-elf" ;; |
Ben Laurie | dabba11 | 1999-01-17 14:20:20 +0000 | [diff] [blame] | 306 | *-*-linux1) OUT="linux-aout" ;; |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 307 | sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;; |
| 308 | *86*-sun-solaris2) OUT="solaris-x86-$CC" ;; |
| 309 | *-*-sunos4) OUT="sunos-$CC" ;; |
Ben Laurie | 5dcdcd4 | 1998-12-28 17:14:28 +0000 | [diff] [blame] | 310 | *-freebsd3) OUT="FreeBSD-elf" ;; |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 311 | *-freebsd) OUT="FreeBSD" ;; |
| 312 | *86*-*-netbsd) OUT="NetBSD-x86" ;; |
| 313 | sun3*-*-netbsd) OUT="NetBSD-m68" ;; |
| 314 | *-*-netbsd) OUT="NetBSD-sparc" ;; |
Ralf S. Engelschall | dfeab06 | 1998-12-21 11:00:56 +0000 | [diff] [blame] | 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" ;; |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 320 | *-*-unixware*) OUT="unixware-2.0" ;; |
| 321 | *-sni-sysv4) OUT="SINIX" ;; |
Ralf S. Engelschall | dfeab06 | 1998-12-21 11:00:56 +0000 | [diff] [blame] | 322 | *-hpux*) OUT="hpux-$CC" ;; |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 323 | # these are all covered by the catchall below |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 324 | # *-aix) OUT="aix-$CC" ;; |
| 325 | # *-dgux) OUT="dgux" ;; |
| 326 | *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;; |
| 327 | esac |
| 328 | |
Ulf Möller | 5d3bb22 | 1999-04-22 19:23:56 +0000 | [diff] [blame] | 329 | case "$GUESSOS" in |
| 330 | i386-*) options="$options 386" ;; |
| 331 | esac |
| 332 | |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 333 | if [ -z "$OUT" ]; then |
| 334 | OUT="$CC" |
| 335 | fi |
| 336 | |
Ulf Möller | 99aab16 | 1999-04-01 12:34:33 +0000 | [diff] [blame] | 337 | if [ ".$PERL" = . ] ; then |
| 338 | for i in . `echo $PATH | sed 's/:/ /g'`; do |
| 339 | if [ -f "$i/perl5" ] ; then |
| 340 | PERL="$i/perl5" |
| 341 | break; |
| 342 | fi; |
| 343 | done |
| 344 | fi |
| 345 | |
| 346 | if [ ".$PERL" = . ] ; then |
| 347 | for i in . `echo $PATH | sed 's/:/ /g'`; do |
| 348 | if [ -f "$i/perl" ] ; then |
Ulf Möller | a5a47e4 | 1999-04-09 16:25:25 +0000 | [diff] [blame] | 349 | if "$i/perl" -e 'exit($]<5.0)'; then |
| 350 | PERL="$i/perl" |
| 351 | break; |
| 352 | fi; |
Ulf Möller | 99aab16 | 1999-04-01 12:34:33 +0000 | [diff] [blame] | 353 | fi; |
| 354 | done |
| 355 | fi |
| 356 | |
Ulf Möller | a5a47e4 | 1999-04-09 16:25:25 +0000 | [diff] [blame] | 357 | if [ ".$PERL" = . ] ; then |
Ulf Möller | 99aab16 | 1999-04-01 12:34:33 +0000 | [diff] [blame] | 358 | echo "You need Perl 5." |
| 359 | exit 1 |
| 360 | fi |
| 361 | |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 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 |
Ulf Möller | 99aab16 | 1999-04-01 12:34:33 +0000 | [diff] [blame] | 365 | |
| 366 | $PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 367 | if [ $? = "0" ]; then |
| 368 | OUT="$OUT-$CC" |
| 369 | fi |
| 370 | |
| 371 | OUT="$PREFIX$OUT" |
| 372 | |
| 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 |
| 377 | |
| 378 | if [ "$TEST" = "true" ]; then |
Ulf Möller | 99aab16 | 1999-04-01 12:34:33 +0000 | [diff] [blame] | 379 | echo $PERL ./Configure $OUT $options |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 380 | else |
Ulf Möller | 99aab16 | 1999-04-01 12:34:33 +0000 | [diff] [blame] | 381 | $PERL ./Configure $OUT $options |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 382 | fi |
| 383 | |
| 384 | ) |
| 385 | |