perl 1.0 patch 1: Portability bugs and one possible SIGSEGV
[p5sagit/p5-mst-13.2.git] / Configure
CommitLineData
8d063cd8 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#
36ce8bec 11# $Header: Configure,v 1.0.1.1 88/01/21 21:21:47 root Exp $
8d063cd8 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
18PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc'
19export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
20
21if test ! -t 0; then
22 echo "Say 'sh Configure', not 'sh <Configure'"
23 exit 1
24fi
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
30if test ! -d ../UU; then
31 if test ! -d UU; then
32 mkdir UU
33 fi
34 cd UU
35fi
36
37d_eunice=''
38eunicefix=''
39define=''
40loclist=''
41expr=''
42sed=''
43echo=''
44cat=''
45rm=''
46mv=''
47cp=''
48tail=''
49tr=''
50mkdir=''
51sort=''
52uniq=''
53grep=''
54trylist=''
55test=''
56inews=''
57egrep=''
58more=''
59pg=''
60Mcc=''
61vi=''
62mailx=''
63mail=''
64Log=''
65Header=''
66bin=''
67cc=''
68contains=''
69cpp=''
36ce8bec 70cppminus=''
8d063cd8 71d_charsprf=''
72d_index=''
36ce8bec 73d_stdstdio=''
8d063cd8 74d_strctcpy=''
75d_vfork=''
36ce8bec 76d_voidsig=''
8d063cd8 77libc=''
78libnm=''
79mansrc=''
80manext=''
81models=''
82split=''
83small=''
84medium=''
85large=''
86huge=''
87ccflags=''
88ldflags=''
89n=''
90c=''
91package=''
92spitshell=''
93shsharp=''
94sharpbang=''
95startsh=''
36ce8bec 96stdchar=''
8d063cd8 97voidflags=''
98defvoidused=''
99CONFIG=''
100
101: set package name
102package=perl
103
104echo " "
105echo "Beginning of configuration questions for $package kit."
106: Eunice requires " " instead of "", can you believe it
107echo " "
108
109define='define'
110undef='/*undef'
111libpth='/usr/lib /usr/local/lib /lib'
112smallmach='pdp11 i8086 z8000 i80286 iAPX286'
113rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
114trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
115attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
116attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
36ce8bec 117attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
8d063cd8 118pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib"
119defvoidused=7
120
121: some greps do not return status, grrr.
122echo "grimblepritz" >grimble
123if grep blurfldyick grimble >/dev/null 2>&1 ; then
124 contains=contains
125elif grep grimblepritz grimble >/dev/null 2>&1 ; then
126 contains=grep
127else
128 contains=contains
129fi
130rm -f grimble
131: the following should work in any shell
132case "$contains" in
133contains*)
134 echo " "
135 echo "AGH! Grep doesn't return a status. Attempting remedial action."
136 cat >contains <<'EOSS'
137grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
138EOSS
139chmod 755 contains
140esac
141
142: first determine how to suppress newline on echo command
143echo "Checking echo to see how to suppress newlines..."
144(echo "hi there\c" ; echo " ") >.echotmp
145if $contains c .echotmp >/dev/null 2>&1 ; then
146 echo "...using -n."
147 n='-n'
148 c=''
149else
150 cat <<'EOM'
151...using \c
152EOM
153 n=''
154 c='\c'
155fi
156echo $n "Type carriage return to continue. Your cursor should be here-->$c"
157read ans
158rm -f .echotmp
159
160: now set up to do reads with possible shell escape and default assignment
161cat <<EOSC >myread
162ans='!'
163while 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
178done
179rp='Your answer:'
180case "\$ans" in
181'') ans="\$dflt";;
182esac
183EOSC
184
185: general instructions
186cat <<EOH
187
188This installation shell script will examine your system and ask you questions
189to determine how the $package package should be installed. If you get stuck
190on a question, you may use a ! shell escape to start a subshell or execute
191a command. Many of the questions will have default answers in square
192brackets--typing carriage return will give you the default.
193
194On some of the questions which ask for file or directory names you are
195allowed to use the ~name construct to specify the login directory belonging
196to "name", even if you don't have a shell which knows about that. Questions
197where this is allowed will be marked "(~name ok)".
198
199EOH
200rp="[Type carriage return to continue]"
201echo $n "$rp $c"
202. myread
203cat <<EOH
204
205Much effort has been expended to ensure that this shell script will run
206on any Unix system. If despite that it blows up on you, your best bet is
36ce8bec 207to edit Configure and run it again. Also, let me (lwall@jpl-devvax.jpl.nasa.gov)
208know how I blew it. If you can't run Configure for some reason, you'll have
8d063cd8 209to generate a config.sh file by hand.
210
211This installation script affects things in two ways: 1) it may do direct
212variable substitutions on some of the files included in this kit, and
2132) it builds a config.h file for inclusion in C programs. You may edit
214any of these files as the need arises after running this script.
215
216If you make a mistake on a question, there is no easy way to back up to it
217currently. The easiest thing to do is to edit config.sh and rerun all the
218SH files. Configure will offer to let you do this before it runs the SH files.
219
220EOH
221rp="[Type carriage return to continue]"
222echo $n "$rp $c"
223. myread
224
225: get old answers, if there is a config file out there
226if 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
242fi
243
244: find out where common programs are
245echo " "
246echo "Locating common programs..."
247cat <<EOSC >loc
248$startsh
249case \$# in
2500) exit 1;;
251esac
252thing=\$1
253shift
254dflt=\$1
255shift
256for 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
271done
272echo \$dflt
273exit 1
274EOSC
275chmod 755 loc
276$eunicefix loc
277loclist="
278expr
279sed
280echo
281cat
282rm
283mv
284cp
285tr
286mkdir
287sort
288uniq
289grep
290"
291trylist="
292test
293egrep
294Mcc
295"
296for 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
308done
309echo " "
310echo "Don't worry if any of the following aren't found..."
311ans=offhand
312for 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
325done
326case "$egrep" in
327egrep)
328 echo "Substituting grep for egrep."
329 egrep=$grep
330 ;;
331esac
332case "$test" in
333test)
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 ;;
349esac
350case "$echo" in
351echo)
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
367They are not compatible! You are probably running ksh on a non-USG system.
368I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
369have echo built in and we may have to run some Bourne shell scripts. That
370means I'll have to use $ans to suppress newlines now. Life is ridiculous.
371
372FOO
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 ;;
383esac
384rmlist="$rmlist loc"
385
386: get list of predefined functions in a handy place
387echo " "
388if test -f /lib/libc.a; then
389 echo "Your C library is in /lib/libc.a. You're normal."
390 libc=/lib/libc.a
391else
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
402I can't seem to find your C library. I've looked in the following places:
403
404 $libpth
405
406None of these seems to contain your C library. What is the full name
407EOM
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
415fi
416echo " "
417$echo $n "Extracting names from $libc for later perusal...$c"
418if ar t $libc > libc.list; then
419 echo "done"
420else
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
430fi
431rmlist="$rmlist libc.list"
432
433: make some quick guesses about what we are up against
434echo " "
435$echo $n "Hmm... $c"
436if $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
441elif $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
446else
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
451fi
452if $contains vmssystem libc.list >/dev/null 2>&1 ; then
453 cat <<'EOI'
454There is, however, a strange, musty smell in the air that reminds me of
455something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
456EOI
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
461else
462 echo " "
463 echo "Congratulations. You aren't running Eunice."
464 eunicefix=':'
465 d_eunice="$undef"
466 echo "exit 1" >eunice
467fi
468if test -f /xenix; then
469 echo "Actually, this looks more like a XENIX system..."
470 echo "exit 0" >xenix
471else
472 echo " "
473 echo "It's not Xenix..."
474 echo "exit 1" >xenix
475fi
476chmod 755 xenix
477if test -f /venix; then
478 echo "Actually, this looks more like a VENIX system..."
479 echo "exit 0" >venix
480else
481 echo " "
482 if xenix; then
483 : null
484 else
485 echo "Nor is it Venix..."
486 fi
487 echo "exit 1" >venix
488fi
489chmod 755 bsd usg v7 eunice venix xenix
490$eunicefix bsd usg v7 eunice venix xenix
491rmlist="$rmlist bsd usg v7 eunice venix xenix"
492
493: see if sh knows # comments
494echo " "
495echo "Checking your sh to see if it knows about # comments..."
496if 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
522else
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 '
531fi
532
533: figure out how to guarantee sh startup
534echo " "
535echo "Checking out how to guarantee sh startup..."
536startsh=$sharpbang'/bin/sh'
537echo "Let's see if '$startsh' works..."
538cat >try <<EOSS
539$startsh
540set abc
541test "$?abc" != 1
542EOSS
543
544chmod 755 try
545$eunicefix try
546if try; then
547 echo "Yup, it does."
548else
549 echo "Nope. You may have to fix up the shell scripts to make sure sh runs them."
550fi
551rm -f try today
552
36ce8bec 553: see how we invoke the C preprocessor
554echo " "
555echo "Now, how can we feed standard input to your C preprocessor..."
556cat <<'EOT' >testcpp.c
557#define ABC abc
558#define XYZ xyz
559ABC.XYZ
560EOT
561echo 'Maybe "/lib/cpp" will work...'
562/lib/cpp <testcpp.c >testcpp.out 2>&1
563if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
564 echo "Yup, it does."
565 cpp='/lib/cpp'
566 cppminus='';
567else
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
638fi
639rm -f testcpp.c testcpp.out
640
8d063cd8 641: see if sprintf is declared as int or pointer to char
642echo " "
643if $contains 'char.*sprintf' /usr/include/stdio.h >/dev/null 2>&1 ; then
644 echo "Your sprintf() returns (char*)."
645 d_charsprf="$define"
646else
647 echo "Your sprintf() returns (int)."
648 d_charsprf="$undef"
649fi
650
651: index or strcpy
652echo " "
653dflt=y
654if $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
663else
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
672fi
673
36ce8bec 674: see if stdio is really std
675echo " "
676if $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
684else
685 echo "Your stdio isn't very std."
686 d_stdstdio="$undef"
687fi
688
8d063cd8 689: check for structure copying
690echo " "
691echo "Checking to see if your C compiler can copy structs..."
692$cat >try.c <<'EOCP'
693main()
694{
695 struct blurfl {
696 int dyick;
697 } foo, bar;
698
699 foo = bar;
700}
701EOCP
702if cc -c try.c >/dev/null 2>&1 ; then
703 d_strctcpy="$define"
704 echo "Yup, it can."
705else
706 d_strctcpy="$undef"
707 echo "Nope, it can't."
708fi
709$rm -f try.*
710
711: see if there is a vfork
712echo " "
713if $contains vfork libc.list >/dev/null 2>&1 ; then
714 echo "vfork() found."
715 d_vfork="$undef"
716else
717 echo "No vfork() found--will use fork() instead."
718 d_vfork="$define"
719fi
720
36ce8bec 721: see if signal is declared as pointer to function returning int or void
722echo " "
723if $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"
726else
727 echo "You have int (*signal())() instead of void."
728 d_voidsig="$undef"
729fi
730
8d063cd8 731: check for void type
732echo " "
733$cat <<EOM
734Checking 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
741EOM
742case "$voidflags" in
743'')
744 $cat >try.c <<'EOCP'
745#if TRY & 1
746void main() {
747#else
748main() {
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}
763EOCP
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
793esac
794dflt="$voidflags";
795rp="Your void support flags add up to what? [$dflt]"
796$echo $n "$rp $c"
797. myread
798voidflags="$ans"
799$rm -f try.* .out
800
36ce8bec 801: see what type of char stdio uses.
802echo " "
803if $contains 'unsigned.*char.*_ptr;' /usr/include/stdio.h >/dev/null 2>&1 ; then
804 echo "Your stdio uses unsigned chars."
805 stdchar="unsigned char"
806else
807 echo "Your stdio uses signed chars."
808 stdchar="char"
809fi
810
8d063cd8 811: preserve RCS keywords in files with variable substitution, grrr
812Log='$Log'
813Header='$Header'
814
815: set up shell script to do ~ expansion
816cat >filexp <<EOSS
817$startsh
818: expand filename
819case "\$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 ;;
848esac
849EOSS
850chmod 755 filexp
851$eunicefix filexp
852
853: determine where public executables go
854case "$bin" in
855'')
856 dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
857 ;;
858*) dflt="$bin"
859 ;;
860esac
861cont=true
862while $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
881done
882
883: determine where manual pages go
884case "$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 ;;
890esac
891cont=true
892while $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
910done
911case "$mansrc" in
912*l)
913 manext=l
914 ;;
915*n)
916 manext=n
917 ;;
918*)
919 manext=1
920 ;;
921esac
922
8d063cd8 923: get C preprocessor symbols handy
924echo " "
36ce8bec 925echo $attrlist | $tr '[ - ]' '[\012-\012]' >Cppsym.know
8d063cd8 926$cat <<EOSS >Cppsym
927$startsh
928case "\$1" in
929-l) list=true
930 shift
931 ;;
932esac
933unknown=''
934case "\$list\$#" in
9351|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 ;;
948esac
949case \$# in
9500) exit 1;;
951esac
36ce8bec 952echo \$* | $tr '[ - ]' '[\012-\012]' | $sed -e 's/\(.*\)/\\
8d063cd8 953#ifdef \1\\
954exit 0; _ _ _ _\1\\ \1\\
955#endif\\
956/' >/tmp/Cppsym\$\$
957echo exit 1 >>/tmp/Cppsym\$\$
36ce8bec 958$cpp $cppminus </tmp/Cppsym\$\$ >/tmp/Cppsym2\$\$
8d063cd8 959case "\$list" in
960true) awk '\$6 != "" {print substr(\$6,2,100)}' </tmp/Cppsym2\$\$ ;;
961*)
962 sh /tmp/Cppsym2\$\$
963 status=\$?
964 ;;
965esac
966$rm -f /tmp/Cppsym\$\$ /tmp/Cppsym2\$\$
967exit \$status
968EOSS
969chmod 755 Cppsym
970$eunicefix Cppsym
971echo "Your C preprocessor defines the following symbols:"
972Cppsym -l $attrlist >Cppsym.true
973cat Cppsym.true
974rmlist="$rmlist Cppsym Cppsym.know Cppsym.true"
975
976: see what memory models we can support
977case "$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" ;;
1003esac
1004$cat <<EOM
1005
1006Some systems have different model sizes. On most systems they are called
1007small, medium, large, and huge. On the PDP11 they are called unsplit and
1008split. If your system doesn't support different memory models, say "none".
1009If you wish to force everything to one memory model, say "none" here and
1010put the appropriate flags later when it asks you for other cc and ld flags.
1011Venix 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
1014EOM
1015rp="Which models are supported? [$dflt]"
1016$echo $n "$rp $c"
1017. myread
1018models="$ans"
1019
1020case "$models" in
1021none)
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 ;;
1119esac
1120
1121case "$ccflags" in
1122'') dflt='none';;
1123*) dflt="$ccflags";;
1124esac
1125echo " "
1126rp="Any additional cc flags? [$dflt]"
1127$echo $n "$rp $c"
1128. myread
1129case "$ans" in
1130none) ans='';
1131esac
1132ccflags="$ans"
1133
1134case "$ldflags" in
1135'') if venix; then
1136 dflt='-i -z'
1137 else
1138 dflt='none'
1139 fi
1140 ;;
1141*) dflt="$ldflags";;
1142esac
1143echo " "
1144rp="Any additional ld flags? [$dflt]"
1145$echo $n "$rp $c"
1146. myread
1147case "$ans" in
1148none) ans='';
1149esac
1150ldflags="$ans"
1151
1152: see if we need a special compiler
1153echo " "
1154if 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
1180On some systems the default C compiler will not resolve multiple global
1181references 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
1183a "cc -M" command is required. (Note that the -M flag on other systems
1184indicates a memory model to use!) What command will force resolution on
1185EOM
1186 $echo $n "this system? [$dflt] $c"
1187 rp="Command to resolve multiple refs? [$dflt]"
1188 . myread
1189 cc="$ans"
1190else
1191 echo "Not a USG system--assuming cc can resolve multiple definitions."
1192 cc=cc
1193fi
1194
1195: see if we should include -lnm
1196echo " "
1197if $test -r /usr/lib/libnm.a || $test -r /usr/local/lib/libnm.a ; then
1198 echo "New math library found."
1199 libnm='-lnm'
1200else
36ce8bec 1201 ans=`loc libnm.a x $libpth`
8d063cd8 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
1212fi
1213
1214echo " "
1215echo "End of configuration questions."
1216echo " "
1217
1218: create config.sh file
1219echo " "
1220if test -d ../UU; then
1221 cd ..
1222fi
1223echo "Creating config.sh..."
1224$spitshell <<EOT >config.sh
1225$startsh
1226# config.sh
1227# This file was produced by running the Configure script.
1228
1229d_eunice='$d_eunice'
1230eunicefix='$eunicefix'
1231define='$define'
1232loclist='$loclist'
1233expr='$expr'
1234sed='$sed'
1235echo='$echo'
1236cat='$cat'
1237rm='$rm'
1238mv='$mv'
1239cp='$cp'
1240tail='$tail'
1241tr='$tr'
1242mkdir='$mkdir'
1243sort='$sort'
1244uniq='$uniq'
1245grep='$grep'
1246trylist='$trylist'
1247test='$test'
1248inews='$inews'
1249egrep='$egrep'
1250more='$more'
1251pg='$pg'
1252Mcc='$Mcc'
1253vi='$vi'
1254mailx='$mailx'
1255mail='$mail'
1256Log='$Log'
1257Header='$Header'
1258bin='$bin'
1259cc='$cc'
1260contains='$contains'
1261cpp='$cpp'
36ce8bec 1262cppminus='$cppminus'
8d063cd8 1263d_charsprf='$d_charsprf'
1264d_index='$d_index'
36ce8bec 1265d_stdstdio='$d_stdstdio'
8d063cd8 1266d_strctcpy='$d_strctcpy'
1267d_vfork='$d_vfork'
36ce8bec 1268d_voidsig='$d_voidsig'
8d063cd8 1269libc='$libc'
1270libnm='$libnm'
1271mansrc='$mansrc'
1272manext='$manext'
1273models='$models'
1274split='$split'
1275small='$small'
1276medium='$medium'
1277large='$large'
1278huge='$huge'
1279ccflags='$ccflags'
1280ldflags='$ldflags'
1281n='$n'
1282c='$c'
1283package='$package'
1284spitshell='$spitshell'
1285shsharp='$shsharp'
1286sharpbang='$sharpbang'
1287startsh='$startsh'
36ce8bec 1288stdchar='$stdchar'
8d063cd8 1289voidflags='$voidflags'
1290defvoidused='$defvoidused'
1291CONFIG=true
1292EOT
1293
1294CONFIG=true
1295
1296echo " "
1297dflt=''
1298echo "If you didn't make any mistakes, then just type a carriage return here."
1299rp="If you need to edit config.sh, do it as a shell escape here:"
1300$echo $n "$rp $c"
1301. UU/myread
1302case "$ans" in
1303'') ;;
1304*) : in case they cannot read
1305 eval $ans;;
1306esac
1307
1308echo " "
1309echo "Doing variable substitutions on .SH files..."
36ce8bec 1310set x `$grep '\.SH' <MANIFEST | awk '{print $1}'`
1311shift
1312case $# in
13130) set x *.SH; shift;;
1314esac
1315if test ! -f $1; then
1316 shift
1317fi
8d063cd8 1318for 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
1329done
1330if 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
1335fi
1336
1337if $contains '^depend:' Makefile >/dev/null 2>&1; then
1338 dflt=n
1339 $cat <<EOM
1340
1341Now you need to generate make dependencies by running "make depend".
1342You might prefer to run it in background: "make depend > makedepend.out &"
1343It can take a while, so you might not want to run it right now.
1344
1345EOM
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
1356elif test -f Makefile; then
1357 echo " "
1358 echo "Now you must run a make."
1359else
1360 echo "Done."
1361fi
1362
1363$rm -f kit*isdone
1364cd UU && $rm -f $rmlist
1365: end of Configure