This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[ID 20000911.009] t/pod/*.t tests not run by harness or make test
[perl5.git] / Configure
CommitLineData
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
26cat >/tmp/c1$$ <<EOF
27ARGGGHHHH!!!!!
28
29SCO csh still thinks true is false. Write to SCO today and tell them that next
30year 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
33we'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...]
36EOF
37cat >/tmp/c2$$ <<EOF
38
39OOPS! You naughty creature! You didn't run Configure with sh!
40I will attempt to remedy the situation by running sh for you...
41EOF
42
43true || cat /tmp/c1$$ /tmp/c2$$
44true || exec sh $0 $argv:q
45
46(exit $?0) || cat /tmp/c2$$
47(exit $?0) || exec sh $0 $argv:q
48rm -f /tmp/c1$$ /tmp/c2$$
49
a0d0e21e
LW
50: compute my invocation name
51me=$0
52case "$0" in
53*/*)
54 me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
55 test "$me" || me=$0
56 ;;
57esac
58
dfe9444c 59: Proper separator for the PATH environment variable
8e07c86e
AD
60p_=:
61: On OS/2 this directory should exist if this is not floppy only system :-]
dfe9444c
AD
62if 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 70fi
a0d0e21e
LW
71
72: Proper PATH setting
73paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
16d20bd9 74paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
232e078e 75paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
16d20bd9 76paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
232e078e
AD
77paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
78paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
79paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
80paths="$paths /sbin /usr/sbin /usr/libexec"
a0d0e21e
LW
81
82for p in $paths
83do
8e07c86e
AD
84 case "$p_$PATH$p_" in
85 *$p_$p$p_*) ;;
86 *) test -d $p && PATH=$PATH$p_$p ;;
a0d0e21e
LW
87 esac
88done
89
8e07c86e 90PATH=.$p_$PATH
2304df62
AD
91export PATH
92
dfe9444c
AD
93: shall we be using ksh?
94inksh=''
95needksh=''
96avoidksh=''
97newsh=/bin/ksh
98changesh=''
ff0cee69 99if (PATH=.; alias -x) >/dev/null 2>&1; then
dfe9444c
AD
100 inksh=true
101fi
102if test -f /hp-ux -a -f /bin/ksh; then
103 needksh='to avoid sh bug in "here document" expansion'
104fi
105if 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 110fi
cf04f91f
JH
111if 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
117fi
dfe9444c
AD
118case "$inksh/$needksh" in
119/[a-z]*)
c4f23d77 120 ENV=''
dfe9444c
AD
121 changesh=true
122 reason="$needksh"
123 ;;
124esac
125case "$inksh/$avoidksh" in
126true/[a-z]*)
127 changesh=true
128 reason="$avoidksh"
129 ;;
130esac
131case "$inksh/$needksh-$avoidksh-" in
132true/--)
a0d0e21e
LW
133 cat <<EOM
134(I see you are using the Korn shell. Some ksh's blow up on $me,
dfe9444c 135mainly on older exotic systems. If yours does, try the Bourne shell instead.)
ff0cee69 136EOM
dfe9444c
AD
137 ;;
138esac
139case "$changesh" in
140true)
141 echo "(Feeding myself to $newsh $reason.)"
142 case "$0" in
143 Configure|*/Configure) exec $newsh $0 "$@";;
144 *) exec $newsh Configure "$@";;
145 esac
146 ;;
147esac
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.
151case "$CDPATH" in
152'') ;;
153*) case "$SHELL" in
154 *bash*) CDPATH='.' ;;
155 *) CDPATH='' ;;
156 esac
157 ;;
158esac
2304df62
AD
159: Configure runs within the UU subdirectory
160test -d UU || mkdir UU
8e07c86e 161cd UU && rm -f ./*
2304df62 162
6b356c8e
JH
163ccname=''
164ccversion=''
9c839522 165perllibs=''
ecfc5424 166d_bsd=''
40a7a20a 167d_eunice=''
2304df62
AD
168d_xenix=''
169eunicefix=''
170Mcc=''
dfe9444c 171ar=''
2304df62
AD
172awk=''
173bash=''
174bison=''
175byacc=''
176cat=''
177chgrp=''
178chmod=''
179chown=''
ecfc5424 180comm=''
2304df62
AD
181compress=''
182cp=''
183cpio=''
184cpp=''
185csh=''
186date=''
187echo=''
188egrep=''
189emacs=''
190expr=''
191find=''
192flex=''
2304df62 193grep=''
8ff267be 194gzip=''
2304df62
AD
195inews=''
196ksh=''
197less=''
198line=''
199lint=''
200ln=''
201lp=''
202lpr=''
203ls=''
204mail=''
205mailx=''
dfe9444c 206make=''
2304df62
AD
207mkdir=''
208more=''
209mv=''
693762b4 210nm=''
2304df62
AD
211nroff=''
212perl=''
213pg=''
214pmake=''
215pr=''
216rm=''
217rmail=''
218sed=''
219sendmail=''
2304df62
AD
220shar=''
221sleep=''
222smail=''
223sort=''
224submit=''
225tail=''
226tar=''
227tbl=''
693762b4 228tee=''
2304df62
AD
229test=''
230touch=''
231tr=''
232troff=''
233uname=''
234uniq=''
235uuname=''
236vi=''
237zcat=''
8ff267be 238zip=''
a0d0e21e 239libswanted=''
2304df62
AD
240hint=''
241myuname=''
85e6fe83
LW
242osname=''
243osvers=''
2304df62
AD
244Author=''
245Date=''
246Header=''
247Id=''
248Locker=''
249Log=''
250RCSfile=''
251Revision=''
252Source=''
253State=''
dfe9444c
AD
254_a=''
255_exe=''
256_o=''
4633a7c4
LW
257archobjs=''
258exe_ext=''
259firstmakefile=''
260lib_ext=''
261obj_ext=''
262path_sep=''
2304df62 263cc=''
2304df62
AD
264ccflags=''
265cppflags=''
266ldflags=''
267lkflags=''
8e07c86e 268locincpth=''
2304df62
AD
269optimize=''
270cf_by=''
271cf_time=''
272contains=''
273cpplast=''
274cppminus=''
275cpprun=''
276cppstdin=''
a0d0e21e 277d_dlopen=''
a4f3eea9 278d_gnulibc=''
2304df62 279d_portable=''
85e6fe83
LW
280cccdlflags=''
281ccdlflags=''
2304df62 282dlsrc=''
232e078e 283ld=''
85e6fe83 284lddlflags=''
2304df62 285usedl=''
5b463ca7 286gccosandvers=''
8a27cf78 287gccversion=''
a0d0e21e 288i_dld=''
2304df62 289libc=''
a0d0e21e 290glibpth=''
2304df62 291libpth=''
8e07c86e 292loclibpth=''
2304df62
AD
293plibpth=''
294xlibpth=''
1cfa4ec7 295ignore_versioned_solibs=''
2304df62 296libs=''
43999f95
JH
297libsdirs=''
298libsfiles=''
299libsfound=''
13b3f787 300libspath=''
85e6fe83 301lns=''
8ff267be 302make_set_make=''
2304df62
AD
303c=''
304n=''
2304df62
AD
305package=''
306spackage=''
8ff267be 307sh=''
a0d0e21e 308so=''
2304df62
AD
309sharpbang=''
310shsharp=''
311spitshell=''
dfe9444c 312src=''
2304df62 313startsh=''
5ff3f7a4 314trnl=''
2304df62 315nm_opt=''
40a7a20a 316nm_so_opt=''
2304df62
AD
317runnm=''
318usenm=''
29209bc5 319usesocks=''
2304df62 320incpath=''
2304df62
AD
321mips_type=''
322usrinc=''
2304df62
AD
323CONFIG=''
324
ecfc5424
AD
325define='define'
326undef='undef'
327smallmach='pdp11 i8086 z8000 i80286 iAPX286'
328rmlist=''
329
330: We must find out about Eunice early
331eunicefix=':'
332if test -f /etc/unixtovms; then
333 eunicefix=/etc/unixtovms
334fi
335if test -f /etc/unixtovms.exe; then
336 eunicefix=/etc/unixtovms.exe
337fi
338
6b356c8e
JH
339ccname=''
340ccversion=''
9c839522 341perllibs=''
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.
345archobjs=''
9c839522
PM
346cppflags=''
347optimize=''
ff935051
JH
348: Possible local include directories to search.
349: Set locincpth to "" in a hint file to defeat local include searches.
350locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
351locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
352:
353: no include file wanted by default
354inclwanted=''
355
732c9516
JH
356: change the next line if compiling for Xenix/286 on Xenix/386
357xlibpth='/usr/lib/386 /lib/386'
732c9516
JH
358: Possible local library directories to search.
359loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
360loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
361
362: general looking path for locating libraries
5869b1f1 363glibpth="/lib /usr/lib $xlibpth"
732c9516 364glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
f7dd4e7f
JH
365test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
366test -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.
371plibpth=''
372
1cfa4ec7
GS
373: default library list
374libswanted=''
921b2963 375: some systems want to use only the non-versioned libso:s
1cfa4ec7 376ignore_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 380libswanted='sfio socket bind inet nsl nm ndbm gdbm dbm db malloc dl'
69e84d1d 381libswanted="$libswanted dld ld sun m c cposix posix"
f1066039 382libswanted="$libswanted ndir dir crypt sec"
0c9177ab 383libswanted="$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
386glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
387glibpth="/usr/shlib $glibpth"
388: Do not use vfork unless overridden by a hint file.
389usevfork=false
390
8ff267be 391: Find the basic shell for Bourne shell scripts
392case "$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 ;;
419esac
420
421case "$sh" in
422'') cat <<EOM >&2
423$me: Fatal Error: I can't find a Bourne Shell anywhere.
dfe9444c 424
8ff267be 425Usually it's in /bin/sh. How did you even get this far?
7f2de2d2 426Please contact me (Perl Maintainers) at perlbug@perl.org and
dfe9444c 427we'll try to straighten this all out.
8ff267be 428EOM
429 exit 1
430 ;;
431esac
432
760ac839 433: see if sh knows # comments
8ff267be 434if `$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
456else
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 '
468fi
469rm -f try today
470
471: figure out how to guarantee sh startup
8ff267be 472case "$startsh" in
473'') startsh=${sharpbang}${sh} ;;
474*)
760ac839 475esac
760ac839
LW
476cat >try <<EOSS
477$startsh
478set abc
479test "$?abc" != 1
480EOSS
481
482chmod +x try
483$eunicefix try
484if ./try; then
8ff267be 485 : echo "Yup, it does."
760ac839 486else
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
489fi
490rm -f try
491
aebf16e7
AD
492
493: Save command line options in file UU/cmdline.opt for later use in
494: generating config.sh.
495cat > cmdline.opt <<EOSH
496# Configure command line arguments.
497config_arg0='$0'
498config_args='$*'
499config_argc=$#
500EOSH
501argn=1
502for arg in "$@"; do
503 cat >>cmdline.opt <<EOSH
504config_arg$argn='$arg'
505EOSH
506 argn=`expr $argn + 1`
507done
508
2304df62
AD
509: produce awk script to parse command line options
510cat >options.awk <<'EOF'
511BEGIN {
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}
549END {
550 if (expect)
551 print "?";
552}
553EOF
554
555: process the command line options
4633a7c4
LW
556set X `for arg in "$@"; do echo "X$arg"; done |
557 sed -e s/X// | awk -f options.awk`
2304df62
AD
558eval "set $*"
559shift
560rm -f options.awk
561
562: set up default values
563fastread=''
564reuseval=false
565config_sh=''
566alldone=''
567error=''
568silent=''
569extractsh=''
ecfc5424 570override=''
16d20bd9 571knowitall=''
02e93a22 572rm -f optdef.sh posthint.sh
28757baa 573cat >optdef.sh <<EOS
574$startsh
575EOS
2304df62 576
dfe9444c 577
2304df62
AD
578: option parsing
579while 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
682done
683
684case "$error" in
685true)
686 cat >&2 <<EOM
2afac517 687Usage: $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).
716EOM
717 exit 1
718 ;;
719esac
720
dfe9444c
AD
721: Sanity checks
722case "$fastread$alldone" in
723yescont|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 ;;
735esac
736
2304df62
AD
737exec 4>&1
738case "$silent" in
739true) exec 1>/dev/null;;
740esac
741
ecfc5424 742: run the defines and the undefines, if any, but leave the file out there...
1aef975c
AD
743touch optdef.sh
744. ./optdef.sh
02e93a22
JH
745: create the posthint manipulation script and leave the file out there...
746touch posthint.sh
a0d0e21e 747
2304df62 748: set package name
85e6fe83 749package=perl5
2304df62 750
2304df62
AD
751: Some greps do not return status, grrr.
752echo "grimblepritz" >grimble
753if grep blurfldyick grimble >/dev/null 2>&1 ; then
754 contains=contains
755elif grep grimblepritz grimble >/dev/null 2>&1 ; then
756 contains=grep
757else
758 contains=contains
759fi
760rm -f grimble
761: the following should work in any shell
762case "$contains" in
763contains*)
764 echo " "
765 echo "AGH! Grep doesn't return a status. Attempting remedial action."
766 cat >contains <<'EOSS'
767grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
768EOSS
769chmod +x contains
770esac
771
dfe9444c
AD
772: Find the path to the source tree
773case "$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;;
783esac
784case "$src" in
785'') src=/
786 rsrc=/
787 ;;
788/*) rsrc="$src";;
789*) rsrc="../$src";;
790esac
791if test -f $rsrc/Configure && \
792 $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
793then
794 : found it, so we are ok.
795else
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
805fi
806case "$rsrc" in
807'')
808 cat <<EOM >&4
809
810Sorry, I can't seem to locate the source dir for $package. Please start
811Configure with an explicit path -- i.e. /some/path/Configure.
812
813EOM
814 exit 1
815 ;;
816../.) rsrc='..';;
817*)
818 echo " "
819 echo "Sources for $package found in \"$src\"." >&4
820 ;;
821esac
822
823: script used to extract .SH files with variable substitutions
824cat >extract <<'EOS'
2000072c 825CONFIGDOTSH=true
dfe9444c
AD
826echo "Doing variable substitutions on .SH files..."
827if test -f $src/MANIFEST; then
f7ab18e9 828 set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
dfe9444c
AD
829else
830 echo "(Looking for .SH files under the source directory.)"
831 set x `(cd $src; find . -name "*.SH" -print)`
832fi
833shift
834case $# in
8350) set x `(cd $src; echo *.SH)`; shift;;
836esac
837if test ! -f $src/$1; then
838 shift
839fi
840mkdir_p='
841name=$1;
842create="";
843while 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;
851done;
852for file in $create; do
853 mkdir $file;
854done
855'
856for 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
884done
885if 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
890fi
891EOS
892
893: extract files and exit if asked to do so
894case "$extractsh" in
895true)
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 ;;
914esac
915
916: Eunice requires " " instead of "", can you believe it
917echo " "
918: Here we go...
919echo "Beginning of configuration questions for $package."
920
921trap '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
924echo " "
925echo "Checking echo to see how to suppress newlines..."
926(echo "hi there\c" ; echo " ") >.echotmp
927if $contains c .echotmp >/dev/null 2>&1 ; then
928 echo "...using -n."
929 n='-n'
930 c=''
931else
932 cat <<'EOM'
933...using \c
934EOM
935 n=''
936 c='\c'
937fi
938echo $n "The star should be here-->$c"
939echo '*'
940rm -f .echotmp
941
942: Now test for existence of everything in MANIFEST
943echo " "
dfe9444c 944if 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
956THIS PACKAGE SEEMS TO BE INCOMPLETE.
957
958You have the option of continuing the configuration process, despite the
959distinct possibility that your kit is damaged, by typing 'y'es. If you
960do, don't blame me if something goes wrong. I advise you to type 'n'o
7f2de2d2 961and contact the author (perlbug@perl.org).
2304df62
AD
962
963EOM
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
979else
980 echo "There is no MANIFEST file. I hope your kit is complete !"
981fi
982rm -f missing x??
983
5ff3f7a4
GS
984echo " "
985: Find the appropriate value for a newline for tr
986if test -n "$DJGPP"; then
987 trnl='\012'
988fi
989if test X"$trnl" = X; then
990 case "`echo foo|tr '\n' x 2>/dev/null`" in
991 foox) trnl='\n' ;;
992 esac
993fi
994if test X"$trnl" = X; then
995 case "`echo foo|tr '\012' x 2>/dev/null`" in
996 foox) trnl='\012' ;;
997 esac
998fi
999if test X"$trnl" = X; then
1000 cat <<EOM >&2
1001
1002$me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1003
1004EOM
1005 exit 1
1006fi
1007
2304df62
AD
1008: compute the number of columns on the terminal for proper question formatting
1009case "$COLUMNS" in
1010'') COLUMNS='80';;
1011esac
1012
1013: set up the echo used in my read
1014myecho="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;;
1027esac"
1028
1029: now set up to do reads with possible shell escape and default assignment
1030cat <<EOSC >myread
28757baa 1031$startsh
2304df62
AD
1032xxxm=\$dflt
1033$myecho
1034ans='!'
1035case "\$fastread" in
1036yes) 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;;
1049esac
1050while 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
1109done
1110case "\$ans" in
1111'') ans="\$xxxm";;
1112esac
1113EOSC
1114
1115: create .config dir to save info across Configure sessions
1116test -d ../.config || mkdir ../.config
1117cat >../.config/README <<EOF
1118This directory created by Configure to save information that should
dfe9444c 1119persist across sessions for $package.
2304df62
AD
1120
1121You may safely delete it if you wish.
1122EOF
1123
9507cadf 1124xversion=`awk '/define[ ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
af960fef 1125case "$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
1143EOH
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 ;;
1156esac
1157
2304df62
AD
1158: general instructions
1159needman=true
1160firsttime=true
760ac839 1161user=`(logname) 2>/dev/null`
dfe9444c
AD
1162case "$user" in
1163'') user=`whoami 2>&1`;;
760ac839 1164esac
2304df62
AD
1165if $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
1175fi
1176if $needman; then
1177 cat <<EOH
4e2a5f63 1178
2304df62 1179This installation shell script will examine your system and ask you questions
a0d0e21e 1180to determine how the perl5 package should be installed. If you get
2304df62
AD
1181stuck on a question, you may use a ! shell escape to start a subshell or
1182execute a command. Many of the questions will have default answers in square
1183brackets; typing carriage return will give you the default.
1184
1185On some of the questions which ask for file or directory names you are allowed
1186to use the ~name construct to specify the login directory belonging to "name",
1187even if you don't have a shell which knows about that. Questions where this is
1188allowed will be marked "(~name ok)".
1189
1190EOH
1191 rp=''
1192 dflt='Type carriage return to continue'
1193 . ./myread
1194 cat <<'EOH'
1195
1196The prompter used in this script allows you to use shell variables and
1197backticks in your answers. You may use $1, $2, etc... to refer to the words
1198in the default answer, as if the default line was a set of arguments given to a
1199script shell. This means you may also use $* to repeat the whole default line,
1200so you do not have to re-type everything to add something to the default.
1201
1202Everytime there is a substitution, you will have to confirm. If there is an
1203error (e.g. an unmatched backtick), the default answer will remain unchanged
1204and you will be prompted again.
1205
1206If you are in a hurry, you may run 'Configure -d'. This will bypass nearly all
1207the questions and use the computed defaults (or the previous answers if there
1208was already a config.sh file). Type 'Configure -h' for a list of options.
ecfc5424 1209You may also start interactively and then answer '& -d' at any prompt to turn
dfe9444c 1210on the non-interactive behaviour for the remainder of the execution.
2304df62
AD
1211
1212EOH
1213 . ./myread
1214 cat <<EOH
1215
1216Much effort has been expended to ensure that this shell script will run on any
1217Unix system. If despite that it blows up on yours, your best bet is to edit
40000a8c
AD
1218Configure and run it again. If you can't run Configure for some reason,
1219you'll have to generate a config.sh file by hand. Whatever problems you
7f2de2d2 1220have, let me (perlbug@perl.org) know how I blew it.
2304df62
AD
1221
1222This installation script affects things in two ways:
1223
12241) it may do direct variable substitutions on some of the files included
1225 in this kit.
12262) 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
1229If you make a mistake on a question, there is no easy way to back up to it
1230currently. The easiest thing to do is to edit config.sh and rerun all the SH
1231files. Configure will offer to let you do this before it runs the SH files.
1232
1233EOH
1234 dflt='Type carriage return to continue'
1235 . ./myread
1236 case "$firsttime" in
1237 true) echo $user >>../.config/instruct;;
1238 esac
1239fi
1240
2304df62
AD
1241: find out where common programs are
1242echo " "
1243echo "Locating common programs..." >&4
1244cat <<EOSC >loc
1245$startsh
1246case \$# in
12470) exit 1;;
1248esac
1249thing=\$1
1250shift
1251dflt=\$1
1252shift
1253for 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
1279done
1280echo \$dflt
1281exit 1
1282EOSC
1283chmod +x loc
1284$eunicefix loc
1285loclist="
1286awk
1287cat
2304df62
AD
1288echo
1289expr
1290grep
a0d0e21e 1291ls
dfe9444c 1292make
2304df62
AD
1293rm
1294sed
85e6fe83 1295touch
2304df62 1296tr
2304df62
AD
1297"
1298trylist="
1299Mcc
dfe9444c 1300ar
2304df62 1301cpp
2304df62
AD
1302date
1303egrep
8ff267be 1304gzip
8ff267be 1305ln
693762b4 1306nm
2304df62
AD
1307test
1308uname
8ff267be 1309zip
2304df62 1310"
8e07c86e 1311pth=`echo $PATH | sed -e "s/$p_/ /g"`
2304df62
AD
1312pth="$pth /lib /usr/lib"
1313for 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
1342done
1343echo " "
1344echo "Don't worry if any of the following aren't found..."
1345say=offhand
1346for 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
1374done
1375case "$egrep" in
1376egrep)
1377 echo "Substituting grep for egrep."
1378 egrep=$grep
1379 ;;
1380esac
8ff267be 1381case "$ln" in
1382ln)
1383 echo "Substituting cp for ln."
1384 ln=$cp
1385 ;;
1386esac
2304df62
AD
1387case "$test" in
1388test)
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 ;;
1398esac
1399case "$echo" in
1400echo)
1401 echo "Hopefully echo is built into your sh."
1402 ;;
1403'') ;;
1404*)
1405 echo " "
1406echo "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
1417They are not compatible! You are probably running ksh on a non-USG system.
1418I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1419have echo built in and we may have to run some Bourne shell scripts. That
1420means I'll have to use '$n$c' to suppress newlines now. Life is ridiculous.
1421
1422FOO
1423 $echo $n "The star should be here-->$c"
1424 $echo "*"
1425 fi
1426 $rm -f foo1 foo2
1427 ;;
1428esac
1429
2573c5f9
JH
1430cat <<EOS >checkcc
1431$startsh
1432EOS
1433cat <<'EOSC' >>checkcc
1434case "$cc" in
1435'') ;;
1436*) $rm -f try try.*
1437 $cat >try.c <<EOM
1438int main(int argc, char *argv[]) {
1439 return 0;
1440}
1441EOM
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 ;;
1483esac
1484EOSC
1485
a0d0e21e
LW
1486: determine whether symbolic links are supported
1487echo " "
1488$touch blurfl
1489if $ln -s blurfl sym > /dev/null 2>&1 ; then
1490 echo "Symbolic links are supported." >&4
1491 lns="$ln -s"
1492else
1493 echo "Symbolic links are NOT supported." >&4
1494 lns="$ln"
1495fi
1496$rm -f blurfl sym
1497
ecfc5424
AD
1498: see whether [:lower:] and [:upper:] are supported character classes
1499echo " "
ecfc5424
AD
1500case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1501ABYZ)
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
1543esac
3eaeeeae 1544case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
28e8609d
JH
1545ij)
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
1553esac
1554: set up the translation script tr, must be called with ./tr of course
1555cat >tr <<EOSC
1556$startsh
1557case "\$1\$2" in
1558'[A-Z][a-z]') exec $tr '$up' '$low';;
1559'[a-z][A-Z]') exec $tr '$low' '$up';;
1560esac
1561exec $tr "\$@"
1562EOSC
1563chmod +x tr
1564$eunicefix tr
1565
2304df62
AD
1566: Try to determine whether config.sh was made on this system
1567case "$config_sh" in
1568'')
43999f95
JH
1569myuname=`$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 1573myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
3eaeeeae 1574 ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
1aef975c 1575newmyuname="$myuname"
2304df62 1576dflt=n
16d20bd9
AD
1577case "$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;;
1589esac
2304df62
AD
1590
1591: Get old answers from old config file if Configure was run on the
1592: same system, otherwise use the hints.
1593hint=default
1594cd ..
1595if 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
1617fi
2573c5f9 1618. ./UU/checkcc
2304df62
AD
1619if test ! -f config.sh; then
1620 $cat <<EOM
1621
4e2a5f63
AD
1622First time through, eh? I have some defaults handy for some systems
1623that need some extra help getting the Configure answers right:
2304df62
AD
1624
1625EOM
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
1938There's also a Policy hint file available, which should make the
1939site-specific (policy) questions easier to answer.
1940EOM
1941
1942 fi
1943
2304df62
AD
1944 $cat <<EOM
1945
1946You may give one or more space-separated answers, or "none" if appropriate.
4e2a5f63 1947A well-behaved OS will have no hints, so answering "none" or just "Policy"
a3635516 1948is a good thing. DO NOT give a wrong version or a wrong OS.
2304df62
AD
1949
1950EOM
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
1990fi
1991cd 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 ;;
2008esac
1aef975c
AD
2009test "$override" && . ./optdef.sh
2010myuname="$newmyuname"
2304df62
AD
2011
2012: Restore computed paths
2013for file in $loclist $trylist; do
2014 eval $file="\$_$file"
2015done
2016
85e6fe83 2017cat << EOM
a0d0e21e 2018
85e6fe83 2019Configure uses the operating system name and version to set some defaults.
ecfc5424
AD
2020The default value is probably right if the name rings a bell. Otherwise,
2021since spelling matters for me, either accept the default or answer "none"
2022to leave it blank.
a0d0e21e 2023
85e6fe83 2024EOM
85e6fe83 2025case "$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" ;;
2033esac
2034rp="Operating system name?"
2035. ./myread
2036case "$ans" in
ecfc5424
AD
2037none) osname='' ;;
2038*) osname=`echo "$ans" | $sed -e 's/[ ][ ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
85e6fe83 2039esac
8ff267be 2040echo " "
2041case "$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" ;;
2054esac
2055rp="Operating system version?"
2056. ./myread
2057case "$ans" in
2058none) osvers='' ;;
2059*) osvers="$ans" ;;
2060esac
2061
02e93a22
JH
2062
2063. ./posthint.sh
2064
2304df62 2065: who configured the system
59b83a6f 2066cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
8ff267be 2067cf_by=`(logname) 2>/dev/null`
dfe9444c
AD
2068case "$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 ;;
2074esac
2304df62 2075
e5e20432
JH
2076: make some quick guesses about what we are up against
2077echo " "
2078$echo $n "Hmm... $c"
2079echo exit 1 >bsd
2080echo exit 1 >usg
2081echo exit 1 >v7
2082echo exit 1 >osf1
2083echo exit 1 >eunice
2084echo exit 1 >xenix
2085echo exit 1 >venix
2086echo exit 1 >os2
2087d_bsd="$undef"
2088$cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
2089if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
2090then
2091 echo "Looks kind of like an OSF/1 system, but we'll see..."
2092 echo exit 0 >osf1
2093elif 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
2107elif $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
2111else
2112 echo "Looks kind of like a Version 7 system, but we'll see..."
2113 echo exit 0 >v7
2114fi
2115case "$eunicefix" in
2116*unixtovms*)
2117 $cat <<'EOI'
2118There is, however, a strange, musty smell in the air that reminds me of
2119something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
2120EOI
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 ;;
2130esac
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
2134case "$p_" in
2135:) ;;
2136*)
2137 $cat <<'EOI'
2138I have the feeling something is not exactly right, however...don't tell me...
2139lemme 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
2141EOI
2142 echo exit 0 >os2
2143 ;;
2144esac
2145if test -f /xenix; then
2146 echo "Actually, this looks more like a XENIX system..."
2147 echo exit 0 >xenix
2148 d_xenix="$define"
2149else
2150 echo " "
2151 echo "It's not Xenix..."
2152 d_xenix="$undef"
2153fi
2154chmod +x xenix
2155$eunicefix xenix
2156if test -f /venix; then
2157 echo "Actually, this looks more like a VENIX system..."
2158 echo exit 0 >venix
2159else
2160 echo " "
2161 if ./xenix; then
2162 : null
2163 else
2164 echo "Nor is it Venix..."
2165 fi
2166fi
2167chmod +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
2171case "$cc" in
2172'') dflt=cc;;
2173*) dflt="$cc";;
2174esac
2175rp="Use which C compiler?"
2176. ./myread
2177cc="$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.
2181if $test -f cc.cbu; then
2182 . ./cc.cbu
2183fi
2573c5f9 2184. ./checkcc
8a27cf78 2185
e5e20432
JH
2186echo " "
2187echo "Checking for GNU cc in disguise and/or its version number..." >&4
2188$cat >gccvers.c <<EOM
2189#include <stdio.h>
2190int 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}
2200EOM
bf0c440f 2201if $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
2209else
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
2219fi
2220$rm -f gccvers*
2221case "$gccversion" in
22221*) cpp=`./loc gcc-cpp $cpp $pth` ;;
2223esac
5b463ca7
KS
2224case "$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
2249EOM
2250 ;;
81575342 2251 *) gccosandvers='' ;; # failed to parse, better be silent
5b463ca7
KS
2252 esac
2253 ;;
2254esac
e723fc21
JH
2255case "$ccname" in
2256'') ccname="$cc" ;;
2257esac
e5e20432 2258
8a27cf78
JH
2259: see how we invoke the C preprocessor
2260echo " "
2261echo "Now, how can we feed standard input to your C preprocessor..." >&4
2262cat <<'EOT' >testcpp.c
2263#define ABC abc
2264#define XYZ xyz
2265ABC.XYZ
2266EOT
2267cd ..
2268if 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
2276else
2277 echo "Keeping your $hint cppstdin wrapper."
2278fi
2279chmod 755 cppstdin
2280wrapper=`pwd`/cppstdin
2281ok='false'
2282cd UU
2283
2284if $test "X$cppstdin" != "X" && \
2285 $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
2286 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
2287then
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
2302else
2303 case "$cppstdin" in
2304 '') ;;
2305 *)
2306 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
2307 ;;
2308 esac
2309fi
2310
2311if $ok; then
2312 : nothing
2313elif 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='';
2319elif 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='-';
2325elif 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='';
2331elif 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='-';
2337elif 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='';
2343elif 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='-';
2349elif 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!"
2355else
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
2365echo "Sorry, I can't get that to work. Go find one and rerun Configure." >&4
2366 exit 1
2367 fi
2368fi
2369
2370case "$ok" in
2371false)
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 ;;
2399esac
2400
2401case "$cppstdin" in
2402"$wrapper"|'cppstdin') ;;
2403*) $rm -f $wrapper;;
2404esac
2405$rm -f testcpp.c testcpp.out
2406
bd9b35c9
JH
2407: decide how portable to be. Allow command line overrides.
2408case "$d_portable" in
2409"$undef") ;;
2410*) d_portable="$define" ;;
104d25b7 2411esac
85ab1d1d 2412
bd9b35c9
JH
2413: set up shell script to do ~ expansion
2414cat >filexp <<EOSS
2415$startsh
2416: expand filename
2417case "\$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 ;;
2448esac
4633a7c4
LW
2449EOSS
2450chmod +x filexp
2451$eunicefix filexp
2304df62
AD
2452
2453: now set up to get a file name
28757baa 2454cat <<EOS >getfile
2455$startsh
2456EOS
2457cat <<'EOSC' >>getfile
2304df62
AD
2458tilde=''
2459fullpath=''
2460already=''
2461skip=''
2462none_ok=''
2463exp_file=''
a0d0e21e 2464nopath_ok=''
2304df62
AD
2465orig_rp="$rp"
2466orig_dflt="$dflt"
b233458b
JH
2467case "$gfpth" in
2468'') gfpth='.' ;;
2469esac
2304df62
AD
2470
2471case "$fn" in
ecfc5424 2472*\(*)
28e8609d 2473 expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
ecfc5424
AD
2474 fn=`echo $fn | sed 's/(.*)//'`
2475 ;;
2476esac
2477
2478case "$fn" in
a0d0e21e
LW
2479*:*)
2480 loc_file=`expr $fn : '.*:\(.*\)'`
2481 fn=`expr $fn : '\(.*\):.*'`
2482 ;;
2483esac
2484
2485case "$fn" in
2304df62
AD
2486*~*) tilde=true;;
2487esac
2488case "$fn" in
2489*/*) fullpath=true;;
2490esac
2491case "$fn" in
2492*+*) skip=true;;
2493esac
2494case "$fn" in
2495*n*) none_ok=true;;
2496esac
2497case "$fn" in
2498*e*) exp_file=true;;
2499esac
a0d0e21e
LW
2500case "$fn" in
2501*p*) nopath_ok=true;;
2502esac
2304df62
AD
2503
2504case "$fn" in
2505*f*) type='File';;
2506*d*) type='Directory';;
a0d0e21e 2507*l*) type='Locate';;
2304df62
AD
2508esac
2509
2510what="$type"
2511case "$what" in
2512Locate) what='File';;
2513esac
2514
2515case "$exp_file" in
2516'')
2517 case "$d_portable" in
2518 "$define") ;;
2519 *) exp_file=true;;
2520 esac
2521 ;;
2522esac
2523
2524cd ..
2525while 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
2678done
2679cd UU
2680ans="$value"
2681rp="$orig_rp"
2682dflt="$orig_dflt"
ecfc5424 2683rm -f getfile.ok
b233458b 2684test "X$gfpthkeep" != Xy && gfpth=""
2304df62
AD
2685EOSC
2686
bd9b35c9
JH
2687: What should the include directory be ?
2688echo " "
2689$echo $n "Hmm... $c"
2690dflt='/usr/include'
2691incpath=''
2692mips_type=''
2693if $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
2699EOCP
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
2711else
2712 echo "Doesn't look like a MIPS system."
2713 xxx_prompt=n
2714 echo "exit 1" >mips
2715fi
2716chmod +x mips
2717$eunicefix mips
2718case "$usrinc" in
2719'') ;;
2720*) dflt="$usrinc";;
2721esac
2722case "$xxx_prompt" in
2723y) 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 ;;
2731esac
2304df62 2732
bd9b35c9
JH
2733: Set private lib path
2734case "$plibpth" in
2735'') if ./mips; then
2736 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
2737 fi;;
2738esac
2739case "$libpth" in
2740' ') dlist='';;
2741'') dlist="$loclibpth $plibpth $glibpth";;
2742*) dlist="$libpth";;
2743esac
2744
2745: Now check and see which directories actually exist, avoiding duplicates
2746libpth=''
2747for xxx in $dlist
2748do
2749 if $test -d $xxx; then
2750 case " $libpth " in
2751 *" $xxx "*) ;;
2752 *) libpth="$libpth $xxx";;
2753 esac
2754 fi
2755done
2756$cat <<'EOM'
2757
2758Some systems have incompatible or broken versions of libraries. Among
2759the directories listed in the question below, please remove any you
2760know not to be holding relevant libraries, and add any that are needed.
2761Say "none" for none.
8e07c86e
AD
2762
2763EOM
bd9b35c9
JH
2764case "$libpth" in
2765'') dflt='none';;
8e07c86e 2766*)
bd9b35c9
JH
2767 set X $libpth
2768 shift
2769 dflt=${1+"$@"}
8e07c86e 2770 ;;
a0d0e21e 2771esac
bd9b35c9
JH
2772rp="Directories to use for library searches?"
2773. ./myread
2774case "$ans" in
2775none) libpth=' ';;
2776*) libpth="$ans";;
2777esac
a0d0e21e 2778
bd9b35c9
JH
2779: compute shared library extension
2780case "$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 2789esac
dd4e71fd
JH
2790$cat <<EOM
2791
bd9b35c9 2792On some systems, shared libraries may be available. Answer 'none' if
7f95ee77 2793you want to suppress searching of shared libraries for the remainder
bd9b35c9 2794of this configuration.
dd4e71fd
JH
2795
2796EOM
bd9b35c9
JH
2797rp='What is the file extension used for shared libraries?'
2798. ./myread
2799so="$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.
2805case "$_exe" in
2806'') case "$exe_ext" in
2807 '') ;;
2808 *) _exe="$exe_ext" ;;
dd4e71fd 2809 esac
bd9b35c9 2810 ;;
bfb7748a 2811esac
bd9b35c9
JH
2812case "$_a" in
2813'') case "$lib_ext" in
2814 '') _a='.a';;
2815 *) _a="$lib_ext" ;;
dd4e71fd
JH
2816 esac
2817 ;;
dd4e71fd 2818esac
bd9b35c9
JH
2819case "$_o" in
2820'') case "$obj_ext" in
2821 '') _o='.o';;
2822 *) _o="$obj_ext";;
2823 esac
2824 ;;
2825esac
2826case "$p_" in
2827'') case "$path_sep" in
2828 '') p_=':';;
2829 *) p_="$path_sep";;
2830 esac
2831 ;;
2832esac
2833exe_ext=$_exe
2834lib_ext=$_a
2835obj_ext=$_o
2836path_sep=$p_
dd4e71fd 2837
9c839522
PM
2838: set up the script used to warn in case of inconsistency
2839cat <<EOS >whoa
2840$startsh
2841EOS
2842cat <<'EOSC' >>whoa
2843dflt=y
2844echo " "
2845echo "*** WHOA THERE!!! ***" >&4
2846echo " The $hint value for \$$var on this machine was \"$was\"!" >&4
2847rp=" Keep the $hint value?"
2848. ./myread
2849case "$ans" in
2850y) td=$was; tu=$was;;
4633a7c4 2851esac
9c839522
PM
2852EOSC
2853
2854: function used to set $1 to $val
2855setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2856case "$val$was" in
2857$define$undef) . ./whoa; eval "$var=\$td";;
2858$undef$define) . ./whoa; eval "$var=\$tu";;
2859*) eval "$var=$val";;
2860esac'
4633a7c4 2861
0f0995ae
JH
2862case "$usesocks" in
2863$define|true|[yY]*) dflt='y';;
2864*) dflt='n';;
2865esac
bd9b35c9 2866cat <<EOM
4633a7c4 2867
bd9b35c9
JH
2868Perl can be built to use the SOCKS proxy protocol library. To do so,
2869Configure must be run with -Dusesocks.
4633a7c4 2870
0f0995ae 2871If this doesn't make any sense to you, just accept the default '$dflt'.
bd9b35c9 2872EOM
bd9b35c9
JH
2873rp='Build Perl for SOCKS?'
2874. ./myread
2875case "$ans" in
2876y|Y) val="$define" ;;
2877*) val="$undef" ;;
2878esac
2879set usesocks
2880eval $setvar
2881
2882: Looking for optional libraries
2883echo " "
2884echo "Checking for optional libraries..." >&4
2885case "$libs" in
2886' '|'') dflt='';;
2887*) dflt="$libs";;
2888esac
2889case "$libswanted" in
2890'') libswanted='c_s';;
2891esac
2892case "$usesocks" in
923fc586 2893"$define") libswanted="$libswanted socks5 socks5_sh" ;;
8e07c86e 2894esac
68435ea7
JH
2895libsfound=''
2896libsfiles=''
2897libsdirs=''
13b3f787
JH
2898libspath=''
2899for thisdir in $libpth $xlibpth; do
2900 test -d $thisdir && libspath="$libspath $thisdir"
2901done
bd9b35c9 2902for 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
2961done
2962set X $dflt
2963shift
2964dflt="$*"
2965case "$libs" in
2966'') dflt="$dflt";;
2967*) dflt="$libs";;
2968esac
2969case "$dflt" in
2970' '|'') dflt='none';;
2971esac
4633a7c4 2972
bd9b35c9 2973$cat <<EOM
4633a7c4 2974
bd9b35c9
JH
2975In order to compile $package on your machine, a number of libraries
2976are usually needed. Include any other special libraries here as well.
2977Say "none" for none. The default list is almost always right.
8e07c86e 2978EOM
8e07c86e 2979
bd9b35c9
JH
2980echo " "
2981rp="What libraries to use?"
2982. ./myread
2983case "$ans" in
2984none) libs=' ';;
2985*) libs="$ans";;
2986esac
d71b2b6b 2987
9c839522
PM
2988: determine filename position in cpp output
2989echo " "
2990echo "Computing filename position in cpp output for #include directives..." >&4
2991echo '#include <stdio.h>' > foo.c
2992$cat >fieldn <<EOF
2993$startsh
2994$cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
2995$grep '^[ ]*#.*stdio\.h' | \
2996while 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
3007done
3008EOF
3009chmod +x fieldn
3010fieldn=`./fieldn`
3011$rm -f foo.c fieldn
3012case $fieldn in
3013'') pos='???';;
30141) pos=first;;
30152) pos=second;;
30163) pos=third;;
3017*) pos="${fieldn}th";;
3018esac
3019echo "Your cpp writes the filename in the $pos field of the line."
3020
3021: locate header file
3022$cat >findhdr <<EOF
3023$startsh
3024wanted=\$1
3025name=''
3026for usrincdir in $usrinc
3027do
3028 if test -f \$usrincdir/\$wanted; then
3029 echo "\$usrincdir/\$wanted"
3030 exit 0
3031 fi
3032done
3033awkprg='{ print \$$fieldn }'
3034echo "#include <\$wanted>" > foo\$\$.c
3035$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
3036$grep "^[ ]*#.*\$wanted" | \
3037while 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;
3044done;
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#
3050status=\$?
3051$rm -f foo\$\$.c;
3052if test \$status -eq 1; then
3053 exit 0;
3054fi
3055exit 1
3056EOF
3057chmod +x findhdr
3058
3059: define an alternate in-header-list? function
3060inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
3061cont=true; xxf="echo \"<\$1> found.\" >&4";
3062case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
3063*) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
3064esac;
3065case $# in 4) instead=instead;; *) instead="at last";; esac;
3066while $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;
3082done;
3083while $test "$yyy";
3084do set $yyy; var=$2; eval "was=\$$2";
3085 eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
3086 set $yyy; shift; shift; yyy=$@;
3087done'
3088
3089: see if dld is available
3090set dld.h i_dld
3091eval $inhdr
3092
bd9b35c9
JH
3093: determine optimization, if desired, or use for debug flag also
3094case "$optimize" in
3095' '|$undef) dflt='none';;
3096'') dflt='-O';;
3097*) dflt="$optimize";;
3098esac
3099$cat <<EOH
d71b2b6b 3100
bd9b35c9
JH
3101By default, $package compiles with the -O flag to use the optimizer.
3102Alternately, you might want to use the symbolic debugger, which uses
3103the -g flag (on traditional Unix systems). Either flag can be
3104specified here. To use neither flag, specify the word "none".
d71b2b6b 3105
bd9b35c9
JH
3106EOH
3107rp="What optimizer/debugger flag should be used?"
3108. ./myread
3109optimize="$ans"
3110case "$optimize" in
3111'none') optimize=" ";;
3112esac
3113
3114dflt=''
3115: We will not override a previous value, but we might want to
3116: augment a hint file
3117case "$hint" in
3118default|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 ;;
3153esac
3154
bd9b35c9
JH
3155case "$mips_type" in
3156*BSD*|'') inclwanted="$locincpth $usrinc";;
3157*) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
3158esac
3159for 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
3168done
40a7a20a 3169
bd9b35c9
JH
3170inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
3171 xxx=true;
3172elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
3173 xxx=true;
3174else
3175 xxx=false;
3176fi;
3177if $xxx; then
3178 case "$dflt" in
3179 *$2*);;
3180 *) dflt="$dflt -D$2";;
3181 esac;
3182fi'
40a7a20a 3183
bd9b35c9 3184set signal.h LANGUAGE_C; eval $inctest
40a7a20a 3185
bd9b35c9
JH
3186case "$usesocks" in
3187$define)
3188 ccflags="$ccflags -DSOCKS"
3189 ;;
3190esac
40a7a20a 3191
bd9b35c9
JH
3192case "$hint" in
3193default|recommended) dflt="$ccflags $dflt" ;;
3194*) dflt="$ccflags";;
3195esac
40a7a20a 3196
bd9b35c9
JH
3197case "$dflt" in
3198''|' ') dflt=none;;
3199esac
422af00a 3200
bd9b35c9 3201$cat <<EOH
40a7a20a 3202
bd9b35c9
JH
3203Your 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,
3205but you should NOT include libraries or ld flags like -lwhatever. If you
3206want $package to honor its debug switch, you should include -DDEBUGGING here.
3207Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
40a7a20a 3208
bd9b35c9 3209To use no flags, specify the word "none".
40a7a20a 3210
bd9b35c9
JH
3211EOH
3212set X $dflt
3213shift
3214dflt=${1+"$@"}
3215rp="Any additional cc flags?"
3216. ./myread
3217case "$ans" in
3218none) ccflags='';;
3219*) ccflags="$ans";;
3220esac
8e07c86e 3221
bd9b35c9
JH
3222: the following weeds options from ccflags that are of no interest to cpp
3223cppflags="$ccflags"
3224case "$gccversion" in
32251*) cppflags="$cppflags -D__GNUC__"
4633a7c4 3226esac
bd9b35c9
JH
3227case "$mips_type" in
3228'');;
3229*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
3230esac
3231case "$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
3242BLURFL xx LFRULB
3243EOM
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 ;;
3272esac
8e07c86e 3273
bd9b35c9
JH
3274: flags used in final linking phase
3275case "$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";;
3286esac
3287
3288: Try to guess additional flags to pick up local libraries.
3289for 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 3298done
c4f23d77 3299
bd9b35c9
JH
3300case "$dflt" in
3301'') dflt='none' ;;
3302esac
c4f23d77 3303
bd9b35c9
JH
3304$cat <<EOH
3305
3306Your C linker may need flags. For this question you should
3307include -L/whatever and any other flags used by the C linker, but you
3308should NOT include libraries like -lwhatever.
3309
3310Make sure you include the appropriate -L/path flags if your C linker
3311does not normally search all of the directories you specified above,
3312namely
3313 $libpth
3314To use no flags, specify the word "none".
3315
3316EOH
3317
3318rp="Any additional ld flags (NOT including libraries)?"
3319. ./myread
3320case "$ans" in
3321none) ldflags='';;
3322*) ldflags="$ans";;
3323esac
3324rmlist="$rmlist pdp11"
3325
3326: coherency check
3327echo " "
3328echo "Checking your choice of C compiler and flags for coherency..." >&4
3329$cat > try.c <<'EOF'
3330#include <stdio.h>
3331int main() { printf("Ok\n"); exit(0); }
3332EOF
3333set X $cc $optimize $ccflags -o try $ldflags try.c $libs
3334shift
3335$cat >try.msg <<'EOM'
3336I've tried to compile and run the following simple program:
3337
3338EOM
3339$cat try.c >> try.msg
3340
3341$cat >> try.msg <<EOM
3342
3343I used the command:
3344
3345 $*
3346 ./try
3347
3348and I got the following output:
3349
3350EOM
3351dflt=y
3352if 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'
3361If $libs contains -lsfio, and sfio is mis-configured, then it
3362sometimes (apparently) runs and exits with a 0 status, but with no
3363output! It may have to do with sfio's use of _exit vs. exit.
3364
3365EOQS
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
3377else
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
3381fi
3382case "$dflt" in
3383y)
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 3400n) echo "OK, that should do.";;
c4f23d77 3401esac
bd9b35c9 3402$rm -f try try.* core
c4f23d77 3403
bd9b35c9
JH
3404: define a shorthand compile call
3405compile='
3406mc_file=$1;
3407shift;
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.
3410compile_ok='
3411mc_file=$1;
3412shift;
3413$cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
8e07c86e 3414
bd9b35c9 3415echo " "
9c839522
PM
3416echo "Checking for GNU C Library..." >&4
3417cat >gnulibc.c <<EOM
bd9b35c9
JH
3418#include <stdio.h>
3419int main()
3420{
9c839522
PM
3421#ifdef __GLIBC__
3422 exit(0);
3423#else
3424 exit(1);
3425#endif
bd9b35c9 3426}
bd9b35c9 3427EOM
9c839522
PM
3428set gnulibc
3429if eval $compile_ok && ./gnulibc; then
3430 val="$define"
3431 echo "You are using the GNU C Library"
bd9b35c9 3432else
c1a7f87b
JH
3433 val="$undef"
3434 echo "You are not using the GNU C Library"
bd9b35c9 3435fi
c1a7f87b
JH
3436$rm -f gnulibc*
3437set d_gnulibc
3438eval $setvar
3439
3440: see if nm is to be used to determine whether a symbol is defined or not
3441case "$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 ;;
3477esac
3478$cat <<EOM
3479
c1a7f87b
JH
3480I can use $nm to extract the symbols from your C libraries. This
3481is a time consuming task which may generate huge output on the disk (up
3482to 3 megabytes) but that should make the symbols extraction faster. The
3483alternative is to skip the 'nm' extraction part and to compile a small
3484test program instead to determine whether each symbol is present. If
3485you have a fast C compiler and/or if your 'nm' output cannot be parsed,
3486this may be the best solution.
3487
3488You probably shouldn't let me use 'nm' if you are using the GNU C Library.
bd9b35c9
JH
3489
3490EOM
c1a7f87b
JH
3491rp="Shall I use $nm to extract C symbols from the libraries?"
3492. ./myread
3493case "$ans" in
3494[Nn]*) usenm=false;;
3495*) usenm=true;;
bd9b35c9 3496esac
bd9b35c9 3497
c1a7f87b
JH
3498runnm=$usenm
3499case "$reuseval" in
3500true) runnm=false;;
8e07c86e 3501esac
29209bc5 3502
c1a7f87b
JH
3503: nm options which may be necessary
3504case "$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;;
3516esac
bd9b35c9 3517
c1a7f87b
JH
3518: nm options which may be necessary for shared libraries but illegal
3519: for archive libraries. Thank you, Linux.
3520case "$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 ;;
3529esac
8e07c86e 3530
c1a7f87b
JH
3531case "$runnm" in
3532true)
3533: get list of predefined functions in a handy place
3534echo " "
3535case "$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 ;;
3541esac
c1a7f87b
JH
3542libnames='';
3543case "$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 ;;
3575esac
c1a7f87b
JH
3576xxx=normal
3577case "$libc" in
3578unknown)
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 3600esac
c1a7f87b
JH
3601if $test -r "$1"; then
3602 echo "Your (shared) C library seems to be in $1."
3603 libc="$1"
3604elif $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
3612elif $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."
3614elif $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."
3617elif $test -r /lib/libc$_a; then
3618 libc=/lib/libc$_a;
3619 echo "Your C library seems to be in $libc. You're normal."
3620else
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
3640fi
3641if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
3642 dflt="$libc"
3643 cat <<EOM
a4f3eea9 3644
c1a7f87b
JH
3645If the guess above is wrong (which it might be if you're using a strange
3646compiler, or your machine supports multiple models), you can override it here.
bd9b35c9
JH
3647
3648EOM
a4f3eea9 3649else
c1a7f87b
JH
3650 dflt=''
3651 echo $libpth | tr ' ' $trnl | sort | uniq > libpath
3652 cat >&4 <<EOM
3653I can't seem to find your C library. I've looked in the following places:
a4f3eea9 3654
c1a7f87b
JH
3655EOM
3656 $sed 's/^/ /' libpath
3657 cat <<EOM
29209bc5 3658
c1a7f87b 3659None of these seems to contain your C library. I need to get its name...
a4f3eea9 3660
bd9b35c9 3661EOM
bd9b35c9 3662fi
c1a7f87b
JH
3663fn=f
3664rp='Where is your C library?'
3665. ./getfile
3666libc="$ans"
a4f3eea9 3667
c1a7f87b
JH
3668echo " "
3669echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
3670set X `cat libnames`
3671shift
3672xxx=files
3673case $# in 1) xxx=file; esac
3674echo "Extracting names from the following $xxx for later perusal:" >&4
3675echo " "
3676$sed 's/^/ /' libnames >&4
3677echo " "
3678$echo $n "This may take a while...$c" >&4
a4f3eea9 3679
c1a7f87b
JH
3680for 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 3685done >libc.tmp
a4f3eea9 3686
c1a7f87b
JH
3687$echo $n ".$c"
3688$grep fprintf libc.tmp > libc.ptf
3689xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
3690xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
3691xxx='[ADTSIW]'
3692if 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
3696elif 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
3700elif 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
3704elif 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
3708elif 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
3712elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
3713 eval $xscan;\
3714 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
3715 eval $xrun
3716elif 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
3721elif 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
3725elif 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
3729elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
3730 eval $xscan;\
3731 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
3732 eval $xrun
3733elif 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
3737elif 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
3741elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
3742 eval $xscan;\
3743 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
3744 eval $xrun
3745elif 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
3749else
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 3799fi
c1a7f87b
JH
3800nm_extract="$com"
3801if $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
3805fi
3806;;
3807esac
3808$rm -f libnames libpath
bd9b35c9 3809
c1a7f87b
JH
3810: is a C symbol defined?
3811csym='tlook=$1;
3812case "$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="()";;
3816esac;
3817tx=yes;
3818case "$reuseval-$4" in
3819true-) ;;
3820true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
3821esac;
3822case "$tx" in
3823yes)
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;;
3843esac;
3844eval "$2=$tval"'
bd9b35c9 3845
c1a7f87b
JH
3846: define an is-in-libc? function
3847inlibc='echo " "; td=$define; tu=$undef;
3848sym=$1; var=$2; eval "was=\$$2";
3849tx=yes;
3850case "$reuseval$was" in
3851true) ;;
3852true*) tx=no;;
3853esac;
3854case "$tx" in
3855yes)
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;;
3871esac'
3872
9c839522
PM
3873: see if dlopen exists
3874xxx_runnm="$runnm"
3875runnm=false
3876set dlopen d_dlopen
c1a7f87b 3877eval $inlibc
9c839522 3878runnm="$xxx_runnm"
c1a7f87b 3879
9c839522
PM
3880: determine which dynamic loading, if any, to compile in
3881echo " "
3882dldir="ext/DynaLoader"
3883case "$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 3903esac
9c839522 3904rp="Do you wish to use dynamic loading?"
c1a7f87b 3905. ./myread
9c839522 3906usedl="$ans"
c1a7f87b 3907case "$ans" in
9c839522
PM
3908y*) 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
3937Some systems may require passing special flags to $cc -c to
3938compile modules that will be used to create a shared library.
3939To use no flags, say "none".
bfb7748a 3940
c1a7f87b 3941EOM
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
3970Some systems use ld to create libraries that can be dynamically loaded,
3971while other systems (such as those using ELF) use $cc.
5f80c64f 3972
9c839522
PM
3973EOM
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>
3979int 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}
3989EOM
3990 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
3991 cat <<EOM
3992You appear to have ELF support. I'll use $cc to build dynamic libraries.
3993EOM
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
4011Some systems may require passing special flags to $ld to create a
4012library that can be dynamically loaded. If your ld flags include
4013-L/other/path options to locate libraries outside your loader's normal
4014search path, you may need to specify those -L options here as well. To
4015use no flags, say "none".
5f80c64f
JH
4016
4017EOM
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=' ' ;;
4061 *) lddlflags="$ans" ;;
4062 esac
4063
4064 cat <<EOM
4065
4066Some systems may require passing special flags to $cc to indicate that
4067the resulting executable will use dynamic linking. To use no flags,
4068say "none".
5f80c64f
JH
4069
4070EOM
9c839522
PM
4071 case "$ccdlflags" in
4072 '') case "$osname" in
4073 hpux) dflt='-Wl,-E' ;;
4074 linux) dflt='-rdynamic' ;;
4075 next) dflt='none' ;;
4076 sunos) dflt='none' ;;
4077 *) dflt='none' ;;
4078 esac ;;
4079 ' ') dflt='none' ;;
4080 *) dflt="$ccdlflags" ;;
4081 esac
4082 rp="Any special flags to pass to $cc to use dynamic linking?"
4083 . ./myread
4084 case "$ans" in
4085 none) ccdlflags=' ' ;;
4086 *) ccdlflags="$ans" ;;
4087 esac
4088 ;;
4089*) usedl="$undef"
4090 ld='ld'
4091 dlsrc='dl_none.xs'
4092 lddlflags=''
4093 ccdlflags=''
4094 ;;
5f80c64f
JH
4095esac
4096
9c839522
PM
4097: Remove libraries needed only for extensions
4098: The appropriate ext/Foo/Makefile.PL will add them back in, if necessary.
4099case "$usedl" in
4100$define|true|[yY]*)
4101 set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
4102 shift
4103 perllibs="$*"
4104 ;;
4105*) perllibs="$libs"
4106 ;;
4107esac
5f80c64f
JH
4108
4109: Remove build directory name from cppstdin so it can be used from
4110: either the present location or the final installed location.
4111echo " "
4112: Get out of the UU directory to get correct path name.
4113cd ..
4114case "$cppstdin" in
4115`pwd`/cppstdin)
4116 echo "Stripping down cppstdin path name"
4117 cppstdin=cppstdin
4118 ;;
4119esac
4120cd UU
4121
4122: end of configuration questions
4123echo " "
4124echo "End of configuration questions."
4125echo " "
4126
4127: back to where it started
4128if test -d ../UU; then
4129 cd ..
4130fi
4131
4132: configuration may be patched via a 'config.over' file
4133if $test -f config.over; then
4134 echo " "
4135 dflt=y
4136 rp='I see a config.over file. Do you wish to load it?'
4137 . UU/myread
4138 case "$ans" in
4139 n*) echo "OK, I'll ignore it.";;
4140 *) . ./config.over
4141 echo "Configuration override changes have been loaded."
4142 ;;
4143 esac
4144fi
4145
4146: in case they want portability, strip down executable paths
4147case "$d_portable" in
4148"$define")
4149 echo " "
4150 echo "Stripping down executable paths..." >&4
4151 for file in $loclist $trylist; do
534ac15a
JH
4152 eval temp=\$$file
4153 eval $file=`basename $temp`
5f80c64f
JH
4154 done
4155 ;;
4156esac
4157
4158: create config.sh file
4159echo " "
4160echo "Creating config.sh..." >&4
4161$spitshell <<EOT >config.sh
4162$startsh
4163#
4164# This file was produced by running the Configure script. It holds all the
4165# definitions figured out by Configure. Should you modify one of these values,
4166# do not forget to propagate your changes by running "Configure -der". You may
4167# instead choose to run each of the .SH files by yourself, or "Configure -S".
4168#
4169
4170# Package name : $package
4171# Source directory : $src
4172# Configuration time: $cf_time
4173# Configured by : $cf_by
4174# Target system : $myuname
4175
4176Author='$Author'
4177Date='$Date'
4178Header='$Header'
4179Id='$Id'
4180Locker='$Locker'
4181Log='$Log'
4182Mcc='$Mcc'
4183RCSfile='$RCSfile'
4184Revision='$Revision'
4185Source='$Source'
4186State='$State'
4187_a='$_a'
4188_exe='$_exe'
4189_o='$_o'
5f80c64f 4190ar='$ar'
5f80c64f
JH
4191archobjs='$archobjs'
4192awk='$awk'
5f80c64f 4193bash='$bash'
5f80c64f
JH
4194bison='$bison'
4195byacc='$byacc'
5f80c64f 4196c='$c'
5f80c64f
JH
4197cat='$cat'
4198cc='$cc'
4199cccdlflags='$cccdlflags'
4200ccdlflags='$ccdlflags'
4201ccflags='$ccflags'
e723fc21 4202ccname='$ccname'
6b356c8e 4203ccversion='$ccversion'
5f80c64f 4204cf_by='$cf_by'
5f80c64f
JH
4205cf_time='$cf_time'
4206chgrp='$chgrp'
4207chmod='$chmod'
4208chown='$chown'
5f80c64f
JH
4209comm='$comm'
4210compress='$compress'
4211contains='$contains'
4212cp='$cp'
4213cpio='$cpio'
4214cpp='$cpp'
5f80c64f
JH
4215cppflags='$cppflags'
4216cpplast='$cpplast'
4217cppminus='$cppminus'
4218cpprun='$cpprun'
4219cppstdin='$cppstdin'
5f80c64f 4220csh='$csh'
5f80c64f 4221d_bsd='$d_bsd'
5f80c64f 4222d_dlopen='$d_dlopen'
5f80c64f 4223d_eunice='$d_eunice'
5f80c64f 4224d_gnulibc='$d_gnulibc'
5f80c64f 4225d_portable='$d_portable'
5f80c64f
JH
4226d_xenix='$d_xenix'
4227date='$date'
5f80c64f 4228dlsrc='$dlsrc'
5f80c64f
JH
4229echo='$echo'
4230egrep='$egrep'
4231emacs='$emacs'
4232eunicefix='$eunicefix'
4233exe_ext='$exe_ext'
4234expr='$expr'
5f80c64f
JH
4235find='$find'
4236firstmakefile='$firstmakefile'
4237flex='$flex'
5b463ca7 4238gccosandvers='$gccosandvers'
5f80c64f 4239gccversion='$gccversion'
5f80c64f
JH
4240glibpth='$glibpth'
4241grep='$grep'
5f80c64f 4242gzip='$gzip'
5f80c64f 4243hint='$hint'
5f80c64f 4244i_dld='$i_dld'
5f80c64f
JH
4245ignore_versioned_solibs='$ignore_versioned_solibs'
4246incpath='$incpath'
4247inews='$inews'
5f80c64f 4248ksh='$ksh'
5f80c64f
JH
4249ld='$ld'
4250lddlflags='$lddlflags'
4251ldflags='$ldflags'
4252less='$less'
4253lib_ext='$lib_ext'
4254libc='$libc'
5f80c64f
JH
4255libpth='$libpth'
4256libs='$libs'
43999f95
JH
4257libsdirs='$libsdirs'
4258libsfiles='$libsfiles'
4259libsfound='$libsfound'
13b3f787 4260libspath='$libspath'
5f80c64f
JH
4261libswanted='$libswanted'
4262line='$line'
4263lint='$lint'
4264lkflags='$lkflags'
4265ln='$ln'
4266lns='$lns'
4267locincpth='$locincpth'
4268loclibpth='$loclibpth'
5f80c64f
JH
4269lp='$lp'
4270lpr='$lpr'
4271ls='$ls'
5f80c64f
JH
4272mail='$mail'
4273mailx='$mailx'
4274make='$make'
4275make_set_make='$make_set_make'
5f80c64f
JH
4276mips_type='$mips_type'
4277mkdir='$mkdir'
5f80c64f
JH
4278more='$more'
4279mv='$mv'
5f80c64f
JH
4280myuname='$myuname'
4281n='$n'
5f80c64f
JH
4282nm='$nm'
4283nm_opt='$nm_opt'
4284nm_so_opt='$nm_so_opt'
5f80c64f 4285nroff='$nroff'
5f80c64f
JH
4286obj_ext='$obj_ext'
4287optimize='$optimize'
5f80c64f
JH
4288osname='$osname'
4289osvers='$osvers'
4290package='$package'
5f80c64f
JH
4291path_sep='$path_sep'
4292perl='$perl'
9c839522 4293perllibs='$perllibs'
5f80c64f 4294pg='$pg'
5f80c64f
JH
4295plibpth='$plibpth'
4296pmake='$pmake'
4297pr='$pr'
5f80c64f
JH
4298rm='$rm'
4299rmail='$rmail'
4300runnm='$runnm'
5f80c64f 4301sed='$sed'
5f80c64f
JH
4302sendmail='$sendmail'
4303sh='$sh'
4304shar='$shar'
4305sharpbang='$sharpbang'
5f80c64f 4306shsharp='$shsharp'
5f80c64f
JH
4307sleep='$sleep'
4308smail='$smail'
5f80c64f 4309so='$so'
5f80c64f
JH
4310sort='$sort'
4311spackage='$spackage'
4312spitshell='$spitshell'
5f80c64f 4313src='$src'
5f80c64f 4314startsh='$startsh'
5f80c64f 4315submit='$submit'
5f80c64f
JH
4316tail='$tail'
4317tar='$tar'
4318tbl='$tbl'
4319tee='$tee'
4320test='$test'
5f80c64f
JH
4321touch='$touch'
4322tr='$tr'
4323trnl='$trnl'
4324troff='$troff'
5f80c64f
JH
4325uname='$uname'
4326uniq='$uniq'
5f80c64f 4327usedl='$usedl'
5f80c64f 4328usenm='$usenm'
29209bc5 4329usesocks='$usesocks'
5f80c64f
JH
4330usrinc='$usrinc'
4331uuname='$uuname'
5f80c64f 4332vi='$vi'
5f80c64f
JH
4333xlibpth='$xlibpth'
4334zcat='$zcat'
4335zip='$zip'
4336EOT
4337
4338: Add in command line options if available
4339$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
4340
4341: add special variables
4342$test -f $src/patchlevel.h && \
d00b958f 4343awk '/^#define[ ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
2000072c 4344echo "CONFIGDOTSH=true" >>config.sh
5f80c64f
JH
4345
4346: propagate old symbols
4347if $test -f UU/config.sh; then
4348 <UU/config.sh sort | uniq >UU/oldconfig.sh
4349 sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
4350 sort | uniq -u >UU/oldsyms
4351 set X `cat UU/oldsyms`
4352 shift
4353 case $# in
4354 0) ;;
4355 *)
4356 cat <<EOM
4357Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
4358EOM
4359 echo "# Variables propagated from previous config.sh file." >>config.sh
4360 for sym in `cat UU/oldsyms`; do
4361 echo " Propagating $hint variable "'$'"$sym..."
4362 eval 'tmp="$'"${sym}"'"'
4363 echo "$tmp" | \
4364 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
4365 done
4366 ;;
4367 esac
4368fi
4369
9c839522
PM
4370: preserve RCS keywords in files with variable substitution, grrr
4371Id='$Id'
4372
5f80c64f
JH
4373: Finish up by extracting the .SH files
4374case "$alldone" in
4375exit)
4376 $rm -rf UU
4377 echo "Done."
4378 exit 0
4379 ;;
4380cont)
4381 ;;
4382'')
4383 dflt=''
4384 nostick=true
4385 $cat <<EOM
4386
4387If you'd like to make any changes to the config.sh file before I begin
4388to configure things, do it as a shell escape now (e.g. !vi config.sh).
4389
4390EOM
4391 rp="Press return or use a shell escape to edit config.sh:"
4392 . UU/myread
4393 nostick=''
4394 case "$ans" in
4395 '') ;;
4396 *) : in case they cannot read
4397 sh 1>&4 -c "$ans";;
4398 esac
4399 ;;
4400esac
4401
4402: if this fails, just run all the .SH files by hand
4403. ./config.sh
4404
4405echo " "
4406exec 1>&4
4407. ./UU/extract
4408
4409if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
4410 dflt=y
4411 case "$silent" in
4412 true) ;;
4413 *)
4414 $cat <<EOM
4415
4416Now you need to generate make dependencies by running "$make depend".
4417You might prefer to run it in background: "$make depend > makedepend.out &"
4418It can take a while, so you might not want to run it right now.
4419
4420EOM
4421 ;;
4422 esac
4423 rp="Run $make depend now?"
4424 . UU/myread
4425 case "$ans" in
4426 y*)
3d5d58b1 4427 $make depend && echo "Now you must run '$make'."
5f80c64f
JH
4428 ;;
4429 *)
4430 echo "You must run '$make depend' then '$make'."
4431 ;;
4432 esac
4433elif test -f [Mm]akefile; then
4434 echo " "
4435 echo "Now you must run a $make."
4436else
4437 echo "Done."
4438fi
4439
4440if $test -f Policy.sh; then
4441 $cat <<EOM
4442
4443If you compile $package on a different machine or from a different object
4444directory, copy the Policy.sh file from this object directory to the
4445new one before you run Configure -- this will help you with most of
4446the policy defaults.
4447
4448EOM
4449fi
4450if $test -f config.msg; then
4451 echo "Hmm. I also noted the following information while running:"
4452 echo " "
4453 $cat config.msg >&4
4454 $rm -f config.msg
4455fi
4456$rm -f kit*isdone ark*isdone
4457$rm -rf UU
4458
4459: End of Configure
4460