Oops! update CHANGES file properly.
[openssl.git] / config
1 #!/bin/sh
2 #
3 # config - this is a merge of minarch and GuessOS from the Apache Group
4 #          which then automatically runs Configure from SSLeay after
5 #          mapping the Apache names for OSs into SSLeay names
6 #
7 # 29-May-97 eay         Added no-asm option
8 # 27-May-97 eay         Alpha linux mods
9 # ??-May-97 eay         IRIX mods
10 # 16-Sep-97 tjh         first cut of merged version
11 #
12 # Tim Hudson
13 # tjh@cryptsoft.com
14 #
15
16 # Original Apache Group comments on GuessOS
17
18 # Simple OS/Platform guesser. Similar to config.guess but
19 # much, much smaller. Since it was developed for use with
20 # Apache, it follows under Apache's regular licensing
21 # with one specific addition: Any changes or additions
22 # to this script should be Emailed to the Apache
23 # group (apache@apache.org) in general and to
24 # Jim Jagielski (jim@jaguNET.com) in specific.
25 #
26 # Be as similar to the output of config.guess/config.sub
27 # as possible.
28
29 # First get uname entries that we use below
30
31 MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
32 RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
33 SYSTEM=`(uname -s) 2>/dev/null`  || SYSTEM="unknown"
34 VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
35
36 # Now test for ISC and SCO, since it is has a braindamaged uname.
37 #
38 # We need to work around FreeBSD 1.1.5.1 
39 (
40 XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
41 if [ "x$XREL" != "x" ]; then
42     if [ -f /etc/kconfig ]; then
43         case "$XREL" in
44             4.0|4.1)
45                     echo "${MACHINE}-whatever-isc4"; exit 0
46                 ;;
47         esac
48     else
49         case "$XREL" in
50             3.2v4.2)
51                 echo "whatever-whatever-sco3"; exit 0
52                 ;;
53             3.2v5.0*)
54                 echo "whatever-whatever-sco5"; exit 0
55                 ;;
56             4.2MP)
57                 if [ "x$VERSION" = "x2.1.1" ]; then
58                     echo "${MACHINE}-whatever-unixware211"; exit 0
59                 else
60                     echo "${MACHINE}-whatever-unixware2"; exit 0
61                 fi
62                 ;;
63             4.2)
64                 echo "whatever-whatever-unixware1"; exit 0
65                 ;;
66         esac
67     fi
68 fi
69 # Now we simply scan though... In most cases, the SYSTEM info is enough
70 #
71 case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
72     A/UX:*)
73         echo "m68k-apple-aux3"; exit 0
74         ;;
75
76     AIX:*)
77         echo "${MACHINE}-ibm-aix"; exit 0
78         ;;
79
80     dgux:*)
81         echo "${MACHINE}-dg-dgux"; exit 0
82         ;;
83
84     HI-UX:*)
85         echo "${MACHINE}-hi-hiux"; exit 0
86         ;;
87
88     HP-UX:*)
89         HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
90         case "$HPUXVER" in
91             10.*)
92                 echo "${MACHINE}-hp-hpux10."; exit 0
93                 ;;
94             *)
95                 echo "${MACHINE}-hp-hpux"; exit 0
96                 ;;
97         esac
98         ;;
99
100     IRIX:*)
101         echo "${MACHINE}-sgi-irix"; exit 0
102         ;;
103
104     IRIX64:*)
105         echo "${MACHINE}-sgi-irix64"; exit 0
106         ;;
107
108     Linux:[2-9].*)
109         echo "${MACHINE}-whatever-linux2"; exit 0
110         ;;
111
112     Linux:1.*)
113         echo "${MACHINE}-whatever-linux1"; exit 0
114         ;;
115
116     LynxOS:*)
117         echo "${MACHINE}-lynx-lynxos"; exit 0
118         ;;
119
120     BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
121         echo "i486-whatever-bsdi"; exit 0
122         ;;
123
124     BSD/386:*|BSD/OS:*)
125         echo "${MACHINE}-whatever-bsdi"; exit 0
126         ;;
127
128     FreeBSD:3*:*:*)
129         echo "${MACHINE}-whatever-freebsd3"; exit 0
130         ;;
131
132     FreeBSD:*:*:*486*)
133         echo "i486-whatever-freebsd"; exit 0
134         ;;
135
136     FreeBSD:*)
137         echo "${MACHINE}-whatever-freebsd"; exit 0
138         ;;
139
140     NetBSD:*:*:*486*)
141         echo "i486-whatever-netbsd"; exit 0
142         ;;
143
144     NetBSD:*)
145         echo "${MACHINE}-whatever-netbsd"; exit 0
146         ;;
147
148     OpenBSD:*)
149         echo "${MACHINE}-whatever-openbsd"; exit 0
150         ;;
151
152     OSF1:*:*:*alpha*)
153         echo "${MACHINE}-dec-osf"; exit 0
154         ;;
155
156     QNX:*)
157         case "$VERSION" in
158             423)
159                 echo "${MACHINE}-qssl-qnx32"
160                 ;;
161             *)
162                 echo "${MACHINE}-qssl-qnx"
163                 ;;
164         esac
165         exit 0
166         ;;
167
168     Paragon*:*:*:*)
169         echo "i860-intel-osf1"; exit 0
170         ;;
171
172     SunOS:5.*)
173         echo "${MACHINE}-sun-solaris2"; exit 0
174         ;;
175
176     SunOS:*)
177         echo "${MACHINE}-sun-sunos4"; exit 0
178         ;;
179
180     UNIX_System_V:4.*:*)
181         echo "${MACHINE}-whatever-sysv4"; exit 0
182         ;;
183
184     *:4*:R4*:m88k)
185         echo "${MACHINE}-whatever-sysv4"; exit 0
186         ;;
187
188     DYNIX/ptx:4*:*)
189         echo "${MACHINE}-whatever-sysv4"; exit 0
190         ;;
191
192     *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
193         echo "i486-ncr-sysv4"; exit 0
194         ;;
195
196     ULTRIX:*)
197         echo "${MACHINE}-unknown-ultrix"; exit 0
198         ;;
199
200     SINIX*)
201         echo "${MACHINE}-sni-sysv4"; exit 0
202         ;;
203
204     machten:*)
205        echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
206        ;;
207
208     library:*)
209         echo "${MACHINE}-ncr-sysv4"; exit 0
210         ;;
211
212     ConvexOS:*:11.0:*)
213         echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
214         ;;
215
216 esac
217
218 #
219 # Ugg. These are all we can determine by what we know about
220 # the output of uname. Be more creative:
221 #
222
223 # Do the Apollo stuff first. Here, we just simply assume
224 # that the existance of the /usr/apollo directory is proof
225 # enough
226 if [ -d /usr/apollo ]; then
227     echo "whatever-apollo-whatever"
228     exit 0
229 fi
230
231 # Now NeXT
232 ISNEXT=`hostinfo 2>/dev/null`
233 case "$ISNEXT" in
234     *NeXT*)
235         echo "whatever-next-nextstep"; exit 0
236         ;;
237 esac
238
239 # At this point we gone through all the one's
240 # we know of: Punt
241
242 echo "${MACHINE}-whatever-${SYSTEM}|${RELEASE}|${VERSION}" 
243 exit 0
244 ) 2>/dev/null | (
245
246 # ---------------------------------------------------------------------------
247 # this is where the translation occurs into SSLeay terms
248 # ---------------------------------------------------------------------------
249
250 PREFIX=""
251 SUFFIX=""
252 VERBOSE="false"
253 TEST="false"
254
255 # pick up any command line args to config
256 for i
257 do
258 case "$i" in 
259 -d*) PREFIX="debug-";;
260 -v*) VERBOSE="true";;
261 -t*) TEST="true";;
262 -h*) cat <<EOF
263 usage: config [options]
264  -d     Add a debug- prefix to machine choice.
265  -v     Verbose mode.
266  -t     Test mode, do not run the Configure perl script.
267  -h     This help.
268
269 Any other text will be passed to ther Configure perl script.
270 Usefull options include
271  no-asm Build with no assember code.
272  -Dxxx  Add xxx define to compilation.
273  -Lxxx  Add xxx library include path to build.
274  -lxxx  Add xxx library to build.
275
276 eg, to build using RSAref, without assember, building to allow anon-DH
277 ciphers and null encryption ciphers,
278  config no-asm -DRSAref -DSSL_ALLOW_ADH -DSSL_ALLOW_ENULL -lrsaref
279 EOF
280 ;;
281 *) options=$options" $i" ;;
282 esac
283 done
284
285 # figure out if gcc is available and if so we use it otherwise
286 # we fallback to whatever cc does on the system
287 GCCVER=`gcc -v 2>&1`
288 if [ $? = "0" ]; then
289   CC=gcc
290 else
291   CC=cc
292 fi
293
294 # read the output of the embedded GuessOS 
295 read GUESSOS
296
297 if [ "$VERBOSE" = "true" ]; then
298   echo GUESSOS $GUESSOS
299 fi
300
301 # now map the output into SSLeay terms ... really should hack into the
302 # script above so we end up with values in vars but that would take
303 # more time that I want to waste at the moment
304 case "$GUESSOS" in
305   alpha-*-linux2) OUT="alpha-gcc" ;;
306   *-*-linux2) OUT="linux-elf" ;;
307   *-*-linux) OUT="linux-aout" ;;
308   sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;;
309   *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
310   *-*-sunos4) OUT="sunos-$CC" ;;
311   *-freebsd3) OUT="FreeBSD-elf" ;;
312   *-freebsd) OUT="FreeBSD" ;;
313   *86*-*-netbsd) OUT="NetBSD-x86" ;;
314   sun3*-*-netbsd) OUT="NetBSD-m68" ;;
315   *-*-netbsd) OUT="NetBSD-sparc" ;;
316   *86*-*-openbsd) OUT="OpenBSD-x86" ;;
317   alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
318   pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
319   *-*-openbsd) OUT="OpenBSD" ;;
320   *-*-osf) OUT="alpha-cc" ;;
321   *-*-unixware*) OUT="unixware-2.0" ;;
322   *-sni-sysv4) OUT="SINIX" ;;
323   *-hpux*) OUT="hpux-$CC" ;;
324   # these are all covered by the catchall below
325   # *-aix) OUT="aix-$CC" ;;
326   # *-dgux) OUT="dgux" ;;
327   *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
328 esac
329
330 if [ -z "$OUT" ]; then
331   OUT="$CC"
332 fi
333
334 # run Configure to check to see if we need to specify the 
335 # compiler for the platform ... in which case we add it on
336 # the end ... otherwise we leave it off
337 perl ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
338 if [ $? = "0" ]; then
339   OUT="$OUT-$CC"
340 fi
341
342 OUT="$PREFIX$OUT"
343
344 # at this point we have the answer ... which we could check again
345 # and then fallback to a vanilla SSLeay build but then this script
346 # wouldn't get updated
347 echo Configuring for $OUT
348
349 if [ "$TEST" = "true" ]; then
350   echo ./Configure $OUT $options
351 else
352   perl ./Configure $OUT $options
353 fi
354
355 )
356