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