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