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.
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.)
11 # $Header: Configure,v 1.0 87/12/18 15:05:56 root Exp $
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.)
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 $$)
22 echo "Say 'sh Configure', not 'sh <Configure'"
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.)"
30 if test ! -d ../UU; then
101 echo "Beginning of configuration questions for $package kit."
102 : Eunice requires " " instead of "", can you believe it
107 libpth='/usr/lib /usr/local/lib /lib'
108 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
109 rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
110 trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
111 attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
112 attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
113 attrlist="$attrlist ns32000 ns16000 iAPX286"
114 pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib"
117 : some greps do not return status, grrr.
118 echo "grimblepritz" >grimble
119 if grep blurfldyick grimble >/dev/null 2>&1 ; then
121 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
127 : the following should work in any shell
131 echo "AGH! Grep doesn't return a status. Attempting remedial action."
132 cat >contains <<'EOSS'
133 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
138 : first determine how to suppress newline on echo command
139 echo "Checking echo to see how to suppress newlines..."
140 (echo "hi there\c" ; echo " ") >.echotmp
141 if $contains c .echotmp >/dev/null 2>&1 ; then
152 echo $n "Type carriage return to continue. Your cursor should be here-->$c"
156 : now set up to do reads with possible shell escape and default assignment
159 while expr "X\$ans" : "X!" >/dev/null; do
168 set \`expr "X\$ans" : "X!\(.*\)\$"\`
181 : general instructions
184 This installation shell script will examine your system and ask you questions
185 to determine how the $package package should be installed. If you get stuck
186 on a question, you may use a ! shell escape to start a subshell or execute
187 a command. Many of the questions will have default answers in square
188 brackets--typing carriage return will give you the default.
190 On some of the questions which ask for file or directory names you are
191 allowed to use the ~name construct to specify the login directory belonging
192 to "name", even if you don't have a shell which knows about that. Questions
193 where this is allowed will be marked "(~name ok)".
196 rp="[Type carriage return to continue]"
201 Much effort has been expended to ensure that this shell script will run
202 on any Unix system. If despite that it blows up on you, your best bet is
203 to edit Configure and run it again. Also, let me (lwall@sdcrdcf.UUCP) know
204 how I blew it. If you can't run Configure for some reason, you'll have
205 to generate a config.sh file by hand.
207 This installation script affects things in two ways: 1) it may do direct
208 variable substitutions on some of the files included in this kit, and
209 2) it builds a config.h file for inclusion in C programs. You may edit
210 any of these files as the need arises after running this script.
212 If you make a mistake on a question, there is no easy way to back up to it
213 currently. The easiest thing to do is to edit config.sh and rerun all the
214 SH files. Configure will offer to let you do this before it runs the SH files.
217 rp="[Type carriage return to continue]"
221 : get old answers, if there is a config file out there
222 if test -f ../config.sh; then
225 rp="I see a config.sh file. Did Configure make it on THIS system? [$dflt]"
229 n*) echo "OK, I'll ignore it.";;
230 *) echo "Fetching default answers from your old config.sh file..."
240 : find out where common programs are
242 echo "Locating common programs..."
255 if test -d \$dir/\$thing; then
261 if test -f \$dir/\$thing; then
292 for file in $loclist; do
293 xxx=`loc $file $file $pth`
298 echo $file is in $xxx.
301 echo "I don't know where $file is. I hope it's in everyone's PATH."
306 echo "Don't worry if any of the following aren't found..."
308 for file in $trylist; do
309 xxx=`loc $file $file $pth`
314 echo $file is in $xxx.
317 echo "I don't see $file out there, $ans."
324 echo "Substituting grep for egrep."
330 echo "Hopefully test is built into your sh."
335 rp="Is your "'"'"test"'"'" built into sh? [$dflt] (OK to guess)"
348 echo "Hopefully echo is built into your sh."
352 echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
353 $echo $n "hi there$c" >foo1
354 echo $n "hi there$c" >foo2
355 if cmp foo1 foo2 >/dev/null 2>&1; then
356 echo "They are compatible. In fact, they may be identical."
359 '-n') n='' c='\c' ans='\c' ;;
360 *) n='-n' c='' ans='-n' ;;
363 They are not compatible! You are probably running ksh on a non-USG system.
364 I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
365 have echo built in and we may have to run some Bourne shell scripts. That
366 means I'll have to use $ans to suppress newlines now. Life is ridiculous.
369 rp="Your cursor should be here-->"
382 : get list of predefined functions in a handy place
384 if test -f /lib/libc.a; then
385 echo "Your C library is in /lib/libc.a. You're normal."
388 ans=`loc libc.a blurfl/dyick $libpth`
389 if test -f $ans; then
390 echo "Your C library is in $ans, of all places."
393 if test -f "$libc"; then
394 echo "Your C library is in $libc, like you said before."
398 I can't seem to find your C library. I've looked in the following places:
402 None of these seems to contain your C library. What is the full name
405 $echo $n "of your C library? $c"
406 rp='C library full name?'
413 $echo $n "Extracting names from $libc for later perusal...$c"
414 if ar t $libc > libc.list; then
418 echo "The archiver doesn't think $libc is a reasonable library."
419 echo "Trying nm instead..."
420 if nm -g $libc > libc.list; then
421 echo "Done. Maybe this is Unicos, or an Apollo?"
423 echo "That didn't work either. Giving up."
427 rmlist="$rmlist libc.list"
429 : make some quick guesses about what we are up against
432 if $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then
433 echo "Looks kind of like a BSD system, but we'll see..."
437 elif $contains fcntl libc.list >/dev/null 2>&1 ; then
438 echo "Looks kind of like a USG system, but we'll see..."
443 echo "Looks kind of like a version 7 system, but we'll see..."
448 if $contains vmssystem libc.list >/dev/null 2>&1 ; then
450 There is, however, a strange, musty smell in the air that reminds me of
451 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
453 echo "exit 0" >eunice
456 : it so happens the Eunice I know will not run shell scripts in Unix format
459 echo "Congratulations. You aren't running Eunice."
462 echo "exit 1" >eunice
464 if test -f /xenix; then
465 echo "Actually, this looks more like a XENIX system..."
469 echo "It's not Xenix..."
473 if test -f /venix; then
474 echo "Actually, this looks more like a VENIX system..."
481 echo "Nor is it Venix..."
485 chmod 755 bsd usg v7 eunice venix xenix
486 $eunicefix bsd usg v7 eunice venix xenix
487 rmlist="$rmlist bsd usg v7 eunice venix xenix"
489 : see if sh knows # comments
491 echo "Checking your sh to see if it knows about # comments..."
492 if sh -c '#' >/dev/null 2>&1 ; then
493 echo "Your sh handles # comments correctly."
497 echo "Okay, let's see if #! works on this system..."
498 echo "#!/bin/echo hi" > try
502 if test -s today; then
506 echo "#! /bin/echo hi" > try
510 if test -s today; then
519 echo "Your sh doesn't grok # comments--I will strip them later on."
521 echo "exec grep -v '^#'" >spitshell
524 spitshell=`pwd`/spitshell
525 echo "I presume that if # doesn't work, #! won't work either!"
529 : figure out how to guarantee sh startup
531 echo "Checking out how to guarantee sh startup..."
532 startsh=$sharpbang'/bin/sh'
533 echo "Let's see if '$startsh' works..."
545 echo "Nope. You may have to fix up the shell scripts to make sure sh runs them."
549 : see if sprintf is declared as int or pointer to char
551 if $contains 'char.*sprintf' /usr/include/stdio.h >/dev/null 2>&1 ; then
552 echo "Your sprintf() returns (char*)."
555 echo "Your sprintf() returns (int)."
562 if $contains index libc.list >/dev/null 2>&1 ; then
563 echo "Your system appears to use index() and rindex() rather than strchr()"
564 $echo $n "and strrchr(). Is this correct? [$dflt] $c"
565 rp='index() rather than strchr()? [$dflt]'
568 n*|f*) d_index="$define" ;;
569 *) d_index="$undef" ;;
572 echo "Your system appears to use strchr() and strrchr() rather than index()"
573 $echo $n "and rindex(). Is this correct? [$dflt] $c"
574 rp='strchr() rather than index()? [$dflt]'
577 n*|f*) d_index="$undef" ;;
578 *) d_index="$define" ;;
582 : check for structure copying
584 echo "Checking to see if your C compiler can copy structs..."
595 if cc -c try.c >/dev/null 2>&1 ; then
600 echo "Nope, it can't."
604 : see if there is a vfork
606 if $contains vfork libc.list >/dev/null 2>&1 ; then
607 echo "vfork() found."
610 echo "No vfork() found--will use fork() instead."
614 : check for void type
617 Checking to see how well your C compiler groks the void type...
619 Support flag bits are:
620 1: basic void declarations.
621 2: arrays of pointers to functions returning void.
622 4: operations between pointers to and addresses of void functions.
647 if cc -S -DTRY=7 try.c >.out 2>&1 ; then
649 echo "It appears to support void fully."
650 if $contains warning .out >/dev/null 2>&1; then
651 echo "However, you might get some warnings that look like this:"
655 echo "Hmm, you compiler has some difficulty with void. Checking further..."
656 if cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
657 echo "It supports 1..."
658 if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
660 echo "And it supports 2 but not 4."
662 echo "It doesn't support 2..."
663 if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
665 echo "But it supports 4."
668 echo "And it doesn't support 4."
672 echo "There is no support at all for void."
678 rp="Your void support flags add up to what? [$dflt]"
684 : preserve RCS keywords in files with variable substitution, grrr
688 : set up shell script to do ~ expansion
694 echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
697 if $test -f /bin/csh; then
698 /bin/csh -f -c "glob \$1"
701 name=\`$expr x\$1 : '..\([^/]*\)'\`
702 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
703 if $test ! -d "\$dir"; then
705 echo "\$me: can't locate home directory for: \$name" >&2
710 echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
726 : determine where public executables go
729 dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
735 while $test "$cont" ; do
737 rp="Where do you want to put the public executables? [$dflt]"
742 if test -d $bin; then
746 rp="Directory $bin doesn't exist. Use that name anyway? [$dflt]"
756 : determine where manual pages go
759 dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
765 while $test "$cont" ; do
767 rp="Where do the manual pages (source) go? [$dflt]"
770 mansrc=`filexp "$ans"`
771 if test -d $mansrc; then
775 rp="Directory $mansrc doesn't exist. Use that name anyway? [$dflt]"
796 : see how we invoke the C preprocessor
798 echo "Checking to see how your C preprocessor is invoked..."
799 cat <<'EOT' >testcpp.c
804 echo 'Maybe "cc -E" will work...'
805 cc -E testcpp.c >testcpp.out 2>&1
806 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
810 echo 'Nope...maybe "cc -P" will work...'
811 cc -P testcpp.c >testcpp.out 2>&1
812 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
813 echo "Yup, that does."
816 echo 'Nixed again...maybe "/lib/cpp" will work...'
817 /lib/cpp testcpp.c >testcpp.out 2>&1
818 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
819 echo "Hooray, it works! I was beginning to wonder."
822 echo 'Hmm...maybe you already told me...'
825 *) $cpp testcpp.c >testcpp.out 2>&1;;
827 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
828 echo "Hooray, you did! I was beginning to wonder."
831 $echo $n "Nope. I can't find a C preprocessor. Name one: $c"
832 rp='Name a C preprocessor:'
835 $cpp testcpp.c >testcpp.out 2>&1
836 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
837 echo "OK, that will do."
839 echo "Sorry, I can't get that to work. Go find one."
846 rm -f testcpp.c testcpp.out
848 : get C preprocessor symbols handy
850 echo $attrlist | $tr '[ ]' '[\012]' >Cppsym.know
862 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
864 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
867 unknown="\$unknown \$sym"
877 echo \$* | $tr '[ ]' '[\012]' | $sed -e 's/\(.*\)/\\
879 exit 0; _ _ _ _\1\\ \1\\
882 echo exit 1 >>/tmp/Cppsym\$\$
883 $cpp /tmp/Cppsym\$\$ >/tmp/Cppsym2\$\$
885 true) awk '\$6 != "" {print substr(\$6,2,100)}' </tmp/Cppsym2\$\$ ;;
891 $rm -f /tmp/Cppsym\$\$ /tmp/Cppsym2\$\$
896 echo "Your C preprocessor defines the following symbols:"
897 Cppsym -l $attrlist >Cppsym.true
899 rmlist="$rmlist Cppsym Cppsym.know Cppsym.true"
901 : see what memory models we can support
904 if Cppsym pdp11; then
907 ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
910 *) if $test -d /lib/small || $test -d /usr/lib/small; then
915 if $test -d /lib/medium || $test -d /usr/lib/medium; then
918 if $test -d /lib/large || $test -d /usr/lib/large; then
921 if $test -d /lib/huge || $test -d /usr/lib/huge; then
931 Some systems have different model sizes. On most systems they are called
932 small, medium, large, and huge. On the PDP11 they are called unsplit and
933 split. If your system doesn't support different memory models, say "none".
934 If you wish to force everything to one memory model, say "none" here and
935 put the appropriate flags later when it asks you for other cc and ld flags.
936 Venix systems may wish to put "none" and let the compiler figure things out.
937 (In the following question multiple model names should be space separated.)
940 rp="Which models are supported? [$dflt]"
957 if $contains '-i' $mansrc/ld.1 >/dev/null 2>&1 || \
958 $contains '-i' $mansrc/cc.1 >/dev/null 2>&1; then
966 rp="What flag indicates separate I and D space? [$dflt]"
975 *large*|*small*|*medium*|*huge*)
982 rp="What flag indicates large model? [$dflt]"
998 rp="What flag indicates huge model? [$dflt]"
1014 rp="What flag indicates medium model? [$dflt]"
1022 *) medium="$large";;
1030 rp="What flag indicates small model? [$dflt]"
1042 echo "Unrecognized memory models--you may have to edit Makefile.SH"
1048 *) dflt="$ccflags";;
1051 rp="Any additional cc flags? [$dflt]"
1066 *) dflt="$ldflags";;
1069 rp="Any additional ld flags? [$dflt]"
1077 : see if we need a special compiler
1091 if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
1105 On some systems the default C compiler will not resolve multiple global
1106 references that happen to have the same name. On some such systems the
1107 "Mcc" command may be used to force these to be resolved. On other systems
1108 a "cc -M" command is required. (Note that the -M flag on other systems
1109 indicates a memory model to use!) What command will force resolution on
1111 $echo $n "this system? [$dflt] $c"
1112 rp="Command to resolve multiple refs? [$dflt]"
1116 echo "Not a USG system--assuming cc can resolve multiple definitions."
1120 : see if we should include -lnm
1122 if $test -r /usr/lib/libnm.a || $test -r /usr/local/lib/libnm.a ; then
1123 echo "New math library found."
1126 ans=`loc libtermlib.a x $libpth`
1129 echo "No nm library found--the normal math library will have to do."
1133 echo "New math library found in $ans."
1140 echo "End of configuration questions."
1143 : create config.sh file
1145 if test -d ../UU; then
1148 echo "Creating config.sh..."
1149 $spitshell <<EOT >config.sh
1152 # This file was produced by running the Configure script.
1154 d_eunice='$d_eunice'
1155 eunicefix='$eunicefix'
1185 contains='$contains'
1187 d_charsprf='$d_charsprf'
1189 d_strctcpy='$d_strctcpy'
1206 spitshell='$spitshell'
1208 sharpbang='$sharpbang'
1210 voidflags='$voidflags'
1211 defvoidused='$defvoidused'
1219 echo "If you didn't make any mistakes, then just type a carriage return here."
1220 rp="If you need to edit config.sh, do it as a shell escape here:"
1225 *) : in case they cannot read
1230 echo "Doing variable substitutions on .SH files..."
1231 set `$grep '\.SH' <MANIFEST | awk '{print $1}'`
1235 dir=`$expr X$file : 'X\(.*\)/'`
1236 file=`$expr X$file : 'X.*/\(.*\)'`
1237 (cd $dir && . $file)
1244 if test -f config.h.SH; then
1245 if test ! -f config.h; then
1246 : oops, they left it out of MANIFEST, probably, so do it anyway.
1251 if $contains '^depend:' Makefile >/dev/null 2>&1; then
1255 Now you need to generate make dependencies by running "make depend".
1256 You might prefer to run it in background: "make depend > makedepend.out &"
1257 It can take a while, so you might not want to run it right now.
1260 rp="Run make depend now? [$dflt]"
1265 echo "Now you must run a make."
1267 *) echo "You must run 'make depend' then 'make'."
1270 elif test -f Makefile; then
1272 echo "Now you must run a make."
1278 cd UU && $rm -f $rmlist