bfa8fb3a88418ed598646a217b66749322890030
[p5sagit/p5-mst-13.2.git] / Configure
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
17 # comp.sources.misc so you may fetch it yourself from your nearest
18 # archive site. Check with Archie if you don't know where that can be.)
19 #
20
21 # $Id: Head.U,v 3.0.1.3 1993/12/15 08:15:07 ram Exp $
22 #
23 # Generated on Sat Apr  2 17:29:14 EST 1994 [metaconfig 3.0 PL22]
24
25 cat >/tmp/c1$$ <<EOF
26 ARGGGHHHH!!!!!
27
28 SCO csh still thinks true is false.  Write to SCO today and tell them that next
29 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
30
31 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
32 we'd have to do is go in and swap the && and || tokens, wherever they are.)
33
34 [End of diatribe. We now return you to your regularly scheduled programming...]
35 EOF
36 cat >/tmp/c2$$ <<EOF
37
38 OOPS!  You naughty creature!  You didn't run Configure with sh!
39 I will attempt to remedy the situation by running sh for you...
40 EOF
41
42 true || cat /tmp/c1$$ /tmp/c2$$
43 true || exec sh $0 $argv:q
44
45 (exit $?0) || cat /tmp/c2$$
46 (exit $?0) || exec sh $0 $argv:q
47 rm -f /tmp/c1$$ /tmp/c2$$
48
49 : Sanity checks
50 PATH=".:$PATH:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin"
51 PATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
52 PATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin:/bsd4.3/bin:/bsd4.3/usr/ucb'
53 PATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd:/bsd43/bin:/usr/ccs/bin'
54 PATH=$PATH:'/etc:/usr/lib:/usr/ucblib:/lib:/usr/ccs/lib'
55 PATH=$PATH:'/sbin:/usr/sbin:/usr/libexec'
56 export PATH
57
58 if test ! -t 0; then
59         echo "Say 'sh Configure', not 'sh <Configure'"
60         exit 1
61 fi
62
63 : On HP-UX, large Configure scripts may exercise a bug in /bin/sh
64 if test -f /hp-ux -a -f /bin/ksh; then
65         if (PATH=.; alias -x) >/dev/null 2>&1; then
66                 : already under /bin/ksh
67         else
68                 cat <<'EOM'
69 (Feeding myself to ksh to avoid nasty sh bug in "here document" expansion.)
70 EOM
71                 exec /bin/ksh $0 "$@"
72         fi
73 else
74         : Warn them if they use ksh on other systems
75         (PATH=.; alias -x) >/dev/null 2>&1 && \
76                 cat <<'EOM'
77 (I see you are using the Korn shell.  Some ksh's blow up on Configure,
78 especially on exotic machines.  If yours does, try the Bourne shell instead.)
79 EOM
80 fi
81
82 : Configure runs within the UU subdirectory
83 test -d UU || mkdir UU
84 cd UU && rm -f *
85
86 extensions=''
87 d_bsd=''
88 d_eunice=''
89 d_xenix=''
90 eunicefix=''
91 Mcc=''
92 awk=''
93 bash=''
94 bison=''
95 byacc=''
96 cat=''
97 chgrp=''
98 chmod=''
99 chown=''
100 compress=''
101 cp=''
102 cpio=''
103 cpp=''
104 csh=''
105 date=''
106 echo=''
107 egrep=''
108 emacs=''
109 expr=''
110 find=''
111 flex=''
112 gcc=''
113 grep=''
114 inews=''
115 ksh=''
116 less=''
117 line=''
118 lint=''
119 ln=''
120 lp=''
121 lpr=''
122 ls=''
123 mail=''
124 mailx=''
125 make=''
126 mkdir=''
127 more=''
128 mv=''
129 nroff=''
130 perl=''
131 pg=''
132 pmake=''
133 pr=''
134 rm=''
135 rmail=''
136 sed=''
137 sendmail=''
138 sh=''
139 shar=''
140 sleep=''
141 smail=''
142 sort=''
143 submit=''
144 tail=''
145 tar=''
146 tbl=''
147 test=''
148 touch=''
149 tr=''
150 troff=''
151 uname=''
152 uniq=''
153 uuname=''
154 vi=''
155 zcat=''
156 hint=''
157 myuname=''
158 Author=''
159 Date=''
160 Header=''
161 Id=''
162 Locker=''
163 Log=''
164 RCSfile=''
165 Revision=''
166 Source=''
167 State=''
168 afs=''
169 alignbytes=''
170 bin=''
171 binexp=''
172 installbin=''
173 byteorder=''
174 cc=''
175 gccversion=''
176 ccflags=''
177 cppflags=''
178 ldflags=''
179 lkflags=''
180 optimize=''
181 cf_by=''
182 cf_time=''
183 contains=''
184 cpplast=''
185 cppminus=''
186 cpprun=''
187 cppstdin=''
188 d_access=''
189 d_bcmp=''
190 d_bcopy=''
191 d_bzero=''
192 d_casti32=''
193 castflags=''
194 d_castneg=''
195 d_charsprf=''
196 d_chsize=''
197 d_const=''
198 cryptlib=''
199 d_crypt=''
200 d_csh=''
201 d_dosuid=''
202 d_dup2=''
203 d_fchmod=''
204 d_fchown=''
205 d_fcntl=''
206 d_flexfnam=''
207 d_flock=''
208 d_getgrps=''
209 d_gethent=''
210 aphostname=''
211 d_gethname=''
212 d_phostname=''
213 d_uname=''
214 d_getpgrp2=''
215 d_getpgrp=''
216 d_getprior=''
217 d_htonl=''
218 d_isascii=''
219 d_killpg=''
220 d_link=''
221 d_lstat=''
222 d_memcmp=''
223 d_memcpy=''
224 d_memmove=''
225 d_memset=''
226 d_mkdir=''
227 d_msg=''
228 d_msgctl=''
229 d_msgget=''
230 d_msgrcv=''
231 d_msgsnd=''
232 d_open3=''
233 d_portable=''
234 d_readdir=''
235 d_rename=''
236 d_rmdir=''
237 d_safebcpy=''
238 d_safemcpy=''
239 d_select=''
240 d_sem=''
241 d_semctl=''
242 d_semget=''
243 d_semop=''
244 d_setegid=''
245 d_seteuid=''
246 d_setlocale=''
247 d_setpgid=''
248 d_setpgrp2=''
249 d_bsdpgrp=''
250 d_setpgrp=''
251 d_setprior=''
252 d_setregid=''
253 d_setresgid=''
254 d_setresuid=''
255 d_setreuid=''
256 d_setrgid=''
257 d_setruid=''
258 d_setsid=''
259 d_shm=''
260 d_shmat=''
261 d_shmctl=''
262 d_shmdt=''
263 d_shmget=''
264 d_oldsock=''
265 d_socket=''
266 d_sockpair=''
267 sockethdr=''
268 socketlib=''
269 d_statblks=''
270 d_stdstdio=''
271 d_index=''
272 d_strchr=''
273 d_strctcpy=''
274 d_strerrm=''
275 d_strerror=''
276 d_sysernlst=''
277 d_syserrlst=''
278 d_symlink=''
279 d_syscall=''
280 d_system=''
281 clocktype=''
282 d_times=''
283 d_truncate=''
284 d_usendir=''
285 i_ndir=''
286 ndirc=''
287 ndirlib=''
288 ndiro=''
289 d_vfork=''
290 d_voidsig=''
291 signal_t=''
292 d_volatile=''
293 d_charvspr=''
294 d_vprintf=''
295 d_wait4=''
296 d_waitpid=''
297 dlobj=''
298 dlsrc=''
299 usedl=''
300 gidtype=''
301 groupstype=''
302 h_fcntl=''
303 h_sysfile=''
304 i_dbm=''
305 d_dirnamlen=''
306 i_dirent=''
307 i_dlfcn=''
308 i_fcntl=''
309 i_gdbm=''
310 i_grp=''
311 i_ndbm=''
312 i_niin=''
313 i_sysin=''
314 d_pwage=''
315 d_pwchange=''
316 d_pwclass=''
317 d_pwcomment=''
318 d_pwexpire=''
319 d_pwquota=''
320 i_pwd=''
321 i_stdarg=''
322 i_stddef=''
323 i_string=''
324 strings=''
325 i_sysdir=''
326 i_sysfile=''
327 d_voidtty=''
328 i_bsdioctl=''
329 i_sysioctl=''
330 i_syssockio=''
331 i_sysndir=''
332 i_sysselct=''
333 i_sgtty=''
334 i_termio=''
335 i_termios=''
336 i_systime=''
337 i_systimek=''
338 i_time=''
339 timeincl=''
340 i_utime=''
341 i_varargs=''
342 i_varhdr=''
343 i_vfork=''
344 intsize=''
345 lib=''
346 libexp=''
347 libc=''
348 libpth=''
349 plibpth=''
350 xlibpth=''
351 libs=''
352 mallocobj=''
353 mallocsrc=''
354 malloctype=''
355 usemymalloc=''
356 installmansrc=''
357 manext=''
358 mansrc=''
359 mansrcexp=''
360 huge=''
361 large=''
362 medium=''
363 models=''
364 small=''
365 split=''
366 mydomain=''
367 myhostname=''
368 phostname=''
369 c=''
370 n=''
371 groupcat=''
372 hostcat=''
373 passcat=''
374 package=''
375 spackage=''
376 installprivlib=''
377 privlib=''
378 privlibexp=''
379 prototype=''
380 randbits=''
381 installscript=''
382 scriptdir=''
383 scriptdirexp=''
384 sig_name=''
385 sharpbang=''
386 shsharp=''
387 spitshell=''
388 startsh=''
389 stdchar=''
390 sysman=''
391 uidtype=''
392 nm_opt=''
393 runnm=''
394 usenm=''
395 incpath=''
396 mips=''
397 mips_type=''
398 usrinc=''
399 defvoidused=''
400 voidflags=''
401 yacc=''
402 yaccflags=''
403 CONFIG=''
404
405 : script used to extract .SH files with variable substitutions
406 cat >extract <<'EOS'
407 CONFIG=true
408 echo "Doing variable substitutions on .SH files..."
409 if test -f MANIFEST; then
410         set x `awk '{print $1}' <MANIFEST | grep '\.SH'`
411 else
412         echo "(Looking for .SH files under the current directory.)"
413         set x `find . -name "*.SH" -print`
414 fi
415 shift
416 case $# in
417 0) set x *.SH; shift;;
418 esac
419 if test ! -f $1; then
420         shift
421 fi
422 for file in $*; do
423         case "$file" in
424         */*)
425                 dir=`expr X$file : 'X\(.*\)/'`
426                 file=`expr X$file : 'X.*/\(.*\)'`
427                 (cd $dir && . ./$file)
428                 ;;
429         *)
430                 . ./$file
431                 ;;
432         esac
433 done
434 if test -f config_h.SH; then
435         if test ! -f config.h; then
436         : oops, they left it out of MANIFEST, probably, so do it anyway.
437         . ./config_h.SH
438         fi
439 fi
440 EOS
441
442 : produce awk script to parse command line options
443 cat >options.awk <<'EOF'
444 BEGIN {
445         optstr = "deEf:hrsSV";  # getopt-style specification
446
447         len = length(optstr);
448         for (i = 1; i <= len; i++) {
449                 c = substr(optstr, i, 1);
450                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
451                 if (a == ":") {
452                         arg[c] = 1;
453                         i++;
454                 }
455                 opt[c] = 1;
456         }
457 }
458 {
459         expect = 0;
460         str = $0;
461         if (substr(str, 1, 1) != "-") {
462                 printf("'%s'\n", str);
463                 next;
464         }
465         len = length($0);
466         for (i = 2; i <= len; i++) {
467                 c = substr(str, i, 1);
468                 if (!opt[c]) {
469                         printf("-%s\n", substr(str, i));
470                         next;
471                 }
472                 printf("-%s\n", c);
473                 if (arg[c]) {
474                         if (i < len)
475                                 printf("'%s'\n", substr(str, i + 1));
476                         else
477                                 expect = 1;
478                         next;
479                 }
480         }
481 }
482 END {
483         if (expect)
484                 print "?";
485 }
486 EOF
487
488 : process the command line options
489 set X `for arg in "$@"; do echo $arg; done | awk -f options.awk`
490 eval "set $*"
491 shift
492 rm -f options.awk
493
494 : set up default values
495 fastread=''
496 reuseval=false
497 config_sh=''
498 alldone=''
499 error=''
500 silent=''
501 extractsh=''
502
503 : option parsing
504 while test $# -gt 0; do
505         case "$1" in
506         -d) shift; fastread=yes;;
507         -e) shift; alldone=cont;;
508         -f)
509                 shift
510                 cd ..
511                 if test -r "$1"; then
512                         config_sh="$1"
513                 else
514                         echo "Configure: cannot read config file $1." >&2
515                         error=true
516                 fi
517                 cd UU
518                 shift;;
519         -h) shift; error=true;;
520         -r) shift; reuseval=true;;
521         -s) shift; silent=true;;
522         -E) shift; alldone=exit;;
523         -S) shift; extractsh=true;;
524         -V) echo "Configure generated by metaconfig 3.0 PL22." >&2
525                 exit 0;;
526         --) break;;
527         -*) echo "Configure: unknown option $1" >&2; shift; error=true;;
528         *) break;;
529         esac
530 done
531
532 case "$error" in
533 true)
534         cat >&2 <<EOM
535 Usage: Configure [-dehrESV] [-f config.sh]
536   -d : use defaults for all answers.
537   -e : go on without questioning past the production of config.sh.
538   -f : specify an alternate default configuration file.
539   -h : print this help message and exit (with an error status).
540   -r : reuse C symbols value if possible (skips costly nm extraction).
541   -s : silent mode, only echoes questions and essential information.
542   -E : stop at the end of questions, after having produced config.sh.
543   -S : perform variable substitutions on all .SH files (can mix with -f)
544   -V : print version number and exit (with a zero status).
545 EOM
546         exit 1
547         ;;
548 esac
549
550 exec 4>&1
551 case "$silent" in
552 true) exec 1>/dev/null;;
553 esac
554
555 case "$extractsh" in
556 true)
557         case "$config_sh" in
558         '') config_sh='config.sh'; config='./config.sh';;
559         /*) config="$config_sh";;
560         *) config="./$config_sh";;
561         esac
562         echo " "
563         echo "Fetching answers from $config_sh..."
564         cd ..
565         . $config
566         echo " "
567         . ./UU/extract
568         rm -rf UU
569         echo "Done."
570         exit 0
571         ;;
572 esac
573
574 : set package name
575 package=perl
576
577 : Eunice requires " " instead of "", can you believe it
578 echo " "
579 : Here we go...
580 echo "Beginning of configuration questions for $package."
581
582 define='define'
583 undef='undef'
584 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
585 rmlist=''
586
587 trap 'echo " "; rm -rf $rmlist; exit 1' 1 2 3 15
588
589 : We must find out about Eunice early
590 eunicefix=':'
591 if test -f /etc/unixtovms; then
592         eunicefix=/etc/unixtovms
593 fi
594 if test -f /etc/unixtovms.exe; then
595         eunicefix=/etc/unixtovms.exe
596 fi
597
598 : list of known cpp symbols
599 attrlist="__alpha __bsdi__ BSD_NET2 DGUX M_I186 M_I286 M_I386"
600 attrlist="$attrlist M_I8086 M_XENIX UTS __DGUX__"
601 attrlist="$attrlist _AIX __STDC__ __m88k__ ansi bsd4_2 gcos gimpel"
602 attrlist="$attrlist hp9000s300 hp9000s400 hp9000s500 hp9000s700"
603 attrlist="$attrlist hp9000s800 hpux"
604 attrlist="$attrlist i186 i386 i486 i8086 iAPX286 ibm interdata"
605 attrlist="$attrlist m88k mc300 mc500 mc68000 mc68k mc700 mert"
606 attrlist="$attrlist mips NeXT ns16000 ns32000 nsc32000 os"
607 attrlist="$attrlist __osf__ pdp11 posix"
608 attrlist="$attrlist pyr sinix sony sparc sun tower tower32 tower32_600"
609 attrlist="$attrlist tower32_800 tss u3b2 u3b20 u3b200 u3b5 ultrix unix"
610 attrlist="$attrlist __unix__ vax venix xenix z8000"
611
612 i_whoami=''
613 : List of extensions we want:
614 extensions=''
615 gccversion=''
616 : no include file wanted by default
617 inclwanted=''
618
619  usedl=''
620 groupstype=''
621 : change the next line if compiling for Xenix/286 on Xenix/386
622 xlibpth='/usr/lib/386 /lib/386'
623
624 : general looking path for locating libraries
625 libpth="/usr/lib/large /lib /usr/lib $xlibpth /lib/large"
626 libpth="$libpth /usr/lib/small /lib/small"
627 libpth="$libpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
628
629 : Private path used by Configure to find libraries.  Its value
630 : is prepend to libpth. This variable takes care of special
631 : machines, like the mips.  Usually, it should be empty.
632 plibpth=''
633
634 libswanted="net socket nsl inet nm sdbm gdbm ndbm dbm malloc dl dld sun m c_s posix cposix ndir dir ucb bsd BSD PW x"
635
636 : full support for void wanted by default
637 defvoidused=15
638
639
640 : Some greps do not return status, grrr.
641 echo "grimblepritz" >grimble
642 if grep blurfldyick grimble >/dev/null 2>&1 ; then
643         contains=contains
644 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
645         contains=grep
646 else
647         contains=contains
648 fi
649 rm -f grimble
650 : the following should work in any shell
651 case "$contains" in
652 contains*)
653         echo " "
654         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
655         cat >contains <<'EOSS'
656 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
657 EOSS
658 chmod +x contains
659 esac
660
661 : first determine how to suppress newline on echo command
662 echo " "
663 echo "Checking echo to see how to suppress newlines..."
664 (echo "hi there\c" ; echo " ") >.echotmp
665 if $contains c .echotmp >/dev/null 2>&1 ; then
666         echo "...using -n."
667         n='-n'
668         c=''
669 else
670         cat <<'EOM'
671 ...using \c
672 EOM
673         n=''
674         c='\c'
675 fi
676 echo $n "The star should be here-->$c"
677 echo '*'
678 rm -f .echotmp
679
680 : Now test for existence of everything in MANIFEST
681 echo " "
682 if test -f ../MANIFEST; then
683         echo "First let's make sure your kit is complete.  Checking..." >&4
684         awk '$1 !~ /PACK[A-Z]+/ {print $1}' ../MANIFEST | split -50
685         rm -f missing
686         for filelist in x??; do
687                 (cd ..; ls `cat UU/$filelist` >/dev/null 2>>UU/missing)
688         done
689         if test -s missing; then
690                 cat missing >&4
691                 cat >&4 <<'EOM'
692
693 THIS PACKAGE SEEMS TO BE INCOMPLETE.
694
695 You have the option of continuing the configuration process, despite the
696 distinct possibility that your kit is damaged, by typing 'y'es.  If you
697 do, don't blame me if something goes wrong.  I advise you to type 'n'o
698 and contact the author (lwall@netlabs.com).
699
700 EOM
701                 echo $n "Continue? [n] $c" >&4
702                 read ans
703                 case "$ans" in
704                 y*)
705                         echo "Continuing..." >&4
706                         rm -f missing
707                         ;;
708                 *)
709                         echo "ABORTING..." >&4
710                         kill $$
711                         ;;
712                 esac
713         else
714                 echo "Looks good..." >&4
715         fi
716 else
717         echo "There is no MANIFEST file.  I hope your kit is complete !"
718 fi
719 rm -f missing x??
720
721 : compute the number of columns on the terminal for proper question formatting
722 case "$COLUMNS" in
723 '') COLUMNS='80';;
724 esac
725
726 : set up the echo used in my read
727 myecho="case \"\$xxxm\" in
728 '') echo $n \"\$rp $c\" >&4;;
729 *) case \"\$rp\" in
730         '') echo $n \"[\$xxxm] $c\";;
731         *)
732                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
733                         echo \"\$rp\" >&4
734                         echo $n \"[\$xxxm] $c\" >&4
735                 else
736                         echo $n \"\$rp [\$xxxm] $c\" >&4
737                 fi
738                 ;;
739         esac;;
740 esac"
741
742 : now set up to do reads with possible shell escape and default assignment
743 cat <<EOSC >myread
744 xxxm=\$dflt
745 $myecho
746 ans='!'
747 case "\$fastread" in
748 yes) case "\$dflt" in
749         '') ;;
750         *) ans='';
751                 case "\$silent-\$rp" in
752                 true-) ;;
753                 *) echo " " >&4;;
754                 esac;;
755         esac;;
756 *) case "\$silent" in
757         true) case "\$rp" in
758                 '') ans='';;
759                 esac;;
760         esac;;
761 esac
762 while expr "X\$ans" : "X!" >/dev/null; do
763         read answ
764         set x \$xxxm
765         shift
766         aok=''; eval "ans=\"\$answ\"" && aok=y
767         case  "\$answ" in
768         "\$ans")
769                 case "\$ans" in
770                 "!")
771                         sh 1>&4
772                         echo " "
773                         $myecho
774                         ;;
775                 !*)
776                         set x \`expr "X\$ans" : "X!\(.*\)\$"\`
777                         shift
778                         sh 1>&4 -c "\$*"
779                         echo " "
780                         $myecho
781                         ;;
782                 esac;;
783         *)
784                 case "\$aok" in
785                 y)
786                         echo "*** Substitution done -- please confirm."
787                         xxxm="\$ans"
788                         ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
789                         xxxm="\$ans"
790                         ans=!
791                         ;;
792                 *)
793                         echo "*** Error -- try again."
794                         ans=!
795                         ;;
796                 esac
797                 $myecho
798                 ;;
799         esac
800         case "\$ans\$xxxm\$nostick" in
801         '')
802                 ans=!
803                 $myecho
804                 ;;
805         esac
806 done
807 case "\$ans" in
808 '') ans="\$xxxm";;
809 esac
810 EOSC
811
812 : create .config dir to save info across Configure sessions
813 test -d ../.config || mkdir ../.config
814 cat >../.config/README <<EOF
815 This directory created by Configure to save information that should
816 persist across sessions.
817
818 You may safely delete it if you wish.
819 EOF
820
821 : general instructions
822 needman=true
823 firsttime=true
824 user=`( (logname) 2>/dev/null || whoami) 2>&1`
825 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
826         firsttime=false
827         echo " "
828         rp='Would you like to see the instructions?'
829         dflt=n
830         . ./myread
831         case "$ans" in
832         [yY]*) ;;
833         *) needman=false;;
834         esac
835 fi
836 if $needman; then
837         cat <<EOH
838  
839 This installation shell script will examine your system and ask you questions
840 to determine how the perl package should be installed. If you get
841 stuck on a question, you may use a ! shell escape to start a subshell or
842 execute a command.  Many of the questions will have default answers in square
843 brackets; typing carriage return will give you the default.
844
845 On some of the questions which ask for file or directory names you are allowed
846 to use the ~name construct to specify the login directory belonging to "name",
847 even if you don't have a shell which knows about that.  Questions where this is
848 allowed will be marked "(~name ok)".
849
850 EOH
851         rp=''
852         dflt='Type carriage return to continue'
853         . ./myread
854         cat <<'EOH'
855
856 The prompter used in this script allows you to use shell variables and
857 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
858 in the default answer, as if the default line was a set of arguments given to a
859 script shell.  This means you may also use $* to repeat the whole default line,
860 so you do not have to re-type everything to add something to the default.
861
862 Everytime there is a substitution, you will have to confirm.  If there is an
863 error (e.g. an unmatched backtick), the default answer will remain unchanged
864 and you will be prompted again.
865
866 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
867 the questions and use the computed defaults (or the previous answers if there
868 was already a config.sh file). Type 'Configure -h' for a list of options.
869
870 EOH
871         . ./myread
872         cat <<EOH
873
874 Much effort has been expended to ensure that this shell script will run on any
875 Unix system.  If despite that it blows up on yours, your best bet is to edit
876 Configure and run it again.  Also, let me (lwall@netlabs.com)
877 know how I blew it.  If you can't run Configure for some reason, you'll have to
878 generate a config.sh file by hand.
879
880 This installation script affects things in two ways:
881
882 1) it may do direct variable substitutions on some of the files included
883    in this kit.
884 2) it builds a config.h file for inclusion in C programs.  You may edit
885    any of these files as the need arises after running this script.
886
887 If you make a mistake on a question, there is no easy way to back up to it
888 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
889 files.  Configure will offer to let you do this before it runs the SH files.
890
891 EOH
892         dflt='Type carriage return to continue'
893         . ./myread
894         case "$firsttime" in
895         true) echo $user >>../.config/instruct;;
896         esac
897 fi
898
899 : see if sh knows # comments
900 echo " "
901 echo "Checking your sh to see if it knows about # comments..." >&4
902 if sh -c '#' >/dev/null 2>&1 ; then
903         echo "Your sh handles # comments correctly."
904         shsharp=true
905         spitshell=cat
906         echo " "
907         echo "Okay, let's see if #! works on this system..."
908         echo "#!/bin/cat" >try
909         $eunicefix try
910         chmod +x try
911         ./try > today
912         if test -s today; then
913                 echo "It does."
914                 sharpbang='#!'
915         else
916                 echo "#! /bin/cat" > try
917                 $eunicefix try
918                 chmod +x try
919                 ./try > today
920                 if test -s today; then
921                         echo "It does."
922                         sharpbang='#! '
923                 else
924                         echo "It's just a comment."
925                         sharpbang=': use '
926                 fi
927         fi
928 else
929         echo "Your sh doesn't grok # comments--I will strip them later on."
930         shsharp=false
931         echo "exec grep -v '^[  ]*#'" >spitshell
932         chmod +x spitshell
933         $eunicefix spitshell
934         spitshell=`pwd`/spitshell
935         echo "I presume that if # doesn't work, #! won't work either!"
936         sharpbang=': use '
937 fi
938 rm -f try today
939
940 : figure out how to guarantee sh startup
941 echo " "
942 echo "Checking out how to guarantee sh startup..." >&4
943 case "$SYSTYPE" in
944 *bsd*|sys5*) startsh=$sharpbang"/$SYSTYPE/bin/sh";;
945 *) startsh=$sharpbang'/bin/sh';;
946 esac
947 echo "Let's see if '$startsh' works..."
948 cat >try <<EOSS
949 $startsh
950 set abc
951 test "$?abc" != 1
952 EOSS
953
954 chmod +x try
955 $eunicefix try
956 if ./try; then
957         echo "Yup, it does."
958 else
959 echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
960 fi
961 rm -f try
962
963 : find out where common programs are
964 echo " "
965 echo "Locating common programs..." >&4
966 cat <<EOSC >loc
967 $startsh
968 case \$# in
969 0) exit 1;;
970 esac
971 thing=\$1
972 shift
973 dflt=\$1
974 shift
975 for dir in \$*; do
976         case "\$thing" in
977         .)
978         if test -d \$dir/\$thing; then
979                 echo \$dir
980                 exit 0
981         fi
982         ;;
983         *)
984         if test -f \$dir/\$thing; then
985                 echo \$dir/\$thing
986                 exit 0
987         elif test -f \$dir/\$thing.exe; then
988                 : on Eunice apparently
989                 echo \$dir/\$thing
990                 exit 0
991         fi
992         ;;
993         esac
994 done
995 echo \$dflt
996 exit 1
997 EOSC
998 chmod +x loc
999 $eunicefix loc
1000 loclist="
1001 awk
1002 cat
1003 cp
1004 echo
1005 expr
1006 grep
1007 mkdir
1008 mv
1009 rm
1010 sed
1011 sort
1012 tr
1013 uniq
1014 "
1015 trylist="
1016 Mcc
1017 bison
1018 byacc
1019 cpp
1020 csh
1021 date
1022 egrep
1023 find
1024 line
1025 nroff
1026 perl
1027 test
1028 uname
1029 "
1030 pth=`echo $PATH | sed -e 's/:/ /g'`
1031 pth="$pth /lib /usr/lib"
1032 for file in $loclist; do
1033         xxx=`./loc $file $file $pth`
1034         eval $file=$xxx
1035         eval _$file=$xxx
1036         case "$xxx" in
1037         /*)
1038                 echo $file is in $xxx.
1039                 ;;
1040         *)
1041                 echo "I don't know where $file is.  I hope it's in everyone's PATH."
1042                 ;;
1043         esac
1044 done
1045 echo " "
1046 echo "Don't worry if any of the following aren't found..."
1047 say=offhand
1048 for file in $trylist; do
1049         xxx=`./loc $file $file $pth`
1050         eval $file=$xxx
1051         eval _$file=$xxx
1052         case "$xxx" in
1053         /*)
1054                 echo $file is in $xxx.
1055                 ;;
1056         *)
1057                 echo "I don't see $file out there, $say."
1058                 say=either
1059                 ;;
1060         esac
1061 done
1062 case "$egrep" in
1063 egrep)
1064         echo "Substituting grep for egrep."
1065         egrep=$grep
1066         ;;
1067 esac
1068 case "$test" in
1069 test)
1070         echo "Hopefully test is built into your sh."
1071         ;;
1072 *)
1073         if sh -c "PATH= test true" >/dev/null 2>&1; then
1074                 echo "Using the test built into your sh."
1075                 test=test
1076                 _test=test
1077         fi
1078         ;;
1079 esac
1080 case "$echo" in
1081 echo)
1082         echo "Hopefully echo is built into your sh."
1083         ;;
1084 '') ;;
1085 *)
1086         echo " "
1087 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1088         $echo $n "hi there$c" >foo1
1089         echo $n "hi there$c" >foo2
1090         if cmp foo1 foo2 >/dev/null 2>&1; then
1091                 echo "They are compatible.  In fact, they may be identical."
1092         else
1093                 case "$n" in
1094                 '-n') n='' c='\c';;
1095                 *) n='-n' c='';;
1096                 esac
1097                 cat <<FOO
1098 They are not compatible!  You are probably running ksh on a non-USG system.
1099 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1100 have echo built in and we may have to run some Bourne shell scripts.  That
1101 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1102
1103 FOO
1104                 $echo $n "The star should be here-->$c"
1105                 $echo "*"
1106         fi
1107         $rm -f foo1 foo2
1108         ;;
1109 esac
1110
1111 : Try to determine whether config.sh was made on this system
1112 case "$config_sh" in
1113 '')
1114 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
1115 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' | \
1116         tr '[A-Z]' '[a-z]' | tr '\012' ' '`
1117 dflt=n
1118 if test "$fastread" = yes; then
1119         dflt=y
1120 elif test -f ../config.sh; then
1121         oldmyuname=''
1122         if $contains myuname= ../config.sh >/dev/null 2>&1; then
1123                 eval "old`grep myuname= ../config.sh`"
1124         fi
1125         if test "X$myuname" = "X$oldmyuname"; then
1126                 dflt=y
1127         fi
1128 fi
1129
1130 : Get old answers from old config file if Configure was run on the
1131 : same system, otherwise use the hints.
1132 hint=default
1133 cd ..
1134 if test -f config.sh; then
1135         echo " "
1136         rp="I see a config.sh file.  Shall I use it to set the defaults?"
1137         . UU/myread
1138         case "$ans" in
1139         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
1140         *)  echo "Fetching default answers from your old config.sh file..." >&4
1141                 tmp="$n"
1142                 tans="$c"
1143                 . ./config.sh
1144                 cp config.sh UU
1145                 n="$tmp"
1146                 c="$tans"
1147                 hint=previous
1148                 ;;
1149         esac
1150 fi
1151 if test ! -f config.sh; then
1152         $cat <<EOM
1153
1154 First time through, eh?  I have some defaults handy for the following systems:
1155
1156 EOM
1157         cd hints; ls -C *.sh | $sed 's/\.sh/   /g' >&4
1158         dflt=''
1159         : Half the following guesses are probably wrong... If you have better
1160         : tests or hints, please send them to lwall@netlabs.com
1161         : The metaconfig authors would also appreciate a copy...
1162         $test -f /irix && dflt="$dflt sgi"
1163         $test -f /xenix && dflt="$dflt sco_xenix"
1164         $test -f /dynix && dflt="$dflt dynix"
1165         $test -f /dnix && dflt="$dflt dnix"
1166         $test -f /bin/mips && /bin/mips && dflt="$dflt mips"
1167         $test -d /NextApps && test -f /usr/adm/software_version && dflt="$dflt next"
1168         $test -d /usr/include/minix && dflt="$dflt minix"
1169         if $test -f $uname; then
1170                 set X $myuname
1171                 shift
1172
1173                 $test -f $5.sh && dflt="$dflt $5"
1174
1175                 case "$5" in
1176                 fps*) dflt="$dflt fps";;
1177                 mips*)
1178                         case "$4" in
1179                         umips) dflt="$dflt umips";;
1180                         *) dflt="$dflt mips";;
1181                         esac;;
1182                 [23]100) dflt="$dflt mips";;
1183                 next*) dflt="$dflt next" ;;
1184                 news*) dflt="$dflt news" ;;
1185                 i386*) if $test -f /etc/kconfig; then
1186                                 if $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
1187                                         dflt="$dflt isc_3_2_3"
1188                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
1189                                         dflt="$dflt isc_3_2_2"
1190                             fi
1191                                 : i386.sh hint is wrong for Interactive.
1192                                 dflt=`echo $dflt | $sed 's/i386//'`
1193                        fi
1194                        ;;
1195                 esac
1196
1197                 case "$1" in
1198                 aix) dflt="$dflt aix_rs" ;;
1199                 sun[Oo][Ss]) case "$3" in
1200                         [34]*) vers=`echo $3 | $sed 's/\./_/g'`
1201                                 dflt="$dflt sunos_$vers" ;;
1202                         5*) vers=`echo $3 | $sed 's/^5/2/g'`
1203                                 dflt="$dflt solaris_$vers" ;;
1204                         esac
1205                         ;;
1206                 [sS]olaris) case "$3" in
1207                         5*) vers=`echo $3 | $sed 's/^5/2/g'`
1208                                 dflt="$dflt solaris_$vers" ;;
1209                         esac
1210                         ;;
1211                 dnix) dflt="$dflt dnix" ;;
1212                 dgux) dflt="$dflt dgux" ;;
1213                 genix) dflt="$dflt genix" ;;
1214                 hp*ux) dflt="$dflt hpux" ;;
1215                 next) dflt="$dflt next" ;;
1216                 irix) dflt="$dflt sgi" ;;
1217                 ultrix) case "$3" in
1218                         3*) dflt="$dflt ultrix_3" ;;
1219                         4*) dflt="$dflt ultrix_4" ;;
1220                         esac
1221                         ;;
1222                 uts) dflt="$dflt uts" ;;
1223                 $2) case "$dflt" in
1224                         *isc*) ;;
1225                         *)      if test -f /etc/systemid; then
1226                                 set `echo $3 | $sed 's/\./ /g'` $4
1227                                         if $test -f sco_$1_$2_$3.sh; then
1228                                                 dflt="$dflt sco_$1_$2_$3"
1229                                         elif $test -f sco_$1_$2.sh; then
1230                                                 dflt="$dflt sco_$1_$2"
1231                                         elif $test -f sco_$1.sh; then
1232                                                 dflt="$dflt sco_$1"
1233                                         fi
1234                                 fi
1235                                 ;;
1236                         esac
1237                         ;;
1238                 esac
1239         else
1240                 if test -f /vmunix -a -f news_os.sh; then
1241                         (what /vmunix | tr '[A-Z]' '[a-z]') > ../UU/kernel.what 2>&1
1242                         if $contains news-os ../UU/kernel.what >/dev/null 2>&1; then
1243                                 dflt="$dflt news_os"
1244                         fi
1245                         $rm -f ../UU/kernel.what
1246                 fi
1247         fi
1248         set X `echo $dflt | tr ' ' '\012' | sort | uniq`
1249         shift
1250         dflt=''
1251         for file in $*; do
1252                 if $test -f "$file.sh"; then
1253                         dflt="$dflt $file"
1254                 fi
1255         done
1256         set X $dflt
1257         shift
1258         dflt=${1+"$@"}
1259         case "$dflt" in
1260         '') dflt=none;;
1261         esac
1262         $cat <<EOM
1263
1264 You may give one or more space-separated answers, or "none" if appropriate.
1265 If your OS version has no hints, DO NOT give a wrong version -- say "none".
1266
1267 EOM
1268         rp="Which of these apply, if any?"
1269         . ../UU/myread
1270         for file in $ans; do
1271                 if $test -f $file.sh; then
1272                         . ./$file.sh
1273                         $cat $file.sh >> ../UU/config.sh
1274                 elif $test X$ans = X -o X$ans = Xnone ; then
1275                         : nothing
1276                 else
1277                         echo "$file.sh does not exist -- ignored"
1278                 fi
1279         done
1280         hint=recommended
1281         cd ..
1282 fi
1283 cd UU
1284 ;;
1285 *)
1286         echo " "
1287         echo "Fetching default answers from $config_sh..." >&4
1288         tmp="$n"
1289         tans="$c"
1290         cd ..
1291         cp $config_sh config.sh 2>/dev/null
1292         . ./config.sh
1293         cd UU
1294         cp ../config.sh .
1295         n="$tmp"
1296         c="$tans"
1297         hint=previous
1298         ;;
1299 esac
1300
1301 : Restore computed paths
1302 for file in $loclist $trylist; do
1303         eval $file="\$_$file"
1304 done
1305
1306 : who configured the system
1307 cf_time=`$date 2>&1`
1308 cf_by=`( (logname) 2>/dev/null || whoami) 2>&1`
1309
1310 : determine where manual pages are on this system
1311 echo " "
1312 case "$sysman" in
1313 '') 
1314         syspath='/usr/man/man1 /usr/man/man1 /usr/man/mann'
1315         syspath="$syspath /usr/man/manl /usr/man/local/man1"
1316         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
1317         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
1318         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
1319         syspath="$syspath /usr/man/man.L /local/man/man1"
1320         sysman=`./loc . $syspath`
1321         ;;
1322 esac
1323 if $test -d "$sysman"; then
1324         echo "System manual is in $sysman." >&4
1325 else
1326         echo "Could not find manual pages in source form." >&4
1327 fi
1328
1329 : see what memory models we can support
1330 case "$models" in
1331 '')
1332         $cat >pdp11.c <<'EOP'
1333 main() {
1334 #ifdef pdp11
1335         exit(0);
1336 #else
1337         exit(1);
1338 #endif
1339 }
1340 EOP
1341         cc -o pdp11 pdp11.c >/dev/null 2>&1
1342         if ./pdp11 2>/dev/null; then
1343                 dflt='unsplit split'
1344         else
1345                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
1346                 case "$tans" in
1347                 X) dflt='none';;
1348                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
1349                                 dflt='small'
1350                         else
1351                                 dflt=''
1352                         fi
1353                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
1354                                 dflt="$dflt medium"
1355                         fi
1356                         if $test -d /lib/large || $test -d /usr/lib/large; then
1357                                 dflt="$dflt large"
1358                         fi
1359                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
1360                                 dflt="$dflt huge"
1361                         fi
1362                 esac
1363         fi;;
1364 *) dflt="$models";;
1365 esac
1366 $cat <<EOM
1367  
1368 Some systems have different model sizes.  On most systems they are called
1369 small, medium, large, and huge.  On the PDP11 they are called unsplit and
1370 split.  If your system doesn't support different memory models, say "none".
1371 If you wish to force everything to one memory model, say "none" here and
1372 put the appropriate flags later when it asks you for other cc and ld flags.
1373 Venix systems may wish to put "none" and let the compiler figure things out.
1374 (In the following question multiple model names should be space separated.)
1375
1376 EOM
1377 rp="Which memory models are supported?"
1378 . ./myread
1379 models="$ans"
1380
1381 case "$models" in
1382 none)
1383         small=''
1384         medium=''
1385         large=''
1386         huge=''
1387         unsplit=''
1388         split=''
1389         ;;
1390 *split)
1391         case "$split" in
1392         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
1393                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
1394                         dflt='-i'
1395                 else
1396                         dflt='none'
1397                 fi;;
1398         *) dflt="$split";;
1399         esac
1400         rp="What flag indicates separate I and D space?"
1401         . ./myread
1402         tans="$ans"
1403         case "$tans" in
1404         none) tans='';;
1405         esac
1406         split="$tans"
1407         unsplit='';;
1408 *large*|*small*|*medium*|*huge*)
1409         case "$models" in
1410         *large*)
1411                 case "$large" in
1412                 '') dflt='-Ml';;
1413                 *) dflt="$large";;
1414                 esac
1415         rp="What flag indicates large model?"
1416         . ./myread
1417         tans="$ans"
1418         case "$tans" in
1419         none) tans='';
1420         esac
1421         large="$tans";;
1422         *) large='';;
1423         esac
1424         case "$models" in
1425         *huge*) case "$huge" in
1426                 '') dflt='-Mh';;
1427                 *) dflt="$huge";;
1428                 esac
1429                 rp="What flag indicates huge model?"
1430                 . ./myread
1431                 tans="$ans"
1432                 case "$tans" in
1433                 none) tans='';
1434                 esac
1435                 huge="$tans";;
1436         *) huge="$large";;
1437         esac
1438         case "$models" in
1439         *medium*) case "$medium" in
1440                 '') dflt='-Mm';;
1441                 *) dflt="$medium";;
1442                 esac
1443                 rp="What flag indicates medium model?"
1444                 . ./myread
1445                 tans="$ans"
1446                 case "$tans" in
1447                 none) tans='';
1448                 esac
1449                 medium="$tans";;
1450         *) medium="$large";;
1451         esac
1452         case "$models" in
1453         *small*) case "$small" in
1454                 '') dflt='none';;
1455                 *) dflt="$small";;
1456                 esac
1457                 rp="What flag indicates small model?"
1458                 . ./myread
1459                 tans="$ans"
1460                 case "$tans" in
1461                 none) tans='';
1462                 esac
1463                 small="$tans";;
1464         *) small='';;
1465         esac
1466         ;;
1467 *)
1468         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
1469         ;;
1470 esac
1471
1472 : make some quick guesses about what we are up against
1473 echo " "
1474 $echo $n "Hmm...  $c"
1475 echo exit 1 >bsd
1476 echo exit 1 >usg
1477 echo exit 1 >v7
1478 echo exit 1 >osf1
1479 echo exit 1 >eunice
1480 echo exit 1 >xenix
1481 echo exit 1 >venix
1482 d_bsd="$undef"
1483 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
1484 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
1485 then
1486         echo "Looks kind of like an OSF/1 system, but we'll see..."
1487         echo exit 0 >osf1
1488 elif test `echo abc | tr a-z A-Z` = Abc ; then
1489         xxx=`./loc addbib blurfl $pth`
1490         if $test -f $xxx; then
1491         echo "Looks kind of like a USG system with BSD features, but we'll see..."
1492                 echo exit 0 >bsd
1493                 echo exit 0 >usg
1494         else
1495                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
1496                         echo "Looks kind of like an extended USG system, but we'll see..."
1497                 else
1498                         echo "Looks kind of like a USG system, but we'll see..."
1499                 fi
1500                 echo exit 0 >usg
1501         fi
1502 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
1503         echo "Looks kind of like a BSD system, but we'll see..."
1504         d_bsd="$define"
1505         echo exit 0 >bsd
1506 else
1507         echo "Looks kind of like a Version 7 system, but we'll see..."
1508         echo exit 0 >v7
1509 fi
1510 case "$eunicefix" in
1511 *unixtovms*)
1512         $cat <<'EOI'
1513 There is, however, a strange, musty smell in the air that reminds me of
1514 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
1515 EOI
1516         echo exit 0 >eunice
1517         d_eunice="$define"
1518 : it so happens the Eunice I know will not run shell scripts in Unix format
1519         ;;
1520 *)
1521         echo " "
1522         echo "Congratulations.  You aren't running Eunice."
1523         d_eunice="$undef"
1524         ;;
1525 esac
1526 if test -f /xenix; then
1527         echo "Actually, this looks more like a XENIX system..."
1528         echo exit 0 >xenix
1529         d_xenix="$define"
1530 else
1531         echo " "
1532         echo "It's not Xenix..."
1533         d_xenix="$undef"
1534 fi
1535 chmod +x xenix
1536 $eunicefix xenix
1537 if test -f /venix; then
1538         echo "Actually, this looks more like a VENIX system..."
1539         echo exit 0 >venix
1540 else
1541         echo " "
1542         if xenix; then
1543                 : null
1544         else
1545                 echo "Nor is it Venix..."
1546         fi
1547 fi
1548 chmod +x bsd usg v7 osf1 eunice xenix venix
1549 $eunicefix bsd usg v7 osf1 eunice xenix venix
1550 $rm -f foo
1551
1552 : see if we need a special compiler
1553 echo " "
1554 if usg; then
1555         case "$cc" in
1556         '') case "$Mcc" in
1557                 /*) dflt='Mcc';;
1558                 *) case "$large" in
1559                         -M*) dflt='cc';;
1560                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
1561                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
1562                                                 dflt='cc'
1563                                         else
1564                                                 dflt='cc -M'
1565                                         fi
1566                                 else
1567                                         dflt='cc'
1568                                 fi;;
1569                         esac;;
1570                 esac;;
1571         *)  dflt="$cc";;
1572         esac
1573         $cat <<'EOM'
1574 On some systems the default C compiler will not resolve multiple global
1575 references that happen to have the same name.  On some such systems the "Mcc"
1576 command may be used to force these to be resolved.  On other systems a "cc -M"
1577 command is required.  (Note that the -M flag on other systems indicates a
1578 memory model to use!) If you have the Gnu C compiler, you might wish to use
1579 that instead.
1580
1581 EOM
1582         rp="What command will force resolution on this system?"
1583         . ./myread
1584         cc="$ans"
1585 else
1586         case "$cc" in
1587         '') dflt=cc;;
1588         *) dflt="$cc";;
1589         esac
1590         rp="Use which C compiler?"
1591         . ./myread
1592         cc="$ans"
1593 fi
1594 case "$cc" in
1595 gcc*)   echo "Checking out which version of gcc"
1596 $cat >gccvers.c <<EOM
1597 #include <stdio.h>
1598 int main()
1599 {
1600 char *v;
1601 v = "unknown";
1602 #ifdef __GNUC__
1603 #  ifdef __VERSION__
1604         v = __VERSION__;
1605 #  endif
1606 #endif
1607 switch((int) v[0])
1608   {
1609     case '1':  printf("1\n"); break;
1610     case '2':  printf("2\n"); break;
1611     case '3':  printf("3\n"); break;
1612     default:   break;
1613   }
1614 #ifdef __GNUC__
1615 return 0;
1616 #else
1617 return 1;
1618 #endif
1619 }
1620 EOM
1621         if $cc -o gccvers $ccflags gccvers.c >/dev/null 2>&1; then
1622             gccversion=`./gccvers`
1623                 echo "You appear to have version $gccversion."
1624         else
1625                 echo "Doesn't appear to be GNU cc."
1626         fi
1627         $rm -f gccvers*
1628         if $test "$gccversion" = '1'; then
1629                 cpp=`./loc gcc-cpp $cpp $pth`
1630         fi
1631         ;;
1632 esac
1633 : decide how portable to be
1634 case "$d_portable" in
1635 "$define") dflt=y;;
1636 *)      dflt=n;;
1637 esac
1638 $cat <<'EOH'
1639  
1640 I can set things up so that your shell scripts and binaries are more portable,
1641 at what may be a noticable cost in performance.  In particular, if you
1642 ask to be portable, the following happens:
1643
1644      1) Shell scripts will rely on the PATH variable rather than using
1645         the paths derived above.
1646      2) ~username interpretations will be done at run time rather than
1647         by Configure.
1648
1649 EOH
1650 rp="Do you expect to run these scripts and binaries on multiple machines?"
1651 . ./myread
1652 case "$ans" in
1653         y*) d_portable="$define"
1654         for file in $loclist $trylist; do
1655                 eval $file="\$file"
1656         done
1657         ;;
1658         *)  d_portable="$undef" ;;
1659 esac
1660
1661 : set up shell script to do ~ expansion
1662 cat >filexp <<EOSS
1663 $startsh
1664 : expand filename
1665 case "\$1" in
1666  ~/*|~)
1667         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
1668         ;;
1669  ~*)
1670         if $test -f /bin/csh; then
1671                 /bin/csh -f -c "glob \$1"
1672                 failed=$?
1673                 echo ""
1674                 exit \$failed
1675         else
1676                 name=\`$expr x\$1 : '..\([^/]*\)'\`
1677                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
1678                 if $test ! -d "\$dir"; then
1679                         me=\`basename \$0\`
1680                         echo "\$me: can't locate home directory for: \$name" >&2
1681                         exit 1
1682                 fi
1683                 case "\$1" in
1684                 */*)
1685                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
1686                         ;;
1687                 *)
1688                         echo \$dir
1689                         ;;
1690                 esac
1691         fi
1692         ;;
1693 *)
1694         echo \$1
1695         ;;
1696 esac
1697 EOSS
1698 chmod +x filexp
1699 $eunicefix filexp
1700
1701 : now set up to get a file name
1702 cat <<'EOSC' >getfile
1703 tilde=''
1704 fullpath=''
1705 already=''
1706 skip=''
1707 none_ok=''
1708 exp_file=''
1709 orig_rp="$rp"
1710 orig_dflt="$dflt"
1711
1712 case "$fn" in
1713 *~*) tilde=true;;
1714 esac
1715 case "$fn" in
1716 */*) fullpath=true;;
1717 esac
1718 case "$fn" in
1719 *+*) skip=true;;
1720 esac
1721 case "$fn" in
1722 *n*) none_ok=true;;
1723 esac
1724 case "$fn" in
1725 *e*) exp_file=true;;
1726 esac
1727
1728 case "$fn" in
1729 *f*) type='File';;
1730 *d*) type='Directory';;
1731 *l*) type='Locate'; fn=`expr $fn : '.*:\(.*\)'`;;
1732 esac
1733
1734 what="$type"
1735 case "$what" in
1736 Locate) what='File';;
1737 esac
1738
1739 case "$exp_file" in
1740 '')
1741         case "$d_portable" in
1742         "$define") ;;
1743         *) exp_file=true;;
1744         esac
1745         ;;
1746 esac
1747
1748 cd ..
1749 while test "$type"; do
1750         redo=''
1751         rp="$orig_rp"
1752         dflt="$orig_dflt"
1753         case "$tilde" in
1754         true) rp="$rp (~name ok)";;
1755         esac
1756         . UU/myread
1757         case "$ans" in
1758         none)
1759                 value=''
1760                 ansexp=''
1761                 case "$none_ok" in
1762                 true) type='';;
1763                 esac
1764                 ;;
1765         *)
1766                 case "$tilde" in
1767                 '') value="$ans"
1768                         ansexp="$ans";;
1769                 *)
1770                         value=`UU/filexp $ans`
1771                         case $? in
1772                         0)
1773                                 if test "$ans" != "$value"; then
1774                                         echo "(That is $value on this particular system.)"
1775                                 fi
1776                                 ;;
1777                         *) value="$ans";;
1778                         esac
1779                         ansexp="$value"
1780                         case "$exp_file" in
1781                         '') value="$ans";;
1782                         esac
1783                         ;;
1784                 esac
1785                 case "$fullpath" in
1786                 true)
1787                         case "$ansexp" in
1788                         /*) value="$ansexp" ;;
1789                         *)
1790                                 redo=true
1791                                 case "$already" in
1792                                 true)
1793                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
1794                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
1795                                         ;;
1796                                 *)
1797                                 echo "Please give a full path name, starting with slash." >&4
1798                                         case "$tilde" in
1799                                         true)
1800                                 echo "Note that using ~name is ok provided it expands well." >&4
1801                                                 already=true
1802                                                 ;;
1803                                         esac
1804                                 esac
1805                                 ;;
1806                         esac
1807                         ;;
1808                 esac
1809                 case "$redo" in
1810                 '')
1811                         case "$type" in
1812                         File)
1813                                 if test -f "$ansexp"; then
1814                                         type=''
1815                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
1816                                 then
1817                                         echo "($value is not a plain file, but that's ok.)"
1818                                         type=''
1819                                 fi
1820                                 ;;
1821                         Directory)
1822                                 if test -d "$ansexp"; then
1823                                         type=''
1824                                 fi
1825                                 ;;
1826                         Locate)
1827                                 if test -d "$value"; then
1828                                         echo "(Looking for $fn in directory $value.)"
1829                                         value="$value/$fn"
1830                                 fi
1831                                 if test -f "$value"; then
1832                                         type=''
1833                                 fi
1834                                 ;;
1835                         esac
1836
1837                         case "$skip" in
1838                         true) type='';
1839                         esac
1840
1841                         case "$type" in
1842                         '') ;;
1843                         *)
1844                                 if test "$fastread" = yes; then
1845                                         dflt=y
1846                                 else
1847                                         dflt=n
1848                                 fi
1849                                 rp="$what $value doesn't exist.  Use that name anyway?"
1850                                 . UU/myread
1851                                 dflt=''
1852                                 case "$ans" in
1853                                 y*) type='';;
1854                                 *) echo " ";;
1855                                 esac
1856                                 ;;
1857                         esac
1858                         ;;
1859                 esac
1860                 ;;
1861         esac
1862 done
1863 cd UU
1864 ans="$value"
1865 rp="$orig_rp"
1866 dflt="$orig_dflt"
1867 EOSC
1868
1869 : What should the include directory be ?
1870 echo " "
1871 $echo $n "Hmm...  $c"
1872 case "$usrinc" in
1873 '') dflt='/usr/include';;
1874 *) dflt=$usrinc;;
1875 esac
1876 incpath=''
1877 mips_type=''
1878 if $test -f /bin/mips && /bin/mips; then
1879         echo "Looks like a MIPS system..."
1880         $cat >usr.c <<'EOCP'
1881 #ifdef SYSTYPE_BSD43
1882 /bsd43
1883 #endif
1884 EOCP
1885         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
1886                 dflt='/bsd43/usr/include'
1887                 incpath='/bsd43'
1888                 mips_type='BSD 4.3'
1889         else
1890                 mips_type='System V'
1891         fi
1892         $rm -f usr.c usr.out
1893         echo "and you're compiling with the $mips_type compiler and libraries."
1894 else
1895         echo "Doesn't look like a MIPS system."
1896         echo "exit 1" >mips
1897         chmod +x mips
1898         $eunicefix mips
1899 fi
1900 echo " "
1901 fn=d/
1902 rp='Where are the include files you want to use?'
1903 . ./getfile
1904 usrinc="$ans"
1905
1906 : determine optimize, if desired, or use for debug flag also
1907 case "$optimize" in
1908 ' ') dflt="none";;
1909 '') dflt="-g";;
1910 *) dflt="$optimize";;
1911 esac
1912 $cat <<EOH
1913
1914 Some C compilers have problems with their optimizers, by default, $package
1915 compiles with the -O flag to use the optimizer.  Alternately, you might want
1916 to use the symbolic debugger, which uses the -g flag (on traditional Unix
1917 systems).  Either flag can be specified here.  To use neither flag, specify
1918 the word "none".
1919
1920 EOH
1921 rp="What optimizer/debugger flag should be used?"
1922 . ./myread
1923 optimize="$ans"
1924 case "$optimize" in
1925 'none') optimize=" ";;
1926 esac
1927
1928 case "$ccflags" in
1929 '')     case "$cc" in
1930         *gcc*) if $test "$gccversion" = "1"; then
1931                         dflt='-fpcc-struct-return'
1932                    fi ;;
1933         *) dflt='';;
1934         esac
1935         case "$optimize" in
1936         *-g*) dflt="$dflt -DDEBUGGING";;
1937         esac
1938         case "$cc" in
1939         *gcc*)  if test -d /etc/conf/kconfig.d &&
1940                   $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
1941                 then
1942                         dflt="$dflt -posix"
1943                 fi
1944                 ;;
1945         esac
1946         ;;
1947 *) dflt="$ccflags" ;;
1948 esac
1949
1950 case "$mips_type" in
1951 *BSD*) ;;
1952 '') ;;
1953 *) inclwanted="$inclwanted $usrinc/bsd";;
1954 esac
1955 for thisincl in $inclwanted; do
1956         if $test -d $thisincl; then
1957                 if $test x$thisincl != x$usrinc; then
1958                         case "$dflt" in
1959                         *$thisincl*);;
1960                         *) dflt="$dflt -I$thisincl";;
1961                         esac
1962                 fi
1963         fi
1964 done
1965
1966 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
1967         xxx=true;
1968 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
1969         xxx=true;
1970 else
1971         xxx=false;
1972 fi;
1973 if $xxx; then
1974         case "$dflt" in
1975         *$2*);;
1976         *) dflt="$dflt -D$2";;
1977         esac;
1978 fi'
1979
1980 if ./osf1; then
1981         set signal.h __LANGUAGE_C__; eval $inctest
1982 else
1983         set signal.h LANGUAGE_C; eval $inctest
1984 fi
1985 set signal.h NO_PROTOTYPE; eval $inctest
1986 set signal.h _NO_PROTO; eval $inctest
1987
1988 case "$dflt" in
1989 '') dflt=none;;
1990 esac
1991 $cat <<EOH
1992
1993 Your C compiler may want other flags.  For this question you should include
1994 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
1995 but you should NOT include libraries or ld flags like -lwhatever.  If you
1996 want $package to honor its debug switch, you should include -DDEBUGGING here.
1997 To use no flags, specify the word "none".
1998
1999 Your C compiler might also need additional flags, such as -DJMPCLOBBER
2000 or -DCRIPPLED_CC.
2001 EOH
2002 set X $dflt
2003 shift
2004 dflt=${1+"$@"}
2005 rp="Any additional cc flags?"
2006 . ./myread
2007 case "$ans" in
2008 none) ccflags='';;
2009 *) ccflags="$ans";;
2010 esac
2011
2012 : the following weeds options from ccflags that are of no interest to cpp
2013 cppflags="$ccflags"
2014 case "$cc" in
2015 *gcc*) if $test "$gccversion" = "1"; then
2016                 cppflags="$cppflags -D__GNUC__"
2017             fi ;;
2018 esac
2019 case "$mips_type" in
2020 '');;
2021 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
2022 esac
2023 case "$cppflags" in
2024 '');;
2025 *)  set X $cppflags
2026         cppflags=''
2027         for flag
2028         do
2029                 case $flag in
2030                 -D*|-I*|-traditional|-ansi|-nostdinc) cppflags="$cppflags $flag";;
2031                 esac
2032         done
2033         case "$cppflags" in
2034         *-*)  echo "(C preprocessor flags: $cppflags)";;
2035         esac
2036         ;;
2037 esac
2038
2039 : flags used in final linking phase
2040 case "$ldflags" in
2041 '') if venix; then
2042                 dflt='-i -z'
2043         else
2044                 dflt='none'
2045         fi
2046         ;;
2047 *) dflt="$ldflags";;
2048 esac
2049 echo " "
2050 rp="Any additional ld flags (NOT including libraries)?"
2051 . ./myread
2052 case "$ans" in
2053 none) ldflags='';;
2054 *) ldflags="$ans";;
2055 esac
2056 rmlist="$rmlist pdp11"
2057
2058 : Initialize h_fcntl
2059 h_fcntl=false
2060
2061 : Initialize h_sysfile
2062 h_sysfile=false
2063
2064 : Set private lib path
2065 case "$plibpth" in
2066 '') if mips; then
2067                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
2068         fi;;
2069 esac
2070 libpth="$plibpth $libpth"
2071 : Now check and see which directories actually exist.
2072 xxx=''
2073 for yyy in $libpth
2074 do
2075     if $test -d $yyy; then
2076                 xxx="$xxx $yyy"
2077     fi
2078 done
2079 libpth="$xxx"
2080 $cat <<EOM
2081 Some systems have incompatible or broken versions of libraries.  Where
2082 should I look for libraries?
2083 EOM
2084
2085 dflt="$libpth"
2086 echo " "
2087 rp="Directories to use for library searches?"
2088 . ./myread
2089 case "$ans" in
2090 none) libpth=' ';;
2091 *) libpth="$ans";;
2092 esac
2093 : Looking for optional libraries
2094 echo " "
2095 echo "Checking for optional libraries..." >&4
2096 case "$libs" in
2097 ' '|'') dflt='';;
2098 *) dflt="$libs";;
2099 esac
2100 case "$libswanted" in
2101 '') libswanted='c_s';;
2102 esac
2103 for thislib in $libswanted; do
2104         case "$thislib" in
2105         dbm) thatlib=ndbm;;
2106         *_s) thatlib=NONE;;
2107         *) thatlib="${thislib}_s";;
2108         esac
2109         xxx=`./loc lib$thislib.a X $libpth`
2110         yyy=`./loc lib$thatlib.a X $libpth`
2111         zzz=`./loc lib$thislib.so.[0-9]'*' $libpth`
2112         if $test -f $xxx; then
2113                 echo "Found -l$thislib."
2114                 case "$dflt" in
2115                 "*-l$thislib *.*"|"*-l$thatlib *.*") ;;
2116                 *) dflt="$dflt -l$thislib";;
2117                 esac
2118         elif $test -f $yyy; then
2119                 echo "Found -l$thatlib."
2120                 case "$dflt" in
2121                 "*-l$thislib *.*"|"*-l$thatlib *.*") ;;
2122                 *) dflt="$dflt -l$thatlib";;
2123                 esac
2124         elif $test -f $zzz; then
2125                 echo "Found -$thislib."
2126                 case "$dflt" in
2127                 "*-l$thislib *.*"|"*-l$thatlib *.*") ;;
2128                 *) dflt="$dflt -l$thislib";;
2129                 esac
2130         else
2131                 xxx=`./loc Slib$thislib.a X $xlibpth`
2132                 yyy=`./loc Slib$thatlib.a X $xlibpth`
2133                 if $test -f $xxx; then
2134                         echo "Found -l$thislib."
2135                         case "$dflt" in
2136                         "*-l$thislib *.*"|"*-l$thatlib *.*") ;;
2137                         *) dflt="$dflt -l$thislib";;
2138                         esac
2139                 elif $test -f $yyy; then
2140                         echo "Found -l$thatlib."
2141                         case "$dflt" in
2142                         "*-l$thislib *.*"|"*-l$thatlib *.*") ;;
2143                         *) dflt="$dflt -l$thatlib";;
2144                         esac
2145                 else
2146                         echo "No -l$thislib."
2147                 fi
2148         fi
2149 done
2150 set X $dflt
2151 shift
2152 dflt="$*"
2153 case "$libs" in
2154 '') dflt="$dflt";;
2155 *) dflt="$libs";;
2156 esac
2157 case "$dflt" in
2158 ' '|'') dflt='none';;
2159 esac
2160
2161 $cat <<EOM
2162  
2163 Some versions of Unix support shared libraries, which make executables smaller
2164 but make load time slightly longer.
2165
2166 On some systems, mostly newer Unix System V's, the shared library is included
2167 by putting the option "-lc_s" as the last thing on the cc command line when
2168 linking.  Other systems use shared libraries by default.  There may be other
2169 libraries needed to compile $package on your machine as well.  If your system
2170 needs the "-lc_s" option, include it here.  Include any other special libraries
2171 here as well.  Say "none" for none.
2172 EOM
2173
2174 echo " "
2175 rp="Any additional libraries?"
2176 . ./myread
2177 case "$ans" in
2178 none) libs=' ';;
2179 *) libs="$ans";;
2180 esac
2181
2182 : see if nm is to be used to determine whether a symbol is defined or not
2183 case "$usenm" in
2184 '')
2185         dflt=`egrep 'inlibc|csym' ../Configure | wc -l 2>/dev/null`
2186         if $test $dflt -gt 20; then
2187                 dflt=y
2188         else
2189                 dflt=n
2190         fi
2191         ;;
2192 *)
2193         case "$usenm" in
2194         true) dflt=y;;
2195         *) dflt=n;;
2196         esac
2197         ;;
2198 esac
2199 $cat <<EOM
2200
2201 I can use 'nm' to extract the symbols from your C libraries. This is a time
2202 consuming task which may generate huge output on the disk (up to 3 megabytes)
2203 but that should make the symbols extraction faster. The alternative is to skip
2204 the 'nm' extraction part and to compile a small test program instead to
2205 determine whether each symbol is present. If you have a fast C compiler and/or
2206 if your 'nm' output cannot be parsed, this may be the best solution.
2207
2208 EOM
2209 rp='Shall I use nm to extract C symbols from the libraries?'
2210 . ./myread
2211 case "$ans" in
2212 n|N) usenm=false;;
2213 *) usenm=true;;
2214 esac
2215
2216 runnm=$usenm
2217 case "$reuseval" in
2218 true) runnm=false;;
2219 esac
2220
2221 : nm options which may be necessary
2222 case "$nm_opt" in
2223 '') if $test -f /mach_boot; then
2224                 nm_opt=''
2225         elif $test -d /usr/ccs/lib; then
2226                 nm_opt='-p'
2227         elif $test -f /dgux; then
2228                 nm_opt='-p'
2229         else
2230                 nm_opt=''
2231         fi;;
2232 esac
2233
2234 case "$runnm" in
2235 true)
2236 : get list of predefined functions in a handy place
2237 echo " "
2238 case "$libc" in
2239 '') libc=unknown
2240         case "$libs" in
2241         *-lc_s*) libc=`./loc libc_s.a $libc $libpth`
2242         esac
2243         ;;
2244 esac
2245 libpth="$plibpth $libpth"
2246 libnames='';
2247 case "$libs" in
2248 '') ;;
2249 *)  for thislib in $libs; do
2250         case "$thislib" in
2251         -l*)
2252                 thislib=`expr X$thislib : 'X-l\(.*\)'`
2253                 try=`./loc lib$thislib.a blurfl/dyick $libpth`
2254                 if test ! -f $try; then
2255                         try=`./loc lib$thislib blurfl/dyick $libpth`
2256                         if test ! -f $try; then
2257                                 try=`./loc lib$thislib.so.'*' blurfl/dyick $libpth`
2258                                 if test ! -f $try; then
2259                                         try=`./loc $thislib blurfl/dyick $libpth`
2260                                         if test ! -f $try; then
2261                                                 try=`./loc Slib$thislib.a blurfl/dyick $xlibpth`
2262                                                 if test ! -f $try; then
2263                                                         try=''
2264                                                 fi
2265                                         fi
2266                                 fi
2267                         fi
2268                 fi
2269                 libnames="$libnames $try"
2270                 ;;
2271         *) libnames="$libnames $thislib" ;;
2272         esac
2273         done
2274         ;;
2275 esac
2276 xxx=normal
2277 case "$libc" in
2278 unknown)
2279         set /usr/ccs/lib/libc.so
2280         $test -r $1 || set /usr/lib/libc.so
2281         $test -r $1 || set /usr/shlib/libc.so
2282         $test -r $1 || set /usr/lib/libc.so.[0-9]*
2283         $test -r $1 || set /lib/libsys_s.a
2284         eval set \$$#
2285         ;;
2286 *)
2287         set blurfl
2288         ;;
2289 esac
2290 if $test -r "$1"; then
2291         echo "Your (shared) C library seems to be in $1."
2292         libc="$1"
2293 elif $test -r /lib/libc && $test -r /lib/clib; then
2294         echo "Your C library seems to be in both /lib/clib and /lib/libc."
2295         xxx=apollo
2296         libc='/lib/clib /lib/libc'
2297         if $test -r /lib/syslib; then
2298                 echo "(Your math library is in /lib/syslib.)"
2299                 libc="$libc /lib/syslib"
2300         fi
2301 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
2302         echo "Your C library seems to be in $libc, as you said before."
2303 elif $test -r $incpath/usr/lib/libc.a; then
2304         libc=$incpath/usr/lib/libc.a;
2305         echo "Your C library seems to be in $libc.  That's fine."
2306 elif $test -r /lib/libc.a; then
2307         libc=/lib/libc.a;
2308         echo "Your C library seems to be in $libc.  You're normal."
2309 else
2310         if tans=`./loc libc.a blurfl/dyick $libpth`; $test -r "$tans"; then
2311                 :
2312         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
2313                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
2314         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
2315                 :
2316         elif tans=`./loc Slibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
2317                 :
2318         elif tans=`./loc Mlibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
2319                 :
2320         else
2321                 tans=`./loc Llibc.a blurfl/dyick $xlibpth`
2322         fi
2323         if $test -r "$tans"; then
2324                 echo "Your C library seems to be in $tans, of all places."
2325                 libc=$tans
2326         else
2327                 libc='blurfl'
2328         fi
2329 fi
2330 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
2331         dflt="$libc"
2332         cat <<EOM
2333
2334 If the guess above is wrong (which it might be if you're using a strange
2335 compiler, or your machine supports multiple models), you can override it here.
2336
2337 EOM
2338 else
2339         dflt=''
2340         echo $libpth | tr ' ' '\012' | sort | uniq > libpath
2341         cat >&4 <<EOM
2342 I can't seem to find your C library.  I've looked in the following places:
2343
2344 EOM
2345         $sed 's/^/      /' libpath
2346         cat <<EOM
2347
2348 None of these seems to contain your C library. I need to get its name...
2349
2350 EOM
2351 fi
2352 fn=f
2353 rp='Where is your C library?'
2354 . ./getfile
2355 libc="$ans"
2356
2357 echo " "
2358 echo $libc $libnames | tr ' ' '\012' | sort | uniq > libnames
2359 set X `cat libnames`
2360 shift
2361 xxx=files
2362 case $# in 1) xxx=file; esac
2363 echo "Extracting names from the following $xxx for later perusal:" >&4
2364 echo " "
2365 $sed 's/^/      /' libnames >&4
2366 echo " "
2367 $echo $n "This may take a while...$c" >&4
2368
2369 nm $nm_opt $* 2>/dev/null >libc.tmp
2370 $echo $n ".$c"
2371 $grep fprintf libc.tmp > libc.ptf
2372 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
2373 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
2374 if com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
2375         eval $xscan;\
2376         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2377                 eval $xrun
2378 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
2379         eval $xscan;\
2380         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2381                 eval $xrun
2382 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
2383         eval $xscan;\
2384         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2385                 eval $xrun
2386 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
2387         eval $xscan;\
2388         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2389                 eval $xrun
2390 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
2391         eval $xscan;\
2392         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2393                 eval $xrun
2394 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
2395         eval $xscan;\
2396         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2397                 eval $xrun
2398 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
2399                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
2400         eval $xscan;\
2401         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2402                 eval $xrun
2403 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
2404         eval $xscan;\
2405         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2406                 eval $xrun
2407 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
2408         eval $xscan;\
2409         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2410                 eval $xrun
2411 else
2412         nm -p $* 2>/dev/null >libc.tmp
2413         com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
2414         eval "<libc.tmp $com >libc.list"
2415         if $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2416                 nm_opt='-p'
2417                 echo "done" >&4
2418         else
2419                 echo " "
2420                 echo "nm didn't seem to work right. Trying ar instead..." >&4
2421                 com=''
2422                 if ar t $libc > libc.tmp; then
2423                         for thisname in $libnames; do
2424                                 ar t $thisname >>libc.tmp
2425                         done
2426                         $sed -e 's/\.o$//' < libc.tmp > libc.list
2427                         echo "Ok." >&4
2428                 else
2429                         echo "ar didn't seem to work right." >&4
2430                         echo "Maybe this is a Cray...trying bld instead..." >&4
2431                         if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
2432                                 for thisname in $libnames; do
2433                                         bld t $libnames | \
2434                                         $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
2435                                         ar t $thisname >>libc.tmp
2436                                 done
2437                                 echo "Ok." >&4
2438                         else
2439                                 echo "That didn't work either.  Giving up." >&4
2440                                 exit 1
2441                         fi
2442                 fi
2443         fi
2444 fi
2445 nm_extract="$com"
2446 if $test -f /lib/syscalls.exp; then
2447         echo " "
2448         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
2449         $sed -n 's/^\([^        ]*\)[   ]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
2450 fi
2451 ;;
2452 esac
2453 $rm -f libnames libpath
2454
2455 : is a C symbol defined?
2456 csym='tlook=$1;
2457 case "$3" in
2458 -v) tf=libc.tmp; tc=""; tdc="";;
2459 -a) tf=libc.tmp; tc="[0]"; tdc=[];;
2460 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
2461 esac;
2462 tx=yes;
2463 case "$reuseval-$4" in
2464 true-) ;;
2465 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
2466 esac;
2467 case "$tx" in
2468 yes)
2469         case "$runnm" in
2470         true)
2471                 if $contains $tlook $tf >/dev/null 2>&1;
2472                 then tval=true;
2473                 else tval=false;
2474                 fi;;
2475         *)
2476                 echo "main() { extern int $1$tdc; printf(\"%d\", $1$tc); }" > t.c;
2477                 if $cc $ccflags -o t t.c $ldflags $libs >/dev/null 2>&1;
2478                 then tval=true;
2479                 else tval=false;
2480                 fi;
2481                 $rm -f t t.c;;
2482         esac;;
2483 *)
2484         case "$tval" in
2485         $define) tval=true;;
2486         *) tval=false;;
2487         esac;;
2488 esac;
2489 eval "$2=$tval"'
2490
2491 : set up the script used to warn in case of inconsistency
2492 cat <<'EOSC' >whoa
2493 dflt=y
2494 echo " "
2495 echo "*** WHOA THERE!!! ***" >&4
2496 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2497 rp="    Keep the $hint value?"
2498 . ./myread
2499 case "$ans" in
2500 y) td=$was; tu=$was;;
2501 esac
2502 EOSC
2503
2504 : define an is-in-libc? function
2505 inlibc='echo " "; td=$define; tu=$undef;
2506 sym=$1; var=$2; eval "was=\$$2";
2507 tx=yes;
2508 case "$reuseval$was" in
2509 true) ;;
2510 true*) tx=no;;
2511 esac;
2512 case "$tx" in
2513 yes)
2514         set $sym tres -f;
2515         eval $csym;
2516         case "$tres" in
2517         true)
2518                 echo "$sym() found." >&4;
2519                 case "$was" in $undef) . whoa; esac; eval "$var=\$td";;
2520         *)
2521                 echo "$sym() NOT found." >&4;
2522                 case "$was" in $define) . whoa; esac; eval "$var=\$tu";;
2523         esac;;
2524 *)
2525         case "$was" in
2526         $define) echo "$sym() found." >&4;;
2527         *) echo "$sym() NOT found." >&4;;
2528         esac;;
2529 esac'
2530
2531 : see how we invoke the C preprocessor
2532 echo " "
2533 echo "Now, how can we feed standard input to your C preprocessor..." >&4
2534 cat <<'EOT' >testcpp.c
2535 #define ABC abc
2536 #define XYZ xyz
2537 ABC.XYZ
2538 EOT
2539 cd ..
2540 echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
2541 chmod 755 cppstdin
2542 wrapper=`pwd`/cppstdin
2543 ok='false'
2544 cd UU
2545
2546 if $test "X$cppstdin" != "X" && \
2547         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
2548         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
2549 then
2550         echo "You used to use $cppstdin $cppminus so we'll use that again."
2551         case "$cpprun" in
2552         '') echo "But let's see if we can live without a wrapper..." ;;
2553         *)
2554                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
2555                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
2556                 then
2557                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
2558                         ok='true'
2559                 else
2560                         echo "(However, $cpprun $cpplast does not work, let's see...)"
2561                 fi
2562                 ;;
2563         esac
2564 else
2565         case "$cppstdin" in
2566         '') ;;
2567         *)
2568                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
2569                 ;;
2570         esac
2571 fi
2572
2573 if $ok; then
2574         : nothing
2575 elif echo 'Maybe "'"$cc"' -E" will work...'; \
2576         $cc -E <testcpp.c >testcpp.out 2>&1; \
2577         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2578         echo "Yup, it does."
2579         x_cpp="$cc -E"
2580         x_minus='';
2581 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
2582         $cc -E - <testcpp.c >testcpp.out 2>&1; \
2583         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2584         echo "Yup, it does."
2585         x_cpp="$cc -E"
2586         x_minus='-';
2587 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
2588         $cc -P <testcpp.c >testcpp.out 2>&1; \
2589         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2590         echo "Yipee, that works!"
2591         x_cpp="$cc -P"
2592         x_minus='';
2593 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
2594         $cc -P - <testcpp.c >testcpp.out 2>&1; \
2595         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2596         echo "At long last!"
2597         x_cpp="$cc -P"
2598         x_minus='-';
2599 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
2600         $cpp <testcpp.c >testcpp.out 2>&1; \
2601         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2602         echo "It works!"
2603         x_cpp="$cpp"
2604         x_minus='';
2605 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
2606         $cpp - <testcpp.c >testcpp.out 2>&1; \
2607         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2608         echo "Hooray, it works!  I was beginning to wonder."
2609         x_cpp="$cpp"
2610         x_minus='-';
2611 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
2612         $wrapper <testcpp.c >testcpp.out 2>&1; \
2613         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2614         x_cpp="$wrapper"
2615         x_minus=''
2616         echo "Eureka!"
2617 else
2618         dflt=''
2619         rp="No dice.  I can't find a C preprocessor.  Name one:"
2620         . ./myread
2621         x_cpp="$ans"
2622         x_minus=''
2623         $x_cpp <testcpp.c >testcpp.out 2>&1
2624         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2625                 echo "OK, that will do." >&4
2626         else
2627 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
2628                 exit 1
2629         fi
2630 fi
2631
2632 case "$ok" in
2633 false)
2634         cppstdin="$x_cpp"
2635         cppminus="$x_minus"
2636         cpprun="$x_cpp"
2637         cpplast="$x_minus"
2638         set X $x_cpp
2639         shift
2640         case "$1" in
2641         "$cpp")
2642                 echo "Perhaps can we force $cc -E using a wrapper..."
2643                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
2644                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
2645                 then
2646                         echo "Yup, we can."
2647                         cppstdin="$wrapper"
2648                         cppminus='';
2649                 else
2650                         echo "Nope, we'll have to live without it..."
2651                 fi
2652                 ;;
2653         esac
2654         case "$cpprun" in
2655         "$wrapper")
2656                 cpprun=''
2657                 cpplast=''
2658                 ;;
2659         esac
2660         ;;
2661 esac
2662
2663 case "$cppstdin" in
2664 "$wrapper") ;;
2665 *) $rm -f $wrapper;;
2666 esac
2667 $rm -f testcpp.c testcpp.out
2668
2669 : determine filename position in cpp output
2670 echo " "
2671 echo "Computing filename position in cpp output for #include directives..." >&4
2672 echo '#include <stdio.h>' > foo.c
2673 $cat >fieldn <<EOF
2674 $startsh
2675 $cppstdin $cppminus $cppflags <foo.c 2>/dev/null | \
2676 $grep '^[       ]*#.*stdio\.h' | \
2677 while read cline; do
2678         pos=1
2679         set \$cline
2680         while $test \$# -gt 0; do
2681                 if $test -r \`echo \$1 | $tr -d '"'\`; then
2682                         echo "\$pos"
2683                         exit 0
2684                 fi
2685                 shift
2686                 pos=\`expr \$pos + 1\`
2687         done
2688 done
2689 EOF
2690 chmod +x fieldn
2691 fieldn=`./fieldn`
2692 $rm -f foo.c fieldn
2693 case $fieldn in
2694 '') pos='???';;
2695 1) pos=first;;
2696 2) pos=second;;
2697 3) pos=third;;
2698 *) pos="${fieldn}th";;
2699 esac
2700 echo "Your cpp writes the filename in the $pos field of the line."
2701
2702 : locate header file
2703 $cat >findhdr <<EOF
2704 $startsh
2705 wanted=\$1
2706 name=''
2707 if test -f $usrinc/\$wanted; then
2708         echo "$usrinc/\$wanted"
2709         exit 0
2710 fi
2711 awkprg='{ print \$$fieldn }'
2712 echo "#include <\$wanted>" > foo\$\$.c
2713 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
2714 $grep "^[       ]*#.*\$wanted" | \
2715 while read cline; do
2716         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
2717         case "\$name" in
2718         */\$wanted) echo "\$name"; exit 0;;
2719         *) name='';;
2720         esac;
2721 done;
2722 $rm -f foo\$\$.c;
2723 case "\$name" in
2724 '') exit 1;;
2725 esac
2726 EOF
2727 chmod +x findhdr
2728
2729 : access call always available on UNIX
2730 set access d_access
2731 eval $inlibc
2732
2733 : locate the flags for 'access()'
2734 case "$d_access" in
2735 "$define")
2736         echo " "
2737         $cat >access.c <<'EOCP'
2738 #include <sys/types.h>
2739 #ifdef I_FCNTL
2740 #include <fcntl.h>
2741 #endif
2742 #ifdef I_SYS_FILE
2743 #include <sys/file.h>
2744 #endif
2745 #ifdef I_UNISTD
2746 #include <unistd.h>
2747 #endif
2748 main() {
2749         exit(R_OK);
2750 }
2751 EOCP
2752         : check sys/file.h first, no particular reason here
2753         if $test `./findhdr sys/file.h` && \
2754                 $cc $cppflags -DI_SYS_FILE access.c -o access >/dev/null 2>&1 ; then
2755                 h_sysfile=true;
2756                 echo "<sys/file.h> defines the *_OK access constants." >&4
2757         elif $test `./findhdr fcntl.h` && \
2758                 $cc $cppflags -DI_FCNTL access.c -o access >/dev/null 2>&1 ; then
2759                 h_fcntl=true;
2760                 echo "<fcntl.h> defines the *_OK access constants." >&4
2761         else
2762                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
2763         fi
2764         ;;
2765 esac
2766 $rm -f access*
2767
2768 : see if bcmp exists
2769 set bcmp d_bcmp
2770 eval $inlibc
2771
2772 : see if bcopy exists
2773 set bcopy d_bcopy
2774 eval $inlibc
2775
2776 : see if bzero exists
2777 set bzero d_bzero
2778 eval $inlibc
2779
2780 : check for length of integer
2781 echo " "
2782 case "$intsize" in
2783 '')
2784         echo "Checking to see how big your integers are..." >&4
2785         $cat >try.c <<'EOCP'
2786 #include <stdio.h>
2787 main()
2788 {
2789         printf("%d\n", sizeof(int));
2790 }
2791 EOCP
2792         if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
2793                 dflt=`./try`
2794         else
2795                 dflt='4'
2796                 echo "(I can't seem to compile the test program.  Guessing...)"
2797         fi
2798         ;;
2799 *)
2800         dflt="$intsize"
2801         ;;
2802 esac
2803 rp="What is the size of an integer (in bytes)?"
2804 . ./myread
2805 intsize="$ans"
2806 $rm -f try.c try
2807
2808 : function used to set $1 to $val
2809 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2810 case "$val$was" in
2811 $define$undef) . whoa; eval "$var=\$td";;
2812 $undef$define) . whoa; eval "$var=\$tu";;
2813 *) eval "$var=$val";;
2814 esac'
2815
2816 : check for ability to cast large floats to 32-bit ints.
2817 echo " "
2818 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
2819 if $test "$intsize" -ge 4; then
2820     xxx=int
2821 else
2822     xxx=long
2823 fi
2824
2825 $cat >try.c <<EOCP
2826 #include <sys/types.h>
2827 #include <signal.h>
2828 blech() { exit(3); }
2829 main()
2830 {
2831         $xxx i32;
2832         double f;
2833         int result = 0;
2834         signal(SIGFPE, blech);
2835
2836         f = (double) 0x7fffffff;
2837         f = 10 * f;
2838         i32  = ( $xxx )f;
2839
2840         if (i32 != ( $xxx )f)
2841                 result |= 1;
2842         exit(result);
2843 }
2844 EOCP
2845 if $cc -o try $ccflags try.c >/dev/null 2>&1; then
2846         ./try
2847         yyy=$?
2848 else
2849         yyy=1
2850 fi
2851 case "$yyy" in
2852 0)      val="$define"
2853         echo "Yup, it can."
2854         ;;
2855 *)      val="$undef"
2856         echo "Nope, it can't."
2857         ;;
2858 esac
2859 set d_casti32
2860 eval $setvar
2861 $rm -f try.*
2862 : check for ability to cast negative floats to unsigned
2863 echo " "
2864 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
2865 $cat >try.c <<'EOCP'
2866 #include <signal.h>
2867 blech() { exit(3); }
2868 main()
2869 {
2870         double f = -123;
2871         unsigned long along;
2872         unsigned int aint;
2873         unsigned short ashort;
2874         int result = 0;
2875
2876         signal(SIGFPE, blech);
2877         along = (unsigned long)f;
2878         aint = (unsigned int)f;
2879         ashort = (unsigned short)f;
2880         if (along != (unsigned long)-123)
2881                 result |= 1;
2882         if (aint != (unsigned int)-123)
2883                 result |= 1;
2884         if (ashort != (unsigned short)-123)
2885                 result |= 1;
2886         f = (double)0x40000000;
2887         f = f + f;
2888         along = 0;
2889         along = (unsigned long)f;
2890         if (along != 0x80000000)
2891                 result |= 2;
2892         f -= 1.;
2893         along = 0;
2894         along = (unsigned long)f;
2895         if (along != 0x7fffffff)
2896                 result |= 1;
2897         f += 2.;
2898         along = 0;
2899         along = (unsigned long)f;
2900         if (along != 0x80000001)
2901                 result |= 2;
2902         exit(result);
2903
2904 }
2905 EOCP
2906 if $cc -o try $ccflags try.c >/dev/null 2>&1; then
2907         ./try
2908         castflags=$?
2909 else
2910         castflags=3
2911 fi
2912 case "$castflags" in
2913 0)      val="$define"
2914         echo "Yup, it can."
2915         ;;
2916 *)      val="$undef"
2917         echo "Nope, it can't."
2918         ;;
2919 esac
2920 set d_castneg
2921 eval $setvar
2922 $rm -f try.*
2923
2924 : see if sprintf is declared as int or pointer to char
2925 echo " "
2926 $cat >ucbsprf.c <<'EOF'
2927 main()
2928 {
2929         int sprintf();
2930         char buf[10];
2931         exit((unsigned long)sprintf(buf,"%s","foo") > 10L);
2932 }
2933 EOF
2934 if $cc ucbsprf.c -o ucbsprf >/dev/null 2>&1 && ./ucbsprf; then
2935         echo "Your sprintf() returns (int)." >&4
2936         val="$undef"
2937 else
2938         echo "Your sprintf() returns (char*)." >&4
2939         val="$define"
2940 fi
2941 set d_charsprf
2942 eval $setvar
2943 $rm -f ucbsprf*
2944
2945 : see if vprintf exists
2946 echo " "
2947 if set vprintf val -f d_vprintf; eval $csym; $val; then
2948         echo 'vprintf() found.' >&4
2949         val="$define"
2950         $cat >vprintf.c <<'EOF'
2951 #include <varargs.h>
2952
2953 main() { xxx("foo"); }
2954
2955 xxx(va_alist)
2956 va_dcl
2957 {
2958         va_list args;
2959         char buf[10];
2960
2961         va_start(args);
2962         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
2963 }
2964 EOF
2965         if $cc $ccflags vprintf.c -o vprintf >/dev/null 2>&1 && ./vprintf; then
2966                 echo "Your vsprintf() returns (int)." >&4
2967                 val2="$undef"
2968         else
2969                 echo "Your vsprintf() returns (char*)." >&4
2970                 val2="$define"
2971         fi
2972 else
2973         echo 'vprintf() NOT found.' >&4
2974                 val="$undef"
2975                 val2="$undef"
2976 fi
2977 set d_vprintf
2978 eval $setvar
2979 val=$val2
2980 set d_charvspr
2981 eval $setvar
2982
2983 : see if chsize exists
2984 set chsize d_chsize
2985 eval $inlibc
2986
2987 : check for const keyword
2988 echo " "
2989 echo 'Checking to see if your C compiler knows about "const"...' >&4
2990 $cat >const.c <<'EOCP'
2991 typedef struct spug { int drokk; } spug;
2992 main()
2993 {
2994         const char *foo;
2995         const spug y;
2996 }
2997 EOCP
2998 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
2999         val="$define"
3000         echo "Yup, it does."
3001 else
3002         val="$undef"
3003         echo "Nope, it doesn't."
3004 fi
3005 set d_const
3006 eval $setvar
3007
3008 : see if crypt exists
3009 echo " "
3010 if set crypt val -f d_crypt; eval $csym; $val; then
3011         echo 'crypt() found.' >&4
3012         val="$define"
3013         cryptlib=''
3014 else
3015         cryptlib=`./loc Slibcrypt.a "" $xlibpth`
3016         if $test -z "$cryptlib"; then
3017                 cryptlib=`./loc Mlibcrypt.a "" $xlibpth`
3018         else
3019                 cryptlib=-lcrypt
3020         fi
3021         if $test -z "$cryptlib"; then
3022                 cryptlib=`./loc Llibcrypt.a "" $xlibpth`
3023         else
3024                 cryptlib=-lcrypt
3025         fi
3026         if $test -z "$cryptlib"; then
3027                 cryptlib=`./loc libcrypt.a "" $libpth`
3028         else
3029                 cryptlib=-lcrypt
3030         fi
3031         if $test -z "$cryptlib"; then
3032                 echo 'crypt() NOT found.' >&4
3033                 val="$undef"
3034         else
3035                 val="$define"
3036         fi
3037 fi
3038 set d_crypt
3039 eval $setvar
3040
3041 : get csh whereabouts
3042 case "$csh" in
3043 'csh') val="$undef" ;;
3044 *) val="$define" ;;
3045 esac
3046 set d_csh
3047 eval $setvar
3048
3049 : see if this is a dirent system
3050 echo " "
3051 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
3052         val="$define"
3053         echo "<dirent.h> found." >&4
3054 else
3055         val="$undef"
3056         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
3057                 echo "<sys/dir.h> found." >&4
3058                 echo " "
3059         else
3060                 xinc=`./findhdr sys/ndir.h`
3061         fi
3062         echo "<dirent.h> NOT found." >&4
3063 fi
3064 set i_dirent
3065 eval $setvar
3066
3067 : see if the directory entry stores field length
3068 echo " "
3069 if $contains 'd_namlen' $xinc >/dev/null 2>&1; then
3070         echo "Good, your directory entry keeps length information in d_namlen." >&4
3071         val="$define"
3072 else
3073         echo "Your directory entry does not know about the d_namlen field." >&4
3074         val="$undef"
3075 fi
3076 set d_dirnamlen
3077 eval $setvar
3078
3079 : now see if they want to do setuid emulation
3080 case "$d_dosuid" in
3081 '') dflt=n;;
3082 "$undef") dflt=n;;
3083 *) dflt=y;;
3084 esac
3085 cat <<EOM
3086  
3087 Some sites have disabled setuid #! scripts because of a bug in the kernel
3088 that prevents them from being secure.  If you are on such a system, the
3089 setuid/setgid bits on scripts are currently useless.  It is possible for
3090 $package to detect those bits and emulate setuid/setgid in a secure fashion
3091 until a better solution is devised for the kernel problem.
3092
3093 EOM
3094 rp="Do you want to do setuid/setgid emulation?"
3095 . ./myread
3096 case "$ans" in
3097 y*)  d_dosuid="$define";;
3098 *) d_dosuid="$undef";;
3099 esac
3100
3101 : see if dup2 exists
3102 set dup2 d_dup2
3103 eval $inlibc
3104
3105 : see if fchmod exists
3106 set fchmod d_fchmod
3107 eval $inlibc
3108
3109 : see if fchown exists
3110 set fchown d_fchown
3111 eval $inlibc
3112
3113 : see if this is an fcntl system
3114 set fcntl d_fcntl
3115 eval $inlibc
3116
3117 : see if we can have long filenames
3118 echo " "
3119 rmlist="$rmlist /tmp/cf$$"
3120 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
3121 first=123456789abcdef
3122 second=/tmp/cf$$/$first
3123 $rm -f $first $second
3124 if (echo hi >$first) 2>/dev/null; then
3125         if $test -f 123456789abcde; then
3126                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
3127                 val="$undef"
3128         else
3129                 if (echo hi >$second) 2>/dev/null; then
3130                         if $test -f /tmp/cf$$/123456789abcde; then
3131                                 $cat <<'EOM'
3132 That's peculiar... You can have filenames longer than 14 characters, but only
3133 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
3134 I shall consider your system cannot support long filenames at all.
3135 EOM
3136                                 val="$undef"
3137                         else
3138                                 echo 'You can have filenames longer than 14 characters.' >&4
3139                                 val="$define"
3140                         fi
3141                 else
3142                         $cat <<'EOM'
3143 How confusing! Some of your filesystems are sane enough to allow filenames
3144 longer than 14 characters but some others like /tmp can't even think about them.
3145 So, for now on, I shall assume your kernel does not allow them at all.
3146 EOM
3147                         val="$undef"
3148                 fi
3149         fi
3150 else
3151         $cat <<'EOM'
3152 You can't have filenames longer than 14 chars.  You can't even think about them!
3153 EOM
3154         val="$undef"
3155 fi 
3156 set d_flexfnam
3157 eval $setvar
3158 $rm -rf /tmp/cf$$ 123456789abcde*
3159
3160 : see if flock exists
3161 set flock d_flock
3162 eval $inlibc
3163
3164 : see if gethostent exists
3165 set gethostent d_gethent
3166 eval $inlibc
3167
3168 : see if getpgrp exists
3169 set getpgrp d_getpgrp
3170 eval $inlibc
3171
3172 : see if getpgrp2 exists
3173 set getpgrp2 d_getpgrp2
3174 eval $inlibc
3175
3176 : see if getpriority exists
3177 set getpriority d_getprior
3178 eval $inlibc
3179
3180 : see if htonl --and friends-- exists
3181 set htonl d_htonl
3182 eval $inlibc
3183
3184 : Look for isascii
3185 echo " "
3186 $cat >isascii.c <<'EOCP'
3187 #include <stdio.h>
3188 #include <ctype.h>
3189 main() {
3190         int c = 'A';
3191         if (isascii(c))
3192             exit(0);
3193         else
3194             exit(1);
3195 }
3196 EOCP
3197 if $cc $cppflags -o isascii isascii.c >/dev/null 2>&1 ; then
3198     echo "isascii() found."
3199     val="$define"
3200 else
3201     echo "isascii() NOT found."
3202     val="$undef"
3203 fi
3204 set d_isascii
3205 eval $setvar
3206 $rm -f isascii*
3207 : see if killpg exists
3208 set killpg d_killpg
3209 eval $inlibc
3210
3211 : see if link exists
3212 set link d_link
3213 eval $inlibc
3214
3215 : see if lstat exists
3216 set lstat d_lstat
3217 eval $inlibc
3218
3219 : see if memcmp exists
3220 set memcmp d_memcmp
3221 eval $inlibc
3222
3223 : see if memcpy exists
3224 set memcpy d_memcpy
3225 eval $inlibc
3226
3227 : see if memmove exists
3228 set memmove d_memmove
3229 eval $inlibc
3230
3231 : see if memset exists
3232 set memset d_memset
3233 eval $inlibc
3234
3235 : see if mkdir exists
3236 set mkdir d_mkdir
3237 eval $inlibc
3238
3239 : see if msgctl exists
3240 set msgctl d_msgctl
3241 eval $inlibc
3242
3243 : see if msgget exists
3244 set msgget d_msgget
3245 eval $inlibc
3246
3247 : see if msgsnd exists
3248 set msgsnd d_msgsnd
3249 eval $inlibc
3250
3251 : see if msgrcv exists
3252 set msgrcv d_msgrcv
3253 eval $inlibc
3254
3255 : see how much of the 'msg*(2)' library is present.
3256 h_msg=true
3257 echo " "
3258 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
3259 *"$undef"*) h_msg=false;;
3260 esac
3261 : we could also check for sys/ipc.h ...
3262 if $h_msg && $test `./findhdr sys/msg.h`; then
3263         echo "You have the full msg*(2) library." >&4
3264         val="$define"
3265 else
3266         echo "You don't have the full msg*(2) library." >&4
3267         val="$undef"
3268 fi
3269 set d_msg
3270 eval $setvar
3271
3272 socketlib=''
3273 sockethdr=''
3274 : see whether socket exists
3275 echo " "
3276 $echo $n "Hmm... $c" >&4
3277 if set socket val -f d_socket; eval $csym; $val; then
3278         echo "Looks like you have Berkeley networking support." >&4
3279         d_socket="$define"
3280         if set setsockopt val -f; eval $csym; $val; then
3281                 d_oldsock="$undef"
3282         else
3283                 echo "...but it uses the old 4.1c interface, rather than 4.2" >&4
3284                 d_oldsock="$define"
3285         fi
3286 else
3287         if $contains socklib libc.list >/dev/null 2>&1; then
3288                 echo "Looks like you have Berkeley networking support." >&4
3289                 d_socket="$define"
3290                 : we will have to assume that it supports the 4.2 BSD interface
3291                 d_oldsock="$undef"
3292         else
3293                 echo "You don't have Berkeley networking in libc.a..." >&4
3294                 if test -f /usr/lib/libnet.a; then
3295                         ( (nm $nm_opt /usr/lib/libnet.a | eval $nm_extract) ||  \
3296                         ar t /usr/lib/libnet.a) 2>/dev/null >> libc.list
3297                         if $contains socket libc.list >/dev/null 2>&1; then
3298                         echo "...but the Wollongong group seems to have hacked it in." >&4
3299                                 socketlib="-lnet"
3300                                 sockethdr="-I/usr/netinclude"
3301                                 d_socket="$define"
3302                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
3303                                         d_oldsock="$undef"
3304                                 else
3305                                         echo "...using the old 4.1c interface, rather than 4.2" >&4
3306                                         d_oldsock="$define"
3307                                 fi
3308                         else
3309                                 echo "or even in libnet.a, which is peculiar." >&4
3310                                 d_socket="$undef"
3311                                 d_oldsock="$undef"
3312                         fi
3313                 else
3314                         echo "or anywhere else I see." >&4
3315                         d_socket="$undef"
3316                         d_oldsock="$undef"
3317                 fi
3318         fi
3319 fi
3320
3321 : see if socketpair exists
3322 set socketpair d_sockpair
3323 eval $inlibc
3324
3325 : Locate the flags for 'open()'
3326 echo " "
3327 $cat >open3.c <<'EOCP'
3328 #include <sys/types.h>
3329 #ifdef I_FCNTL
3330 #include <fcntl.h>
3331 #endif
3332 #ifdef I_SYS_FILE
3333 #include <sys/file.h>
3334 #endif
3335 main() {
3336         if(O_RDONLY);
3337 #ifdef O_TRUNC
3338         exit(0);
3339 #else
3340         exit(1);
3341 #endif
3342 }
3343 EOCP
3344 : check sys/file.h first to get FREAD on Sun
3345 if $test `./findhdr sys/file.h` && \
3346                 $cc $cppflags "-DI_SYS_FILE" open3.c -o open3 >/dev/null 2>&1 ; then
3347         h_sysfile=true;
3348         echo "<sys/file.h> defines the O_* constants..." >&4
3349         if ./open3; then
3350                 echo "and you have the 3 argument form of open()." >&4
3351                 val="$define"
3352         else
3353                 echo "but not the 3 argument form of open().  Oh, well." >&4
3354                 val="$undef"
3355         fi
3356 elif $test `./findhdr fcntl.h` && \
3357                 $cc "-DI_FCNTL" open3.c -o open3 >/dev/null 2>&1 ; then
3358         h_fcntl=true;
3359         echo "<fcntl.h> defines the O_* constants..." >&4
3360         if ./open3; then
3361                 echo "and you have the 3 argument form of open()." >&4
3362                 val="$define"
3363         else
3364                 echo "but not the 3 argument form of open().  Oh, well." >&4
3365                 val="$undef"
3366         fi
3367 else
3368         val="$undef"
3369         echo "I can't find the O_* constant definitions!  You got problems." >&4
3370 fi
3371 set d_open3
3372 eval $setvar
3373 $rm -f open3*
3374
3375 : see if this is a pwd system
3376 echo " "
3377 xxx=`./findhdr pwd.h`
3378 if $test "$xxx"; then
3379         i_pwd="$define"
3380         echo "<pwd.h> found." >&4
3381         $cppstdin $cppflags < $xxx >$$.h
3382         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
3383                 d_pwquota="$define"
3384         else
3385                 d_pwquota="$undef"
3386         fi
3387         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
3388                 d_pwage="$define"
3389         else
3390                 d_pwage="$undef"
3391         fi
3392         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
3393                 d_pwchange="$define"
3394         else
3395                 d_pwchange="$undef"
3396         fi
3397         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
3398                 d_pwclass="$define"
3399         else
3400                 d_pwclass="$undef"
3401         fi
3402         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
3403                 d_pwexpire="$define"
3404         else
3405                 d_pwexpire="$undef"
3406         fi
3407         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
3408                 d_pwcomment="$define"
3409         else
3410                 d_pwcomment="$undef"
3411         fi
3412         $rm -f $$.h
3413 else
3414         i_pwd="$undef"
3415         d_pwquota="$undef"
3416         d_pwage="$undef"
3417         d_pwchange="$undef"
3418         d_pwclass="$undef"
3419         d_pwexpire="$undef"
3420         d_pwcomment="$undef"
3421         echo "<pwd.h> NOT found." >&4
3422 fi
3423
3424 : see if readdir exists
3425 set readdir d_readdir
3426 eval $inlibc
3427
3428 : see if rename exists
3429 set rename d_rename
3430 eval $inlibc
3431
3432 : see if rmdir exists
3433 set rmdir d_rmdir
3434 eval $inlibc
3435
3436 : can bcopy handle overlapping blocks?
3437 val="$undef"
3438 case "$d_bcopy" in
3439 "$define")
3440         echo " "
3441         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
3442         $cat >foo.c <<'EOCP'
3443 main()
3444 {
3445 char buf[128];
3446 register char *b;
3447 register int len;
3448 register int off;
3449 register int align;
3450
3451 for (align = 7; align >= 0; align--) {
3452         for (len = 36; len; len--) {
3453                 b = buf+align;
3454                 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", b, len);
3455                 for (off = 1; off <= len; off++) {
3456                         bcopy(b, b+off, len);
3457                         bcopy(b+off, b, len);
3458                         if (bcmp(b, "abcdefghijklmnopqrstuvwxyz0123456789", len))
3459                                 exit(1);
3460                 }
3461         }
3462 }
3463 exit(0);
3464 }
3465 EOCP
3466         if $cc foo.c -o safebcpy $ccflags $libs >/dev/null 2>&1 ; then
3467                 if ./safebcpy 2>/dev/null; then
3468                         echo "Yes, it can."
3469                         val="$define"
3470                 else
3471                         echo "It can't, sorry."
3472                 fi
3473         else
3474                 echo "(I can't compile the test program, so we'll assume not...)"
3475         fi
3476         ;;
3477 esac
3478 $rm -f foo.* safebcpy core
3479 set d_safebcpy
3480 eval $setvar
3481
3482 : can memcpy handle overlapping blocks?
3483 val="$undef"
3484 case "$d_memcpy" in
3485 "$define")
3486         echo " "
3487         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
3488         $cat >foo.c <<'EOCP'
3489 main()
3490 {
3491 char buf[128];
3492 register char *b;
3493 register int len;
3494 register int off;
3495 register int align;
3496
3497 for (align = 7; align >= 0; align--) {
3498         for (len = 36; len; len--) {
3499                 b = buf+align;
3500                 memcpy("abcdefghijklmnopqrstuvwxyz0123456789", b, len);
3501                 for (off = 1; off <= len; off++) {
3502                         memcpy(b, b+off, len);
3503                         memcpy(b+off, b, len);
3504                         if (memcmp(b, "abcdefghijklmnopqrstuvwxyz0123456789", len))
3505                                 exit(1);
3506                 }
3507         }
3508 }
3509 exit(0);
3510 }
3511 EOCP
3512         if $cc foo.c -o safemcpy $ccflags $libs >/dev/null 2>&1 ; then
3513                 if ./safemcpy 2>/dev/null; then
3514                         echo "Yes, it can."
3515                         val="$define"
3516                 else
3517                         echo "It can't, sorry."
3518                 fi
3519         else
3520                 echo "(I can't compile the test program, so we'll assume not...)"
3521         fi
3522         ;;
3523 esac
3524 $rm -f foo.* safemcpy core
3525 set d_safemcpy
3526 eval $setvar
3527
3528 : see if select exists
3529 set select d_select
3530 eval $inlibc
3531
3532 : see if semctl exists
3533 set semctl d_semctl
3534 eval $inlibc
3535
3536 : see if semget exists
3537 set semget d_semget
3538 eval $inlibc
3539
3540 : see if semop exists
3541 set semop d_semop
3542 eval $inlibc
3543
3544 : see how much of the 'sem*(2)' library is present.
3545 h_sem=true
3546 echo " "
3547 case "$d_semctl$d_semget$d_semop" in
3548 *"$undef"*) h_sem=false;;
3549 esac
3550 : we could also check for sys/ipc.h ...
3551 if $h_sem && $test `./findhdr sys/sem.h`; then
3552         echo "You have the full sem*(2) library." >&4
3553         val="$define"
3554 else
3555         echo "You don't have the full sem*(2) library." >&4
3556         val="$undef"
3557 fi
3558 set d_sem
3559 eval $setvar
3560
3561 : see if setegid exists
3562 set setegid d_setegid
3563 eval $inlibc
3564
3565 : see if seteuid exists
3566 set seteuid d_seteuid
3567 eval $inlibc
3568
3569 : see if setlocale exists
3570 set setlocale d_setlocale
3571 eval $inlibc
3572 : see if setpgid exists
3573 set setpgid d_setpgid
3574 eval $inlibc
3575
3576 : see if setpgrp exists
3577 set setpgrp d_setpgrp
3578 eval $inlibc
3579
3580 : see if setpgrp2 exists
3581 set setpgrp2 d_setpgrp2
3582 eval $inlibc
3583
3584 : see if setpriority exists
3585 set setpriority d_setprior
3586 eval $inlibc
3587
3588 : see if setregid exists
3589 set setregid d_setregid
3590 eval $inlibc
3591 set setresgid d_setresgid
3592 eval $inlibc
3593
3594 : see if setreuid exists
3595 set setreuid d_setreuid
3596 eval $inlibc
3597 set setresuid d_setresuid
3598 eval $inlibc
3599
3600 : see if setrgid exists
3601 set setrgid d_setrgid
3602 eval $inlibc
3603
3604 : see if setruid exists
3605 set setruid d_setruid
3606 eval $inlibc
3607
3608 : see if setsid exists
3609 set setsid d_setsid
3610 eval $inlibc
3611
3612 : see if shmctl exists
3613 set shmctl d_shmctl
3614 eval $inlibc
3615
3616 : see if shmget exists
3617 set shmget d_shmget
3618 eval $inlibc
3619
3620 : see if shmat exists
3621 set shmat d_shmat
3622 eval $inlibc
3623
3624 : see if shmdt exists
3625 set shmdt d_shmdt
3626 eval $inlibc
3627
3628 : see how much of the 'shm*(2)' library is present.
3629 h_shm=true
3630 echo " "
3631 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
3632 *"$undef"*) h_shm=false;;
3633 esac
3634 : we could also check for sys/ipc.h ...
3635 if $h_shm && $test `./findhdr sys/shm.h`; then
3636         echo "You have the full shm*(2) library." >&4
3637         val="$define"
3638 else
3639         echo "You don't have the full shm*(2) library." >&4
3640         val="$undef"
3641 fi
3642 set d_shm
3643 eval $setvar
3644
3645 : see if stat knows about block sizes
3646 echo " "
3647 xxx=`./findhdr sys/stat.h`
3648 if $contains 'st_blocks;' "$xxx" >/dev/null 2>&1 ; then
3649         if $contains 'st_blksize;' "$xxx" >/dev/null 2>&1 ; then
3650                 echo "Your stat() knows about block sizes." >&4
3651                 val="$define"
3652         else
3653                 echo "Your stat() doesn't know about block sizes." >&4
3654                 val="$undef"
3655         fi
3656 else
3657         echo "Your stat() doesn't know about block sizes." >&4
3658         val="$undef"
3659 fi
3660 set d_statblks
3661 eval $setvar
3662
3663 : see if stdio is really std
3664 echo " "
3665 xxx=`./findhdr stdio.h`
3666 if $contains 'char.*_ptr;' "$xxx" >/dev/null 2>&1 ; then
3667         if $contains '_cnt;' "$xxx" >/dev/null 2>&1 ; then
3668                 echo "Your stdio is pretty std." >&4
3669                 val="$define"
3670         else
3671                 echo "Your stdio isn't very std." >&4
3672                 val="$undef"
3673         fi
3674 else
3675         echo "Your stdio isn't very std." >&4
3676         val="$undef"
3677 fi
3678 set d_stdstdio
3679 eval $setvar
3680
3681 : see which of string.h or strings.h is needed
3682 echo " "
3683 strings=`./findhdr string.h`
3684 if $test "$strings" && $test -r "$strings"; then
3685         echo "Using <string.h> instead of <strings.h>." >&4
3686         val="$define"
3687 else
3688         val="$undef"
3689         strings=`./findhdr strings.h`
3690         if $test "$strings" && $test -r "$strings"; then
3691                 echo "Using <strings.h> instead of <string.h>." >&4
3692         else
3693                 echo "No string header found -- You'll surely have problems." >&4
3694         fi
3695 fi
3696 set i_string
3697 eval $setvar
3698 case "$i_string" in
3699 "$undef") strings=`./findhdr strings.h`;;
3700 *)        strings=`./findhdr string.h`;;
3701 esac
3702
3703 : index or strchr
3704 echo " "
3705 if set index val -f; eval $csym; $val; then
3706         if set strchr val -f d_strchr; eval $csym; $val; then
3707                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
3708                         val="$define"
3709                         vali="$undef"
3710                         echo "strchr() found." >&4
3711                 else
3712                         val="$undef"
3713                         vali="$define"
3714                         echo "index() found." >&4
3715                 fi
3716         else
3717                 val="$undef"
3718                 vali="$define"
3719                 echo "index() found." >&4
3720         fi
3721 else
3722         if set strchr val -f d_strchr; eval $csym; $val; then
3723                 val="$define"
3724                 vali="$undef"
3725                 echo "strchr() found." >&4
3726         else
3727                 echo "No index() or strchr() found!" >&4
3728                 val="$undef"
3729                 vali="$undef"
3730         fi
3731 fi
3732 set d_strchr; eval $setvar
3733 val="$vali"
3734 set d_index; eval $setvar
3735
3736 : check for structure copying
3737 echo " "
3738 echo "Checking to see if your C compiler can copy structs..." >&4
3739 $cat >try.c <<'EOCP'
3740 main()
3741 {
3742         struct blurfl {
3743                 int dyick;
3744         } foo, bar;
3745
3746         foo = bar;
3747 }
3748 EOCP
3749 if $cc -c try.c >/dev/null 2>&1 ; then
3750         val="$define"
3751         echo "Yup, it can."
3752 else
3753         val="$undef"
3754         echo "Nope, it can't."
3755 fi
3756 set d_strctcpy
3757 eval $setvar
3758 $rm -f try.*
3759
3760 : see if strerror and/or sys_errlist[] exist
3761 echo " "
3762 if set strerror val -f d_strerror; eval $csym; $val; then
3763         echo 'strerror() found.' >&4
3764         d_strerror="$define"
3765         d_strerrm="$undef"
3766         if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
3767                 echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
3768                 d_syserrlst="$define"
3769         else
3770         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
3771                 d_syserrlst="$undef"
3772         fi
3773 elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
3774         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
3775         echo 'strerror() found in string header.' >&4
3776         d_strerror="$define"
3777         d_strerrm="$undef"
3778         if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
3779                 echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
3780                 d_syserrlst="$define"
3781         else
3782                 echo "(You don't appear to have any sys_errlist[], how can this be?)"
3783                 d_syserrlst="$undef"
3784         fi
3785 elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
3786 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
3787         d_strerror="$undef"
3788         d_syserrlst="$define"
3789         d_strerrm="$define"
3790 else
3791         echo 'strerror() and sys_errlist[] NOT found.' >&4
3792         d_strerror="$undef"
3793         d_syserrlst="$undef"
3794         d_strerrm="$undef"
3795 fi
3796
3797 : see if symlink exists
3798 set symlink d_symlink
3799 eval $inlibc
3800
3801 : see if syscall exists
3802 set syscall d_syscall
3803 eval $inlibc
3804
3805 : see if system exists
3806 set system d_system
3807 eval $inlibc
3808
3809 : see if times exists
3810 echo " "
3811 if set times val -f d_times; eval $csym; $val; then
3812         echo 'times() found.' >&4
3813         d_times="$define"
3814         case "$clocktype" in
3815         '')
3816                 if $contains 'clock_t;' `./findhdr sys/types.h` >/dev/null 2>&1 ; then
3817                         dflt='clock_t';
3818                 elif $contains 'clock_t;' `./findhdr sys/times.h` >/dev/null 2>&1; then
3819                         dflt='clock_t';
3820                 else
3821                         dflt='long';
3822                 fi
3823                 ;;
3824         *)  dflt="$clocktype"
3825                 ;;
3826         esac
3827         echo " "
3828         rp="What type is returned by times() on this sytem?"
3829         . ./myread
3830         clocktype="$ans"
3831 else
3832         echo 'times() not found, hope that will do.' >&4
3833         d_times="$undef"
3834         clocktype='int'
3835 fi
3836
3837 : see if truncate exists
3838 set truncate d_truncate
3839 eval $inlibc
3840
3841 : see if we have to deal with yellow pages, now NIS.
3842 if $test -d /usr/etc/yp || $test -d /etc/yp; then
3843         if $test -f /usr/etc/nibindd; then
3844                 echo " "
3845                 echo "I'm fairly confident you're on a NeXT."
3846                 echo " "
3847                 rp='Do you get the hosts file via NetInfo?'
3848                 dflt=y
3849                 case "$hostcat" in
3850                 nidump*) ;;
3851                 '') ;;
3852                 *) dflt=n;;
3853                 esac
3854                 . ./myread
3855                 case "$ans" in
3856                 y*) hostcat='nidump hosts .';;
3857                 *) hostcat='cat /etc/hosts';;
3858                 esac
3859         fi
3860         case "$hostcat" in
3861         nidump*) ;;
3862         *)
3863                 case "$hostcat" in
3864                 *ypcat*) dflt=y;;
3865                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
3866                                 dflt=y
3867                         else
3868                                 dflt=n
3869                         fi;;
3870                 *) dflt=n;;
3871                 esac
3872                 echo " "
3873                 rp='Are you getting the hosts file via yellow pages?'
3874                 . ./myread
3875                 case "$ans" in
3876                 y*) hostcat='ypcat hosts';;
3877                 *) hostcat='cat /etc/hosts';;
3878                 esac
3879                 ;;
3880         esac
3881 fi
3882
3883 : now get the host name
3884 echo " "
3885 echo "Figuring out host name..." >&4
3886 case "$myhostname" in
3887 '') cont=true
3888         echo 'Maybe "hostname" will work...'
3889         if tans=`sh -c hostname 2>&1` ; then
3890                 myhostname=$tans
3891                 phostname=hostname
3892                 cont=''
3893         fi
3894         ;;
3895 *) cont='';;
3896 esac
3897 if $test "$cont"; then
3898         if xenix; then
3899                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
3900                 if tans=`cat /etc/systemid 2>&1` ; then
3901                         myhostname=$tans
3902                         phostname='cat /etc/systemid'
3903                         echo "Whadyaknow.  Xenix always was a bit strange..."
3904                         cont=''
3905                 fi
3906         elif $test -r /etc/systemid; then
3907                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
3908         fi
3909 fi
3910 if $test "$cont"; then
3911         echo 'No, maybe "uuname -l" will work...'
3912         if tans=`sh -c 'uuname -l' 2>&1` ; then
3913                 myhostname=$tans
3914                 phostname='uuname -l'
3915         else
3916                 echo 'Strange.  Maybe "uname -n" will work...'
3917                 if tans=`sh -c 'uname -n' 2>&1` ; then
3918                         myhostname=$tans
3919                         phostname='uname -n'
3920                 else
3921                         echo 'Oh well, maybe I can mine it out of whoami.h...'
3922                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
3923                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
3924                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
3925                         else
3926                                 case "$myhostname" in
3927                                 '') echo "Does this machine have an identity crisis or something?"
3928                                         phostname='';;
3929                                 *)
3930                                         echo "Well, you said $myhostname before..."
3931                                         phostname='echo $myhostname';;
3932                                 esac
3933                         fi
3934                 fi
3935         fi
3936 fi
3937 : you do not want to know about this
3938 set $myhostname
3939 myhostname=$1
3940
3941 : translate upper to lower if necessary
3942 case "$myhostname" in
3943 *[A-Z]*)
3944         myhostname=`echo $myhostname | tr '[A-Z]' '[a-z]'`
3945         echo "(Normalizing case in your host name)"
3946         ;;
3947 esac
3948
3949 : verify guess
3950 if $test "$myhostname" ; then
3951         dflt=y
3952         rp='Your host name appears to be "'$myhostname'".'" Right?"
3953         . ./myread
3954         case "$ans" in
3955         y*) ;;
3956         *) myhostname='';;
3957         esac
3958 fi
3959
3960 : bad guess or no guess
3961 while $test "X$myhostname" = X ; do
3962         dflt=''
3963         rp="Please type the (one word) name of your host:"
3964         . ./myread
3965         myhostname="$ans"
3966 done
3967
3968 : a little sanity check here
3969 case "$phostname" in
3970 '') ;;
3971 *)
3972         case `$phostname` in
3973         $myhostname$mydomain|$myhostname) ;;
3974         *)
3975                 case "$phostname" in
3976                 sed*)
3977                         echo "(That doesn't agree with your whoami.h file, by the way.)"
3978                         ;;
3979                 *)
3980                         echo "(That doesn't agree with your $phostname command, by the way.)"
3981                         ;;
3982                 esac
3983         ;;
3984         esac
3985         ;;
3986 esac
3987
3988 : see how we will look up host name
3989 echo " "
3990 if false; then
3991         : dummy stub to allow use of elif
3992 elif set uname val -f d_uname; eval $csym; $val; then
3993         if xenix; then
3994                 $cat <<'EOM'
3995 uname() was found, but you're running xenix, and older versions of xenix
3996 have a broken uname(). If you don't really know whether your xenix is old
3997 enough to have a broken system call, use the default answer.
3998
3999 EOM
4000                 dflt=y
4001                 case "$d_uname" in
4002                 "$define") dflt=n;;
4003                 esac
4004                 rp='Is your uname() broken?'
4005                 . ./myread
4006                 case "$ans" in
4007                 n*) d_uname="$define"; call=uname;;
4008                 esac
4009         else
4010                 echo 'uname() found.' >&4
4011                 d_uname="$define"
4012                 call=uname
4013         fi
4014 fi
4015 case "$d_gethname" in
4016 '') d_gethname="$undef";;
4017 esac
4018 case "$d_uname" in
4019 '') d_uname="$undef";;
4020 esac
4021 case "$d_phostname" in
4022 '') d_phostname="$undef";;
4023 esac
4024
4025 : backward compatibility for d_hvfork
4026 if test X$d_hvfork != X; then
4027         d_vfork="$d_hvfork"
4028         d_hvfork=''
4029 fi
4030 : see if there is a vfork
4031 set vfork d_vfork
4032 eval $inlibc
4033
4034 : see if signal is declared as pointer to function returning int or void
4035 echo " "
4036 xxx=`./findhdr signal.h`
4037 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
4038 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
4039         echo "You have int (*signal())() instead of void." >&4
4040         val="$undef"
4041         signal_t="int"
4042 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
4043         echo "You have void (*signal())() instead of int." >&4
4044         val="$define"
4045         signal_t="void"
4046 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
4047         echo "You have int (*signal())() instead of void." >&4
4048         val="$undef"
4049         signal_t="int"
4050 else
4051         case "$d_voidsig" in
4052         '')
4053         echo "I can't determine whether signal handler returns void or int..." >&4
4054                 dflt=void
4055                 rp="What type does your signal handler returns?"
4056                 . ./myread
4057                 case "$ans" in
4058                 void) val="$define"; signal_t="void";;
4059                 *) val="$undef"; signal_t="int";;
4060                 esac;;
4061         *) echo "As you already told me, signal handler returns $signal_t." >&4;;
4062         esac
4063 fi
4064 set d_voidsig
4065 eval $setvar
4066 $rm -f $$.tmp
4067
4068 : check for volatile keyword
4069 echo " "
4070 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
4071 $cat >try.c <<'EOCP'
4072 main()
4073 {
4074         typedef struct _goo_struct goo_struct;
4075         goo_struct * volatile goo = ((goo_struct *)0);
4076         struct _goo_struct {
4077                 long long_int;
4078                 int reg_int;
4079                 char char_var;
4080         };
4081         typedef unsigned short foo_t;
4082         char *volatile foo;
4083         volatile int bar;
4084         volatile foo_t blech;
4085         foo = foo;
4086 }
4087 EOCP
4088 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
4089         val="$define"
4090         echo "Yup, it does."
4091 else
4092         val="$undef"
4093         echo "Nope, it doesn't."
4094 fi
4095 set d_volatile
4096 eval $setvar
4097 $rm -f try.*
4098
4099 : see if there is a wait4
4100 set wait4 d_wait4
4101 eval $inlibc
4102
4103 : see if waitpid exists
4104 set waitpid d_waitpid
4105 eval $inlibc
4106
4107 : preserve RCS keywords in files with variable substitution, grrr
4108 Date='$Date'
4109 Id='$Id'
4110 Log='$Log'
4111 RCSfile='$RCSfile'
4112 Revision='$Revision'
4113
4114 : check for alignment requirements
4115 echo " "
4116 case "$alignbytes" in
4117 '') echo "Checking alignment constraints..." >&4
4118         $cat >try.c <<'EOCP'
4119 struct foobar {
4120         char foo;
4121         double bar;
4122 } try;
4123 main()
4124 {
4125         printf("%d\n", (char *)&try.bar - (char *)&try.foo);
4126 }
4127 EOCP
4128         if $cc $ccflags try.c -o try >/dev/null 2>&1; then
4129                 dflt=`./try`
4130         else
4131                 dflt='8'
4132                 echo"(I can't seem to compile the test program...)"
4133         fi
4134         ;;
4135 *) dflt="$alignbytes"
4136         ;;
4137 esac
4138 rp="Doubles must be aligned on a how-many-byte boundary?"
4139 . ./myread
4140 alignbytes="$ans"
4141 $rm -f try.c try
4142
4143 : is AFS running?
4144 echo " "
4145 if test -d /afs; then
4146         echo "AFS may be running... I'll be extra cautious then..." >&4
4147         afs=true
4148 else
4149         echo "AFS does not seem to be running..." >&4
4150         afs=false
4151 fi
4152
4153 : determine where public executables go
4154 echo " "
4155 case "$bin" in
4156 '')
4157         dflt=`./loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
4158         ;;
4159 *)
4160         dflt="$bin"
4161         ;;
4162 esac
4163 fn=d~
4164 rp='Pathname where the public executables will reside?'
4165 . ./getfile
4166 bin="$ans"
4167 binexp="$ansexp"
4168 if $afs; then
4169         $cat <<EOM
4170
4171 Since you are running AFS, I need to distinguish the directory in which
4172 executables reside from the directory in which they are installed (and from
4173 which they are presumably copied to the former directory by occult means).
4174
4175 EOM
4176         case "$installbin" in
4177         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4178         *) dflt="$installbin";;
4179         esac
4180         fn=de~
4181         rp='Where will public executables be installed?'
4182         . ./getfile
4183         installbin="$ans"
4184 else
4185         installbin="$binexp"
4186 fi
4187
4188 : check for ordering of bytes in a long
4189 case "$byteorder" in
4190 '')
4191         $cat <<'EOM'
4192   
4193 In the following, larger digits indicate more significance.  A big-endian
4194 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
4195 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
4196 machines may have weird orders like 3412.  A Cray will report 87654321. If
4197 the test program works the default is probably right.
4198 I'm now running the test program...
4199 EOM
4200         $cat >try.c <<'EOCP'
4201 #include <stdio.h>
4202 main()
4203 {
4204         int i;
4205         union {
4206                 unsigned long l;
4207                 char c[sizeof(long)];
4208         } u;
4209
4210         if (sizeof(long) > 4)
4211                 u.l = (0x08070605L << 32) | 0x04030201L;
4212         else
4213                 u.l = 0x04030201L;
4214         for (i = 0; i < sizeof(long); i++)
4215                 printf("%c", u.c[i]+'0');
4216         printf("\n");
4217 }
4218 EOCP
4219         if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
4220                 dflt=`./try`
4221                 case "$dflt" in
4222                 ????|????????) echo "(The test program ran ok.)";;
4223                 *) echo "(The test program didn't run right for some reason.)";;
4224                 esac
4225         else
4226                 dflt='4321'
4227                 cat <<'EOM'
4228 (I can't seem to compile the test program.  Guessing big-endian...)
4229 EOM
4230         fi
4231         ;;
4232 *)
4233         echo " "
4234         dflt="$byteorder"
4235         ;;
4236 esac
4237 rp="What is the order of bytes in a long?"
4238 . ./myread
4239 byteorder="$ans"
4240 $rm -f try.c try
4241
4242 : define an alternate in-header-list? function
4243 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4244 cont=true; xxf="echo \"<\$1> found.\" >&4";
4245 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4246 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4247 esac;
4248 case $# in 4) instead=instead;; *) instead="at last";; esac;
4249 while $test "$cont"; do
4250         xxx=`./findhdr $1`
4251         var=$2; eval "was=\$$2";
4252         if $test "$xxx" && $test -r "$xxx";
4253         then eval $xxf;
4254                 eval "case \"\$$var\" in $undef) . whoa; esac"; eval "$var=\$td";
4255                 cont="";
4256         else eval $xxnf;
4257                 eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu"; fi;
4258         set $yyy; shift; shift; yyy=$@;
4259         case $# in 0) cont="";;
4260         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4261                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4262         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4263                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4264         esac;
4265 done;
4266 while $test "$yyy";
4267 do set $yyy; var=$2; eval "was=\$$2";
4268         eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu";
4269         set $yyy; shift; shift; yyy=$@;
4270 done'
4271
4272 : see if dlfcn is available
4273 set dlfcn.h i_dlfcn
4274 eval $inhdr
4275
4276 : determine which dynamic loading, if any, to compile in
4277 echo " "
4278 case "$usedl" in
4279 '')
4280         case "$i_dlfcn" in
4281         'define') dflt='y' ;;
4282         *)        dflt='n' ;;
4283         esac
4284         ;;
4285 'define') dflt='y' ;;
4286 'y') dflt='y'
4287      usedl='define' ;;
4288 *)  dflt='n' ;;
4289 esac
4290 rp="Do you wish to attempt to use dynamic loading?"
4291 . ./myread
4292 usedl="$ans"
4293 case "$ans" in
4294 y*) usedl='define'; dlsrc='dl.c'; dlobj='dl.o';;
4295 *) usedl='undef'; dlsrc=''; dlobj='';;
4296 esac
4297 echo " "
4298 case "$extensions" in
4299 ' '|'') echo "Looking for extensions..."
4300         case "$find" in
4301                 *find*) 
4302                 cd ..
4303                 dflt="`$find ext -type f -name \*.xs -print`"
4304                 cd UU
4305                 ;;
4306         *)      dflt='ext/dbm/NDBM_File.xs ext/dbm/ODBM_File.xs ext/dbm/GDBM_File.xs ext/dbm/SDBM_File.xs ext/posix/POSIX.xs'
4307                 ;;
4308         esac
4309         ;;
4310 none)   dflt='' ;;
4311 *)      dflt="$extensions" ;;
4312 esac
4313 rp="What extensions do you wish to include?"
4314 . ./myread
4315 extensions="$ans"
4316
4317 : see what type gids are declared as in the kernel
4318 case "$gidtype" in
4319 '')
4320         if $contains 'gid_t;' `./findhdr sys/types.h` >/dev/null 2>&1 ; then
4321                 dflt='gid_t';
4322         else
4323                 xxx=`./findhdr sys/user.h`
4324                 set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
4325                 case $1 in
4326                 unsigned) dflt="$1 $2" ;;
4327                 *) dflt="$1" ;;
4328                 esac
4329         fi
4330         ;;
4331 *)  dflt="$gidtype";;
4332 esac
4333 echo " "
4334 rp="What is the type for group ids returned by getgid()?"
4335 . ./myread
4336 gidtype="$ans"
4337 : see if getgroups exists
4338 set getgroups d_getgrps
4339 eval $inlibc
4340
4341 case "$d_getgrps" in
4342 'define')
4343     case "$groupstype" in
4344         '') dflt="$gidtype" ;;
4345         *)  dflt="$groupstype" ;;
4346     esac
4347     echo " "
4348     $cat <<EOM
4349 What is the type of the second argument to getgroups()?  Usually this
4350 is the same as group ids, "$gidtype", but not always.
4351 EOM
4352     rp="What type is the second arguement to getgroups()?"
4353     . ./myread
4354     groupstype="$ans"
4355     ;;
4356 *)  groupstype="$gidtype";;
4357 esac
4358 : determine where private executables go
4359 case "$privlib" in
4360 '')
4361         dflt=/usr/lib/$package
4362         $test -d /usr/local/lib && dflt=/usr/local/lib/$package
4363         $test -d /local/lib && dflt=/local/lib/$package
4364         ;;
4365 *)  dflt="$privlib"
4366         ;;
4367 esac
4368 $cat <<EOM
4369
4370 There are some auxiliary files for $package that need to be put into a
4371 private library directory that is accessible by everyone.
4372
4373 EOM
4374 fn=d~+
4375 rp='Pathname where private library files will reside?'
4376 . ./getfile
4377 privlib="$ans"
4378 privlibexp="$ansexp"
4379 if $afs; then
4380         $cat <<EOM
4381
4382 Since you are running AFS, I need to distinguish the directory in which
4383 private files reside from the directory in which they are installed (and from
4384 which they are presumably copied to the former directory by occult means).
4385
4386 EOM
4387         case "$installprivlib" in
4388         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
4389         *) dflt="$installprivlib";;
4390         esac
4391         fn=de~
4392         rp='Where will private files be installed?'
4393         . ./getfile
4394         installprivlib="$ans"
4395 else
4396         installprivlib="$privlibexp"
4397 fi
4398
4399 : determine where public libraries go
4400 case "$lib" in
4401 '') dflt=`./loc . "." /usr/local/lib /usr/lib /lib`;;
4402 *)  dflt="$lib";;
4403 esac
4404 echo " "
4405 fn=d~
4406 rp='Where do you want to put the public libraries?'
4407 . ./getfile
4408 lib="$ans"
4409 libexp="$ansexp"
4410
4411 : determine which malloc to compile in
4412 :  Old versions had dflt='y' only for bsd or v7.
4413 echo " "
4414 case "$usemymalloc" in
4415 '')
4416         if bsd || v7; then
4417                 dflt='y'
4418         else
4419                 dflt='y'
4420         fi
4421         ;;
4422 *)  dflt="$usemymalloc"
4423         ;;
4424 esac
4425 rp="Do you wish to attempt to use the malloc that comes with $package?"
4426 . ./myread
4427 usemymalloc="$ans"
4428 case "$ans" in
4429 y*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
4430 *) mallocsrc=''; mallocobj='';;
4431 esac
4432
4433 : compute the type returned by malloc
4434 echo " "
4435 case "$malloctype" in
4436 '')
4437         if $test `./findhdr malloc.h`; then
4438                 echo "#include <malloc.h>" > malloc.c
4439         fi
4440 #include <malloc.h>
4441         $cat >>malloc.c <<'END'
4442 void *malloc();
4443 END
4444         if $cc $ccflags -c malloc.c >/dev/null 2>&1; then
4445                 malloctype='void *'
4446         else
4447                 malloctype='char *'
4448         fi
4449         $rm -f malloc.[co]
4450         ;;
4451 esac
4452 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4453
4454 : determine where manual pages go
4455 $cat <<EOM
4456
4457 $package has manual pages available in source form.
4458 EOM
4459 case "$_nroff" in
4460 nroff)
4461         echo "However, you don't have nroff, so they're probably useless to you."
4462         case "$mansrc" in
4463         '') mansrc="none";;
4464         esac;;
4465 esac
4466 echo "If you don't want the manual sources installed, answer 'none'."
4467 case "$mansrc" in
4468 '')
4469         lookpath='/usr/local/man/man1 /usr/local/man/man1 /usr/man/manl'
4470         lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
4471         lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
4472         lookpath="$lookpath /usr/man/man.L"
4473         mansrc=`./loc . $lookpath`
4474         if $test -d "$mansrc"; then
4475                 dflt="$mansrc"
4476         else
4477                 dflt="$sysman"
4478         fi
4479         ;;
4480 *)  dflt="$mansrc"
4481         ;;
4482 esac
4483 echo " "
4484 fn=dn~
4485 rp='Where do the manual pages (source) go?'
4486 . ./getfile
4487 mansrc="$ans"
4488 mansrcexp="$ansexp"
4489 if $afs; then
4490         $cat <<EOM
4491
4492 Since you are running AFS, I need to distinguish the directory in which
4493 manual pages reside from the directory in which they are installed (and from
4494 which they are presumably copied to the former directory by occult means).
4495
4496 EOM
4497         case "$installmansrc" in
4498         '') dflt=`echo $mansrcexp | sed 's#^/afs/#/afs/.#'`;;
4499         *) dflt="$installmansrc";;
4500         esac
4501         fn=de~
4502         rp='Where will man pages be installed?'
4503         . ./getfile
4504         installmansrc="$ans"
4505 else
4506         installmansrc="$mansrcexp"
4507 fi
4508
4509
4510 case "$mansrc" in
4511 '') manext='0';;
4512 *l) manext=l;;
4513 *n) manext=n;;
4514 *o) manext=l;;
4515 *p) manext=n;;
4516 *C) manext=C;;
4517 *L) manext=L;;
4518 *L1) manext=L1;;
4519 *) manext=1;;
4520 esac
4521
4522 : Cruising for prototypes
4523 echo " "
4524 echo "Checking out function prototypes..." >&4
4525 $cat >prototype.c <<'EOCP'
4526 main(int argc, char *argv[]) {
4527         exit(0);}
4528 EOCP
4529 if $cc -c prototype.c >prototype.out 2>&1 ; then
4530         echo "Your C compiler appears to support function prototypes."
4531         val="$define"
4532 else
4533         echo "Your C compiler doesn't seem to understand function prototypes."
4534         val="$undef"
4535 fi
4536 set prototype
4537 eval $setvar
4538 $rm -f prototype*
4539
4540 : check for size of random number generator
4541 echo " "
4542 case "$randbits" in
4543 '')
4544         echo "Checking to see how many bits your rand function produces..." >&4
4545         $cat >try.c <<'EOCP'
4546 #include <stdio.h>
4547 main()
4548 {
4549         register int i;
4550         register unsigned long tmp;
4551         register unsigned long max = 0L;
4552
4553         for (i = 1000; i; i--) {
4554                 tmp = (unsigned long)rand();
4555                 if (tmp > max) max = tmp;
4556         }
4557         for (i = 0; max; i++)
4558                 max /= 2;
4559         printf("%d\n",i);
4560 }
4561 EOCP
4562         if $cc try.c -o try >/dev/null 2>&1 ; then
4563                 dflt=`try`
4564         else
4565                 dflt='?'
4566                 echo "(I can't seem to compile the test program...)"
4567         fi
4568         ;;
4569 *)
4570         dflt="$randbits"
4571         ;;
4572 esac
4573 rp='How many bits does your rand() function produce?'
4574 . ./myread
4575 randbits="$ans"
4576 $rm -f try.c try
4577
4578 : determine where public executables go
4579 case "$scriptdir" in
4580 '')
4581         dflt="$bin"
4582         : guess some guesses
4583         $test -d /usr/share/scripts && dflt=/usr/share/scripts
4584         $test -d /usr/share/bin && dflt=/usr/share/bin
4585         $test -d /usr/local/script && dflt=/usr/local/script
4586         ;;
4587 *)  dflt="$scriptdir"
4588         ;;
4589 esac
4590 $cat <<EOM
4591  
4592 Some installations have a separate directory just for executable scripts so
4593 that they can mount it across multiple architectures but keep the scripts in
4594 one spot.  You might, for example, have a subdirectory of /usr/share for this.
4595 Or you might just lump your scripts in with all your other executables.
4596  
4597 EOM
4598 fn=d~
4599 rp='Where do you keep publicly executable scripts?'
4600 . ./getfile
4601 scriptdir="$ans"
4602 scriptdirexp="$ansexp"
4603 if $afs; then
4604         $cat <<EOM
4605
4606 Since you are running AFS, I need to distinguish the directory in which
4607 scripts reside from the directory in which they are installed (and from
4608 which they are presumably copied to the former directory by occult means).
4609
4610 EOM
4611         case "$installscript" in
4612         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
4613         *) dflt="$installscript";;
4614         esac
4615         fn=de~
4616         rp='Where will public scripts be installed?'
4617         . ./getfile
4618         installscript="$ans"
4619 else
4620         installscript="$scriptdirexp"
4621 fi
4622
4623 : generate list of signal names
4624 echo " "
4625 case "$sig_name" in
4626 '')
4627         echo "Generating a list of signal names..." >&4
4628         xxx=`./findhdr signal.h`" "`./findhdr sys/signal.h`
4629         set X `cat $xxx 2>&1 | $awk '
4630 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
4631         sig[$3] = substr($2,4,20)
4632         if (max < $3 && $3 < 60) {
4633                 max = $3
4634         }
4635 }
4636
4637 END {
4638         for (i = 1; i <= max; i++) {
4639                 if (sig[i] == "")
4640                         printf "%d", i
4641                 else
4642                         printf "%s", sig[i]
4643                 if (i < max)
4644                         printf " "
4645         }
4646         printf "\n"
4647 }
4648 '`
4649         shift
4650         case $# in
4651         0)
4652                 echo 'kill -l' >/tmp/foo$$
4653                 set X `csh -f </tmp/foo$$`
4654                 $rm -f /tmp/foo$$
4655                 shift
4656                 case $# in
4657                 0)set HUP INT QUIT ILL TRAP IOT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
4658                 ;;
4659                 esac
4660                 ;;
4661         esac
4662         sig_name="ZERO $*"
4663         ;;
4664 esac
4665 echo "The following signals are available:"
4666 echo $sig_name | tr ' ' '\012' | $sed 's/^/    SIG/'
4667
4668 : see what type of char stdio uses.
4669 echo " "
4670 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
4671         echo "Your stdio uses unsigned chars." >&4
4672         stdchar="unsigned char"
4673 else
4674         echo "Your stdio uses signed chars." >&4
4675         stdchar="char"
4676 fi
4677
4678 : see what type uids are declared as in the kernel
4679 case "$uidtype" in
4680 '')
4681         if $contains 'uid_t;' `./findhdr sys/types.h` >/dev/null 2>&1 ; then
4682                 dflt='uid_t';
4683         else
4684                 xxx=`./findhdr sys/user.h`
4685                 set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
4686                 case $1 in
4687                 unsigned) dflt="$1 $2" ;;
4688                 *) dflt="$1" ;;
4689                 esac
4690         fi
4691         ;;
4692 *)  dflt="$uidtype";;
4693 esac
4694 echo " "
4695 rp="What type are user ids on this system declared as?"
4696 . ./myread
4697 uidtype="$ans"
4698
4699 : check for void type
4700 echo " "
4701 $cat >&4 <<EOM
4702 Checking to see how well your C compiler groks the void type...
4703
4704   Support flag bits are:
4705     1: basic void declarations.
4706     2: arrays of pointers to functions returning void.
4707     4: operations between pointers to and addresses of void functions.
4708     8: generic void pointers.
4709
4710 EOM
4711 case "$voidflags" in
4712 '')
4713         $cat >try.c <<'EOCP'
4714 #if TRY & 1
4715 void main() {
4716 #else
4717 main() {
4718 #endif
4719         extern void moo();      /* function returning void */
4720         void (*goo)();          /* ptr to func returning void */
4721 #if TRY & 8
4722         void *hue;              /* generic ptr */
4723 #endif
4724 #if TRY & 2
4725         void (*foo[10])();
4726 #endif
4727
4728 #if TRY & 4
4729         if(goo == moo) {
4730                 exit(0);
4731         }
4732 #endif
4733         exit(0);
4734 }
4735 EOCP
4736         if $cc -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
4737                 voidflags=$defvoidused
4738         echo "It appears to support void to the level $package wants ($defvoidused)."
4739                 if $contains warning .out >/dev/null 2>&1; then
4740                         echo "However, you might get some warnings that look like this:"
4741                         $cat .out
4742                 fi
4743         else
4744 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
4745                 if $cc -c -DTRY=1 try.c >/dev/null 2>&1 ; then
4746                         echo "It supports 1..."
4747                         if $cc -c -DTRY=3 try.c >/dev/null 2>&1 ; then
4748                                 echo "It also supports 2..."
4749                                 if $cc -c -DTRY=7 try.c >/dev/null 2>&1 ; then
4750                                         voidflags=7
4751                                         echo "And it supports 4 but not 8 definitely."
4752                                 else
4753                                         echo "It doesn't support 4..."
4754                                         if $cc -c -DTRY=11 try.c >/dev/null 2>&1 ; then
4755                                                 voidflags=11
4756                                                 echo "But it supports 8."
4757                                         else
4758                                                 voidflags=3
4759                                                 echo "Neither does it support 8."
4760                                         fi
4761                                 fi
4762                         else
4763                                 echo "It does not support 2..."
4764                                 if $cc -c -DTRY=13 try.c >/dev/null 2>&1 ; then
4765                                         voidflags=13
4766                                         echo "But it supports 4 and 8."
4767                                 else
4768                                         if $cc -c -DTRY=5 try.c >/dev/null 2>&1 ; then
4769                                                 voidflags=5
4770                                                 echo "And it supports 4 but has not heard about 8."
4771                                         else
4772                                                 echo "However it supports 8 but not 4."
4773                                         fi
4774                                 fi
4775                         fi
4776                 else
4777                         echo "There is no support at all for void."
4778                         voidflags=0
4779                 fi
4780         fi
4781 esac
4782 dflt="$voidflags";
4783 rp="Your void support flags add up to what?"
4784 . ./myread
4785 voidflags="$ans"
4786 $rm -f try.* .out
4787
4788 : determine compiler compiler
4789 case "$yacc" in
4790 '')
4791         dflt=yacc;;
4792 *)
4793         dflt="$yacc";;
4794 esac
4795 echo " "
4796 rp="yacc"
4797 if $test -f "$byacc"; then
4798         dflt="$byacc"
4799         rp="byacc or $rp"
4800 fi
4801 if $test -f "$bison"; then
4802         rp="$rp or bison -y"
4803 fi
4804 $cat <<EOM
4805 $package no longer requires a compiler compiler, so the following is
4806 optional.
4807 EOM
4808 rp="Which compiler compiler ($rp) shall I use?"
4809 . ./myread
4810 yacc="$ans"
4811 case "$yacc" in
4812 *bis*)
4813         case "$yacc" in
4814         *-y*) ;;
4815         *)
4816                 yacc="$yacc -y"
4817                 echo "(Adding -y option to bison to get yacc-compatible behaviour.)"
4818                 ;;
4819         esac
4820         ;;
4821 esac
4822
4823 : see if we have the old dbm
4824 set dbm.h i_dbm
4825 eval $inhdr
4826
4827 : see if this is a sys/file.h system
4828 val=''
4829 set sys/file.h val
4830 eval $inhdr
4831
4832 : do we need to #include <sys/file.h> ?
4833 case "$val" in
4834 "$define")
4835         echo " "
4836         if $h_sysfile; then
4837                 val="$define"
4838                 echo "We'll be including <sys/file.h>." >&4
4839         else
4840                 val="$undef"
4841                 echo "We won't be including <sys/file.h>." >&4
4842         fi
4843         ;;
4844 *)
4845         h_sysfile=false
4846         ;;
4847 esac
4848 set i_sysfile
4849 eval $setvar
4850
4851 : see if fcntl.h is there
4852 val=''
4853 set fcntl.h val
4854 eval $inhdr
4855
4856 : see if we can include fcntl.h
4857 case "$val" in
4858 "$define")
4859         echo " "
4860         if $h_fcntl; then
4861                 val="$define"
4862                 echo "We'll be including <fcntl.h>." >&4
4863         else
4864                 val="$undef"
4865                 if $h_sysfile; then
4866         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
4867                 else
4868                         echo "We won't be including <fcntl.h>." >&4
4869                 fi
4870         fi
4871         ;;
4872 *)
4873         h_fcntl=false
4874         val="$undef"
4875         ;;
4876 esac
4877 set i_fcntl
4878 eval $setvar
4879
4880 : see if gdbm.h is available
4881 set gdbm.h i_gdbm
4882 eval $inhdr
4883
4884 : see if this is an grp system
4885 set grp.h i_grp
4886 eval $inhdr
4887
4888 : see if ndbm.h is available
4889 set ndbm.h i_ndbm
4890 eval $inhdr
4891
4892 : see if there are directory access routines out there
4893 echo " "
4894 if $test `./findhdr ndir.h` && \
4895           ( $test -r /usr/lib/libndir.a || $test -r /usr/local/lib/libndir.a ); then
4896         echo "Ndir library found." >&4
4897         if $test -r /usr/lib/libndir.a; then
4898                 ndirlib='-lndir'
4899         else
4900                 ndirlib="/usr/local/lib/libndir.a"
4901         fi
4902         i_ndir="$define"
4903         d_usendir="$undef"
4904         ndirc=''
4905         ndiro=''
4906 else
4907         ndirlib=''
4908         i_ndir="$undef"
4909         if set readdir val -f; eval $csym; $val; then
4910         echo "No ndir library found, but you have readdir() so we'll use that." >&4
4911                 d_usendir="$undef"
4912                 ndirc=''
4913                 ndiro=''
4914         else
4915                 echo "No ndir library found--using ./ndir.c." >&4
4916                 d_usendir="$define"
4917                 ndirc='ndir.c'
4918                 ndiro='ndir.o'
4919         fi
4920 fi
4921
4922 : see if this is a netinet/in.h or sys/in.h system
4923 set netinet/in.h i_niin sys/in.h i_sysin
4924 eval $inhdr
4925
4926 : see if stdarg is available
4927 set stdarg.h i_stdarg
4928 eval $inhdr
4929
4930 : see if stddef is available
4931 set stddef.h i_stddef
4932 eval $inhdr
4933
4934 : see if this is an sysdir system
4935 set sys/dir.h i_sysdir
4936 eval $inhdr
4937
4938 : get C preprocessor symbols handy
4939 echo " "
4940 echo $attrlist | $tr ' ' '\012' >Cppsym.know
4941 $cat <<EOSS >Cppsym
4942 $startsh
4943 case "\$1" in
4944 -l) list=true
4945         shift
4946         ;;
4947 esac
4948 unknown=''
4949 case "\$list\$#" in
4950 1|2)
4951         for sym do
4952                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
4953                         exit 0
4954                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
4955                         :
4956                 else
4957                         unknown="\$unknown \$sym"
4958                 fi
4959         done
4960         set X \$unknown
4961         shift
4962         ;;
4963 esac
4964 case \$# in
4965 0) exit 1;;
4966 esac
4967 echo \$* | $tr ' ' '\012' | $sed -e 's/\(.*\)/\\
4968 #ifdef \1\\
4969 exit 0; _ _ _ _\1\\      \1\\
4970 #endif\\
4971 /' >Cppsym\$\$
4972 echo "exit 1; _ _ _" >>Cppsym\$\$
4973 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
4974 case "\$list" in
4975 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
4976 *)
4977         sh Cppsym2\$\$
4978         status=\$?
4979         ;;
4980 esac
4981 $rm -f Cppsym\$\$ Cppsym2\$\$
4982 exit \$status
4983 EOSS
4984 chmod +x Cppsym
4985 $eunicefix Cppsym
4986 echo "Your C preprocessor defines the following symbols:"
4987 Cppsym -l $attrlist >Cppsym.true
4988 $cat Cppsym.true
4989
4990 : see if this is a termio system
4991 val="$undef"
4992 val2="$undef"
4993 val3="$undef"
4994 if $test `./findhdr termios.h`; then
4995         set tcsetattr i_termios
4996         eval $inlibc
4997         val3="$i_termios"
4998 fi
4999 echo " "
5000 case "$val3" in
5001 "$define") echo "You have POSIX termios.h... good!" >&4;;
5002 *) if Cppsym pyr; then
5003                 case "`/bin/universe`" in
5004                 ucb) if $test `./findhdr sgtty.h`; then
5005                                 val2="$define"
5006                                 echo "<sgtty.h> found." >&4
5007                         else
5008                                 echo "System is pyramid with BSD universe."
5009                                 echo "<sgtty.h> not found--you could have problems." >&4
5010                         fi;;
5011                 *) if $test `./findhdr termio.h`; then
5012                                 val="$define"
5013                                 echo "<termio.h> found." >&4
5014                         else
5015                                 echo "System is pyramid with USG universe."
5016                                 echo "<termio.h> not found--you could have problems." >&4
5017                         fi;;
5018                 esac
5019         elif usg; then
5020                 if $test `./findhdr termio.h`; then
5021                         echo "<termio.h> found." >&4
5022                         val="$define"
5023                 elif $test `./findhdr sgtty.h`; then
5024                         echo "<sgtty.h> found." >&4
5025                         val2="$define"
5026                 else
5027 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
5028                 fi
5029         else
5030                 if $test `./findhdr sgtty.h`; then
5031                         echo "<sgtty.h> found." >&4
5032                         val2="$define"
5033                 elif $test `./findhdr termio.h`; then
5034                         echo "<termio.h> found." >&4
5035                         val="$define"
5036                 else
5037 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
5038                 fi
5039         fi;;
5040 esac
5041 set i_termio; eval $setvar
5042 val=$val2; set i_sgtty; eval $setvar
5043 val=$val3; set i_termios; eval $setvar
5044
5045 : see if ioctl defs are in sgtty/termio or sys/ioctl
5046 echo " "
5047 if $test `./findhdr sys/ioctl.h`; then
5048         val="$define"
5049         echo "<sys/ioctl.h> found." >&4
5050 else
5051         val="$undef"
5052         $test $i_termio = "$define" && xxx="termio.h"
5053         $test $i_termios = "$define" && xxx="termios.h"
5054         $test $i_sgtty = "$define" && xxx="sgtty.h"
5055 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
5056 fi
5057 set i_sysioctl
5058 eval $setvar
5059
5060 : see if this is an sysndir system
5061 set sys/ndir.h i_sysndir
5062 eval $inhdr
5063
5064 : see if sys/select.h has to be included
5065 set sys/select.h i_sysselct
5066 eval $inhdr
5067
5068 : see if we should include time.h, sys/time.h, or both
5069 echo " "
5070 echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
5071 $echo $n "I'm now running the test program...$c"
5072 $cat >try.c <<'EOCP'
5073 #include <sys/types.h>
5074 #ifdef I_TIME
5075 #include <time.h>
5076 #endif
5077 #ifdef I_SYSTIME
5078 #ifdef SYSTIMEKERNEL
5079 #define KERNEL
5080 #endif
5081 #include <sys/time.h>
5082 #endif
5083 #ifdef I_SYSSELECT
5084 #include <sys/select.h>
5085 #endif
5086 main()
5087 {
5088         struct tm foo;
5089 #ifdef S_TIMEVAL
5090         struct timeval bar;
5091 #endif
5092 #ifdef S_TIMEZONE
5093         struct timezone tzp;
5094 #endif
5095         if (foo.tm_sec == foo.tm_sec)
5096                 exit(0);
5097 #ifdef S_TIMEVAL
5098         if (bar.tv_sec == bar.tv_sec)
5099                 exit(0);
5100 #endif
5101         exit(1);
5102 }
5103 EOCP
5104 flags=''
5105 s_timezone=''
5106 sysselect=''
5107 for s_timeval in '-DS_TIMEVAL' ''; do
5108 for i_systimek in '' '-DSYSTIMEKERNEL'; do
5109 for i_time in '' '-DI_TIME'; do
5110 for i_systime in '-DI_SYSTIME' ''; do
5111         case "$flags" in
5112         '') $echo $n ".$c"
5113                 if $cc $ccflags \
5114                 $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone \
5115                 try.c -o try >/dev/null 2>&1 ; then
5116                         set X $i_time $i_systime $i_systimek $sysselect $s_timeval
5117                         shift
5118                         flags="$*"
5119                         echo " "
5120                         $echo $n "Succeeded with $flags$c"
5121                 fi
5122                 ;;
5123         esac
5124 done
5125 done
5126 done
5127 done
5128 timeincl=''
5129 echo " "
5130 case "$flags" in
5131 *SYSTIMEKERNEL*) i_systimek="$define"
5132         timeincl=`./findhdr sys/time.h`
5133         echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
5134 *) i_systimek="$undef";;
5135 esac
5136 case "$flags" in
5137 *I_TIME*) i_time="$define"
5138         timeincl=`./findhdr time.h`" $timeincl"
5139         echo "We'll include <time.h>." >&4;;
5140 *) i_time="$undef";;
5141 esac
5142 case "$flags" in
5143 *I_SYSTIME*) i_systime="$define"
5144         timeincl=`./findhdr sys/time.h`" $timeincl"
5145         echo "We'll include <sys/time.h>." >&4;;
5146 *) i_systime="$undef";;
5147 esac
5148 $rm -f try.c try
5149
5150 : see if this is an utime system
5151 set utime.h i_utime
5152 eval $inhdr
5153
5154 : see if this is a varargs system
5155 echo " "
5156 if $test `./findhdr varargs.h`; then
5157         val="$define"
5158         echo "<varargs.h> found." >&4
5159 else
5160         val="$undef"
5161         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
5162 fi
5163 set i_varargs
5164 eval $setvar
5165
5166 : set up the varargs testing programs
5167 $cat > varargs.c <<EOP
5168 #ifdef I_STDARG
5169 #include <stdarg.h>
5170 #endif
5171 #ifdef I_VARARGS
5172 #include <varargs.h>
5173 #endif
5174
5175 #ifdef I_STDARG
5176 int f(char *p, ...)
5177 #else
5178 int f(va_alist)
5179 va_dcl
5180 #endif
5181 {
5182         va_list ap;
5183 #ifndef I_STDARG
5184         char *p;
5185 #endif
5186 #ifdef I_STDARG
5187         va_start(ap,p);
5188 #else
5189         va_start(ap);
5190         p = va_arg(ap, char *);
5191 #endif
5192         va_end(ap);
5193 }
5194 EOP
5195 $cat > varargs <<EOP
5196 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
5197         echo "true"
5198 else
5199         echo "false"
5200 fi
5201 $rm -f varargs.o
5202 EOP
5203 chmod +x varargs
5204
5205 : now check which varargs header should be included
5206 echo " "
5207 i_varhdr=''
5208 case "$i_stdarg" in
5209 "$define")
5210         if `./varargs I_STDARG`; then
5211                 i_varhdr='stdarg.h'
5212                 i_varargs="$undef"
5213         elif `./varargs I_VARARGS`; then
5214                 i_varhdr='varargs.h'
5215                 i_stdarg="$undef"
5216         fi
5217         ;;
5218 *)
5219         if `./varargs I_VARARGS`; then
5220                 i_varhdr='varargs.h'
5221         fi
5222         ;;
5223 esac
5224 case "$i_varhdr" in
5225 '')
5226 echo "I could not find the definition for va_dcl... You have problems..." >&4
5227         ;;
5228 *) echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
5229 esac
5230 $rm -f varargs*
5231
5232 : see if this is a vfork system
5233 set vfork.h i_vfork
5234 eval $inhdr
5235
5236 : end of configuration questions
5237 echo " "
5238 echo "End of configuration questions."
5239 echo " "
5240
5241 : back to where it started
5242 if test -d ../UU; then
5243         cd ..
5244 fi
5245
5246 : configuration may be patched via a 'config.over' file
5247 if $test -f config.over; then
5248         echo " "
5249         dflt=y
5250         rp='I see a config.over file.  Do you wish to load it?'
5251         . UU/myread
5252         case "$ans" in
5253         n*) echo "OK, I'll ignore it.";;
5254         *)      . ./config.over
5255                 echo "Configuration override changes have been loaded."
5256                 ;;
5257         esac
5258 fi
5259
5260 : create config.sh file
5261 echo " "
5262 echo "Creating config.sh..." >&4
5263 $spitshell <<EOT >config.sh
5264 $startsh
5265 #
5266 # This file was produced by running the Configure script. It holds all the
5267 # definitions figured out by Configure. Should you modify one of these values,
5268 # do not forget to propagate your changes by running "Configure -der". You may
5269 # instead choose to run each of the .SH files by yourself, or "Configure -S".
5270 #
5271
5272 # Configuration time: $cf_time
5273 # Configured by: $cf_by
5274 # Target system: $myuname
5275
5276 extensions='$extensions'
5277 d_bsd='$d_bsd'
5278 d_eunice='$d_eunice'
5279 d_xenix='$d_xenix'
5280 eunicefix='$eunicefix'
5281 Mcc='$Mcc'
5282 awk='$awk'
5283 bash='$bash'
5284 bison='$bison'
5285 byacc='$byacc'
5286 cat='$cat'
5287 chgrp='$chgrp'
5288 chmod='$chmod'
5289 chown='$chown'
5290 compress='$compress'
5291 cp='$cp'
5292 cpio='$cpio'
5293 cpp='$cpp'
5294 csh='$csh'
5295 date='$date'
5296 echo='$echo'
5297 egrep='$egrep'
5298 emacs='$emacs'
5299 expr='$expr'
5300 find='$find'
5301 flex='$flex'
5302 gcc='$gcc'
5303 grep='$grep'
5304 inews='$inews'
5305 ksh='$ksh'
5306 less='$less'
5307 line='$line'
5308 lint='$lint'
5309 ln='$ln'
5310 lp='$lp'
5311 lpr='$lpr'
5312 ls='$ls'
5313 mail='$mail'
5314 mailx='$mailx'
5315 make='$make'
5316 mkdir='$mkdir'
5317 more='$more'
5318 mv='$mv'
5319 nroff='$nroff'
5320 perl='$perl'
5321 pg='$pg'
5322 pmake='$pmake'
5323 pr='$pr'
5324 rm='$rm'
5325 rmail='$rmail'
5326 sed='$sed'
5327 sendmail='$sendmail'
5328 sh='$sh'
5329 shar='$shar'
5330 sleep='$sleep'
5331 smail='$smail'
5332 sort='$sort'
5333 submit='$submit'
5334 tail='$tail'
5335 tar='$tar'
5336 tbl='$tbl'
5337 test='$test'
5338 touch='$touch'
5339 tr='$tr'
5340 troff='$troff'
5341 uname='$uname'
5342 uniq='$uniq'
5343 uuname='$uuname'
5344 vi='$vi'
5345 zcat='$zcat'
5346 hint='$hint'
5347 myuname='$myuname'
5348 Author='$Author'
5349 Date='$Date'
5350 Header='$Header'
5351 Id='$Id'
5352 Locker='$Locker'
5353 Log='$Log'
5354 RCSfile='$RCSfile'
5355 Revision='$Revision'
5356 Source='$Source'
5357 State='$State'
5358 afs='$afs'
5359 alignbytes='$alignbytes'
5360 bin='$bin'
5361 binexp='$binexp'
5362 installbin='$installbin'
5363 byteorder='$byteorder'
5364 cc='$cc'
5365 gccversion='$gccversion'
5366 ccflags='$ccflags'
5367 cppflags='$cppflags'
5368 ldflags='$ldflags'
5369 lkflags='$lkflags'
5370 optimize='$optimize'
5371 cf_by='$cf_by'
5372 cf_time='$cf_time'
5373 contains='$contains'
5374 cpplast='$cpplast'
5375 cppminus='$cppminus'
5376 cpprun='$cpprun'
5377 cppstdin='$cppstdin'
5378 d_access='$d_access'
5379 d_bcmp='$d_bcmp'
5380 d_bcopy='$d_bcopy'
5381 d_bzero='$d_bzero'
5382 d_casti32='$d_casti32'
5383 castflags='$castflags'
5384 d_castneg='$d_castneg'
5385 d_charsprf='$d_charsprf'
5386 d_chsize='$d_chsize'
5387 d_const='$d_const'
5388 cryptlib='$cryptlib'
5389 d_crypt='$d_crypt'
5390 d_csh='$d_csh'
5391 d_dosuid='$d_dosuid'
5392 d_dup2='$d_dup2'
5393 d_fchmod='$d_fchmod'
5394 d_fchown='$d_fchown'
5395 d_fcntl='$d_fcntl'
5396 d_flexfnam='$d_flexfnam'
5397 d_flock='$d_flock'
5398 d_getgrps='$d_getgrps'
5399 d_gethent='$d_gethent'
5400 aphostname='$aphostname'
5401 d_gethname='$d_gethname'
5402 d_phostname='$d_phostname'
5403 d_uname='$d_uname'
5404 d_getpgrp2='$d_getpgrp2'
5405 d_getpgrp='$d_getpgrp'
5406 d_getprior='$d_getprior'
5407 d_htonl='$d_htonl'
5408 d_isascii='$d_isascii'
5409 d_killpg='$d_killpg'
5410 d_link='$d_link'
5411 d_lstat='$d_lstat'
5412 d_memcmp='$d_memcmp'
5413 d_memcpy='$d_memcpy'
5414 d_memmove='$d_memmove'
5415 d_memset='$d_memset'
5416 d_mkdir='$d_mkdir'
5417 d_msg='$d_msg'
5418 d_msgctl='$d_msgctl'
5419 d_msgget='$d_msgget'
5420 d_msgrcv='$d_msgrcv'
5421 d_msgsnd='$d_msgsnd'
5422 d_open3='$d_open3'
5423 d_portable='$d_portable'
5424 d_readdir='$d_readdir'
5425 d_rename='$d_rename'
5426 d_rmdir='$d_rmdir'
5427 d_safebcpy='$d_safebcpy'
5428 d_safemcpy='$d_safemcpy'
5429 d_select='$d_select'
5430 d_sem='$d_sem'
5431 d_semctl='$d_semctl'
5432 d_semget='$d_semget'
5433 d_semop='$d_semop'
5434 d_setegid='$d_setegid'
5435 d_seteuid='$d_seteuid'
5436 d_setlocale='$d_setlocale'
5437 d_setpgid='$d_setpgid'
5438 d_setpgrp2='$d_setpgrp2'
5439 d_bsdpgrp='$d_bsdpgrp'
5440 d_setpgrp='$d_setpgrp'
5441 d_setprior='$d_setprior'
5442 d_setregid='$d_setregid'
5443 d_setresgid='$d_setresgid'
5444 d_setresuid='$d_setresuid'
5445 d_setreuid='$d_setreuid'
5446 d_setrgid='$d_setrgid'
5447 d_setruid='$d_setruid'
5448 d_setsid='$d_setsid'
5449 d_shm='$d_shm'
5450 d_shmat='$d_shmat'
5451 d_shmctl='$d_shmctl'
5452 d_shmdt='$d_shmdt'
5453 d_shmget='$d_shmget'
5454 d_oldsock='$d_oldsock'
5455 d_socket='$d_socket'
5456 d_sockpair='$d_sockpair'
5457 sockethdr='$sockethdr'
5458 socketlib='$socketlib'
5459 d_statblks='$d_statblks'
5460 d_stdstdio='$d_stdstdio'
5461 d_index='$d_index'
5462 d_strchr='$d_strchr'
5463 d_strctcpy='$d_strctcpy'
5464 d_strerrm='$d_strerrm'
5465 d_strerror='$d_strerror'
5466 d_sysernlst='$d_sysernlst'
5467 d_syserrlst='$d_syserrlst'
5468 d_symlink='$d_symlink'
5469 d_syscall='$d_syscall'
5470 d_system='$d_system'
5471 clocktype='$clocktype'
5472 d_times='$d_times'
5473 d_truncate='$d_truncate'
5474 d_usendir='$d_usendir'
5475 i_ndir='$i_ndir'
5476 ndirc='$ndirc'
5477 ndirlib='$ndirlib'
5478 ndiro='$ndiro'
5479 d_vfork='$d_vfork'
5480 d_voidsig='$d_voidsig'
5481 signal_t='$signal_t'
5482 d_volatile='$d_volatile'
5483 d_charvspr='$d_charvspr'
5484 d_vprintf='$d_vprintf'
5485 d_wait4='$d_wait4'
5486 d_waitpid='$d_waitpid'
5487 dlobj='$dlobj'
5488 dlsrc='$dlsrc'
5489 usedl='$usedl'
5490 gidtype='$gidtype'
5491 groupstype='$groupstype'
5492 h_fcntl='$h_fcntl'
5493 h_sysfile='$h_sysfile'
5494 i_dbm='$i_dbm'
5495 d_dirnamlen='$d_dirnamlen'
5496 i_dirent='$i_dirent'
5497 i_dlfcn='$i_dlfcn'
5498 i_fcntl='$i_fcntl'
5499 i_gdbm='$i_gdbm'
5500 i_grp='$i_grp'
5501 i_ndbm='$i_ndbm'
5502 i_niin='$i_niin'
5503 i_sysin='$i_sysin'
5504 d_pwage='$d_pwage'
5505 d_pwchange='$d_pwchange'
5506 d_pwclass='$d_pwclass'
5507 d_pwcomment='$d_pwcomment'
5508 d_pwexpire='$d_pwexpire'
5509 d_pwquota='$d_pwquota'
5510 i_pwd='$i_pwd'
5511 i_stdarg='$i_stdarg'
5512 i_stddef='$i_stddef'
5513 i_string='$i_string'
5514 strings='$strings'
5515 i_sysdir='$i_sysdir'
5516 i_sysfile='$i_sysfile'
5517 d_voidtty='$d_voidtty'
5518 i_bsdioctl='$i_bsdioctl'
5519 i_sysioctl='$i_sysioctl'
5520 i_syssockio='$i_syssockio'
5521 i_sysndir='$i_sysndir'
5522 i_sysselct='$i_sysselct'
5523 i_sgtty='$i_sgtty'
5524 i_termio='$i_termio'
5525 i_termios='$i_termios'
5526 i_systime='$i_systime'
5527 i_systimek='$i_systimek'
5528 i_time='$i_time'
5529 timeincl='$timeincl'
5530 i_utime='$i_utime'
5531 i_varargs='$i_varargs'
5532 i_varhdr='$i_varhdr'
5533 i_vfork='$i_vfork'
5534 intsize='$intsize'
5535 lib='$lib'
5536 libexp='$libexp'
5537 libc='$libc'
5538 libpth='$libpth'
5539 plibpth='$plibpth'
5540 xlibpth='$xlibpth'
5541 libs='$libs'
5542 mallocobj='$mallocobj'
5543 mallocsrc='$mallocsrc'
5544 malloctype='$malloctype'
5545 usemymalloc='$usemymalloc'
5546 installmansrc='$installmansrc'
5547 manext='$manext'
5548 mansrc='$mansrc'
5549 mansrcexp='$mansrcexp'
5550 huge='$huge'
5551 large='$large'
5552 medium='$medium'
5553 models='$models'
5554 small='$small'
5555 split='$split'
5556 mydomain='$mydomain'
5557 myhostname='$myhostname'
5558 phostname='$phostname'
5559 c='$c'
5560 n='$n'
5561 groupcat='$groupcat'
5562 hostcat='$hostcat'
5563 passcat='$passcat'
5564 package='$package'
5565 spackage='$spackage'
5566 installprivlib='$installprivlib'
5567 privlib='$privlib'
5568 privlibexp='$privlibexp'
5569 prototype='$prototype'
5570 randbits='$randbits'
5571 installscript='$installscript'
5572 scriptdir='$scriptdir'
5573 scriptdirexp='$scriptdirexp'
5574 sig_name='$sig_name'
5575 sharpbang='$sharpbang'
5576 shsharp='$shsharp'
5577 spitshell='$spitshell'
5578 startsh='$startsh'
5579 stdchar='$stdchar'
5580 sysman='$sysman'
5581 uidtype='$uidtype'
5582 nm_opt='$nm_opt'
5583 runnm='$runnm'
5584 usenm='$usenm'
5585 incpath='$incpath'
5586 mips='$mips'
5587 mips_type='$mips_type'
5588 usrinc='$usrinc'
5589 defvoidused='$defvoidused'
5590 voidflags='$voidflags'
5591 yacc='$yacc'
5592 yaccflags='$yaccflags'
5593 EOT
5594
5595 : add special variables
5596 $test -f patchlevel.h && \
5597 awk '/^#define/ {printf "%s=%s\n",$2,$3}' patchlevel.h >>config.sh
5598 echo "CONFIG=true" >>config.sh
5599
5600 : propagate old symbols
5601 if $test -f UU/config.sh; then
5602         <UU/config.sh sort | uniq >UU/oldconfig.sh
5603         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
5604         sort | uniq -u >UU/oldsyms
5605         set X `cat UU/oldsyms`
5606         shift
5607         case $# in
5608         0) ;;
5609         *)
5610                 cat <<EOM
5611 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
5612 EOM
5613                 echo "# Variables propagated from previous config.sh file." >>config.sh
5614                 for sym in `cat UU/oldsyms`; do
5615                         echo "    Propagating $hint variable "'$'"$sym..."
5616                         eval 'tmp="$'"${sym}"'"'
5617                         echo "$tmp" | \
5618                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
5619                 done
5620                 ;;
5621         esac
5622 fi
5623
5624 : Finish up by extracting the .SH files
5625 case "$alldone" in
5626 exit)
5627         $rm -rf UU
5628         echo "Done."
5629         exit 0
5630         ;;
5631 cont)
5632         ;;
5633 '')
5634         echo " "
5635         dflt=''
5636         nostick=true
5637 echo "If you didn't make any mistakes, then just type a carriage return here."
5638         rp="If you need to edit config.sh, do it as a shell escape here:"
5639         . UU/myread
5640         nostick=''
5641         case "$ans" in
5642         '') ;;
5643         *) : in case they cannot read
5644                 sh 1>&4 -c "$ans";;
5645         esac
5646         ;;
5647 esac
5648
5649 : if this fails, just run all the .SH files by hand
5650 . ./config.sh
5651
5652 echo " "
5653 exec 1>&4
5654 . ./UU/extract
5655
5656 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
5657         dflt=y
5658         case "$silent" in
5659         true) ;;
5660         *)
5661                 $cat <<EOM
5662
5663 Now you need to generate make dependencies by running "make depend".
5664 You might prefer to run it in background: "make depend > makedepend.out &"
5665 It can take a while, so you might not want to run it right now.
5666
5667 EOM
5668                 ;;
5669         esac
5670         rp="Run make depend now?"
5671         . UU/myread
5672         case "$ans" in
5673         y*)
5674                 make depend && echo "Now you must run a make."
5675                 ;;
5676         *)
5677                 echo "You must run 'make depend' then 'make'."
5678                 ;;
5679         esac
5680 elif test -f [Mm]akefile; then
5681         echo " "
5682         echo "Now you must run a make."
5683 else
5684         echo "Done."
5685 fi
5686
5687 $rm -f kit*isdone ark*isdone
5688 $rm -rf UU
5689 : End of Configure