]> git.ipfire.org Git - thirdparty/openssl.git/blob - config
Enhanced support for Alpha Linux. See CHANGES for details.
[thirdparty/openssl.git] / config
1 #!/bin/sh
2 #
3 # OpenSSL config: determine the operating system and run ./Configure
4 #
5 # "config -h" for usage information.
6 #
7 # this is a merge of minarch and GuessOS from the Apache Group.
8 # Originally written by Tim Hudson <tjh@cryptsoft.com>.
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
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 11.*)
86 echo "${MACHINE}-hp-hpux11"; exit 0
87 ;;
88 10.*)
89 echo "${MACHINE}-hp-hpux10"; exit 0
90 ;;
91 *)
92 echo "${MACHINE}-hp-hpux"; exit 0
93 ;;
94 esac
95 ;;
96
97 IRIX:5.*)
98 echo "mips2-sgi-irix"; exit 0
99 ;;
100
101 IRIX:6.*)
102 echo "mips3-sgi-irix"; exit 0
103 ;;
104
105 IRIX64:*)
106 echo "mips4-sgi-irix64"; exit 0
107 ;;
108
109 Linux:[2-9].*)
110 echo "${MACHINE}-whatever-linux2"; exit 0
111 ;;
112
113 Linux:1.*)
114 echo "${MACHINE}-whatever-linux1"; exit 0
115 ;;
116
117 LynxOS:*)
118 echo "${MACHINE}-lynx-lynxos"; exit 0
119 ;;
120
121 BSD/OS:4.*) # BSD/OS always says 386
122 echo "i486-whatever-bsdi4"; exit 0
123 ;;
124
125 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
126 case `/sbin/sysctl -n hw.model` in
127 Pentium*)
128 echo "i586-whatever-bsdi"; exit 0
129 ;;
130 *)
131 echo "i386-whatever-bsdi"; exit 0
132 ;;
133 esac;
134 ;;
135
136 BSD/386:*|BSD/OS:*)
137 echo "${MACHINE}-whatever-bsdi"; exit 0
138 ;;
139
140 FreeBSD:*)
141 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
142 MACH=`sysctl -n hw.model`
143 ARCH='whatever'
144 case ${MACH} in
145 *386* ) MACH="i386" ;;
146 *486* ) MACH="i486" ;;
147 Pentium\ II*) MACH="i686" ;;
148 Pentium* ) MACH="i586" ;;
149 Alpha* ) MACH="alpha" ;;
150 * ) MACH="$MACHINE" ;;
151 esac
152 case ${MACH} in
153 i[0-9]86 ) ARCH="pc" ;;
154 esac
155 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
156 ;;
157
158 NetBSD:*:*:*386*)
159 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
160 ;;
161
162 NetBSD:*)
163 echo "${MACHINE}-whatever-netbsd"; exit 0
164 ;;
165
166 OpenBSD:*)
167 echo "${MACHINE}-whatever-openbsd"; exit 0
168 ;;
169
170 OSF1:*:*:*alpha*)
171 echo "${MACHINE}-dec-osf"; exit 0
172 ;;
173
174 QNX:*)
175 case "$VERSION" in
176 423)
177 echo "${MACHINE}-qssl-qnx32"
178 ;;
179 *)
180 echo "${MACHINE}-qssl-qnx"
181 ;;
182 esac
183 exit 0
184 ;;
185
186 Paragon*:*:*:*)
187 echo "i860-intel-osf1"; exit 0
188 ;;
189
190 SunOS:5.*)
191 echo "${MACHINE}-sun-solaris2"; exit 0
192 ;;
193
194 SunOS:*)
195 echo "${MACHINE}-sun-sunos4"; exit 0
196 ;;
197
198 UNIX_System_V:4.*:*)
199 echo "${MACHINE}-whatever-sysv4"; exit 0
200 ;;
201
202 *:4*:R4*:m88k)
203 echo "${MACHINE}-whatever-sysv4"; exit 0
204 ;;
205
206 DYNIX/ptx:4*:*)
207 echo "${MACHINE}-whatever-sysv4"; exit 0
208 ;;
209
210 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
211 echo "i486-ncr-sysv4"; exit 0
212 ;;
213
214 ULTRIX:*)
215 echo "${MACHINE}-unknown-ultrix"; exit 0
216 ;;
217
218 SINIX*|ReliantUNIX*)
219 echo "${MACHINE}-siemens-sysv4"; exit 0
220 ;;
221
222 POSIX-BC*)
223 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
224 ;;
225
226 machten:*)
227 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
228 ;;
229
230 library:*)
231 echo "${MACHINE}-ncr-sysv4"; exit 0
232 ;;
233
234 ConvexOS:*:11.0:*)
235 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
236 ;;
237
238 esac
239
240 #
241 # Ugg. These are all we can determine by what we know about
242 # the output of uname. Be more creative:
243 #
244
245 # Do the Apollo stuff first. Here, we just simply assume
246 # that the existance of the /usr/apollo directory is proof
247 # enough
248 if [ -d /usr/apollo ]; then
249 echo "whatever-apollo-whatever"
250 exit 0
251 fi
252
253 # Now NeXT
254 ISNEXT=`hostinfo 2>/dev/null`
255 case "$ISNEXT" in
256 *'NeXT Mach 3.3'*)
257 echo "whatever-next-nextstep3.3"; exit 0
258 ;;
259 *NeXT*)
260 echo "whatever-next-nextstep"; exit 0
261 ;;
262 esac
263
264 # At this point we gone through all the one's
265 # we know of: Punt
266
267 echo "${MACHINE}-whatever-${SYSTEM}"
268 exit 0
269 ) 2>/dev/null | (
270
271 # ---------------------------------------------------------------------------
272 # this is where the translation occurs into SSLeay terms
273 # ---------------------------------------------------------------------------
274
275 PREFIX=""
276 SUFFIX=""
277 TEST="false"
278
279 # pick up any command line args to config
280 for i
281 do
282 case "$i" in
283 -d*) PREFIX="debug-";;
284 -t*) TEST="true";;
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.
289 -h This help.
290
291 Any other text will be passed to the Configure perl script.
292 See INSTALL for instructions.
293
294 EOF
295 ;;
296 *) options=$options" $i" ;;
297 esac
298 done
299
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
304 CC=gcc
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/'`
309 else
310 CC=cc
311 fi
312
313 if [ "$SYSTEM" = "SunOS" ]; then
314 # check for WorkShop C, expected output is "cc: 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/'`
318 CCVER=${CCVER:-0}
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."
324 sleep 5
325 fi
326 elif [ "$CC" = "cc" -a $CCVER -gt 0 ]; then
327 CC=sc3
328 fi
329 fi
330
331 if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
332 # check for Compaq C, expected output is "blah-blah C Vx.x"
333 CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
334 egrep -e '.* C V[0-9]\.[0-9]' | \
335 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
336 CCCVER=${CCCVER:-0}
337 if [ $CCCVER -gt 60 ]; then
338 CC=ccc # overrides gcc!!! well, ccc outperforms inoticeably
339 # only on hash routines and des, otherwise gcc (2.95)
340 # keeps along rather tight...
341 fi
342 fi
343
344 GCCVER=${GCCVER:-0}
345 CCVER=${CCVER:-0}
346
347 # read the output of the embedded GuessOS
348 read GUESSOS
349
350 echo Operating system: $GUESSOS
351
352 # now map the output into SSLeay terms ... really should hack into the
353 # script above so we end up with values in vars but that would take
354 # more time that I want to waste at the moment
355 case "$GUESSOS" in
356 mips2-sgi-irix)
357 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
358 CPU=${CPU:-0}
359 if [ $CPU -ge 4000 ]; then
360 options="$options -mips2"
361 fi
362 OUT="irix-$CC"
363 ;;
364 mips3-sgi-irix)
365 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
366 CPU=${CPU:-0}
367 if [ $CPU -ge 5000 ]; then
368 options="$options -mips4"
369 else
370 options="$options -mips3"
371 fi
372 OUT="irix-mips3-$CC"
373 ;;
374 mips4-sgi-irix64)
375 echo "WARNING! If you wish to build 64-bit library, then you have to"
376 echo " invoke './Configre irix64-mips4-$CC' *manually*."
377 echo " Type Ctrl-C if you don't want to continue."
378 read waste < /dev/tty
379 options="$options -mips4"
380 OUT="irix-mips3-$CC"
381 ;;
382 alpha-*-linux2)
383 ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
384 case ${ISA:-generic} in
385 *[67]) OUT="linux-alpha+bwx-$CC" ;;
386 *) OUT="linux-alpha-$CC" ;;
387 esac
388 if [ "$CC" = "gcc" ]; then
389 case ${ISA:-generic} in
390 EV5|EV45) options="$options -mcpu=ev5";;
391 EV56|PCA56) options="$options -mcpu=ev56";;
392 EV6|EV67|PCA57) options="$options -mcpu=ev6";;
393 esac
394 fi
395 ;;
396 mips-*-linux?) OUT="linux-mips" ;;
397 ppc-*-linux2) OUT="linux-ppc" ;;
398 sparc64-*-linux2)
399 #Before we can uncomment following lines we have to wait at least
400 #till 64-bit glibc for SPARC is operational:-(
401 #echo "WARNING! If you wish to build 64-bit library, then you have to"
402 #echo " invoke './Configure linux64-sparcv9' *manually*."
403 #echo " Type Ctrl-C if you don't want to continue."
404 #read waste < /dev/tty
405 OUT="linux-sparcv9" ;;
406 sparc-*-linux2)
407 KARCH=`awk '/type/{print$3}' /proc/cpuinfo`
408 case ${KARCH:-sun4} in
409 sun4u*) OUT="linux-sparcv9" ;;
410 sun4m) OUT="linux-sparcv8" ;;
411 sun4d) OUT="linux-sparcv8" ;;
412 *) OUT="linux-sparcv7" ;;
413 esac ;;
414 *-*-linux2) OUT="linux-elf" ;;
415 *-*-linux1) OUT="linux-aout" ;;
416 sun4u*-sun-solaris2)
417 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
418 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then
419 echo "WARNING! If you wish to build 64-bit library, then you have to"
420 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
421 echo " Type Ctrl-C if you don't want to continue."
422 read waste < /dev/tty
423 fi
424 OUT="solaris-sparcv9-$CC" ;;
425 sun4m-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
426 sun4d-sun-solaris2) OUT="solaris-sparcv8-$CC" ;;
427 sun4*-sun-solaris2) OUT="solaris-sparcv7-$CC" ;;
428 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
429 *-*-sunos4) OUT="sunos-$CC" ;;
430 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
431 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
432 *-freebsd[1-2]*) OUT="FreeBSD" ;;
433 *86*-*-netbsd) OUT="NetBSD-x86" ;;
434 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
435 *-*-netbsd) OUT="NetBSD-sparc" ;;
436 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
437 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
438 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
439 *-*-openbsd) OUT="OpenBSD" ;;
440 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
441 *-*-osf) OUT="alpha-cc" ;;
442 *-*-unixware*) OUT="unixware-2.0" ;;
443 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
444 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
445 *-siemens-sysv4) OUT="SINIX" ;;
446 # these are all covered by the catchall below
447 # *-hpux*) OUT="hpux-$CC" ;;
448 # *-aix) OUT="aix-$CC" ;;
449 # *-dgux) OUT="dgux" ;;
450 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
451 esac
452
453 # gcc < 2.8 does not support -mcpu=ultrasparc
454 if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
455 then
456 echo "WARNING! Do consider upgrading to gcc-2.8 or later."
457 sleep 5
458 OUT=solaris-sparcv9-gcc27
459 fi
460 if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
461 then
462 echo "WARNING! Falling down to 'linux-sparcv8'."
463 echo " Upgrade to gcc-2.8 or later."
464 sleep 5
465 OUT=linux-sparcv8
466 fi
467 if [ "$OUT" = "i86pc-sun-solaris2" ]
468 then
469 ASM=`as -V /dev/null 2>&1`
470 case "$ASM" in
471 GNU*) ;;
472 *) 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." ;;
473 esac
474 fi
475
476 case "$GUESSOS" in
477 i386-*) options="$options 386" ;;
478 esac
479
480 for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
481 do
482 if [ ! -d crypto/$i ]
483 then
484 options="$options no-$i"
485 fi
486 done
487
488 if [ -z "$OUT" ]; then
489 OUT="$CC"
490 fi
491
492 if [ ".$PERL" = . ] ; then
493 for i in . `echo $PATH | sed 's/:/ /g'`; do
494 if [ -f "$i/perl5" ] ; then
495 PERL="$i/perl5"
496 break;
497 fi;
498 done
499 fi
500
501 if [ ".$PERL" = . ] ; then
502 for i in . `echo $PATH | sed 's/:/ /g'`; do
503 if [ -f "$i/perl" ] ; then
504 if "$i/perl" -e 'exit($]<5.0)'; then
505 PERL="$i/perl"
506 break;
507 fi;
508 fi;
509 done
510 fi
511
512 if [ ".$PERL" = . ] ; then
513 echo "You need Perl 5."
514 exit 1
515 fi
516
517 # run Configure to check to see if we need to specify the
518 # compiler for the platform ... in which case we add it on
519 # the end ... otherwise we leave it off
520
521 $PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
522 if [ $? = "0" ]; then
523 OUT="$OUT-$CC"
524 fi
525
526 OUT="$PREFIX$OUT"
527
528 $PERL ./Configure 2>&1 | grep "$OUT" > /dev/null
529 if [ $? = "0" ]; then
530 echo Configuring for $OUT
531
532 if [ "$TEST" = "true" ]; then
533 echo $PERL ./Configure $OUT $options
534 else
535 $PERL ./Configure $OUT $options
536 fi
537 else
538 echo "This system ($OUT) is not supported. See file INSTALL for details."
539 fi
540 )