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