home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / games / patch / config.ure < prev    next >
Encoding:
Text File  |  1988-06-05  |  30.2 KB  |  1,420 lines

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