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