Commit | Line | Data |
---|---|---|
2304df62 AD |
1 | #! /bin/sh |
2 | # | |
3 | # If these # comments don't work, trim them. Don't worry about any other | |
4 | # shell scripts, Configure will trim # comments from them for you. | |
5 | # | |
6 | # (If you are trying to port this package to a machine without sh, | |
7 | # I would suggest you have a look at the prototypical config_h.SH file | |
8 | # and edit it to reflect your system. Some packages may include samples | |
9 | # of config.h for certain machines, so you might look for one of those.) | |
10 | # | |
11 | # Yes, you may rip this off to use in other distribution packages. This | |
12 | # script belongs to the public domain and cannot be copyrighted. | |
13 | # | |
14 | # (Note: this Configure script was generated automatically. Rather than | |
15 | # working with this copy of Configure, you may wish to get metaconfig. | |
16 | # The dist-3.0 package (which contains metaconfig) was posted in | |
dfe9444c AD |
17 | # comp.sources.misc and is available on CPAN under authors/id/RAM so |
18 | # you may fetch it yourself from your nearest archive site.) | |
2304df62 AD |
19 | # |
20 | ||
dfe9444c | 21 | # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ |
2304df62 | 22 | # |
9c839522 | 23 | # Generated on Tue Sep 12 16:47:06 EET DST 2000 [metaconfig 3.0 PL70] |
7f2de2d2 | 24 | # (with additional metaconfig patches by perlbug@perl.org) |
2304df62 AD |
25 | |
26 | cat >/tmp/c1$$ <<EOF | |
27 | ARGGGHHHH!!!!! | |
28 | ||
29 | SCO csh still thinks true is false. Write to SCO today and tell them that next | |
30 | year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-) | |
31 | ||
32 | (Actually, Configure ought to just patch csh in place. Hmm. Hmmmmm. All | |
33 | we'd have to do is go in and swap the && and || tokens, wherever they are.) | |
34 | ||
35 | [End of diatribe. We now return you to your regularly scheduled programming...] | |
36 | EOF | |
37 | cat >/tmp/c2$$ <<EOF | |
38 | ||
39 | OOPS! You naughty creature! You didn't run Configure with sh! | |
40 | I will attempt to remedy the situation by running sh for you... | |
41 | EOF | |
42 | ||
43 | true || cat /tmp/c1$$ /tmp/c2$$ | |
44 | true || exec sh $0 $argv:q | |
45 | ||
46 | (exit $?0) || cat /tmp/c2$$ | |
47 | (exit $?0) || exec sh $0 $argv:q | |
48 | rm -f /tmp/c1$$ /tmp/c2$$ | |
49 | ||
a0d0e21e LW |
50 | : compute my invocation name |
51 | me=$0 | |
52 | case "$0" in | |
53 | */*) | |
54 | me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null` | |
55 | test "$me" || me=$0 | |
56 | ;; | |
57 | esac | |
58 | ||
dfe9444c | 59 | : Proper separator for the PATH environment variable |
8e07c86e AD |
60 | p_=: |
61 | : On OS/2 this directory should exist if this is not floppy only system :-] | |
dfe9444c AD |
62 | if test -d c:/. ; then |
63 | if test -n "$OS2_SHELL"; then | |
64 | p_=\; | |
65 | PATH=`cmd /c "echo %PATH%" | tr '\\\\' / ` | |
66 | OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'` | |
c4f23d77 | 67 | elif test -n "$DJGPP"; then |
dfe9444c AD |
68 | p_=\; |
69 | fi | |
39e571d4 | 70 | fi |
a0d0e21e LW |
71 | |
72 | : Proper PATH setting | |
73 | paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin' | |
16d20bd9 | 74 | paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin" |
232e078e | 75 | paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin" |
16d20bd9 | 76 | paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin" |
232e078e AD |
77 | paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb" |
78 | paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin" | |
79 | paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib" | |
80 | paths="$paths /sbin /usr/sbin /usr/libexec" | |
a0d0e21e LW |
81 | |
82 | for p in $paths | |
83 | do | |
8e07c86e AD |
84 | case "$p_$PATH$p_" in |
85 | *$p_$p$p_*) ;; | |
86 | *) test -d $p && PATH=$PATH$p_$p ;; | |
a0d0e21e LW |
87 | esac |
88 | done | |
89 | ||
8e07c86e | 90 | PATH=.$p_$PATH |
2304df62 AD |
91 | export PATH |
92 | ||
dfe9444c AD |
93 | : shall we be using ksh? |
94 | inksh='' | |
95 | needksh='' | |
96 | avoidksh='' | |
97 | newsh=/bin/ksh | |
98 | changesh='' | |
ff0cee69 | 99 | if (PATH=.; alias -x) >/dev/null 2>&1; then |
dfe9444c AD |
100 | inksh=true |
101 | fi | |
102 | if test -f /hp-ux -a -f /bin/ksh; then | |
103 | needksh='to avoid sh bug in "here document" expansion' | |
104 | fi | |
105 | if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then | |
106 | if test X`/usr/bin/uname -v` = X4; then | |
107 | avoidksh="to avoid AIX 4's /bin/sh" | |
108 | newsh=/usr/bin/bsh | |
2304df62 | 109 | fi |
dfe9444c | 110 | fi |
cf04f91f JH |
111 | if test -f /osf_boot -a -f /usr/sbin/setld; then |
112 | if test X`/usr/bin/uname -s` = XOSF1; then | |
113 | avoidksh="to avoid Digital UNIX' ksh" | |
114 | newsh=/bin/sh | |
115 | unset BIN_SH # if this is 'xpg4' sh will start up ksh | |
116 | fi | |
117 | fi | |
dfe9444c AD |
118 | case "$inksh/$needksh" in |
119 | /[a-z]*) | |
c4f23d77 | 120 | ENV='' |
dfe9444c AD |
121 | changesh=true |
122 | reason="$needksh" | |
123 | ;; | |
124 | esac | |
125 | case "$inksh/$avoidksh" in | |
126 | true/[a-z]*) | |
127 | changesh=true | |
128 | reason="$avoidksh" | |
129 | ;; | |
130 | esac | |
131 | case "$inksh/$needksh-$avoidksh-" in | |
132 | true/--) | |
a0d0e21e LW |
133 | cat <<EOM |
134 | (I see you are using the Korn shell. Some ksh's blow up on $me, | |
dfe9444c | 135 | mainly on older exotic systems. If yours does, try the Bourne shell instead.) |
ff0cee69 | 136 | EOM |
dfe9444c AD |
137 | ;; |
138 | esac | |
139 | case "$changesh" in | |
140 | true) | |
141 | echo "(Feeding myself to $newsh $reason.)" | |
142 | case "$0" in | |
143 | Configure|*/Configure) exec $newsh $0 "$@";; | |
144 | *) exec $newsh Configure "$@";; | |
145 | esac | |
146 | ;; | |
147 | esac | |
2304df62 | 148 | |
bfb7748a AD |
149 | : if needed set CDPATH to a harmless value that is not chatty |
150 | : avoid bash 2.02 problems with empty CDPATH. | |
151 | case "$CDPATH" in | |
152 | '') ;; | |
153 | *) case "$SHELL" in | |
154 | *bash*) CDPATH='.' ;; | |
155 | *) CDPATH='' ;; | |
156 | esac | |
157 | ;; | |
158 | esac | |
2304df62 AD |
159 | : Configure runs within the UU subdirectory |
160 | test -d UU || mkdir UU | |
8e07c86e | 161 | cd UU && rm -f ./* |
2304df62 | 162 | |
6b356c8e JH |
163 | ccname='' |
164 | ccversion='' | |
9c839522 | 165 | perllibs='' |
ecfc5424 | 166 | d_bsd='' |
40a7a20a | 167 | d_eunice='' |
2304df62 AD |
168 | d_xenix='' |
169 | eunicefix='' | |
170 | Mcc='' | |
dfe9444c | 171 | ar='' |
2304df62 AD |
172 | awk='' |
173 | bash='' | |
174 | bison='' | |
175 | byacc='' | |
176 | cat='' | |
177 | chgrp='' | |
178 | chmod='' | |
179 | chown='' | |
ecfc5424 | 180 | comm='' |
2304df62 AD |
181 | compress='' |
182 | cp='' | |
183 | cpio='' | |
184 | cpp='' | |
185 | csh='' | |
186 | date='' | |
187 | echo='' | |
188 | egrep='' | |
189 | emacs='' | |
190 | expr='' | |
191 | find='' | |
192 | flex='' | |
2304df62 | 193 | grep='' |
8ff267be | 194 | gzip='' |
2304df62 AD |
195 | inews='' |
196 | ksh='' | |
197 | less='' | |
198 | line='' | |
199 | lint='' | |
200 | ln='' | |
201 | lp='' | |
202 | lpr='' | |
203 | ls='' | |
204 | mail='' | |
205 | mailx='' | |
dfe9444c | 206 | make='' |
2304df62 AD |
207 | mkdir='' |
208 | more='' | |
209 | mv='' | |
693762b4 | 210 | nm='' |
2304df62 AD |
211 | nroff='' |
212 | perl='' | |
213 | pg='' | |
214 | pmake='' | |
215 | pr='' | |
216 | rm='' | |
217 | rmail='' | |
218 | sed='' | |
219 | sendmail='' | |
2304df62 AD |
220 | shar='' |
221 | sleep='' | |
222 | smail='' | |
223 | sort='' | |
224 | submit='' | |
225 | tail='' | |
226 | tar='' | |
227 | tbl='' | |
693762b4 | 228 | tee='' |
2304df62 AD |
229 | test='' |
230 | touch='' | |
231 | tr='' | |
232 | troff='' | |
233 | uname='' | |
234 | uniq='' | |
235 | uuname='' | |
236 | vi='' | |
237 | zcat='' | |
8ff267be | 238 | zip='' |
a0d0e21e | 239 | libswanted='' |
2304df62 AD |
240 | hint='' |
241 | myuname='' | |
85e6fe83 LW |
242 | osname='' |
243 | osvers='' | |
2304df62 AD |
244 | Author='' |
245 | Date='' | |
246 | Header='' | |
247 | Id='' | |
248 | Locker='' | |
249 | Log='' | |
250 | RCSfile='' | |
251 | Revision='' | |
252 | Source='' | |
253 | State='' | |
dfe9444c AD |
254 | _a='' |
255 | _exe='' | |
256 | _o='' | |
4633a7c4 LW |
257 | archobjs='' |
258 | exe_ext='' | |
259 | firstmakefile='' | |
260 | lib_ext='' | |
261 | obj_ext='' | |
262 | path_sep='' | |
2304df62 | 263 | cc='' |
2304df62 AD |
264 | ccflags='' |
265 | cppflags='' | |
266 | ldflags='' | |
267 | lkflags='' | |
8e07c86e | 268 | locincpth='' |
2304df62 AD |
269 | optimize='' |
270 | cf_by='' | |
271 | cf_time='' | |
272 | contains='' | |
273 | cpplast='' | |
274 | cppminus='' | |
275 | cpprun='' | |
276 | cppstdin='' | |
a0d0e21e | 277 | d_dlopen='' |
a4f3eea9 | 278 | d_gnulibc='' |
2304df62 | 279 | d_portable='' |
85e6fe83 LW |
280 | cccdlflags='' |
281 | ccdlflags='' | |
2304df62 | 282 | dlsrc='' |
232e078e | 283 | ld='' |
85e6fe83 | 284 | lddlflags='' |
2304df62 | 285 | usedl='' |
5b463ca7 | 286 | gccosandvers='' |
8a27cf78 | 287 | gccversion='' |
a0d0e21e | 288 | i_dld='' |
2304df62 | 289 | libc='' |
a0d0e21e | 290 | glibpth='' |
2304df62 | 291 | libpth='' |
8e07c86e | 292 | loclibpth='' |
2304df62 AD |
293 | plibpth='' |
294 | xlibpth='' | |
1cfa4ec7 | 295 | ignore_versioned_solibs='' |
2304df62 | 296 | libs='' |
43999f95 JH |
297 | libsdirs='' |
298 | libsfiles='' | |
299 | libsfound='' | |
13b3f787 | 300 | libspath='' |
85e6fe83 | 301 | lns='' |
8ff267be | 302 | make_set_make='' |
2304df62 AD |
303 | c='' |
304 | n='' | |
2304df62 AD |
305 | package='' |
306 | spackage='' | |
8ff267be | 307 | sh='' |
a0d0e21e | 308 | so='' |
2304df62 AD |
309 | sharpbang='' |
310 | shsharp='' | |
311 | spitshell='' | |
dfe9444c | 312 | src='' |
2304df62 | 313 | startsh='' |
5ff3f7a4 | 314 | trnl='' |
2304df62 | 315 | nm_opt='' |
40a7a20a | 316 | nm_so_opt='' |
2304df62 AD |
317 | runnm='' |
318 | usenm='' | |
29209bc5 | 319 | usesocks='' |
2304df62 | 320 | incpath='' |
2304df62 AD |
321 | mips_type='' |
322 | usrinc='' | |
2304df62 AD |
323 | CONFIG='' |
324 | ||
ecfc5424 AD |
325 | define='define' |
326 | undef='undef' | |
327 | smallmach='pdp11 i8086 z8000 i80286 iAPX286' | |
328 | rmlist='' | |
329 | ||
330 | : We must find out about Eunice early | |
331 | eunicefix=':' | |
332 | if test -f /etc/unixtovms; then | |
333 | eunicefix=/etc/unixtovms | |
334 | fi | |
335 | if test -f /etc/unixtovms.exe; then | |
336 | eunicefix=/etc/unixtovms.exe | |
337 | fi | |
338 | ||
6b356c8e JH |
339 | ccname='' |
340 | ccversion='' | |
9c839522 | 341 | perllibs='' |
dfe9444c | 342 | : Trailing extension. Override this in a hint file, if needed. |
4e2a5f63 | 343 | _exe='' |
dfe9444c AD |
344 | : Extra object files, if any, needed on this platform. |
345 | archobjs='' | |
9c839522 PM |
346 | cppflags='' |
347 | optimize='' | |
ff935051 JH |
348 | : Possible local include directories to search. |
349 | : Set locincpth to "" in a hint file to defeat local include searches. | |
350 | locincpth="/usr/local/include /opt/local/include /usr/gnu/include" | |
351 | locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include" | |
352 | : | |
353 | : no include file wanted by default | |
354 | inclwanted='' | |
355 | ||
732c9516 JH |
356 | : change the next line if compiling for Xenix/286 on Xenix/386 |
357 | xlibpth='/usr/lib/386 /lib/386' | |
732c9516 JH |
358 | : Possible local library directories to search. |
359 | loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib" | |
360 | loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib" | |
361 | ||
362 | : general looking path for locating libraries | |
5869b1f1 | 363 | glibpth="/lib /usr/lib $xlibpth" |
732c9516 | 364 | glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib" |
f7dd4e7f JH |
365 | test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth" |
366 | test -f /shlib/libc.so && glibpth="/shlib $glibpth" | |
732c9516 JH |
367 | |
368 | : Private path used by Configure to find libraries. Its value | |
369 | : is prepended to libpth. This variable takes care of special | |
370 | : machines, like the mips. Usually, it should be empty. | |
371 | plibpth='' | |
372 | ||
1cfa4ec7 GS |
373 | : default library list |
374 | libswanted='' | |
921b2963 | 375 | : some systems want to use only the non-versioned libso:s |
1cfa4ec7 | 376 | ignore_versioned_solibs='' |
29209bc5 | 377 | : set usesocks on the Configure command line to enable socks. |
ecfc5424 | 378 | : List of libraries we want. |
693762b4 | 379 | : If anyone needs -lnet, put it in a hint file. |
997d70a2 | 380 | libswanted='sfio socket bind inet nsl nm ndbm gdbm dbm db malloc dl' |
69e84d1d | 381 | libswanted="$libswanted dld ld sun m c cposix posix" |
f1066039 | 382 | libswanted="$libswanted ndir dir crypt sec" |
0c9177ab | 383 | libswanted="$libswanted ucb bsd BSD PW x iconv util" |
1aef975c | 384 | : We probably want to search /usr/shlib before most other libraries. |
94b6baf5 | 385 | : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist. |
ecfc5424 AD |
386 | glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'` |
387 | glibpth="/usr/shlib $glibpth" | |
388 | : Do not use vfork unless overridden by a hint file. | |
389 | usevfork=false | |
390 | ||
8ff267be | 391 | : Find the basic shell for Bourne shell scripts |
392 | case "$sh" in | |
393 | '') | |
8ff267be | 394 | case "$SYSTYPE" in |
395 | *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";; | |
396 | *) xxx='/bin/sh';; | |
397 | esac | |
398 | if test -f "$xxx"; then | |
399 | sh="$xxx" | |
400 | else | |
401 | : Build up a list and do a single loop so we can 'break' out. | |
402 | pth=`echo $PATH | sed -e "s/$p_/ /g"` | |
403 | for xxx in sh bash ksh pdksh ash; do | |
404 | for p in $pth; do | |
405 | try="$try ${p}/${xxx}" | |
406 | done | |
407 | done | |
408 | for xxx in $try; do | |
409 | if test -f "$xxx"; then | |
410 | sh="$xxx"; | |
8ff267be | 411 | break |
412 | elif test -f "$xxx.exe"; then | |
413 | sh="$xxx"; | |
8ff267be | 414 | break |
415 | fi | |
416 | done | |
417 | fi | |
418 | ;; | |
419 | esac | |
420 | ||
421 | case "$sh" in | |
422 | '') cat <<EOM >&2 | |
423 | $me: Fatal Error: I can't find a Bourne Shell anywhere. | |
dfe9444c | 424 | |
8ff267be | 425 | Usually it's in /bin/sh. How did you even get this far? |
7f2de2d2 | 426 | Please contact me (Perl Maintainers) at perlbug@perl.org and |
dfe9444c | 427 | we'll try to straighten this all out. |
8ff267be | 428 | EOM |
429 | exit 1 | |
430 | ;; | |
431 | esac | |
432 | ||
760ac839 | 433 | : see if sh knows # comments |
8ff267be | 434 | if `$sh -c '#' >/dev/null 2>&1`; then |
760ac839 LW |
435 | shsharp=true |
436 | spitshell=cat | |
760ac839 LW |
437 | xcat=/bin/cat |
438 | test -f $xcat || xcat=/usr/bin/cat | |
439 | echo "#!$xcat" >try | |
440 | $eunicefix try | |
441 | chmod +x try | |
442 | ./try > today | |
443 | if test -s today; then | |
760ac839 LW |
444 | sharpbang='#!' |
445 | else | |
446 | echo "#! $xcat" > try | |
447 | $eunicefix try | |
448 | chmod +x try | |
449 | ./try > today | |
450 | if test -s today; then | |
760ac839 LW |
451 | sharpbang='#! ' |
452 | else | |
760ac839 LW |
453 | sharpbang=': use ' |
454 | fi | |
455 | fi | |
456 | else | |
dfe9444c | 457 | echo " " |
8ff267be | 458 | echo "Your $sh doesn't grok # comments--I will strip them later on." |
760ac839 LW |
459 | shsharp=false |
460 | cd .. | |
461 | echo "exec grep -v '^[ ]*#'" >spitshell | |
462 | chmod +x spitshell | |
463 | $eunicefix spitshell | |
464 | spitshell=`pwd`/spitshell | |
465 | cd UU | |
466 | echo "I presume that if # doesn't work, #! won't work either!" | |
467 | sharpbang=': use ' | |
468 | fi | |
469 | rm -f try today | |
470 | ||
471 | : figure out how to guarantee sh startup | |
8ff267be | 472 | case "$startsh" in |
473 | '') startsh=${sharpbang}${sh} ;; | |
474 | *) | |
760ac839 | 475 | esac |
760ac839 LW |
476 | cat >try <<EOSS |
477 | $startsh | |
478 | set abc | |
479 | test "$?abc" != 1 | |
480 | EOSS | |
481 | ||
482 | chmod +x try | |
483 | $eunicefix try | |
484 | if ./try; then | |
8ff267be | 485 | : echo "Yup, it does." |
760ac839 | 486 | else |
dfe9444c AD |
487 | echo "Hmm... '$startsh' does not guarantee sh startup..." |
488 | echo "You may have to fix up the shell scripts to make sure $sh runs them." | |
760ac839 LW |
489 | fi |
490 | rm -f try | |
491 | ||
aebf16e7 AD |
492 | |
493 | : Save command line options in file UU/cmdline.opt for later use in | |
494 | : generating config.sh. | |
495 | cat > cmdline.opt <<EOSH | |
496 | # Configure command line arguments. | |
497 | config_arg0='$0' | |
498 | config_args='$*' | |
499 | config_argc=$# | |
500 | EOSH | |
501 | argn=1 | |
502 | for arg in "$@"; do | |
503 | cat >>cmdline.opt <<EOSH | |
504 | config_arg$argn='$arg' | |
505 | EOSH | |
506 | argn=`expr $argn + 1` | |
507 | done | |
508 | ||
2304df62 AD |
509 | : produce awk script to parse command line options |
510 | cat >options.awk <<'EOF' | |
511 | BEGIN { | |
02e93a22 | 512 | optstr = "A:dD:eEf:hKOrsSU:V"; # getopt-style specification |
2304df62 AD |
513 | |
514 | len = length(optstr); | |
515 | for (i = 1; i <= len; i++) { | |
516 | c = substr(optstr, i, 1); | |
517 | if (i < len) a = substr(optstr, i + 1, 1); else a = ""; | |
518 | if (a == ":") { | |
519 | arg[c] = 1; | |
520 | i++; | |
521 | } | |
522 | opt[c] = 1; | |
523 | } | |
524 | } | |
525 | { | |
526 | expect = 0; | |
527 | str = $0; | |
528 | if (substr(str, 1, 1) != "-") { | |
529 | printf("'%s'\n", str); | |
530 | next; | |
531 | } | |
532 | len = length($0); | |
533 | for (i = 2; i <= len; i++) { | |
534 | c = substr(str, i, 1); | |
535 | if (!opt[c]) { | |
536 | printf("-%s\n", substr(str, i)); | |
537 | next; | |
538 | } | |
539 | printf("-%s\n", c); | |
540 | if (arg[c]) { | |
541 | if (i < len) | |
542 | printf("'%s'\n", substr(str, i + 1)); | |
543 | else | |
544 | expect = 1; | |
545 | next; | |
546 | } | |
547 | } | |
548 | } | |
549 | END { | |
550 | if (expect) | |
551 | print "?"; | |
552 | } | |
553 | EOF | |
554 | ||
555 | : process the command line options | |
4633a7c4 LW |
556 | set X `for arg in "$@"; do echo "X$arg"; done | |
557 | sed -e s/X// | awk -f options.awk` | |
2304df62 AD |
558 | eval "set $*" |
559 | shift | |
560 | rm -f options.awk | |
561 | ||
562 | : set up default values | |
563 | fastread='' | |
564 | reuseval=false | |
565 | config_sh='' | |
566 | alldone='' | |
567 | error='' | |
568 | silent='' | |
569 | extractsh='' | |
ecfc5424 | 570 | override='' |
16d20bd9 | 571 | knowitall='' |
02e93a22 | 572 | rm -f optdef.sh posthint.sh |
28757baa | 573 | cat >optdef.sh <<EOS |
574 | $startsh | |
575 | EOS | |
2304df62 | 576 | |
dfe9444c | 577 | |
2304df62 AD |
578 | : option parsing |
579 | while test $# -gt 0; do | |
580 | case "$1" in | |
581 | -d) shift; fastread=yes;; | |
582 | -e) shift; alldone=cont;; | |
583 | -f) | |
584 | shift | |
585 | cd .. | |
586 | if test -r "$1"; then | |
587 | config_sh="$1" | |
588 | else | |
a0d0e21e | 589 | echo "$me: cannot read config file $1." >&2 |
2304df62 AD |
590 | error=true |
591 | fi | |
592 | cd UU | |
593 | shift;; | |
594 | -h) shift; error=true;; | |
595 | -r) shift; reuseval=true;; | |
dfe9444c | 596 | -s) shift; silent=true; realsilent=true;; |
2304df62 | 597 | -E) shift; alldone=exit;; |
16d20bd9 | 598 | -K) shift; knowitall=true;; |
ecfc5424 | 599 | -O) shift; override=true;; |
dfe9444c | 600 | -S) shift; silent=true; extractsh=true;; |
a0d0e21e LW |
601 | -D) |
602 | shift | |
603 | case "$1" in | |
604 | *=) | |
605 | echo "$me: use '-U symbol=', not '-D symbol='." >&2 | |
606 | echo "$me: ignoring -D $1" >&2 | |
607 | ;; | |
ecfc5424 | 608 | *=*) echo "$1" | \ |
1aef975c AD |
609 | sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;; |
610 | *) echo "$1='define'" >> optdef.sh;; | |
a0d0e21e LW |
611 | esac |
612 | shift | |
613 | ;; | |
614 | -U) | |
615 | shift | |
616 | case "$1" in | |
1aef975c | 617 | *=) echo "$1" >> optdef.sh;; |
a0d0e21e LW |
618 | *=*) |
619 | echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2 | |
620 | echo "$me: ignoring -U $1" >&2 | |
621 | ;; | |
1aef975c | 622 | *) echo "$1='undef'" >> optdef.sh;; |
a0d0e21e LW |
623 | esac |
624 | shift | |
625 | ;; | |
02e93a22 JH |
626 | -A) |
627 | shift | |
628 | xxx='' | |
629 | yyy="$1" | |
02e93a22 | 630 | zzz='' |
5f83a3e9 | 631 | uuu=undef |
02e93a22 | 632 | case "$yyy" in |
5f83a3e9 JH |
633 | *=*) zzz=`echo $yyy|sed 's!=.*!!'` |
634 | case "$zzz" in | |
635 | *:*) zzz='' ;; | |
636 | *) xxx=append | |
637 | zzz=" "`echo $yyy|sed 's!^[^=]*=!!'` | |
638 | yyy=`echo $yyy|sed 's!=.*!!'` ;; | |
639 | esac | |
640 | ;; | |
641 | esac | |
642 | case "$xxx" in | |
643 | '') case "$yyy" in | |
644 | *:*) xxx=`echo $yyy|sed 's!:.*!!'` | |
645 | yyy=`echo $yyy|sed 's!^[^:]*:!!'` | |
646 | zzz=`echo $yyy|sed 's!^[^=]*=!!'` | |
647 | yyy=`echo $yyy|sed 's!=.*!!'` ;; | |
648 | *) xxx=`echo $yyy|sed 's!:.*!!'` | |
649 | yyy=`echo $yyy|sed 's!^[^:]*:!!'` ;; | |
650 | esac | |
651 | ;; | |
652 | esac | |
02e93a22 JH |
653 | case "$xxx" in |
654 | append) | |
5f83a3e9 | 655 | echo "$yyy=\"\${$yyy}$zzz\"" >> posthint.sh ;; |
02e93a22 | 656 | clear) |
5f83a3e9 | 657 | echo "$yyy=''" >> posthint.sh ;; |
02e93a22 JH |
658 | define) |
659 | case "$zzz" in | |
660 | '') zzz=define ;; | |
661 | esac | |
5f83a3e9 | 662 | echo "$yyy='$zzz'" >> posthint.sh ;; |
02e93a22 | 663 | eval) |
5f83a3e9 | 664 | echo "eval \"$yyy=$zzz\"" >> posthint.sh ;; |
02e93a22 | 665 | prepend) |
5f83a3e9 | 666 | echo "$yyy=\"$zzz\${$yyy}\"" >> posthint.sh ;; |
02e93a22 JH |
667 | undef) |
668 | case "$zzz" in | |
669 | '') zzz="$uuu" ;; | |
670 | esac | |
5f83a3e9 JH |
671 | echo "$yyy=$zzz" >> posthint.sh ;; |
672 | *) echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;; | |
02e93a22 | 673 | esac |
bde6b06b | 674 | shift |
02e93a22 | 675 | ;; |
dfe9444c | 676 | -V) echo "$me generated by metaconfig 3.0 PL70." >&2 |
5f83a3e9 | 677 | exit 0;; |
2304df62 | 678 | --) break;; |
a0d0e21e | 679 | -*) echo "$me: unknown option $1" >&2; shift; error=true;; |
2304df62 AD |
680 | *) break;; |
681 | esac | |
682 | done | |
683 | ||
684 | case "$error" in | |
685 | true) | |
686 | cat >&2 <<EOM | |
2afac517 | 687 | Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value] |
02e93a22 | 688 | [-U symbol] [-U symbol=] [-A command:symbol...] |
2304df62 AD |
689 | -d : use defaults for all answers. |
690 | -e : go on without questioning past the production of config.sh. | |
691 | -f : specify an alternate default configuration file. | |
692 | -h : print this help message and exit (with an error status). | |
693 | -r : reuse C symbols value if possible (skips costly nm extraction). | |
694 | -s : silent mode, only echoes questions and essential information. | |
a0d0e21e LW |
695 | -D : define symbol to have some value: |
696 | -D symbol symbol gets the value 'define' | |
697 | -D symbol=value symbol gets the value 'value' | |
2304df62 | 698 | -E : stop at the end of questions, after having produced config.sh. |
16d20bd9 | 699 | -K : do not use unless you know what you are doing. |
ecfc5424 | 700 | -O : let -D and -U override definitions from loaded configuration file. |
2304df62 | 701 | -S : perform variable substitutions on all .SH files (can mix with -f) |
a0d0e21e LW |
702 | -U : undefine symbol: |
703 | -U symbol symbol gets the value 'undef' | |
704 | -U symbol= symbol gets completely empty | |
02e93a22 | 705 | -A : manipulate symbol after the platform specific hints have been applied: |
5f83a3e9 | 706 | -A symbol=value append " "value to symbol |
02e93a22 JH |
707 | -A append:symbol=value append value to symbol |
708 | -A define:symbol=value define symbol to have value | |
02e93a22 JH |
709 | -A clear:symbol define symbol to be '' |
710 | -A define:symbol define symbol to be 'define' | |
711 | -A eval:symbol=value define symbol to be eval of value | |
712 | -A prepend:symbol=value prepend value to symbol | |
713 | -A undef:symbol define symbol to be 'undef' | |
714 | -A undef:symbol= define symbol to be '' | |
2304df62 AD |
715 | -V : print version number and exit (with a zero status). |
716 | EOM | |
717 | exit 1 | |
718 | ;; | |
719 | esac | |
720 | ||
dfe9444c AD |
721 | : Sanity checks |
722 | case "$fastread$alldone" in | |
723 | yescont|yesexit) ;; | |
724 | *) | |
aaeb8e51 GS |
725 | case "$extractsh" in |
726 | true) ;; | |
727 | *) | |
728 | if test ! -t 0; then | |
729 | echo "Say 'sh Configure', not 'sh <Configure'" | |
730 | exit 1 | |
731 | fi | |
732 | ;; | |
733 | esac | |
dfe9444c AD |
734 | ;; |
735 | esac | |
736 | ||
2304df62 AD |
737 | exec 4>&1 |
738 | case "$silent" in | |
739 | true) exec 1>/dev/null;; | |
740 | esac | |
741 | ||
ecfc5424 | 742 | : run the defines and the undefines, if any, but leave the file out there... |
1aef975c AD |
743 | touch optdef.sh |
744 | . ./optdef.sh | |
02e93a22 JH |
745 | : create the posthint manipulation script and leave the file out there... |
746 | touch posthint.sh | |
a0d0e21e | 747 | |
2304df62 | 748 | : set package name |
85e6fe83 | 749 | package=perl5 |
2304df62 | 750 | |
2304df62 AD |
751 | : Some greps do not return status, grrr. |
752 | echo "grimblepritz" >grimble | |
753 | if grep blurfldyick grimble >/dev/null 2>&1 ; then | |
754 | contains=contains | |
755 | elif grep grimblepritz grimble >/dev/null 2>&1 ; then | |
756 | contains=grep | |
757 | else | |
758 | contains=contains | |
759 | fi | |
760 | rm -f grimble | |
761 | : the following should work in any shell | |
762 | case "$contains" in | |
763 | contains*) | |
764 | echo " " | |
765 | echo "AGH! Grep doesn't return a status. Attempting remedial action." | |
766 | cat >contains <<'EOSS' | |
767 | grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp | |
768 | EOSS | |
769 | chmod +x contains | |
770 | esac | |
771 | ||
dfe9444c AD |
772 | : Find the path to the source tree |
773 | case "$src" in | |
774 | '') case "$0" in | |
b233458b JH |
775 | */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'` |
776 | case "$src" in | |
777 | /*) ;; | |
778 | *) src=`cd ../$src && pwd` ;; | |
779 | esac | |
780 | ;; | |
dfe9444c AD |
781 | *) src='.';; |
782 | esac;; | |
783 | esac | |
784 | case "$src" in | |
785 | '') src=/ | |
786 | rsrc=/ | |
787 | ;; | |
788 | /*) rsrc="$src";; | |
789 | *) rsrc="../$src";; | |
790 | esac | |
791 | if test -f $rsrc/Configure && \ | |
792 | $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1 | |
793 | then | |
794 | : found it, so we are ok. | |
795 | else | |
796 | rsrc='' | |
797 | for src in . .. ../.. ../../.. ../../../..; do | |
798 | if test -f ../$src/Configure && \ | |
799 | $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1 | |
800 | then | |
801 | rsrc=../$src | |
802 | break | |
803 | fi | |
804 | done | |
805 | fi | |
806 | case "$rsrc" in | |
807 | '') | |
808 | cat <<EOM >&4 | |
809 | ||
810 | Sorry, I can't seem to locate the source dir for $package. Please start | |
811 | Configure with an explicit path -- i.e. /some/path/Configure. | |
812 | ||
813 | EOM | |
814 | exit 1 | |
815 | ;; | |
816 | ../.) rsrc='..';; | |
817 | *) | |
818 | echo " " | |
819 | echo "Sources for $package found in \"$src\"." >&4 | |
820 | ;; | |
821 | esac | |
822 | ||
823 | : script used to extract .SH files with variable substitutions | |
824 | cat >extract <<'EOS' | |
2000072c | 825 | CONFIGDOTSH=true |
dfe9444c AD |
826 | echo "Doing variable substitutions on .SH files..." |
827 | if test -f $src/MANIFEST; then | |
f7ab18e9 | 828 | set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'` |
dfe9444c AD |
829 | else |
830 | echo "(Looking for .SH files under the source directory.)" | |
831 | set x `(cd $src; find . -name "*.SH" -print)` | |
832 | fi | |
833 | shift | |
834 | case $# in | |
835 | 0) set x `(cd $src; echo *.SH)`; shift;; | |
836 | esac | |
837 | if test ! -f $src/$1; then | |
838 | shift | |
839 | fi | |
840 | mkdir_p=' | |
841 | name=$1; | |
842 | create=""; | |
843 | while test $name; do | |
844 | if test ! -d "$name"; then | |
845 | create="$name $create"; | |
846 | name=`echo $name | sed -e "s|^[^/]*$||"`; | |
847 | name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`; | |
848 | else | |
849 | name=""; | |
850 | fi; | |
851 | done; | |
852 | for file in $create; do | |
853 | mkdir $file; | |
854 | done | |
855 | ' | |
856 | for file in $*; do | |
857 | case "$src" in | |
858 | ".") | |
859 | case "$file" in | |
860 | */*) | |
861 | dir=`expr X$file : 'X\(.*\)/'` | |
862 | file=`expr X$file : 'X.*/\(.*\)'` | |
863 | (cd $dir && . ./$file) | |
864 | ;; | |
865 | *) | |
866 | . ./$file | |
867 | ;; | |
868 | esac | |
869 | ;; | |
870 | *) | |
871 | case "$file" in | |
872 | */*) | |
873 | dir=`expr X$file : 'X\(.*\)/'` | |
874 | file=`expr X$file : 'X.*/\(.*\)'` | |
875 | (set x $dir; shift; eval $mkdir_p) | |
876 | sh <$src/$dir/$file | |
877 | ;; | |
878 | *) | |
879 | sh <$src/$file | |
880 | ;; | |
881 | esac | |
882 | ;; | |
883 | esac | |
884 | done | |
885 | if test -f $src/config_h.SH; then | |
886 | if test ! -f config.h; then | |
887 | : oops, they left it out of MANIFEST, probably, so do it anyway. | |
888 | . $src/config_h.SH | |
889 | fi | |
890 | fi | |
891 | EOS | |
892 | ||
893 | : extract files and exit if asked to do so | |
894 | case "$extractsh" in | |
895 | true) | |
896 | case "$realsilent" in | |
897 | true) ;; | |
898 | *) exec 1>&4;; | |
899 | esac | |
900 | case "$config_sh" in | |
901 | '') config_sh='config.sh';; | |
902 | esac | |
903 | echo " " | |
904 | echo "Fetching answers from $config_sh..." | |
905 | cd .. | |
906 | . $config_sh | |
907 | test "$override" && . ./optdef.sh | |
908 | echo " " | |
909 | . UU/extract | |
910 | rm -rf UU | |
911 | echo "Done." | |
912 | exit 0 | |
913 | ;; | |
914 | esac | |
915 | ||
916 | : Eunice requires " " instead of "", can you believe it | |
917 | echo " " | |
918 | : Here we go... | |
919 | echo "Beginning of configuration questions for $package." | |
920 | ||
921 | trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15 | |
922 | ||
2304df62 AD |
923 | : first determine how to suppress newline on echo command |
924 | echo " " | |
925 | echo "Checking echo to see how to suppress newlines..." | |
926 | (echo "hi there\c" ; echo " ") >.echotmp | |
927 | if $contains c .echotmp >/dev/null 2>&1 ; then | |
928 | echo "...using -n." | |
929 | n='-n' | |
930 | c='' | |
931 | else | |
932 | cat <<'EOM' | |
933 | ...using \c | |
934 | EOM | |
935 | n='' | |
936 | c='\c' | |
937 | fi | |
938 | echo $n "The star should be here-->$c" | |
939 | echo '*' | |
940 | rm -f .echotmp | |
941 | ||
942 | : Now test for existence of everything in MANIFEST | |
943 | echo " " | |
dfe9444c | 944 | if test -f $rsrc/MANIFEST; then |
2304df62 | 945 | echo "First let's make sure your kit is complete. Checking..." >&4 |
dfe9444c | 946 | awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50 |
2304df62 | 947 | rm -f missing |
dfe9444c | 948 | tmppwd=`pwd` |
2304df62 | 949 | for filelist in x??; do |
dfe9444c | 950 | (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing) |
2304df62 AD |
951 | done |
952 | if test -s missing; then | |
953 | cat missing >&4 | |
954 | cat >&4 <<'EOM' | |
955 | ||
956 | THIS PACKAGE SEEMS TO BE INCOMPLETE. | |
957 | ||
958 | You have the option of continuing the configuration process, despite the | |
959 | distinct possibility that your kit is damaged, by typing 'y'es. If you | |
960 | do, don't blame me if something goes wrong. I advise you to type 'n'o | |
7f2de2d2 | 961 | and contact the author (perlbug@perl.org). |
2304df62 AD |
962 | |
963 | EOM | |
964 | echo $n "Continue? [n] $c" >&4 | |
965 | read ans | |
966 | case "$ans" in | |
967 | y*) | |
968 | echo "Continuing..." >&4 | |
969 | rm -f missing | |
970 | ;; | |
971 | *) | |
972 | echo "ABORTING..." >&4 | |
973 | kill $$ | |
974 | ;; | |
975 | esac | |
976 | else | |
dfe9444c | 977 | echo "Looks good..." |
2304df62 AD |
978 | fi |
979 | else | |
980 | echo "There is no MANIFEST file. I hope your kit is complete !" | |
981 | fi | |
982 | rm -f missing x?? | |
983 | ||
5ff3f7a4 GS |
984 | echo " " |
985 | : Find the appropriate value for a newline for tr | |
986 | if test -n "$DJGPP"; then | |
987 | trnl='\012' | |
988 | fi | |
989 | if test X"$trnl" = X; then | |
990 | case "`echo foo|tr '\n' x 2>/dev/null`" in | |
991 | foox) trnl='\n' ;; | |
992 | esac | |
993 | fi | |
994 | if test X"$trnl" = X; then | |
995 | case "`echo foo|tr '\012' x 2>/dev/null`" in | |
996 | foox) trnl='\012' ;; | |
997 | esac | |
998 | fi | |
999 | if test X"$trnl" = X; then | |
1000 | cat <<EOM >&2 | |
1001 | ||
1002 | $me: Fatal Error: cannot figure out how to translate newlines with 'tr'. | |
1003 | ||
1004 | EOM | |
1005 | exit 1 | |
1006 | fi | |
1007 | ||
2304df62 AD |
1008 | : compute the number of columns on the terminal for proper question formatting |
1009 | case "$COLUMNS" in | |
1010 | '') COLUMNS='80';; | |
1011 | esac | |
1012 | ||
1013 | : set up the echo used in my read | |
1014 | myecho="case \"\$xxxm\" in | |
1015 | '') echo $n \"\$rp $c\" >&4;; | |
1016 | *) case \"\$rp\" in | |
1017 | '') echo $n \"[\$xxxm] $c\";; | |
1018 | *) | |
1019 | if test \`echo \"\$rp [\$xxxm] \" | wc -c\` -ge $COLUMNS; then | |
1020 | echo \"\$rp\" >&4 | |
1021 | echo $n \"[\$xxxm] $c\" >&4 | |
1022 | else | |
1023 | echo $n \"\$rp [\$xxxm] $c\" >&4 | |
1024 | fi | |
1025 | ;; | |
1026 | esac;; | |
1027 | esac" | |
1028 | ||
1029 | : now set up to do reads with possible shell escape and default assignment | |
1030 | cat <<EOSC >myread | |
28757baa | 1031 | $startsh |
2304df62 AD |
1032 | xxxm=\$dflt |
1033 | $myecho | |
1034 | ans='!' | |
1035 | case "\$fastread" in | |
1036 | yes) case "\$dflt" in | |
1037 | '') ;; | |
1038 | *) ans=''; | |
1039 | case "\$silent-\$rp" in | |
1040 | true-) ;; | |
1041 | *) echo " " >&4;; | |
1042 | esac;; | |
1043 | esac;; | |
1044 | *) case "\$silent" in | |
1045 | true) case "\$rp" in | |
1046 | '') ans='';; | |
1047 | esac;; | |
1048 | esac;; | |
1049 | esac | |
1050 | while expr "X\$ans" : "X!" >/dev/null; do | |
1051 | read answ | |
1052 | set x \$xxxm | |
1053 | shift | |
dfe9444c | 1054 | aok=''; eval "ans=\\"\$answ\\"" && aok=y |
2304df62 | 1055 | case "\$answ" in |
dfe9444c AD |
1056 | "!") |
1057 | sh 1>&4 | |
1058 | echo " " | |
1059 | $myecho | |
1060 | ;; | |
1061 | !*) | |
1062 | set x \`expr "X\$ans" : "X!\(.*\)\$"\` | |
1063 | shift | |
1064 | sh 1>&4 -c "\$*" | |
1065 | echo " " | |
1066 | $myecho | |
1067 | ;; | |
2304df62 AD |
1068 | "\$ans") |
1069 | case "\$ans" in | |
ecfc5424 AD |
1070 | \\&*) |
1071 | set x \`expr "X\$ans" : "X&\(.*\)\$"\` | |
1072 | shift | |
1073 | case "\$1" in | |
1074 | -d) | |
1075 | fastread=yes | |
40a7a20a | 1076 | echo "(OK, I'll run with -d after this question.)" >&4 |
ecfc5424 AD |
1077 | ;; |
1078 | -*) | |
40a7a20a | 1079 | echo "*** Sorry, \$1 not supported yet." >&4 |
ecfc5424 AD |
1080 | ;; |
1081 | esac | |
1082 | $myecho | |
1083 | ans=! | |
1084 | ;; | |
2304df62 AD |
1085 | esac;; |
1086 | *) | |
1087 | case "\$aok" in | |
1088 | y) | |
1089 | echo "*** Substitution done -- please confirm." | |
1090 | xxxm="\$ans" | |
c9795ab7 | 1091 | ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\` |
2304df62 AD |
1092 | xxxm="\$ans" |
1093 | ans=! | |
1094 | ;; | |
1095 | *) | |
1096 | echo "*** Error -- try again." | |
1097 | ans=! | |
1098 | ;; | |
1099 | esac | |
1100 | $myecho | |
1101 | ;; | |
1102 | esac | |
1103 | case "\$ans\$xxxm\$nostick" in | |
1104 | '') | |
1105 | ans=! | |
1106 | $myecho | |
1107 | ;; | |
1108 | esac | |
1109 | done | |
1110 | case "\$ans" in | |
1111 | '') ans="\$xxxm";; | |
1112 | esac | |
1113 | EOSC | |
1114 | ||
1115 | : create .config dir to save info across Configure sessions | |
1116 | test -d ../.config || mkdir ../.config | |
1117 | cat >../.config/README <<EOF | |
1118 | This directory created by Configure to save information that should | |
dfe9444c | 1119 | persist across sessions for $package. |
2304df62 AD |
1120 | |
1121 | You may safely delete it if you wish. | |
1122 | EOF | |
1123 | ||
9507cadf | 1124 | xversion=`awk '/define[ ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h` |
af960fef | 1125 | case "$usedevel" in |
0107c034 | 1126 | $define|true|[yY]*) ;; |
9507cadf | 1127 | *) case "$xversion" in |
0107c034 JH |
1128 | *[13579]) |
1129 | cat >&4 <<EOH | |
1130 | *** WHOA THERE!!! *** | |
1131 | ||
1132 | This is an UNSTABLE DEVELOPMENT release. | |
9507cadf JH |
1133 | The version of this $package distribution is $xversion, that is, odd, |
1134 | (as opposed to even) and that signifies a development release. | |
3d5d58b1 | 1135 | If you want a maintenance release, you want an even-numbered version. |
0107c034 JH |
1136 | |
1137 | Do ***NOT*** install this into production use. | |
1138 | Data corruption and crashes are possible. | |
1139 | ||
1140 | It is most seriously suggested that you do not continue any further | |
1141 | unless you want to help in developing and debugging Perl. | |
1142 | ||
1143 | EOH | |
1144 | rp='Do you really want to continue?' | |
1145 | dflt='n' | |
1146 | . ./myread | |
1147 | case "$ans" in | |
1148 | [yY]) echo >&4 "Okay, continuing." ;; | |
1149 | *) echo >&4 "Okay, bye." | |
1150 | exit 1 | |
1151 | ;; | |
1152 | esac | |
1153 | ;; | |
1154 | esac | |
1155 | ;; | |
1156 | esac | |
1157 | ||
2304df62 AD |
1158 | : general instructions |
1159 | needman=true | |
1160 | firsttime=true | |
760ac839 | 1161 | user=`(logname) 2>/dev/null` |
dfe9444c AD |
1162 | case "$user" in |
1163 | '') user=`whoami 2>&1`;; | |
760ac839 | 1164 | esac |
2304df62 AD |
1165 | if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then |
1166 | firsttime=false | |
1167 | echo " " | |
1168 | rp='Would you like to see the instructions?' | |
1169 | dflt=n | |
1170 | . ./myread | |
1171 | case "$ans" in | |
1172 | [yY]*) ;; | |
1173 | *) needman=false;; | |
1174 | esac | |
1175 | fi | |
1176 | if $needman; then | |
1177 | cat <<EOH | |
4e2a5f63 | 1178 | |
2304df62 | 1179 | This installation shell script will examine your system and ask you questions |
a0d0e21e | 1180 | to determine how the perl5 package should be installed. If you get |
2304df62 AD |
1181 | stuck on a question, you may use a ! shell escape to start a subshell or |
1182 | execute a command. Many of the questions will have default answers in square | |
1183 | brackets; typing carriage return will give you the default. | |
1184 | ||
1185 | On some of the questions which ask for file or directory names you are allowed | |
1186 | to use the ~name construct to specify the login directory belonging to "name", | |
1187 | even if you don't have a shell which knows about that. Questions where this is | |
1188 | allowed will be marked "(~name ok)". | |
1189 | ||
1190 | EOH | |
1191 | rp='' | |
1192 | dflt='Type carriage return to continue' | |
1193 | . ./myread | |
1194 | cat <<'EOH' | |
1195 | ||
1196 | The prompter used in this script allows you to use shell variables and | |
1197 | backticks in your answers. You may use $1, $2, etc... to refer to the words | |
1198 | in the default answer, as if the default line was a set of arguments given to a | |
1199 | script shell. This means you may also use $* to repeat the whole default line, | |
1200 | so you do not have to re-type everything to add something to the default. | |
1201 | ||
1202 | Everytime there is a substitution, you will have to confirm. If there is an | |
1203 | error (e.g. an unmatched backtick), the default answer will remain unchanged | |
1204 | and you will be prompted again. | |
1205 | ||
1206 | If you are in a hurry, you may run 'Configure -d'. This will bypass nearly all | |
1207 | the questions and use the computed defaults (or the previous answers if there | |
1208 | was already a config.sh file). Type 'Configure -h' for a list of options. | |
ecfc5424 | 1209 | You may also start interactively and then answer '& -d' at any prompt to turn |
dfe9444c | 1210 | on the non-interactive behaviour for the remainder of the execution. |
2304df62 AD |
1211 | |
1212 | EOH | |
1213 | . ./myread | |
1214 | cat <<EOH | |
1215 | ||
1216 | Much effort has been expended to ensure that this shell script will run on any | |
1217 | Unix system. If despite that it blows up on yours, your best bet is to edit | |
40000a8c AD |
1218 | Configure and run it again. If you can't run Configure for some reason, |
1219 | you'll have to generate a config.sh file by hand. Whatever problems you | |
7f2de2d2 | 1220 | have, let me (perlbug@perl.org) know how I blew it. |
2304df62 AD |
1221 | |
1222 | This installation script affects things in two ways: | |
1223 | ||
1224 | 1) it may do direct variable substitutions on some of the files included | |
1225 | in this kit. | |
1226 | 2) it builds a config.h file for inclusion in C programs. You may edit | |
1227 | any of these files as the need arises after running this script. | |
1228 | ||
1229 | If you make a mistake on a question, there is no easy way to back up to it | |
1230 | currently. The easiest thing to do is to edit config.sh and rerun all the SH | |
1231 | files. Configure will offer to let you do this before it runs the SH files. | |
1232 | ||
1233 | EOH | |
1234 | dflt='Type carriage return to continue' | |
1235 | . ./myread | |
1236 | case "$firsttime" in | |
1237 | true) echo $user >>../.config/instruct;; | |
1238 | esac | |
1239 | fi | |
1240 | ||
2304df62 AD |
1241 | : find out where common programs are |
1242 | echo " " | |
1243 | echo "Locating common programs..." >&4 | |
1244 | cat <<EOSC >loc | |
1245 | $startsh | |
1246 | case \$# in | |
1247 | 0) exit 1;; | |
1248 | esac | |
1249 | thing=\$1 | |
1250 | shift | |
1251 | dflt=\$1 | |
1252 | shift | |
1253 | for dir in \$*; do | |
1254 | case "\$thing" in | |
1255 | .) | |
1256 | if test -d \$dir/\$thing; then | |
1257 | echo \$dir | |
1258 | exit 0 | |
1259 | fi | |
1260 | ;; | |
1261 | *) | |
a0d0e21e | 1262 | for thisthing in \$dir/\$thing; do |
ecfc5424 | 1263 | : just loop through to pick last item |
a0d0e21e | 1264 | done |
25f94b33 | 1265 | if test -f \$thisthing; then |
a0d0e21e | 1266 | echo \$thisthing |
2304df62 AD |
1267 | exit 0 |
1268 | elif test -f \$dir/\$thing.exe; then | |
c4f23d77 AD |
1269 | if test -n "$DJGPP"; then |
1270 | echo \$dir/\$thing.exe | |
1271 | else | |
1272 | : on Eunice apparently | |
1273 | echo \$dir/\$thing | |
1274 | fi | |
2304df62 AD |
1275 | exit 0 |
1276 | fi | |
1277 | ;; | |
1278 | esac | |
1279 | done | |
1280 | echo \$dflt | |
1281 | exit 1 | |
1282 | EOSC | |
1283 | chmod +x loc | |
1284 | $eunicefix loc | |
1285 | loclist=" | |
1286 | awk | |
1287 | cat | |
2304df62 AD |
1288 | echo |
1289 | expr | |
1290 | grep | |
a0d0e21e | 1291 | ls |
dfe9444c | 1292 | make |
2304df62 AD |
1293 | rm |
1294 | sed | |
85e6fe83 | 1295 | touch |
2304df62 | 1296 | tr |
2304df62 AD |
1297 | " |
1298 | trylist=" | |
1299 | Mcc | |
dfe9444c | 1300 | ar |
2304df62 | 1301 | cpp |
2304df62 AD |
1302 | date |
1303 | egrep | |
8ff267be | 1304 | gzip |
8ff267be | 1305 | ln |
693762b4 | 1306 | nm |
2304df62 AD |
1307 | test |
1308 | uname | |
8ff267be | 1309 | zip |
2304df62 | 1310 | " |
8e07c86e | 1311 | pth=`echo $PATH | sed -e "s/$p_/ /g"` |
2304df62 AD |
1312 | pth="$pth /lib /usr/lib" |
1313 | for file in $loclist; do | |
dfe9444c AD |
1314 | eval xxx=\$$file |
1315 | case "$xxx" in | |
1316 | /*|?:[\\/]*) | |
1317 | if test -f "$xxx"; then | |
1318 | : ok | |
1319 | else | |
1320 | echo "WARNING: no $xxx -- ignoring your setting for $file." >&4 | |
1321 | xxx=`./loc $file $file $pth` | |
1322 | fi | |
1323 | ;; | |
1324 | '') xxx=`./loc $file $file $pth`;; | |
1325 | *) xxx=`./loc $xxx $xxx $pth`;; | |
1326 | esac | |
2304df62 AD |
1327 | eval $file=$xxx |
1328 | eval _$file=$xxx | |
1329 | case "$xxx" in | |
1330 | /*) | |
1331 | echo $file is in $xxx. | |
1332 | ;; | |
8e07c86e AD |
1333 | ?:[\\/]*) |
1334 | echo $file is in $xxx. | |
1335 | ;; | |
2304df62 | 1336 | *) |
25f94b33 AD |
1337 | echo "I don't know where '$file' is, and my life depends on it." >&4 |
1338 | echo "Go find a public domain implementation or fix your PATH setting!" >&4 | |
4633a7c4 | 1339 | exit 1 |
2304df62 AD |
1340 | ;; |
1341 | esac | |
1342 | done | |
1343 | echo " " | |
1344 | echo "Don't worry if any of the following aren't found..." | |
1345 | say=offhand | |
1346 | for file in $trylist; do | |
dfe9444c AD |
1347 | eval xxx=\$$file |
1348 | case "$xxx" in | |
1349 | /*|?:[\\/]*) | |
1350 | if test -f "$xxx"; then | |
1351 | : ok | |
1352 | else | |
1353 | echo "WARNING: no $xxx -- ignoring your setting for $file." >&4 | |
1354 | xxx=`./loc $file $file $pth` | |
1355 | fi | |
1356 | ;; | |
1357 | '') xxx=`./loc $file $file $pth`;; | |
1358 | *) xxx=`./loc $xxx $xxx $pth`;; | |
1359 | esac | |
2304df62 AD |
1360 | eval $file=$xxx |
1361 | eval _$file=$xxx | |
1362 | case "$xxx" in | |
1363 | /*) | |
1364 | echo $file is in $xxx. | |
1365 | ;; | |
8e07c86e AD |
1366 | ?:[\\/]*) |
1367 | echo $file is in $xxx. | |
1368 | ;; | |
2304df62 AD |
1369 | *) |
1370 | echo "I don't see $file out there, $say." | |
1371 | say=either | |
1372 | ;; | |
1373 | esac | |
1374 | done | |
1375 | case "$egrep" in | |
1376 | egrep) | |
1377 | echo "Substituting grep for egrep." | |
1378 | egrep=$grep | |
1379 | ;; | |
1380 | esac | |
8ff267be | 1381 | case "$ln" in |
1382 | ln) | |
1383 | echo "Substituting cp for ln." | |
1384 | ln=$cp | |
1385 | ;; | |
1386 | esac | |
2304df62 AD |
1387 | case "$test" in |
1388 | test) | |
1389 | echo "Hopefully test is built into your sh." | |
1390 | ;; | |
1391 | *) | |
ecfc5424 | 1392 | if `sh -c "PATH= test true" >/dev/null 2>&1`; then |
2304df62 AD |
1393 | echo "Using the test built into your sh." |
1394 | test=test | |
1395 | _test=test | |
1396 | fi | |
1397 | ;; | |
1398 | esac | |
1399 | case "$echo" in | |
1400 | echo) | |
1401 | echo "Hopefully echo is built into your sh." | |
1402 | ;; | |
1403 | '') ;; | |
1404 | *) | |
1405 | echo " " | |
1406 | echo "Checking compatibility between $echo and builtin echo (if any)..." >&4 | |
1407 | $echo $n "hi there$c" >foo1 | |
1408 | echo $n "hi there$c" >foo2 | |
1409 | if cmp foo1 foo2 >/dev/null 2>&1; then | |
1410 | echo "They are compatible. In fact, they may be identical." | |
1411 | else | |
1412 | case "$n" in | |
1413 | '-n') n='' c='\c';; | |
1414 | *) n='-n' c='';; | |
1415 | esac | |
1416 | cat <<FOO | |
1417 | They are not compatible! You are probably running ksh on a non-USG system. | |
1418 | I'll have to use $echo instead of the builtin, since Bourne shell doesn't | |
1419 | have echo built in and we may have to run some Bourne shell scripts. That | |
1420 | means I'll have to use '$n$c' to suppress newlines now. Life is ridiculous. | |
1421 | ||
1422 | FOO | |
1423 | $echo $n "The star should be here-->$c" | |
1424 | $echo "*" | |
1425 | fi | |
1426 | $rm -f foo1 foo2 | |
1427 | ;; | |
1428 | esac | |
1429 | ||
2573c5f9 JH |
1430 | cat <<EOS >checkcc |
1431 | $startsh | |
1432 | EOS | |
1433 | cat <<'EOSC' >>checkcc | |
1434 | case "$cc" in | |
1435 | '') ;; | |
1436 | *) $rm -f try try.* | |
1437 | $cat >try.c <<EOM | |
1438 | int main(int argc, char *argv[]) { | |
1439 | return 0; | |
1440 | } | |
1441 | EOM | |
1442 | if $cc -o try try.c; then | |
1443 | : | |
1444 | else | |
1445 | echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4 | |
1446 | despair=yes | |
1447 | trygcc=yes | |
1448 | case "$cc" in | |
1449 | *gcc*) trygcc=no ;; | |
1450 | esac | |
1451 | case "`$cc -v -c try.c 2>&1`" in | |
1452 | *gcc*) trygcc=no ;; | |
1453 | esac | |
1454 | if $test X"$trygcc" = Xyes; then | |
1455 | if gcc -o try -c try.c; then | |
1456 | echo " " | |
1457 | echo "You seem to have a working gcc, though." >&4 | |
1458 | rp="Would you like to use it?" | |
1459 | dflt=y | |
1460 | if $test -f myread; then | |
1461 | . ./myread | |
1462 | else | |
1463 | if $test -f UU/myread; then | |
1464 | . ./UU/myread | |
1465 | else | |
1466 | echo "Cannot find myread, sorry. Aborting." >&2 | |
1467 | exit 1 | |
1468 | fi | |
1469 | fi | |
1470 | case "$ans" in | |
e723fc21 | 1471 | [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no ;; |
2573c5f9 JH |
1472 | esac |
1473 | fi | |
1474 | fi | |
1475 | if $test X"$despair" = Xyes; then | |
1476 | echo "You need to find a working C compiler." >&4 | |
1477 | echo "I cannot continue any further, aborting." >&4 | |
1478 | exit 1 | |
1479 | fi | |
1480 | fi | |
1481 | $rm -f try try.* | |
1482 | ;; | |
1483 | esac | |
1484 | EOSC | |
1485 | ||
a0d0e21e LW |
1486 | : determine whether symbolic links are supported |
1487 | echo " " | |
1488 | $touch blurfl | |
1489 | if $ln -s blurfl sym > /dev/null 2>&1 ; then | |
1490 | echo "Symbolic links are supported." >&4 | |
1491 | lns="$ln -s" | |
1492 | else | |
1493 | echo "Symbolic links are NOT supported." >&4 | |
1494 | lns="$ln" | |
1495 | fi | |
1496 | $rm -f blurfl sym | |
1497 | ||
ecfc5424 AD |
1498 | : see whether [:lower:] and [:upper:] are supported character classes |
1499 | echo " " | |
ecfc5424 AD |
1500 | case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in |
1501 | ABYZ) | |
1502 | echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4 | |
1503 | up='[:upper:]' | |
1504 | low='[:lower:]' | |
1505 | ;; | |
28e8609d JH |
1506 | *) # There is a discontinuity in EBCDIC between 'I' and 'J' |
1507 | # (0xc9 and 0xd1), therefore that is a nice testing point. | |
1508 | if test "X$up" = X -o "X$low" = X; then | |
3eaeeeae | 1509 | case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in |
28e8609d JH |
1510 | ij) up='[A-Z]' |
1511 | low='[a-z]' | |
1512 | ;; | |
1513 | esac | |
1514 | fi | |
1515 | if test "X$up" = X -o "X$low" = X; then | |
3eaeeeae | 1516 | case "`echo IJ | $tr I-J i-j 2>/dev/null`" in |
28e8609d JH |
1517 | ij) up='A-Z' |
1518 | low='a-z' | |
1519 | ;; | |
1520 | esac | |
1521 | fi | |
1522 | if test "X$up" = X -o "X$low" = X; then | |
1523 | case "`echo IJ | od -x 2>/dev/null`" in | |
1524 | *C9D1*|*c9d1*) | |
1525 | echo "Hey, this might be EBCDIC." >&4 | |
1526 | if test "X$up" = X -o "X$low" = X; then | |
5ff3f7a4 | 1527 | case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in |
28e8609d JH |
1528 | ij) up='[A-IJ-RS-Z]' |
1529 | low='[a-ij-rs-z]' | |
1530 | ;; | |
1531 | esac | |
1532 | fi | |
1533 | if test "X$up" = X -o "X$low" = X; then | |
5ff3f7a4 | 1534 | case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in |
28e8609d JH |
1535 | ij) up='A-IJ-RS-Z' |
1536 | low='a-ij-rs-z' | |
1537 | ;; | |
1538 | esac | |
1539 | fi | |
1540 | ;; | |
1541 | esac | |
1542 | fi | |
1543 | esac | |
3eaeeeae | 1544 | case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in |
28e8609d JH |
1545 | ij) |
1546 | echo "Using $up and $low to convert case." >&4 | |
1547 | ;; | |
ecfc5424 | 1548 | *) |
28e8609d JH |
1549 | echo "I don't know how to translate letters from upper to lower case." >&4 |
1550 | echo "Your tr is not acting any way I know of." >&4 | |
1551 | exit 1 | |
1552 | ;; | |
ecfc5424 AD |
1553 | esac |
1554 | : set up the translation script tr, must be called with ./tr of course | |
1555 | cat >tr <<EOSC | |
1556 | $startsh | |
1557 | case "\$1\$2" in | |
1558 | '[A-Z][a-z]') exec $tr '$up' '$low';; | |
1559 | '[a-z][A-Z]') exec $tr '$low' '$up';; | |
1560 | esac | |
1561 | exec $tr "\$@" | |
1562 | EOSC | |
1563 | chmod +x tr | |
1564 | $eunicefix tr | |
1565 | ||
2304df62 AD |
1566 | : Try to determine whether config.sh was made on this system |
1567 | case "$config_sh" in | |
1568 | '') | |
43999f95 JH |
1569 | myuname=`$uname -a 2>/dev/null` |
1570 | $test -z "$myuname" && myuname=`hostname 2>/dev/null` | |
28e8609d JH |
1571 | # tr '[A-Z]' '[a-z]' would not work in EBCDIC |
1572 | # because the A-Z/a-z are not consecutive. | |
a0d0e21e | 1573 | myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \ |
3eaeeeae | 1574 | ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '` |
1aef975c | 1575 | newmyuname="$myuname" |
2304df62 | 1576 | dflt=n |
16d20bd9 AD |
1577 | case "$knowitall" in |
1578 | '') | |
1579 | if test -f ../config.sh; then | |
1580 | if $contains myuname= ../config.sh >/dev/null 2>&1; then | |
1581 | eval "`grep myuname= ../config.sh`" | |
1582 | fi | |
1583 | if test "X$myuname" = "X$newmyuname"; then | |
1584 | dflt=y | |
1585 | fi | |
2304df62 | 1586 | fi |
16d20bd9 AD |
1587 | ;; |
1588 | *) dflt=y;; | |
1589 | esac | |
2304df62 AD |
1590 | |
1591 | : Get old answers from old config file if Configure was run on the | |
1592 | : same system, otherwise use the hints. | |
1593 | hint=default | |
1594 | cd .. | |
1595 | if test -f config.sh; then | |
16d20bd9 AD |
1596 | echo " " |
1597 | rp="I see a config.sh file. Shall I use it to set the defaults?" | |
2304df62 AD |
1598 | . UU/myread |
1599 | case "$ans" in | |
1600 | n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;; | |
1601 | *) echo "Fetching default answers from your old config.sh file..." >&4 | |
ecfc5424 AD |
1602 | tmp_n="$n" |
1603 | tmp_c="$c" | |
85cad39c | 1604 | tmp_sh="$sh" |
2304df62 AD |
1605 | . ./config.sh |
1606 | cp config.sh UU | |
ecfc5424 AD |
1607 | n="$tmp_n" |
1608 | c="$tmp_c" | |
85cad39c | 1609 | : Older versions did not always set $sh. Catch re-use of such |
1610 | : an old config.sh. | |
1611 | case "$sh" in | |
1612 | '') sh="$tmp_sh" ;; | |
1613 | esac | |
2304df62 AD |
1614 | hint=previous |
1615 | ;; | |
1616 | esac | |
1617 | fi | |
2573c5f9 | 1618 | . ./UU/checkcc |
2304df62 AD |
1619 | if test ! -f config.sh; then |
1620 | $cat <<EOM | |
1621 | ||
4e2a5f63 AD |
1622 | First time through, eh? I have some defaults handy for some systems |
1623 | that need some extra help getting the Configure answers right: | |
2304df62 AD |
1624 | |
1625 | EOM | |
dfe9444c | 1626 | (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/ /g' >&4 |
2304df62 AD |
1627 | dflt='' |
1628 | : Half the following guesses are probably wrong... If you have better | |
7f2de2d2 | 1629 | : tests or hints, please send them to perlbug@perl.org |
2304df62 | 1630 | : The metaconfig authors would also appreciate a copy... |
a0d0e21e | 1631 | $test -f /irix && osname=irix |
85e6fe83 LW |
1632 | $test -f /xenix && osname=sco_xenix |
1633 | $test -f /dynix && osname=dynix | |
1634 | $test -f /dnix && osname=dnix | |
5f05dabc | 1635 | $test -f /lynx.os && osname=lynxos |
1636 | $test -f /unicos && osname=unicos && osvers=`$uname -r` | |
c71a9cee | 1637 | $test -f /unicosmk && osname=unicosmk && osvers=`$uname -r` |
7a4c00b4 | 1638 | $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r` |
85e6fe83 | 1639 | $test -f /bin/mips && /bin/mips && osname=mips |
ecfc5424 AD |
1640 | $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \ |
1641 | $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4 | |
a0d0e21e LW |
1642 | $test -d /usr/apollo/bin && osname=apollo |
1643 | $test -f /etc/saf/_sactab && osname=svr4 | |
85e6fe83 | 1644 | $test -d /usr/include/minix && osname=minix |
e060872b | 1645 | if $test -d /MachTen -o -d /MachTen_Folder; then |
dfe9444c | 1646 | osname=machten |
4633a7c4 | 1647 | if $test -x /sbin/version; then |
dfe9444c | 1648 | osvers=`/sbin/version | $awk '{print $2}' | |
4633a7c4 LW |
1649 | $sed -e 's/[A-Za-z]$//'` |
1650 | elif $test -x /usr/etc/version; then | |
dfe9444c | 1651 | osvers=`/usr/etc/version | $awk '{print $2}' | |
4633a7c4 LW |
1652 | $sed -e 's/[A-Za-z]$//'` |
1653 | else | |
1654 | osvers="$2.$3" | |
1655 | fi | |
1656 | fi | |
aaacdc8b GS |
1657 | |
1658 | $test -f /sys/posix.dll && | |
1659 | $test -f /usr/bin/what && | |
1660 | set X `/usr/bin/what /sys/posix.dll` && | |
1661 | $test "$3" = UWIN && | |
1662 | osname=uwin && | |
1663 | osvers="$5" | |
1664 | ||
2304df62 AD |
1665 | if $test -f $uname; then |
1666 | set X $myuname | |
1667 | shift | |
1668 | ||
2304df62 | 1669 | case "$5" in |
85e6fe83 | 1670 | fps*) osname=fps ;; |
2304df62 AD |
1671 | mips*) |
1672 | case "$4" in | |
85e6fe83 LW |
1673 | umips) osname=umips ;; |
1674 | *) osname=mips ;; | |
2304df62 | 1675 | esac;; |
85e6fe83 LW |
1676 | [23]100) osname=mips ;; |
1677 | next*) osname=next ;; | |
ecfc5424 | 1678 | i386*) |
c6912327 JH |
1679 | tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'` |
1680 | if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then | |
619ffc2b JH |
1681 | osname='sco' |
1682 | osvers=$tmp | |
1683 | elif $test -f /etc/kconfig; then | |
ecfc5424 | 1684 | osname=isc |
bd628c73 | 1685 | if test "$lns" = "$ln -s"; then |
a0d0e21e LW |
1686 | osvers=4 |
1687 | elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then | |
1688 | osvers=3 | |
2304df62 | 1689 | elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then |
a0d0e21e | 1690 | osvers=2 |
ecfc5424 AD |
1691 | fi |
1692 | fi | |
2000072c | 1693 | tmp='' |
ecfc5424 | 1694 | ;; |
c4f23d77 AD |
1695 | pc*) |
1696 | if test -n "$DJGPP"; then | |
1697 | osname=dos | |
1698 | osvers=djgpp | |
1699 | fi | |
1700 | ;; | |
2304df62 AD |
1701 | esac |
1702 | ||
1703 | case "$1" in | |
a0d0e21e LW |
1704 | aix) osname=aix |
1705 | tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1` | |
1706 | case "$tmp" in | |
1aef975c | 1707 | 'not found') osvers="$4"."$3" ;; |
a0d0e21e LW |
1708 | '<3240'|'<>3240') osvers=3.2.0 ;; |
1709 | '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;; | |
1710 | '=3250'|'>3250') osvers=3.2.5 ;; | |
1aef975c | 1711 | *) osvers=$tmp;; |
a0d0e21e LW |
1712 | esac |
1713 | ;; | |
aaacdc8b GS |
1714 | bsd386) osname=bsd386 |
1715 | osvers=`$uname -r` | |
1716 | ;; | |
1717 | cygwin*) osname=cygwin | |
1718 | osvers="$3" | |
1719 | ;; | |
23f87696 SZ |
1720 | *dc.osx) osname=dcosx |
1721 | osvers="$3" | |
1722 | ;; | |
a0d0e21e LW |
1723 | dnix) osname=dnix |
1724 | osvers="$3" | |
1725 | ;; | |
1726 | domainos) osname=apollo | |
1727 | osvers="$3" | |
1728 | ;; | |
1729 | dgux) osname=dgux | |
1730 | osvers="$3" | |
1731 | ;; | |
760ac839 | 1732 | dynixptx*) osname=dynixptx |
e58e581d | 1733 | osvers=`echo "$4"|sed 's/^v//'` |
760ac839 | 1734 | ;; |
a0d0e21e LW |
1735 | freebsd) osname=freebsd |
1736 | osvers="$3" ;; | |
1737 | genix) osname=genix ;; | |
1738 | hp*) osname=hpux | |
bfb7748a | 1739 | osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'` |
a0d0e21e | 1740 | ;; |
a78b0d02 | 1741 | irix*) osname=irix |
a0d0e21e LW |
1742 | case "$3" in |
1743 | 4*) osvers=4 ;; | |
1744 | 5*) osvers=5 ;; | |
ecfc5424 | 1745 | *) osvers="$3" ;; |
a0d0e21e LW |
1746 | esac |
1747 | ;; | |
1748 | linux) osname=linux | |
1749 | case "$3" in | |
a0d0e21e LW |
1750 | *) osvers="$3" ;; |
1751 | esac | |
1752 | ;; | |
28e8609d JH |
1753 | MiNT) osname=mint |
1754 | ;; | |
1755 | netbsd*) osname=netbsd | |
ecfc5424 AD |
1756 | osvers="$3" |
1757 | ;; | |
4e81affe MM |
1758 | news-os) osvers="$3" |
1759 | case "$3" in | |
1760 | 4*) osname=newsos4 ;; | |
1761 | *) osname=newsos ;; | |
1762 | esac | |
1763 | ;; | |
aaacdc8b GS |
1764 | next*) osname=next ;; |
1765 | POSIX-BC | posix-bc ) osname=posix-bc | |
1766 | osvers="$3" | |
a0d0e21e | 1767 | ;; |
ae3afa4e TH |
1768 | powerux | power_ux | powermax_os | powermaxos | \ |
1769 | powerunix | power_unix) osname=powerux | |
1770 | osvers="$3" | |
1771 | ;; | |
aaacdc8b GS |
1772 | qnx) osname=qnx |
1773 | osvers="$4" | |
1774 | ;; | |
a0d0e21e LW |
1775 | solaris) osname=solaris |
1776 | case "$3" in | |
1777 | 5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;; | |
ecfc5424 | 1778 | *) osvers="$3" ;; |
a0d0e21e LW |
1779 | esac |
1780 | ;; | |
85e6fe83 LW |
1781 | sunos) osname=sunos |
1782 | case "$3" in | |
85e6fe83 LW |
1783 | 5*) osname=solaris |
1784 | osvers=`echo $3 | $sed 's/^5/2/g'` ;; | |
a0d0e21e | 1785 | *) osvers="$3" ;; |
2304df62 AD |
1786 | esac |
1787 | ;; | |
a0d0e21e | 1788 | titanos) osname=titanos |
85e6fe83 | 1789 | case "$3" in |
a0d0e21e LW |
1790 | 1*) osvers=1 ;; |
1791 | 2*) osvers=2 ;; | |
1792 | 3*) osvers=3 ;; | |
1793 | 4*) osvers=4 ;; | |
ecfc5424 | 1794 | *) osvers="$3" ;; |
2304df62 AD |
1795 | esac |
1796 | ;; | |
85e6fe83 | 1797 | ultrix) osname=ultrix |
ecfc5424 | 1798 | osvers="$3" |
2304df62 | 1799 | ;; |
28757baa | 1800 | osf1|mls+) case "$5" in |
fed7345c AD |
1801 | alpha) |
1802 | osname=dec_osf | |
2aa76180 JH |
1803 | osvers=`sizer -v | awk '{print $3}' | tr '[A-Z]' '[a-z]' | sed 's/^[xvt]//'` |
1804 | case "$osvers" in | |
1805 | [1-9].[0-9]*) ;; | |
1806 | *) osvers=`echo "$3" | sed 's/^[xvt]//'` ;; | |
1807 | esac | |
ecfc5424 AD |
1808 | ;; |
1809 | hp*) osname=hp_osf1 ;; | |
1810 | mips) osname=mips_osf1 ;; | |
85e6fe83 LW |
1811 | esac |
1812 | ;; | |
0337d152 BG |
1813 | unixware) osname=svr5 |
1814 | osvers="$4" | |
1815 | ;; | |
1816 | uts) osname=uts | |
a0d0e21e LW |
1817 | osvers="$3" |
1818 | ;; | |
85e6fe83 | 1819 | $2) case "$osname" in |
2304df62 | 1820 | *isc*) ;; |
a0d0e21e | 1821 | *freebsd*) ;; |
5f05dabc | 1822 | svr*) |
a0d0e21e LW |
1823 | : svr4.x or possibly later |
1824 | case "svr$3" in | |
1825 | ${osname}*) | |
1826 | osname=svr$3 | |
1827 | osvers=$4 | |
1828 | ;; | |
1829 | esac | |
1830 | case "$osname" in | |
1831 | svr4.0) | |
1832 | : Check for ESIX | |
1833 | if test -f /stand/boot ; then | |
1834 | eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot` | |
ecfc5424 AD |
1835 | if test -n "$INITPROG" -a -f "$INITPROG"; then |
1836 | isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'` | |
1837 | if test -n "$isesix"; then | |
a0d0e21e LW |
1838 | osname=esix4 |
1839 | fi | |
1840 | fi | |
1841 | fi | |
1842 | ;; | |
1843 | esac | |
1844 | ;; | |
2304df62 | 1845 | *) if test -f /etc/systemid; then |
a0d0e21e LW |
1846 | osname=sco |
1847 | set `echo $3 | $sed 's/\./ /g'` $4 | |
c4f23d77 | 1848 | if $test -f $src/hints/sco_$1_$2_$3.sh; then |
85e6fe83 | 1849 | osvers=$1.$2.$3 |
c4f23d77 | 1850 | elif $test -f $src/hints/sco_$1_$2.sh; then |
85e6fe83 | 1851 | osvers=$1.$2 |
c4f23d77 | 1852 | elif $test -f $src/hints/sco_$1.sh; then |
85e6fe83 | 1853 | osvers=$1 |
2304df62 | 1854 | fi |
a0d0e21e LW |
1855 | else |
1856 | case "$osname" in | |
1857 | '') : Still unknown. Probably a generic Sys V. | |
1858 | osname="sysv" | |
1859 | osvers="$3" | |
1860 | ;; | |
1861 | esac | |
2304df62 AD |
1862 | fi |
1863 | ;; | |
1864 | esac | |
1865 | ;; | |
a0d0e21e LW |
1866 | *) case "$osname" in |
1867 | '') : Still unknown. Probably a generic BSD. | |
1868 | osname="$1" | |
1869 | osvers="$3" | |
1870 | ;; | |
1871 | esac | |
1872 | ;; | |
2304df62 AD |
1873 | esac |
1874 | else | |
dfe9444c AD |
1875 | if test -f /vmunix -a -f $src/hints/news_os.sh; then |
1876 | (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1 | |
1877 | if $contains news-os UU/kernel.what >/dev/null 2>&1; then | |
1878 | osname=news_os | |
2304df62 | 1879 | fi |
dfe9444c | 1880 | $rm -f UU/kernel.what |
8e07c86e AD |
1881 | elif test -d c:/.; then |
1882 | set X $myuname | |
1883 | osname=os2 | |
1884 | osvers="$5" | |
2304df62 AD |
1885 | fi |
1886 | fi | |
85e6fe83 | 1887 | |
a0d0e21e LW |
1888 | : Now look for a hint file osname_osvers, unless one has been |
1889 | : specified already. | |
1890 | case "$hintfile" in | |
1891 | ''|' ') | |
1e127011 | 1892 | file=`echo "${osname}_${osvers}" | $sed -e 's%\.%_%g' -e 's%_$%%'` |
a0d0e21e | 1893 | : Also try without trailing minor version numbers. |
1e127011 DD |
1894 | xfile=`echo $file | $sed -e 's%_[^_]*$%%'` |
1895 | xxfile=`echo $xfile | $sed -e 's%_[^_]*$%%'` | |
1896 | xxxfile=`echo $xxfile | $sed -e 's%_[^_]*$%%'` | |
1897 | xxxxfile=`echo $xxxfile | $sed -e 's%_[^_]*$%%'` | |
a0d0e21e LW |
1898 | case "$file" in |
1899 | '') dflt=none ;; | |
1900 | *) case "$osvers" in | |
1901 | '') dflt=$file | |
1902 | ;; | |
dfe9444c | 1903 | *) if $test -f $src/hints/$file.sh ; then |
a0d0e21e | 1904 | dflt=$file |
dfe9444c | 1905 | elif $test -f $src/hints/$xfile.sh ; then |
a0d0e21e | 1906 | dflt=$xfile |
dfe9444c | 1907 | elif $test -f $src/hints/$xxfile.sh ; then |
a0d0e21e | 1908 | dflt=$xxfile |
dfe9444c | 1909 | elif $test -f $src/hints/$xxxfile.sh ; then |
a0d0e21e | 1910 | dflt=$xxxfile |
dfe9444c | 1911 | elif $test -f $src/hints/$xxxxfile.sh ; then |
a0d0e21e | 1912 | dflt=$xxxxfile |
dfe9444c | 1913 | elif $test -f "$src/hints/${osname}.sh" ; then |
a0d0e21e LW |
1914 | dflt="${osname}" |
1915 | else | |
1916 | dflt=none | |
1917 | fi | |
1918 | ;; | |
1919 | esac | |
85e6fe83 LW |
1920 | ;; |
1921 | esac | |
4e2a5f63 AD |
1922 | if $test -f Policy.sh ; then |
1923 | case "$dflt" in | |
1924 | *Policy*) ;; | |
1925 | none) dflt="Policy" ;; | |
1926 | *) dflt="Policy $dflt" ;; | |
1927 | esac | |
1928 | fi | |
85e6fe83 | 1929 | ;; |
a0d0e21e | 1930 | *) |
ecfc5424 | 1931 | dflt=`echo $hintfile | $sed 's/\.sh$//'` |
a0d0e21e | 1932 | ;; |
2304df62 | 1933 | esac |
1aef975c | 1934 | |
4e2a5f63 AD |
1935 | if $test -f Policy.sh ; then |
1936 | $cat <<EOM | |
1937 | ||
1938 | There's also a Policy hint file available, which should make the | |
1939 | site-specific (policy) questions easier to answer. | |
1940 | EOM | |
1941 | ||
1942 | fi | |
1943 | ||
2304df62 AD |
1944 | $cat <<EOM |
1945 | ||
1946 | You may give one or more space-separated answers, or "none" if appropriate. | |
4e2a5f63 | 1947 | A well-behaved OS will have no hints, so answering "none" or just "Policy" |
a3635516 | 1948 | is a good thing. DO NOT give a wrong version or a wrong OS. |
2304df62 AD |
1949 | |
1950 | EOM | |
4e2a5f63 | 1951 | |
2304df62 | 1952 | rp="Which of these apply, if any?" |
dfe9444c | 1953 | . UU/myread |
85e6fe83 LW |
1954 | tans=$ans |
1955 | for file in $tans; do | |
4e2a5f63 AD |
1956 | if $test X$file = XPolicy -a -f Policy.sh; then |
1957 | . Policy.sh | |
1958 | $cat Policy.sh >> UU/config.sh | |
1959 | elif $test -f $src/hints/$file.sh; then | |
dfe9444c AD |
1960 | . $src/hints/$file.sh |
1961 | $cat $src/hints/$file.sh >> UU/config.sh | |
85e6fe83 | 1962 | elif $test X$tans = X -o X$tans = Xnone ; then |
2304df62 AD |
1963 | : nothing |
1964 | else | |
85e6fe83 LW |
1965 | : Give one chance to correct a possible typo. |
1966 | echo "$file.sh does not exist" | |
1967 | dflt=$file | |
1968 | rp="hint to use instead?" | |
dfe9444c | 1969 | . UU/myread |
85e6fe83 | 1970 | for file in $ans; do |
dfe9444c AD |
1971 | if $test -f "$src/hints/$file.sh"; then |
1972 | . $src/hints/$file.sh | |
1973 | $cat $src/hints/$file.sh >> UU/config.sh | |
85e6fe83 LW |
1974 | elif $test X$ans = X -o X$ans = Xnone ; then |
1975 | : nothing | |
1976 | else | |
1977 | echo "$file.sh does not exist -- ignored." | |
1978 | fi | |
1979 | done | |
2304df62 AD |
1980 | fi |
1981 | done | |
85e6fe83 | 1982 | |
2304df62 | 1983 | hint=recommended |
85e6fe83 | 1984 | : Remember our hint file for later. |
dfe9444c | 1985 | if $test -f "$src/hints/$file.sh" ; then |
a0d0e21e | 1986 | hintfile="$file" |
85e6fe83 | 1987 | else |
a0d0e21e | 1988 | hintfile='' |
85e6fe83 | 1989 | fi |
2304df62 AD |
1990 | fi |
1991 | cd UU | |
1992 | ;; | |
1993 | *) | |
1994 | echo " " | |
1995 | echo "Fetching default answers from $config_sh..." >&4 | |
ecfc5424 AD |
1996 | tmp_n="$n" |
1997 | tmp_c="$c" | |
2304df62 AD |
1998 | cd .. |
1999 | cp $config_sh config.sh 2>/dev/null | |
a78b0d02 | 2000 | chmod +w config.sh |
2304df62 AD |
2001 | . ./config.sh |
2002 | cd UU | |
2003 | cp ../config.sh . | |
ecfc5424 AD |
2004 | n="$tmp_n" |
2005 | c="$tmp_c" | |
2304df62 AD |
2006 | hint=previous |
2007 | ;; | |
2008 | esac | |
1aef975c AD |
2009 | test "$override" && . ./optdef.sh |
2010 | myuname="$newmyuname" | |
2304df62 AD |
2011 | |
2012 | : Restore computed paths | |
2013 | for file in $loclist $trylist; do | |
2014 | eval $file="\$_$file" | |
2015 | done | |
2016 | ||
85e6fe83 | 2017 | cat << EOM |
a0d0e21e | 2018 | |
85e6fe83 | 2019 | Configure uses the operating system name and version to set some defaults. |
ecfc5424 AD |
2020 | The default value is probably right if the name rings a bell. Otherwise, |
2021 | since spelling matters for me, either accept the default or answer "none" | |
2022 | to leave it blank. | |
a0d0e21e | 2023 | |
85e6fe83 | 2024 | EOM |
85e6fe83 | 2025 | case "$osname" in |
a0d0e21e | 2026 | ''|' ') |
85e6fe83 | 2027 | case "$hintfile" in |
a0d0e21e | 2028 | ''|' '|none) dflt=none ;; |
ecfc5424 | 2029 | *) dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;; |
85e6fe83 LW |
2030 | esac |
2031 | ;; | |
2032 | *) dflt="$osname" ;; | |
2033 | esac | |
2034 | rp="Operating system name?" | |
2035 | . ./myread | |
2036 | case "$ans" in | |
ecfc5424 AD |
2037 | none) osname='' ;; |
2038 | *) osname=`echo "$ans" | $sed -e 's/[ ][ ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;; | |
85e6fe83 | 2039 | esac |
8ff267be | 2040 | echo " " |
2041 | case "$osvers" in | |
2042 | ''|' ') | |
2043 | case "$hintfile" in | |
2044 | ''|' '|none) dflt=none ;; | |
2045 | *) dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'` | |
2046 | dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'` | |
2047 | case "$dflt" in | |
2048 | ''|' ') dflt=none ;; | |
2049 | esac | |
2050 | ;; | |
2051 | esac | |
2052 | ;; | |
2053 | *) dflt="$osvers" ;; | |
2054 | esac | |
2055 | rp="Operating system version?" | |
2056 | . ./myread | |
2057 | case "$ans" in | |
2058 | none) osvers='' ;; | |
2059 | *) osvers="$ans" ;; | |
2060 | esac | |
2061 | ||
02e93a22 JH |
2062 | |
2063 | . ./posthint.sh | |
2064 | ||
2304df62 | 2065 | : who configured the system |
59b83a6f | 2066 | cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1` |
8ff267be | 2067 | cf_by=`(logname) 2>/dev/null` |
dfe9444c AD |
2068 | case "$cf_by" in |
2069 | "") | |
8ff267be | 2070 | cf_by=`(whoami) 2>/dev/null` |
dfe9444c AD |
2071 | case "$cf_by" in |
2072 | "") cf_by=unknown ;; | |
8ff267be | 2073 | esac ;; |
2074 | esac | |
2304df62 | 2075 | |
e5e20432 JH |
2076 | : make some quick guesses about what we are up against |
2077 | echo " " | |
2078 | $echo $n "Hmm... $c" | |
2079 | echo exit 1 >bsd | |
2080 | echo exit 1 >usg | |
2081 | echo exit 1 >v7 | |
2082 | echo exit 1 >osf1 | |
2083 | echo exit 1 >eunice | |
2084 | echo exit 1 >xenix | |
2085 | echo exit 1 >venix | |
2086 | echo exit 1 >os2 | |
2087 | d_bsd="$undef" | |
2088 | $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null | |
2089 | if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1 | |
2090 | then | |
2091 | echo "Looks kind of like an OSF/1 system, but we'll see..." | |
2092 | echo exit 0 >osf1 | |
2093 | elif test `echo abc | tr a-z A-Z` = Abc ; then | |
2094 | xxx=`./loc addbib blurfl $pth` | |
2095 | if $test -f $xxx; then | |
2096 | echo "Looks kind of like a USG system with BSD features, but we'll see..." | |
2097 | echo exit 0 >bsd | |
2098 | echo exit 0 >usg | |
2099 | else | |
2100 | if $contains SIGTSTP foo >/dev/null 2>&1 ; then | |
2101 | echo "Looks kind of like an extended USG system, but we'll see..." | |
2102 | else | |
2103 | echo "Looks kind of like a USG system, but we'll see..." | |
2104 | fi | |
2105 | echo exit 0 >usg | |
2106 | fi | |
2107 | elif $contains SIGTSTP foo >/dev/null 2>&1 ; then | |
2108 | echo "Looks kind of like a BSD system, but we'll see..." | |
2109 | d_bsd="$define" | |
2110 | echo exit 0 >bsd | |
2111 | else | |
2112 | echo "Looks kind of like a Version 7 system, but we'll see..." | |
2113 | echo exit 0 >v7 | |
2114 | fi | |
2115 | case "$eunicefix" in | |
2116 | *unixtovms*) | |
2117 | $cat <<'EOI' | |
2118 | There is, however, a strange, musty smell in the air that reminds me of | |
2119 | something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit. | |
2120 | EOI | |
2121 | echo exit 0 >eunice | |
2122 | d_eunice="$define" | |
2123 | : it so happens the Eunice I know will not run shell scripts in Unix format | |
2124 | ;; | |
2125 | *) | |
2126 | echo " " | |
2127 | echo "Congratulations. You aren't running Eunice." | |
2128 | d_eunice="$undef" | |
2129 | ;; | |
2130 | esac | |
2131 | : Detect OS2. The p_ variable is set above in the Head.U unit. | |
3d5d58b1 JH |
2132 | : Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses |
2133 | : semicolon as a patch separator | |
e5e20432 JH |
2134 | case "$p_" in |
2135 | :) ;; | |
2136 | *) | |
2137 | $cat <<'EOI' | |
2138 | I have the feeling something is not exactly right, however...don't tell me... | |
2139 | lemme think...does HAL ring a bell?...no, of course, you're only running OS/2! | |
3d5d58b1 | 2140 | (Or you may be running DOS with DJGPP.) |
e5e20432 JH |
2141 | EOI |
2142 | echo exit 0 >os2 | |
2143 | ;; | |
2144 | esac | |
2145 | if test -f /xenix; then | |
2146 | echo "Actually, this looks more like a XENIX system..." | |
2147 | echo exit 0 >xenix | |
2148 | d_xenix="$define" | |
2149 | else | |
2150 | echo " " | |
2151 | echo "It's not Xenix..." | |
2152 | d_xenix="$undef" | |
2153 | fi | |
2154 | chmod +x xenix | |
2155 | $eunicefix xenix | |
2156 | if test -f /venix; then | |
2157 | echo "Actually, this looks more like a VENIX system..." | |
2158 | echo exit 0 >venix | |
2159 | else | |
2160 | echo " " | |
2161 | if ./xenix; then | |
2162 | : null | |
2163 | else | |
2164 | echo "Nor is it Venix..." | |
2165 | fi | |
2166 | fi | |
2167 | chmod +x bsd usg v7 osf1 eunice xenix venix os2 | |
2168 | $eunicefix bsd usg v7 osf1 eunice xenix venix os2 | |
2169 | $rm -f foo | |
2170 | ||
5869b1f1 JH |
2171 | case "$cc" in |
2172 | '') dflt=cc;; | |
2173 | *) dflt="$cc";; | |
2174 | esac | |
2175 | rp="Use which C compiler?" | |
2176 | . ./myread | |
2177 | cc="$ans" | |
e5e20432 JH |
2178 | : Look for a hint-file generated 'call-back-unit'. Now that the |
2179 | : user has specified the compiler, we may need to set or change some | |
2180 | : other defaults. | |
2181 | if $test -f cc.cbu; then | |
2182 | . ./cc.cbu | |
2183 | fi | |
2573c5f9 | 2184 | . ./checkcc |
8a27cf78 | 2185 | |
e5e20432 JH |
2186 | echo " " |
2187 | echo "Checking for GNU cc in disguise and/or its version number..." >&4 | |
2188 | $cat >gccvers.c <<EOM | |
2189 | #include <stdio.h> | |
2190 | int main() { | |
2191 | #ifdef __GNUC__ | |
2192 | #ifdef __VERSION__ | |
2193 | printf("%s\n", __VERSION__); | |
2194 | #else | |
2195 | printf("%s\n", "1"); | |
2196 | #endif | |
2197 | #endif | |
2198 | exit(0); | |
2199 | } | |
2200 | EOM | |
bf0c440f | 2201 | if $cc $ldflags -o gccvers gccvers.c; then |
e5e20432 JH |
2202 | gccversion=`./gccvers` |
2203 | case "$gccversion" in | |
2204 | '') echo "You are not using GNU cc." ;; | |
fc68435e | 2205 | *) echo "You are using GNU cc $gccversion." |
e723fc21 | 2206 | ccname=gcc |
fc68435e | 2207 | ;; |
e5e20432 JH |
2208 | esac |
2209 | else | |
2210 | echo " " | |
2211 | echo "*** WHOA THERE!!! ***" >&4 | |
2212 | echo " Your C compiler \"$cc\" doesn't seem to be working!" >&4 | |
2213 | case "$knowitall" in | |
2214 | '') | |
2215 | echo " You'd better start hunting for one and let me know about it." >&4 | |
2216 | exit 1 | |
2217 | ;; | |
2218 | esac | |
2219 | fi | |
2220 | $rm -f gccvers* | |
2221 | case "$gccversion" in | |
2222 | 1*) cpp=`./loc gcc-cpp $cpp $pth` ;; | |
2223 | esac | |
5b463ca7 KS |
2224 | case "$gccversion" in |
2225 | '') gccosandvers='' ;; | |
10b4ebb5 JH |
2226 | *) gccshortvers=`echo "$gccversion"|sed 's/ .*//'` |
2227 | gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"` | |
2228 | gccshortvers='' | |
5b463ca7 | 2229 | case "$gccosandvers" in |
02903077 JH |
2230 | $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr |
2231 | $osname$osvers) ;; # looking good | |
5b463ca7 KS |
2232 | $osname*) cat <<EOM >&4 |
2233 | ||
2234 | *** WHOA THERE!!! *** | |
2235 | ||
2236 | Your gcc has not been compiled for the exact release of | |
2237 | your operating system ($gccosandvers versus $osname$osvers). | |
2238 | ||
2239 | In general it is a good idea to keep gcc synchronized with | |
2240 | the operating system because otherwise serious problems | |
2241 | may ensue when trying to compile software, like Perl. | |
2242 | ||
2243 | I'm trying to be optimistic here, though, and will continue. | |
2244 | If later during the configuration and build icky compilation | |
02903077 JH |
2245 | problems appear (headerfile conflicts being the most common |
2246 | manifestation), I suggest reinstalling the gcc to match | |
5b463ca7 KS |
2247 | your operating system release. |
2248 | ||
2249 | EOM | |
2250 | ;; | |
81575342 | 2251 | *) gccosandvers='' ;; # failed to parse, better be silent |
5b463ca7 KS |
2252 | esac |
2253 | ;; | |
2254 | esac | |
e723fc21 JH |
2255 | case "$ccname" in |
2256 | '') ccname="$cc" ;; | |
2257 | esac | |
e5e20432 | 2258 | |
8a27cf78 JH |
2259 | : see how we invoke the C preprocessor |
2260 | echo " " | |
2261 | echo "Now, how can we feed standard input to your C preprocessor..." >&4 | |
2262 | cat <<'EOT' >testcpp.c | |
2263 | #define ABC abc | |
2264 | #define XYZ xyz | |
2265 | ABC.XYZ | |
2266 | EOT | |
2267 | cd .. | |
2268 | if test ! -f cppstdin; then | |
2269 | if test "X$osname" = "Xaix" -a "X$gccversion" = X; then | |
2270 | # AIX cc -E doesn't show the absolute headerfile | |
2271 | # locations but we'll cheat by using the -M flag. | |
2272 | echo 'cat >.$$.c; rm -f .$$.u; '"$cc"' ${1+"$@"} -M -c .$$.c 2>/dev/null; test -s .$$.u && awk '"'"'$2 ~ /\.h$/ { print "# 0 \""$2"\"" }'"'"' .$$.u; rm -f .$$.o .$$.u; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' > cppstdin | |
2273 | else | |
2274 | echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin | |
2275 | fi | |
2276 | else | |
2277 | echo "Keeping your $hint cppstdin wrapper." | |
2278 | fi | |
2279 | chmod 755 cppstdin | |
2280 | wrapper=`pwd`/cppstdin | |
2281 | ok='false' | |
2282 | cd UU | |
2283 | ||
2284 | if $test "X$cppstdin" != "X" && \ | |
2285 | $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \ | |
2286 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 | |
2287 | then | |
2288 | echo "You used to use $cppstdin $cppminus so we'll use that again." | |
2289 | case "$cpprun" in | |
2290 | '') echo "But let's see if we can live without a wrapper..." ;; | |
2291 | *) | |
2292 | if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \ | |
2293 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 | |
2294 | then | |
2295 | echo "(And we'll use $cpprun $cpplast to preprocess directly.)" | |
2296 | ok='true' | |
2297 | else | |
2298 | echo "(However, $cpprun $cpplast does not work, let's see...)" | |
2299 | fi | |
2300 | ;; | |
2301 | esac | |
2302 | else | |
2303 | case "$cppstdin" in | |
2304 | '') ;; | |
2305 | *) | |
2306 | echo "Good old $cppstdin $cppminus does not seem to be of any help..." | |
2307 | ;; | |
2308 | esac | |
2309 | fi | |
2310 | ||
2311 | if $ok; then | |
2312 | : nothing | |
2313 | elif echo 'Maybe "'"$cc"' -E" will work...'; \ | |
2314 | $cc -E <testcpp.c >testcpp.out 2>&1; \ | |
2315 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then | |
2316 | echo "Yup, it does." | |
2317 | x_cpp="$cc -E" | |
2318 | x_minus=''; | |
2319 | elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \ | |
2320 | $cc -E - <testcpp.c >testcpp.out 2>&1; \ | |
2321 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then | |
2322 | echo "Yup, it does." | |
2323 | x_cpp="$cc -E" | |
2324 | x_minus='-'; | |
2325 | elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \ | |
2326 | $cc -P <testcpp.c >testcpp.out 2>&1; \ | |
2327 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then | |
2328 | echo "Yipee, that works!" | |
2329 | x_cpp="$cc -P" | |
2330 | x_minus=''; | |
2331 | elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \ | |
2332 | $cc -P - <testcpp.c >testcpp.out 2>&1; \ | |
2333 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then | |
2334 | echo "At long last!" | |
2335 | x_cpp="$cc -P" | |
2336 | x_minus='-'; | |
2337 | elif echo 'No such luck, maybe "'$cpp'" will work...'; \ | |
2338 | $cpp <testcpp.c >testcpp.out 2>&1; \ | |
2339 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then | |
2340 | echo "It works!" | |
2341 | x_cpp="$cpp" | |
2342 | x_minus=''; | |
2343 | elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \ | |
2344 | $cpp - <testcpp.c >testcpp.out 2>&1; \ | |
2345 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then | |
2346 | echo "Hooray, it works! I was beginning to wonder." | |
2347 | x_cpp="$cpp" | |
2348 | x_minus='-'; | |
2349 | elif echo 'Uh-uh. Time to get fancy. Trying a wrapper...'; \ | |
2350 | $wrapper <testcpp.c >testcpp.out 2>&1; \ | |
2351 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then | |
2352 | x_cpp="$wrapper" | |
2353 | x_minus='' | |
2354 | echo "Eureka!" | |
2355 | else | |
2356 | dflt='' | |
2357 | rp="No dice. I can't find a C preprocessor. Name one:" | |
2358 | . ./myread | |
2359 | x_cpp="$ans" | |
2360 | x_minus='' | |
2361 | $x_cpp <testcpp.c >testcpp.out 2>&1 | |
2362 | if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then | |
2363 | echo "OK, that will do." >&4 | |
2364 | else | |
2365 | echo "Sorry, I can't get that to work. Go find one and rerun Configure." >&4 | |
2366 | exit 1 | |
2367 | fi | |
2368 | fi | |
2369 | ||
2370 | case "$ok" in | |
2371 | false) | |
2372 | cppstdin="$x_cpp" | |
2373 | cppminus="$x_minus" | |
2374 | cpprun="$x_cpp" | |
2375 | cpplast="$x_minus" | |
2376 | set X $x_cpp | |
2377 | shift | |
2378 | case "$1" in | |
2379 | "$cpp") | |
2380 | echo "Perhaps can we force $cc -E using a wrapper..." | |
2381 | if $wrapper <testcpp.c >testcpp.out 2>&1; \ | |
2382 | $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 | |
2383 | then | |
2384 | echo "Yup, we can." | |
2385 | cppstdin="$wrapper" | |
2386 | cppminus=''; | |
2387 | else | |
2388 | echo "Nope, we'll have to live without it..." | |
2389 | fi | |
2390 | ;; | |
2391 | esac | |
2392 | case "$cpprun" in | |
2393 | "$wrapper") | |
2394 | cpprun='' | |
2395 | cpplast='' | |
2396 | ;; | |
2397 | esac | |
2398 | ;; | |
2399 | esac | |
2400 | ||
2401 | case "$cppstdin" in | |
2402 | "$wrapper"|'cppstdin') ;; | |
2403 | *) $rm -f $wrapper;; | |
2404 | esac | |
2405 | $rm -f testcpp.c testcpp.out | |
2406 | ||
bd9b35c9 JH |
2407 | : decide how portable to be. Allow command line overrides. |
2408 | case "$d_portable" in | |
2409 | "$undef") ;; | |
2410 | *) d_portable="$define" ;; | |
104d25b7 | 2411 | esac |
85ab1d1d | 2412 | |
bd9b35c9 JH |
2413 | : set up shell script to do ~ expansion |
2414 | cat >filexp <<EOSS | |
2415 | $startsh | |
2416 | : expand filename | |
2417 | case "\$1" in | |
2418 | ~/*|~) | |
2419 | echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|" | |
2420 | ;; | |
2421 | ~*) | |
2422 | if $test -f /bin/csh; then | |
2423 | /bin/csh -f -c "glob \$1" | |
2424 | failed=\$? | |
2425 | echo "" | |
2426 | exit \$failed | |
e5e20432 | 2427 | else |
bd9b35c9 JH |
2428 | name=\`$expr x\$1 : '..\([^/]*\)'\` |
2429 | dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\` | |
2430 | if $test ! -d "\$dir"; then | |
2431 | me=\`basename \$0\` | |
2432 | echo "\$me: can't locate home directory for: \$name" >&2 | |
2433 | exit 1 | |
2434 | fi | |
2435 | case "\$1" in | |
2436 | */*) | |
2437 | echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\` | |
2438 | ;; | |
2439 | *) | |
2440 | echo \$dir | |
e5e20432 JH |
2441 | ;; |
2442 | esac | |
2443 | fi | |
b691c02f | 2444 | ;; |
4633a7c4 | 2445 | *) |
bd9b35c9 | 2446 | echo \$1 |
2304df62 AD |
2447 | ;; |
2448 | esac | |
4633a7c4 LW |
2449 | EOSS |
2450 | chmod +x filexp | |
2451 | $eunicefix filexp | |
2304df62 AD |
2452 | |
2453 | : now set up to get a file name | |
28757baa | 2454 | cat <<EOS >getfile |
2455 | $startsh | |
2456 | EOS | |
2457 | cat <<'EOSC' >>getfile | |
2304df62 AD |
2458 | tilde='' |
2459 | fullpath='' | |
2460 | already='' | |
2461 | skip='' | |
2462 | none_ok='' | |
2463 | exp_file='' | |
a0d0e21e | 2464 | nopath_ok='' |
2304df62 AD |
2465 | orig_rp="$rp" |
2466 | orig_dflt="$dflt" | |
b233458b JH |
2467 | case "$gfpth" in |
2468 | '') gfpth='.' ;; | |
2469 | esac | |
2304df62 AD |
2470 | |
2471 | case "$fn" in | |
ecfc5424 | 2472 | *\(*) |
28e8609d | 2473 | expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok |
ecfc5424 AD |
2474 | fn=`echo $fn | sed 's/(.*)//'` |
2475 | ;; | |
2476 | esac | |
2477 | ||
2478 | case "$fn" in | |
a0d0e21e LW |
2479 | *:*) |
2480 | loc_file=`expr $fn : '.*:\(.*\)'` | |
2481 | fn=`expr $fn : '\(.*\):.*'` | |
2482 | ;; | |
2483 | esac | |
2484 | ||
2485 | case "$fn" in | |
2304df62 AD |
2486 | *~*) tilde=true;; |
2487 | esac | |
2488 | case "$fn" in | |
2489 | */*) fullpath=true;; | |
2490 | esac | |
2491 | case "$fn" in | |
2492 | *+*) skip=true;; | |
2493 | esac | |
2494 | case "$fn" in | |
2495 | *n*) none_ok=true;; | |
2496 | esac | |
2497 | case "$fn" in | |
2498 | *e*) exp_file=true;; | |
2499 | esac | |
a0d0e21e LW |
2500 | case "$fn" in |
2501 | *p*) nopath_ok=true;; | |
2502 | esac | |
2304df62 AD |
2503 | |
2504 | case "$fn" in | |
2505 | *f*) type='File';; | |
2506 | *d*) type='Directory';; | |
a0d0e21e | 2507 | *l*) type='Locate';; |
2304df62 AD |
2508 | esac |
2509 | ||
2510 | what="$type" | |
2511 | case "$what" in | |
2512 | Locate) what='File';; | |
2513 | esac | |
2514 | ||
2515 | case "$exp_file" in | |
2516 | '') | |
2517 | case "$d_portable" in | |
2518 | "$define") ;; | |
2519 | *) exp_file=true;; | |
2520 | esac | |
2521 | ;; | |
2522 | esac | |
2523 | ||
2524 | cd .. | |
2525 | while test "$type"; do | |
2526 | redo='' | |
2527 | rp="$orig_rp" | |
2528 | dflt="$orig_dflt" | |
2529 | case "$tilde" in | |
2530 | true) rp="$rp (~name ok)";; | |
2531 | esac | |
2532 | . UU/myread | |
ecfc5424 AD |
2533 | if test -f UU/getfile.ok && \ |
2534 | $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1 | |
2535 | then | |
2536 | value="$ans" | |
2537 | ansexp="$ans" | |
2538 | break | |
2539 | fi | |
2304df62 AD |
2540 | case "$ans" in |
2541 | none) | |
2542 | value='' | |
2543 | ansexp='' | |
2544 | case "$none_ok" in | |
2545 | true) type='';; | |
2546 | esac | |
2547 | ;; | |
2548 | *) | |
2549 | case "$tilde" in | |
2550 | '') value="$ans" | |
2551 | ansexp="$ans";; | |
2552 | *) | |
2553 | value=`UU/filexp $ans` | |
2554 | case $? in | |
2555 | 0) | |
2556 | if test "$ans" != "$value"; then | |
ecfc5424 | 2557 | echo "(That expands to $value on this system.)" |
2304df62 AD |
2558 | fi |
2559 | ;; | |
2560 | *) value="$ans";; | |
2561 | esac | |
2562 | ansexp="$value" | |
2563 | case "$exp_file" in | |
2564 | '') value="$ans";; | |
2565 | esac | |
2566 | ;; | |
2567 | esac | |
2568 | case "$fullpath" in | |
2569 | true) | |
2570 | case "$ansexp" in | |
2571 | /*) value="$ansexp" ;; | |
23da6c43 | 2572 | [a-zA-Z]:/*) value="$ansexp" ;; |
2304df62 AD |
2573 | *) |
2574 | redo=true | |
2575 | case "$already" in | |
2576 | true) | |
2577 | echo "I shall only accept a full path name, as in /bin/ls." >&4 | |
2578 | echo "Use a ! shell escape if you wish to check pathnames." >&4 | |
2579 | ;; | |
2580 | *) | |
2581 | echo "Please give a full path name, starting with slash." >&4 | |
2582 | case "$tilde" in | |
2583 | true) | |
2584 | echo "Note that using ~name is ok provided it expands well." >&4 | |
2585 | already=true | |
2586 | ;; | |
2587 | esac | |
2588 | esac | |
2589 | ;; | |
2590 | esac | |
2591 | ;; | |
2592 | esac | |
2593 | case "$redo" in | |
2594 | '') | |
2595 | case "$type" in | |
2596 | File) | |
b233458b JH |
2597 | for fp in $gfpth; do |
2598 | if test "X$fp" = X.; then | |
2599 | pf="$ansexp" | |
2600 | else | |
2601 | pf="$fp/$ansexp" | |
2602 | fi | |
2603 | if test -f "$pf"; then | |
2604 | type='' | |
2605 | elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1 | |
2606 | then | |
2607 | echo "($value is not a plain file, but that's ok.)" | |
2608 | type='' | |
2609 | fi | |
2610 | if test X"$type" = X; then | |
2611 | value="$pf" | |
2612 | break | |
2613 | fi | |
2614 | done | |
2304df62 AD |
2615 | ;; |
2616 | Directory) | |
b233458b JH |
2617 | for fp in $gfpth; do |
2618 | if test "X$fp" = X.; then | |
f78bfc9c JH |
2619 | dir="$ans" |
2620 | direxp="$ansexp" | |
b233458b | 2621 | else |
dd858076 | 2622 | dir="$fp/$ansexp" |
f78bfc9c | 2623 | direxp="$fp/$ansexp" |
b233458b | 2624 | fi |
f78bfc9c | 2625 | if test -d "$direxp"; then |
b233458b | 2626 | type='' |
f78bfc9c | 2627 | value="$dir" |
b233458b JH |
2628 | break |
2629 | fi | |
2630 | done | |
2304df62 AD |
2631 | ;; |
2632 | Locate) | |
40000a8c | 2633 | if test -d "$ansexp"; then |
a0d0e21e LW |
2634 | echo "(Looking for $loc_file in directory $value.)" |
2635 | value="$value/$loc_file" | |
40000a8c | 2636 | ansexp="$ansexp/$loc_file" |
2304df62 | 2637 | fi |
40000a8c | 2638 | if test -f "$ansexp"; then |
2304df62 AD |
2639 | type='' |
2640 | fi | |
a0d0e21e LW |
2641 | case "$nopath_ok" in |
2642 | true) case "$value" in | |
2643 | */*) ;; | |
2644 | *) echo "Assuming $value will be in people's path." | |
2645 | type='' | |
2646 | ;; | |
2647 | esac | |
2648 | ;; | |
2649 | esac | |
2304df62 AD |
2650 | ;; |
2651 | esac | |
2652 | ||
2653 | case "$skip" in | |
2654 | true) type=''; | |
2655 | esac | |
2656 | ||
2657 | case "$type" in | |
2658 | '') ;; | |
2659 | *) | |
2660 | if test "$fastread" = yes; then | |
2661 | dflt=y | |
2662 | else | |
2663 | dflt=n | |
2664 | fi | |
2665 | rp="$what $value doesn't exist. Use that name anyway?" | |
2666 | . UU/myread | |
2667 | dflt='' | |
2668 | case "$ans" in | |
2669 | y*) type='';; | |
2670 | *) echo " ";; | |
2671 | esac | |
2672 | ;; | |
2673 | esac | |
2674 | ;; | |
2675 | esac | |
2676 | ;; | |
2677 | esac | |
2678 | done | |
2679 | cd UU | |
2680 | ans="$value" | |
2681 | rp="$orig_rp" | |
2682 | dflt="$orig_dflt" | |
ecfc5424 | 2683 | rm -f getfile.ok |
b233458b | 2684 | test "X$gfpthkeep" != Xy && gfpth="" |
2304df62 AD |
2685 | EOSC |
2686 | ||
bd9b35c9 JH |
2687 | : What should the include directory be ? |
2688 | echo " " | |
2689 | $echo $n "Hmm... $c" | |
2690 | dflt='/usr/include' | |
2691 | incpath='' | |
2692 | mips_type='' | |
2693 | if $test -f /bin/mips && /bin/mips; then | |
2694 | echo "Looks like a MIPS system..." | |
2695 | $cat >usr.c <<'EOCP' | |
2696 | #ifdef SYSTYPE_BSD43 | |
2697 | /bsd43 | |
2698 | #endif | |
2699 | EOCP | |
8a27cf78 | 2700 | if cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then |
bd9b35c9 JH |
2701 | dflt='/bsd43/usr/include' |
2702 | incpath='/bsd43' | |
2703 | mips_type='BSD 4.3' | |
2704 | else | |
2705 | mips_type='System V' | |
2706 | fi | |
2707 | $rm -f usr.c usr.out | |
2708 | echo "and you're compiling with the $mips_type compiler and libraries." | |
2709 | xxx_prompt=y | |
2710 | echo "exit 0" >mips | |
2711 | else | |
2712 | echo "Doesn't look like a MIPS system." | |
2713 | xxx_prompt=n | |
2714 | echo "exit 1" >mips | |
2715 | fi | |
2716 | chmod +x mips | |
2717 | $eunicefix mips | |
2718 | case "$usrinc" in | |
2719 | '') ;; | |
2720 | *) dflt="$usrinc";; | |
2721 | esac | |
2722 | case "$xxx_prompt" in | |
2723 | y) fn=d/ | |
2724 | echo " " | |
2725 | rp='Where are the include files you want to use?' | |
2726 | . ./getfile | |
2727 | usrinc="$ans" | |
8e07c86e | 2728 | ;; |
bd9b35c9 | 2729 | *) usrinc="$dflt" |
8e07c86e AD |
2730 | ;; |
2731 | esac | |
2304df62 | 2732 | |
bd9b35c9 JH |
2733 | : Set private lib path |
2734 | case "$plibpth" in | |
2735 | '') if ./mips; then | |
2736 | plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib" | |
2737 | fi;; | |
2738 | esac | |
2739 | case "$libpth" in | |
2740 | ' ') dlist='';; | |
2741 | '') dlist="$loclibpth $plibpth $glibpth";; | |
2742 | *) dlist="$libpth";; | |
2743 | esac | |
2744 | ||
2745 | : Now check and see which directories actually exist, avoiding duplicates | |
2746 | libpth='' | |
2747 | for xxx in $dlist | |
2748 | do | |
2749 | if $test -d $xxx; then | |
2750 | case " $libpth " in | |
2751 | *" $xxx "*) ;; | |
2752 | *) libpth="$libpth $xxx";; | |
2753 | esac | |
2754 | fi | |
2755 | done | |
2756 | $cat <<'EOM' | |
2757 | ||
2758 | Some systems have incompatible or broken versions of libraries. Among | |
2759 | the directories listed in the question below, please remove any you | |
2760 | know not to be holding relevant libraries, and add any that are needed. | |
2761 | Say "none" for none. | |
8e07c86e AD |
2762 | |
2763 | EOM | |
bd9b35c9 JH |
2764 | case "$libpth" in |
2765 | '') dflt='none';; | |
8e07c86e | 2766 | *) |
bd9b35c9 JH |
2767 | set X $libpth |
2768 | shift | |
2769 | dflt=${1+"$@"} | |
8e07c86e | 2770 | ;; |
a0d0e21e | 2771 | esac |
bd9b35c9 JH |
2772 | rp="Directories to use for library searches?" |
2773 | . ./myread | |
2774 | case "$ans" in | |
2775 | none) libpth=' ';; | |
2776 | *) libpth="$ans";; | |
2777 | esac | |
a0d0e21e | 2778 | |
bd9b35c9 JH |
2779 | : compute shared library extension |
2780 | case "$so" in | |
2781 | '') | |
2782 | if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then | |
2783 | dflt='sl' | |
dd4e71fd | 2784 | else |
bd9b35c9 | 2785 | dflt='so' |
dd4e71fd JH |
2786 | fi |
2787 | ;; | |
bd9b35c9 | 2788 | *) dflt="$so";; |
dd4e71fd | 2789 | esac |
dd4e71fd JH |
2790 | $cat <<EOM |
2791 | ||
bd9b35c9 | 2792 | On some systems, shared libraries may be available. Answer 'none' if |
7f95ee77 | 2793 | you want to suppress searching of shared libraries for the remainder |
bd9b35c9 | 2794 | of this configuration. |
dd4e71fd JH |
2795 | |
2796 | EOM | |
bd9b35c9 JH |
2797 | rp='What is the file extension used for shared libraries?' |
2798 | . ./myread | |
2799 | so="$ans" | |
dd4e71fd | 2800 | |
bd9b35c9 JH |
2801 | : Define several unixisms. |
2802 | : Hints files or command line option can be used to override them. | |
2803 | : The convoluted testing is in case hints files set either the old | |
2804 | : or the new name. | |
2805 | case "$_exe" in | |
2806 | '') case "$exe_ext" in | |
2807 | '') ;; | |
2808 | *) _exe="$exe_ext" ;; | |
dd4e71fd | 2809 | esac |
bd9b35c9 | 2810 | ;; |
bfb7748a | 2811 | esac |
bd9b35c9 JH |
2812 | case "$_a" in |
2813 | '') case "$lib_ext" in | |
2814 | '') _a='.a';; | |
2815 | *) _a="$lib_ext" ;; | |
dd4e71fd JH |
2816 | esac |
2817 | ;; | |
dd4e71fd | 2818 | esac |
bd9b35c9 JH |
2819 | case "$_o" in |
2820 | '') case "$obj_ext" in | |
2821 | '') _o='.o';; | |
2822 | *) _o="$obj_ext";; | |
2823 | esac | |
2824 | ;; | |
2825 | esac | |
2826 | case "$p_" in | |
2827 | '') case "$path_sep" in | |
2828 | '') p_=':';; | |
2829 | *) p_="$path_sep";; | |
2830 | esac | |
2831 | ;; | |
2832 | esac | |
2833 | exe_ext=$_exe | |
2834 | lib_ext=$_a | |
2835 | obj_ext=$_o | |
2836 | path_sep=$p_ | |
dd4e71fd | 2837 | |
9c839522 PM |
2838 | : set up the script used to warn in case of inconsistency |
2839 | cat <<EOS >whoa | |
2840 | $startsh | |
2841 | EOS | |
2842 | cat <<'EOSC' >>whoa | |
2843 | dflt=y | |
2844 | echo " " | |
2845 | echo "*** WHOA THERE!!! ***" >&4 | |
2846 | echo " The $hint value for \$$var on this machine was \"$was\"!" >&4 | |
2847 | rp=" Keep the $hint value?" | |
2848 | . ./myread | |
2849 | case "$ans" in | |
2850 | y) td=$was; tu=$was;; | |
4633a7c4 | 2851 | esac |
9c839522 PM |
2852 | EOSC |
2853 | ||
2854 | : function used to set $1 to $val | |
2855 | setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef; | |
2856 | case "$val$was" in | |
2857 | $define$undef) . ./whoa; eval "$var=\$td";; | |
2858 | $undef$define) . ./whoa; eval "$var=\$tu";; | |
2859 | *) eval "$var=$val";; | |
2860 | esac' | |
4633a7c4 | 2861 | |
0f0995ae JH |
2862 | case "$usesocks" in |
2863 | $define|true|[yY]*) dflt='y';; | |
2864 | *) dflt='n';; | |
2865 | esac | |
bd9b35c9 | 2866 | cat <<EOM |
4633a7c4 | 2867 | |
bd9b35c9 JH |
2868 | Perl can be built to use the SOCKS proxy protocol library. To do so, |
2869 | Configure must be run with -Dusesocks. | |
4633a7c4 | 2870 | |
0f0995ae | 2871 | If this doesn't make any sense to you, just accept the default '$dflt'. |
bd9b35c9 | 2872 | EOM |
bd9b35c9 JH |
2873 | rp='Build Perl for SOCKS?' |
2874 | . ./myread | |
2875 | case "$ans" in | |
2876 | y|Y) val="$define" ;; | |
2877 | *) val="$undef" ;; | |
2878 | esac | |
2879 | set usesocks | |
2880 | eval $setvar | |
2881 | ||
2882 | : Looking for optional libraries | |
2883 | echo " " | |
2884 | echo "Checking for optional libraries..." >&4 | |
2885 | case "$libs" in | |
2886 | ' '|'') dflt='';; | |
2887 | *) dflt="$libs";; | |
2888 | esac | |
2889 | case "$libswanted" in | |
2890 | '') libswanted='c_s';; | |
2891 | esac | |
2892 | case "$usesocks" in | |
923fc586 | 2893 | "$define") libswanted="$libswanted socks5 socks5_sh" ;; |
8e07c86e | 2894 | esac |
68435ea7 JH |
2895 | libsfound='' |
2896 | libsfiles='' | |
2897 | libsdirs='' | |
13b3f787 JH |
2898 | libspath='' |
2899 | for thisdir in $libpth $xlibpth; do | |
2900 | test -d $thisdir && libspath="$libspath $thisdir" | |
2901 | done | |
bd9b35c9 | 2902 | for thislib in $libswanted; do |
13b3f787 | 2903 | for thisdir in $libspath; do |
f7dd4e7f JH |
2904 | xxx='' |
2905 | if $test ! -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then | |
2906 | xxx=`ls $thisdir/lib$thislib.$so.[0-9] 2>/dev/null|tail -1` | |
2907 | $test -f "$xxx" && eval $libscheck | |
2908 | $test -f "$xxx" && libstyle=shared | |
2909 | fi | |
2910 | if test ! -f "$xxx"; then | |
2911 | xxx=$thisdir/lib$thislib.$so | |
2912 | $test -f "$xxx" && eval $libscheck | |
2913 | $test -f "$xxx" && libstyle=shared | |
2914 | fi | |
2915 | if test ! -f "$xxx"; then | |
2916 | xxx=$thisdir/lib$thislib$_a | |
2917 | $test -f "$xxx" && eval $libscheck | |
2918 | $test -f "$xxx" && libstyle=static | |
2919 | fi | |
2920 | if test ! -f "$xxx"; then | |
2921 | xxx=$thisdir/$thislib$_a | |
2922 | $test -f "$xxx" && eval $libscheck | |
2923 | $test -f "$xxx" && libstyle=static | |
2924 | fi | |
2925 | if test ! -f "$xxx"; then | |
2926 | xxx=$thisdir/lib${thislib}_s$_a | |
2927 | $test -f "$xxx" && eval $libscheck | |
2928 | $test -f "$xxx" && libstyle=static | |
09ea5ba9 | 2929 | $test -f "$xxx" && thislib=${thislib}_s |
f7dd4e7f JH |
2930 | fi |
2931 | if test ! -f "$xxx"; then | |
2932 | xxx=$thisdir/Slib$thislib$_a | |
2933 | $test -f "$xxx" && eval $libscheck | |
2934 | $test -f "$xxx" && libstyle=static | |
2935 | fi | |
2936 | if $test -f "$xxx"; then | |
43999f95 | 2937 | case "$libstyle" in |
f7dd4e7f JH |
2938 | shared) echo "Found -l$thislib (shared)." ;; |
2939 | static) echo "Found -l$thislib." ;; | |
2940 | *) echo "Found -l$thislib ($libstyle)." ;; | |
43999f95 | 2941 | esac |
bd9b35c9 JH |
2942 | case " $dflt " in |
2943 | *"-l$thislib "*);; | |
f7dd4e7f | 2944 | *) dflt="$dflt -l$thislib" |
43999f95 JH |
2945 | libsfound="$libsfound $xxx" |
2946 | yyy=`basename $xxx` | |
2947 | libsfiles="$libsfiles $yyy" | |
1e127011 | 2948 | yyy=`echo $xxx|$sed -e "s%/$yyy\\$%%"` |
43999f95 JH |
2949 | case " $libsdirs " in |
2950 | *" $yyy "*) ;; | |
2951 | *) libsdirs="$libsdirs $yyy" ;; | |
2952 | esac | |
2953 | ;; | |
bd9b35c9 | 2954 | esac |
f7dd4e7f JH |
2955 | break |
2956 | fi | |
2957 | done | |
2958 | if $test ! -f "$xxx"; then | |
2959 | echo "No -l$thislib." | |
bd9b35c9 JH |
2960 | fi |
2961 | done | |
2962 | set X $dflt | |
2963 | shift | |
2964 | dflt="$*" | |
2965 | case "$libs" in | |
2966 | '') dflt="$dflt";; | |
2967 | *) dflt="$libs";; | |
2968 | esac | |
2969 | case "$dflt" in | |
2970 | ' '|'') dflt='none';; | |
2971 | esac | |
4633a7c4 | 2972 | |
bd9b35c9 | 2973 | $cat <<EOM |
4633a7c4 | 2974 | |
bd9b35c9 JH |
2975 | In order to compile $package on your machine, a number of libraries |
2976 | are usually needed. Include any other special libraries here as well. | |
2977 | Say "none" for none. The default list is almost always right. | |
8e07c86e | 2978 | EOM |
8e07c86e | 2979 | |
bd9b35c9 JH |
2980 | echo " " |
2981 | rp="What libraries to use?" | |
2982 | . ./myread | |
2983 | case "$ans" in | |
2984 | none) libs=' ';; | |
2985 | *) libs="$ans";; | |
2986 | esac | |
d71b2b6b | 2987 | |
9c839522 PM |
2988 | : determine filename position in cpp output |
2989 | echo " " | |
2990 | echo "Computing filename position in cpp output for #include directives..." >&4 | |
2991 | echo '#include <stdio.h>' > foo.c | |
2992 | $cat >fieldn <<EOF | |
2993 | $startsh | |
2994 | $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \ | |
2995 | $grep '^[ ]*#.*stdio\.h' | \ | |
2996 | while read cline; do | |
2997 | pos=1 | |
2998 | set \$cline | |
2999 | while $test \$# -gt 0; do | |
3000 | if $test -r \`echo \$1 | $tr -d '"'\`; then | |
3001 | echo "\$pos" | |
3002 | exit 0 | |
3003 | fi | |
3004 | shift | |
3005 | pos=\`expr \$pos + 1\` | |
3006 | done | |
3007 | done | |
3008 | EOF | |
3009 | chmod +x fieldn | |
3010 | fieldn=`./fieldn` | |
3011 | $rm -f foo.c fieldn | |
3012 | case $fieldn in | |
3013 | '') pos='???';; | |
3014 | 1) pos=first;; | |
3015 | 2) pos=second;; | |
3016 | 3) pos=third;; | |
3017 | *) pos="${fieldn}th";; | |
3018 | esac | |
3019 | echo "Your cpp writes the filename in the $pos field of the line." | |
3020 | ||
3021 | : locate header file | |
3022 | $cat >findhdr <<EOF | |
3023 | $startsh | |
3024 | wanted=\$1 | |
3025 | name='' | |
3026 | for usrincdir in $usrinc | |
3027 | do | |
3028 | if test -f \$usrincdir/\$wanted; then | |
3029 | echo "\$usrincdir/\$wanted" | |
3030 | exit 0 | |
3031 | fi | |
3032 | done | |
3033 | awkprg='{ print \$$fieldn }' | |
3034 | echo "#include <\$wanted>" > foo\$\$.c | |
3035 | $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \ | |
3036 | $grep "^[ ]*#.*\$wanted" | \ | |
3037 | while read cline; do | |
3038 | name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\` | |
3039 | case "\$name" in | |
3040 | *[/\\\\]\$wanted) echo "\$name"; exit 1;; | |
3041 | *[\\\\/]\$wanted) echo "\$name"; exit 1;; | |
3042 | *) exit 2;; | |
3043 | esac; | |
3044 | done; | |
3045 | # | |
3046 | # status = 0: grep returned 0 lines, case statement not executed | |
3047 | # status = 1: headerfile found | |
3048 | # status = 2: while loop executed, no headerfile found | |
3049 | # | |
3050 | status=\$? | |
3051 | $rm -f foo\$\$.c; | |
3052 | if test \$status -eq 1; then | |
3053 | exit 0; | |
3054 | fi | |
3055 | exit 1 | |
3056 | EOF | |
3057 | chmod +x findhdr | |
3058 | ||
3059 | : define an alternate in-header-list? function | |
3060 | inhdr='echo " "; td=$define; tu=$undef; yyy=$@; | |
3061 | cont=true; xxf="echo \"<\$1> found.\" >&4"; | |
3062 | case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";; | |
3063 | *) xxnf="echo \"<\$1> NOT found, ...\" >&4";; | |
3064 | esac; | |
3065 | case $# in 4) instead=instead;; *) instead="at last";; esac; | |
3066 | while $test "$cont"; do | |
3067 | xxx=`./findhdr $1` | |
3068 | var=$2; eval "was=\$$2"; | |
3069 | if $test "$xxx" && $test -r "$xxx"; | |
3070 | then eval $xxf; | |
3071 | eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td"; | |
3072 | cont=""; | |
3073 | else eval $xxnf; | |
3074 | eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi; | |
3075 | set $yyy; shift; shift; yyy=$@; | |
3076 | case $# in 0) cont="";; | |
3077 | 2) xxf="echo \"but I found <\$1> $instead.\" >&4"; | |
3078 | xxnf="echo \"and I did not find <\$1> either.\" >&4";; | |
3079 | *) xxf="echo \"but I found <\$1\> instead.\" >&4"; | |
3080 | xxnf="echo \"there is no <\$1>, ...\" >&4";; | |
3081 | esac; | |
3082 | done; | |
3083 | while $test "$yyy"; | |
3084 | do set $yyy; var=$2; eval "was=\$$2"; | |
3085 | eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; | |
3086 | set $yyy; shift; shift; yyy=$@; | |
3087 | done' | |
3088 | ||
3089 | : see if dld is available | |
3090 | set dld.h i_dld | |
3091 | eval $inhdr | |
3092 | ||
bd9b35c9 JH |
3093 | : determine optimization, if desired, or use for debug flag also |
3094 | case "$optimize" in | |
3095 | ' '|$undef) dflt='none';; | |
3096 | '') dflt='-O';; | |
3097 | *) dflt="$optimize";; | |
3098 | esac | |
3099 | $cat <<EOH | |
d71b2b6b | 3100 | |
bd9b35c9 JH |
3101 | By default, $package compiles with the -O flag to use the optimizer. |
3102 | Alternately, you might want to use the symbolic debugger, which uses | |
3103 | the -g flag (on traditional Unix systems). Either flag can be | |
3104 | specified here. To use neither flag, specify the word "none". | |
d71b2b6b | 3105 | |
bd9b35c9 JH |
3106 | EOH |
3107 | rp="What optimizer/debugger flag should be used?" | |
3108 | . ./myread | |
3109 | optimize="$ans" | |
3110 | case "$optimize" in | |
3111 | 'none') optimize=" ";; | |
3112 | esac | |
3113 | ||
3114 | dflt='' | |
3115 | : We will not override a previous value, but we might want to | |
3116 | : augment a hint file | |
3117 | case "$hint" in | |
3118 | default|recommended) | |
3119 | case "$gccversion" in | |
3120 | 1*) dflt='-fpcc-struct-return' ;; | |
d71b2b6b | 3121 | esac |
bd9b35c9 JH |
3122 | case "$optimize" in |
3123 | *-g*) dflt="$dflt -DDEBUGGING";; | |
d71b2b6b | 3124 | esac |
bd9b35c9 JH |
3125 | case "$gccversion" in |
3126 | 2*) if test -d /etc/conf/kconfig.d && | |
3127 | $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1 | |
3128 | then | |
3129 | dflt="$dflt -posix" | |
3130 | fi | |
f0d04425 | 3131 | ;; |
bd9b35c9 JH |
3132 | esac |
3133 | case "$gccversion" in | |
3134 | 1*) ;; | |
3135 | 2.[0-8]*) ;; | |
3136 | ?*) echo " " | |
3137 | echo "Checking if your compiler accepts -fno-strict-aliasing" 2>&1 | |
3138 | echo 'int main(void) { return 0; }' > gcctest.c | |
3139 | if $cc -O2 -fno-strict-aliasing -o gcctest gcctest.c; then | |
3140 | echo "Yes, it does." 2>&1 | |
3141 | case "$ccflags" in | |
3142 | *strict-aliasing*) | |
3143 | echo "Leaving current flags $ccflags alone." 2>&1 | |
3144 | ;; | |
3145 | *) dflt="$dflt -fno-strict-aliasing" ;; | |
3146 | esac | |
3147 | else | |
3148 | echo "Nope, it doesn't, but that's ok." 2>&1 | |
3149 | fi | |
f0d04425 | 3150 | ;; |
e5e20432 JH |
3151 | esac |
3152 | ;; | |
3153 | esac | |
3154 | ||
bd9b35c9 JH |
3155 | case "$mips_type" in |
3156 | *BSD*|'') inclwanted="$locincpth $usrinc";; | |
3157 | *) inclwanted="$locincpth $inclwanted $usrinc/bsd";; | |
3158 | esac | |
3159 | for thisincl in $inclwanted; do | |
3160 | if $test -d $thisincl; then | |
3161 | if $test x$thisincl != x$usrinc; then | |
3162 | case "$dflt" in | |
422af00a LC |
3163 | *" -I$thisincl "*);; |
3164 | *) dflt="$dflt -I$thisincl ";; | |
bd9b35c9 JH |
3165 | esac |
3166 | fi | |
3167 | fi | |
3168 | done | |
40a7a20a | 3169 | |
bd9b35c9 JH |
3170 | inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then |
3171 | xxx=true; | |
3172 | elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then | |
3173 | xxx=true; | |
3174 | else | |
3175 | xxx=false; | |
3176 | fi; | |
3177 | if $xxx; then | |
3178 | case "$dflt" in | |
3179 | *$2*);; | |
3180 | *) dflt="$dflt -D$2";; | |
3181 | esac; | |
3182 | fi' | |
40a7a20a | 3183 | |
bd9b35c9 | 3184 | set signal.h LANGUAGE_C; eval $inctest |
40a7a20a | 3185 | |
bd9b35c9 JH |
3186 | case "$usesocks" in |
3187 | $define) | |
3188 | ccflags="$ccflags -DSOCKS" | |
3189 | ;; | |
3190 | esac | |
40a7a20a | 3191 | |
bd9b35c9 JH |
3192 | case "$hint" in |
3193 | default|recommended) dflt="$ccflags $dflt" ;; | |
3194 | *) dflt="$ccflags";; | |
3195 | esac | |
40a7a20a | 3196 | |
bd9b35c9 JH |
3197 | case "$dflt" in |
3198 | ''|' ') dflt=none;; | |
3199 | esac | |
422af00a | 3200 | |
bd9b35c9 | 3201 | $cat <<EOH |
40a7a20a | 3202 | |
bd9b35c9 JH |
3203 | Your C compiler may want other flags. For this question you should include |
3204 | -I/whatever and -DWHATEVER flags and any other flags used by the C compiler, | |
3205 | but you should NOT include libraries or ld flags like -lwhatever. If you | |
3206 | want $package to honor its debug switch, you should include -DDEBUGGING here. | |
3207 | Your C compiler might also need additional flags, such as -D_POSIX_SOURCE. | |
40a7a20a | 3208 | |
bd9b35c9 | 3209 | To use no flags, specify the word "none". |
40a7a20a | 3210 | |
bd9b35c9 JH |
3211 | EOH |
3212 | set X $dflt | |
3213 | shift | |
3214 | dflt=${1+"$@"} | |
3215 | rp="Any additional cc flags?" | |
3216 | . ./myread | |
3217 | case "$ans" in | |
3218 | none) ccflags='';; | |
3219 | *) ccflags="$ans";; | |
3220 | esac | |
8e07c86e | 3221 | |
bd9b35c9 JH |
3222 | : the following weeds options from ccflags that are of no interest to cpp |
3223 | cppflags="$ccflags" | |
3224 | case "$gccversion" in | |
3225 | 1*) cppflags="$cppflags -D__GNUC__" | |
4633a7c4 | 3226 | esac |
bd9b35c9 JH |
3227 | case "$mips_type" in |
3228 | '');; | |
3229 | *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";; | |
3230 | esac | |
3231 | case "$cppflags" in | |
3232 | '');; | |
3233 | *) | |
3234 | echo " " | |
3235 | echo "Let me guess what the preprocessor flags are..." >&4 | |
3236 | set X $cppflags | |
3237 | shift | |
3238 | cppflags='' | |
3239 | $cat >cpp.c <<'EOM' | |
3240 | #define BLURFL foo | |
8e07c86e | 3241 | |
bd9b35c9 JH |
3242 | BLURFL xx LFRULB |
3243 | EOM | |
3244 | previous='' | |
3245 | for flag in $* | |
3246 | do | |
3247 | case "$flag" in | |
3248 | -*) ftry="$flag";; | |
3249 | *) ftry="$previous $flag";; | |
3250 | esac | |
3251 | if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \ | |
3252 | >cpp1.out 2>/dev/null && \ | |
3253 | $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \ | |
3254 | >cpp2.out 2>/dev/null && \ | |
3255 | $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \ | |
3256 | $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1 | |
3257 | then | |
3258 | cppflags="$cppflags $ftry" | |
3259 | previous='' | |
3260 | else | |
3261 | previous="$flag" | |
3262 | fi | |
3263 | done | |
3264 | set X $cppflags | |
3265 | shift | |
3266 | cppflags=${1+"$@"} | |
3267 | case "$cppflags" in | |
3268 | *-*) echo "They appear to be: $cppflags";; | |
3269 | esac | |
3270 | $rm -f cpp.c cpp?.out | |
2afac517 | 3271 | ;; |
3272 | esac | |
8e07c86e | 3273 | |
bd9b35c9 JH |
3274 | : flags used in final linking phase |
3275 | case "$ldflags" in | |
3276 | '') if ./venix; then | |
3277 | dflt='-i -z' | |
10a23457 | 3278 | else |
bd9b35c9 | 3279 | dflt='' |
10a23457 | 3280 | fi |
bd9b35c9 JH |
3281 | case "$ccflags" in |
3282 | *-posix*) dflt="$dflt -posix" ;; | |
c4f23d77 | 3283 | esac |
bd9b35c9 JH |
3284 | ;; |
3285 | *) dflt="$ldflags";; | |
3286 | esac | |
3287 | ||
3288 | : Try to guess additional flags to pick up local libraries. | |
3289 | for thislibdir in $libpth; do | |
3290 | case " $loclibpth " in | |
3291 | *" $thislibdir "*) | |
3292 | case "$dflt " in | |
3293 | *"-L$thislibdir "*) ;; | |
3294 | *) dflt="$dflt -L$thislibdir" ;; | |
3295 | esac | |
c4f23d77 AD |
3296 | ;; |
3297 | esac | |
bd9b35c9 | 3298 | done |
c4f23d77 | 3299 | |
bd9b35c9 JH |
3300 | case "$dflt" in |
3301 | '') dflt='none' ;; | |
3302 | esac | |
c4f23d77 | 3303 | |
bd9b35c9 JH |
3304 | $cat <<EOH |
3305 | ||
3306 | Your C linker may need flags. For this question you should | |
3307 | include -L/whatever and any other flags used by the C linker, but you | |
3308 | should NOT include libraries like -lwhatever. | |
3309 | ||
3310 | Make sure you include the appropriate -L/path flags if your C linker | |
3311 | does not normally search all of the directories you specified above, | |
3312 | namely | |
3313 | $libpth | |
3314 | To use no flags, specify the word "none". | |
3315 | ||
3316 | EOH | |
3317 | ||
3318 | rp="Any additional ld flags (NOT including libraries)?" | |
3319 | . ./myread | |
3320 | case "$ans" in | |
3321 | none) ldflags='';; | |
3322 | *) ldflags="$ans";; | |
3323 | esac | |
3324 | rmlist="$rmlist pdp11" | |
3325 | ||
3326 | : coherency check | |
3327 | echo " " | |
3328 | echo "Checking your choice of C compiler and flags for coherency..." >&4 | |
3329 | $cat > try.c <<'EOF' | |
3330 | #include <stdio.h> | |
3331 | int main() { printf("Ok\n"); exit(0); } | |
3332 | EOF | |
3333 | set X $cc $optimize $ccflags -o try $ldflags try.c $libs | |
3334 | shift | |
3335 | $cat >try.msg <<'EOM' | |
3336 | I've tried to compile and run the following simple program: | |
3337 | ||
3338 | EOM | |
3339 | $cat try.c >> try.msg | |
3340 | ||
3341 | $cat >> try.msg <<EOM | |
3342 | ||
3343 | I used the command: | |
3344 | ||
3345 | $* | |
3346 | ./try | |
3347 | ||
3348 | and I got the following output: | |
3349 | ||
3350 | EOM | |
3351 | dflt=y | |
3352 | if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then | |
3353 | if sh -c './try' >>try.msg 2>&1; then | |
3354 | xxx=`./try` | |
3355 | case "$xxx" in | |
3356 | "Ok") dflt=n ;; | |
3357 | *) echo 'The program compiled OK, but produced no output.' >> try.msg | |
3358 | case " $libs " in | |
3359 | *" -lsfio "*) | |
3360 | cat >> try.msg <<'EOQS' | |
3361 | If $libs contains -lsfio, and sfio is mis-configured, then it | |
3362 | sometimes (apparently) runs and exits with a 0 status, but with no | |
3363 | output! It may have to do with sfio's use of _exit vs. exit. | |
3364 | ||
3365 | EOQS | |
3366 | rp="You have a big problem. Shall I abort Configure" | |
3367 | dflt=y | |
3368 | ;; | |
3369 | esac | |
3370 | ;; | |
3371 | esac | |
3372 | else | |
3373 | echo "The program compiled OK, but exited with status $?." >>try.msg | |
3374 | rp="You have a problem. Shall I abort Configure" | |
3375 | dflt=y | |
3376 | fi | |
3377 | else | |
3378 | echo "I can't compile the test program." >>try.msg | |
3379 | rp="You have a BIG problem. Shall I abort Configure" | |
3380 | dflt=y | |
3381 | fi | |
3382 | case "$dflt" in | |
3383 | y) | |
3384 | $cat try.msg >&4 | |
3385 | case "$knowitall" in | |
3386 | '') | |
3387 | echo "(The supplied flags or libraries might be incorrect.)" | |
c4f23d77 | 3388 | ;; |
bd9b35c9 | 3389 | *) dflt=n;; |
c4f23d77 | 3390 | esac |
bd9b35c9 JH |
3391 | echo " " |
3392 | . ./myread | |
3393 | case "$ans" in | |
3394 | n*|N*) ;; | |
3395 | *) echo "Ok. Stopping Configure." >&4 | |
3396 | exit 1 | |
c4f23d77 AD |
3397 | ;; |
3398 | esac | |
3399 | ;; | |
bd9b35c9 | 3400 | n) echo "OK, that should do.";; |
c4f23d77 | 3401 | esac |
bd9b35c9 | 3402 | $rm -f try try.* core |
c4f23d77 | 3403 | |
bd9b35c9 JH |
3404 | : define a shorthand compile call |
3405 | compile=' | |
3406 | mc_file=$1; | |
3407 | shift; | |
3408 | $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;' | |
3409 | : define a shorthand compile call for compilations that should be ok. | |
3410 | compile_ok=' | |
3411 | mc_file=$1; | |
3412 | shift; | |
3413 | $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;' | |
8e07c86e | 3414 | |
bd9b35c9 | 3415 | echo " " |
9c839522 PM |
3416 | echo "Checking for GNU C Library..." >&4 |
3417 | cat >gnulibc.c <<EOM | |
bd9b35c9 JH |
3418 | #include <stdio.h> |
3419 | int main() | |
3420 | { | |
9c839522 PM |
3421 | #ifdef __GLIBC__ |
3422 | exit(0); | |
3423 | #else | |
3424 | exit(1); | |
3425 | #endif | |
bd9b35c9 | 3426 | } |
bd9b35c9 | 3427 | EOM |
9c839522 PM |
3428 | set gnulibc |
3429 | if eval $compile_ok && ./gnulibc; then | |
3430 | val="$define" | |
3431 | echo "You are using the GNU C Library" | |
bd9b35c9 | 3432 | else |
c1a7f87b JH |
3433 | val="$undef" |
3434 | echo "You are not using the GNU C Library" | |
bd9b35c9 | 3435 | fi |
c1a7f87b JH |
3436 | $rm -f gnulibc* |
3437 | set d_gnulibc | |
3438 | eval $setvar | |
3439 | ||
3440 | : see if nm is to be used to determine whether a symbol is defined or not | |
3441 | case "$usenm" in | |
3442 | '') | |
3443 | dflt='' | |
3444 | case "$d_gnulibc" in | |
3445 | "$define") | |
3446 | echo " " | |
3447 | echo "nm probably won't work on the GNU C Library." >&4 | |
3448 | dflt=n | |
bd9b35c9 | 3449 | ;; |
c1a7f87b JH |
3450 | esac |
3451 | case "$dflt" in | |
3452 | '') | |
3453 | if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then | |
3454 | echo " " | |
3455 | echo "Whoops! This is an AIX system without /lib/syscalls.exp!" >&4 | |
3456 | echo "'nm' won't be sufficient on this sytem." >&4 | |
3457 | dflt=n | |
3458 | fi | |
3459 | ;; | |
3460 | esac | |
3461 | case "$dflt" in | |
3462 | '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null` | |
3463 | if $test $dflt -gt 20; then | |
3464 | dflt=y | |
3465 | else | |
3466 | dflt=n | |
3467 | fi | |
bd9b35c9 JH |
3468 | ;; |
3469 | esac | |
bd9b35c9 JH |
3470 | ;; |
3471 | *) | |
c1a7f87b JH |
3472 | case "$usenm" in |
3473 | true|$define) dflt=y;; | |
3474 | *) dflt=n;; | |
3475 | esac | |
bd9b35c9 JH |
3476 | ;; |
3477 | esac | |
3478 | $cat <<EOM | |
3479 | ||
c1a7f87b JH |
3480 | I can use $nm to extract the symbols from your C libraries. This |
3481 | is a time consuming task which may generate huge output on the disk (up | |
3482 | to 3 megabytes) but that should make the symbols extraction faster. The | |
3483 | alternative is to skip the 'nm' extraction part and to compile a small | |
3484 | test program instead to determine whether each symbol is present. If | |
3485 | you have a fast C compiler and/or if your 'nm' output cannot be parsed, | |
3486 | this may be the best solution. | |
3487 | ||
3488 | You probably shouldn't let me use 'nm' if you are using the GNU C Library. | |
bd9b35c9 JH |
3489 | |
3490 | EOM | |
c1a7f87b JH |
3491 | rp="Shall I use $nm to extract C symbols from the libraries?" |
3492 | . ./myread | |
3493 | case "$ans" in | |
3494 | [Nn]*) usenm=false;; | |
3495 | *) usenm=true;; | |
bd9b35c9 | 3496 | esac |
bd9b35c9 | 3497 | |
c1a7f87b JH |
3498 | runnm=$usenm |
3499 | case "$reuseval" in | |
3500 | true) runnm=false;; | |
8e07c86e | 3501 | esac |
29209bc5 | 3502 | |
c1a7f87b JH |
3503 | : nm options which may be necessary |
3504 | case "$nm_opt" in | |
3505 | '') if $test -f /mach_boot; then | |
3506 | nm_opt='' # Mach | |
3507 | elif $test -d /usr/ccs/lib; then | |
3508 | nm_opt='-p' # Solaris (and SunOS?) | |
3509 | elif $test -f /dgux; then | |
3510 | nm_opt='-p' # DG-UX | |
3511 | elif $test -f /lib64/rld; then | |
3512 | nm_opt='-p' # 64-bit Irix | |
3513 | else | |
3514 | nm_opt='' | |
3515 | fi;; | |
3516 | esac | |
bd9b35c9 | 3517 | |
c1a7f87b JH |
3518 | : nm options which may be necessary for shared libraries but illegal |
3519 | : for archive libraries. Thank you, Linux. | |
3520 | case "$nm_so_opt" in | |
3521 | '') case "$myuname" in | |
3522 | *linux*) | |
3523 | if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then | |
3524 | nm_so_opt='--dynamic' | |
3525 | fi | |
3526 | ;; | |
bd9b35c9 | 3527 | esac |
c1a7f87b JH |
3528 | ;; |
3529 | esac | |
8e07c86e | 3530 | |
c1a7f87b JH |
3531 | case "$runnm" in |
3532 | true) | |
3533 | : get list of predefined functions in a handy place | |
3534 | echo " " | |
3535 | case "$libc" in | |
3536 | '') libc=unknown | |
3537 | case "$libs" in | |
3538 | *-lc_s*) libc=`./loc libc_s$_a $libc $libpth` | |
bd9b35c9 | 3539 | esac |
ff935051 JH |
3540 | ;; |
3541 | esac | |
c1a7f87b JH |
3542 | libnames=''; |
3543 | case "$libs" in | |
3544 | '') ;; | |
3545 | *) for thislib in $libs; do | |
3546 | case "$thislib" in | |
3547 | -lc|-lc_s) | |
3548 | : Handle C library specially below. | |
3549 | ;; | |
3550 | -l*) | |
3551 | thislib=`echo $thislib | $sed -e 's/^-l//'` | |
3552 | if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then | |
3553 | : | |
3554 | elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then | |
3555 | : | |
3556 | elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then | |
3557 | : | |
3558 | elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then | |
3559 | : | |
3560 | elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then | |
3561 | : | |
3562 | elif try=`./loc $thislib X $libpth`; $test -f "$try"; then | |
3563 | : | |
3564 | elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then | |
3565 | : | |
3566 | else | |
3567 | try='' | |
3568 | fi | |
3569 | libnames="$libnames $try" | |
3570 | ;; | |
3571 | *) libnames="$libnames $thislib" ;; | |
34d1710f | 3572 | esac |
c1a7f87b | 3573 | done |
4633a7c4 LW |
3574 | ;; |
3575 | esac | |
c1a7f87b JH |
3576 | xxx=normal |
3577 | case "$libc" in | |
3578 | unknown) | |
3579 | set /lib/libc.$so | |
3580 | for xxx in $libpth; do | |
3581 | $test -r $1 || set $xxx/libc.$so | |
3582 | : The messy sed command sorts on library version numbers. | |
3583 | $test -r $1 || \ | |
3584 | set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \ | |
3585 | tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e ' | |
3586 | h | |
3587 | s/[0-9][0-9]*/0000&/g | |
3588 | s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g | |
3589 | G | |
3590 | s/\n/ /' | \ | |
3591 | sort | $sed -e 's/^.* //'` | |
3592 | eval set \$$# | |
3593 | done | |
3594 | $test -r $1 || set /usr/ccs/lib/libc.$so | |
3595 | $test -r $1 || set /lib/libsys_s$_a | |
3596 | ;; | |
3597 | *) | |
3598 | set blurfl | |
3599 | ;; | |
a4f3eea9 | 3600 | esac |
c1a7f87b JH |
3601 | if $test -r "$1"; then |
3602 | echo "Your (shared) C library seems to be in $1." | |
3603 | libc="$1" | |
3604 | elif $test -r /lib/libc && $test -r /lib/clib; then | |
3605 | echo "Your C library seems to be in both /lib/clib and /lib/libc." | |
3606 | xxx=apollo | |
3607 | libc='/lib/clib /lib/libc' | |
3608 | if $test -r /lib/syslib; then | |
3609 | echo "(Your math library is in /lib/syslib.)" | |
3610 | libc="$libc /lib/syslib" | |
3611 | fi | |
3612 | elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then | |
3613 | echo "Your C library seems to be in $libc, as you said before." | |
3614 | elif $test -r $incpath/usr/lib/libc$_a; then | |
3615 | libc=$incpath/usr/lib/libc$_a; | |
3616 | echo "Your C library seems to be in $libc. That's fine." | |
3617 | elif $test -r /lib/libc$_a; then | |
3618 | libc=/lib/libc$_a; | |
3619 | echo "Your C library seems to be in $libc. You're normal." | |
3620 | else | |
3621 | if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then | |
3622 | : | |
3623 | elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then | |
3624 | libnames="$libnames "`./loc clib blurfl/dyick $libpth` | |
3625 | elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then | |
3626 | : | |
3627 | elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then | |
3628 | : | |
3629 | elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then | |
3630 | : | |
3631 | else | |
3632 | tans=`./loc Llibc$_a blurfl/dyick $xlibpth` | |
3633 | fi | |
3634 | if $test -r "$tans"; then | |
3635 | echo "Your C library seems to be in $tans, of all places." | |
3636 | libc=$tans | |
3637 | else | |
3638 | libc='blurfl' | |
3639 | fi | |
3640 | fi | |
3641 | if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then | |
3642 | dflt="$libc" | |
3643 | cat <<EOM | |
a4f3eea9 | 3644 | |
c1a7f87b JH |
3645 | If the guess above is wrong (which it might be if you're using a strange |
3646 | compiler, or your machine supports multiple models), you can override it here. | |
bd9b35c9 JH |
3647 | |
3648 | EOM | |
a4f3eea9 | 3649 | else |
c1a7f87b JH |
3650 | dflt='' |
3651 | echo $libpth | tr ' ' $trnl | sort | uniq > libpath | |
3652 | cat >&4 <<EOM | |
3653 | I can't seem to find your C library. I've looked in the following places: | |
a4f3eea9 | 3654 | |
c1a7f87b JH |
3655 | EOM |
3656 | $sed 's/^/ /' libpath | |
3657 | cat <<EOM | |
29209bc5 | 3658 | |
c1a7f87b | 3659 | None of these seems to contain your C library. I need to get its name... |
a4f3eea9 | 3660 | |
bd9b35c9 | 3661 | EOM |
bd9b35c9 | 3662 | fi |
c1a7f87b JH |
3663 | fn=f |
3664 | rp='Where is your C library?' | |
3665 | . ./getfile | |
3666 | libc="$ans" | |
a4f3eea9 | 3667 | |
c1a7f87b JH |
3668 | echo " " |
3669 | echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames | |
3670 | set X `cat libnames` | |
3671 | shift | |
3672 | xxx=files | |
3673 | case $# in 1) xxx=file; esac | |
3674 | echo "Extracting names from the following $xxx for later perusal:" >&4 | |
3675 | echo " " | |
3676 | $sed 's/^/ /' libnames >&4 | |
3677 | echo " " | |
3678 | $echo $n "This may take a while...$c" >&4 | |
a4f3eea9 | 3679 | |
c1a7f87b JH |
3680 | for file in $*; do |
3681 | case $file in | |
3682 | *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;; | |
3683 | *) $nm $nm_opt $file 2>/dev/null;; | |
a4f3eea9 | 3684 | esac |
c1a7f87b | 3685 | done >libc.tmp |
a4f3eea9 | 3686 | |
c1a7f87b JH |
3687 | $echo $n ".$c" |
3688 | $grep fprintf libc.tmp > libc.ptf | |
3689 | xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4' | |
3690 | xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4' | |
3691 | xxx='[ADTSIW]' | |
3692 | if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx *_[_.]*//p' -e 's/^.* $xxx *//p'";\ | |
3693 | eval $xscan;\ | |
3694 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3695 | eval $xrun | |
3696 | elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\ | |
3697 | eval $xscan;\ | |
3698 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3699 | eval $xrun | |
3700 | elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\ | |
3701 | eval $xscan;\ | |
3702 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3703 | eval $xrun | |
3704 | elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\ | |
3705 | eval $xscan;\ | |
3706 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3707 | eval $xrun | |
3708 | elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\ | |
3709 | eval $xscan;\ | |
3710 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3711 | eval $xrun | |
3712 | elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\ | |
3713 | eval $xscan;\ | |
3714 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3715 | eval $xrun | |
3716 | elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \ | |
3717 | -e '/ file/d' -e 's/^\([^ ]*\).*/\1/p'";\ | |
3718 | eval $xscan;\ | |
3719 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3720 | eval $xrun | |
3721 | elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\ | |
3722 | eval $xscan;\ | |
3723 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3724 | eval $xrun | |
3725 | elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\ | |
3726 | eval $xscan;\ | |
3727 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3728 | eval $xrun | |
3729 | elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\ | |
3730 | eval $xscan;\ | |
3731 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3732 | eval $xrun | |
3733 | elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\ | |
3734 | eval $xscan;\ | |
3735 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3736 | eval $xrun | |
3737 | elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\ | |
3738 | eval $xscan;\ | |
3739 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3740 | eval $xrun | |
3741 | elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\ | |
3742 | eval $xscan;\ | |
3743 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3744 | eval $xrun | |
3745 | elif com="sed -n -e 's/^__.*//' -e 's/[ ]*D[ ]*[0-9]*.*//p'";\ | |
3746 | eval $xscan;\ | |
3747 | $contains '^fprintf$' libc.list >/dev/null 2>&1; then | |
3748 | eval $xrun | |
3749 | else | |
3750 | $nm -p $* 2>/dev/null >libc.tmp | |
3751 | $grep fprintf libc.tmp > libc.ptf | |
3752 | if com="$sed -n -e 's/^.* [ADTSIW] *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\ | |
3753 | eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1 | |
3754 | then | |
3755 | nm_opt='-p' | |
3756 | eval $xrun | |
bd9b35c9 | 3757 | else |
c1a7f87b JH |
3758 | echo " " |
3759 | echo "$nm didn't seem to work right. Trying $ar instead..." >&4 | |
3760 | com='' | |
3761 | if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then | |
3762 | for thisname in $libnames $libc; do | |
3763 | $ar t $thisname >>libc.tmp | |
3764 | done | |
3765 | $sed -e "s/\\$_o\$//" < libc.tmp > libc.list | |
3766 | echo "Ok." >&4 | |
3767 | elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then | |
3768 | # Repeat libc to extract forwarders to DLL entries too | |
3769 | for thisname in $libnames $libc; do | |
3770 | $ar tv $thisname >>libc.tmp | |
3771 | # Revision 50 of EMX has bug in $ar. | |
3772 | # it will not extract forwarders to DLL entries | |
3773 | # Use emximp which will extract exactly them. | |
3774 | emximp -o tmp.imp $thisname \ | |
3775 | 2>/dev/null && \ | |
3776 | $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \ | |
3777 | < tmp.imp >>libc.tmp | |
3778 | $rm tmp.imp | |
3779 | done | |
3780 | $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list | |
3781 | echo "Ok." >&4 | |
3782 | else | |
3783 | echo "$ar didn't seem to work right." >&4 | |
3784 | echo "Maybe this is a Cray...trying bld instead..." >&4 | |
3785 | if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list | |
3786 | then | |
3787 | for thisname in $libnames; do | |
3788 | bld t $libnames | \ | |
3789 | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list | |
3790 | $ar t $thisname >>libc.tmp | |
3791 | done | |
3792 | echo "Ok." >&4 | |
bd9b35c9 | 3793 | else |
c1a7f87b JH |
3794 | echo "That didn't work either. Giving up." >&4 |
3795 | exit 1 | |
bd9b35c9 | 3796 | fi |
c1a7f87b | 3797 | fi |
a4f3eea9 | 3798 | fi |
a4f3eea9 | 3799 | fi |
c1a7f87b JH |
3800 | nm_extract="$com" |
3801 | if $test -f /lib/syscalls.exp; then | |
3802 | echo " " | |
3803 | echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4 | |
3804 | $sed -n 's/^\([^ ]*\)[ ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list | |
3805 | fi | |
3806 | ;; | |
3807 | esac | |
3808 | $rm -f libnames libpath | |
bd9b35c9 | 3809 | |
c1a7f87b JH |
3810 | : is a C symbol defined? |
3811 | csym='tlook=$1; | |
3812 | case "$3" in | |
3813 | -v) tf=libc.tmp; tc=""; tdc="";; | |
3814 | -a) tf=libc.tmp; tc="[0]"; tdc="[]";; | |
3815 | *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";; | |
3816 | esac; | |
3817 | tx=yes; | |
3818 | case "$reuseval-$4" in | |
3819 | true-) ;; | |
3820 | true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;; | |
3821 | esac; | |
3822 | case "$tx" in | |
3823 | yes) | |
3824 | case "$runnm" in | |
3825 | true) | |
3826 | if $contains $tlook $tf >/dev/null 2>&1; | |
3827 | then tval=true; | |
3828 | else tval=false; | |
3829 | fi;; | |
3830 | *) | |
3831 | echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c; | |
3832 | if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1; | |
3833 | then tval=true; | |
3834 | else tval=false; | |
3835 | fi; | |
3836 | $rm -f t t.c;; | |
3837 | esac;; | |
3838 | *) | |
3839 | case "$tval" in | |
3840 | $define) tval=true;; | |
3841 | *) tval=false;; | |
3842 | esac;; | |
3843 | esac; | |
3844 | eval "$2=$tval"' | |
bd9b35c9 | 3845 | |
c1a7f87b JH |
3846 | : define an is-in-libc? function |
3847 | inlibc='echo " "; td=$define; tu=$undef; | |
3848 | sym=$1; var=$2; eval "was=\$$2"; | |
3849 | tx=yes; | |
3850 | case "$reuseval$was" in | |
3851 | true) ;; | |
3852 | true*) tx=no;; | |
3853 | esac; | |
3854 | case "$tx" in | |
3855 | yes) | |
3856 | set $sym tres -f; | |
3857 | eval $csym; | |
3858 | case "$tres" in | |
3859 | true) | |
3860 | echo "$sym() found." >&4; | |
3861 | case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";; | |
3862 | *) | |
3863 | echo "$sym() NOT found." >&4; | |
3864 | case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";; | |
3865 | esac;; | |
bd9b35c9 | 3866 | *) |
c1a7f87b JH |
3867 | case "$was" in |
3868 | $define) echo "$sym() found." >&4;; | |
3869 | *) echo "$sym() NOT found." >&4;; | |
3870 | esac;; | |
3871 | esac' | |
3872 | ||
9c839522 PM |
3873 | : see if dlopen exists |
3874 | xxx_runnm="$runnm" | |
3875 | runnm=false | |
3876 | set dlopen d_dlopen | |
c1a7f87b | 3877 | eval $inlibc |
9c839522 | 3878 | runnm="$xxx_runnm" |
c1a7f87b | 3879 | |
9c839522 PM |
3880 | : determine which dynamic loading, if any, to compile in |
3881 | echo " " | |
3882 | dldir="ext/DynaLoader" | |
3883 | case "$usedl" in | |
3884 | $define|y|true) | |
3885 | dflt='y' | |
3886 | usedl="$define" | |
3887 | ;; | |
3888 | $undef|n|false) | |
3889 | dflt='n' | |
3890 | usedl="$undef" | |
3891 | ;; | |
3892 | *) | |
3893 | dflt='n' | |
3894 | case "$d_dlopen" in | |
3895 | $define) dflt='y' ;; | |
3896 | esac | |
3897 | case "$i_dld" in | |
3898 | $define) dflt='y' ;; | |
3899 | esac | |
3900 | : Does a dl_xxx.xs file exist for this operating system | |
3901 | $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y' | |
3902 | ;; | |
c1a7f87b | 3903 | esac |
9c839522 | 3904 | rp="Do you wish to use dynamic loading?" |
c1a7f87b | 3905 | . ./myread |
9c839522 | 3906 | usedl="$ans" |
c1a7f87b | 3907 | case "$ans" in |
9c839522 PM |
3908 | y*) usedl="$define" |
3909 | case "$dlsrc" in | |
3910 | '') | |
3911 | if $test -f $rsrc/$dldir/dl_${osname}.xs ; then | |
3912 | dflt="$dldir/dl_${osname}.xs" | |
3913 | elif $test "$d_dlopen" = "$define" ; then | |
3914 | dflt="$dldir/dl_dlopen.xs" | |
3915 | elif $test "$i_dld" = "$define" ; then | |
3916 | dflt="$dldir/dl_dld.xs" | |
3917 | else | |
3918 | dflt='' | |
3919 | fi | |
3920 | ;; | |
3921 | *) dflt="$dldir/$dlsrc" | |
3922 | ;; | |
3923 | esac | |
3924 | echo "The following dynamic loading files are available:" | |
3925 | : Can not go over to $dldir because getfile has path hard-coded in. | |
3926 | tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir | |
3927 | rp="Source file to use for dynamic loading" | |
3928 | fn="fne" | |
3929 | gfpth="$src" | |
3930 | . ./getfile | |
3931 | usedl="$define" | |
3932 | : emulate basename | |
3933 | dlsrc=`echo $ans | $sed -e 's%.*/\([^/]*\)$%\1%'` | |
bfb7748a | 3934 | |
9c839522 | 3935 | $cat << EOM |
bfb7748a | 3936 | |
9c839522 PM |
3937 | Some systems may require passing special flags to $cc -c to |
3938 | compile modules that will be used to create a shared library. | |
3939 | To use no flags, say "none". | |
bfb7748a | 3940 | |
c1a7f87b | 3941 | EOM |
9c839522 PM |
3942 | case "$cccdlflags" in |
3943 | '') case "$gccversion" in | |
3944 | '') case "$osname" in | |
3945 | hpux) dflt='+z' ;; | |
3946 | next) dflt='none' ;; | |
3947 | irix*) dflt='-KPIC' ;; | |
3948 | svr4*|esix*|solaris) dflt='-KPIC' ;; | |
3949 | sunos) dflt='-pic' ;; | |
3950 | *) dflt='none' ;; | |
3951 | esac | |
c1a7f87b | 3952 | ;; |
9c839522 PM |
3953 | *) case "$osname" in |
3954 | svr4*|esix*|solaris) dflt='-fPIC' ;; | |
3955 | *) dflt='-fpic' ;; | |
3956 | esac ;; | |
3957 | esac ;; | |
3958 | ' ') dflt='none' ;; | |
3959 | *) dflt="$cccdlflags" ;; | |
3960 | esac | |
3961 | rp="Any special flags to pass to $cc -c to compile shared library modules?" | |
3962 | . ./myread | |
3963 | case "$ans" in | |
3964 | none) cccdlflags=' ' ;; | |
3965 | *) cccdlflags="$ans" ;; | |
3966 | esac | |
5f80c64f | 3967 | |
9c839522 | 3968 | cat << EOM |
923fc586 | 3969 | |
9c839522 PM |
3970 | Some systems use ld to create libraries that can be dynamically loaded, |
3971 | while other systems (such as those using ELF) use $cc. | |
5f80c64f | 3972 | |
9c839522 PM |
3973 | EOM |
3974 | case "$ld" in | |
3975 | '') $cat >try.c <<'EOM' | |
3976 | /* Test for whether ELF binaries are produced */ | |
3977 | #include <fcntl.h> | |
3978 | #include <stdlib.h> | |
3979 | int main() { | |
3980 | char b[4]; | |
3981 | int i = open("a.out",O_RDONLY); | |
3982 | if(i == -1) | |
3983 | exit(1); /* fail */ | |
3984 | if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F') | |
3985 | exit(0); /* succeed (yes, it's ELF) */ | |
5f80c64f | 3986 | else |
9c839522 PM |
3987 | exit(1); /* fail */ |
3988 | } | |
3989 | EOM | |
3990 | if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then | |
3991 | cat <<EOM | |
3992 | You appear to have ELF support. I'll use $cc to build dynamic libraries. | |
3993 | EOM | |
3994 | dflt="$cc" | |
3995 | else | |
3996 | echo "I'll use ld to build dynamic libraries." | |
3997 | dflt='ld' | |
3998 | fi | |
3999 | rm -f try.c a.out | |
5f80c64f | 4000 | ;; |
9c839522 | 4001 | *) dflt="$ld" |
5f80c64f JH |
4002 | ;; |
4003 | esac | |
5f80c64f | 4004 | |
9c839522 PM |
4005 | rp="What command should be used to create dynamic libraries?" |
4006 | . ./myread | |
4007 | ld="$ans" | |
5f80c64f | 4008 | |
9c839522 | 4009 | cat << EOM |
5f80c64f | 4010 | |
9c839522 PM |
4011 | Some systems may require passing special flags to $ld to create a |
4012 | library that can be dynamically loaded. If your ld flags include | |
4013 | -L/other/path options to locate libraries outside your loader's normal | |
4014 | search path, you may need to specify those -L options here as well. To | |
4015 | use no flags, say "none". | |
5f80c64f JH |
4016 | |
4017 | EOM | |
9c839522 PM |
4018 | case "$lddlflags" in |
4019 | '') case "$osname" in | |
4020 | beos) dflt='-nostart' ;; | |
4021 | hpux) dflt='-b'; | |
4022 | case "$gccversion" in | |
4023 | '') dflt="$dflt +vnocompatwarnings" ;; | |
4024 | esac | |
4025 | ;; | |
4026 | linux|irix*) dflt='-shared' ;; | |
4027 | next) dflt='none' ;; | |
4028 | solaris) dflt='-G' ;; | |
4029 | sunos) dflt='-assert nodefinitions' ;; | |
4030 | svr4*|esix*) dflt="-G $ldflags" ;; | |
4031 | *) dflt='none' ;; | |
4032 | esac | |
5f80c64f | 4033 | ;; |
9c839522 PM |
4034 | *) dflt="$lddlflags" ;; |
4035 | esac | |
4036 | ||
4037 | : Try to guess additional flags to pick up local libraries. | |
4038 | : Be careful not to append to a plain 'none' | |
5f80c64f | 4039 | case "$dflt" in |
9c839522 | 4040 | none) dflt='' ;; |
5f80c64f | 4041 | esac |
9c839522 PM |
4042 | for thisflag in $ldflags; do |
4043 | case "$thisflag" in | |
4044 | -L*|-R*) | |
4045 | case " $dflt " in | |
4046 | *" $thisflag "*) ;; | |
4047 | *) dflt="$dflt $thisflag" ;; | |
5f80c64f | 4048 | esac |
9c839522 PM |
4049 | ;; |
4050 | esac | |
4051 | done | |
5f80c64f JH |
4052 | |
4053 | case "$dflt" in | |
9c839522 | 4054 | ''|' ') dflt='none' ;; |
5f80c64f | 4055 | esac |
5f80c64f | 4056 | |
9c839522 PM |
4057 | rp="Any special flags to pass to $ld to create a dynamically loaded library?" |
4058 | . ./myread | |
4059 | case "$ans" in | |
4060 | none) lddlflags=' ' ;; | |