perl 3.0 patch #44 patch #42, continued
[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.14 91/01/11 21:56:38 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 $cc -o try $ccflags try.c >/dev/null 2>&1 && ./try
1325 castflags=$?
1326 case "$castflags" in
1327 0)  d_castneg="$define"
1328     echo "Yup, it does."
1329     ;;
1330 *)  d_castneg="$undef"
1331     echo "Nope, it doesn't."
1332     ;;
1333 esac
1334 $rm -f try.*
1335
1336 : see how we invoke the C preprocessor
1337 echo " "
1338 echo "Now, how can we feed standard input to your C preprocessor..."
1339 cat <<'EOT' >testcpp.c
1340 #define ABC abc
1341 #define XYZ xyz
1342 ABC.XYZ
1343 EOT
1344 echo 'Maybe "'"$cc"' -E" will work...'
1345 $cc -E <testcpp.c >testcpp.out 2>&1
1346 : try to force gcc preprocessor if that is the compiler they are using
1347 case $? in
1348 0) cppstdin="$cc -E";;
1349 *) case "$cc" in
1350     *gcc*)
1351         cd ..
1352         echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
1353         echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
1354         chmod 755 cppstdin
1355         cppstdin=`pwd`/cppstdin
1356         cppminus='';
1357         cd UU
1358         $cppstdin <testcpp.c >testcpp.out 2>&1
1359         ;;
1360     esac
1361     ;;
1362 esac
1363 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1364     echo "Yup, it does."
1365     cppstdin="$cc -E"
1366     cppminus='';
1367 else
1368     echo 'Nope...maybe "'"$cc"' -E -" will work...'
1369     $cc -E - <testcpp.c >testcpp.out 2>&1
1370     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1371         echo "Yup, it does."
1372         cppstdin="$cc -E"
1373         cppminus='-';
1374     else
1375         echo 'No such luck, maybe "'$cpp'" will work...'
1376         $cpp <testcpp.c >testcpp.out 2>&1
1377         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1378             echo "It works!"
1379             cppstdin="$cpp"
1380             cppminus='';
1381         else
1382             echo 'Nixed again...maybe "'$cpp' -" will work...'
1383             $cpp - <testcpp.c >testcpp.out 2>&1
1384             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1385                 echo "Hooray, it works!  I was beginning to wonder."
1386                 cppstdin="$cpp"
1387                 cppminus='-';
1388             else
1389                 echo 'Nope...maybe "'"$cc"' -P" will work...'
1390                 $cc -P <testcpp.c >testcpp.out 2>&1
1391                 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1392                     echo "Yup, that does."
1393                     cppstdin="$cc -P"
1394                     cppminus='';
1395                 else
1396                     echo 'Nope...maybe "'"$cc"' -P -" will work...'
1397                     $cc -P - <testcpp.c >testcpp.out 2>&1
1398                     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1399                         echo "Yup, that does."
1400                         cppstdin="$cc -P"
1401                         cppminus='-';
1402                     else
1403                         echo 'Hmm...perhaps you already told me...'
1404                         case "$cppstdin" in
1405                         '') ;;
1406                         *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
1407                         esac
1408                         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1409                             echo "Hooray, you did!  I was beginning to wonder."
1410                         else
1411                             echo 'Uh-uh.  Time to get fancy...'
1412                             cd ..
1413                             echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
1414                             echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
1415                             chmod 755 cppstdin
1416                             cppstdin=`pwd`/cppstdin
1417                             cppminus='';
1418                             cd UU
1419                             $cppstdin <testcpp.c >testcpp.out 2>&1
1420                             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1421                                 echo "Eureka!."
1422                             else
1423                                 dflt=blurfl
1424                                 $echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
1425                                 rp='Name a C preprocessor:'
1426                                 . myread
1427                                 cppstdin="$ans"
1428                                 $cppstdin <testcpp.c >testcpp.out 2>&1
1429                                 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1430                                     echo "OK, that will do."
1431                                 else
1432                                     echo "Sorry, I can't get that to work.  Go find one."
1433                                     exit 1
1434                                 fi
1435                             fi
1436                         fi
1437                     fi
1438                 fi
1439             fi
1440         fi
1441     fi
1442 fi
1443 rm -f testcpp.c testcpp.out
1444
1445 : get list of predefined functions in a handy place
1446 echo " "
1447 case "$libc" in
1448 '') libc=unknown;;
1449 esac
1450 case "$libpth" in
1451 '') libpth='/usr/ccs/lib /lib /usr/lib /usr/local/lib';;
1452 esac
1453 case "$libs" in
1454 *-lc_s*) libc=`./loc libc_s.a $libc $libpth`
1455 esac
1456 libnames='';
1457 case "$libs" in
1458 '') ;;
1459 *)  for thislib in $libs; do
1460         case "$thislib" in
1461         -l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
1462             try=`./loc lib$thislib.a blurfl/dyick $libpth`
1463             if test ! -f $try; then
1464                 try=`./loc lib$thislib blurfl/dyick $libpth`
1465                 if test ! -f $try; then
1466                     try=`./loc $thislib blurfl/dyick $libpth`
1467                     if test ! -f $try; then
1468                         try=`./loc Slib$thislib.a blurfl/dyick $xlibpth`
1469                         if test ! -f $try; then
1470                             try=''
1471                         fi
1472                     fi
1473                 fi
1474             fi
1475             libnames="$libnames $try"
1476             ;;
1477         *) libnames="$libnames $thislib" ;;
1478         esac
1479     done
1480     ;;
1481 esac
1482 set /usr/ccs/lib/libc.so
1483 test -f $1 || set /usr/lib/libc.so
1484 test -f $1 || set /usr/lib/libc.so.[0-9]*
1485 eval set \$$#
1486 if test -f "$1"; then
1487     echo "Your shared C library is in $1."
1488     libc="$1"
1489 elif test -f $libc; then
1490     echo "Your C library is in $libc, like you said before."
1491     if test $libc = "/lib/libc"; then
1492         libc="$libc /lib/clib"
1493     fi
1494 elif test -f /lib/libc.a; then
1495     echo "Your C library is in /lib/libc.a.  You're normal."
1496     libc=/lib/libc.a
1497 else
1498     ans=`./loc libc.a blurfl/dyick $libpth`
1499     if test ! -f "$ans"; then
1500         ans=`./loc Slibc.a blurfl/dyick $xlibpth`
1501     fi
1502     if test ! -f "$ans"; then
1503         ans=`./loc Mlibc.a blurfl/dyick $xlibpth`
1504     fi
1505     if test ! -f "$ans"; then
1506         ans=`./loc Llibc.a blurfl/dyick $xlibpth`
1507     fi
1508     if test ! -f "$ans"; then
1509         ans=`./loc libc blurfl/dyick $libpth`
1510     fi
1511     if test ! -f "$ans"; then
1512         ans=`./loc clib blurfl/dyick $libpth`
1513     else
1514         libnames="$libnames "`./loc clib blurfl/dyick $libpth`
1515     fi
1516     if test -f "$ans"; then
1517         echo "Your C library is in $ans, of all places."
1518         libc=$ans
1519     else
1520         cat <<EOM
1521  
1522 I can't seem to find your C library.  I've looked in the following places:
1523
1524         $libpth
1525
1526 None of these seems to contain your C library.  What is the full name
1527 EOM
1528         dflt=None
1529         $echo $n "of your C library? $c"
1530         rp='C library full name?'
1531         . myread
1532         libc="$ans"
1533     fi
1534 fi
1535 echo " "
1536 set `echo $libc $libnames | tr ' ' '\012' | sort | uniq`
1537 $echo $n "Extracting names from $* for later perusal...$c"
1538 nm $* 2>/dev/null >libc.tmp
1539 $sed -n -e 's/^.* [ATDS]  *_[_.]*//p' -e 's/^.* [ATDS] //p' <libc.tmp >libc.list
1540 if $contains '^printf$' libc.list >/dev/null 2>&1; then
1541     echo "done"
1542 else
1543     $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' <libc.tmp >libc.list
1544     $contains '^printf$' libc.list >/dev/null 2>&1 || \
1545         $sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p' <libc.tmp >libc.list
1546     $contains '^printf$' libc.list >/dev/null 2>&1 || \
1547         $sed -n -e 's/^.* D __*//p' -e 's/^.* D //p' <libc.tmp >libc.list
1548     $contains '^printf$' libc.list >/dev/null 2>&1 || \
1549        $sed -n -e 's/^_//' \
1550               -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' <libc.tmp >libc.list
1551     $contains '^printf$' libc.list >/dev/null 2>&1 || \
1552         $sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p' \
1553            <libc.tmp >libc.list
1554     if $contains '^printf$' libc.list >/dev/null 2>&1; then
1555         echo "done"
1556     else
1557         echo " "
1558         echo "nm didn't seem to work right."
1559         echo "Trying ar instead..."
1560         if ar t $libc > libc.tmp; then
1561             for thisname in $libnames; do
1562                 ar t $thisname >>libc.tmp
1563             done
1564             $sed -e 's/\.o$//' < libc.tmp > libc.list
1565             echo "Ok."
1566         else
1567             echo "ar didn't seem to work right."
1568             echo "Maybe this is a Cray...trying bld instead..."
1569             if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
1570                 for thisname in $libnames; do
1571                     bld t $libnames | \
1572                         $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
1573                     ar t $thisname >>libc.tmp
1574                 done
1575                 echo "Ok."
1576             else
1577                 echo "That didn't work either.  Giving up."
1578                 exit 1
1579             fi
1580         fi
1581     fi
1582 fi
1583
1584 inlibc='echo " ";
1585 if $contains "^$1\$" libc.list >/dev/null 2>&1;
1586 then echo "$1() found"; eval "$2=$define";
1587 else echo "$1() not found"; eval "$2=$undef"; fi'
1588
1589 rmlist="$rmlist libc.tmp libc.list"
1590
1591 : see if bcmp exists
1592 set bcmp d_bcmp
1593 eval $inlibc
1594
1595 : see if bcopy exists
1596 set bcopy d_bcopy
1597 eval $inlibc
1598
1599 : see if bzero exists
1600 set bzero d_bzero
1601 eval $inlibc
1602
1603 : see if sprintf is declared as int or pointer to char
1604 echo " "
1605 cat >.ucbsprf.c <<'EOF'
1606 main() { char buf[10]; exit((unsigned long)sprintf(buf,"%s","foo") > 10L); }
1607 EOF
1608 if $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
1609     echo "Your sprintf() returns (int)."
1610     d_charsprf="$undef"
1611 else
1612     echo "Your sprintf() returns (char*)."
1613     d_charsprf="$define"
1614 fi
1615 /bin/rm -f .ucbsprf.c .ucbsprf
1616
1617 : see if vprintf exists
1618 echo " "
1619 if $contains '^vprintf$' libc.list >/dev/null 2>&1; then
1620     echo 'vprintf() found.'
1621     d_vprintf="$define"
1622     cat >.ucbsprf.c <<'EOF'
1623 #include <stdio.h>
1624 #include <varargs.h>
1625
1626 main() { xxx("foo"); }
1627
1628 xxx(va_alist)
1629 va_dcl
1630 {
1631     va_list args;
1632     char buf[10];
1633
1634     va_start(args);
1635     exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
1636 }
1637 EOF
1638     if $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
1639         echo "Your vsprintf() returns (int)."
1640         d_charvspr="$undef"
1641     else
1642         echo "Your vsprintf() returns (char*)."
1643         d_charvspr="$define"
1644     fi
1645     /bin/rm -f .ucbsprf.c .ucbsprf
1646 else
1647     echo 'vprintf() not found.'
1648     d_vprintf="$undef"
1649     d_charvspr="$undef"
1650 fi
1651
1652 : see if chsize exists
1653 set chsize d_chsize
1654 eval $inlibc
1655
1656 : see if crypt exists
1657 echo " "
1658 if $contains '^crypt$' libc.list >/dev/null 2>&1; then
1659     echo 'crypt() found.'
1660     d_crypt="$define"
1661     cryptlib=''
1662 else
1663     cryptlib=`./loc Slibcrypt.a "" $xlibpth`
1664     if $test -z "$cryptlib"; then
1665         cryptlib=`./loc Mlibcrypt.a "" $xlibpth`
1666     else
1667         cryptlib=-lcrypt
1668     fi
1669     if $test -z "$cryptlib"; then
1670         cryptlib=`./loc Llibcrypt.a "" $xlibpth`
1671     else
1672         cryptlib=-lcrypt
1673     fi
1674     if $test -z "$cryptlib"; then
1675         cryptlib=`./loc libcrypt.a "" $libpth`
1676     else
1677         cryptlib=-lcrypt
1678     fi
1679     if $test -z "$cryptlib"; then
1680         echo 'crypt() not found.'
1681         d_crypt="$undef"
1682     else
1683         d_crypt="$define"
1684     fi
1685 fi
1686
1687 : get csh whereabouts
1688 case "$csh" in
1689 'csh') d_csh="$undef" ;;
1690 *)     d_csh="$define" ;;
1691 esac
1692
1693 : see if this is a dirent system
1694 echo " "
1695 if $test -r /usr/include/dirent.h ; then
1696     i_dirent="$define"
1697     echo "dirent.h found."
1698     if $contains 'd_namlen' /usr/include/sys/dirent.h >/dev/null 2>&1; then
1699         d_dirnamlen="$define"
1700     else
1701         d_dirnamlen="$undef"
1702     fi
1703 else
1704     i_dirent="$undef"
1705     if $contains 'd_namlen' /usr/include/sys/dir.h >/dev/null 2>&1; then
1706         d_dirnamlen="$define"
1707     else
1708         d_dirnamlen="$undef"
1709     fi
1710     echo "No dirent.h found."
1711 fi
1712
1713 : now see if they want to do setuid emulation
1714 case "$d_dosuid" in
1715 '') dflt=n;;
1716 *undef*) dflt=n;;
1717 *) dflt=y;;
1718 esac
1719 cat <<EOM
1720  
1721 Some sites have disabled setuid #! scripts because of a bug in the kernel
1722 that prevents them from being secure.  If you are on such a system, the
1723 setuid/setgid bits on scripts are currently useless.  It is possible for
1724 $package to detect those bits and emulate setuid/setgid in a secure fashion
1725 until a better solution is devised for the kernel problem.
1726
1727 EOM
1728 rp="Do you want to do setuid/setgid emulation? [$dflt]"
1729 $echo $n "$rp $c"
1730 . myread
1731 case "$ans" in
1732 '') $ans="$dflt";;
1733 esac
1734 case "$ans" in
1735 y*)  d_dosuid="$define";;
1736 *) d_dosuid="$undef";;
1737 esac
1738
1739 : see if dup2 exists
1740 set dup2 d_dup2
1741 eval $inlibc
1742
1743 : see if fchmod exists
1744 set fchmod d_fchmod
1745 eval $inlibc
1746
1747 : see if fchown exists
1748 set fchown d_fchown
1749 eval $inlibc
1750
1751 : see if this is an fcntl system
1752 echo " "
1753 if $test -r /usr/include/fcntl.h ; then
1754     d_fcntl="$define"
1755     echo "fcntl.h found."
1756 else
1757     d_fcntl="$undef"
1758     echo "No fcntl.h found, but that's ok."
1759 fi
1760
1761 : see if we can have long filenames
1762 echo " "
1763 rm -f 123456789abcde
1764 if (echo hi >123456789abcdef) 2>/dev/null; then
1765     : not version 8
1766     if test -f 123456789abcde; then
1767         echo 'You cannot have filenames longer than 14 characters.  Sigh.'
1768         d_flexfnam="$undef"
1769     else
1770         echo 'You can have filenames longer than 14 characters.'
1771         d_flexfnam="$define"
1772     fi
1773 else
1774     : version 8 probably
1775     echo "You can't have filenames longer than 14 chars.  V8 can't even think about them!"
1776     d_flexfnam="$undef"
1777 fi 
1778 : see if flock exists
1779 set flock d_flock
1780 eval $inlibc
1781
1782 : see if getgroups exists
1783 set getgroups d_getgrps
1784 eval $inlibc
1785
1786 : see if gethostent exists
1787 set gethostent d_gethent
1788 eval $inlibc
1789
1790 : see if getpgrp exists
1791 set getpgrp d_getpgrp
1792 eval $inlibc
1793
1794 : see if getpgrp2 exists
1795 set getpgrp2 d_getpgrp2
1796 eval $inlibc
1797
1798 : see if getpriority exists
1799 set getpriority d_getprior
1800 eval $inlibc
1801
1802 : see if htonl exists
1803 set htonl d_htonl
1804 eval $inlibc
1805
1806 : index or strcpy
1807 echo " "
1808 case "$d_index" in
1809 n) dflt=n;;
1810 *) dflt=y;;
1811 esac
1812 if $contains '^index$' libc.list >/dev/null 2>&1 ; then
1813     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
1814         echo "Your system has both index() and strchr().  Shall I use"
1815         rp="index() rather than strchr()? [$dflt]"
1816         $echo $n "$rp $c"
1817         . myread
1818         case "$ans" in
1819             n*) d_index="$define" ;;
1820             *)  d_index="$undef" ;;
1821         esac
1822     else
1823         d_index="$undef"
1824         echo "index() found."
1825     fi
1826 else
1827     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
1828         d_index="$define"
1829         echo "strchr() found."
1830     else
1831         echo "No index() or strchr() found!"
1832         d_index="$undef"
1833     fi
1834 fi
1835
1836 : see if ioctl defs are in sgtty/termio or sys/ioctl
1837 echo " "
1838 if $test -r /usr/include/sys/ioctl.h ; then
1839     d_ioctl="$define"
1840     echo "sys/ioctl.h found."
1841 else
1842     d_ioctl="$undef"
1843     echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
1844 fi
1845
1846 : see if there is System V IPC
1847 set msgget d_ipcmsg
1848 eval $inlibc
1849
1850 set semget d_ipcsem
1851 eval $inlibc
1852
1853 set shmget d_ipcshm
1854 eval $inlibc
1855
1856 case "$d_ipcmsg$d_ipcsem$d_ipcshm" in
1857 *define*) d_sysvipc="$define";;
1858 *) d_sysvipc="$undef";;
1859 esac
1860
1861 : see if killpg exists
1862 set killpg d_killpg
1863 eval $inlibc
1864
1865 : see if lstat exists
1866 set lstat d_lstat
1867 eval $inlibc
1868
1869 : see if memcmp exists
1870 set memcmp d_memcmp
1871 eval $inlibc
1872
1873 : see if memcpy exists
1874 set memcpy d_memcpy
1875 eval $inlibc
1876
1877 : see if mkdir exists
1878 set mkdir d_mkdir
1879 eval $inlibc
1880
1881 : see if ndbm is available
1882 echo " "
1883 xxx=`./loc ndbm.h x /usr/include /usr/local/include $inclwanted`
1884 if test -f $xxx; then
1885     d_ndbm="$define"
1886     echo "ndbm.h found."
1887 else
1888     d_ndbm="$undef"
1889     echo "ndbm.h not found."
1890 fi
1891
1892 : see if we have the old dbm
1893 echo " "
1894 xxx=`./loc dbm.h x /usr/include /usr/local/include $inclwanted`
1895 if test -f $xxx; then
1896     d_odbm="$define"
1897     echo "dbm.h found."
1898 else
1899     d_odbm="$undef"
1900     echo "dbm.h not found."
1901 fi
1902
1903 socketlib=''
1904 : see whether socket exists
1905 echo " "
1906 if $contains socket libc.list >/dev/null 2>&1; then
1907     echo "Looks like you have Berkeley networking support."
1908     d_socket="$define"
1909     : now check for advanced features
1910     if $contains setsockopt libc.list >/dev/null 2>&1; then
1911         d_oldsock="$undef"
1912     else
1913         echo "...but it uses the old 4.1c interface, rather than 4.2"
1914         d_oldsock="$define"
1915     fi
1916 else
1917     : hpux, for one, puts all the socket stuff in socklib.o
1918     if $contains socklib libc.list >/dev/null 2>&1; then
1919         echo "Looks like you have Berkeley networking support."
1920         d_socket="$define"
1921         : we will have to assume that it supports the 4.2 BSD interface
1922         d_oldsock="$undef"
1923     else
1924         echo "Hmmm...you don't have Berkeley networking in libc.a..."
1925         : look for an optional networking library
1926         if test -f /usr/lib/libnet.a; then
1927             (ar t /usr/lib/libnet.a ||
1928                 nm -g /usr/lib/libnet.a) 2>/dev/null >> libc.list
1929             if $contains socket libc.list >/dev/null 2>&1; then
1930                 echo "but the Wollongong group seems to have hacked it in."
1931                 socketlib="-lnet"
1932                 d_socket="$define"
1933                 : now check for advanced features
1934                 if $contains setsockopt libc.list >/dev/null 2>&1; then
1935                     d_oldsock="$undef"
1936                 else
1937                     echo "...using the old 4.1c interface, rather than 4.2"
1938                     d_oldsock="$define"
1939                 fi
1940             else
1941                 echo "or even in libnet.a, which is peculiar."
1942                 d_socket="$undef"
1943                 d_oldsock="$undef"
1944             fi
1945         else
1946             echo "or anywhere else I see."
1947             d_socket="$undef"
1948             d_oldsock="$undef"
1949         fi
1950     fi
1951 fi
1952 if $contains socketpair libc.list >/dev/null 2>&1; then
1953     d_sockpair="$define"
1954 else
1955     d_sockpair="$undef"
1956 fi
1957
1958 : see if this is a pwd system
1959 echo " "
1960 if $test -r /usr/include/pwd.h ; then
1961     i_pwd="$define"
1962     echo "pwd.h found."
1963     $cppstdin $cppflags $cppminus </usr/include/pwd.h >$$.h
1964     if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
1965         d_pwcomment="$define"
1966     else
1967         d_pwcomment="$undef"
1968     fi
1969     if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
1970         d_pwquota="$define"
1971     else
1972         d_pwquota="$undef"
1973     fi
1974     if $contains 'pw_age' $$.h >/dev/null 2>&1; then
1975         d_pwage="$define"
1976     else
1977         d_pwage="$undef"
1978     fi
1979     if $contains 'pw_change' $$.h >/dev/null 2>&1; then
1980         d_pwchange="$define"
1981     else
1982         d_pwchange="$undef"
1983     fi
1984     if $contains 'pw_class' $$.h >/dev/null 2>&1; then
1985         d_pwclass="$define"
1986     else
1987         d_pwclass="$undef"
1988     fi
1989     if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
1990         d_pwexpire="$define"
1991     else
1992         d_pwexpire="$undef"
1993     fi
1994     rm -f $$.h
1995 else
1996     i_pwd="$undef"
1997     d_pwcomment="$undef"
1998     d_pwquota="$undef"
1999     d_pwage="$undef"
2000     d_pwchange="$undef"
2001     d_pwclass="$undef"
2002     d_pwexpire="$undef"
2003     echo "No pwd.h found."
2004 fi
2005
2006 : see if readdir exists
2007 set readdir d_readdir
2008 eval $inlibc
2009
2010 : see if rename exists
2011 set rename d_rename
2012 eval $inlibc
2013
2014 : see if rmdir exists
2015 set rmdir d_rmdir
2016 eval $inlibc
2017
2018 : see if select exists
2019 set select d_select
2020 eval $inlibc
2021
2022 : see if setegid exists
2023 set setegid d_setegid
2024 eval $inlibc
2025
2026 : see if seteuid exists
2027 set seteuid d_seteuid
2028 eval $inlibc
2029
2030 : see if setpgrp exists
2031 set setpgrp d_setpgrp
2032 eval $inlibc
2033
2034 : see if setpgrp2 exists
2035 set setpgrp2 d_setpgrp2
2036 eval $inlibc
2037
2038 : see if setpriority exists
2039 set setpriority d_setprior
2040 eval $inlibc
2041
2042 : see if setregid exists
2043 set setregid d_setregid
2044 eval $inlibc
2045 set setresgid d_setresgid
2046 eval $inlibc
2047
2048 : see if setreuid exists
2049 set setreuid d_setreuid
2050 eval $inlibc
2051 set setresuid d_setresuid
2052 eval $inlibc
2053
2054 : see if setrgid exists
2055 set setrgid d_setrgid
2056 eval $inlibc
2057
2058 : see if setruid exists
2059 set setruid d_setruid
2060 eval $inlibc
2061
2062 : see if stat knows about block sizes
2063 echo " "
2064 if $contains 'st_blocks;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
2065     if $contains 'st_blksize;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
2066         echo "Your stat knows about block sizes."
2067         d_statblks="$define"
2068     else
2069         echo "Your stat doesn't know about block sizes."
2070         d_statblks="$undef"
2071     fi
2072 else
2073     echo "Your stat doesn't know about block sizes."
2074     d_statblks="$undef"
2075 fi
2076
2077 : see if stdio is really std
2078 echo " "
2079 if $contains 'char.*_ptr.*;' /usr/include/stdio.h >/dev/null 2>&1 ; then
2080     if $contains '_cnt;' /usr/include/stdio.h >/dev/null 2>&1 ; then
2081         echo "Your stdio is pretty std."
2082         d_stdstdio="$define"
2083     else
2084         echo "Your stdio isn't very std."
2085         d_stdstdio="$undef"
2086     fi
2087 else
2088     echo "Your stdio isn't very std."
2089     d_stdstdio="$undef"
2090 fi
2091
2092 : check for structure copying
2093 echo " "
2094 echo "Checking to see if your C compiler can copy structs..."
2095 $cat >try.c <<'EOCP'
2096 main()
2097 {
2098         struct blurfl {
2099             int dyick;
2100         } foo, bar;
2101
2102         foo = bar;
2103 }
2104 EOCP
2105 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
2106     d_strctcpy="$define"
2107     echo "Yup, it can."
2108 else
2109     d_strctcpy="$undef"
2110     echo "Nope, it can't."
2111 fi
2112 $rm -f try.*
2113
2114 : see if strerror exists
2115 set strerror d_strerror
2116 eval $inlibc
2117
2118 : see if symlink exists
2119 set symlink d_symlink
2120 eval $inlibc
2121
2122 : see if syscall exists
2123 set syscall d_syscall
2124 eval $inlibc
2125
2126 : see if we should include time.h, sys/time.h, or both
2127 cat <<'EOM'
2128   
2129 Testing to see if we should include <time.h>, <sys/time.h> or both.
2130 I'm now running the test program...
2131 EOM
2132 $cat >try.c <<'EOCP'
2133 #ifdef I_TIME
2134 #include <time.h>
2135 #endif
2136 #ifdef I_SYSTIME
2137 #ifdef SYSTIMEKERNEL
2138 #define KERNEL
2139 #endif
2140 #include <sys/time.h>
2141 #endif
2142 main()
2143 {
2144     struct tm foo;
2145 #ifdef S_TIMEVAL
2146     struct timeval bar;
2147 #endif
2148     if (foo.tm_sec == foo.tm_sec)
2149         exit(0);
2150 #ifdef S_TIMEVAL
2151     if (bar.tv_sec == bar.tv_sec)
2152         exit(0);
2153 #endif
2154     exit(1);
2155 }
2156 EOCP
2157 flags=''
2158 for s_timeval in '-DS_TIMEVAL' ''; do
2159     for d_systimekernel in '' '-DSYSTIMEKERNEL'; do
2160         for i_time in '' '-DI_TIME'; do
2161             for i_systime in '-DI_SYSTIME' ''; do
2162                 case "$flags" in
2163                 '') echo Trying $i_time $i_systime $d_systimekernel $s_timeval
2164                     if $cc $ccflags \
2165                             $i_time $i_systime $d_systimekernel $s_timeval \
2166                             try.c -o try >/dev/null 2>&1 ; then
2167                         set X $i_time $i_systime $d_systimekernel $s_timeval
2168                         shift
2169                         flags="$*"
2170                         echo Succeeded with $flags
2171                     fi
2172                     ;;
2173                 esac
2174             done
2175         done
2176     done
2177 done
2178 case "$flags" in
2179 *SYSTIMEKERNEL*) d_systimekernel="$define";;
2180 *) d_systimekernel="$undef";;
2181 esac
2182 case "$flags" in
2183 *I_TIME*) i_time="$define";;
2184 *) i_time="$undef";;
2185 esac
2186 case "$flags" in
2187 *I_SYSTIME*) i_systime="$define";;
2188 *) i_systime="$undef";;
2189 esac
2190 $rm -f try.c try
2191
2192 : see if truncate exists
2193 set truncate d_truncate
2194 eval $inlibc
2195
2196 : see if this is a varargs system
2197 echo " "
2198 if $test -r /usr/include/varargs.h ; then
2199     d_varargs="$define"
2200     echo "varargs.h found."
2201 else
2202     d_varargs="$undef"
2203     echo "No varargs.h found, but that's ok (I hope)."
2204 fi
2205
2206 : see if there is a vfork
2207 set vfork d_vfork
2208 eval $inlibc
2209
2210 : see if signal is declared as pointer to function returning int or void
2211 echo " "
2212 $cppstdin $cppflags $cppminus < /usr/include/signal.h >$$.tmp
2213 if $contains 'void.*signal' $$.tmp >/dev/null 2>&1 ; then
2214     echo "You have void (*signal())() instead of int."
2215     d_voidsig="$define"
2216 else
2217     echo "You have int (*signal())() instead of void."
2218     d_voidsig="$undef"
2219 fi
2220 rm -f $$.tmp
2221
2222 : check for volatile keyword
2223 echo " "
2224 echo 'Checking to see if your C compiler knows about "volatile"...'
2225 $cat >try.c <<'EOCP'
2226 main()
2227 {
2228         typedef unsigned short foo_t;
2229         char *volatile foo;
2230         volatile int bar;
2231         volatile foo_t blech;
2232         foo = foo;
2233 }
2234 EOCP
2235 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
2236     d_volatile="$define"
2237     echo "Yup, it does."
2238 else
2239     d_volatile="$undef"
2240     echo "Nope, it doesn't."
2241 fi
2242 $rm -f try.*
2243
2244 : see if there is a wait4
2245 set wait4 d_wait4
2246 eval $inlibc
2247
2248 : see if there is a waitpid
2249 set waitpid d_waitpid
2250 eval $inlibc
2251
2252 : check for void type
2253 echo " "
2254 $cat <<EOM
2255 Checking to see how well your C compiler groks the void type...
2256
2257   Support flag bits are:
2258     1: basic void declarations.
2259     2: arrays of pointers to functions returning void.
2260     4: operations between pointers to and addresses of void functions.
2261
2262 EOM
2263 case "$voidflags" in
2264 '')
2265     $cat >try.c <<'EOCP'
2266 #if TRY & 1
2267 void main() {
2268 #else
2269 main() {
2270 #endif
2271         extern void moo();      /* function returning void */
2272         void (*goo)();          /* ptr to func returning void */
2273 #if TRY & 2
2274         void (*foo[10])();
2275 #endif
2276
2277 #if TRY & 4
2278         if(goo == moo) {
2279                 exit(0);
2280         }
2281 #endif
2282         exit(0);
2283 }
2284 EOCP
2285     if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
2286         voidflags=$defvoidused
2287         echo "It appears to support void."
2288         if $contains warning .out >/dev/null 2>&1; then
2289             echo "However, you might get some warnings that look like this:"
2290             $cat .out
2291         fi
2292     else
2293         echo "Hmm, your compiler has some difficulty with void.  Checking further..."
2294         if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1 ; then
2295             echo "It supports 1..."
2296             if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1 ; then
2297                 voidflags=3
2298                 echo "And it supports 2 but not 4."
2299             else
2300                 echo "It doesn't support 2..."
2301                 if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1 ; then
2302                     voidflags=5
2303                     echo "But it supports 4."
2304                 else
2305                     voidflags=1
2306                     echo "And it doesn't support 4."
2307                 fi
2308             fi
2309         else
2310             echo "There is no support at all for void."
2311             voidflags=0
2312         fi
2313     fi
2314 esac
2315 dflt="$voidflags";
2316 rp="Your void support flags add up to what? [$dflt]"
2317 $echo $n "$rp $c"
2318 . myread
2319 voidflags="$ans"
2320 $rm -f try.* .out
2321
2322 : see what type gids are declared as in the kernel
2323 echo " "
2324 case "$gidtype" in
2325 '')
2326     if $contains 'getgroups.*short' /usr/lib/lint/llib-lc >/dev/null 2>&1; then
2327         dflt='short'
2328     elif $contains 'getgroups.*int' /usr/lib/lint/llib-lc >/dev/null 2>&1; then
2329         dflt='int'
2330     elif $contains 'gid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
2331         dflt='gid_t'
2332     else
2333         set `grep 'groups\[NGROUPS\];' /usr/include/sys/user.h 2>/dev/null` unsigned short
2334         case $1 in
2335         unsigned) dflt="$1 $2" ;;
2336         *) dflt="$1" ;;
2337         esac
2338     fi
2339     ;;
2340 *)  dflt="$gidtype"
2341     ;;
2342 esac
2343 cont=true
2344 echo "(The following only matters if you have getgroups().)"
2345 rp="What type are the group ids returned by getgroups()? [$dflt]"
2346 $echo $n "$rp $c"
2347 . myread
2348 gidtype="$ans"
2349
2350 : see if this is an fcntl system
2351 echo " "
2352 if $test -r /usr/include/fcntl.h ; then
2353     i_fcntl="$define"
2354     echo "fcntl.h found."
2355 else
2356     i_fcntl="$undef"
2357     echo "No fcntl.h found, but that's ok."
2358 fi
2359
2360 : see if this is an grp system
2361 echo " "
2362 if $test -r /usr/include/grp.h ; then
2363     i_grp="$define"
2364     echo "grp.h found."
2365 else
2366     i_grp="$undef"
2367     echo "No grp.h found."
2368 fi
2369
2370 : see if this is a netinet/in.h system
2371 echo " "
2372 xxx=`./loc netinet/in.h x /usr/include /usr/local/include $inclwanted`
2373 if test -f $xxx; then
2374     i_niin="$define"
2375     echo "netinet/in.h found."
2376 else
2377     i_niin="$undef"
2378     echo "No netinet/in.h found."
2379 fi
2380
2381 : see if this is a sys/dir.h system
2382 echo " "
2383 if $test -r /usr/include/sys/dir.h ; then
2384     i_sysdir="$define"
2385     echo "sys/dir.h found."
2386 else
2387     i_sysdir="$undef"
2388     echo "No sys/dir.h found."
2389 fi
2390
2391 : see if ioctl defs are in sgtty/termio or sys/ioctl
2392 echo " "
2393 if $test -r /usr/include/sys/ioctl.h ; then
2394     i_sysioctl="$define"
2395     echo "sys/ioctl.h found."
2396 else
2397     i_sysioctl="$undef"
2398     echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
2399 fi
2400
2401 : see if this is a sys/ndir.h system
2402 echo " "
2403 xxx=`./loc sys/ndir.h x /usr/include /usr/local/include $inclwanted`
2404 if test -f $xxx; then
2405     i_sysndir="$define"
2406     echo "sys/ndir.h found."
2407 else
2408     i_sysndir="$undef"
2409     echo "No sys/ndir.h found."
2410 fi
2411
2412 : see if we should include utime.h
2413 echo " "
2414 if $test -r /usr/include/utime.h ; then
2415     i_utime="$define"
2416     echo "utime.h found."
2417 else
2418     i_utime="$undef"
2419     echo "No utime.h found, but that's ok."
2420 fi
2421
2422 : see if this is a varargs system
2423 echo " "
2424 if $test -r /usr/include/varargs.h ; then
2425     i_varargs="$define"
2426     echo "varargs.h found."
2427 else
2428     i_varargs="$undef"
2429     echo "No varargs.h found, but that's ok (I hope)."
2430 fi
2431
2432 : see if this is a vfork system
2433 echo " "
2434 if $test -r /usr/include/vfork.h ; then
2435     i_vfork="$define"
2436     echo "vfork.h found."
2437 else
2438     i_vfork="$undef"
2439     echo "No vfork.h found."
2440 fi
2441
2442 : check for length of integer
2443 echo " "
2444 case "$intsize" in
2445 '')
2446     echo "Checking to see how big your integers are..."
2447     $cat >try.c <<'EOCP'
2448 #include <stdio.h>
2449 main()
2450 {
2451     printf("%d\n", sizeof(int));
2452 }
2453 EOCP
2454     if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
2455         dflt=`./try`
2456     else
2457         dflt='4'
2458         echo "(I can't seem to compile the test program.  Guessing...)"
2459     fi
2460     ;;
2461 *)
2462     dflt="$intsize"
2463     ;;
2464 esac
2465 rp="What is the size of an integer (in bytes)? [$dflt]"
2466 $echo $n "$rp $c"
2467 . myread
2468 intsize="$ans"
2469 $rm -f try.c try
2470
2471 : determine where private executables go
2472 case "$privlib" in
2473 '')
2474     dflt=/usr/lib/$package
2475     test -d /usr/local/lib && dflt=/usr/local/lib/$package
2476     ;;
2477 *)  dflt="$privlib"
2478     ;;
2479 esac
2480 $cat <<EOM
2481
2482 The $package package has some auxiliary files that should be put in a library
2483 that is accessible by everyone.  Where do you want to put these "private"
2484 EOM
2485 $echo $n "but accessible files? (~name ok) [$dflt] $c"
2486 rp="Put private files where? [$dflt]"
2487 . myread
2488 privlib=`./filexp "$ans"`
2489
2490 : check for size of random number generator
2491 echo " "
2492 case "$randbits" in
2493 '')
2494     echo "Checking to see how many bits your rand function produces..."
2495     $cat >try.c <<'EOCP'
2496 #include <stdio.h>
2497 main()
2498 {
2499     register int i;
2500     register unsigned long tmp;
2501     register unsigned long max = 0L;
2502
2503     for (i=1000; i; i--) {
2504         tmp = (unsigned long)rand();
2505         if (tmp > max) max = tmp;
2506     }
2507     for (i=0; max; i++)
2508         max /= 2;
2509     printf("%d\n",i);
2510 }
2511 EOCP
2512     if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
2513         dflt=`./try`
2514     else
2515         dflt='?'
2516         echo "(I can't seem to compile the test program...)"
2517     fi
2518     ;;
2519 *)
2520     dflt="$randbits"
2521     ;;
2522 esac
2523 rp="How many bits does your rand() function produce? [$dflt]"
2524 $echo $n "$rp $c"
2525 . myread
2526 randbits="$ans"
2527 $rm -f try.c try
2528
2529 : generate list of signal names
2530 echo " "
2531 case "$sig_name" in
2532 '')
2533     echo "Generating a list of signal names..."
2534     set X `cat /usr/include/signal.h /usr/include/sys/signal.h 2>&1 | awk '
2535 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
2536     sig[$3] = substr($2,4,20)
2537     if (max < $3 && $3 < 60) {
2538         max = $3
2539     }
2540 }
2541
2542 END {
2543     for (i=1; i<=max; i++) {
2544         if (sig[i] == "")
2545             printf "%d", i
2546         else
2547             printf "%s", sig[i]
2548         if (i < max)
2549             printf " "
2550     }
2551     printf "\n"
2552 }
2553 '`
2554     shift
2555     case $# in
2556     0)  echo 'kill -l' >/tmp/foo$$
2557         set X `$csh -f </tmp/foo$$`
2558         shift
2559         case $# in
2560         0)set HUP INT QUIT ILL TRAP IOT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
2561             ;;
2562         esac
2563         ;;
2564     esac
2565     sig_name="ZERO $*"
2566     ;;
2567 esac
2568 echo "Signals are: $sig_name"
2569
2570 : see what type of char stdio uses.
2571 echo " "
2572 if $contains 'unsigned.*char.*_ptr.*;' /usr/include/stdio.h >/dev/null 2>&1 ; then
2573     echo "Your stdio uses unsigned chars."
2574     stdchar="unsigned char"
2575 else
2576     echo "Your stdio uses signed chars."
2577     stdchar="char"
2578 fi
2579
2580 : see what type uids are declared as in the kernel
2581 case "$uidtype" in
2582 '')
2583     if $contains 'uid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
2584         dflt='uid_t';
2585     else
2586         set `grep '_ruid;' /usr/include/sys/user.h 2>/dev/null` unsigned short
2587         case $1 in
2588         unsigned) dflt="$1 $2" ;;
2589         *) dflt="$1" ;;
2590         esac
2591     fi
2592     ;;
2593 *)  dflt="$uidtype"
2594     ;;
2595 esac
2596 cont=true
2597 echo " "
2598 rp="What type are user ids returned by getuid(), etc.? [$dflt]"
2599 $echo $n "$rp $c"
2600 . myread
2601 uidtype="$ans"
2602
2603 : preserve RCS keywords in files with variable substitution, grrr
2604 Log='$Log'
2605 Header='$Header'
2606
2607
2608 : determine which malloc to compile in
2609 echo " "
2610 case "$usemymalloc" in
2611 '')
2612     if bsd || v7; then
2613         dflt='y'
2614     else
2615         dflt='n'
2616     fi
2617     ;;
2618 *)  dflt="$usemymalloc"
2619     ;;
2620 esac
2621 rp="Do you wish to attempt to use the malloc that comes with $package? [$dflt]"
2622 $echo $n "$rp $c"
2623 . myread
2624 case "$ans" in
2625 '') ans=$dflt;;
2626 esac
2627 usemymalloc="$ans"
2628 case "$ans" in
2629 y*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
2630 *) mallocsrc=''; mallocobj='';;
2631 esac
2632
2633 : determine where public executables go
2634 case "$scriptdir" in
2635 '')
2636     dflt="$bin"
2637     : guess some guesses
2638     test -d /usr/share/scripts && dflt=/usr/share/scripts
2639     test -d /usr/share/bin && dflt=/usr/share/bin
2640     ;;
2641 *)  dflt="$scriptdir"
2642     ;;
2643 esac
2644 cont=true
2645 $cat <<EOM
2646  
2647 Some installations have a separate directory just for executable scripts so
2648 that they can mount it across multiple architectures but keep the scripts in
2649 one spot.  You might, for example, have a subdirectory of /usr/share for this.
2650 Or you might just lump your scripts in with all your other executables.
2651  
2652 EOM
2653 while $test "$cont" ; do
2654     rp="Where do you keep publicly executable scripts? (~name ok) [$dflt]"
2655     $echo $n "$rp $c"
2656     . myread
2657     scriptdir="$ans"
2658     scriptdir=`./filexp "$scriptdir"`
2659     if test -d $scriptdir; then
2660         cont=''
2661     else
2662         case "$fastread" in
2663         yes) dflt=y;;
2664         *) dflt=n;;
2665         esac
2666         rp="Directory $scriptdir doesn't exist.  Use that name anyway? [$dflt]"
2667         $echo $n "$rp $c"
2668         . myread
2669         dflt=''
2670         case "$ans" in
2671         y*) cont='';;
2672         esac
2673     fi
2674 done
2675
2676 : determine compiler compiler
2677 case "$yacc" in
2678 '') dflt=yacc;;
2679 *)  dflt="$yacc";;
2680 esac
2681 cont=true
2682     echo " "
2683 rp="Which compiler compiler (yacc or bison -y) will you use? [$dflt]"
2684 $echo $n "$rp $c"
2685 . myread
2686 case "$ans" in
2687 '') ans="$dflt";;
2688 esac
2689 yacc="$ans"
2690
2691 echo " "
2692 echo "End of configuration questions."
2693 echo " "
2694
2695 : create config.sh file
2696 echo " "
2697 if test -d ../UU; then
2698     cd ..
2699 fi
2700 echo "Creating config.sh..."
2701 $spitshell <<EOT >config.sh
2702 $startsh
2703 # config.sh
2704 # This file was produced by running the Configure script.
2705
2706 d_eunice='$d_eunice'
2707 define='$define'
2708 eunicefix='$eunicefix'
2709 loclist='$loclist'
2710 expr='$expr'
2711 sed='$sed'
2712 echo='$echo'
2713 cat='$cat'
2714 rm='$rm'
2715 mv='$mv'
2716 cp='$cp'
2717 tail='$tail'
2718 tr='$tr'
2719 mkdir='$mkdir'
2720 sort='$sort'
2721 uniq='$uniq'
2722 grep='$grep'
2723 trylist='$trylist'
2724 test='$test'
2725 inews='$inews'
2726 egrep='$egrep'
2727 more='$more'
2728 pg='$pg'
2729 Mcc='$Mcc'
2730 vi='$vi'
2731 mailx='$mailx'
2732 mail='$mail'
2733 cpp='$cpp'
2734 perl='$perl'
2735 emacs='$emacs'
2736 ls='$ls'
2737 rmail='$rmail'
2738 sendmail='$sendmail'
2739 shar='$shar'
2740 smail='$smail'
2741 tbl='$tbl'
2742 troff='$troff'
2743 nroff='$nroff'
2744 uname='$uname'
2745 uuname='$uuname'
2746 line='$line'
2747 chgrp='$chgrp'
2748 chmod='$chmod'
2749 lint='$lint'
2750 sleep='$sleep'
2751 pr='$pr'
2752 tar='$tar'
2753 ln='$ln'
2754 lpr='$lpr'
2755 lp='$lp'
2756 touch='$touch'
2757 make='$make'
2758 date='$date'
2759 csh='$csh'
2760 Log='$Log'
2761 Header='$Header'
2762 alignbytes='$alignbytes'
2763 bin='$bin'
2764 byteorder='$byteorder'
2765 contains='$contains'
2766 cppstdin='$cppstdin'
2767 cppminus='$cppminus'
2768 d_bcmp='$d_bcmp'
2769 d_bcopy='$d_bcopy'
2770 d_bzero='$d_bzero'
2771 d_castneg='$d_castneg'
2772 castflags='$castflags'
2773 d_charsprf='$d_charsprf'
2774 d_chsize='$d_chsize'
2775 d_crypt='$d_crypt'
2776 cryptlib='$cryptlib'
2777 d_csh='$d_csh'
2778 d_dosuid='$d_dosuid'
2779 d_dup2='$d_dup2'
2780 d_fchmod='$d_fchmod'
2781 d_fchown='$d_fchown'
2782 d_fcntl='$d_fcntl'
2783 d_flexfnam='$d_flexfnam'
2784 d_flock='$d_flock'
2785 d_getgrps='$d_getgrps'
2786 d_gethent='$d_gethent'
2787 d_getpgrp='$d_getpgrp'
2788 d_getpgrp2='$d_getpgrp2'
2789 d_getprior='$d_getprior'
2790 d_htonl='$d_htonl'
2791 d_index='$d_index'
2792 d_ioctl='$d_ioctl'
2793 d_killpg='$d_killpg'
2794 d_lstat='$d_lstat'
2795 d_memcmp='$d_memcmp'
2796 d_memcpy='$d_memcpy'
2797 d_mkdir='$d_mkdir'
2798 d_ndbm='$d_ndbm'
2799 d_odbm='$d_odbm'
2800 d_readdir='$d_readdir'
2801 d_rename='$d_rename'
2802 d_rmdir='$d_rmdir'
2803 d_select='$d_select'
2804 d_setegid='$d_setegid'
2805 d_seteuid='$d_seteuid'
2806 d_setpgrp='$d_setpgrp'
2807 d_setpgrp2='$d_setpgrp2'
2808 d_setprior='$d_setprior'
2809 d_setregid='$d_setregid'
2810 d_setresgid='$d_setresgid'
2811 d_setreuid='$d_setreuid'
2812 d_setresuid='$d_setresuid'
2813 d_setrgid='$d_setrgid'
2814 d_setruid='$d_setruid'
2815 d_socket='$d_socket'
2816 d_sockpair='$d_sockpair'
2817 d_oldsock='$d_oldsock'
2818 socketlib='$socketlib'
2819 d_statblks='$d_statblks'
2820 d_stdstdio='$d_stdstdio'
2821 d_strctcpy='$d_strctcpy'
2822 d_strerror='$d_strerror'
2823 d_symlink='$d_symlink'
2824 d_syscall='$d_syscall'
2825 d_sysvipc='$d_sysvipc'
2826 d_ipcmsg='$d_ipcmsg'
2827 d_ipcsem='$d_ipcsem'
2828 d_ipcshm='$d_ipcshm'
2829 d_truncate='$d_truncate'
2830 d_varargs='$d_varargs'
2831 d_vfork='$d_vfork'
2832 d_voidsig='$d_voidsig'
2833 d_volatile='$d_volatile'
2834 d_vprintf='$d_vprintf'
2835 d_charvspr='$d_charvspr'
2836 d_wait4='$d_wait4'
2837 d_waitpid='$d_waitpid'
2838 gidtype='$gidtype'
2839 i_dirent='$i_dirent'
2840 d_dirnamlen='$d_dirnamlen'
2841 i_fcntl='$i_fcntl'
2842 i_grp='$i_grp'
2843 i_niin='$i_niin'
2844 i_pwd='$i_pwd'
2845 d_pwcomment='$d_pwcomment'
2846 d_pwquota='$d_pwquota'
2847 d_pwage='$d_pwage'
2848 d_pwchange='$d_pwchange'
2849 d_pwclass='$d_pwclass'
2850 d_pwexpire='$d_pwexpire'
2851 i_sysdir='$i_sysdir'
2852 i_sysioctl='$i_sysioctl'
2853 i_sysndir='$i_sysndir'
2854 i_time='$i_time'
2855 i_systime='$i_systime'
2856 d_systimekernel='$d_systimekernel'
2857 i_utime='$i_utime'
2858 i_varargs='$i_varargs'
2859 i_vfork='$i_vfork'
2860 intsize='$intsize'
2861 libc='$libc'
2862 mallocsrc='$mallocsrc'
2863 mallocobj='$mallocobj'
2864 usemymalloc='$usemymalloc'
2865 mansrc='$mansrc'
2866 manext='$manext'
2867 models='$models'
2868 split='$split'
2869 small='$small'
2870 medium='$medium'
2871 large='$large'
2872 huge='$huge'
2873 optimize='$optimize'
2874 ccflags='$ccflags'
2875 cppflags='$cppflags'
2876 ldflags='$ldflags'
2877 cc='$cc'
2878 libs='$libs'
2879 n='$n'
2880 c='$c'
2881 package='$package'
2882 randbits='$randbits'
2883 scriptdir='$scriptdir'
2884 sig_name='$sig_name'
2885 spitshell='$spitshell'
2886 shsharp='$shsharp'
2887 sharpbang='$sharpbang'
2888 startsh='$startsh'
2889 stdchar='$stdchar'
2890 uidtype='$uidtype'
2891 voidflags='$voidflags'
2892 defvoidused='$defvoidused'
2893 yacc='$yacc'
2894 privlib='$privlib'
2895 lib='$lib'
2896 CONFIG=true
2897 EOT
2898
2899 CONFIG=true
2900
2901 echo " "
2902 dflt=''
2903 fastread=''
2904 echo "If you didn't make any mistakes, then just type a carriage return here."
2905 rp="If you need to edit config.sh, do it as a shell escape here:"
2906 $echo $n "$rp $c"
2907 . UU/myread
2908 case "$ans" in
2909 '') ;;
2910 *) : in case they cannot read
2911     eval $ans;;
2912 esac
2913 : if this fails, just run all the .SH files by hand
2914 . ./config.sh
2915
2916 echo " "
2917 echo "Doing variable substitutions on .SH files..."
2918 set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
2919 shift
2920 case $# in
2921 0) set x *.SH; shift;;
2922 esac
2923 if test ! -f $1; then
2924     shift
2925 fi
2926 for file in $*; do
2927     case "$file" in
2928     */*)
2929         dir=`$expr X$file : 'X\(.*\)/'`
2930         file=`$expr X$file : 'X.*/\(.*\)'`
2931         (cd $dir && . $file)
2932         ;;
2933     *)
2934         . $file
2935         ;;
2936     esac
2937 done
2938 if test -f config.h.SH; then
2939     if test ! -f config.h; then
2940         : oops, they left it out of MANIFEST, probably, so do it anyway.
2941         . config.h.SH
2942     fi
2943 fi
2944
2945 if $contains '^depend:' Makefile >/dev/null 2>&1; then
2946     dflt=n
2947     $cat <<EOM
2948
2949 Now you need to generate make dependencies by running "make depend".
2950 You might prefer to run it in background: "make depend > makedepend.out &"
2951 It can take a while, so you might not want to run it right now.
2952
2953 EOM
2954     rp="Run make depend now? [$dflt]"
2955     $echo $n "$rp $c"
2956     . UU/myread
2957     case "$ans" in
2958     y*) make depend && echo "Now you must run a make."
2959         ;;
2960     *)  echo "You must run 'make depend' then 'make'."
2961         ;;
2962     esac
2963 elif test -f Makefile; then
2964     echo " "
2965     echo "Now you must run a make."
2966 else
2967     echo "Done."
2968 fi
2969
2970 $rm -f kit*isdone
2971 : the following is currently useless
2972 cd UU && $rm -f $rmlist
2973 : since this removes it all anyway
2974 cd .. && $rm -rf UU
2975 : end of Configure