home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1344 / Configure
Text File  |  1990-12-28  |  34KB  |  1,600 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: Head.U,v 2.0 88/06/28 23:13: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:/usr/new:/usr/new/bin:/usr/nbin'
  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. :
  38. : Loop through all commandline parameters
  39. :
  40.  
  41. while test $# != 0 ; do
  42.     case "$1" in
  43.     -d) shift; fastread='yes';;
  44.     -f) shift; f_flag='yes' ;;
  45.     *) echo "Warning : I don't understand parameter \"$1\"."; shift;;
  46.     esac
  47. done
  48. d_eunice=''
  49. eunicefix=''
  50. loclist=''
  51. expr=''
  52. sed=''
  53. echo=''
  54. cat=''
  55. rm=''
  56. mv=''
  57. cp=''
  58. tail=''
  59. tr=''
  60. mkdir=''
  61. sort=''
  62. uniq=''
  63. grep=''
  64. trylist=''
  65. test=''
  66. inews=''
  67. egrep=''
  68. more=''
  69. pg=''
  70. Mcc=''
  71. vi=''
  72. mailx=''
  73. mail=''
  74. cpp=''
  75. perl=''
  76. contains=''
  77. d_bcopy=''
  78. d_charsprf=''
  79. d_index=''
  80. d_memcpy=''
  81. libc=''
  82. mansrc=''
  83. manext=''
  84. models=''
  85. split=''
  86. small=''
  87. medium=''
  88. large=''
  89. huge=''
  90. ccflags=''
  91. ldflags=''
  92. cc=''
  93. n=''
  94. c=''
  95. package=''
  96. spitshell=''
  97. shsharp=''
  98. sharpbang=''
  99. startsh=''
  100. define=''
  101. cppstdin=''
  102. cppminus=''
  103. d_intfree=''
  104. d_reread=''
  105. d_termio=''
  106. systermio=''
  107. look4char=''
  108. use_select=''
  109. use_rdchk=''
  110. use_fionread=''
  111. wait4char=''
  112. CONFIG=''
  113. : set package name
  114. package=KEF
  115.  
  116. echo " "
  117. echo "Beginning of configuration questions for $package kit."
  118. : Eunice requires " " instead of "", can you believe it
  119. echo " "
  120.  
  121. define='define'
  122. undef='undef'
  123. libpth='/usr/lib /usr/local/lib /lib'
  124. smallmach='pdp11 i8086 z8000 i80286 iAPX286'
  125. rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
  126. trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
  127.  
  128. : We must find out about Eunice early
  129. eunicefix=':'
  130. if test -f /etc/unixtovms; then
  131.     eunicefix=/etc/unixtovms
  132. fi
  133. if test -f /etc/unixtovms.exe; then
  134.     eunicefix=/etc/unixtovms.exe
  135. fi
  136.  
  137. : Now test for existence of everything in MANIFEST
  138.  
  139. if test "X$f_flag" = "X" ; then
  140.     echo "First let's make sure your kit is complete.  Checking..."
  141.     : mg : original test does not work for NFS
  142.     current=`pwd`
  143.     cd ..
  144.     missing=""
  145.     for i in `awk 'NR>2{print $1}' MANIFEST` ; do
  146.         if test ! \( -f $i -o -d $i \) ; then
  147.             missing="$missing $i"
  148.         fi
  149.     done
  150.     if test "X$missing" != "X" ; then
  151.         echo "The following files are missing : $missing"
  152.         exit 1
  153.     fi
  154.     echo " "
  155.     cd $current
  156. fi
  157. attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
  158. attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
  159. attrlist="$attrlist hpux hp9000s300 hp9000s500 hp9000s800"
  160. attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
  161. attrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
  162. attrlist="$attrlist $mc68k __STDC__ UTS M_I8086 M_I186 M_I286 M_I386"
  163. pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /lib /usr/local/lib"
  164. d_newshome="/usr/NeWS"
  165. defvoidused=7
  166.  
  167. : some greps do not return status, grrr.
  168. echo "grimblepritz" >grimble
  169. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  170.     contains=contains
  171. elif grep grimblepritz grimble >/dev/null 2>&1 ; then
  172.     contains=grep
  173. else
  174.     contains=contains
  175. fi
  176. rm -f grimble
  177. : the following should work in any shell
  178. case "$contains" in
  179. contains*)
  180.     echo " "
  181.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  182.     cat >contains <<'EOSS'
  183. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  184. EOSS
  185. chmod +x contains
  186. esac
  187.  
  188. : first determine how to suppress newline on echo command
  189. echo "Checking echo to see how to suppress newlines..."
  190. (echo "hi there\c" ; echo " ") >.echotmp
  191. if $contains c .echotmp >/dev/null 2>&1 ; then
  192.     echo "...using -n."
  193.     n='-n'
  194.     c=''
  195. else
  196.     cat <<'EOM'
  197. ...using \c
  198. EOM
  199.     n=''
  200.     c='\c'
  201. fi
  202. echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
  203. read ans
  204. rm -f .echotmp
  205.  
  206. : now set up to do reads with possible shell escape and default assignment
  207. cat <<EOSC >myread
  208. case "\$fastread" in
  209. yes) ans=''; echo " " ;;
  210. *) ans='!';;
  211. esac
  212. while expr "X\$ans" : "X!" >/dev/null; do
  213.     read ans
  214.     case "\$ans" in
  215.     !)
  216.     sh
  217.     echo " "
  218.     echo $n "\$rp $c"
  219.     ;;
  220.     !*)
  221.     set \`expr "X\$ans" : "X!\(.*\)\$"\`
  222.     sh -c "\$*"
  223.     echo " "
  224.     echo $n "\$rp $c"
  225.     ;;
  226.     esac
  227. done
  228. rp='Your answer:'
  229. case "\$ans" in
  230. '') ans="\$dflt";;
  231. esac
  232. EOSC
  233.  
  234. : general instructions
  235. cat <<EOH
  236.  
  237. This installation shell script will examine your system and ask you questions
  238. to determine how the $package package should be installed.  If you get stuck
  239. on a question, you may use a ! shell escape to start a subshell or execute
  240. a command.  Many of the questions will have default answers in square
  241. brackets--typing carriage return will give you the default.
  242.  
  243. On some of the questions which ask for file or directory names you are
  244. allowed to use the ~name construct to specify the login directory belonging
  245. to "name", even if you don't have a shell which knows about that.  Questions
  246. where this is allowed will be marked "(~name ok)".
  247.  
  248. EOH
  249. rp="[Type carriage return to continue]"
  250. echo $n "$rp $c"
  251. . myread
  252. cat <<EOH
  253.  
  254. Much effort has been expended to ensure that this shell script will run
  255. on any Unix system.  If despite that it blows up on you, your best bet is
  256. to edit Configure and run it again. Also, let me (greim@cs.uni-sb.de)
  257. know how I blew it.  This script was generated by "metaconfig" written by
  258. Larry Wall (lwall@jpl-devvax.jpl.nasa.gov), but any errors are probably
  259. mine, not his.  If you can't run Configure for some reason, you'll have
  260. to generate a config.sh file by hand.
  261.  
  262. This installation script affects things in two ways: 1) it may do direct
  263. variable substitutions on some of the files included in this kit, and
  264. 2) it builds a config.h file for inclusion in C programs.  You may edit
  265. any of these files as the need arises after running this script.
  266.  
  267. If you make a mistake on a question, there is no easy way to back up to it
  268. currently.  The easiest thing to do is to edit config.sh and rerun all the
  269. SH files.  Configure will offer to let you do this before it runs the SH files.
  270.  
  271. EOH
  272. rp="[Type carriage return to continue]"
  273. echo $n "$rp $c"
  274. . myread
  275.  
  276. : get old answers, if there is a config file out there
  277. if test -f ../config.sh; then
  278.     echo " "
  279.     dflt=y
  280.     rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
  281.     echo $n "$rp $c"
  282.     . myread
  283.     case "$ans" in
  284.     n*) echo "OK, I'll ignore it.";;
  285.     *)  echo "Fetching default answers from your old config.sh file..."
  286.     tmp="$n"
  287.     ans="$c"
  288.         . ../config.sh
  289.     n="$tmp"
  290.     c="$ans"
  291.     ;;
  292.     esac
  293. fi
  294.  
  295. : find out where common programs are
  296. echo " "
  297. echo "Locating common programs..."
  298. cat <<EOSC >loc
  299. $startsh
  300. case \$# in
  301. 0) exit 1;;
  302. esac
  303. thing=\$1
  304. shift
  305. dflt=\$1
  306. shift
  307. for dir in \$*; do
  308.     case "\$thing" in
  309.     .)
  310.     if test -d \$dir/\$thing; then
  311.         echo \$dir
  312.         exit 0
  313.     fi
  314.     ;;
  315.     *)
  316.     if test -f \$dir/\$thing; then
  317.         echo \$dir/\$thing
  318.         exit 0
  319.     elif test -f \$dir/\$thing.exe; then
  320.         : on Eunice apparently
  321.         echo \$dir/\$thing
  322.         exit 0
  323.     fi
  324.     ;;
  325.     esac
  326. done
  327. echo \$dflt
  328. exit 1
  329. EOSC
  330. chmod +x loc
  331. $eunicefix loc
  332. loclist="
  333. expr
  334. sed
  335. echo
  336. cat
  337. rm
  338. tr
  339. grep
  340. "
  341. trylist="
  342. test
  343. Mcc
  344. cpp
  345. "
  346. for file in $loclist; do
  347.     xxx=`loc $file $file $pth`
  348.     eval $file=$xxx
  349.     eval _$file=$xxx
  350.     case "$xxx" in
  351.     /*)
  352.     echo $file is in $xxx.
  353.     ;;
  354.     *)
  355.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  356.     ;;
  357.     esac
  358. done
  359. echo " "
  360. echo "Don't worry if any of the following aren't found..."
  361. ans=offhand
  362. for file in $trylist; do
  363.     xxx=`loc $file $file $pth`
  364.     eval $file=$xxx
  365.     eval _$file=$xxx
  366.     case "$xxx" in
  367.     /*)
  368.     echo $file is in $xxx.
  369.     ;;
  370.     *)
  371.     echo "I don't see $file out there, $ans."
  372.     ans=either
  373.     ;;
  374.     esac
  375. done
  376. case "$egrep" in
  377. egrep)
  378.     echo "Substituting grep for egrep."
  379.     egrep=$grep
  380.     ;;
  381. esac
  382. case "$test" in
  383. test)
  384.     echo "Hopefully test is built into your sh."
  385.     ;;
  386. /bin/test)
  387.     if sh -c "PATH= test true" >/dev/null 2>&1; then
  388.     echo "Using the test built into your sh."
  389.     test=test
  390.     fi
  391.     ;;
  392. *)
  393.     test=test
  394.     ;;
  395. esac
  396. case "$echo" in
  397. echo)
  398.     echo "Hopefully echo is built into your sh."
  399.     ;;
  400. /bin/echo)
  401.     echo " "
  402.     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  403.     $echo $n "hi there$c" >foo1
  404.     echo $n "hi there$c" >foo2
  405.     if cmp foo1 foo2 >/dev/null 2>&1; then
  406.     echo "They are compatible.  In fact, they may be identical."
  407.     else
  408.     case "$n" in
  409.     '-n') n='' c='\c' ans='\c' ;;
  410.     *) n='-n' c='' ans='-n' ;;
  411.     esac
  412.     cat <<FOO
  413. They are not compatible!  You are probably running ksh on a non-USG system.
  414. I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
  415. have echo built in and we may have to run some Bourne shell scripts.  That
  416. means I'll have to use $ans to suppress newlines now.  Life is ridiculous.
  417.  
  418. FOO
  419.     rp="Your cursor should be here-->"
  420.     $echo $n "$rp$c"
  421.     . myread
  422.     fi
  423.     $rm -f foo1 foo2
  424.     ;;
  425. *)
  426.     : cross your fingers
  427.     echo=echo
  428.     ;;
  429. esac
  430. rmlist="$rmlist loc"
  431.  
  432. : get list of predefined functions in a handy place
  433. echo " "
  434. if test -f /lib/libc.a; then
  435.     echo "Your C library is in /lib/libc.a.  You're normal."
  436.     libc=/lib/libc.a
  437. else
  438.     ans=`loc libc.a blurfl/dyick $libpth`
  439.     if test ! -f $ans; then
  440.     ans=`loc clib blurfl/dyick $libpth`
  441.     fi
  442.     if test ! -f $ans; then
  443.     ans=`loc libc blurfl/dyick $libpth`
  444.     fi
  445.     if test -f $ans; then
  446.     echo "Your C library is in $ans, of all places."
  447.     libc=$ans
  448.     else
  449.     if test -f "$libc"; then
  450.         echo "Your C library is in $libc, like you said before."
  451.     else
  452.         cat <<EOM
  453.  
  454. I can't seem to find your C library.  I've looked in the following places:
  455.  
  456.     $libpth
  457.  
  458. None of these seems to contain your C library.  What is the full name
  459. EOM
  460.         dflt=None
  461.         $echo $n "of your C library? $c"
  462.         rp='C library full name?'
  463.         . myread
  464.         libc="$ans"
  465.     fi
  466.     fi
  467. fi
  468. echo " "
  469. $echo $n "Extracting names from $libc for later perusal...$c"
  470. nm $libc 2>/dev/null >libc.tmp
  471. sed -n -e 's/^.* [AT] _//p' -e 's/^.* [AT] //p' <libc.tmp >libc.list
  472. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  473.     echo "done"
  474. else
  475.     sed -n -e 's/^.* D _//p' -e 's/^.* D //p' <libc.tmp >libc.list
  476.     $contains '^printf$' libc.list >/dev/null 2>&1 || \
  477.        sed -n -e 's/^_//' \
  478.           -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' <libc.tmp >libc.list
  479.     if $contains '^printf$' libc.list >/dev/null 2>&1; then
  480.     echo "done"
  481.     else
  482.     echo " "
  483.     echo "nm didn't seem to work right."
  484.     echo "Trying ar instead..."
  485.     if ar t $libc > libc.tmp; then
  486.         sed -e 's/\.o$//' < libc.tmp > libc.list
  487.         echo "Ok."
  488.     else
  489.         echo "ar didn't seem to work right."
  490.         echo "Maybe this is a Cray...trying bld instead..."
  491.         if bld t $libc | sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  492.         echo "Ok."
  493.         else
  494.             echo "That didn't work either.  Giving up."
  495.             exit 1
  496.         fi
  497.     fi
  498.     fi
  499. fi
  500. rmlist="$rmlist libc.tmp libc.list"
  501.  
  502. : make some quick guesses about what we are up against
  503. echo " "
  504. $echo $n "Hmm...  $c"
  505. if $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then
  506.     echo "Looks kind of like a BSD system, but we'll see..."
  507.     echo exit 0 >bsd
  508.     echo exit 1 >usg
  509.     echo exit 1 >v7
  510. elif $contains '^fcntl$' libc.list >/dev/null 2>&1 ; then
  511.     echo "Looks kind of like a USG system, but we'll see..."
  512.     echo exit 1 >bsd
  513.     echo exit 0 >usg
  514.     echo exit 1 >v7
  515. else
  516.     echo "Looks kind of like a version 7 system, but we'll see..."
  517.     echo exit 1 >bsd
  518.     echo exit 1 >usg
  519.     echo exit 0 >v7
  520. fi
  521. if $contains '^vmssystem$' libc.list >/dev/null 2>&1 ; then
  522.     cat <<'EOI'
  523. There is, however, a strange, musty smell in the air that reminds me of
  524. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  525. EOI
  526.     echo "exit 0" >eunice
  527.     eunicefix=unixtovms
  528.     d_eunice="$define"
  529. : it so happens the Eunice I know will not run shell scripts in Unix format
  530. else
  531.     echo " "
  532.     echo "Congratulations.  You aren't running Eunice."
  533.     eunicefix=':'
  534.     d_eunice="$undef"
  535.     echo "exit 1" >eunice
  536. fi
  537. if test -f /xenix; then
  538.     echo "Actually, this looks more like a XENIX system..."
  539.     echo "exit 0" >xenix
  540. else
  541.     echo " "
  542.     echo "It's not Xenix..."
  543.     echo "exit 1" >xenix
  544. fi
  545. chmod +x xenix
  546. $eunicefix xenix
  547. if test -f /venix; then
  548.     echo "Actually, this looks more like a VENIX system..."
  549.     echo "exit 0" >venix
  550. else
  551.     echo " "
  552.     if xenix; then
  553.     : null
  554.     else
  555.     echo "Nor is it Venix..."
  556.     fi
  557.     echo "exit 1" >venix
  558. fi
  559. chmod +x bsd usg v7 eunice venix
  560. $eunicefix bsd usg v7 eunice venix
  561. rmlist="$rmlist bsd usg v7 eunice venix xenix"
  562.  
  563. : see if sh knows # comments
  564. echo " "
  565. echo "Checking your sh to see if it knows about # comments..."
  566. if sh -c '#' >/dev/null 2>&1 ; then
  567.     echo "Your sh handles # comments correctly."
  568.     shsharp=true
  569.     spitshell=cat
  570.     echo " "
  571.     echo "Okay, let's see if #! works on this system..."
  572.     echo "#!/bin/echo hi" > try
  573.     $eunicefix try
  574.     chmod +x try
  575.     try > today
  576.     if $contains hi today >/dev/null 2>&1; then
  577.     echo "It does."
  578.     sharpbang='#!'
  579.     else
  580.     echo "#! /bin/echo hi" > try
  581.     $eunicefix try
  582.     chmod +x try
  583.     try > today
  584.     if test -s today; then
  585.         echo "It does."
  586.         sharpbang='#! '
  587.     else
  588.         echo "It doesn't."
  589.         sharpbang=': use '
  590.     fi
  591.     fi
  592. else
  593.     echo "Your sh doesn't grok # comments--I will strip them later on."
  594.     shsharp=false
  595.     echo "exec grep -v '^#'" >spitshell
  596.     chmod +x spitshell
  597.     $eunicefix spitshell
  598.     spitshell=`pwd`/spitshell
  599.     echo "I presume that if # doesn't work, #! won't work either!"
  600.     sharpbang=': use '
  601. fi
  602.  
  603. : figure out how to guarantee sh startup
  604. echo " "
  605. echo "Checking out how to guarantee sh startup..."
  606. startsh=$sharpbang'/bin/sh'
  607. echo "Let's see if '$startsh' works..."
  608. cat >try <<EOSS
  609. $startsh
  610. set abc
  611. test "$?abc" != 1
  612. EOSS
  613.  
  614. chmod +x try
  615. $eunicefix try
  616. if try; then
  617.     echo "Yup, it does."
  618. else
  619.     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  620. fi
  621. rm -f try today
  622.  
  623. : see if bcopy exists
  624. echo " "
  625. if $contains '^bcopy$' libc.list >/dev/null 2>&1; then
  626.     echo 'bcopy() found.'
  627.     d_bcopy="$define"
  628. else
  629.     echo 'bcopy() not found.'
  630.     d_bcopy="$undef"
  631. fi
  632.  
  633. : set up shell script to do ~ expansion
  634. cat >filexp <<EOSS
  635. $startsh
  636. : expand filename
  637. case "\$1" in
  638.  ~/*|~)
  639.     echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  640.     ;;
  641.  ~*)
  642.     if $test -f /bin/csh; then
  643.     /bin/csh -f -c "glob \$1"
  644.     echo ""
  645.     else
  646.     name=\`$expr x\$1 : '..\([^/]*\)'\`
  647.     dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  648.     if $test ! -d "\$dir"; then
  649.         me=\`basename \$0\`
  650.         echo "\$me: can't locate home directory for: \$name" >&2
  651.         exit 1
  652.     fi
  653.     case "\$1" in
  654.     */*)
  655.         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  656.         ;;
  657.     *)
  658.         echo \$dir
  659.         ;;
  660.     esac
  661.     fi
  662.     ;;
  663. *)
  664.     echo \$1
  665.     ;;
  666. esac
  667. EOSS
  668. chmod +x filexp
  669. $eunicefix filexp
  670.  
  671. : determine where manual pages go
  672. case "$mansrc" in
  673. '')
  674.     dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
  675.     ;;
  676. *)  dflt="$mansrc"
  677.     ;;
  678. esac
  679. cont=true
  680. while $test "$cont" ; do
  681.     echo " "
  682.     rp="Where do the manual pages (source) go? [$dflt]"
  683.     $echo $n "$rp $c"
  684.     . myread
  685.     mansrc=`filexp "$ans"`
  686.     if test -d $mansrc; then
  687.     cont=''
  688.     else
  689.     dflt=n
  690.     rp="Directory $mansrc doesn't exist.  Use that name anyway? [$dflt]"
  691.     $echo $n "$rp $c"
  692.     . myread
  693.     dflt=''
  694.     case "$ans" in
  695.     y*) cont='';;
  696.     esac
  697.     fi
  698. done
  699. case "$mansrc" in
  700. *l)
  701.     manext=l
  702.     ;;
  703. *n)
  704.     manext=n
  705.     ;;
  706. *C)
  707.     manext=C
  708.     ;;
  709. *)
  710.     manext=1
  711.     ;;
  712. esac
  713.  
  714. : see what memory models we can support
  715. case "$models" in
  716. '')
  717.     : We may not use Cppsym or we get a circular dependency through cc.
  718.     : But this should work regardless of which cc we eventually use.
  719.     cat >pdp11.c <<'EOP'
  720. main() {
  721. #ifdef pdp11
  722.     exit(0);
  723. #else
  724.     exit(1);
  725. #endif
  726. }
  727. EOP
  728.     cc -o pdp11 pdp11.c >/dev/null 2>&1
  729.     if pdp11 2>/dev/null; then
  730.     dflt='unsplit split'
  731.     else
  732.     ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
  733.     case "$ans" in
  734.     X) dflt='none';;
  735.     *)  if $test -d /lib/small || $test -d /usr/lib/small; then
  736.         dflt='small'
  737.         else
  738.         dflt=''
  739.         fi
  740.         if $test -d /lib/medium || $test -d /usr/lib/medium; then
  741.         dflt="$dflt medium"
  742.         fi
  743.         if $test -d /lib/large || $test -d /usr/lib/large; then
  744.         dflt="$dflt large"
  745.         fi
  746.         if $test -d /lib/huge || $test -d /usr/lib/huge; then
  747.         dflt="$dflt huge"
  748.         fi
  749.     esac
  750.     fi
  751.     ;;
  752. *)  dflt="$models" ;;
  753. esac
  754. $cat <<EOM
  755.  
  756. Some systems have different model sizes.  On most systems they are called
  757. small, medium, large, and huge.  On the PDP11 they are called unsplit and
  758. split.  If your system doesn't support different memory models, say "none".
  759. If you wish to force everything to one memory model, say "none" here and
  760. put the appropriate flags later when it asks you for other cc and ld flags.
  761. Venix systems may wish to put "none" and let the compiler figure things out.
  762. (In the following question multiple model names should be space separated.)
  763.  
  764. EOM
  765. rp="Which models are supported? [$dflt]"
  766. $echo $n "$rp $c"
  767. . myread
  768. models="$ans"
  769.  
  770. case "$models" in
  771. none)
  772.     small=''
  773.     medium=''
  774.     large=''
  775.     huge=''
  776.     unsplit=''
  777.     split=''
  778.     ;;
  779. *split)
  780.     case "$split" in
  781.     '') 
  782.     if $contains '\-i' $mansrc/ld.1 >/dev/null 2>&1 || \
  783.        $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1; then
  784.         dflt='-i'
  785.     else
  786.         dflt='none'
  787.     fi
  788.     ;;
  789.     *) dflt="$split";;
  790.     esac
  791.     rp="What flag indicates separate I and D space? [$dflt]"
  792.     $echo $n "$rp $c"
  793.     . myread
  794.     case "$ans" in
  795.     none) ans='';;
  796.     esac
  797.     split="$ans"
  798.     unsplit=''
  799.     ;;
  800. *large*|*small*|*medium*|*huge*)
  801.     case "$model" in
  802.     *large*)
  803.     case "$large" in
  804.     '') dflt='-Ml';;
  805.     *) dflt="$large";;
  806.     esac
  807.     rp="What flag indicates large model? [$dflt]"
  808.     $echo $n "$rp $c"
  809.     . myread
  810.     case "$ans" in
  811.     none) ans='';
  812.     esac
  813.     large="$ans"
  814.     ;;
  815.     *) large='';;
  816.     esac
  817.     case "$model" in
  818.     *huge*)
  819.     case "$huge" in
  820.     '') dflt='-Mh';;
  821.     *) dflt="$huge";;
  822.     esac
  823.     rp="What flag indicates huge model? [$dflt]"
  824.     $echo $n "$rp $c"
  825.     . myread
  826.     case "$ans" in
  827.     none) ans='';
  828.     esac
  829.     huge="$ans"
  830.     ;;
  831.     *) huge="$large";;
  832.     esac
  833.     case "$model" in
  834.     *medium*)
  835.     case "$medium" in
  836.     '') dflt='-Mm';;
  837.     *) dflt="$medium";;
  838.     esac
  839.     rp="What flag indicates medium model? [$dflt]"
  840.     $echo $n "$rp $c"
  841.     . myread
  842.     case "$ans" in
  843.     none) ans='';
  844.     esac
  845.     medium="$ans"
  846.     ;;
  847.     *) medium="$large";;
  848.     esac
  849.     case "$model" in
  850.     *small*)
  851.     case "$small" in
  852.     '') dflt='none';;
  853.     *) dflt="$small";;
  854.     esac
  855.     rp="What flag indicates small model? [$dflt]"
  856.     $echo $n "$rp $c"
  857.     . myread
  858.     case "$ans" in
  859.     none) ans='';
  860.     esac
  861.     small="$ans"
  862.     ;;
  863.     *) small='';;
  864.     esac
  865.     ;;
  866. *)
  867.     echo "Unrecognized memory models--you may have to edit Makefile.SH"
  868.     ;;
  869. esac
  870.  
  871. : see if we need a special compiler
  872. echo " "
  873. if usg; then
  874.     case "$cc" in
  875.     '')
  876.     case "$Mcc" in
  877.     /*) dflt='Mcc'
  878.         ;;
  879.     *)
  880.         case "$large" in
  881.         -M*)
  882.         dflt='cc'
  883.         ;;
  884.         *)
  885.         if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
  886.             dflt='cc -M'
  887.         else
  888.             dflt='cc'
  889.         fi
  890.         ;;
  891.         esac
  892.         ;;
  893.     esac
  894.     ;;
  895.     *)  dflt="$cc";;
  896.     esac
  897.     $cat <<'EOM'
  898.  
  899. On some systems the default C compiler will not resolve multiple global
  900. references that happen to have the same name.  On some such systems the
  901. "Mcc" command may be used to force these to be resolved.  On other systems
  902. a "cc -M" command is required.  (Note that the -M flag on other systems
  903. indicates a memory model to use!)  If you have the Gnu C compiler, you
  904. might wish to use that instead.  What command will force resolution on
  905. EOM
  906.     $echo $n "this system? [$dflt] $c"
  907.     rp="Command to resolve multiple refs? [$dflt]"
  908.     . myread
  909.     cc="$ans"
  910. else
  911.     case "$cc" in
  912.     '') dflt=cc;;
  913.     *) dflt="$cc";;
  914.     esac
  915.     rp="Use which C compiler? [$dflt]"
  916.     $echo $n "$rp $c"
  917.     . myread
  918.     cc="$ans"
  919. fi
  920. case "$cc" in
  921. gcc*) cpp=`loc gcc-cpp $cpp $pth`;;
  922. esac
  923.  
  924. case "$ccflags" in
  925. '') dflt='none';;
  926. *) dflt="$ccflags";;
  927. esac
  928. echo " "
  929. rp="Any additional cc flags? [$dflt]"
  930. $echo $n "$rp $c"
  931. . myread
  932. case "$ans" in
  933. none) ans='';
  934. esac
  935. ccflags="$ans"
  936.  
  937. case "$ldflags" in
  938. '') if venix; then
  939.     dflt='-i -z'
  940.     else
  941.     dflt='none'
  942.     fi
  943.     ;;
  944. *) dflt="$ldflags";;
  945. esac
  946. echo " "
  947. rp="Any additional ld flags? [$dflt]"
  948. $echo $n "$rp $c"
  949. . myread
  950. case "$ans" in
  951. none) ans='';
  952. esac
  953. ldflags="$ans"
  954. rmlist="$rmlist pdp11"
  955.  
  956. : see if sprintf is declared as int or pointer to char
  957. echo " "
  958. cat >.ucbsprf.c <<'EOF'
  959. main() { char buf[10]; exit((unsigned long)sprintf(buf,"%s","foo") > 10L); }
  960. EOF
  961. if $cc .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
  962.     echo "Your sprintf() returns (int)."
  963.     d_charsprf="$undef"
  964. else
  965.     echo "Your sprintf() returns (char*)."
  966.     d_charsprf="$define"
  967. fi
  968. /bin/rm -f .ucbsprf.c .ucbsprf
  969.  
  970. : index or strcpy
  971. echo " "
  972. case "$d_index" in
  973. n) dflt=n;;
  974. *) dflt=y;;
  975. esac
  976. if $contains '^index$' libc.list >/dev/null 2>&1 ; then
  977.     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  978.     echo "Your system has both index() and strchr().  Shall I use"
  979.     rp="index() rather than strchr()? [$dflt]"
  980.     $echo $n "$rp $c"
  981.     . myread
  982.     case "$ans" in
  983.         n*) d_index="$define" ;;
  984.         *)  d_index="$undef" ;;
  985.     esac
  986.     else
  987.     d_index="$undef"
  988.     echo "index() found."
  989.     fi
  990. else
  991.     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  992.     d_index="$define"
  993.     echo "strchr() found."
  994.     else
  995.     echo "No index() or strchr() found!"
  996.     d_index="$undef"
  997.     fi
  998. fi
  999.  
  1000. : see if memcpy exists
  1001. echo " "
  1002. if $contains '^memcpy$' libc.list >/dev/null 2>&1; then
  1003.     echo 'memcpy() found.'
  1004.     d_memcpy="$define"
  1005. else
  1006.     echo 'memcpy() not found.'
  1007.     d_memcpy="$undef"
  1008. fi
  1009.  
  1010. $echo " "
  1011. cat << EOM
  1012. Does "read" restart when interrupted ?
  1013. This is the default behaviour on e.g. BSD4.3 and SUN OS 3.5.
  1014.  
  1015. I am now compiling and running a test program to determine the default
  1016. EOM
  1017. $echo $n "for your system. Just a few seconds ..."
  1018.  
  1019. $cat >tread.c <<'-stop-here-'
  1020. /*
  1021.  * Test whether "read" restarts when interrupted by a signal,
  1022.  * or whether it returns an error code.
  1023.  * Returns:
  1024.  * 0 : read restarts
  1025.  * 1 : read returns error code
  1026.  * 2 : some error
  1027.  *
  1028.  * Don't use "wait" and "SIGCHLD". What with "wait" and "wait3" or even
  1029.  * "wait4" and SYS V's "SIGCLD" braindamage ..
  1030.  */
  1031. #include <stdio.h>
  1032. #include <errno.h>
  1033. #include <signal.h>
  1034.  
  1035. #define    SECS    5        /* how long to wait before interrupting */
  1036.  
  1037. int pid;
  1038. extern int errno;
  1039.  
  1040. ignore (n)
  1041.     int n;
  1042. {
  1043.     signal (SIGINT, ignore);        /* be on the safe side */
  1044. }
  1045.  
  1046. intr2 (n)
  1047.     int n;
  1048. /*
  1049.  * This routine gets called by "alarm", if read does not return.
  1050.  * Kind of an emergency break.
  1051.  */
  1052. {
  1053.     exit (0);
  1054. }
  1055.  
  1056. intr1 (n)
  1057.     int n;
  1058. {
  1059.     signal (SIGALRM, intr2);
  1060.     alarm (SECS);
  1061.     kill (getpid (), SIGINT);
  1062. }
  1063.  
  1064. main (argc, argv)
  1065.     int argc;
  1066.     char ** argv;
  1067. {
  1068.     int i, err;
  1069.     char buf [80];
  1070.  
  1071.     signal (SIGINT, ignore);
  1072.     signal (SIGALRM, intr1);
  1073.     alarm (5);
  1074.     for (;;) {
  1075.         /*
  1076.          * Loop : stupid user may type something. Only exit on EINTR.
  1077.          */
  1078.         i = read (fileno(stdin), buf, 80);
  1079.         if (i == -1) {
  1080.             err = errno;
  1081.             if (err == EINTR)
  1082.                 exit (1);
  1083.         }
  1084.     }
  1085.     /* not reached */
  1086. }
  1087. -stop-here-
  1088.  
  1089. dflt="yes"
  1090. if $cc tread.c >.out 2>&1 ; then
  1091.     a.out
  1092.     rp=$?
  1093.     if $test "X$rp" = "X1" ; then
  1094.         dflt="no"
  1095.     else
  1096.         dflt="yes"
  1097.     fi
  1098.     $rm a.out
  1099. else
  1100.     dflt="none"
  1101. fi
  1102. $echo " done."
  1103. $rm tread.c .out
  1104.  
  1105. tmp="no"
  1106. while $test "X$tmp" = "Xno" ; do
  1107.     rp="Does 'read' restart ? [$dflt]"
  1108.     $echo $n "$rp $c"
  1109.     . myread
  1110.     tmp=yes
  1111.     case "$ans" in
  1112.         y*)    d_reread="define" ;;
  1113.         n*)    d_reread="undef" ;;
  1114.         *)    echo "Answer yes or no" ; tmp="no";;
  1115.     esac
  1116. done
  1117. : see how we invoke the C preprocessor
  1118. echo " "
  1119. echo "Now, how can we feed standard input to your C preprocessor..."
  1120. cat <<'EOT' >testcpp.c
  1121. #define ABC abc
  1122. #define XYZ xyz
  1123. ABC.XYZ
  1124. EOT
  1125.  
  1126. num=0
  1127. #
  1128. # mg 24-apr-90
  1129. # The following stuff was difficult to look over. Unrolled into a while
  1130. # loop instead of nested "if"s
  1131. #
  1132. while test "$num" != 100 ; do
  1133.     case "$num" in
  1134.     0)    echo 'Maybe "'"$cc"' -E" will work...'
  1135.         $cc -E <testcpp.c >testcpp.out 2>&1
  1136.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1137.             echo "Yup, it does."
  1138.             cppstdin="$cc -E"
  1139.             cppminus=''
  1140.             num=100
  1141.         else
  1142.             num=1
  1143.         fi
  1144.         ;;
  1145.     1)    echo 'Nope, maybe "'$cpp'" will work...'
  1146.         $cpp <testcpp.c >testcpp.out 2>&1
  1147.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1148.             echo "Yup, it does."
  1149.             cppstdin="$cpp"
  1150.             cppminus=''
  1151.             num=100
  1152.         else
  1153.             num=2
  1154.         fi
  1155.         ;;
  1156.     2)    echo 'No such luck...maybe "'$cpp' -" will work...'
  1157.         $cpp - <testcpp.c >testcpp.out 2>&1
  1158.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1159.             echo "It works!"
  1160.             cppstdin="$cpp"
  1161.             cppminus='-';
  1162.             num=100
  1163.         else
  1164.             num=3
  1165.         fi
  1166.         ;;
  1167.     3)    echo 'Nixed again...maybe "'"$cc"' -E -" will work...'
  1168.         $cc -E - <testcpp.c >testcpp.out 2>&1
  1169.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1170.             echo "Hooray, it works!  I was beginning to wonder."
  1171.             cppstdin="$cc -E"
  1172.             cppminus='-';
  1173.             num=100
  1174.         else
  1175.             num=4
  1176.         fi
  1177.         ;;
  1178.     4)    echo 'Nope...maybe "'"$cc"' -P" will work...'
  1179.         $cc -P <testcpp.c >testcpp.out 2>&1
  1180.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1181.             echo "Yup, that does."
  1182.             cppstdin="$cc -P"
  1183.             cppminus='';
  1184.             num=100
  1185.         else
  1186.             num=5
  1187.         fi
  1188.         ;;
  1189.     5) echo 'Nope...maybe "'"$cc"' -P -" will work...'
  1190.         $cc -P - <testcpp.c >testcpp.out 2>&1
  1191.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1192.             echo "Yup, that does."
  1193.             cppstdin="$cc -P"
  1194.             cppminus='-';
  1195.             num=100
  1196.         else
  1197.             num=6
  1198.         fi
  1199.         ;;
  1200.     6)    echo 'Hmm...perhaps you already told me...'
  1201.         case "$cppstdin" in
  1202.         '') ;;
  1203.         *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
  1204.         esac
  1205.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1206.             echo "Hooray, you did!  I was beginning to wonder."
  1207.             num=100
  1208.         else
  1209.             num=7
  1210.         fi
  1211.         ;;
  1212.     7)    dflt=blurfl
  1213.         $echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
  1214.         rp='Name a C preprocessor:'
  1215.         . myread
  1216.         cppstdin="$ans"
  1217.         $cppstdin <testcpp.c >testcpp.out 2>&1
  1218.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1219.             echo "OK, that will do."
  1220.             num=100
  1221.         else
  1222.             num=8
  1223.         fi
  1224.         ;;
  1225.     8)    echo 'Uh-uh.  Time to get fancy...'
  1226.         cd ..
  1227.         echo 'Trying shell script.'
  1228. cat > cppstdin << 'GROK meets BC'
  1229. : use /bin/sh
  1230. # gnowb'd cpp  v1.3  14.jul.88   by mg
  1231. #
  1232. # usage :: my_cpp [option] ... [file] ...
  1233. # only 0, 1 or 2 files, parameters start with a '-'
  1234. #
  1235. # run over the parameters, gather them in two
  1236. # strings : pars and files
  1237. #
  1238. # use "cc -E" instead of "cpp"; it inserts lines starting with "#"
  1239. #
  1240. pars=''
  1241. files=''
  1242. j=0
  1243. for i in $*
  1244. do
  1245.     case $i in
  1246.     -*)        pars="$pars $i" ;;
  1247.     *)        files="$files $i" ; j=`expr $j + 1` ;;
  1248.     esac
  1249. done
  1250. f=/tmp/CPP$$.c
  1251. case "$j" in
  1252.     0 )    cat > $f ;
  1253.         set "$pars $f" ;
  1254.         cc -E $@ ;
  1255.         /bin/rm -f $f ;;
  1256.     1 ) set "$pars $files";
  1257.         cc -E $@;;
  1258.     2 ) set "$files";
  1259.         from=$1;
  1260.         to=$2;
  1261.         set "$pars $1";
  1262.         cc -E $@ > $2;;
  1263.     * )    echo "cpp :: too much file parameter" >&- >&2 ;
  1264.         exit 1 ;;
  1265. esac
  1266. exit 0
  1267. GROK meets BC
  1268.         chmod 755 cppstdin
  1269.         cppstdin=`pwd`/cppstdin
  1270.         cppminus='';
  1271.         cd UU
  1272.         $cppstdin <testcpp.c >testcpp.out 2>&1
  1273.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1274.             echo "Eureka!."
  1275.             num=100
  1276.         else
  1277.             echo "Sorry, I can't get that to work.  Go find one."
  1278.             exit 1
  1279.         fi
  1280.         ;;
  1281.     esac
  1282. done
  1283. rm -f testcpp.c testcpp.out
  1284. : get C preprocessor symbols handy
  1285. echo " "
  1286. echo $attrlist | $tr '[ - ]' '[\012-\012]' >Cppsym.know
  1287. $cat <<EOSS >Cppsym
  1288. $startsh
  1289. case "\$1" in
  1290. -l) list=true
  1291.     shift
  1292.     ;;
  1293. esac
  1294. unknown=''
  1295. case "\$list\$#" in
  1296. 1|2)
  1297.     for sym do
  1298.     if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
  1299.         exit 0
  1300.     elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
  1301.         :
  1302.     else
  1303.         unknown="\$unknown \$sym"
  1304.     fi
  1305.     done
  1306.     set X \$unknown
  1307.     shift
  1308.     ;;
  1309. esac
  1310. case \$# in
  1311. 0) exit 1;;
  1312. esac
  1313. echo \$* | $tr '[ - ]' '[\012-\012]' | $sed -e 's/\(.*\)/\\
  1314. #ifdef \1\\
  1315. exit 0; _ _ _ _\1\\     \1\\
  1316. #endif\\
  1317. /' >/tmp/Cppsym\$\$
  1318. echo exit 1 >>/tmp/Cppsym\$\$
  1319. $cppstdin $cppminus </tmp/Cppsym\$\$ >/tmp/Cppsym2\$\$
  1320. case "\$list" in
  1321. true) awk 'NF > 5 {print substr(\$6,2,100)}' </tmp/Cppsym2\$\$ ;;
  1322. *)
  1323.     sh /tmp/Cppsym2\$\$
  1324.     status=\$?
  1325.     ;;
  1326. esac
  1327. $rm -f /tmp/Cppsym\$\$ /tmp/Cppsym2\$\$
  1328. exit \$status
  1329. EOSS
  1330. chmod +x Cppsym
  1331. $eunicefix Cppsym
  1332. echo "Your C preprocessor defines the following symbols:"
  1333. Cppsym -l $attrlist >Cppsym.true
  1334. cat Cppsym.true
  1335. rmlist="$rmlist Cppsym Cppsym.know Cppsym.true"
  1336.  
  1337. : see if this is a termio system, and if, remember where the header file is
  1338. echo " "
  1339. systermio="$undef"
  1340. d_termio="$undef"
  1341. if Cppsym pyr && $test -r /usr/include/sgtty.h ; then
  1342.     echo "sgtty.h found."
  1343. elif $test -r /usr/include/termio.h -o -r /usr/include/sys/termio.h ; then
  1344.        echo "termio.h found."
  1345.     if $test -r /usr/include/sgtty.h ; then
  1346.         $echo "sgtty.h found too"
  1347.         $echo " "
  1348.         dflt="termio"
  1349.         rp="You have both stty and termio. What should I use ? [$dflt]"
  1350.         $echo $n "$rp $c"
  1351.         . myread
  1352.         case "$ans" in
  1353.         stty)    d_termio="$undef" ;;
  1354.         termio)    d_termio="$define" ;;
  1355.         esac
  1356.     fi
  1357.     if $test "X$d_termio" = "X$define" ; then
  1358.         if $test -r /usr/include/sys/termio.h ; then
  1359.             systermio="$define"
  1360.         fi
  1361.     fi
  1362. elif $test -r /usr/include/sgtty.h ; then
  1363.     echo "sgtty.h found."
  1364. else
  1365.     echo "Neither termio.h nor sgtty.h found--you could have problems."
  1366. fi
  1367. : Ask the user !
  1368. $echo " "
  1369. dflt="void"
  1370. cat << EOM
  1371. What method should be used to look whether characters are waiting from
  1372. a terminal?
  1373. Type one of the following numbers to select the corresponding method.
  1374.  
  1375. 1 : select
  1376. 2 : rdchk
  1377. 3 : fionread
  1378.  
  1379. EOM
  1380.  
  1381. tmp="no"
  1382. while $test "X$tmp" = "Xno" ; do
  1383.     rp="What routine should I use ?"
  1384.     $echo $n "$rp $c"
  1385.     . myread
  1386.     tmp=yes
  1387.     case "$ans" in
  1388.         1)    look4char="USE_SELECT" ;;
  1389.         2)    look4char="USE_RDCHK" ;;
  1390.         3)    look4char="USE_FIONREAD" ;;
  1391.         *)    echo "Choose one from 1 through 3" ; tmp="no";;
  1392.     esac
  1393. done
  1394. : Ask the user !
  1395. $echo " "
  1396. dflt="void"
  1397. cat << EOM
  1398. How should your program wait for a character from a terminal ?
  1399. Enter
  1400.  
  1401. 1 : select
  1402. 2 : rdchk
  1403.  
  1404. EOM
  1405.  
  1406. tmp="no"
  1407. while $test "X$tmp" = "Xno" ; do
  1408.     rp="What routine should I use ?"
  1409.     $echo $n "$rp $c"
  1410.     . myread
  1411.     tmp=yes
  1412.     case "$ans" in
  1413.         1)    wait4char="USE_SELECT" ;;
  1414.         2)    wait4char="USE_RDCHK" ;;
  1415.         *)    echo "Choose one from 1 through 2" ; tmp="no";;
  1416.     esac
  1417. done
  1418. : see if free is defined as "int" or "void"
  1419. : Ask the user !
  1420. $echo " "
  1421. dflt="void"
  1422. cat << EOM
  1423. Specifiy how the routine 'free' is defined on your system ?
  1424. Typically it is 'void free ();' but if you are on a SUN running
  1425. SUN OS 3.* it is 'int free();'.
  1426. Specify either 'void' or 'int' here.
  1427.  
  1428. EOM
  1429.  
  1430. tmp="no"
  1431. while $test "X$tmp" = "Xno" ; do
  1432.     rp="How is your 'free' routine defined ? [$dflt]"
  1433.     $echo $n "$rp $c"
  1434.     . myread
  1435.     case "$ans" in
  1436.         void)    d_intfree="void" ; tmp="yes" ;;
  1437.         int)    d_intfree="int" ; tmp="yes" ;;
  1438.         *)        echo "Sorry, I don't think that's correct." ;;
  1439.     esac
  1440. done
  1441. echo " "
  1442. echo "End of configuration questions."
  1443. echo " "
  1444.  
  1445. : create config.sh file
  1446. echo " "
  1447. if test -d ../UU; then
  1448.     cd ..
  1449. fi
  1450. echo "Creating config.sh..."
  1451. $spitshell <<EOT >config.sh
  1452. $startsh
  1453. # config.sh
  1454. # This file was produced by running the Configure script.
  1455.  
  1456. d_eunice='$d_eunice'
  1457. eunicefix='$eunicefix'
  1458. loclist='$loclist'
  1459. expr='$expr'
  1460. sed='$sed'
  1461. echo='$echo'
  1462. cat='$cat'
  1463. rm='$rm'
  1464. mv='$mv'
  1465. cp='$cp'
  1466. tail='$tail'
  1467. tr='$tr'
  1468. mkdir='$mkdir'
  1469. sort='$sort'
  1470. uniq='$uniq'
  1471. grep='$grep'
  1472. trylist='$trylist'
  1473. test='$test'
  1474. inews='$inews'
  1475. egrep='$egrep'
  1476. more='$more'
  1477. pg='$pg'
  1478. Mcc='$Mcc'
  1479. vi='$vi'
  1480. mailx='$mailx'
  1481. mail='$mail'
  1482. cpp='$cpp'
  1483. perl='$perl'
  1484. contains='$contains'
  1485. d_bcopy='$d_bcopy'
  1486. d_charsprf='$d_charsprf'
  1487. d_index='$d_index'
  1488. d_memcpy='$d_memcpy'
  1489. libc='$libc'
  1490. mansrc='$mansrc'
  1491. manext='$manext'
  1492. models='$models'
  1493. split='$split'
  1494. small='$small'
  1495. medium='$medium'
  1496. large='$large'
  1497. huge='$huge'
  1498. ccflags='$ccflags'
  1499. ldflags='$ldflags'
  1500. cc='$cc'
  1501. n='$n'
  1502. c='$c'
  1503. package='$package'
  1504. spitshell='$spitshell'
  1505. shsharp='$shsharp'
  1506. sharpbang='$sharpbang'
  1507. startsh='$startsh'
  1508. define='$define'
  1509. cppstdin='$cppstdin'
  1510. cppminus='$cppminus'
  1511. d_intfree='$d_intfree'
  1512. d_reread='$d_reread'
  1513. d_termio='$d_termio'
  1514. systermio='$systermio'
  1515. look4char='$look4char'
  1516. use_select='$use_select'
  1517. use_rdchk='$use_rdchk'
  1518. use_fionread='$use_fionread'
  1519. wait4char='$wait4char'
  1520. CONFIG=true
  1521. EOT
  1522.  
  1523. CONFIG=true
  1524.  
  1525. echo " "
  1526. dflt=''
  1527. fastread=''
  1528. echo "If you didn't make any mistakes, then just type a carriage return here."
  1529. rp="If you need to edit config.sh, do it as a shell escape here:"
  1530. $echo $n "$rp $c"
  1531. . UU/myread
  1532. case "$ans" in
  1533. '') ;;
  1534. *) : in case they cannot read
  1535.     eval $ans;;
  1536. esac
  1537. . ./config.sh
  1538.  
  1539. echo " "
  1540. echo "Doing variable substitutions on .SH files..."
  1541. set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
  1542. shift
  1543. case $# in
  1544. 0) set x *.SH; shift;;
  1545. esac
  1546. if test ! -f $1; then
  1547.     shift
  1548. fi
  1549. for file in $*; do
  1550.     case "$file" in
  1551.     */*)
  1552.     dir=`$expr X$file : 'X\(.*\)/'`
  1553.     file=`$expr X$file : 'X.*/\(.*\)'`
  1554.     (cd $dir && . $file)
  1555.     ;;
  1556.     *)
  1557.     . $file
  1558.     ;;
  1559.     esac
  1560. done
  1561. if test -f config.h.SH; then
  1562.     if test ! -f config.h; then
  1563.     : oops, they left it out of MANIFEST, probably, so do it anyway.
  1564.     . config.h.SH
  1565.     fi
  1566. fi
  1567.  
  1568. if $contains '^depend:' Makefile >/dev/null 2>&1; then
  1569.     dflt=n
  1570.     $cat <<EOM
  1571.  
  1572. Now you need to generate make dependencies by running "make depend".
  1573. You might prefer to run it in background: "make depend > makedepend.out &"
  1574. It can take a while, so you might not want to run it right now.
  1575.  
  1576. EOM
  1577.     rp="Run make depend now? [$dflt]"
  1578.     $echo $n "$rp $c"
  1579.     . UU/myread
  1580.     case "$ans" in
  1581.     y*) make depend
  1582.     echo "Now you must run a make."
  1583.     ;;
  1584.     *)  echo "You must run 'make depend' then 'make'."
  1585.     ;;
  1586.     esac
  1587. elif test -f Makefile; then
  1588.     echo " "
  1589.     echo "Now you must run a make."
  1590. else
  1591.     echo "Done."
  1592. fi
  1593.  
  1594. $rm -f kit*isdone
  1595. : the following is currently useless
  1596. cd UU && $rm -f $rmlist
  1597. : since this removes it all anyway
  1598. cd .. && $rm -rf UU
  1599. : end of Configure
  1600.