perl 1.0 patch 1: Portability bugs and one possible SIGSEGV
[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 1.0.1.1 88/01/21 21:21:47 root Exp $
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'
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 d_eunice=''
38 eunicefix=''
39 define=''
40 loclist=''
41 expr=''
42 sed=''
43 echo=''
44 cat=''
45 rm=''
46 mv=''
47 cp=''
48 tail=''
49 tr=''
50 mkdir=''
51 sort=''
52 uniq=''
53 grep=''
54 trylist=''
55 test=''
56 inews=''
57 egrep=''
58 more=''
59 pg=''
60 Mcc=''
61 vi=''
62 mailx=''
63 mail=''
64 Log=''
65 Header=''
66 bin=''
67 cc=''
68 contains=''
69 cpp=''
70 cppminus=''
71 d_charsprf=''
72 d_index=''
73 d_stdstdio=''
74 d_strctcpy=''
75 d_vfork=''
76 d_voidsig=''
77 libc=''
78 libnm=''
79 mansrc=''
80 manext=''
81 models=''
82 split=''
83 small=''
84 medium=''
85 large=''
86 huge=''
87 ccflags=''
88 ldflags=''
89 n=''
90 c=''
91 package=''
92 spitshell=''
93 shsharp=''
94 sharpbang=''
95 startsh=''
96 stdchar=''
97 voidflags=''
98 defvoidused=''
99 CONFIG=''
100
101 : set package name
102 package=perl
103
104 echo " "
105 echo "Beginning of configuration questions for $package kit."
106 : Eunice requires " " instead of "", can you believe it
107 echo " "
108
109 define='define'
110 undef='/*undef'
111 libpth='/usr/lib /usr/local/lib /lib'
112 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
113 rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
114 trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
115 attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
116 attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
117 attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
118 pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib"
119 defvoidused=7
120
121 : some greps do not return status, grrr.
122 echo "grimblepritz" >grimble
123 if grep blurfldyick grimble >/dev/null 2>&1 ; then
124     contains=contains
125 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
126     contains=grep
127 else
128     contains=contains
129 fi
130 rm -f grimble
131 : the following should work in any shell
132 case "$contains" in
133 contains*)
134     echo " "
135     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
136     cat >contains <<'EOSS'
137 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
138 EOSS
139 chmod 755 contains
140 esac
141
142 : first determine how to suppress newline on echo command
143 echo "Checking echo to see how to suppress newlines..."
144 (echo "hi there\c" ; echo " ") >.echotmp
145 if $contains c .echotmp >/dev/null 2>&1 ; then
146     echo "...using -n."
147     n='-n'
148     c=''
149 else
150     cat <<'EOM'
151 ...using \c
152 EOM
153     n=''
154     c='\c'
155 fi
156 echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
157 read ans
158 rm -f .echotmp
159
160 : now set up to do reads with possible shell escape and default assignment
161 cat <<EOSC >myread
162 ans='!'
163 while expr "X\$ans" : "X!" >/dev/null; do
164     read ans
165     case "\$ans" in
166     !)
167         sh
168         echo " "
169         echo $n "\$rp $c"
170         ;;
171     !*)
172         set \`expr "X\$ans" : "X!\(.*\)\$"\`
173         sh -c "\$*"
174         echo " "
175         echo $n "\$rp $c"
176         ;;
177     esac
178 done
179 rp='Your answer:'
180 case "\$ans" in
181 '') ans="\$dflt";;
182 esac
183 EOSC
184
185 : general instructions
186 cat <<EOH
187  
188 This installation shell script will examine your system and ask you questions
189 to determine how the $package package should be installed.  If you get stuck
190 on a question, you may use a ! shell escape to start a subshell or execute
191 a command.  Many of the questions will have default answers in square
192 brackets--typing carriage return will give you the default.
193
194 On some of the questions which ask for file or directory names you are
195 allowed to use the ~name construct to specify the login directory belonging
196 to "name", even if you don't have a shell which knows about that.  Questions
197 where this is allowed will be marked "(~name ok)".
198
199 EOH
200 rp="[Type carriage return to continue]"
201 echo $n "$rp $c"
202 . myread
203 cat <<EOH
204
205 Much effort has been expended to ensure that this shell script will run
206 on any Unix system.  If despite that it blows up on you, your best bet is
207 to edit Configure and run it again. Also, let me (lwall@jpl-devvax.jpl.nasa.gov)
208 know how I blew it.  If you can't run Configure for some reason, you'll have
209 to generate a config.sh file by hand.
210
211 This installation script affects things in two ways: 1) it may do direct
212 variable substitutions on some of the files included in this kit, and
213 2) it builds a config.h file for inclusion in C programs.  You may edit
214 any of these files as the need arises after running this script.
215
216 If you make a mistake on a question, there is no easy way to back up to it
217 currently.  The easiest thing to do is to edit config.sh and rerun all the
218 SH files.  Configure will offer to let you do this before it runs the SH files.
219
220 EOH
221 rp="[Type carriage return to continue]"
222 echo $n "$rp $c"
223 . myread
224
225 : get old answers, if there is a config file out there
226 if test -f ../config.sh; then
227     echo " "
228     dflt=y
229     rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
230     echo $n "$rp $c"
231     . myread
232     case "$ans" in
233     n*) echo "OK, I'll ignore it.";;
234     *)  echo "Fetching default answers from your old config.sh file..."
235         tmp="$n"
236         ans="$c"
237         . ../config.sh
238         n="$tmp"
239         c="$ans"
240         ;;
241     esac
242 fi
243
244 : find out where common programs are
245 echo " "
246 echo "Locating common programs..."
247 cat <<EOSC >loc
248 $startsh
249 case \$# in
250 0) exit 1;;
251 esac
252 thing=\$1
253 shift
254 dflt=\$1
255 shift
256 for dir in \$*; do
257     case "\$thing" in
258     .)
259         if test -d \$dir/\$thing; then
260             echo \$dir
261             exit 0
262         fi
263         ;;
264     *)
265         if test -f \$dir/\$thing; then
266             echo \$dir/\$thing
267             exit 0
268         fi
269         ;;
270     esac
271 done
272 echo \$dflt
273 exit 1
274 EOSC
275 chmod 755 loc
276 $eunicefix loc
277 loclist="
278 expr
279 sed
280 echo
281 cat
282 rm
283 mv
284 cp
285 tr
286 mkdir
287 sort
288 uniq
289 grep
290 "
291 trylist="
292 test
293 egrep
294 Mcc
295 "
296 for file in $loclist; do
297     xxx=`loc $file $file $pth`
298     eval $file=$xxx
299     eval _$file=$xxx
300     case "$xxx" in
301     /*)
302         echo $file is in $xxx.
303         ;;
304     *)
305         echo "I don't know where $file is.  I hope it's in everyone's PATH."
306         ;;
307     esac
308 done
309 echo " "
310 echo "Don't worry if any of the following aren't found..."
311 ans=offhand
312 for file in $trylist; do
313     xxx=`loc $file $file $pth`
314     eval $file=$xxx
315     eval _$file=$xxx
316     case "$xxx" in
317     /*)
318         echo $file is in $xxx.
319         ;;
320     *)
321         echo "I don't see $file out there, $ans."
322         ans=either
323         ;;
324     esac
325 done
326 case "$egrep" in
327 egrep)
328     echo "Substituting grep for egrep."
329     egrep=$grep
330     ;;
331 esac
332 case "$test" in
333 test)
334     echo "Hopefully test is built into your sh."
335     ;;
336 /bin/test)
337     echo " "
338     dflt=n
339     rp="Is your "'"'"test"'"'" built into sh? [$dflt] (OK to guess)"
340     echo $n "$rp $c"
341     . myread
342     case "$ans" in
343     y*) test=test ;;
344     esac
345     ;;
346 *)
347     test=test
348     ;;
349 esac
350 case "$echo" in
351 echo)
352     echo "Hopefully echo is built into your sh."
353     ;;
354 /bin/echo)
355     echo " "
356     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
357     $echo $n "hi there$c" >foo1
358     echo $n "hi there$c" >foo2
359     if cmp foo1 foo2 >/dev/null 2>&1; then
360         echo "They are compatible.  In fact, they may be identical."
361     else
362         case "$n" in
363         '-n') n='' c='\c' ans='\c' ;;
364         *) n='-n' c='' ans='-n' ;;
365         esac
366         cat <<FOO
367 They are not compatible!  You are probably running ksh on a non-USG system.
368 I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
369 have echo built in and we may have to run some Bourne shell scripts.  That
370 means I'll have to use $ans to suppress newlines now.  Life is ridiculous.
371
372 FOO
373         rp="Your cursor should be here-->"
374         $echo $n "$rp$c"
375         . myread
376     fi
377     $rm -f foo1 foo2
378     ;;
379 *)
380     : cross your fingers
381     echo=echo
382     ;;
383 esac
384 rmlist="$rmlist loc"
385
386 : get list of predefined functions in a handy place
387 echo " "
388 if test -f /lib/libc.a; then
389     echo "Your C library is in /lib/libc.a.  You're normal."
390     libc=/lib/libc.a
391 else
392     ans=`loc libc.a blurfl/dyick $libpth`
393     if test -f $ans; then
394         echo "Your C library is in $ans, of all places."
395         libc=ans
396     else
397         if test -f "$libc"; then
398             echo "Your C library is in $libc, like you said before."
399         else
400             cat <<EOM
401  
402 I can't seem to find your C library.  I've looked in the following places:
403
404         $libpth
405
406 None of these seems to contain your C library.  What is the full name
407 EOM
408             dflt=None
409             $echo $n "of your C library? $c"
410             rp='C library full name?'
411             . myread
412             libc="$ans"
413         fi
414     fi
415 fi
416 echo " "
417 $echo $n "Extracting names from $libc for later perusal...$c"
418 if ar t $libc > libc.list; then
419     echo "done"
420 else
421     echo " "
422     echo "The archiver doesn't think $libc is a reasonable library."
423     echo "Trying nm instead..."
424     if nm -g $libc > libc.list; then
425         echo "Done.  Maybe this is Unicos, or an Apollo?"
426     else
427         echo "That didn't work either.  Giving up."
428         exit 1
429     fi
430 fi
431 rmlist="$rmlist libc.list"
432
433 : make some quick guesses about what we are up against
434 echo " "
435 $echo $n "Hmm...  $c"
436 if $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then
437     echo "Looks kind of like a BSD system, but we'll see..."
438     echo exit 0 >bsd
439     echo exit 1 >usg
440     echo exit 1 >v7
441 elif $contains fcntl libc.list >/dev/null 2>&1 ; then
442     echo "Looks kind of like a USG system, but we'll see..."
443     echo exit 1 >bsd
444     echo exit 0 >usg
445     echo exit 1 >v7
446 else
447     echo "Looks kind of like a version 7 system, but we'll see..."
448     echo exit 1 >bsd
449     echo exit 1 >usg
450     echo exit 0 >v7
451 fi
452 if $contains vmssystem libc.list >/dev/null 2>&1 ; then
453     cat <<'EOI'
454 There is, however, a strange, musty smell in the air that reminds me of
455 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
456 EOI
457     echo "exit 0" >eunice
458     eunicefix=unixtovms
459     d_eunice="$define"
460 : it so happens the Eunice I know will not run shell scripts in Unix format
461 else
462     echo " "
463     echo "Congratulations.  You aren't running Eunice."
464     eunicefix=':'
465     d_eunice="$undef"
466     echo "exit 1" >eunice
467 fi
468 if test -f /xenix; then
469     echo "Actually, this looks more like a XENIX system..."
470     echo "exit 0" >xenix
471 else
472     echo " "
473     echo "It's not Xenix..."
474     echo "exit 1" >xenix
475 fi
476 chmod 755 xenix
477 if test -f /venix; then
478     echo "Actually, this looks more like a VENIX system..."
479     echo "exit 0" >venix
480 else
481     echo " "
482     if xenix; then
483         : null
484     else
485         echo "Nor is it Venix..."
486     fi
487     echo "exit 1" >venix
488 fi
489 chmod 755 bsd usg v7 eunice venix xenix
490 $eunicefix bsd usg v7 eunice venix xenix
491 rmlist="$rmlist bsd usg v7 eunice venix xenix"
492
493 : see if sh knows # comments
494 echo " "
495 echo "Checking your sh to see if it knows about # comments..."
496 if sh -c '#' >/dev/null 2>&1 ; then
497     echo "Your sh handles # comments correctly."
498     shsharp=true
499     spitshell=cat
500     echo " "
501     echo "Okay, let's see if #! works on this system..."
502     echo "#!/bin/echo hi" > try
503     $eunicefix try
504     chmod 755 try
505     try > today
506     if test -s today; then
507         echo "It does."
508         sharpbang='#!'
509     else
510         echo "#! /bin/echo hi" > try
511         $eunicefix try
512         chmod 755 try
513         try > today
514         if test -s today; then
515             echo "It does."
516             sharpbang='#! '
517         else
518             echo "It doesn't."
519             sharpbang=': use '
520         fi
521     fi
522 else
523     echo "Your sh doesn't grok # comments--I will strip them later on."
524     shsharp=false
525     echo "exec grep -v '^#'" >spitshell
526     chmod 755 spitshell
527     $eunicefix spitshell
528     spitshell=`pwd`/spitshell
529     echo "I presume that if # doesn't work, #! won't work either!"
530     sharpbang=': use '
531 fi
532
533 : figure out how to guarantee sh startup
534 echo " "
535 echo "Checking out how to guarantee sh startup..."
536 startsh=$sharpbang'/bin/sh'
537 echo "Let's see if '$startsh' works..."
538 cat >try <<EOSS
539 $startsh
540 set abc
541 test "$?abc" != 1
542 EOSS
543
544 chmod 755 try
545 $eunicefix try
546 if try; then
547     echo "Yup, it does."
548 else
549     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
550 fi
551 rm -f try today
552
553 : see how we invoke the C preprocessor
554 echo " "
555 echo "Now, how can we feed standard input to your C preprocessor..."
556 cat <<'EOT' >testcpp.c
557 #define ABC abc
558 #define XYZ xyz
559 ABC.XYZ
560 EOT
561 echo 'Maybe "/lib/cpp" will work...'
562 /lib/cpp <testcpp.c >testcpp.out 2>&1
563 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
564     echo "Yup, it does."
565     cpp='/lib/cpp'
566     cppminus='';
567 else
568     echo 'Nope, maybe "/lib/cpp -" will work...'
569     /lib/cpp - <testcpp.c >testcpp.out 2>&1
570     if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
571         echo "Yup, it does."
572         cpp='/lib/cpp'
573         cppminus='-';
574     else
575         echo 'No such luck...maybe "cc -E" will work...'
576         cc -E <testcpp.c >testcpp.out 2>&1
577         if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
578             echo "It works!"
579             cpp='cc -E'
580             cppminus='';
581         else
582             echo 'Nixed again...maybe "cc -E -" will work...'
583             cc -E - <testcpp.c >testcpp.out 2>&1
584             if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
585                 echo "Hooray, it works!  I was beginning to wonder."
586                 cpp='cc -E'
587                 cppminus='-';
588             else
589                 echo 'Nope...maybe "cc -P" will work...'
590                 cc -P <testcpp.c >testcpp.out 2>&1
591                 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
592                     echo "Yup, that does."
593                     cpp='cc -P'
594                     cppminus='';
595                 else
596                     echo 'Nope...maybe "cc -P -" will work...'
597                     cc -P - <testcpp.c >testcpp.out 2>&1
598                     if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
599                         echo "Yup, that does."
600                         cpp='cc -P'
601                         cppminus='-';
602                     else
603                         echo 'Hmm...perhaps you already told me...'
604                         case "$cpp" in
605                         '') ;;
606                         *) $cpp $cppminus <testcpp.c >testcpp.out 2>&1;;
607                         esac
608                         if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
609                             echo "Hooray, you did!  I was beginning to wonder."
610                         else
611                             echo 'Uh-uh.  Time to get fancy...'
612                             echo 'Trying (cat >/tmp/$$.c; cc -E /tmp/$$.c; rm /tmp/$$.c)'
613                             cpp='(cat >/tmp/$$.c; cc -E /tmp/$$.c; rm /tmp/$$.c)'
614                             cppminus='';
615                             $cpp <testcpp.c >testcpp.out 2>&1
616                             if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
617                                 echo "Eureka!."
618                             else
619                                 dflt=blurfl
620                                 $echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
621                                 rp='Name a C preprocessor:'
622                                 . myread
623                                 cpp="$ans"
624                                 $cpp <testcpp.c >testcpp.out 2>&1
625                                 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
626                                     echo "OK, that will do."
627                                 else
628                                     echo "Sorry, I can't get that to work.  Go find one."
629                                     exit 1
630                                 fi
631                             fi
632                         fi
633                     fi
634                 fi
635             fi
636         fi
637     fi
638 fi
639 rm -f testcpp.c testcpp.out
640
641 : see if sprintf is declared as int or pointer to char
642 echo " "
643 if $contains 'char.*sprintf' /usr/include/stdio.h >/dev/null 2>&1 ; then
644     echo "Your sprintf() returns (char*)."
645     d_charsprf="$define"
646 else
647     echo "Your sprintf() returns (int)."
648     d_charsprf="$undef"
649 fi
650
651 : index or strcpy
652 echo " "
653 dflt=y
654 if $contains index libc.list >/dev/null 2>&1 ; then
655     echo "Your system appears to use index() and rindex() rather than strchr()"
656     $echo $n "and strrchr().  Is this correct? [$dflt] $c"
657     rp='index() rather than strchr()? [$dflt]'
658     . myread
659     case "$ans" in
660         n*|f*) d_index="$define" ;;
661         *)     d_index="$undef" ;;
662     esac
663 else
664     echo "Your system appears to use strchr() and strrchr() rather than index()"
665     $echo $n "and rindex().  Is this correct? [$dflt] $c"
666     rp='strchr() rather than index()? [$dflt]'
667     . myread
668     case "$ans" in
669         n*|f*) d_index="$undef" ;;
670         *)     d_index="$define" ;;
671     esac
672 fi
673
674 : see if stdio is really std
675 echo " "
676 if $contains 'char.*_ptr;' /usr/include/stdio.h >/dev/null 2>&1 ; then
677     if $contains '_cnt;' /usr/include/stdio.h >/dev/null 2>&1 ; then
678         echo "Your stdio is pretty std."
679         d_stdstdio="$define"
680     else
681         echo "Your stdio isn't very std."
682         d_stdstdio="$undef"
683     fi
684 else
685     echo "Your stdio isn't very std."
686     d_stdstdio="$undef"
687 fi
688
689 : check for structure copying
690 echo " "
691 echo "Checking to see if your C compiler can copy structs..."
692 $cat >try.c <<'EOCP'
693 main()
694 {
695         struct blurfl {
696             int dyick;
697         } foo, bar;
698
699         foo = bar;
700 }
701 EOCP
702 if cc -c try.c >/dev/null 2>&1 ; then
703     d_strctcpy="$define"
704     echo "Yup, it can."
705 else
706     d_strctcpy="$undef"
707     echo "Nope, it can't."
708 fi
709 $rm -f try.*
710
711 : see if there is a vfork
712 echo " "
713 if $contains vfork libc.list >/dev/null 2>&1 ; then
714     echo "vfork() found."
715     d_vfork="$undef"
716 else
717     echo "No vfork() found--will use fork() instead."
718     d_vfork="$define"
719 fi
720
721 : see if signal is declared as pointer to function returning int or void
722 echo " "
723 if $contains 'void.*signal' /usr/include/signal.h >/dev/null 2>&1 ; then
724     echo "You have void (*signal())() instead of int."
725     d_voidsig="$define"
726 else
727     echo "You have int (*signal())() instead of void."
728     d_voidsig="$undef"
729 fi
730
731 : check for void type
732 echo " "
733 $cat <<EOM
734 Checking to see how well your C compiler groks the void type...
735
736   Support flag bits are:
737     1: basic void declarations.
738     2: arrays of pointers to functions returning void.
739     4: operations between pointers to and addresses of void functions.
740
741 EOM
742 case "$voidflags" in
743 '')
744     $cat >try.c <<'EOCP'
745 #if TRY & 1
746 void main() {
747 #else
748 main() {
749 #endif
750         extern void *moo();
751         void (*goo)();
752 #if TRY & 2
753         void (*foo[10])();
754 #endif
755
756 #if TRY & 4
757         if(goo == moo) {
758                 exit(0);
759         }
760 #endif
761         exit(0);
762 }
763 EOCP
764     if cc -S -DTRY=7 try.c >.out 2>&1 ; then
765         voidflags=7
766         echo "It appears to support void fully."
767         if $contains warning .out >/dev/null 2>&1; then
768             echo "However, you might get some warnings that look like this:"
769             $cat .out
770         fi
771     else
772         echo "Hmm, you compiler has some difficulty with void.  Checking further..."
773         if cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
774             echo "It supports 1..."
775             if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
776                 voidflags=3
777                 echo "And it supports 2 but not 4."
778             else
779                 echo "It doesn't support 2..."
780                 if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
781                     voidflags=5
782                     echo "But it supports 4."
783                 else
784                     voidflags=1
785                     echo "And it doesn't support 4."
786                 fi
787             fi
788         else
789             echo "There is no support at all for void."
790             voidflags=0
791         fi
792     fi
793 esac
794 dflt="$voidflags";
795 rp="Your void support flags add up to what? [$dflt]"
796 $echo $n "$rp $c"
797 . myread
798 voidflags="$ans"
799 $rm -f try.* .out
800
801 : see what type of char stdio uses.
802 echo " "
803 if $contains 'unsigned.*char.*_ptr;' /usr/include/stdio.h >/dev/null 2>&1 ; then
804     echo "Your stdio uses unsigned chars."
805     stdchar="unsigned char"
806 else
807     echo "Your stdio uses signed chars."
808     stdchar="char"
809 fi
810
811 : preserve RCS keywords in files with variable substitution, grrr
812 Log='$Log'
813 Header='$Header'
814
815 : set up shell script to do ~ expansion
816 cat >filexp <<EOSS
817 $startsh
818 : expand filename
819 case "\$1" in
820  ~/*|~)
821     echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
822     ;;
823  ~*)
824     if $test -f /bin/csh; then
825         /bin/csh -f -c "glob \$1"
826         echo ""
827     else
828         name=\`$expr x\$1 : '..\([^/]*\)'\`
829         dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
830         if $test ! -d "\$dir"; then
831             me=\`basename \$0\`
832             echo "\$me: can't locate home directory for: \$name" >&2
833             exit 1
834         fi
835         case "\$1" in
836         */*)
837             echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
838             ;;
839         *)
840             echo \$dir
841             ;;
842         esac
843     fi
844     ;;
845 *)
846     echo \$1
847     ;;
848 esac
849 EOSS
850 chmod 755 filexp
851 $eunicefix filexp
852
853 : determine where public executables go
854 case "$bin" in
855 '')
856     dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
857     ;;
858 *)  dflt="$bin"
859     ;;
860 esac
861 cont=true
862 while $test "$cont" ; do
863     echo " "
864     rp="Where do you want to put the public executables? [$dflt]"
865     $echo $n "$rp $c"
866     . myread
867     bin="$ans"
868     bin=`filexp $bin`
869     if test -d $bin; then
870         cont=''
871     else
872         dflt=n
873         rp="Directory $bin doesn't exist.  Use that name anyway? [$dflt]"
874         $echo $n "$rp $c"
875         . myread
876         dflt=''
877         case "$ans" in
878         y*) cont='';;
879         esac
880     fi
881 done
882
883 : determine where manual pages go
884 case "$mansrc" in
885 '')
886     dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
887     ;;
888 *)  dflt="$mansrc"
889     ;;
890 esac
891 cont=true
892 while $test "$cont" ; do
893     echo " "
894     rp="Where do the manual pages (source) go? [$dflt]"
895     $echo $n "$rp $c"
896     . myread
897     mansrc=`filexp "$ans"`
898     if test -d $mansrc; then
899         cont=''
900     else
901         dflt=n
902         rp="Directory $mansrc doesn't exist.  Use that name anyway? [$dflt]"
903         $echo $n "$rp $c"
904         . myread
905         dflt=''
906         case "$ans" in
907         y*) cont='';;
908         esac
909     fi
910 done
911 case "$mansrc" in
912 *l)
913     manext=l
914     ;;
915 *n)
916     manext=n
917     ;;
918 *)
919     manext=1
920     ;;
921 esac
922
923 : get C preprocessor symbols handy
924 echo " "
925 echo $attrlist | $tr '[ - ]' '[\012-\012]' >Cppsym.know
926 $cat <<EOSS >Cppsym
927 $startsh
928 case "\$1" in
929 -l) list=true
930     shift
931     ;;
932 esac
933 unknown=''
934 case "\$list\$#" in
935 1|2)
936     for sym do
937         if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
938             exit 0
939         elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
940                 :
941         else
942             unknown="\$unknown \$sym"
943         fi
944     done
945     set X \$unknown
946     shift
947     ;;
948 esac
949 case \$# in
950 0) exit 1;;
951 esac
952 echo \$* | $tr '[ - ]' '[\012-\012]' | $sed -e 's/\(.*\)/\\
953 #ifdef \1\\
954 exit 0; _ _ _ _\1\\      \1\\
955 #endif\\
956 /' >/tmp/Cppsym\$\$
957 echo exit 1 >>/tmp/Cppsym\$\$
958 $cpp $cppminus </tmp/Cppsym\$\$ >/tmp/Cppsym2\$\$
959 case "\$list" in
960 true) awk '\$6 != "" {print substr(\$6,2,100)}' </tmp/Cppsym2\$\$ ;;
961 *)
962     sh /tmp/Cppsym2\$\$
963     status=\$?
964     ;;
965 esac
966 $rm -f /tmp/Cppsym\$\$ /tmp/Cppsym2\$\$
967 exit \$status
968 EOSS
969 chmod 755 Cppsym
970 $eunicefix Cppsym
971 echo "Your C preprocessor defines the following symbols:"
972 Cppsym -l $attrlist >Cppsym.true
973 cat Cppsym.true
974 rmlist="$rmlist Cppsym Cppsym.know Cppsym.true"
975
976 : see what memory models we can support
977 case "$models" in
978 '')
979     if Cppsym pdp11; then
980         dflt='unsplit split'
981     else
982         ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
983         case "$ans" in
984         X) dflt='none';;
985         *)  if $test -d /lib/small || $test -d /usr/lib/small; then
986                 dflt='small'
987             else
988                 dflt=''
989             fi
990             if $test -d /lib/medium || $test -d /usr/lib/medium; then
991                 dflt="$dflt medium"
992             fi
993             if $test -d /lib/large || $test -d /usr/lib/large; then
994                 dflt="$dflt large"
995             fi
996             if $test -d /lib/huge || $test -d /usr/lib/huge; then
997                 dflt="$dflt huge"
998             fi
999         esac
1000     fi
1001     ;;
1002 *)  dflt="$models" ;;
1003 esac
1004 $cat <<EOM
1005  
1006 Some systems have different model sizes.  On most systems they are called
1007 small, medium, large, and huge.  On the PDP11 they are called unsplit and
1008 split.  If your system doesn't support different memory models, say "none".
1009 If you wish to force everything to one memory model, say "none" here and
1010 put the appropriate flags later when it asks you for other cc and ld flags.
1011 Venix systems may wish to put "none" and let the compiler figure things out.
1012 (In the following question multiple model names should be space separated.)
1013
1014 EOM
1015 rp="Which models are supported? [$dflt]"
1016 $echo $n "$rp $c"
1017 . myread
1018 models="$ans"
1019
1020 case "$models" in
1021 none)
1022     small=''
1023     medium=''
1024     large=''
1025     huge=''
1026     unsplit=''
1027     split=''
1028     ;;
1029 *split)
1030     case "$split" in
1031     '') 
1032         if $contains '-i' $mansrc/ld.1 >/dev/null 2>&1 || \
1033            $contains '-i' $mansrc/cc.1 >/dev/null 2>&1; then
1034             dflt='-i'
1035         else
1036             dflt='none'
1037         fi
1038         ;;
1039     *) dflt="$split";;
1040     esac
1041     rp="What flag indicates separate I and D space? [$dflt]"
1042     $echo $n "$rp $c"
1043     . myread
1044     case "$ans" in
1045     none) ans='';;
1046     esac
1047     split="$ans"
1048     unsplit=''
1049     ;;
1050 *large*|*small*|*medium*|*huge*)
1051     case "$model" in
1052     *large*)
1053         case "$large" in
1054         '') dflt='-Ml';;
1055         *) dflt="$large";;
1056         esac
1057         rp="What flag indicates large model? [$dflt]"
1058         $echo $n "$rp $c"
1059         . myread
1060         case "$ans" in
1061         none) ans='';
1062         esac
1063         large="$ans"
1064         ;;
1065     *) large='';;
1066     esac
1067     case "$model" in
1068     *huge*)
1069         case "$huge" in
1070         '') dflt='-Mh';;
1071         *) dflt="$huge";;
1072         esac
1073         rp="What flag indicates huge model? [$dflt]"
1074         $echo $n "$rp $c"
1075         . myread
1076         case "$ans" in
1077         none) ans='';
1078         esac
1079         huge="$ans"
1080         ;;
1081     *) huge="$large";;
1082     esac
1083     case "$model" in
1084     *medium*)
1085         case "$medium" in
1086         '') dflt='-Mm';;
1087         *) dflt="$medium";;
1088         esac
1089         rp="What flag indicates medium model? [$dflt]"
1090         $echo $n "$rp $c"
1091         . myread
1092         case "$ans" in
1093         none) ans='';
1094         esac
1095         medium="$ans"
1096         ;;
1097     *) medium="$large";;
1098     esac
1099     case "$model" in
1100     *small*)
1101         case "$small" in
1102         '') dflt='none';;
1103         *) dflt="$small";;
1104         esac
1105         rp="What flag indicates small model? [$dflt]"
1106         $echo $n "$rp $c"
1107         . myread
1108         case "$ans" in
1109         none) ans='';
1110         esac
1111         small="$ans"
1112         ;;
1113     *) small='';;
1114     esac
1115     ;;
1116 *)
1117     echo "Unrecognized memory models--you may have to edit Makefile.SH"
1118     ;;
1119 esac
1120
1121 case "$ccflags" in
1122 '') dflt='none';;
1123 *) dflt="$ccflags";;
1124 esac
1125 echo " "
1126 rp="Any additional cc flags? [$dflt]"
1127 $echo $n "$rp $c"
1128 . myread
1129 case "$ans" in
1130 none) ans='';
1131 esac
1132 ccflags="$ans"
1133
1134 case "$ldflags" in
1135 '') if venix; then
1136         dflt='-i -z'
1137     else
1138         dflt='none'
1139     fi
1140     ;;
1141 *) dflt="$ldflags";;
1142 esac
1143 echo " "
1144 rp="Any additional ld flags? [$dflt]"
1145 $echo $n "$rp $c"
1146 . myread
1147 case "$ans" in
1148 none) ans='';
1149 esac
1150 ldflags="$ans"
1151
1152 : see if we need a special compiler
1153 echo " "
1154 if usg; then
1155     case "$cc" in
1156     '')
1157         case "$Mcc" in
1158         /*) dflt='Mcc'
1159             ;;
1160         *)
1161             case "$large" in
1162             -M*)
1163                 dflt='cc'
1164                 ;;
1165             *)
1166                 if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
1167                     dflt='cc -M'
1168                 else
1169                     dflt='cc'
1170                 fi
1171                 ;;
1172             esac
1173             ;;
1174         esac
1175         ;;
1176     *)  dflt="$cc";;
1177     esac
1178     $cat <<'EOM'
1179  
1180 On some systems the default C compiler will not resolve multiple global
1181 references that happen to have the same name.  On some such systems the
1182 "Mcc" command may be used to force these to be resolved.  On other systems
1183 a "cc -M" command is required.  (Note that the -M flag on other systems
1184 indicates a memory model to use!)  What command will force resolution on
1185 EOM
1186     $echo $n "this system? [$dflt] $c"
1187     rp="Command to resolve multiple refs? [$dflt]"
1188     . myread
1189     cc="$ans"
1190 else
1191     echo "Not a USG system--assuming cc can resolve multiple definitions."
1192     cc=cc
1193 fi
1194
1195 : see if we should include -lnm
1196 echo " "
1197 if $test -r /usr/lib/libnm.a || $test -r /usr/local/lib/libnm.a ; then
1198     echo "New math library found."
1199     libnm='-lnm'
1200 else
1201     ans=`loc libnm.a x $libpth`
1202     case "$ans" in
1203     x)
1204         echo "No nm library found--the normal math library will have to do."
1205         libnm=''
1206         ;;
1207     *)
1208         echo "New math library found in $ans."
1209         libnm="$ans"
1210         ;;
1211     esac
1212 fi
1213
1214 echo " "
1215 echo "End of configuration questions."
1216 echo " "
1217
1218 : create config.sh file
1219 echo " "
1220 if test -d ../UU; then
1221     cd ..
1222 fi
1223 echo "Creating config.sh..."
1224 $spitshell <<EOT >config.sh
1225 $startsh
1226 # config.sh
1227 # This file was produced by running the Configure script.
1228
1229 d_eunice='$d_eunice'
1230 eunicefix='$eunicefix'
1231 define='$define'
1232 loclist='$loclist'
1233 expr='$expr'
1234 sed='$sed'
1235 echo='$echo'
1236 cat='$cat'
1237 rm='$rm'
1238 mv='$mv'
1239 cp='$cp'
1240 tail='$tail'
1241 tr='$tr'
1242 mkdir='$mkdir'
1243 sort='$sort'
1244 uniq='$uniq'
1245 grep='$grep'
1246 trylist='$trylist'
1247 test='$test'
1248 inews='$inews'
1249 egrep='$egrep'
1250 more='$more'
1251 pg='$pg'
1252 Mcc='$Mcc'
1253 vi='$vi'
1254 mailx='$mailx'
1255 mail='$mail'
1256 Log='$Log'
1257 Header='$Header'
1258 bin='$bin'
1259 cc='$cc'
1260 contains='$contains'
1261 cpp='$cpp'
1262 cppminus='$cppminus'
1263 d_charsprf='$d_charsprf'
1264 d_index='$d_index'
1265 d_stdstdio='$d_stdstdio'
1266 d_strctcpy='$d_strctcpy'
1267 d_vfork='$d_vfork'
1268 d_voidsig='$d_voidsig'
1269 libc='$libc'
1270 libnm='$libnm'
1271 mansrc='$mansrc'
1272 manext='$manext'
1273 models='$models'
1274 split='$split'
1275 small='$small'
1276 medium='$medium'
1277 large='$large'
1278 huge='$huge'
1279 ccflags='$ccflags'
1280 ldflags='$ldflags'
1281 n='$n'
1282 c='$c'
1283 package='$package'
1284 spitshell='$spitshell'
1285 shsharp='$shsharp'
1286 sharpbang='$sharpbang'
1287 startsh='$startsh'
1288 stdchar='$stdchar'
1289 voidflags='$voidflags'
1290 defvoidused='$defvoidused'
1291 CONFIG=true
1292 EOT
1293  
1294 CONFIG=true
1295
1296 echo " "
1297 dflt=''
1298 echo "If you didn't make any mistakes, then just type a carriage return here."
1299 rp="If you need to edit config.sh, do it as a shell escape here:"
1300 $echo $n "$rp $c"
1301 . UU/myread
1302 case "$ans" in
1303 '') ;;
1304 *) : in case they cannot read
1305     eval $ans;;
1306 esac
1307
1308 echo " "
1309 echo "Doing variable substitutions on .SH files..."
1310 set x `$grep '\.SH' <MANIFEST | awk '{print $1}'`
1311 shift
1312 case $# in
1313 0) set x *.SH; shift;;
1314 esac
1315 if test ! -f $1; then
1316     shift
1317 fi
1318 for file in $*; do
1319     case "$file" in
1320     */*)
1321         dir=`$expr X$file : 'X\(.*\)/'`
1322         file=`$expr X$file : 'X.*/\(.*\)'`
1323         (cd $dir && . $file)
1324         ;;
1325     *)
1326         . $file
1327         ;;
1328     esac
1329 done
1330 if test -f config.h.SH; then
1331     if test ! -f config.h; then
1332         : oops, they left it out of MANIFEST, probably, so do it anyway.
1333         . config.h.SH
1334     fi
1335 fi
1336
1337 if $contains '^depend:' Makefile >/dev/null 2>&1; then
1338     dflt=n
1339     $cat <<EOM
1340
1341 Now you need to generate make dependencies by running "make depend".
1342 You might prefer to run it in background: "make depend > makedepend.out &"
1343 It can take a while, so you might not want to run it right now.
1344
1345 EOM
1346     rp="Run make depend now? [$dflt]"
1347     $echo $n "$rp $c"
1348     . UU/myread
1349     case "$ans" in
1350     y*) make depend
1351         echo "Now you must run a make."
1352         ;;
1353     *)  echo "You must run 'make depend' then 'make'."
1354         ;;
1355     esac
1356 elif test -f Makefile; then
1357     echo " "
1358     echo "Now you must run a make."
1359 else
1360     echo "Done."
1361 fi
1362
1363 $rm -f kit*isdone
1364 cd UU && $rm -f $rmlist
1365 : end of Configure