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