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