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