perl 3.0 patch #42 (combined patch)
[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, I would
7 # suggest you cut out the prototypical config.h from the end of Configure
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 # $Header: Configure,v 3.0.1.13 91/01/11 17:01:32 lwall Locked $
12 #
13 # Yes, you may rip this off to use in other distribution packages.
14 # (Note: this Configure script was generated automatically.  Rather than
15 # working with this copy of Configure, you may wish to get metaconfig.)
16
17 : sanity checks
18 PATH="$PATH:.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin"
19 export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
20
21 if test ! -t 0; then
22     echo "Say 'sh Configure', not 'sh <Configure'"
23     exit 1
24 fi
25
26 (alias) >/dev/null 2>&1 && \
27     echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
28     echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
29
30 if test ! -d ../UU; then
31     if test ! -d UU; then
32         mkdir UU
33     fi
34     cd UU
35 fi
36
37 case "$1" in
38 -d) shift; fastread='yes';;
39 esac
40
41 d_eunice=''
42 define=''
43 eunicefix=''
44 loclist=''
45 expr=''
46 sed=''
47 echo=''
48 cat=''
49 rm=''
50 mv=''
51 cp=''
52 tail=''
53 tr=''
54 mkdir=''
55 sort=''
56 uniq=''
57 grep=''
58 trylist=''
59 test=''
60 inews=''
61 egrep=''
62 more=''
63 pg=''
64 Mcc=''
65 vi=''
66 mailx=''
67 mail=''
68 cpp=''
69 perl=''
70 emacs=''
71 ls=''
72 rmail=''
73 sendmail=''
74 shar=''
75 smail=''
76 tbl=''
77 troff=''
78 nroff=''
79 uname=''
80 uuname=''
81 line=''
82 chgrp=''
83 chmod=''
84 lint=''
85 sleep=''
86 pr=''
87 tar=''
88 ln=''
89 lpr=''
90 lp=''
91 touch=''
92 make=''
93 date=''
94 csh=''
95 Log=''
96 Header=''
97 alignbytes=''
98 bin=''
99 byteorder=''
100 contains=''
101 cppstdin=''
102 cppminus=''
103 d_bcmp=''
104 d_bcopy=''
105 d_bzero=''
106 d_castneg=''
107 castflags=''
108 d_charsprf=''
109 d_chsize=''
110 d_crypt=''
111 cryptlib=''
112 d_csh=''
113 d_dosuid=''
114 d_dup2=''
115 d_fchmod=''
116 d_fchown=''
117 d_fcntl=''
118 d_flexfnam=''
119 d_flock=''
120 d_getgrps=''
121 d_gethent=''
122 d_getpgrp=''
123 d_getpgrp2=''
124 d_getprior=''
125 d_htonl=''
126 d_index=''
127 d_ioctl=''
128 d_killpg=''
129 d_lstat=''
130 d_memcmp=''
131 d_memcpy=''
132 d_mkdir=''
133 d_ndbm=''
134 d_odbm=''
135 d_readdir=''
136 d_rename=''
137 d_rmdir=''
138 d_select=''
139 d_setegid=''
140 d_seteuid=''
141 d_setpgrp=''
142 d_setpgrp2=''
143 d_setprior=''
144 d_setregid=''
145 d_setresgid=''
146 d_setreuid=''
147 d_setresuid=''
148 d_setrgid=''
149 d_setruid=''
150 d_socket=''
151 d_sockpair=''
152 d_oldsock=''
153 socketlib=''
154 d_statblks=''
155 d_stdstdio=''
156 d_strctcpy=''
157 d_strerror=''
158 d_symlink=''
159 d_syscall=''
160 d_sysvipc=''
161 d_ipcmsg=''
162 d_ipcsem=''
163 d_ipcshm=''
164 d_truncate=''
165 d_varargs=''
166 d_vfork=''
167 d_voidsig=''
168 d_volatile=''
169 d_vprintf=''
170 d_charvspr=''
171 d_wait4=''
172 d_waitpid=''
173 gidtype=''
174 i_dirent=''
175 d_dirnamlen=''
176 i_fcntl=''
177 i_grp=''
178 i_niin=''
179 i_pwd=''
180 d_pwcomment=''
181 d_pwquota=''
182 d_pwage=''
183 d_pwchange=''
184 d_pwclass=''
185 d_pwexpire=''
186 i_sysdir=''
187 i_sysioctl=''
188 i_sysndir=''
189 i_time=''
190 i_systime=''
191 d_systimekernel=''
192 i_utime=''
193 i_varargs=''
194 i_vfork=''
195 intsize=''
196 libc=''
197 mallocsrc=''
198 mallocobj=''
199 usemymalloc=''
200 mansrc=''
201 manext=''
202 models=''
203 split=''
204 small=''
205 medium=''
206 large=''
207 huge=''
208 optimize=''
209 ccflags=''
210 cppflags=''
211 ldflags=''
212 cc=''
213 libs=''
214 n=''
215 c=''
216 package=''
217 randbits=''
218 scriptdir=''
219 sig_name=''
220 spitshell=''
221 shsharp=''
222 sharpbang=''
223 startsh=''
224 stdchar=''
225 uidtype=''
226 voidflags=''
227 defvoidused=''
228 yacc=''
229 privlib=''
230 lib=''
231 CONFIG=''
232 : set package name
233 package=perl
234
235 echo " "
236 echo "Beginning of configuration questions for $package kit."
237 : Eunice requires " " instead of "", can you believe it
238 echo " "
239
240 define='define'
241 undef='undef'
242 : change the next line if compiling for Xenix/286 on Xenix/386
243 xlibpth='/usr/lib/386 /lib/386'
244 libpth='/usr/ccs/lib /usr/lib /usr/local/lib /usr/lib/large /lib '$xlibpth' /lib/large /usr/lib/small /lib/small'
245 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
246 rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
247 trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
248
249 : We must find out about Eunice early
250 eunicefix=':'
251 if test -f /etc/unixtovms; then
252     eunicefix=/etc/unixtovms
253 fi
254 if test -f /etc/unixtovms.exe; then
255     eunicefix=/etc/unixtovms.exe
256 fi
257
258 : Now test for existence of everything in MANIFEST
259
260 echo "First let's make sure your kit is complete.  Checking..."
261 (cd ..; awk '' `awk '$1 !~ /PACKINGLIST/ {print $1}' MANIFEST` >/dev/null || kill $$)
262 echo "Looks good..."
263
264 attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
265 attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
266 attrlist="$attrlist hpux hp9000s300 hp9000s500 hp9000s800"
267 attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
268 attrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
269 attrlist="$attrlist $mc68k __STDC__ UTS M_I8086 M_I186 M_I286 M_I386"
270 attrlist="$attrlist i186 __m88k__ m88k DGUX __DGUX__"
271 pth="/usr/ccs/bin /bin /usr/bin /usr/ucb /usr/local /usr/local/bin /usr/lbin /usr/plx /usr/5bin /vol/local/bin /etc /usr/lib /lib /usr/local/lib /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/bin /bsd4.3/usr/ucb"
272 d_newshome="/usr/NeWS"
273 defvoidused=7
274 libswanted="net_s net nsl_s nsl socket nm ndir ndbm dbm sun m bsd BSD x c_s"
275 inclwanted='/usr/netinclude /usr/include/sun /usr/include/bsd /usr/include/lan'
276
277 : some greps do not return status, grrr.
278 echo "grimblepritz" >grimble
279 if grep blurfldyick grimble >/dev/null 2>&1 ; then
280     contains=contains
281 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
282     contains=grep
283 else
284     contains=contains
285 fi
286 rm -f grimble
287 : the following should work in any shell
288 case "$contains" in
289 contains*)
290     echo " "
291     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
292     cat >contains <<'EOSS'
293 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
294 EOSS
295 chmod +x contains
296 esac
297
298 : see if sh knows # comments
299 echo " "
300 echo "Checking your sh to see if it knows about # comments..."
301 if sh -c '#' >/dev/null 2>&1 ; then
302     echo "Your sh handles # comments correctly."
303     shsharp=true
304     spitshell=cat
305     echo " "
306     echo "Okay, let's see if #! works on this system..."
307     echo "#!/bin/echo hi" > try
308     $eunicefix try
309     chmod +x try
310     ./try > today
311     if $contains hi today >/dev/null 2>&1; then
312         echo "It does."
313         sharpbang='#!'
314     else
315         echo "#! /bin/echo hi" > try
316         $eunicefix try
317         chmod +x try
318         ./try > today
319         if test -s today; then
320             echo "It does."
321             sharpbang='#! '
322         else
323             echo "It doesn't."
324             sharpbang=': use '
325         fi
326     fi
327 else
328     echo "Your sh doesn't grok # comments--I will strip them later on."
329     shsharp=false
330     echo "exec grep -v '^#'" >spitshell
331     chmod +x spitshell
332     $eunicefix spitshell
333     spitshell=`pwd`/spitshell
334     echo "I presume that if # doesn't work, #! won't work either!"
335     sharpbang=': use '
336 fi
337
338 : figure out how to guarantee sh startup
339 echo " "
340 echo "Checking out how to guarantee sh startup..."
341 startsh=$sharpbang'/bin/sh'
342 echo "Let's see if '$startsh' works..."
343 cat >try <<EOSS
344 $startsh
345 set abc
346 test "$?abc" != 1
347 EOSS
348
349 chmod +x try
350 $eunicefix try
351 if ./try; then
352     echo "Yup, it does."
353 else
354     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
355 fi
356 rm -f try today
357
358 : first determine how to suppress newline on echo command
359 echo "Checking echo to see how to suppress newlines..."
360 (echo "hi there\c" ; echo " ") >.echotmp
361 if $contains c .echotmp >/dev/null 2>&1 ; then
362     echo "...using -n."
363     n='-n'
364     c=''
365 else
366     cat <<'EOM'
367 ...using \c
368 EOM
369     n=''
370     c='\c'
371 fi
372 echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
373 read ans
374 rm -f .echotmp
375
376 : now set up to do reads with possible shell escape and default assignment
377 cat <<EOSC >myread
378 case "\$fastread" in
379 yes) ans=''; echo " " ;;
380 *) ans='!';;
381 esac
382 while expr "X\$ans" : "X!" >/dev/null; do
383     read ans
384     case "\$ans" in
385     !)
386         sh
387         echo " "
388         echo $n "\$rp $c"
389         ;;
390     !*)
391         set \`expr "X\$ans" : "X!\(.*\)\$"\`
392         sh -c "\$*"
393         echo " "
394         echo $n "\$rp $c"
395         ;;
396     esac
397 done
398 rp='Your answer:'
399 case "\$ans" in
400 '') ans="\$dflt";;
401 esac
402 EOSC
403
404 : general instructions
405 cat <<EOH
406  
407 This installation shell script will examine your system and ask you questions
408 to determine how the $package package should be installed.  If you get stuck
409 on a question, you may use a ! shell escape to start a subshell or execute
410 a command.  Many of the questions will have default answers in square
411 brackets--typing carriage return will give you the default.
412
413 On some of the questions which ask for file or directory names you are
414 allowed to use the ~name construct to specify the login directory belonging
415 to "name", even if you don't have a shell which knows about that.  Questions
416 where this is allowed will be marked "(~name ok)".
417
418 EOH
419 rp="[Type carriage return to continue]"
420 echo $n "$rp $c"
421 . myread
422 cat <<EOH
423
424 Much effort has been expended to ensure that this shell script will run
425 on any Unix system.  If despite that it blows up on you, your best bet is
426 to edit Configure and run it again. Also, let me (lwall@jpl-devvax.jpl.nasa.gov)
427 know how I blew it.  If you can't run Configure for some reason, you'll have
428 to generate a config.sh file by hand.
429
430 This installation script affects things in two ways: 1) it may do direct
431 variable substitutions on some of the files included in this kit, and
432 2) it builds a config.h file for inclusion in C programs.  You may edit
433 any of these files as the need arises after running this script.
434
435 If you make a mistake on a question, there is no easy way to back up to it
436 currently.  The easiest thing to do is to edit config.sh and rerun all the
437 SH files.  Configure will offer to let you do this before it runs the SH files.
438
439 EOH
440 rp="[Type carriage return to continue]"
441 echo $n "$rp $c"
442 . myread
443
444 : get old answers, if there is a config file out there
445 if test -f ../config.sh; then
446     echo " "
447     dflt=y
448     rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
449     echo $n "$rp $c"
450     . myread
451     case "$ans" in
452     n*) echo "OK, I'll ignore it.";;
453     *)  echo "Fetching default answers from your old config.sh file..."
454         tmp="$n"
455         ans="$c"
456         . ../config.sh
457         n="$tmp"
458         c="$ans"
459         ;;
460     esac
461 fi
462
463 : find out where common programs are
464 echo " "
465 echo "Locating common programs..."
466 cat <<EOSC >loc
467 $startsh
468 case \$# in
469 0) exit 1;;
470 esac
471 thing=\$1
472 shift
473 dflt=\$1
474 shift
475 for dir in \$*; do
476     case "\$thing" in
477     .)
478         if test -d \$dir/\$thing; then
479             echo \$dir
480             exit 0
481         fi
482         ;;
483     *)
484         if test -f \$dir/\$thing; then
485             echo \$dir/\$thing
486             exit 0
487         elif test -f \$dir/\$thing.exe; then
488             : on Eunice apparently
489             echo \$dir/\$thing
490             exit 0
491         fi
492         ;;
493     esac
494 done
495 echo \$dflt
496 exit 1
497 EOSC
498 chmod +x loc
499 $eunicefix loc
500 loclist="
501 cat
502 cp
503 echo
504 expr
505 grep
506 mkdir
507 mv
508 rm
509 sed
510 sort
511 tr
512 uniq
513 "
514 trylist="
515 Mcc
516 cpp
517 csh
518 egrep
519 test
520 "
521 for file in $loclist; do
522     xxx=`./loc $file $file $pth`
523     eval $file=$xxx
524     eval _$file=$xxx
525     case "$xxx" in
526     /*)
527         echo $file is in $xxx.
528         ;;
529     *)
530         echo "I don't know where $file is.  I hope it's in everyone's PATH."
531         ;;
532     esac
533 done
534 echo " "
535 echo "Don't worry if any of the following aren't found..."
536 ans=offhand
537 for file in $trylist; do
538     xxx=`./loc $file $file $pth`
539     eval $file=$xxx
540     eval _$file=$xxx
541     case "$xxx" in
542     /*)
543         echo $file is in $xxx.
544         ;;
545     *)
546         echo "I don't see $file out there, $ans."
547         ans=either
548         ;;
549     esac
550 done
551 case "$egrep" in
552 egrep)
553     echo "Substituting grep for egrep."
554     egrep=$grep
555     ;;
556 esac
557 case "$test" in
558 test)
559     echo "Hopefully test is built into your sh."
560     ;;
561 /bin/test)
562     if sh -c "PATH= test true" >/dev/null 2>&1; then
563         echo "Using the test built into your sh."
564         test=test
565     fi
566     ;;
567 *)
568     test=test
569     ;;
570 esac
571 case "$echo" in
572 echo)
573     echo "Hopefully echo is built into your sh."
574     ;;
575 /bin/echo)
576     echo " "
577     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
578     $echo $n "hi there$c" >foo1
579     echo $n "hi there$c" >foo2
580     if cmp foo1 foo2 >/dev/null 2>&1; then
581         echo "They are compatible.  In fact, they may be identical."
582     else
583         case "$n" in
584         '-n') n='' c='\c' ans='\c' ;;
585         *) n='-n' c='' ans='-n' ;;
586         esac
587         cat <<FOO
588 They are not compatible!  You are probably running ksh on a non-USG system.
589 I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
590 have echo built in and we may have to run some Bourne shell scripts.  That
591 means I'll have to use $ans to suppress newlines now.  Life is ridiculous.
592
593 FOO
594         rp="Your cursor should be here-->"
595         $echo $n "$rp$c"
596         . myread
597     fi
598     $rm -f foo1 foo2
599     ;;
600 *)
601     : cross your fingers
602     echo=echo
603     ;;
604 esac
605 rmlist="$rmlist loc"
606
607 : set up shell script to do ~ expansion
608 cat >filexp <<EOSS
609 $startsh
610 : expand filename
611 case "\$1" in
612  ~/*|~)
613     echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
614     ;;
615  ~*)
616     if $test -f /bin/csh; then
617         /bin/csh -f -c "glob \$1"
618         echo ""
619     else
620         name=\`$expr x\$1 : '..\([^/]*\)'\`
621         dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
622         if $test ! -d "\$dir"; then
623             me=\`basename \$0\`
624             echo "\$me: can't locate home directory for: \$name" >&2
625             exit 1
626         fi
627         case "\$1" in
628         */*)
629             echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
630             ;;
631         *)
632             echo \$dir
633             ;;
634         esac
635     fi
636     ;;
637 *)
638     echo \$1
639     ;;
640 esac
641 EOSS
642 chmod +x filexp
643 $eunicefix filexp
644
645 : determine where manual pages go
646 $cat <<EOM
647   
648 $package has manual pages that need to be installed in source form.
649 EOM
650 case "$mansrc" in
651 '')
652     dflt=`./loc . /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1 /usr/man/man.L`
653     ;;
654 *)  dflt="$mansrc"
655     ;;
656 esac
657 cont=true
658 while $test "$cont" ; do
659     echo " "
660     rp="Where do the manual pages (source) go? (~name ok) [$dflt]"
661     $echo $n "$rp $c"
662     . myread
663     mansrc=`./filexp "$ans"`
664     if $test -d "$mansrc"; then
665         cont=''
666     else
667         if $test "$fastread" = yes; then
668             dflt=y
669         else
670             dflt=n
671         fi
672         rp="Directory $mansrc doesn't exist.  Use that name anyway? [$dflt]"
673         $echo $n "$rp $c"
674         . myread
675         dflt=''
676         case "$ans" in
677         y*) cont='';;
678         esac
679     fi
680 done
681 case "$mansrc" in
682 *l)
683     manext=l
684     ;;
685 *n)
686     manext=n
687     ;;
688 *o)
689     manext=l
690     ;;
691 *p)
692     manext=p
693     ;;
694 *C)
695     manext=C
696     ;;
697 *L)
698     manext=L
699     ;;
700 *)
701     manext=1
702     ;;
703 esac
704
705 : make some quick guesses about what we are up against
706 echo " "
707 $echo $n "Hmm...  $c"
708 cat /usr/include/signal.h /usr/include/sys/signal.h >foo
709 if test `echo abc | tr a-z A-Z` = Abc ; then
710     echo "Looks kind of like a USG system, but we'll see..."
711     echo exit 1 >bsd
712     echo exit 0 >usg
713     echo exit 1 >v7
714 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
715     echo "Looks kind of like a BSD system, but we'll see..."
716     echo exit 0 >bsd
717     echo exit 1 >usg
718     echo exit 1 >v7
719 else
720     echo "Looks kind of like a version 7 system, but we'll see..."
721     echo exit 1 >bsd
722     echo exit 1 >usg
723     echo exit 0 >v7
724 fi
725 case "$eunicefix" in
726 *unixtovms*)
727     cat <<'EOI'
728 There is, however, a strange, musty smell in the air that reminds me of
729 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
730 EOI
731     echo "exit 0" >eunice
732     d_eunice="$define"
733     ;;
734 *)
735     echo " "
736     echo "Congratulations.  You aren't running Eunice."
737     d_eunice="$undef"
738     echo "exit 1" >eunice
739     ;;
740 esac
741 if test -f /xenix; then
742     echo "Actually, this looks more like a XENIX system..."
743     echo "exit 0" >xenix
744 else
745     echo " "
746     echo "It's not Xenix..."
747     echo "exit 1" >xenix
748 fi
749 chmod +x xenix
750 $eunicefix xenix
751 if test -f /venix; then
752     echo "Actually, this looks more like a VENIX system..."
753     echo "exit 0" >venix
754 else
755     echo " "
756     if xenix; then
757         : null
758     else
759         echo "Nor is it Venix..."
760     fi
761     echo "exit 1" >venix
762 fi
763 chmod +x bsd usg v7 eunice venix
764 $eunicefix bsd usg v7 eunice venix
765 rm -rf foo
766 rmlist="$rmlist bsd usg v7 eunice venix xenix"
767
768 : see what memory models we can support
769 case "$models" in
770 '')
771     : We may not use Cppsym or we get a circular dependency through cc.
772     : But this should work regardless of which cc we eventually use.
773     cat >pdp11.c <<'EOP'
774 main() {
775 #ifdef pdp11
776     exit(0);
777 #else
778     exit(1);
779 #endif
780 }
781 EOP
782     cc -o pdp11 pdp11.c >/dev/null 2>&1
783     if pdp11 2>/dev/null; then
784         dflt='unsplit split'
785     else
786         ans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
787         case "$ans" in
788         X) dflt='none';;
789         *)  if $test -d /lib/small || $test -d /usr/lib/small; then
790                 dflt='small'
791             else
792                 dflt=''
793             fi
794             if $test -d /lib/medium || $test -d /usr/lib/medium; then
795                 dflt="$dflt medium"
796             fi
797             if $test -d /lib/large || $test -d /usr/lib/large; then
798                 dflt="$dflt large"
799             fi
800             if $test -d /lib/huge || $test -d /usr/lib/huge; then
801                 dflt="$dflt huge"
802             fi
803         esac
804     fi
805     ;;
806 *)  dflt="$models" ;;
807 esac
808 $cat <<EOM
809  
810 Some systems have different model sizes.  On most systems they are called
811 small, medium, large, and huge.  On the PDP11 they are called unsplit and
812 split.  If your system doesn't support different memory models, say "none".
813 If you wish to force everything to one memory model, say "none" here and
814 put the appropriate flags later when it asks you for other cc and ld flags.
815 Venix systems may wish to put "none" and let the compiler figure things out.
816 (In the following question multiple model names should be space separated.)
817
818 EOM
819 rp="Which models are supported? [$dflt]"
820 $echo $n "$rp $c"
821 . myread
822 models="$ans"
823
824 case "$models" in
825 none)
826     small=''
827     medium=''
828     large=''
829     huge=''
830     unsplit=''
831     split=''
832     ;;
833 *split)
834     case "$split" in
835     '') 
836         if $contains '\-i' $mansrc/man1/ld.1 >/dev/null 2>&1 || \
837            $contains '\-i' $mansrc/man1/cc.1 >/dev/null 2>&1; then
838             dflt='-i'
839         else
840             dflt='none'
841         fi
842         ;;
843     *) dflt="$split";;
844     esac
845     rp="What flag indicates separate I and D space? [$dflt]"
846     $echo $n "$rp $c"
847     . myread
848     case "$ans" in
849     none) ans='';;
850     esac
851     split="$ans"
852     unsplit=''
853     ;;
854 *large*|*small*|*medium*|*huge*)
855     case "$models" in
856     *large*)
857         case "$large" in
858         '') dflt='-Ml';;
859         *) dflt="$large";;
860         esac
861         rp="What flag indicates large model? [$dflt]"
862         $echo $n "$rp $c"
863         . myread
864         case "$ans" in
865         none) ans='';
866         esac
867         large="$ans"
868         ;;
869     *) large='';;
870     esac
871     case "$models" in
872     *huge*)
873         case "$huge" in
874         '') dflt='-Mh';;
875         *) dflt="$huge";;
876         esac
877         rp="What flag indicates huge model? [$dflt]"
878         $echo $n "$rp $c"
879         . myread
880         case "$ans" in
881         none) ans='';
882         esac
883         huge="$ans"
884         ;;
885     *) huge="$large";;
886     esac
887     case "$models" in
888     *medium*)
889         case "$medium" in
890         '') dflt='-Mm';;
891         *) dflt="$medium";;
892         esac
893         rp="What flag indicates medium model? [$dflt]"
894         $echo $n "$rp $c"
895         . myread
896         case "$ans" in
897         none) ans='';
898         esac
899         medium="$ans"
900         ;;
901     *) medium="$large";;
902     esac
903     case "$models" in
904     *small*)
905         case "$small" in
906         '') dflt='none';;
907         *) dflt="$small";;
908         esac
909         rp="What flag indicates small model? [$dflt]"
910         $echo $n "$rp $c"
911         . myread
912         case "$ans" in
913         none) ans='';
914         esac
915         small="$ans"
916         ;;
917     *) small='';;
918     esac
919     ;;
920 *)
921     echo "Unrecognized memory models--you may have to edit Makefile.SH"
922     ;;
923 esac
924
925 : see if we need a special compiler
926 echo " "
927 if usg; then
928     case "$cc" in
929     '')
930         case "$Mcc" in
931         /*) dflt='Mcc'
932             ;;
933         *)
934             case "$large" in
935             -M*)
936                 dflt='cc'
937                 ;;
938             *)
939                 if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
940                     dflt='cc -M'
941                 else
942                     dflt='cc'
943                 fi
944                 ;;
945             esac
946             ;;
947         esac
948         ;;
949     *)  dflt="$cc";;
950     esac
951     $cat <<'EOM'
952   
953 On some systems the default C compiler will not resolve multiple global
954 references that happen to have the same name.  On some such systems the
955 "Mcc" command may be used to force these to be resolved.  On other systems
956 a "cc -M" command is required.  (Note that the -M flag on other systems
957 indicates a memory model to use!)  If you have the Gnu C compiler, you
958 might wish to use that instead.  What command will force resolution on
959 EOM
960     $echo $n "this system? [$dflt] $c"
961     rp="Command to resolve multiple refs? [$dflt]"
962     . myread
963     cc="$ans"
964 else
965     case "$cc" in
966     '') dflt=cc;;
967     *) dflt="$cc";;
968     esac
969     rp="Use which C compiler? [$dflt]"
970     $echo $n "$rp $c"
971     . myread
972     cc="$ans"
973 fi
974 case "$cc" in
975 gcc*) cpp=`./loc gcc-cpp $cpp $pth`;;
976 esac
977
978 : determine optimize, if desired, or use for debug flag also
979 case "$optimize" in
980 ' ') dflt="none"
981      ;;
982 '') dflt="-O";
983     ;;
984 *)  dflt="$optimize"
985     ;;
986 esac
987 cat <<EOH
988
989 Some C compilers have problems with their optimizers, by default, $package
990 compiles with the -O flag to use the optimizer.  Alternately, you might
991 want to use the symbolic debugger, which uses the -g flag (on traditional
992 Unix systems).  Either flag can be specified here.  To use neither flag,
993 specify the word "none".
994   
995 EOH
996 rp="What optimizer/debugger flag should be used? [$dflt]"
997 $echo $n "$rp $c"
998 . myread
999 optimize="$ans"
1000 case "$optimize" in
1001 'none') optimize=" "
1002      ;;
1003 esac
1004
1005 case "$ccflags" in
1006 '') case "$cc" in
1007     *gcc*) dflt='-fpcc-struct-return';;
1008     *) dflt='';;
1009     esac
1010     ;;
1011 *) dflt="$ccflags";;
1012 esac
1013 for thisincl in $inclwanted; do
1014     if test -d $thisincl; then
1015         case "$dflt" in
1016         *$thisincl*);;
1017         *) dflt="$dflt -I$thisincl";;
1018         esac
1019     fi
1020 done
1021 case "$optimize" in
1022 -g*)
1023     case "$dflt" in
1024     *DEBUGGING*);;
1025     *) dflt="$dflt -DDEBUGGING";;
1026     esac
1027     ;;
1028 esac
1029 if $contains 'LANGUAGE_C' /usr/include/signal.h >/dev/null 2>&1; then
1030     case "$dflt" in
1031     *LANGUAGE_C*);;
1032     *) dflt="$dflt -DLANGUAGE_C";;
1033     esac
1034 fi
1035 case "$dflt" in
1036 '') dflt=none;;
1037 esac
1038 cat <<EOH
1039
1040 Your C compiler may want other flags.  For this question you should
1041 include -I/whatever and -DWHATEVER flags and any other flags used by
1042 the C compiler, but you should NOT include libraries or ld flags like
1043 -lwhatever.  To use no flags, specify the word "none".
1044   
1045 EOH
1046 rp="Any additional cc flags? [$dflt]"
1047 $echo $n "$rp $c"
1048 . myread
1049 case "$ans" in
1050 none) ans='';
1051 esac
1052 ccflags="$ans"
1053
1054 : the following weeds options from ccflags that are of no interest to cpp
1055 cppflags="$ccflags"
1056 case "$cc" in
1057 *gcc*) cppflags="$cppflags -D__GNUC__";;
1058 esac
1059 case "$cppflags" in
1060 '');;
1061 *)  set X $cppflags
1062     cppflags=''
1063     for flag do
1064         case $flag in
1065         -D*|-I*) cppflags="$cppflags $flag";;
1066         esac
1067     done
1068     case "$cppflags" in
1069     *-*)  echo "(C preprocessor flags: $cppflags)";;
1070     esac
1071     ;;
1072 esac
1073
1074 case "$ldflags" in
1075 '') if venix; then
1076         dflt='-i -z'
1077     else
1078         dflt='none'
1079     fi
1080     ;;
1081 *) dflt="$ldflags";;
1082 esac
1083 echo " "
1084 rp="Any additional ld flags (NOT including libraries)? [$dflt]"
1085 $echo $n "$rp $c"
1086 . myread
1087 case "$ans" in
1088 none) ans='';
1089 esac
1090 ldflags="$ans"
1091 rmlist="$rmlist pdp11"
1092
1093 echo " "
1094 echo "Checking for optional libraries..."
1095 dflt=''
1096 case "$libswanted" in
1097 '') libswanted='c_s';;
1098 esac
1099 for thislib in $libswanted; do
1100     case "$thislib" in
1101     dbm) thatlib=ndbm;;
1102     *_s) thatlib=NONE;;
1103     *) thatlib="${thislib}_s";;
1104     *) thatlib=NONE;;
1105     esac
1106     xxx=`./loc lib$thislib.a X /usr/ccs/lib /usr/lib /usr/local/lib /lib`
1107     if test -f $xxx; then
1108         echo "Found -l$thislib."
1109         case "$dflt" in
1110         *-l$thislib*|*-l$thatlib*);;
1111         *) dflt="$dflt -l$thislib";;
1112         esac
1113     else
1114         xxx=`./loc lib$thislib.a X $libpth`
1115         if test -f $xxx; then
1116             echo "Found $xxx."
1117             case "$dflt" in
1118             *$xxx*);;
1119             *) dflt="$dflt $xxx";;
1120             esac
1121         else
1122             xxx=`./loc Slib$thislib.a X $xlibpth`
1123             if test -f $xxx; then
1124                 echo "Found -l$thislib."
1125                 case "$dflt" in
1126                 *-l$thislib*|*-l$thatlib*);;
1127                 *) dflt="$dflt -l$thislib";;
1128                 esac
1129             else
1130                 echo "No -l$thislib."
1131             fi
1132         fi
1133     fi
1134 done
1135 set X $dflt
1136 shift
1137 dflt="$*"
1138 case "$libs" in
1139 '') dflt="$dflt";;
1140 *) dflt="$libs";;
1141 esac
1142 case "$dflt" in
1143 '') dflt='none';;
1144 esac
1145
1146 $cat <<EOM
1147  
1148 Some versions of Unix support shared libraries, which make
1149 executables smaller but make load time slightly longer.
1150
1151 On some systems, mostly newer Unix System V's, the shared library
1152 is included by putting the option "-lc_s" as the last thing on the
1153 cc command line when linking.  Other systems use shared libraries
1154 by default.  There may be other libraries needed to compile $package
1155 on your machine as well.  If your system needs the "-lc_s" option,
1156 include it here.  Include any other special libraries here as well.
1157 Say "none" for none.
1158 EOM
1159
1160 echo " "
1161 rp="Any additional libraries? [$dflt]"
1162 $echo $n "$rp $c"
1163 . myread
1164 case "$ans" in
1165 none) ans='';
1166 esac
1167 libs="$ans"
1168
1169 : check for size of random number generator
1170 echo " "
1171 case "$alignbytes" in
1172 '')
1173     echo "Checking alignment constraints..."
1174     $cat >try.c <<'EOCP'
1175 struct foobar {
1176     char foo;
1177     double bar;
1178 } try;
1179 main()
1180 {
1181     printf("%d\n", (char*)&try.bar - (char*)&try.foo);
1182 }
1183 EOCP
1184     if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
1185         dflt=`./try`
1186     else
1187         dflt='?'
1188         echo "(I can't seem to compile the test program...)"
1189     fi
1190     ;;
1191 *)
1192     dflt="$alignbytes"
1193     ;;
1194 esac
1195 rp="Doubles must be aligned on a how-many-byte boundary? [$dflt]"
1196 $echo $n "$rp $c"
1197 . myread
1198 alignbytes="$ans"
1199 $rm -f try.c try
1200
1201 : determine where public executables go
1202 case "$bin" in
1203 '')
1204     dflt=`./loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
1205     ;;
1206 *)  dflt="$bin"
1207     ;;
1208 esac
1209 cont=true
1210 while $test "$cont" ; do
1211     echo " "
1212     rp="Where do you want to put the public executables? (~name ok) [$dflt]"
1213     $echo $n "$rp $c"
1214     . myread
1215     bin="$ans"
1216     bin=`./filexp "$bin"`
1217     if test -d $bin; then
1218         cont=''
1219     else
1220         case "$fastread" in
1221         yes) dflt=y;;
1222         *) dflt=n;;
1223         esac
1224         rp="Directory $bin doesn't exist.  Use that name anyway? [$dflt]"
1225         $echo $n "$rp $c"
1226         . myread
1227         dflt=''
1228         case "$ans" in
1229         y*) cont='';;
1230         esac
1231     fi
1232 done
1233
1234 : check for ordering of bytes in a long
1235 case "$byteorder" in
1236 '')
1237 cat <<'EOM'
1238   
1239 In the following, larger digits indicate more significance.  A big-endian
1240 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321.  A
1241 little-endian machine like a Vax or an Intel 80?86 chip would be 1234.  Other
1242 machines may have weird orders like 3412.  A Cray will report 87654321.  If
1243 the test program works the default is probably right.
1244 I'm now running the test program...
1245 EOM
1246     $cat >try.c <<'EOCP'
1247 #include <stdio.h>
1248 main()
1249 {
1250     int i;
1251     union {
1252         unsigned long l;
1253         char c[sizeof(long)];
1254     } u;
1255
1256     if (sizeof(long) > 4)
1257         u.l = (0x08070605<<32) | 0x04030201;
1258     else
1259         u.l = 0x04030201;
1260     for (i=0; i < sizeof(long); i++)
1261         printf("%c",u.c[i]+'0');
1262     printf("\n");
1263 }
1264 EOCP
1265     if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
1266         dflt=`./try`
1267         case "$dflt" in
1268         ????|????????) echo "(The test program ran ok.)";;
1269         *) echo "(The test program didn't run right for some reason.)";;
1270         esac
1271     else
1272         dflt='4321'
1273         echo "(I can't seem to compile the test program.  Guessing big-endian...)"
1274     fi
1275     ;;
1276 *)
1277     echo " "
1278     dflt="$byteorder"
1279     ;;
1280 esac
1281 rp="What is the order of bytes in a long? [$dflt]"
1282 $echo $n "$rp $c"
1283 . myread
1284 byteorder="$ans"
1285 $rm -f try.c try
1286
1287 : check for ability to cast negative floats to unsigned
1288 echo " "
1289 echo 'Checking to see if your C compiler can cast weird floats to unsigned'
1290 $cat >try.c <<'EOCP'
1291 main()
1292 {
1293         double f = -123;
1294         unsigned long along;
1295         unsigned int aint;
1296         unsigned short ashort;
1297         int result = 0;
1298
1299         along = (unsigned long)f;
1300         aint = (unsigned int)f;
1301         ashort = (unsigned short)f;
1302         if (along != (unsigned long)-123)
1303             result |= 1;
1304         if (aint != (unsigned int)-123)
1305             result |= 1;
1306         if (ashort != (unsigned short)-123)
1307             result |= 1;
1308         f = (double)0x40000000;
1309         f = f + f;
1310         along = (unsigned long)f;
1311         if (along != 0x80000000)
1312             result |= 2;
1313         f -= 1;
1314         along = (unsigned long)f;
1315         if (along != 0x7fffffff)
1316             result |= 1;
1317         f += 2;
1318         along = (unsigned long)f;
1319         if (along != 0x80000001)
1320             result |= 2;
1321         exit(result);
1322 }
1323 EOCP
1324 if $cc -o try $ccflags try.c >/dev/null 2>&1 && ./try; then
1325     d_castneg="$define"
1326     castflags=0
1327     echo "Yup, it does."
1328 else
1329     d_castneg="$undef"
1330     castflags=$?
1331     echo "Nope, it doesn't."
1332 fi
1333 $rm -f try.*
1334
1335 : see how we invoke the C preprocessor
1336 echo " "
1337 echo "Now, how can we feed standard input to your C preprocessor..."
1338 cat <<'EOT' >testcpp.c
1339 #define ABC abc
1340 #define XYZ xyz
1341 ABC.XYZ
1342 EOT
1343 echo 'Maybe "'"$cc"' -E" will work...'
1344 $cc -E <testcpp.c >testcpp.out 2>&1
1345 : try to force gcc preprocessor if that is the compiler they are using
1346 case $? in
1347 0) cppstdin="$cc -E";;
1348 *) case "$cc" in
1349     *gcc*)
1350         cd ..
1351         echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
1352         echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
1353         chmod 755 cppstdin
1354         cppstdin=`pwd`/cppstdin
1355         cppminus='';
1356         cd UU
1357         $cppstdin <testcpp.c >testcpp.out 2>&1
1358         ;;
1359     esac
1360     ;;
1361 esac
1362 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1363     echo "Yup, it does."
1364     cppstdin="$cc -E"
1365     cppminus='';
1366 else
1367     echo 'Nope...maybe "'"$cc"' -E -" will work...'
1368     $cc -E - <testcpp.c >testcpp.out 2>&1
1369     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1370         echo "Yup, it does."
1371         cppstdin="$cc -E"
1372         cppminus='-';
1373     else
1374         echo 'No such luck, maybe "'$cpp'" will work...'
1375         $cpp <testcpp.c >testcpp.out 2>&1
1376         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1377             echo "It works!"
1378             cppstdin="$cpp"
1379             cppminus='';
1380         else
1381             echo 'Nixed again...maybe "'$cpp' -" will work...'
1382             $cpp - <testcpp.c >testcpp.out 2>&1
1383             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1384                 echo "Hooray, it works!  I was beginning to wonder."
1385                 cppstdin="$cpp"
1386                 cppminus='-';
1387             else
1388                 echo 'Nope...maybe "'"$cc"' -P" will work...'
1389                 $cc -P <testcpp.c >testcpp.out 2>&1
1390                 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1391                     echo "Yup, that does."
1392                     cppstdin="$cc -P"
1393                     cppminus='';
1394                 else
1395                     echo 'Nope...maybe "'"$cc"' -P -" will work...'
1396                     $cc -P - <testcpp.c >testcpp.out 2>&1
1397                     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1398                         echo "Yup, that does."
1399                         cppstdin="$cc -P"
1400                         cppminus='-';
1401                     else
1402                         echo 'Hmm...perhaps you already told me...'
1403                         case "$cppstdin" in
1404                         '') ;;
1405                         *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
1406                         esac
1407                         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1408                             echo "Hooray, you did!  I was beginning to wonder."
1409                         else
1410                             echo 'Uh-uh.  Time to get fancy...'
1411                             cd ..
1412                             echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
1413                             echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
1414                             chmod 755 cppstdin
1415                             cppstdin=`pwd`/cppstdin
1416                             cppminus='';
1417                             cd UU
1418                             $cppstdin <testcpp.c >testcpp.out 2>&1
1419                             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1420                                 echo "Eureka!."
1421                             else
1422                                 dflt=blurfl
1423                                 $echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
1424                                 rp='Name a C preprocessor:'
1425                                 . myread
1426                                 cppstdin="$ans"
1427                                 $cppstdin <testcpp.c >testcpp.out 2>&1
1428                                 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1429                                     echo "OK, that will do."
1430                                 else
1431                                     echo "Sorry, I can't get that to work.  Go find one."
1432                                     exit 1
1433                                 fi
1434                             fi
1435                         fi
1436                     fi
1437                 fi
1438             fi
1439         fi
1440     fi
1441 fi
1442 rm -f testcpp.c testcpp.out
1443
1444 : get list of predefined functions in a handy place
1445 echo " "
1446 case "$libc" in
1447 '') libc=unknown;;
1448 esac
1449 case "$libpth" in
1450 '') libpth='/usr/ccs/lib /lib /usr/lib /usr/local/lib';;
1451 esac
1452 case "$libs" in
1453 *-lc_s*) libc=`./loc libc_s.a $libc $libpth`
1454 esac
1455 libnames='';
1456 case "$libs" in
1457 '') ;;
1458 *)  for thislib in $libs; do
1459         case "$thislib" in
1460         -l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
1461             try=`./loc lib$thislib.a blurfl/dyick $libpth`
1462             if test ! -f $try; then
1463                 try=`./loc lib$thislib blurfl/dyick $libpth`
1464                 if test ! -f $try; then
1465                     try=`./loc $thislib blurfl/dyick $libpth`
1466                     if test ! -f $try; then
1467                         try=`./loc Slib$thislib.a blurfl/dyick $xlibpth`
1468                         if test ! -f $try; then
1469                             try=''
1470                         fi
1471                     fi
1472                 fi
1473             fi
1474             libnames="$libnames $try"
1475             ;;
1476         *) libnames="$libnames $thislib" ;;
1477         esac
1478     done
1479     ;;
1480 esac
1481 set /usr/ccs/lib/libc.so
1482 test -f $1 || set /usr/lib/libc.so
1483 test -f $1 || set /usr/lib/libc.so.[0-9]*
1484 eval set \$$#
1485 if test -f "$1"; then
1486     echo "Your shared C library is in $1."
1487     libc="$1"
1488 elif test -f $libc; then
1489     echo "Your C library is in $libc, like you said before."
1490     if test $libc = "/lib/libc"; then
1491         libc="$libc /lib/clib"
1492     fi
1493 elif test -f /lib/libc.a; then
1494     echo "Your C library is in /lib/libc.a.  You're normal."
1495     libc=/lib/libc.a
1496 else
1497     ans=`./loc libc.a blurfl/dyick $libpth`
1498     if test ! -f "$ans"; then
1499         ans=`./loc Slibc.a blurfl/dyick $xlibpth`
1500     fi
1501     if test ! -f "$ans"; then
1502         ans=`./loc Mlibc.a blurfl/dyick $xlibpth`
1503     fi
1504     if test ! -f "$ans"; then
1505         ans=`./loc Llibc.a blurfl/dyick $xlibpth`
1506     fi
1507     if test ! -f "$ans"; then
1508         ans=`./loc libc blurfl/dyick $libpth`
1509     fi
1510     if test ! -f "$ans"; then
1511         ans=`./loc clib blurfl/dyick $libpth`
1512     else
1513         libnames="$libnames "`./loc clib blurfl/dyick $libpth`
1514     fi
1515     if test -f "$ans"; then
1516         echo "Your C library is in $ans, of all places."
1517         libc=$ans
1518     else
1519         cat <<EOM
1520  
1521 I can't seem to find your C library.  I've looked in the following places:
1522
1523         $libpth
1524
1525 None of these seems to contain your C library.  What is the full name
1526 EOM
1527         dflt=None
1528         $echo $n "of your C library? $c"
1529         rp='C library full name?'
1530         . myread
1531         libc="$ans"
1532     fi
1533 fi
1534 echo " "
1535 set `echo $libc $libnames | tr ' ' '\012' | sort | uniq`
1536 $echo $n "Extracting names from $* for later perusal...$c"
1537 nm $* 2>/dev/null >libc.tmp
1538 $sed -n -e 's/^.* [ATDS]  *_[_.]*//p' -e 's/^.* [ATDS] //p' <libc.tmp >libc.list
1539 if $contains '^printf$' libc.list >/dev/null 2>&1; then
1540     echo "done"
1541 else
1542     $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' <libc.tmp >libc.list
1543     $contains '^printf$' libc.list >/dev/null 2>&1 || \
1544         $sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p' <libc.tmp >libc.list
1545     $contains '^printf$' libc.list >/dev/null 2>&1 || \
1546         $sed -n -e 's/^.* D __*//p' -e 's/^.* D //p' <libc.tmp >libc.list
1547     $contains '^printf$' libc.list >/dev/null 2>&1 || \
1548        $sed -n -e 's/^_//' \
1549               -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' <libc.tmp >libc.list
1550     $contains '^printf$' libc.list >/dev/null 2>&1 || \
1551         $sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p' \
1552            <libc.tmp >libc.list
1553     if $contains '^printf$' libc.list >/dev/null 2>&1; then
1554         echo "done"
1555     else
1556         echo " "
1557         echo "nm didn't seem to work right."
1558         echo "Trying ar instead..."
1559         if ar t $libc > libc.tmp; then
1560             for thisname in $libnames; do
1561                 ar t $thisname >>libc.tmp
1562             done
1563             $sed -e 's/\.o$//' < libc.tmp > libc.list
1564             echo "Ok."
1565         else
1566             echo "ar didn't seem to work right."
1567             echo "Maybe this is a Cray...trying bld instead..."
1568             if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
1569                 for thisname in $libnames; do
1570                     bld t $libnames | \
1571                         $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
1572                     ar t $thisname >>libc.tmp
1573                 done
1574                 echo "Ok."
1575             else
1576                 echo "That didn't work either.  Giving up."
1577                 exit 1
1578             fi
1579         fi
1580     fi
1581 fi
1582
1583 inlibc='echo " ";
1584 if $contains "^$1\$" libc.list >/dev/null 2>&1;
1585 then echo "$1() found"; eval "$2=$define";
1586 else echo "$1() not found"; eval "$2=$undef"; fi'
1587
1588 rmlist="$rmlist libc.tmp libc.list"
1589
1590 : see if bcmp exists
1591 set bcmp d_bcmp
1592 eval $inlibc
1593
1594 : see if bcopy exists
1595 set bcopy d_bcopy
1596 eval $inlibc
1597
1598 : see if bzero exists
1599 set bzero d_bzero
1600 eval $inlibc
1601
1602 : see if sprintf is declared as int or pointer to char
1603 echo " "
1604 cat >.ucbsprf.c <<'EOF'
1605 main() { char buf[10]; exit((unsigned long)sprintf(buf,"%s","foo") > 10L); }
1606 EOF
1607 if $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
1608     echo "Your sprintf() returns (int)."
1609     d_charsprf="$undef"
1610 else
1611     echo "Your sprintf() returns (char*)."
1612     d_charsprf="$define"
1613 fi
1614 /bin/rm -f .ucbsprf.c .ucbsprf
1615
1616 : see if vprintf exists
1617 echo " "
1618 if $contains '^vprintf$' libc.list >/dev/null 2>&1; then
1619     echo 'vprintf() found.'
1620     d_vprintf="$define"
1621     cat >.ucbsprf.c <<'EOF'
1622 #include <stdio.h>
1623 #include <varargs.h>
1624
1625 main() { xxx("foo"); }
1626
1627 xxx(va_alist)
1628 va_dcl
1629 {
1630     va_list args;
1631     char buf[10];
1632
1633     va_start(args);
1634     exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
1635 }
1636 EOF
1637     if $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
1638         echo "Your vsprintf() returns (int)."
1639         d_charvspr="$undef"
1640     else
1641         echo "Your vsprintf() returns (char*)."
1642         d_charvspr="$define"
1643     fi
1644     /bin/rm -f .ucbsprf.c .ucbsprf
1645 else
1646     echo 'vprintf() not found.'
1647     d_vprintf="$undef"
1648     d_charvspr="$undef"
1649 fi
1650
1651 : see if chsize exists
1652 set chsize d_chsize
1653 eval $inlibc
1654
1655 : see if crypt exists
1656 echo " "
1657 if $contains '^crypt$' libc.list >/dev/null 2>&1; then
1658     echo 'crypt() found.'
1659     d_crypt="$define"
1660     cryptlib=''
1661 else
1662     cryptlib=`./loc Slibcrypt.a "" $xlibpth`
1663     if $test -z "$cryptlib"; then
1664         cryptlib=`./loc Mlibcrypt.a "" $xlibpth`
1665     else
1666         cryptlib=-lcrypt
1667     fi
1668     if $test -z "$cryptlib"; then
1669         cryptlib=`./loc Llibcrypt.a "" $xlibpth`
1670     else
1671         cryptlib=-lcrypt
1672     fi
1673     if $test -z "$cryptlib"; then
1674         cryptlib=`./loc libcrypt.a "" $libpth`
1675     else
1676         cryptlib=-lcrypt
1677     fi
1678     if $test -z "$cryptlib"; then
1679         echo 'crypt() not found.'
1680         d_crypt="$undef"
1681     else
1682         d_crypt="$define"
1683     fi
1684 fi
1685
1686 : get csh whereabouts
1687 case "$csh" in
1688 'csh') d_csh="$undef" ;;
1689 *)     d_csh="$define" ;;
1690 esac
1691
1692 : see if this is a dirent system
1693 echo " "
1694 if $test -r /usr/include/dirent.h ; then
1695     i_dirent="$define"
1696     echo "dirent.h found."
1697     if $contains 'd_namlen' /usr/include/sys/dirent.h >/dev/null 2>&1; then
1698         d_dirnamlen="$define"
1699     else
1700         d_dirnamlen="$undef"
1701     fi
1702 else
1703     i_dirent="$undef"
1704     if $contains 'd_namlen' /usr/include/sys/dir.h >/dev/null 2>&1; then
1705         d_dirnamlen="$define"
1706     else
1707         d_dirnamlen="$undef"
1708     fi
1709     echo "No dirent.h found."
1710 fi
1711
1712 : now see if they want to do setuid emulation
1713 case "$d_dosuid" in
1714 '') dflt=n;;
1715 *undef*) dflt=n;;
1716 *) dflt=y;;
1717 esac
1718 cat <<EOM
1719  
1720 Some sites have disabled setuid #! scripts because of a bug in the kernel
1721 that prevents them from being secure.  If you are on such a system, the
1722 setuid/setgid bits on scripts are currently useless.  It is possible for
1723 $package to detect those bits and emulate setuid/setgid in a secure fashion
1724 until a better solution is devised for the kernel problem.
1725
1726 EOM
1727 rp="Do you want to do setuid/setgid emulation? [$dflt]"
1728 $echo $n "$rp $c"
1729 . myread
1730 case "$ans" in
1731 '') $ans="$dflt";;
1732 esac
1733 case "$ans" in
1734 y*)  d_dosuid="$define";;
1735 *) d_dosuid="$undef";;
1736 esac
1737
1738 : see if dup2 exists
1739 set dup2 d_dup2
1740 eval $inlibc
1741
1742 : see if fchmod exists
1743 set fchmod d_fchmod
1744 eval $inlibc
1745
1746 : see if fchown exists
1747 set fchown d_fchown
1748 eval $inlibc
1749
1750 : see if this is an fcntl system
1751 echo " "
1752 if $test -r /usr/include/fcntl.h ; then
1753     d_fcntl="$define"
1754     echo "fcntl.h found."
1755 else
1756     d_fcntl="$undef"
1757     echo "No fcntl.h found, but that's ok."
1758 fi
1759
1760 : see if we can have long filenames
1761 echo " "
1762 rm -f 123456789abcde
1763 if (echo hi >123456789abcdef) 2>/dev/null; then
1764     : not version 8
1765     if test -f 123456789abcde; then
1766         echo 'You cannot have filenames longer than 14 characters.  Sigh.'
1767         d_flexfnam="$undef"
1768     else
1769         echo 'You can have filenames longer than 14 characters.'
1770         d_flexfnam="$define"
1771     fi
1772 else
1773     : version 8 probably
1774     echo "You can't have filenames longer than 14 chars.  V8 can't even think about them!"
1775     d_flexfnam="$undef"
1776 fi 
1777 : see if flock exists
1778 set flock d_flock
1779 eval $inlibc
1780
1781 : see if getgroups exists
1782 set getgroups d_getgrps
1783 eval $inlibc
1784
1785 : see if gethostent exists
1786 set gethostent d_gethent
1787 eval $inlibc
1788
1789 : see if getpgrp exists
1790 set getpgrp d_getpgrp
1791 eval $inlibc
1792
1793 : see if getpgrp2 exists
1794 set getpgrp2 d_getpgrp2
1795 eval $inlibc
1796
1797 : see if getpriority exists
1798 set getpriority d_getprior
1799 eval $inlibc
1800
1801 : see if htonl exists
1802 set htonl d_htonl
1803 eval $inlibc
1804
1805 : index or strcpy
1806 echo " "
1807 case "$d_index" in
1808 n) dflt=n;;
1809 *) dflt=y;;
1810 esac
1811 if $contains '^index$' libc.list >/dev/null 2>&1 ; then
1812     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
1813         echo "Your system has both index() and strchr().  Shall I use"
1814         rp="index() rather than strchr()? [$dflt]"
1815         $echo $n "$rp $c"
1816         . myread
1817         case "$ans" in
1818             n*) d_index="$define" ;;
1819             *)  d_index="$undef" ;;
1820         esac
1821     else
1822         d_index="$undef"
1823         echo "index() found."
1824     fi
1825 else
1826     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
1827         d_index="$define"
1828         echo "strchr() found."
1829     else
1830         echo "No index() or strchr() found!"
1831         d_index="$undef"
1832     fi
1833 fi
1834
1835 : see if ioctl defs are in sgtty/termio or sys/ioctl
1836 echo " "
1837 if $test -r /usr/include/sys/ioctl.h ; then
1838     d_ioctl="$define"
1839     echo "sys/ioctl.h found."
1840 else
1841     d_ioctl="$undef"
1842     echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
1843 fi
1844
1845 : see if there is System V IPC
1846 set msgget d_ipcmsg
1847 eval $inlibc
1848
1849 set semget d_ipcsem
1850 eval $inlibc
1851
1852 set shmget d_ipcshm
1853 eval $inlibc
1854
1855 case "$d_ipcmsg$d_ipcsem$d_ipcshm" in
1856 *define*) d_sysvipc="$define";;
1857 *) d_sysvipc="$undef";;
1858 esac
1859
1860 : see if killpg exists
1861 set killpg d_killpg
1862 eval $inlibc
1863
1864 : see if lstat exists
1865 set lstat d_lstat
1866 eval $inlibc
1867
1868 : see if memcmp exists
1869 set memcmp d_memcmp
1870 eval $inlibc
1871
1872 : see if memcpy exists
1873 set memcpy d_memcpy
1874 eval $inlibc
1875
1876 : see if mkdir exists
1877 set mkdir d_mkdir
1878 eval $inlibc
1879
1880 : see if ndbm is available
1881 echo " "
1882 xxx=`./loc ndbm.h x /usr/include /usr/local/include $inclwanted`
1883 if test -f $xxx; then
1884     d_ndbm="$define"
1885     echo "ndbm.h found."
1886 else
1887     d_ndbm="$undef"
1888     echo "ndbm.h not found."
1889 fi
1890
1891 : see if we have the old dbm
1892 echo " "
1893 xxx=`./loc dbm.h x /usr/include /usr/local/include $inclwanted`
1894 if test -f $xxx; then
1895     d_odbm="$define"
1896     echo "dbm.h found."
1897 else
1898     d_odbm="$undef"
1899     echo "dbm.h not found."
1900 fi
1901
1902 socketlib=''
1903 : see whether socket exists
1904 echo " "
1905 if $contains socket libc.list >/dev/null 2>&1; then
1906     echo "Looks like you have Berkeley networking support."
1907     d_socket="$define"
1908     : now check for advanced features
1909     if $contains setsockopt libc.list >/dev/null 2>&1; then
1910         d_oldsock="$undef"
1911     else
1912         echo "...but it uses the old 4.1c interface, rather than 4.2"
1913         d_oldsock="$define"
1914     fi
1915 else
1916     : hpux, for one, puts all the socket stuff in socklib.o
1917     if $contains socklib libc.list >/dev/null 2>&1; then
1918         echo "Looks like you have Berkeley networking support."
1919         d_socket="$define"
1920         : we will have to assume that it supports the 4.2 BSD interface
1921         d_oldsock="$undef"
1922     else
1923         echo "Hmmm...you don't have Berkeley networking in libc.a..."
1924         : look for an optional networking library
1925         if test -f /usr/lib/libnet.a; then
1926             (ar t /usr/lib/libnet.a ||
1927                 nm -g /usr/lib/libnet.a) 2>/dev/null >> libc.list
1928             if $contains socket libc.list >/dev/null 2>&1; then
1929                 echo "but the Wollongong group seems to have hacked it in."
1930                 socketlib="-lnet"
1931                 d_socket="$define"
1932                 : now check for advanced features
1933                 if $contains setsockopt libc.list >/dev/null 2>&1; then
1934                     d_oldsock="$undef"
1935                 else
1936                     echo "...using the old 4.1c interface, rather than 4.2"
1937                     d_oldsock="$define"
1938                 fi
1939             else
1940                 echo "or even in libnet.a, which is peculiar."
1941                 d_socket="$undef"
1942                 d_oldsock="$undef"
1943             fi
1944         else
1945             echo "or anywhere else I see."
1946             d_socket="$undef"
1947             d_oldsock="$undef"
1948         fi
1949     fi
1950 fi
1951 if $contains socketpair libc.list >/dev/null 2>&1; then
1952     d_sockpair="$define"
1953 else
1954     d_sockpair="$undef"
1955 fi
1956
1957 : see if this is a pwd system
1958 echo " "
1959 if $test -r /usr/include/pwd.h ; then
1960     i_pwd="$define"
1961     echo "pwd.h found."
1962     $cppstdin $cppflags $cppminus </usr/include/pwd.h >$$.h
1963     if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
1964         d_pwcomment="$define"
1965     else
1966         d_pwcomment="$undef"
1967     fi
1968     if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
1969         d_pwquota="$define"
1970     else
1971         d_pwquota="$undef"
1972     fi
1973     if $contains 'pw_age' $$.h >/dev/null 2>&1; then
1974         d_pwage="$define"
1975     else
1976         d_pwage="$undef"
1977     fi
1978     if $contains 'pw_change' $$.h >/dev/null 2>&1; then
1979         d_pwchange="$define"
1980     else
1981         d_pwchange="$undef"
1982     fi
1983     if $contains 'pw_class' $$.h >/dev/null 2>&1; then
1984         d_pwclass="$define"
1985     else
1986         d_pwclass="$undef"
1987     fi
1988     if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
1989         d_pwexpire="$define"
1990     else
1991         d_pwexpire="$undef"
1992     fi
1993     rm -f $$.h
1994 else
1995     i_pwd="$undef"
1996     d_pwcomment="$undef"
1997     d_pwquota="$undef"
1998     d_pwage="$undef"
1999     d_pwchange="$undef"
2000     d_pwclass="$undef"
2001     d_pwexpire="$undef"
2002     echo "No pwd.h found."
2003 fi
2004
2005 : see if readdir exists
2006 set readdir d_readdir
2007 eval $inlibc
2008
2009 : see if rename exists
2010 set rename d_rename
2011 eval $inlibc
2012
2013 : see if rmdir exists
2014 set rmdir d_rmdir
2015 eval $inlibc
2016
2017 : see if select exists
2018 set select d_select
2019 eval $inlibc
2020
2021 : see if setegid exists
2022 set setegid d_setegid
2023 eval $inlibc
2024
2025 : see if seteuid exists
2026 set seteuid d_seteuid
2027 eval $inlibc
2028
2029 : see if setpgrp exists
2030 set setpgrp d_setpgrp
2031 eval $inlibc
2032
2033 : see if setpgrp2 exists
2034 set setpgrp2 d_setpgrp2
2035 eval $inlibc
2036
2037 : see if setpriority exists
2038 set setpriority d_setprior
2039 eval $inlibc
2040
2041 : see if setregid exists
2042 set setregid d_setregid
2043 eval $inlibc
2044 set setresgid d_setresgid
2045 eval $inlibc
2046
2047 : see if setreuid exists
2048 set setreuid d_setreuid
2049 eval $inlibc
2050 set setresuid d_setresuid
2051 eval $inlibc
2052
2053 : see if setrgid exists
2054 set setrgid d_setrgid
2055 eval $inlibc
2056
2057 : see if setruid exists
2058 set setruid d_setruid
2059 eval $inlibc
2060
2061 : see if stat knows about block sizes
2062 echo " "
2063 if $contains 'st_blocks;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
2064     if $contains 'st_blksize;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
2065         echo "Your stat knows about block sizes."
2066         d_statblks="$define"
2067     else
2068         echo "Your stat doesn't know about block sizes."
2069         d_statblks="$undef"
2070     fi
2071 else
2072     echo "Your stat doesn't know about block sizes."
2073     d_statblks="$undef"
2074 fi
2075
2076 : see if stdio is really std
2077 echo " "
2078 if $contains 'char.*_ptr.*;' /usr/include/stdio.h >/dev/null 2>&1 ; then
2079     if $contains '_cnt;' /usr/include/stdio.h >/dev/null 2>&1 ; then
2080         echo "Your stdio is pretty std."
2081         d_stdstdio="$define"
2082     else
2083         echo "Your stdio isn't very std."
2084         d_stdstdio="$undef"
2085     fi
2086 else
2087     echo "Your stdio isn't very std."
2088     d_stdstdio="$undef"
2089 fi
2090
2091 : check for structure copying
2092 echo " "
2093 echo "Checking to see if your C compiler can copy structs..."
2094 $cat >try.c <<'EOCP'
2095 main()
2096 {
2097         struct blurfl {
2098             int dyick;
2099         } foo, bar;
2100
2101         foo = bar;
2102 }
2103 EOCP
2104 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
2105     d_strctcpy="$define"
2106     echo "Yup, it can."
2107 else
2108     d_strctcpy="$undef"
2109     echo "Nope, it can't."
2110 fi
2111 $rm -f try.*
2112
2113 : see if strerror exists
2114 set strerror d_strerror
2115 eval $inlibc
2116
2117 : see if symlink exists
2118 set symlink d_symlink
2119 eval $inlibc
2120
2121 : see if syscall exists
2122 set syscall d_syscall
2123 eval $inlibc
2124
2125 : see if we should include time.h, sys/time.h, or both
2126 cat <<'EOM'
2127   
2128 Testing to see if we should include <time.h>, <sys/time.h> or both.
2129 I'm now running the test program...
2130 EOM
2131 $cat >try.c <<'EOCP'
2132 #ifdef I_TIME
2133 #include <time.h>
2134 #endif
2135 #ifdef I_SYSTIME
2136 #ifdef SYSTIMEKERNEL
2137 #define KERNEL
2138 #endif
2139 #include <sys/time.h>
2140 #endif
2141 main()
2142 {
2143     struct tm foo;
2144 #ifdef S_TIMEVAL
2145     struct timeval bar;
2146 #endif
2147     if (foo.tm_sec == foo.tm_sec)
2148         exit(0);
2149 #ifdef S_TIMEVAL
2150     if (bar.tv_sec == bar.tv_sec)
2151         exit(0);
2152 #endif
2153     exit(1);
2154 }
2155 EOCP
2156 flags=''
2157 for s_timeval in '-DS_TIMEVAL' ''; do
2158     for d_systimekernel in '' '-DSYSTIMEKERNEL'; do
2159         for i_time in '' '-DI_TIME'; do
2160             for i_systime in '-DI_SYSTIME' ''; do
2161                 case "$flags" in
2162                 '') echo Trying $i_time $i_systime $d_systimekernel $s_timeval
2163                     if $cc $ccflags \
2164                             $i_time $i_systime $d_systimekernel $s_timeval \
2165                             try.c -o try >/dev/null 2>&1 ; then
2166                         set X $i_time $i_systime $d_systimekernel $s_timeval
2167                         shift
2168                         flags="$*"
2169                         echo Succeeded with $flags
2170                     fi
2171                     ;;
2172                 esac
2173             done
2174         done
2175     done
2176 done
2177 case "$flags" in
2178 *SYSTIMEKERNEL*) d_systimekernel="$define";;
2179 *) d_systimekernel="$undef";;
2180 esac
2181 case "$flags" in
2182 *I_TIME*) i_time="$define";;
2183 *) i_time="$undef";;
2184 esac
2185 case "$flags" in
2186 *I_SYSTIME*) i_systime="$define";;
2187 *) i_systime="$undef";;
2188 esac
2189 $rm -f try.c try
2190
2191 : see if truncate exists
2192 set truncate d_truncate
2193 eval $inlibc
2194
2195 : see if this is a varargs system
2196 echo " "
2197 if $test -r /usr/include/varargs.h ; then
2198     d_varargs="$define"
2199     echo "varargs.h found."
2200 else
2201     d_varargs="$undef"
2202     echo "No varargs.h found, but that's ok (I hope)."
2203 fi
2204
2205 : see if there is a vfork
2206 set vfork d_vfork
2207 eval $inlibc
2208
2209 : see if signal is declared as pointer to function returning int or void
2210 echo " "
2211 $cppstdin $cppflags $cppminus < /usr/include/signal.h >$$.tmp
2212 if $contains 'void.*signal' $$.tmp >/dev/null 2>&1 ; then
2213     echo "You have void (*signal())() instead of int."
2214     d_voidsig="$define"
2215 else
2216     echo "You have int (*signal())() instead of void."
2217     d_voidsig="$undef"
2218 fi
2219 rm -f $$.tmp
2220
2221 : check for volatile keyword
2222 echo " "
2223 echo 'Checking to see if your C compiler knows about "volatile"...'
2224 $cat >try.c <<'EOCP'
2225 main()
2226 {
2227         typedef unsigned short foo_t;
2228         char *volatile foo;
2229         volatile int bar;
2230         volatile foo_t blech;
2231         foo = foo;
2232 }
2233 EOCP
2234 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
2235     d_volatile="$define"
2236     echo "Yup, it does."
2237 else
2238     d_volatile="$undef"
2239     echo "Nope, it doesn't."
2240 fi
2241 $rm -f try.*
2242
2243 : see if there is a wait4
2244 set wait4 d_wait4
2245 eval $inlibc
2246
2247 : see if there is a waitpid
2248 set waitpid d_waitpid
2249 eval $inlibc
2250
2251 : check for void type
2252 echo " "
2253 $cat <<EOM
2254 Checking to see how well your C compiler groks the void type...
2255
2256   Support flag bits are:
2257     1: basic void declarations.
2258     2: arrays of pointers to functions returning void.
2259     4: operations between pointers to and addresses of void functions.
2260
2261 EOM
2262 case "$voidflags" in
2263 '')
2264     $cat >try.c <<'EOCP'
2265 #if TRY & 1
2266 void main() {
2267 #else
2268 main() {
2269 #endif
2270         extern void moo();      /* function returning void */
2271         void (*goo)();          /* ptr to func returning void */
2272 #if TRY & 2
2273         void (*foo[10])();
2274 #endif
2275
2276 #if TRY & 4
2277         if(goo == moo) {
2278                 exit(0);
2279         }
2280 #endif
2281         exit(0);
2282 }
2283 EOCP
2284     if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
2285         voidflags=$defvoidused
2286         echo "It appears to support void."
2287         if $contains warning .out >/dev/null 2>&1; then
2288             echo "However, you might get some warnings that look like this:"
2289             $cat .out
2290         fi
2291     else
2292         echo "Hmm, your compiler has some difficulty with void.  Checking further..."
2293         if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1 ; then
2294             echo "It supports 1..."
2295             if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1 ; then
2296                 voidflags=3
2297                 echo "And it supports 2 but not 4."
2298             else
2299                 echo "It doesn't support 2..."
2300                 if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1 ; then
2301                     voidflags=5
2302                     echo "But it supports 4."
2303                 else
2304                     voidflags=1
2305                     echo "And it doesn't support 4."
2306                 fi
2307             fi
2308         else
2309             echo "There is no support at all for void."
2310             voidflags=0
2311         fi
2312     fi
2313 esac
2314 dflt="$voidflags";
2315 rp="Your void support flags add up to what? [$dflt]"
2316 $echo $n "$rp $c"
2317 . myread
2318 voidflags="$ans"
2319 $rm -f try.* .out
2320
2321 : see what type gids are declared as in the kernel
2322 echo " "
2323 case "$gidtype" in
2324 '')
2325     if $contains 'getgroups.*short' /usr/lib/lint/llib-lc >/dev/null 2>&1; then
2326         dflt='short'
2327     elif $contains 'getgroups.*int' /usr/lib/lint/llib-lc >/dev/null 2>&1; then
2328         dflt='int'
2329     elif $contains 'gid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
2330         dflt='gid_t'
2331     else
2332         set `grep 'groups\[NGROUPS\];' /usr/include/sys/user.h 2>/dev/null` unsigned short
2333         case $1 in
2334         unsigned) dflt="$1 $2" ;;
2335         *) dflt="$1" ;;
2336         esac
2337     fi
2338     ;;
2339 *)  dflt="$gidtype"
2340     ;;
2341 esac
2342 cont=true
2343 echo "(The following only matters if you have getgroups().)"
2344 rp="What type are the group ids returned by getgroups()? [$dflt]"
2345 $echo $n "$rp $c"
2346 . myread
2347 gidtype="$ans"
2348
2349 : see if this is an fcntl system
2350 echo " "
2351 if $test -r /usr/include/fcntl.h ; then
2352     i_fcntl="$define"
2353     echo "fcntl.h found."
2354 else
2355     i_fcntl="$undef"
2356     echo "No fcntl.h found, but that's ok."
2357 fi
2358
2359 : see if this is an grp system
2360 echo " "
2361 if $test -r /usr/include/grp.h ; then
2362     i_grp="$define"
2363     echo "grp.h found."
2364 else
2365     i_grp="$undef"
2366     echo "No grp.h found."
2367 fi
2368
2369 : see if this is a netinet/in.h system
2370 echo " "
2371 xxx=`./loc netinet/in.h x /usr/include /usr/local/include $inclwanted`
2372 if test -f $xxx; then
2373     i_niin="$define"
2374     echo "netinet/in.h found."
2375 else
2376     i_niin="$undef"
2377     echo "No netinet/in.h found."
2378 fi
2379
2380 : see if this is a sys/dir.h system
2381 echo " "
2382 if $test -r /usr/include/sys/dir.h ; then
2383     i_sysdir="$define"
2384     echo "sys/dir.h found."
2385 else
2386     i_sysdir="$undef"
2387     echo "No sys/dir.h found."
2388 fi
2389
2390 : see if ioctl defs are in sgtty/termio or sys/ioctl
2391 echo " "
2392 if $test -r /usr/include/sys/ioctl.h ; then
2393     i_sysioctl="$define"
2394     echo "sys/ioctl.h found."
2395 else
2396     i_sysioctl="$undef"
2397     echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
2398 fi
2399
2400 : see if this is a sys/ndir.h system
2401 echo " "
2402 xxx=`./loc sys/ndir.h x /usr/include /usr/local/include $inclwanted`
2403 if test -f $xxx; then
2404     i_sysndir="$define"
2405     echo "sys/ndir.h found."
2406 else
2407     i_sysndir="$undef"
2408     echo "No sys/ndir.h found."
2409 fi
2410
2411 : see if we should include utime.h
2412 echo " "
2413 if $test -r /usr/include/utime.h ; then
2414     i_utime="$define"
2415     echo "utime.h found."
2416 else
2417     i_utime="$undef"
2418     echo "No utime.h found, but that's ok."
2419 fi
2420
2421 : see if this is a varargs system
2422 echo " "
2423 if $test -r /usr/include/varargs.h ; then
2424     i_varargs="$define"
2425     echo "varargs.h found."
2426 else
2427     i_varargs="$undef"
2428     echo "No varargs.h found, but that's ok (I hope)."
2429 fi
2430
2431 : see if this is a vfork system
2432 echo " "
2433 if $test -r /usr/include/vfork.h ; then
2434     i_vfork="$define"
2435     echo "vfork.h found."
2436 else
2437     i_vfork="$undef"
2438     echo "No vfork.h found."
2439 fi
2440
2441 : check for length of integer
2442 echo " "
2443 case "$intsize" in
2444 '')
2445     echo "Checking to see how big your integers are..."
2446     $cat >try.c <<'EOCP'
2447 #include <stdio.h>
2448 main()
2449 {
2450     printf("%d\n", sizeof(int));
2451 }
2452 EOCP
2453     if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
2454         dflt=`./try`
2455     else
2456         dflt='4'
2457         echo "(I can't seem to compile the test program.  Guessing...)"
2458     fi
2459     ;;
2460 *)
2461     dflt="$intsize"
2462     ;;
2463 esac
2464 rp="What is the size of an integer (in bytes)? [$dflt]"
2465 $echo $n "$rp $c"
2466 . myread
2467 intsize="$ans"
2468 $rm -f try.c try
2469
2470 : determine where private executables go
2471 case "$privlib" in
2472 '')
2473     dflt=/usr/lib/$package
2474     test -d /usr/local/lib && dflt=/usr/local/lib/$package
2475     ;;
2476 *)  dflt="$privlib"
2477     ;;
2478 esac
2479 $cat <<EOM
2480
2481 The $package package has some auxiliary files that should be put in a library
2482 that is accessible by everyone.  Where do you want to put these "private"
2483 EOM
2484 $echo $n "but accessible files? (~name ok) [$dflt] $c"
2485 rp="Put private files where? [$dflt]"
2486 . myread
2487 privlib=`./filexp "$ans"`
2488
2489 : check for size of random number generator
2490 echo " "
2491 case "$randbits" in
2492 '')
2493     echo "Checking to see how many bits your rand function produces..."
2494     $cat >try.c <<'EOCP'
2495 #include <stdio.h>
2496 main()
2497 {
2498     register int i;
2499     register unsigned long tmp;
2500     register unsigned long max = 0L;
2501
2502     for (i=1000; i; i--) {
2503         tmp = (unsigned long)rand();
2504         if (tmp > max) max = tmp;
2505     }
2506     for (i=0; max; i++)
2507         max /= 2;
2508     printf("%d\n",i);
2509 }
2510 EOCP
2511     if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
2512         dflt=`./try`
2513     else
2514         dflt='?'
2515         echo "(I can't seem to compile the test program...)"
2516     fi
2517     ;;
2518 *)
2519     dflt="$randbits"
2520     ;;
2521 esac
2522 rp="How many bits does your rand() function produce? [$dflt]"
2523 $echo $n "$rp $c"
2524 . myread
2525 randbits="$ans"
2526 $rm -f try.c try
2527
2528 : generate list of signal names
2529 echo " "
2530 case "$sig_name" in
2531 '')
2532     echo "Generating a list of signal names..."
2533     set X `cat /usr/include/signal.h /usr/include/sys/signal.h 2>&1 | awk '
2534 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
2535     sig[$3] = substr($2,4,20)
2536     if (max < $3 && $3 < 60) {
2537         max = $3
2538     }
2539 }
2540
2541 END {
2542     for (i=1; i<=max; i++) {
2543         if (sig[i] == "")
2544             printf "%d", i
2545         else
2546             printf "%s", sig[i]
2547         if (i < max)
2548             printf " "
2549     }
2550     printf "\n"
2551 }
2552 '`
2553     shift
2554     case $# in
2555     0)  echo 'kill -l' >/tmp/foo$$
2556         set X `$csh -f </tmp/foo$$`
2557         shift
2558         case $# in
2559         0)set HUP INT QUIT ILL TRAP IOT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
2560             ;;
2561         esac
2562         ;;
2563     esac
2564     sig_name="ZERO $*"
2565     ;;
2566 esac
2567 echo "Signals are: $sig_name"
2568
2569 : see what type of char stdio uses.
2570 echo " "
2571 if $contains 'unsigned.*char.*_ptr.*;' /usr/include/stdio.h >/dev/null 2>&1 ; then
2572     echo "Your stdio uses unsigned chars."
2573     stdchar="unsigned char"
2574 else
2575     echo "Your stdio uses signed chars."
2576     stdchar="char"
2577 fi
2578
2579 : see what type uids are declared as in the kernel
2580 case "$uidtype" in
2581 '')
2582     if $contains 'uid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
2583         dflt='uid_t';
2584     else
2585         set `grep '_ruid;' /usr/include/sys/user.h 2>/dev/null` unsigned short
2586         case $1 in
2587         unsigned) dflt="$1 $2" ;;
2588         *) dflt="$1" ;;
2589         esac
2590     fi
2591     ;;
2592 *)  dflt="$uidtype"
2593     ;;
2594 esac
2595 cont=true
2596 echo " "
2597 rp="What type are user ids returned by getuid(), etc.? [$dflt]"
2598 $echo $n "$rp $c"
2599 . myread
2600 uidtype="$ans"
2601
2602 : preserve RCS keywords in files with variable substitution, grrr
2603 Log='$Log'
2604 Header='$Header'
2605
2606
2607 : determine which malloc to compile in
2608 echo " "
2609 case "$usemymalloc" in
2610 '')
2611     if bsd || v7; then
2612         dflt='y'
2613     else
2614         dflt='n'
2615     fi
2616     ;;
2617 *)  dflt="$usemymalloc"
2618     ;;
2619 esac
2620 rp="Do you wish to attempt to use the malloc that comes with $package? [$dflt]"
2621 $echo $n "$rp $c"
2622 . myread
2623 case "$ans" in
2624 '') ans=$dflt;;
2625 esac
2626 usemymalloc="$ans"
2627 case "$ans" in
2628 y*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
2629 *) mallocsrc=''; mallocobj='';;
2630 esac
2631
2632 : determine where public executables go
2633 case "$scriptdir" in
2634 '')
2635     dflt="$bin"
2636     : guess some guesses
2637     test -d /usr/share/scripts && dflt=/usr/share/scripts
2638     test -d /usr/share/bin && dflt=/usr/share/bin
2639     ;;
2640 *)  dflt="$scriptdir"
2641     ;;
2642 esac
2643 cont=true
2644 $cat <<EOM
2645  
2646 Some installations have a separate directory just for executable scripts so
2647 that they can mount it across multiple architectures but keep the scripts in
2648 one spot.  You might, for example, have a subdirectory of /usr/share for this.
2649 Or you might just lump your scripts in with all your other executables.
2650  
2651 EOM
2652 while $test "$cont" ; do
2653     rp="Where do you keep publicly executable scripts? (~name ok) [$dflt]"
2654     $echo $n "$rp $c"
2655     . myread
2656     scriptdir="$ans"
2657     scriptdir=`./filexp "$scriptdir"`
2658     if test -d $scriptdir; then
2659         cont=''
2660     else
2661         case "$fastread" in
2662         yes) dflt=y;;
2663         *) dflt=n;;
2664         esac
2665         rp="Directory $scriptdir doesn't exist.  Use that name anyway? [$dflt]"
2666         $echo $n "$rp $c"
2667         . myread
2668         dflt=''
2669         case "$ans" in
2670         y*) cont='';;
2671         esac
2672     fi
2673 done
2674
2675 : determine compiler compiler
2676 case "$yacc" in
2677 '') dflt=yacc;;
2678 *)  dflt="$yacc";;
2679 esac
2680 cont=true
2681     echo " "
2682 rp="Which compiler compiler (yacc or bison -y) will you use? [$dflt]"
2683 $echo $n "$rp $c"
2684 . myread
2685 case "$ans" in
2686 '') ans="$dflt";;
2687 esac
2688 yacc="$ans"
2689
2690 echo " "
2691 echo "End of configuration questions."
2692 echo " "
2693
2694 : create config.sh file
2695 echo " "
2696 if test -d ../UU; then
2697     cd ..
2698 fi
2699 echo "Creating config.sh..."
2700 $spitshell <<EOT >config.sh
2701 $startsh
2702 # config.sh
2703 # This file was produced by running the Configure script.
2704
2705 d_eunice='$d_eunice'
2706 define='$define'
2707 eunicefix='$eunicefix'
2708 loclist='$loclist'
2709 expr='$expr'
2710 sed='$sed'
2711 echo='$echo'
2712 cat='$cat'
2713 rm='$rm'
2714 mv='$mv'
2715 cp='$cp'
2716 tail='$tail'
2717 tr='$tr'
2718 mkdir='$mkdir'
2719 sort='$sort'
2720 uniq='$uniq'
2721 grep='$grep'
2722 trylist='$trylist'
2723 test='$test'
2724 inews='$inews'
2725 egrep='$egrep'
2726 more='$more'
2727 pg='$pg'
2728 Mcc='$Mcc'
2729 vi='$vi'
2730 mailx='$mailx'
2731 mail='$mail'
2732 cpp='$cpp'
2733 perl='$perl'
2734 emacs='$emacs'
2735 ls='$ls'
2736 rmail='$rmail'
2737 sendmail='$sendmail'
2738 shar='$shar'
2739 smail='$smail'
2740 tbl='$tbl'
2741 troff='$troff'
2742 nroff='$nroff'
2743 uname='$uname'
2744 uuname='$uuname'
2745 line='$line'
2746 chgrp='$chgrp'
2747 chmod='$chmod'
2748 lint='$lint'
2749 sleep='$sleep'
2750 pr='$pr'
2751 tar='$tar'
2752 ln='$ln'
2753 lpr='$lpr'
2754 lp='$lp'
2755 touch='$touch'
2756 make='$make'
2757 date='$date'
2758 csh='$csh'
2759 Log='$Log'
2760 Header='$Header'
2761 alignbytes='$alignbytes'
2762 bin='$bin'
2763 byteorder='$byteorder'
2764 contains='$contains'
2765 cppstdin='$cppstdin'
2766 cppminus='$cppminus'
2767 d_bcmp='$d_bcmp'
2768 d_bcopy='$d_bcopy'
2769 d_bzero='$d_bzero'
2770 d_castneg='$d_castneg'
2771 castflags='$castflags'
2772 d_charsprf='$d_charsprf'
2773 d_chsize='$d_chsize'
2774 d_crypt='$d_crypt'
2775 cryptlib='$cryptlib'
2776 d_csh='$d_csh'
2777 d_dosuid='$d_dosuid'
2778 d_dup2='$d_dup2'
2779 d_fchmod='$d_fchmod'
2780 d_fchown='$d_fchown'
2781 d_fcntl='$d_fcntl'
2782 d_flexfnam='$d_flexfnam'
2783 d_flock='$d_flock'
2784 d_getgrps='$d_getgrps'
2785 d_gethent='$d_gethent'
2786 d_getpgrp='$d_getpgrp'
2787 d_getpgrp2='$d_getpgrp2'
2788 d_getprior='$d_getprior'
2789 d_htonl='$d_htonl'
2790 d_index='$d_index'
2791 d_ioctl='$d_ioctl'
2792 d_killpg='$d_killpg'
2793 d_lstat='$d_lstat'
2794 d_memcmp='$d_memcmp'
2795 d_memcpy='$d_memcpy'
2796 d_mkdir='$d_mkdir'
2797 d_ndbm='$d_ndbm'
2798 d_odbm='$d_odbm'
2799 d_readdir='$d_readdir'
2800 d_rename='$d_rename'
2801 d_rmdir='$d_rmdir'
2802 d_select='$d_select'
2803 d_setegid='$d_setegid'
2804 d_seteuid='$d_seteuid'
2805 d_setpgrp='$d_setpgrp'
2806 d_setpgrp2='$d_setpgrp2'
2807 d_setprior='$d_setprior'
2808 d_setregid='$d_setregid'
2809 d_setresgid='$d_setresgid'
2810 d_setreuid='$d_setreuid'
2811 d_setresuid='$d_setresuid'
2812 d_setrgid='$d_setrgid'
2813 d_setruid='$d_setruid'
2814 d_socket='$d_socket'
2815 d_sockpair='$d_sockpair'
2816 d_oldsock='$d_oldsock'
2817 socketlib='$socketlib'
2818 d_statblks='$d_statblks'
2819 d_stdstdio='$d_stdstdio'
2820 d_strctcpy='$d_strctcpy'
2821 d_strerror='$d_strerror'
2822 d_symlink='$d_symlink'
2823 d_syscall='$d_syscall'
2824 d_sysvipc='$d_sysvipc'
2825 d_ipcmsg='$d_ipcmsg'
2826 d_ipcsem='$d_ipcsem'
2827 d_ipcshm='$d_ipcshm'
2828 d_truncate='$d_truncate'
2829 d_varargs='$d_varargs'
2830 d_vfork='$d_vfork'
2831 d_voidsig='$d_voidsig'
2832 d_volatile='$d_volatile'
2833 d_vprintf='$d_vprintf'
2834 d_charvspr='$d_charvspr'
2835 d_wait4='$d_wait4'
2836 d_waitpid='$d_waitpid'
2837 gidtype='$gidtype'
2838 i_dirent='$i_dirent'
2839 d_dirnamlen='$d_dirnamlen'
2840 i_fcntl='$i_fcntl'
2841 i_grp='$i_grp'
2842 i_niin='$i_niin'
2843 i_pwd='$i_pwd'
2844 d_pwcomment='$d_pwcomment'
2845 d_pwquota='$d_pwquota'
2846 d_pwage='$d_pwage'
2847 d_pwchange='$d_pwchange'
2848 d_pwclass='$d_pwclass'
2849 d_pwexpire='$d_pwexpire'
2850 i_sysdir='$i_sysdir'
2851 i_sysioctl='$i_sysioctl'
2852 i_sysndir='$i_sysndir'
2853 i_time='$i_time'
2854 i_systime='$i_systime'
2855 d_systimekernel='$d_systimekernel'
2856 i_utime='$i_utime'
2857 i_varargs='$i_varargs'
2858 i_vfork='$i_vfork'
2859 intsize='$intsize'
2860 libc='$libc'
2861 mallocsrc='$mallocsrc'
2862 mallocobj='$mallocobj'
2863 usemymalloc='$usemymalloc'
2864 mansrc='$mansrc'
2865 manext='$manext'
2866 models='$models'
2867 split='$split'
2868 small='$small'
2869 medium='$medium'
2870 large='$large'
2871 huge='$huge'
2872 optimize='$optimize'
2873 ccflags='$ccflags'
2874 cppflags='$cppflags'
2875 ldflags='$ldflags'
2876 cc='$cc'
2877 libs='$libs'
2878 n='$n'
2879 c='$c'
2880 package='$package'
2881 randbits='$randbits'
2882 scriptdir='$scriptdir'
2883 sig_name='$sig_name'
2884 spitshell='$spitshell'
2885 shsharp='$shsharp'
2886 sharpbang='$sharpbang'
2887 startsh='$startsh'
2888 stdchar='$stdchar'
2889 uidtype='$uidtype'
2890 voidflags='$voidflags'
2891 defvoidused='$defvoidused'
2892 yacc='$yacc'
2893 privlib='$privlib'
2894 lib='$lib'
2895 CONFIG=true
2896 EOT
2897
2898 CONFIG=true
2899
2900 echo " "
2901 dflt=''
2902 fastread=''
2903 echo "If you didn't make any mistakes, then just type a carriage return here."
2904 rp="If you need to edit config.sh, do it as a shell escape here:"
2905 $echo $n "$rp $c"
2906 . UU/myread
2907 case "$ans" in
2908 '') ;;
2909 *) : in case they cannot read
2910     eval $ans;;
2911 esac
2912 : if this fails, just run all the .SH files by hand
2913 . ./config.sh
2914
2915 echo " "
2916 echo "Doing variable substitutions on .SH files..."
2917 set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
2918 shift
2919 case $# in
2920 0) set x *.SH; shift;;
2921 esac
2922 if test ! -f $1; then
2923     shift
2924 fi
2925 for file in $*; do
2926     case "$file" in
2927     */*)
2928         dir=`$expr X$file : 'X\(.*\)/'`
2929         file=`$expr X$file : 'X.*/\(.*\)'`
2930         (cd $dir && . $file)
2931         ;;
2932     *)
2933         . $file
2934         ;;
2935     esac
2936 done
2937 if test -f config.h.SH; then
2938     if test ! -f config.h; then
2939         : oops, they left it out of MANIFEST, probably, so do it anyway.
2940         . config.h.SH
2941     fi
2942 fi
2943
2944 if $contains '^depend:' Makefile >/dev/null 2>&1; then
2945     dflt=n
2946     $cat <<EOM
2947
2948 Now you need to generate make dependencies by running "make depend".
2949 You might prefer to run it in background: "make depend > makedepend.out &"
2950 It can take a while, so you might not want to run it right now.
2951
2952 EOM
2953     rp="Run make depend now? [$dflt]"
2954     $echo $n "$rp $c"
2955     . UU/myread
2956     case "$ans" in
2957     y*) make depend && echo "Now you must run a make."
2958         ;;
2959     *)  echo "You must run 'make depend' then 'make'."
2960         ;;
2961     esac
2962 elif test -f Makefile; then
2963     echo " "
2964     echo "Now you must run a make."
2965 else
2966     echo "Done."
2967 fi
2968
2969 $rm -f kit*isdone
2970 : the following is currently useless
2971 cd UU && $rm -f $rmlist
2972 : since this removes it all anyway
2973 cd .. && $rm -rf UU
2974 : end of Configure