]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | ||
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 | ( | |
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 | |
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 | ||
117 | BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*) | |
118 | echo "i486-whatever-bsdi"; exit 0 | |
119 | ;; | |
120 | ||
121 | BSD/386:*|BSD/OS:*) | |
122 | echo "${MACHINE}-whatever-bsdi"; exit 0 | |
123 | ;; | |
124 | ||
5dcdcd47 BL |
125 | FreeBSD:3*:*:*) |
126 | echo "${MACHINE}-whatever-freebsd3"; exit 0 | |
127 | ;; | |
128 | ||
c6fdd7dc UM |
129 | FreeBSD:*:*:*386*) |
130 | case `sysctl -n hw.model` in | |
131 | Pentium*) | |
132 | echo "i586-whatever-freebsd"; exit 0 | |
133 | ;; | |
134 | *) | |
135 | echo "i386-whatever-freebsd"; exit 0 | |
136 | ;; | |
137 | esac; | |
58964a49 RE |
138 | ;; |
139 | ||
140 | FreeBSD:*) | |
141 | echo "${MACHINE}-whatever-freebsd"; exit 0 | |
142 | ;; | |
143 | ||
c6fdd7dc UM |
144 | NetBSD:*:*:*386*) |
145 | echo "`sysctl -n hw.model | sed 's,.*\(.\)86-class.*,i\186,'`-whateve\r-netbsd"; exit 0 | |
58964a49 RE |
146 | ;; |
147 | ||
148 | NetBSD:*) | |
149 | echo "${MACHINE}-whatever-netbsd"; exit 0 | |
150 | ;; | |
151 | ||
152 | OpenBSD:*) | |
153 | echo "${MACHINE}-whatever-openbsd"; exit 0 | |
154 | ;; | |
155 | ||
156 | OSF1:*:*:*alpha*) | |
157 | echo "${MACHINE}-dec-osf"; exit 0 | |
158 | ;; | |
159 | ||
160 | QNX:*) | |
161 | case "$VERSION" in | |
162 | 423) | |
163 | echo "${MACHINE}-qssl-qnx32" | |
164 | ;; | |
165 | *) | |
166 | echo "${MACHINE}-qssl-qnx" | |
167 | ;; | |
168 | esac | |
169 | exit 0 | |
170 | ;; | |
171 | ||
172 | Paragon*:*:*:*) | |
173 | echo "i860-intel-osf1"; exit 0 | |
174 | ;; | |
175 | ||
176 | SunOS:5.*) | |
177 | echo "${MACHINE}-sun-solaris2"; exit 0 | |
178 | ;; | |
179 | ||
180 | SunOS:*) | |
181 | echo "${MACHINE}-sun-sunos4"; exit 0 | |
182 | ;; | |
183 | ||
184 | UNIX_System_V:4.*:*) | |
185 | echo "${MACHINE}-whatever-sysv4"; exit 0 | |
186 | ;; | |
187 | ||
188 | *:4*:R4*:m88k) | |
189 | echo "${MACHINE}-whatever-sysv4"; exit 0 | |
190 | ;; | |
191 | ||
192 | DYNIX/ptx:4*:*) | |
193 | echo "${MACHINE}-whatever-sysv4"; exit 0 | |
194 | ;; | |
195 | ||
196 | *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*) | |
197 | echo "i486-ncr-sysv4"; exit 0 | |
198 | ;; | |
199 | ||
200 | ULTRIX:*) | |
201 | echo "${MACHINE}-unknown-ultrix"; exit 0 | |
202 | ;; | |
203 | ||
204 | SINIX*) | |
205 | echo "${MACHINE}-sni-sysv4"; exit 0 | |
206 | ;; | |
207 | ||
208 | machten:*) | |
209 | echo "${MACHINE}-tenon-${SYSTEM}"; exit 0; | |
210 | ;; | |
211 | ||
212 | library:*) | |
213 | echo "${MACHINE}-ncr-sysv4"; exit 0 | |
214 | ;; | |
215 | ||
216 | ConvexOS:*:11.0:*) | |
217 | echo "${MACHINE}-v11-${SYSTEM}"; exit 0; | |
218 | ;; | |
219 | ||
220 | esac | |
221 | ||
222 | # | |
223 | # Ugg. These are all we can determine by what we know about | |
224 | # the output of uname. Be more creative: | |
225 | # | |
226 | ||
227 | # Do the Apollo stuff first. Here, we just simply assume | |
228 | # that the existance of the /usr/apollo directory is proof | |
229 | # enough | |
230 | if [ -d /usr/apollo ]; then | |
231 | echo "whatever-apollo-whatever" | |
232 | exit 0 | |
233 | fi | |
234 | ||
235 | # Now NeXT | |
236 | ISNEXT=`hostinfo 2>/dev/null` | |
237 | case "$ISNEXT" in | |
238 | *NeXT*) | |
239 | echo "whatever-next-nextstep"; exit 0 | |
240 | ;; | |
241 | esac | |
242 | ||
243 | # At this point we gone through all the one's | |
244 | # we know of: Punt | |
245 | ||
b1fe6b43 | 246 | echo "${MACHINE}-whatever-${SYSTEM}" |
58964a49 RE |
247 | exit 0 |
248 | ) 2>/dev/null | ( | |
249 | ||
250 | # --------------------------------------------------------------------------- | |
251 | # this is where the translation occurs into SSLeay terms | |
252 | # --------------------------------------------------------------------------- | |
253 | ||
254 | PREFIX="" | |
255 | SUFFIX="" | |
58964a49 RE |
256 | TEST="false" |
257 | ||
258 | # pick up any command line args to config | |
259 | for i | |
260 | do | |
261 | case "$i" in | |
262 | -d*) PREFIX="debug-";; | |
dfeab068 | 263 | -t*) TEST="true";; |
5d3bb220 UM |
264 | -h*) TEST="true"; cat <<EOF |
265 | Usage: config [options] | |
dfeab068 | 266 | -d Add a debug- prefix to machine choice. |
dfeab068 RE |
267 | -t Test mode, do not run the Configure perl script. |
268 | -h This help. | |
269 | ||
71308064 | 270 | Any other text will be passed to the Configure perl script. |
462ba4f6 | 271 | See INSTALL for instructions. |
dfeab068 | 272 | |
dfeab068 RE |
273 | EOF |
274 | ;; | |
275 | *) options=$options" $i" ;; | |
58964a49 RE |
276 | esac |
277 | done | |
278 | ||
279 | # figure out if gcc is available and if so we use it otherwise | |
280 | # we fallback to whatever cc does on the system | |
44a25707 | 281 | GCCVER=`(gcc -v) 2>&1` |
58964a49 RE |
282 | if [ $? = "0" ]; then |
283 | CC=gcc | |
284 | else | |
285 | CC=cc | |
744029c1 UM |
286 | if [ "$SYSTEM" = "SunOS" ] |
287 | then | |
288 | case `cc -V 2>&1` in | |
289 | *4*) CC=sc4;; | |
290 | *5*) CC=sc5;; | |
291 | *) CC=cc;; | |
292 | esac | |
293 | fi | |
58964a49 RE |
294 | fi |
295 | ||
296 | # read the output of the embedded GuessOS | |
297 | read GUESSOS | |
298 | ||
b1fe6b43 | 299 | echo Operating system: $GUESSOS |
58964a49 RE |
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 | |
dfeab068 | 305 | alpha-*-linux2) OUT="alpha-gcc" ;; |
ba423add | 306 | ppc-*-linux2) OUT="linux-ppc" ;; |
58964a49 | 307 | *-*-linux2) OUT="linux-elf" ;; |
dabba110 | 308 | *-*-linux1) OUT="linux-aout" ;; |
744029c1 | 309 | sun4u-sun-solaris2) OUT="solaris-usparc-$CC" ;; |
58964a49 RE |
310 | sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;; |
311 | *86*-sun-solaris2) OUT="solaris-x86-$CC" ;; | |
312 | *-*-sunos4) OUT="sunos-$CC" ;; | |
5dcdcd47 | 313 | *-freebsd3) OUT="FreeBSD-elf" ;; |
58964a49 RE |
314 | *-freebsd) OUT="FreeBSD" ;; |
315 | *86*-*-netbsd) OUT="NetBSD-x86" ;; | |
316 | sun3*-*-netbsd) OUT="NetBSD-m68" ;; | |
317 | *-*-netbsd) OUT="NetBSD-sparc" ;; | |
dfeab068 RE |
318 | *86*-*-openbsd) OUT="OpenBSD-x86" ;; |
319 | alpha*-*-openbsd) OUT="OpenBSD-alpha" ;; | |
320 | pmax*-*-openbsd) OUT="OpenBSD-mips" ;; | |
321 | *-*-openbsd) OUT="OpenBSD" ;; | |
322 | *-*-osf) OUT="alpha-cc" ;; | |
58964a49 RE |
323 | *-*-unixware*) OUT="unixware-2.0" ;; |
324 | *-sni-sysv4) OUT="SINIX" ;; | |
325 | # these are all covered by the catchall below | |
afd1f9e8 | 326 | # *-hpux*) OUT="hpux-$CC" ;; |
58964a49 RE |
327 | # *-aix) OUT="aix-$CC" ;; |
328 | # *-dgux) OUT="dgux" ;; | |
329 | *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;; | |
5d3bb220 UM |
330 | esac |
331 | ||
332 | case "$GUESSOS" in | |
333 | i386-*) options="$options 386" ;; | |
58964a49 RE |
334 | esac |
335 | ||
336 | if [ -z "$OUT" ]; then | |
337 | OUT="$CC" | |
338 | fi | |
339 | ||
99aab161 UM |
340 | if [ ".$PERL" = . ] ; then |
341 | for i in . `echo $PATH | sed 's/:/ /g'`; do | |
342 | if [ -f "$i/perl5" ] ; then | |
343 | PERL="$i/perl5" | |
344 | break; | |
345 | fi; | |
346 | done | |
347 | fi | |
348 | ||
349 | if [ ".$PERL" = . ] ; then | |
350 | for i in . `echo $PATH | sed 's/:/ /g'`; do | |
351 | if [ -f "$i/perl" ] ; then | |
a5a47e4a UM |
352 | if "$i/perl" -e 'exit($]<5.0)'; then |
353 | PERL="$i/perl" | |
354 | break; | |
355 | fi; | |
99aab161 UM |
356 | fi; |
357 | done | |
358 | fi | |
359 | ||
a5a47e4a | 360 | if [ ".$PERL" = . ] ; then |
99aab161 UM |
361 | echo "You need Perl 5." |
362 | exit 1 | |
363 | fi | |
364 | ||
58964a49 RE |
365 | # run Configure to check to see if we need to specify the |
366 | # compiler for the platform ... in which case we add it on | |
367 | # the end ... otherwise we leave it off | |
99aab161 UM |
368 | |
369 | $PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null | |
58964a49 RE |
370 | if [ $? = "0" ]; then |
371 | OUT="$OUT-$CC" | |
372 | fi | |
373 | ||
374 | OUT="$PREFIX$OUT" | |
375 | ||
b1fe6b43 UM |
376 | $PERL ./Configure 2>&1 | grep "$OUT" > /dev/null |
377 | if [ $? = "0" ]; then | |
378 | echo Configuring for $OUT | |
58964a49 | 379 | |
b1fe6b43 UM |
380 | if [ "$TEST" = "true" ]; then |
381 | echo $PERL ./Configure $OUT $options | |
382 | else | |
383 | $PERL ./Configure $OUT $options | |
384 | fi | |
58964a49 | 385 | else |
744029c1 | 386 | echo "This system ($OUT) is not supported. See file INSTALL for details." |
58964a49 | 387 | fi |
58964a49 | 388 | ) |