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