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