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