]> git.ipfire.org Git - thirdparty/openssl.git/blame - config
Prevent name conflicts.
[thirdparty/openssl.git] / config
CommitLineData
58964a49
RE
1#!/bin/sh
2#
5d3bb220 3# OpenSSL config: determine the operating system and run ./Configure
58964a49 4#
5d3bb220 5# "config -h" for usage information.
58964a49 6#
5d3bb220
UM
7# this is a merge of minarch and GuessOS from the Apache Group.
8# Originally written by Tim Hudson <tjh@cryptsoft.com>.
58964a49
RE
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
25MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
26RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
27SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown"
28VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
29
58964a49
RE
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(
34XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
35if [ "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
62fi
63# Now we simply scan though... In most cases, the SYSTEM info is enough
64#
65case "${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
afd1f9e8
UM
85 11.*)
86 echo "${MACHINE}-hp-hpux11"; exit 0
87 ;;
58964a49 88 10.*)
afd1f9e8 89 echo "${MACHINE}-hp-hpux10"; exit 0
58964a49
RE
90 ;;
91 *)
92 echo "${MACHINE}-hp-hpux"; exit 0
93 ;;
94 esac
95 ;;
96
97 IRIX:*)
98 echo "${MACHINE}-sgi-irix"; exit 0
99 ;;
100
101 IRIX64:*)
102 echo "${MACHINE}-sgi-irix64"; exit 0
103 ;;
104
105 Linux:[2-9].*)
106 echo "${MACHINE}-whatever-linux2"; exit 0
107 ;;
108
109 Linux:1.*)
110 echo "${MACHINE}-whatever-linux1"; exit 0
111 ;;
112
113 LynxOS:*)
114 echo "${MACHINE}-lynx-lynxos"; exit 0
115 ;;
116
0cceb1c7
BM
117 BSD/OS:4.*)
118 echo "${MACHINE}-whatever-bsdi4"; exit 0
119 ;;
120
58964a49
RE
121 BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
122 echo "i486-whatever-bsdi"; exit 0
123 ;;
124
125 BSD/386:*|BSD/OS:*)
126 echo "${MACHINE}-whatever-bsdi"; exit 0
127 ;;
128
5dcdcd47
BL
129 FreeBSD:3*:*:*)
130 echo "${MACHINE}-whatever-freebsd3"; exit 0
131 ;;
132
c6fdd7dc
UM
133 FreeBSD:*:*:*386*)
134 case `sysctl -n hw.model` in
135 Pentium*)
136 echo "i586-whatever-freebsd"; exit 0
137 ;;
138 *)
139 echo "i386-whatever-freebsd"; exit 0
140 ;;
141 esac;
58964a49
RE
142 ;;
143
144 FreeBSD:*)
145 echo "${MACHINE}-whatever-freebsd"; exit 0
146 ;;
147
c6fdd7dc
UM
148 NetBSD:*:*:*386*)
149 echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0
58964a49
RE
150 ;;
151
152 NetBSD:*)
153 echo "${MACHINE}-whatever-netbsd"; exit 0
154 ;;
155
156 OpenBSD:*)
157 echo "${MACHINE}-whatever-openbsd"; exit 0
158 ;;
159
160 OSF1:*:*:*alpha*)
161 echo "${MACHINE}-dec-osf"; exit 0
162 ;;
163
164 QNX:*)
165 case "$VERSION" in
166 423)
167 echo "${MACHINE}-qssl-qnx32"
168 ;;
169 *)
170 echo "${MACHINE}-qssl-qnx"
171 ;;
172 esac
173 exit 0
174 ;;
175
176 Paragon*:*:*:*)
177 echo "i860-intel-osf1"; exit 0
178 ;;
179
180 SunOS:5.*)
181 echo "${MACHINE}-sun-solaris2"; exit 0
182 ;;
183
184 SunOS:*)
185 echo "${MACHINE}-sun-sunos4"; exit 0
186 ;;
187
188 UNIX_System_V:4.*:*)
189 echo "${MACHINE}-whatever-sysv4"; exit 0
190 ;;
191
192 *:4*:R4*:m88k)
193 echo "${MACHINE}-whatever-sysv4"; exit 0
194 ;;
195
196 DYNIX/ptx:4*:*)
197 echo "${MACHINE}-whatever-sysv4"; exit 0
198 ;;
199
200 *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
201 echo "i486-ncr-sysv4"; exit 0
202 ;;
203
204 ULTRIX:*)
205 echo "${MACHINE}-unknown-ultrix"; exit 0
206 ;;
207
1fac96e4
UM
208 SINIX*|ReliantUNIX*)
209 echo "${MACHINE}-siemens-sysv4"; exit 0
58964a49
RE
210 ;;
211
9231f477
UM
212 POSIX-BC*)
213 echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
214 ;;
215
58964a49
RE
216 machten:*)
217 echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
218 ;;
219
220 library:*)
221 echo "${MACHINE}-ncr-sysv4"; exit 0
222 ;;
223
224 ConvexOS:*:11.0:*)
225 echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
226 ;;
227
228esac
229
230#
231# Ugg. These are all we can determine by what we know about
232# the output of uname. Be more creative:
233#
234
235# Do the Apollo stuff first. Here, we just simply assume
236# that the existance of the /usr/apollo directory is proof
237# enough
238if [ -d /usr/apollo ]; then
239 echo "whatever-apollo-whatever"
240 exit 0
241fi
242
243# Now NeXT
244ISNEXT=`hostinfo 2>/dev/null`
245case "$ISNEXT" in
246 *NeXT*)
247 echo "whatever-next-nextstep"; exit 0
248 ;;
249esac
250
251# At this point we gone through all the one's
252# we know of: Punt
253
b1fe6b43 254echo "${MACHINE}-whatever-${SYSTEM}"
58964a49
RE
255exit 0
256) 2>/dev/null | (
257
258# ---------------------------------------------------------------------------
259# this is where the translation occurs into SSLeay terms
260# ---------------------------------------------------------------------------
261
262PREFIX=""
263SUFFIX=""
58964a49
RE
264TEST="false"
265
266# pick up any command line args to config
267for i
268do
269case "$i" in
270-d*) PREFIX="debug-";;
dfeab068 271-t*) TEST="true";;
5d3bb220
UM
272-h*) TEST="true"; cat <<EOF
273Usage: config [options]
dfeab068 274 -d Add a debug- prefix to machine choice.
dfeab068
RE
275 -t Test mode, do not run the Configure perl script.
276 -h This help.
277
71308064 278Any other text will be passed to the Configure perl script.
462ba4f6 279See INSTALL for instructions.
dfeab068 280
dfeab068
RE
281EOF
282;;
283*) options=$options" $i" ;;
58964a49
RE
284esac
285done
286
287# figure out if gcc is available and if so we use it otherwise
288# we fallback to whatever cc does on the system
44a25707 289GCCVER=`(gcc -v) 2>&1`
58964a49
RE
290if [ $? = "0" ]; then
291 CC=gcc
292else
293 CC=cc
744029c1
UM
294 if [ "$SYSTEM" = "SunOS" ]
295 then
296 case `cc -V 2>&1` in
e14d4443
UM
297 *4*) CC=cc;;
298 *5*) CC=cc;;
299 *) CC=sc3;;
744029c1
UM
300 esac
301 fi
58964a49
RE
302fi
303
304# read the output of the embedded GuessOS
305read GUESSOS
306
b1fe6b43 307echo Operating system: $GUESSOS
58964a49
RE
308
309# now map the output into SSLeay terms ... really should hack into the
310# script above so we end up with values in vars but that would take
311# more time that I want to waste at the moment
312case "$GUESSOS" in
dfeab068 313 alpha-*-linux2) OUT="alpha-gcc" ;;
ba423add 314 ppc-*-linux2) OUT="linux-ppc" ;;
38424743 315 mips-*-linux?) OUT="linux-mips" ;;
47aae74e
BM
316 sparc-*-linux2) OUT="linux-sparc" ;;
317 sparc64-*-linux2) OUT="linux-sparc64" ;;
58964a49 318 *-*-linux2) OUT="linux-elf" ;;
dabba110 319 *-*-linux1) OUT="linux-aout" ;;
744029c1 320 sun4u-sun-solaris2) OUT="solaris-usparc-$CC" ;;
58964a49
RE
321 sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;;
322 *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
323 *-*-sunos4) OUT="sunos-$CC" ;;
a2b21737 324 alpha*-*-freebsd3) OUT="FreeBSD-alpha" ;;
5dcdcd47 325 *-freebsd3) OUT="FreeBSD-elf" ;;
58964a49
RE
326 *-freebsd) OUT="FreeBSD" ;;
327 *86*-*-netbsd) OUT="NetBSD-x86" ;;
328 sun3*-*-netbsd) OUT="NetBSD-m68" ;;
329 *-*-netbsd) OUT="NetBSD-sparc" ;;
dfeab068
RE
330 *86*-*-openbsd) OUT="OpenBSD-x86" ;;
331 alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
332 pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
333 *-*-openbsd) OUT="OpenBSD" ;;
0cceb1c7 334 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
dfeab068 335 *-*-osf) OUT="alpha-cc" ;;
58964a49 336 *-*-unixware*) OUT="unixware-2.0" ;;
9231f477 337 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
1fac96e4
UM
338 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
339 *-siemens-sysv4) OUT="SINIX" ;;
58964a49 340 # these are all covered by the catchall below
afd1f9e8 341 # *-hpux*) OUT="hpux-$CC" ;;
58964a49
RE
342 # *-aix) OUT="aix-$CC" ;;
343 # *-dgux) OUT="dgux" ;;
344 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
5d3bb220
UM
345esac
346
b6735832
UM
347# gcc < 2.8 does not support -mcpu=ultrasparc
348if [ "$OUT" = solaris-usparc-gcc ]
349then
15a99e3d
BM
350 GCCVERMAJOR="`echo $GCCVER | sed 's/.*version \([^.]*\).*/\1/`"
351 GCCVERMINOR="`echo $GCCVER | sed 's/.*version[^.]*\.\([^.]*\).*/\1/`"
352 echo "gcc version $GCCVERMAJOR.$GCCVERMINOR.x"
353 if [ $GCCVERMAJOR$GCCVERMINOR -lt 28 ]
b6735832 354 then
054810ec 355 OUT=solaris-usparc-oldgcc
b6735832
UM
356 fi
357fi
358
5d3bb220
UM
359case "$GUESSOS" in
360 i386-*) options="$options 386" ;;
58964a49
RE
361esac
362
9231f477
UM
363for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 rsa sha
364do
365 if [ ! -d crypto/$i ]
366 then
367 options="$options no-$i"
368 fi
369done
370
58964a49
RE
371if [ -z "$OUT" ]; then
372 OUT="$CC"
373fi
374
99aab161
UM
375if [ ".$PERL" = . ] ; then
376 for i in . `echo $PATH | sed 's/:/ /g'`; do
377 if [ -f "$i/perl5" ] ; then
378 PERL="$i/perl5"
379 break;
380 fi;
381 done
382fi
383
384if [ ".$PERL" = . ] ; then
385 for i in . `echo $PATH | sed 's/:/ /g'`; do
386 if [ -f "$i/perl" ] ; then
a5a47e4a
UM
387 if "$i/perl" -e 'exit($]<5.0)'; then
388 PERL="$i/perl"
389 break;
390 fi;
99aab161
UM
391 fi;
392 done
393fi
394
a5a47e4a 395if [ ".$PERL" = . ] ; then
99aab161
UM
396 echo "You need Perl 5."
397 exit 1
398fi
399
58964a49
RE
400# run Configure to check to see if we need to specify the
401# compiler for the platform ... in which case we add it on
402# the end ... otherwise we leave it off
99aab161
UM
403
404$PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
58964a49
RE
405if [ $? = "0" ]; then
406 OUT="$OUT-$CC"
407fi
408
409OUT="$PREFIX$OUT"
410
b1fe6b43
UM
411$PERL ./Configure 2>&1 | grep "$OUT" > /dev/null
412if [ $? = "0" ]; then
413 echo Configuring for $OUT
58964a49 414
b1fe6b43
UM
415 if [ "$TEST" = "true" ]; then
416 echo $PERL ./Configure $OUT $options
417 else
418 $PERL ./Configure $OUT $options
419 fi
58964a49 420else
744029c1 421 echo "This system ($OUT) is not supported. See file INSTALL for details."
58964a49 422fi
58964a49 423)