home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume27 / mthreads / part04 / Configure
Text File  |  1993-11-20  |  67KB  |  3,012 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,
  7. # I would suggest you have a look at the prototypical config.h.SH file
  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. # Yes, you may rip this off to use in other distribution packages. This
  12. # script belongs to the public domain and cannot be copyrighted.
  13. #
  14. # (Note: this Configure script was generated automatically. Rather than
  15. # working with this copy of Configure, you may wish to get metaconfig.
  16. # The dist-3.0 package (which contains metaconfig) was posted in
  17. # comp.sources.misc so you may fetch it yourself from your nearest
  18. # archive site. Check with Archie if you don't know where that can be.)
  19. #
  20.  
  21. # $Id: Head.U,v 3.0.1.1 1993/08/27 14:38:07 ram Exp $
  22. #
  23. # Generated on Fri Sep 24 11:09:28 PDT 1993 [metaconfig 3.0 PL9]
  24.  
  25. cat >/tmp/c1$$ <<EOF
  26. ARGGGHHHH!!!!!
  27.  
  28. SCO csh still thinks true is false.  Write to SCO today and tell them that next
  29. year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
  30.  
  31. (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
  32. we'd have to do is go in and swap the && and || tokens, wherever they are.)
  33.  
  34. [End of diatribe. We now return you to your regularly scheduled programming...]
  35. EOF
  36. cat >/tmp/c2$$ <<EOF
  37.  
  38. OOPS!  You naughty creature!  You didn't run Configure with sh!
  39. I will attempt to remedy the situation by running sh for you...
  40. EOF
  41.  
  42. true || cat /tmp/c1$$ /tmp/c2$$
  43. true || exec sh $0 $argv:q
  44.  
  45. (exit $?0) || cat /tmp/c2$$
  46. (exit $?0) || exec sh $0 $argv:q
  47. rm -f /tmp/c1$$ /tmp/c2$$
  48.  
  49. : Sanity checks
  50. PATH=".:$PATH:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin"
  51. PATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
  52. PATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin:/bsd4.3/bin:/bsd4.3/usr/ucb'
  53. PATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd:/bsd43/bin:/usr/ccs/bin'
  54. PATH=$PATH:'/etc:/usr/lib:/usr/ucblib:/lib:/usr/ccs/lib'
  55. export PATH
  56.  
  57. if test ! -t 0; then
  58.     echo "Say 'sh Configure', not 'sh <Configure'"
  59.     exit 1
  60. fi
  61.  
  62. : On HP-UX, large Configure scripts may exercise a bug in /bin/sh
  63. if test -f /hp-ux -a -f /bin/ksh; then
  64.     if (alias -x) >/dev/null 2>&1; then
  65.         : already under /bin/ksh
  66.     else
  67.         cat <<'EOM'
  68. (Feeding myself to ksh to avoid nasty sh bug in "here document" expansion.)
  69. EOM
  70.         exec /bin/ksh $0 "$@"
  71.     fi
  72. else
  73.     : Warn them if they use ksh on other systems
  74.     (alias -x) >/dev/null 2>&1 && \
  75.         cat <<'EOM'
  76. (I see you are using the Korn shell.  Some ksh's blow up on Configure,
  77. especially on exotic machines.  If yours does, try the Bourne shell instead.)
  78. EOM
  79. fi
  80.  
  81. : Configure runs within the UU subdirectory
  82. test -d UU || mkdir UU
  83. cd UU && rm -f *
  84.  
  85. d_bsd=''
  86. d_eunice=''
  87. d_xenix=''
  88. eunicefix=''
  89. Mcc=''
  90. awk=''
  91. cat=''
  92. cpp=''
  93. date=''
  94. echo=''
  95. egrep=''
  96. expr=''
  97. gcc=''
  98. grep=''
  99. lint=''
  100. mail=''
  101. mkdir=''
  102. mv=''
  103. nroff=''
  104. rm=''
  105. sed=''
  106. sendmail=''
  107. sort=''
  108. test=''
  109. tr=''
  110. uname=''
  111. uniq=''
  112. uuname=''
  113. vi=''
  114. hint=''
  115. myuname=''
  116. Id=''
  117. Log=''
  118. active=''
  119. acttimes=''
  120. d_acttimes=''
  121. myactive=''
  122. afs=''
  123. cc=''
  124. ccflags=''
  125. cppflags=''
  126. ldflags=''
  127. lkflags=''
  128. optimize=''
  129. cf_by=''
  130. cf_time=''
  131. contains=''
  132. cppminus=''
  133. cppstdin=''
  134. d_chsize=''
  135. d_ftrncate=''
  136. d_memcmp=''
  137. d_memcpy=''
  138. d_memset=''
  139. d_newsadm=''
  140. newsadmin=''
  141. d_nntp=''
  142. servername=''
  143. d_normsig=''
  144. jobslib=''
  145. d_novoid=''
  146. void=''
  147. d_portable=''
  148. d_rename=''
  149. d_sighold=''
  150. d_strchr=''
  151. d_syslog=''
  152. syslog=''
  153. d_libndir=''
  154. d_usendir=''
  155. libndir=''
  156. ndirc=''
  157. ndiro=''
  158. d_usleep=''
  159. d_vfork=''
  160. d_voidsig=''
  161. signal_t=''
  162. d_dirnamlen=''
  163. i_dirent=''
  164. i_stdlib=''
  165. i_string=''
  166. strings=''
  167. i_sysdir=''
  168. i_sysndir=''
  169. i_systime=''
  170. i_time=''
  171. i_unistd=''
  172. i_vfork=''
  173. libc=''
  174. plibpth=''
  175. xlibpth=''
  176. libs=''
  177. installmansrc=''
  178. manext=''
  179. mansrc=''
  180. mansrcexp=''
  181. c=''
  182. n=''
  183. newslib=''
  184. newslibexp=''
  185. newsspool=''
  186. package=''
  187. spackage=''
  188. installprivlib=''
  189. privlib=''
  190. privlibexp=''
  191. sharpbang=''
  192. shsharp=''
  193. spitshell=''
  194. startsh=''
  195. sysman=''
  196. threaddir=''
  197. nm_opt=''
  198. runnm=''
  199. usenm=''
  200. incpath=''
  201. mips=''
  202. mips_type=''
  203. usrinc=''
  204. d_whoami=''
  205. CONFIG=''
  206.  
  207. : script used to extract .SH files with variable substitutions
  208. cat >extract <<'EOS'
  209. CONFIG=true
  210. echo "Doing variable substitutions on .SH files..."
  211. if test -f MANIFEST; then
  212.     set x `awk '{print $1}' <MANIFEST | grep '\.SH'`
  213. else
  214.     echo "(Looking for .SH files under the current directory.)"
  215.     set x `find . -name "*.SH" -print`
  216. fi
  217. shift
  218. case $# in
  219. 0) set x *.SH; shift;;
  220. esac
  221. if test ! -f $1; then
  222.     shift
  223. fi
  224. for file in $*; do
  225.     case "$file" in
  226.     */*)
  227.         dir=`expr X$file : 'X\(.*\)/'`
  228.         file=`expr X$file : 'X.*/\(.*\)'`
  229.         (cd $dir && . ./$file)
  230.         ;;
  231.     *)
  232.         . ./$file
  233.         ;;
  234.     esac
  235. done
  236. EOS
  237.  
  238. : produce awk script to parse command line options
  239. cat >options.awk <<'EOF'
  240. BEGIN {
  241.     optstr = "deEf:hrsSV";    # getopt-style specification
  242.  
  243.     len = length(optstr);
  244.     for (i = 1; i <= len; i++) {
  245.         c = substr(optstr, i, 1);
  246.         if (i < len) a = substr(optstr, i + 1, 1); else a = "";
  247.         if (a == ":") {
  248.             arg[c] = 1;
  249.             i++;
  250.         }
  251.         opt[c] = 1;
  252.     }
  253. }
  254. {
  255.     expect = 0;
  256.     str = $0;
  257.     if (substr(str, 1, 1) != "-") {
  258.         printf("'%s'\n", str);
  259.         next;
  260.     }
  261.     len = length($0);
  262.     for (i = 2; i <= len; i++) {
  263.         c = substr(str, i, 1);
  264.         if (!opt[c]) {
  265.             printf("-%s\n", substr(str, i));
  266.             next;
  267.         }
  268.         printf("-%s\n", c);
  269.         if (arg[c]) {
  270.             if (i < len)
  271.                 printf("'%s'\n", substr(str, i + 1));
  272.             else
  273.                 expect = 1;
  274.             next;
  275.         }
  276.     }
  277. }
  278. END {
  279.     if (expect)
  280.         print "?";
  281. }
  282. EOF
  283.  
  284. : process the command line options
  285. set X `for arg in "$@"; do echo $arg; done | awk -f options.awk`
  286. eval "set $*"
  287. shift
  288. rm -f options.awk
  289.  
  290. : set up default values
  291. fastread=''
  292. reuseval=false
  293. config_sh=''
  294. alldone=''
  295. error=''
  296. silent=''
  297. extractsh=''
  298.  
  299. : option parsing
  300. while test $# -gt 0; do
  301.     case "$1" in
  302.     -d) shift; fastread=yes;;
  303.     -e) shift; alldone=cont;;
  304.     -f)
  305.         shift
  306.         cd ..
  307.         if test -r "$1"; then
  308.             config_sh="$1"
  309.         else
  310.             echo "Configure: cannot read config file $1." >&2
  311.             error=true
  312.         fi
  313.         cd UU
  314.         shift;;
  315.     -h) shift; error=true;;
  316.     -r) shift; reuseval=true;;
  317.     -s) shift; silent=true;;
  318.     -E) shift; alldone=exit;;
  319.     -S) shift; extractsh=true;;
  320.     -V) echo "Configure generated by metaconfig 3.0 PL9." >&2
  321.         exit 0;;
  322.     --) break;;
  323.     -*) echo "Configure: unknown option $1" >&2; shift; error=true;;
  324.     *) break;;
  325.     esac
  326. done
  327.  
  328. case "$error" in
  329. true)
  330.     cat >&2 <<EOM
  331. Usage: Configure [-dehrESV] [-f config.sh]
  332.   -d : use defaults for all answers.
  333.   -e : go on without questioning past the production of config.sh.
  334.   -f : specify an alternate default configuration file.
  335.   -h : print this help message and exit (with an error status).
  336.   -r : reuse C symbols value if possible (skips costly nm extraction).
  337.   -s : silent mode, only echoes questions and essential information.
  338.   -E : stop at the end of questions, after having produced config.sh.
  339.   -S : perform variable substitutions on all .SH files (can mix with -f)
  340.   -V : print version number and exit (with a zero status).
  341. EOM
  342.     exit 1
  343.     ;;
  344. esac
  345.  
  346. exec 4>&1
  347. case "$silent" in
  348. true) exec 1>/dev/null;;
  349. esac
  350.  
  351. case "$extractsh" in
  352. true)
  353.     case "$config_sh" in
  354.     '') config_sh='config.sh'; config='./config.sh';;
  355.     /*) config="$config_sh";;
  356.     *) config="./$config_sh";;
  357.     esac
  358.     echo " "
  359.     echo "Fetching answers from $config_sh..."
  360.     cd ..
  361.     . $config
  362.     echo " "
  363.     . ./UU/extract
  364.     rm -rf UU
  365.     echo "Done."
  366.     exit 0
  367.     ;;
  368. esac
  369.  
  370. : set package name
  371. package=mthreads
  372. first=`echo $package | sed -e 's/^\(.\).*/\1/'`
  373. last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
  374. spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last
  375. : Eunice requires " " instead of "", can you believe it
  376. echo " "
  377. : Here we go...
  378. echo "Beginning of configuration questions for $package."
  379.  
  380. define='define'
  381. undef='undef'
  382. smallmach='pdp11 i8086 z8000 i80286 iAPX286'
  383. rmlist=''
  384.  
  385. trap 'echo " "; rm -rf $rmlist; exit 1' 1 2 3 15
  386.  
  387. : We must find out about Eunice early
  388. eunicefix=':'
  389. if test -f /etc/unixtovms; then
  390.     eunicefix=/etc/unixtovms
  391. fi
  392. if test -f /etc/unixtovms.exe; then
  393.     eunicefix=/etc/unixtovms.exe
  394. fi
  395.  
  396. i_sysselct=''
  397. : change the next line if compiling for Xenix/286 on Xenix/386
  398. xlibpth='/usr/lib/386 /lib/386'
  399.  
  400. : general looking path for locating libraries
  401. libpth='/usr/lib/large /lib '$xlibpth' /lib/large'
  402. libpth=$libpth' /usr/lib/small /lib/small'
  403.  
  404. : no additional library wanted by default
  405. libswanted=''
  406.  
  407. large=''
  408. inclwanted='/usr/include/NET-5000'
  409.  
  410. libswanted='malloc bsd socket bsdipc sun net hdb bbn str inet nls nsl c_s intl x'
  411.  
  412. : Some greps do not return status, grrr.
  413. echo "grimblepritz" >grimble
  414. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  415.     contains=contains
  416. elif grep grimblepritz grimble >/dev/null 2>&1 ; then
  417.     contains=grep
  418. else
  419.     contains=contains
  420. fi
  421. rm -f grimble
  422. : the following should work in any shell
  423. case "$contains" in
  424. contains*)
  425.     echo " "
  426.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  427.     cat >contains <<'EOSS'
  428. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  429. EOSS
  430. chmod +x contains
  431. esac
  432.  
  433. : first determine how to suppress newline on echo command
  434. echo " "
  435. echo "Checking echo to see how to suppress newlines..."
  436. (echo "hi there\c" ; echo " ") >.echotmp
  437. if $contains c .echotmp >/dev/null 2>&1 ; then
  438.     echo "...using -n."
  439.     n='-n'
  440.     c=''
  441. else
  442.     cat <<'EOM'
  443. ...using \c
  444. EOM
  445.     n=''
  446.     c='\c'
  447. fi
  448. echo $n "The star should be here-->$c"
  449. echo '*'
  450. rm -f .echotmp
  451.  
  452. : Now test for existence of everything in MANIFEST
  453. echo " "
  454. if test -f ../MANIFEST; then
  455.     echo "First let's make sure your kit is complete.  Checking..." >&4
  456.     awk '$1 !~ /PACK[A-Z]+/ {print $1}' ../MANIFEST | split -50
  457.     rm -f missing
  458.     for filelist in x??; do
  459.         (cd ..; ls `cat UU/$filelist` >/dev/null 2>>UU/missing)
  460.     done
  461.     if test -s missing; then
  462.         cat missing >&4
  463.         cat >&4 <<'EOM'
  464.  
  465. THIS PACKAGE SEEMS TO BE INCOMPLETE.
  466.  
  467. You have the option of continuing the configuration process, despite the
  468. distinct possibility that your kit is damaged, by typing 'y'es.  If you
  469. do, don't blame me if something goes wrong.  I advise you to type 'n'o
  470. and contact the author (davison@borland.com).
  471.  
  472. EOM
  473.         echo $n "Continue? [n] $c" >&4
  474.         read ans
  475.         case "$ans" in
  476.         y*)
  477.             echo "Continuing..." >&4
  478.             rm -f missing
  479.             ;;
  480.         *)
  481.             echo "ABORTING..." >&4
  482.             kill $$
  483.             ;;
  484.         esac
  485.     else
  486.         echo "Looks good..." >&4
  487.     fi
  488. else
  489.     echo "There is no MANIFEST file.  I hope your kit is complete !"
  490. fi
  491. rm -f missing x??
  492.  
  493. : compute the number of columns on the terminal for proper question formatting
  494. case "$COLUMNS" in
  495. '') COLUMNS='80';;
  496. esac
  497.  
  498. : set up the echo used in my read
  499. myecho="case \"\$xxxm\" in
  500. '') echo $n \"\$rp $c\" >&4;;
  501. *) case \"\$rp\" in
  502.     '') echo $n \"[\$xxxm] $c\";;
  503.     *)
  504.         if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
  505.             echo \"\$rp\" >&4
  506.             echo $n \"[\$xxxm] $c\" >&4
  507.         else
  508.             echo $n \"\$rp [\$xxxm] $c\" >&4
  509.         fi
  510.         ;;
  511.     esac;;
  512. esac"
  513.  
  514. : now set up to do reads with possible shell escape and default assignment
  515. cat <<EOSC >myread
  516. xxxm=\$dflt
  517. $myecho
  518. ans='!'
  519. case "\$fastread" in
  520. yes) case "\$dflt" in
  521.     '') ;;
  522.     *) ans='';
  523.         case "\$silent-\$rp" in
  524.         true-) ;;
  525.         *) echo " " >&4;;
  526.         esac;;
  527.     esac;;
  528. *) case "\$silent" in
  529.     true) case "\$rp" in
  530.         '') ans='';;
  531.         esac;;
  532.     esac;;
  533. esac
  534. while expr "X\$ans" : "X!" >/dev/null; do
  535.     read answ
  536.     set x \$xxxm
  537.     shift
  538.     aok=''; eval "ans=\"\$answ\"" && aok=y
  539.     case  "\$answ" in
  540.     "\$ans")
  541.         case "\$ans" in
  542.         "!")
  543.             sh 1>&4
  544.             echo " "
  545.             $myecho
  546.             ;;
  547.         !*)
  548.             set x \`expr "X\$ans" : "X!\(.*\)\$"\`
  549.             shift
  550.             sh 1>&4 -c "\$*"
  551.             echo " "
  552.             $myecho
  553.             ;;
  554.         esac;;
  555.     *)
  556.         case "\$aok" in
  557.         y)
  558.             echo "*** Substitution done -- please confirm."
  559.             xxxm="\$ans"
  560.             ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
  561.             xxxm="\$ans"
  562.             ans=!
  563.             ;;
  564.         *)
  565.             echo "*** Error -- try again."
  566.             ans=!
  567.             ;;
  568.         esac
  569.         $myecho
  570.         ;;
  571.     esac
  572.     case "\$ans\$xxxm\$nostick" in
  573.     '')
  574.         ans=!
  575.         $myecho
  576.         ;;
  577.     esac
  578. done
  579. case "\$ans" in
  580. '') ans="\$xxxm";;
  581. esac
  582. EOSC
  583.  
  584. : create .config dir to save info across Configure sessions
  585. test -d ../.config || mkdir ../.config
  586. cat >../.config/README <<EOF
  587. This directory created by Configure to save information that should
  588. persist across sessions.
  589.  
  590. You may safely delete it if you wish.
  591. EOF
  592.  
  593. : general instructions
  594. needman=true
  595. firsttime=true
  596. user=`( (logname) 2>/dev/null || whoami) 2>&1`
  597. if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
  598.     firsttime=false
  599.     echo " "
  600.     rp='Would you like to see the instructions?'
  601.     dflt=n
  602.     . ./myread
  603.     case "$ans" in
  604.     [yY]*) ;;
  605.     *) needman=false;;
  606.     esac
  607. fi
  608. if $needman; then
  609.     cat <<EOH
  610.  
  611. This installation shell script will examine your system and ask you questions
  612. to determine how the mthreads package should be installed. If you get
  613. stuck on a question, you may use a ! shell escape to start a subshell or
  614. execute a command.  Many of the questions will have default answers in square
  615. brackets; typing carriage return will give you the default.
  616.  
  617. On some of the questions which ask for file or directory names you are allowed
  618. to use the ~name construct to specify the login directory belonging to "name",
  619. even if you don't have a shell which knows about that.  Questions where this is
  620. allowed will be marked "(~name ok)".
  621.  
  622. EOH
  623.     rp=''
  624.     dflt='Type carriage return to continue'
  625.     . ./myread
  626.     cat <<'EOH'
  627.  
  628. The prompter used in this script allows you to use shell variables and
  629. backticks in your answers.  You may use $1, $2, etc...  to refer to the words
  630. in the default answer, as if the default line was a set of arguments given to a
  631. script shell.  This means you may also use $* to repeat the whole default line,
  632. so you do not have to re-type everything to add something to the default.
  633.  
  634. Everytime there is a substitution, you will have to confirm.  If there is an
  635. error (e.g. an unmatched backtick), the default answer will remain unchanged
  636. and you will be prompted again.
  637.  
  638. If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
  639. the questions and use the computed defaults (or the previous answers if there
  640. was already a config.sh file). Type 'Configure -h' for a list of options.
  641.  
  642. EOH
  643.     . ./myread
  644.     cat <<EOH
  645.  
  646. Much effort has been expended to ensure that this shell script will run on any
  647. Unix system.  If despite that it blows up on yours, your best bet is to edit
  648. Configure and run it again.  Also, let me (davison@borland.com)
  649. know how I blew it.  If you can't run Configure for some reason, you'll have to
  650. generate a config.sh file by hand.
  651.  
  652. This installation script affects things in two ways:
  653.  
  654. 1) it may do direct variable substitutions on some of the files included
  655.    in this kit.
  656. 2) it builds a config.h file for inclusion in C programs.  You may edit
  657.    any of these files as the need arises after running this script.
  658.  
  659. If you make a mistake on a question, there is no easy way to back up to it
  660. currently.  The easiest thing to do is to edit config.sh and rerun all the SH
  661. files.  Configure will offer to let you do this before it runs the SH files.
  662.  
  663. EOH
  664.     dflt='Type carriage return to continue'
  665.     . ./myread
  666.     case "$firsttime" in
  667.     true) echo $user >>../.config/instruct;;
  668.     esac
  669. fi
  670.  
  671. : see if sh knows # comments
  672. echo " "
  673. echo "Checking your sh to see if it knows about # comments..." >&4
  674. if sh -c '#' >/dev/null 2>&1 ; then
  675.     echo "Your sh handles # comments correctly."
  676.     shsharp=true
  677.     spitshell=cat
  678.     echo " "
  679.     echo "Okay, let's see if #! works on this system..."
  680.     echo "#!/bin/cat" >try
  681.     $eunicefix try
  682.     chmod +x try
  683.     ./try > today
  684.     if test -s today; then
  685.         echo "It does."
  686.         sharpbang='#!'
  687.     else
  688.         echo "#! /bin/cat" > try
  689.         $eunicefix try
  690.         chmod +x try
  691.         ./try > today
  692.         if test -s today; then
  693.             echo "It does."
  694.             sharpbang='#! '
  695.         else
  696.             echo "It's just a comment."
  697.             sharpbang=': use '
  698.         fi
  699.     fi
  700. else
  701.     echo "Your sh doesn't grok # comments--I will strip them later on."
  702.     shsharp=false
  703.     echo "exec grep -v '^[     ]*#'" >spitshell
  704.     chmod +x spitshell
  705.     $eunicefix spitshell
  706.     spitshell=`pwd`/spitshell
  707.     echo "I presume that if # doesn't work, #! won't work either!"
  708.     sharpbang=': use '
  709. fi
  710. rm -f try today
  711.  
  712. : figure out how to guarantee sh startup
  713. echo " "
  714. echo "Checking out how to guarantee sh startup..." >&4
  715. case "$SYSTYPE" in
  716. *bsd*|sys5*) startsh=$sharpbang"/$SYSTYPE/bin/sh";;
  717. *) startsh=$sharpbang'/bin/sh';;
  718. esac
  719. echo "Let's see if '$startsh' works..."
  720. cat >try <<EOSS
  721. $startsh
  722. set abc
  723. test "$?abc" != 1
  724. EOSS
  725.  
  726. chmod +x try
  727. $eunicefix try
  728. if ./try; then
  729.     echo "Yup, it does."
  730. else
  731. echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  732. fi
  733. rm -f try
  734.  
  735. : find out where common programs are
  736. echo " "
  737. echo "Locating common programs..." >&4
  738. cat <<EOSC >loc
  739. $startsh
  740. case \$# in
  741. 0) exit 1;;
  742. esac
  743. thing=\$1
  744. shift
  745. dflt=\$1
  746. shift
  747. for dir in \$*; do
  748.     case "\$thing" in
  749.     .)
  750.     if test -d \$dir/\$thing; then
  751.         echo \$dir
  752.         exit 0
  753.     fi
  754.     ;;
  755.     *)
  756.     if test -f \$dir/\$thing; then
  757.         echo \$dir/\$thing
  758.         exit 0
  759.     elif test -f \$dir/\$thing.exe; then
  760.         : on Eunice apparently
  761.         echo \$dir/\$thing
  762.         exit 0
  763.     fi
  764.     ;;
  765.     esac
  766. done
  767. echo \$dflt
  768. exit 1
  769. EOSC
  770. chmod +x loc
  771. $eunicefix loc
  772. loclist="
  773. awk
  774. cat
  775. echo
  776. expr
  777. grep
  778. mkdir
  779. mv
  780. rm
  781. sed
  782. sort
  783. tr
  784. uniq
  785. "
  786. trylist="
  787. Mcc
  788. cpp
  789. date
  790. egrep
  791. nroff
  792. test
  793. uname
  794. "
  795. pth=`echo $PATH | sed -e 's/:/ /g'`
  796. pth="$pth /lib /usr/lib"
  797. for file in $loclist; do
  798.     xxx=`./loc $file $file $pth`
  799.     eval $file=$xxx
  800.     eval _$file=$xxx
  801.     case "$xxx" in
  802.     /*)
  803.         echo $file is in $xxx.
  804.         ;;
  805.     *)
  806.         echo "I don't know where $file is.  I hope it's in everyone's PATH."
  807.         ;;
  808.     esac
  809. done
  810. echo " "
  811. echo "Don't worry if any of the following aren't found..."
  812. say=offhand
  813. for file in $trylist; do
  814.     xxx=`./loc $file $file $pth`
  815.     eval $file=$xxx
  816.     eval _$file=$xxx
  817.     case "$xxx" in
  818.     /*)
  819.         echo $file is in $xxx.
  820.         ;;
  821.     *)
  822.         echo "I don't see $file out there, $say."
  823.         say=either
  824.         ;;
  825.     esac
  826. done
  827. case "$egrep" in
  828. egrep)
  829.     echo "Substituting grep for egrep."
  830.     egrep=$grep
  831.     ;;
  832. esac
  833. case "$test" in
  834. test)
  835.     echo "Hopefully test is built into your sh."
  836.     ;;
  837. *)
  838.     if sh -c "PATH= test true" >/dev/null 2>&1; then
  839.         echo "Using the test built into your sh."
  840.         test=test
  841.     fi
  842.     ;;
  843. esac
  844. case "$echo" in
  845. echo)
  846.     echo "Hopefully echo is built into your sh."
  847.     ;;
  848. *)
  849.     echo " "
  850. echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
  851.     $echo $n "hi there$c" >foo1
  852.     echo $n "hi there$c" >foo2
  853.     if cmp foo1 foo2 >/dev/null 2>&1; then
  854.         echo "They are compatible.  In fact, they may be identical."
  855.     else
  856.         case "$n" in
  857.         '-n') n='' c='\c';;
  858.         *) n='-n' c='';;
  859.         esac
  860.         cat <<FOO
  861. They are not compatible!  You are probably running ksh on a non-USG system.
  862. I'll have to use $echo instead of the builtin, since Bourne shell doesn't
  863. have echo built in and we may have to run some Bourne shell scripts.  That
  864. means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
  865.  
  866. FOO
  867.         $echo $n "The star should be here-->$c"
  868.         $echo "*"
  869.     fi
  870.     $rm -f foo1 foo2
  871.     ;;
  872. esac
  873.  
  874. : Try to determine whether config.sh was made on this system
  875. case "$config_sh" in
  876. '')
  877. myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
  878. dflt=n
  879. if test "$fastread" = yes; then
  880.     dflt=y
  881. elif test -f ../config.sh; then
  882.     oldmyuname=''
  883.     if $contains myuname= ../config.sh >/dev/null 2>&1; then
  884.         eval "old`grep myuname= ../config.sh`"
  885.     fi
  886.     if test "X$myuname" = "X$oldmyuname"; then
  887.         dflt=y
  888.     fi
  889. fi
  890.  
  891. : Get old answers from old config file if Configure was run on the
  892. : same system, otherwise use the hints.
  893. hint=default
  894. cd ..
  895. if test -f config.sh; then
  896.     echo " "
  897.     rp="I see a config.sh file.  Do you want to use it to set the defaults?"
  898.     . UU/myread
  899.     case "$ans" in
  900.     n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
  901.     *)  echo "Fetching default answers from your old config.sh file..." >&4
  902.         tmp="$n"
  903.         tans="$c"
  904.         . ./config.sh
  905.         cp config.sh UU
  906.         n="$tmp"
  907.         c="$tans"
  908.         hint=previous
  909.         ;;
  910.     esac
  911. fi
  912. if test ! -f config.sh; then
  913.     $cat <<EOM
  914.  
  915. First time through, eh?  I have some defaults handy for the following systems:
  916.  
  917. EOM
  918.     cd hints; ls -C *.sh | $sed 's/\.sh/   /g' >&4
  919.     dflt=''
  920.     : Half the following guesses are probably wrong... If you have better
  921.     : tests or hints, please send them to davison@borland.com
  922.     : The metaconfig authors would also appreciate a copy...
  923.     $test -f /vmunix && $test -f /usr/convex/spucmd && dflt="$dflt convexos"
  924.     $test -f /irix && dflt="$dflt sgi"
  925.     $test -f /xenix && dflt="$dflt sco_xenix"
  926.     $test -f /dynix && dflt="$dflt dynix"
  927.     $test -f /bin/mips && /bin/mips && dflt="$dflt mips"
  928.     $test -d /NextApps && test -f /usr/adm/software_version && dflt="$dflt next"
  929.     if $test -f $uname; then
  930.         set `$uname -a | tr '[A-Z]' '[a-z]'`
  931.  
  932.         $test -f $5.sh && dflt="$dflt $5"
  933.  
  934.         case "$5" in
  935.         mips*) dflt="$dflt mips";;
  936.         [23]100) dflt="$dflt mips";;
  937.         next*) dflt="$dflt next" ;;
  938.         esac
  939.  
  940.         case "$1" in
  941.         aix) dflt="$dflt aix_rs" ;;
  942.         sunos)    case "$3" in
  943.             4.1*) dflt="$dflt sunos_4_1" ;;
  944.             esac
  945.             ;;
  946.         dgux) dflt="$dflt dgux" ;;
  947.         hp*ux) dflt="$dflt hpux" ;;
  948.         next) dflt="$dflt next" ;;
  949.         irix) dflt="$dflt sgi" ;;
  950.         convexos) dflt="$dflt convexos";;
  951.         $2) if $test -f /usr/lib/sysadm/sysadm.menu; then
  952.             if $test ! -f /etc/copyrights/01.sco; then
  953.                 set 3 2 0
  954.             else
  955.                 set `uname -X 2>&1 | grep Release`
  956.                 if test "x$1" != "xRelease"; then
  957.                 set 3 2 1
  958.                 else
  959.                 set `echo $3 | sed 's/[^0-9]/ /g'`
  960.                 fi
  961.             fi
  962.             if $test -f sco_$1_$2_$3.sh; then
  963.                 dflt="$dflt sco_$1_$2_$3"
  964.             elif $test -f sco_$1_$2.sh; then
  965.                 dflt="$dflt sco_$1_$2"
  966.             elif $test -f sco_$1.sh; then
  967.                 dflt="$dflt sco_$1"
  968.             fi
  969.             fi ;;
  970.         esac
  971.     fi
  972.     set X `echo $dflt | tr ' ' '\012' | sort | uniq`
  973.     shift
  974.     dflt=''
  975.     for file in $*; do
  976.         if $test -f "$file.sh"; then
  977.             dflt="$dflt $file"
  978.         fi
  979.     done
  980.     set X $dflt
  981.     shift
  982.     dflt=${1+"$@"}
  983.     case "$dflt" in
  984.     '') dflt=none;;
  985.     esac
  986.     $cat <<EOM
  987.  
  988. You may give one or more space-separated answers, or "none" if appropriate.
  989. If your OS version has no hints, DO NOT give a wrong version -- say "none".
  990.  
  991. EOM
  992.     rp="Which of these apply, if any?"
  993.     . ../UU/myread
  994.     for file in $ans; do
  995.         if $test -f $file.sh; then
  996.             . ./$file.sh
  997.             $cat $file.sh >> ../UU/config.sh
  998.         elif $test X$ans = X -o X$ans = Xnone ; then
  999.             :
  1000.         else
  1001.             echo "$file.sh does not exist -- ignored"
  1002.         fi
  1003.     done
  1004.     hint=recommended
  1005.     cd ..
  1006. fi
  1007. cd UU
  1008. ;;
  1009. *)
  1010.     echo " "
  1011.     echo "Fetching default answers from $config_sh..." >&4
  1012.     tmp="$n"
  1013.     tans="$c"
  1014.     cd ..
  1015.     cp $config_sh config.sh 2>/dev/null
  1016.     . ./config.sh
  1017.     cd UU
  1018.     cp ../config.sh .
  1019.     n="$tmp"
  1020.     c="$tans"
  1021.     hint=previous
  1022.     ;;
  1023. esac
  1024.  
  1025. : Restore computed paths
  1026. for file in $loclist $trylist; do
  1027.     eval $file="\$_$file"
  1028. done
  1029.  
  1030. : who configured the system
  1031. cf_time=`$date 2>&1`
  1032. cf_by=`( (logname) 2>/dev/null || whoami) 2>&1`
  1033.  
  1034. : set up shell script to do ~ expansion
  1035. cat >filexp <<EOSS
  1036. $startsh
  1037. : expand filename
  1038. case "\$1" in
  1039.  ~/*|~)
  1040.     echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  1041.     ;;
  1042.  ~*)
  1043.     if $test -f /bin/csh; then
  1044.         /bin/csh -f -c "glob \$1"
  1045.         failed=$?
  1046.         echo ""
  1047.         exit \$failed
  1048.     else
  1049.         name=\`$expr x\$1 : '..\([^/]*\)'\`
  1050.         dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  1051.         if $test ! -d "\$dir"; then
  1052.             me=\`basename \$0\`
  1053.             echo "\$me: can't locate home directory for: \$name" >&2
  1054.             exit 1
  1055.         fi
  1056.         case "\$1" in
  1057.         */*)
  1058.             echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  1059.             ;;
  1060.         *)
  1061.             echo \$dir
  1062.             ;;
  1063.         esac
  1064.     fi
  1065.     ;;
  1066. *)
  1067.     echo \$1
  1068.     ;;
  1069. esac
  1070. EOSS
  1071. chmod +x filexp
  1072. $eunicefix filexp
  1073.  
  1074. : check if NNTP is to be used
  1075. case "$d_nntp" in
  1076. "$define") dflt="y";;
  1077. *)       dflt="n";;
  1078. esac
  1079. $echo " "
  1080. rp="Do you want mthreads to access news via NNTP?"
  1081. . myread
  1082. case "$ans" in
  1083. n*)    d_nntp="$undef";;
  1084. y*)    d_nntp="$define"
  1085.     newsspool=/tmp
  1086.     $echo "net.foobar 00001 00001 y" > .falseactive
  1087.     case "$servername" in
  1088.     '')  dflt="no default" ;;
  1089.     *)   dflt="$servername";;
  1090.     esac
  1091.     $cat <<EOM
  1092.  
  1093. $spackage needs to know what machine you wish to use as a news server.  You
  1094. can specify a machine name directly, or a filename from which to read
  1095. the name (start the name with a slash or a tilde to distinguish it).
  1096. Note also that the environment variable NNTPSERVER can be used to
  1097. override this default setting.
  1098.  
  1099. EOM
  1100.  
  1101.     rp="Enter a file name (~name ok) or machine name:"
  1102.     . myread
  1103.     ans=`./filexp "$ans"`
  1104.     case "$ans" in
  1105.     /*) if $test ! -f $ans; then
  1106.         $echo "(You'll need to create $ans before $package will work.)"
  1107.         fi;;
  1108.     esac
  1109.     servername="$ans"
  1110. esac
  1111.  
  1112. : decide how portable to be
  1113. case "$d_portable" in
  1114. "$define") dflt=y;;
  1115. *)    dflt=n;;
  1116. esac
  1117. $cat <<'EOH'
  1118.  
  1119. I can set things up so that your shell scripts and binaries are more portable,
  1120. at what may be a noticable cost in performance.  In particular, if you
  1121. ask to be portable, the following happens:
  1122.  
  1123.      1) Shell scripts will rely on the PATH variable rather than using
  1124.     the paths derived above.
  1125.      2) ~username interpretations will be done at run time rather than
  1126.     by Configure.
  1127.  
  1128. EOH
  1129. rp="Do you expect to run these scripts and binaries on multiple machines?"
  1130. . ./myread
  1131. case "$ans" in
  1132.     y*) d_portable="$define"
  1133.     for file in $loclist; do
  1134.         eval $file=$file
  1135.     done
  1136.     ;;
  1137.     *)  d_portable="$undef" ;;
  1138. esac
  1139.  
  1140. : now set up to get a file name
  1141. cat <<'EOSC' >getfile
  1142. tilde=''
  1143. fullpath=''
  1144. already=''
  1145. skip=''
  1146. none_ok=''
  1147. exp_file=''
  1148. orig_rp="$rp"
  1149. orig_dflt="$dflt"
  1150.  
  1151. case "$fn" in
  1152. *~*) tilde=true;;
  1153. esac
  1154. case "$fn" in
  1155. */*) fullpath=true;;
  1156. esac
  1157. case "$fn" in
  1158. *+*) skip=true;;
  1159. esac
  1160. case "$fn" in
  1161. *n*) none_ok=true;;
  1162. esac
  1163. case "$fn" in
  1164. *e*) exp_file=true;;
  1165. esac
  1166.  
  1167. case "$fn" in
  1168. *f*) type='File';;
  1169. *d*) type='Directory';;
  1170. *l*) type='Locate'; fn=`expr $fn : '.*:\(.*\)'`;;
  1171. esac
  1172.  
  1173. what="$type"
  1174. case "$what" in
  1175. Locate) what='File';;
  1176. esac
  1177.  
  1178. case "$exp_file" in
  1179. '')
  1180.     case "$d_portable" in
  1181.     "$define") ;;
  1182.     *) exp_file=true;;
  1183.     esac
  1184.     ;;
  1185. esac
  1186.  
  1187. cd ..
  1188. while test "$type"; do
  1189.     redo=''
  1190.     rp="$orig_rp"
  1191.     dflt="$orig_dflt"
  1192.     case "$tilde" in
  1193.     true) rp="$rp (~name ok)";;
  1194.     esac
  1195.     . UU/myread
  1196.     case "$ans" in
  1197.     none)
  1198.         value=''
  1199.         ansexp=''
  1200.         case "$none_ok" in
  1201.         true) type='';;
  1202.         esac
  1203.         ;;
  1204.     *)
  1205.         case "$tilde" in
  1206.         '') value="$ans"
  1207.             ansexp="$ans";;
  1208.         *)
  1209.             value=`UU/filexp $ans`
  1210.             case $? in
  1211.             0)
  1212.                 if test "$ans" != "$value"; then
  1213.                     echo "(That is $value on this particular system.)"
  1214.                 fi
  1215.                 ;;
  1216.             *) value="$ans";;
  1217.             esac
  1218.             ansexp="$value"
  1219.             case "$exp_file" in
  1220.             '') value="$ans";;
  1221.             esac
  1222.             ;;
  1223.         esac
  1224.         case "$fullpath" in
  1225.         true)
  1226.             case "$ansexp" in
  1227.             /*) value="$ansexp" ;;
  1228.             *)
  1229.                 redo=true
  1230.                 case "$already" in
  1231.                 true)
  1232.                 echo "I shall only accept a full path name, as in /bin/ls." >&4
  1233.                 echo "Use a ! shell escape if you wish to check pathnames." >&4
  1234.                     ;;
  1235.                 *)
  1236.                 echo "Please give a full path name, starting with slash." >&4
  1237.                     case "$tilde" in
  1238.                     true)
  1239.                 echo "Note that using ~name is ok provided it expands well." >&4
  1240.                         already=true
  1241.                         ;;
  1242.                     esac
  1243.                 esac
  1244.                 ;;
  1245.             esac
  1246.             ;;
  1247.         esac
  1248.         case "$redo" in
  1249.         '')
  1250.             case "$type" in
  1251.             File)
  1252.                 if test -f "$ansexp"; then
  1253.                     type=''
  1254.                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
  1255.                 then
  1256.                     echo "($value is not a plain file, but that's ok.)"
  1257.                     type=''
  1258.                 fi
  1259.                 ;;
  1260.             Directory)
  1261.                 if test -d "$ansexp"; then
  1262.                     type=''
  1263.                 fi
  1264.                 ;;
  1265.             Locate)
  1266.                 if test -d "$value"; then
  1267.                     echo "(Looking for $fn in directory $value.)"
  1268.                     value="$value/$fn"
  1269.                 fi
  1270.                 if test -f "$value"; then
  1271.                     type=''
  1272.                 fi
  1273.                 ;;
  1274.             esac
  1275.  
  1276.             case "$skip" in
  1277.             true) type='';
  1278.             esac
  1279.  
  1280.             case "$type" in
  1281.             '') ;;
  1282.             *)
  1283.                 if test "$fastread" = yes; then
  1284.                     dflt=y
  1285.                 else
  1286.                     dflt=n
  1287.                 fi
  1288.                 rp="$what $value doesn't exist.  Use that name anyway?"
  1289.                 . UU/myread
  1290.                 dflt=''
  1291.                 case "$ans" in
  1292.                 y*) type='';;
  1293.                 *) echo " ";;
  1294.                 esac
  1295.                 ;;
  1296.             esac
  1297.             ;;
  1298.         esac
  1299.         ;;
  1300.     esac
  1301. done
  1302. cd UU
  1303. ans="$value"
  1304. rp="$orig_rp"
  1305. dflt="$orig_dflt"
  1306. EOSC
  1307.  
  1308. : figure out news library
  1309. case "$d_nntp" in
  1310. define) newslib=/tmp
  1311.     newslibexp=/tmp
  1312.     ;;
  1313. *)    case "$newslib" in
  1314.     '') dflt=/usr/lib/news;;
  1315.     *)  dflt=$newslib;;
  1316.     esac
  1317.     $echo " "
  1318.     fn=d~
  1319.     rp='Where is the news library directory?'
  1320.     . ./getfile
  1321.     newslib="$ans"
  1322.     newslibexp=`./filexp $newslib`
  1323. esac
  1324.  
  1325. : locate active file and active.times file
  1326. $echo " "
  1327. case "$d_nntp" in
  1328. define) active=none
  1329.     myactive=.falseactive
  1330.     : check for active.times
  1331.     case "$acttimes" in
  1332.     ''|none) dflt="n";;
  1333.     *)       dflt="y";;
  1334.     esac
  1335.     cat <<'EOM'
  1336.  
  1337. If your server maintains an accurate "active.times" file, trn can make use
  1338. of the NEWGROUPS call in NNTP to find new groups instead of using the old
  1339. method of adding all groups not listed in your .newsrc.  If you aren't sure,
  1340. guess and see if you get notified of the new groups as they are created.
  1341.  
  1342. EOM
  1343.     rp="Does your server support a reliable NEWGROUPS call?"
  1344.     . ./myread
  1345.     case "$ans" in
  1346.     y*) acttimes="nntp" d_acttimes="$define";;
  1347.     *)  acttimes='none' d_acttimes="$undef";;
  1348.     esac
  1349.     ;;
  1350. *)    case "$active" in
  1351.     '') dflt=$newslib/active ;;
  1352.     *)  dflt="$active";;
  1353.     esac
  1354.     fn=l~:active
  1355.     rp='Where is the active file?'
  1356.     . ./getfile
  1357.     active="$ans"
  1358.     myactive=`./filexp $active`
  1359.     : check for active.times
  1360.     case "$acttimes" in
  1361.     ''|nntp) dflt="${active}.times";;
  1362.     *)       dflt="$acttimes";;
  1363.     esac
  1364.     $cat <<'EOM'
  1365.  
  1366. If your news system maintains an "active.times" file, trn can use it for a
  1367. fast new-group check.  If it's not around, answer "none" and the active
  1368. file will be scanned for new groups when it changes size.
  1369.  
  1370. EOM
  1371.     fn=ln~:active.times
  1372.     rp='The full pathname of active.times or "none"?'
  1373.     . ./getfile
  1374.     acttimes="$ans"
  1375.     case "$acttimes" in
  1376.     '') acttimes=none d_acttimes="$undef";;
  1377.     *) d_acttimes="$define";;
  1378.     esac
  1379. esac
  1380.  
  1381. : determine where manual pages are on this system
  1382. echo " "
  1383. case "$sysman" in
  1384. '') 
  1385.     syspath='/usr/man/man1 /usr/man/man1 /usr/man/mann'
  1386.     syspath="$syspath /usr/man/manl /usr/man/local/man1"
  1387.     syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
  1388.     syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
  1389.     syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
  1390.     syspath="$syspath /usr/man/man.L /local/man/man1"
  1391.     sysman=`./loc . $syspath`
  1392.     ;;
  1393. esac
  1394. if $test -d "$sysman"; then
  1395.     echo "System manual is in $sysman." >&4
  1396. else
  1397.     echo "Could not find manual pages in source form." >&4
  1398. fi
  1399.  
  1400. : make some quick guesses about what we are up against
  1401. echo " "
  1402. $echo $n "Hmm...  $c"
  1403. echo exit 1 >bsd
  1404. echo exit 1 >usg
  1405. echo exit 1 >v7
  1406. echo exit 1 >osf1
  1407. echo exit 1 >eunice
  1408. echo exit 1 >xenix
  1409. echo exit 1 >venix
  1410. $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
  1411. if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
  1412. then
  1413.     echo "Looks kind of like an OSF/1 system, but we'll see..."
  1414.     echo exit 0 >osf1
  1415. elif test `echo abc | tr a-z A-Z` = Abc ; then
  1416.     xxx=`./loc addbib blurfl $pth`
  1417.     if $test -f $xxx; then
  1418.     echo "Looks kind of like a USG system with BSD features, but we'll see..."
  1419.         echo exit 0 >bsd
  1420.         echo exit 0 >usg
  1421.     else
  1422.         if $contains SIGTSTP foo >/dev/null 2>&1 ; then
  1423.             echo "Looks kind of like an extended USG system, but we'll see..."
  1424.         else
  1425.             echo "Looks kind of like a USG system, but we'll see..."
  1426.         fi
  1427.         echo exit 0 >usg
  1428.     fi
  1429.     d_bsd="$undef"
  1430. elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  1431.     echo "Looks kind of like a BSD system, but we'll see..."
  1432.     d_bsd="$define"
  1433.     echo exit 0 >bsd
  1434. else
  1435.     echo "Looks kind of like a Version 7 system, but we'll see..."
  1436.     d_bsd="$undef"
  1437.     echo exit 0 >v7
  1438. fi
  1439. case "$eunicefix" in
  1440. *unixtovms*)
  1441.     $cat <<'EOI'
  1442. There is, however, a strange, musty smell in the air that reminds me of
  1443. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  1444. EOI
  1445.     echo exit 0 >eunice
  1446.     d_eunice="$define"
  1447. : it so happens the Eunice I know will not run shell scripts in Unix format
  1448.     ;;
  1449. *)
  1450.     echo " "
  1451.     echo "Congratulations.  You aren't running Eunice."
  1452.     d_eunice="$undef"
  1453.     ;;
  1454. esac
  1455. if test -f /xenix; then
  1456.     echo "Actually, this looks more like a XENIX system..."
  1457.     echo exit 0 >xenix
  1458.     d_xenix="$define"
  1459. else
  1460.     echo " "
  1461.     echo "It's not Xenix..."
  1462.     d_xenix="$undef"
  1463. fi
  1464. chmod +x xenix
  1465. $eunicefix xenix
  1466. if test -f /venix; then
  1467.     echo "Actually, this looks more like a VENIX system..."
  1468.     echo exit 0 >venix
  1469. else
  1470.     echo " "
  1471.     if xenix; then
  1472.         : null
  1473.     else
  1474.         echo "Nor is it Venix..."
  1475.     fi
  1476. fi
  1477. chmod +x bsd usg v7 osf1 eunice xenix venix
  1478. $eunicefix bsd usg v7 osf1 eunice xenix venix
  1479. $rm -f foo
  1480.  
  1481. : see if we need a special compiler
  1482. echo " "
  1483. if usg; then
  1484.     case "$cc" in
  1485.     '') case "$Mcc" in
  1486.         /*) dflt='Mcc';;
  1487.         *) case "$large" in
  1488.             -M*) dflt='cc';;
  1489.             *)    if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
  1490.                     if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
  1491.                         dflt='cc'
  1492.                     else
  1493.                         dflt='cc -M'
  1494.                     fi
  1495.                 else
  1496.                     dflt='cc'
  1497.                 fi;;
  1498.             esac;;
  1499.         esac;;
  1500.     *)  dflt="$cc";;
  1501.     esac
  1502.     $cat <<'EOM'
  1503. On some systems the default C compiler will not resolve multiple global
  1504. references that happen to have the same name.  On some such systems the "Mcc"
  1505. command may be used to force these to be resolved.  On other systems a "cc -M"
  1506. command is required.  (Note that the -M flag on other systems indicates a
  1507. memory model to use!) If you have the Gnu C compiler, you might wish to use
  1508. that instead.
  1509.  
  1510. EOM
  1511.     rp="What command will force resolution on this system?"
  1512.     . ./myread
  1513.     cc="$ans"
  1514. else
  1515.     case "$cc" in
  1516.     '') dflt=cc;;
  1517.     *) dflt="$cc";;
  1518.     esac
  1519.     rp="Use which C compiler?"
  1520.     . ./myread
  1521.     cc="$ans"
  1522. fi
  1523. case "$cc" in
  1524. gcc*) cpp=`./loc gcc-cpp $cpp $pth`;;
  1525. esac
  1526.  
  1527. : What should the include directory be ?
  1528. echo " "
  1529. $echo $n "Hmm...  $c"
  1530. case "$usrinc" in
  1531. '') dflt='/usr/include';;
  1532. *) dflt=$usrinc;;
  1533. esac
  1534. incpath=''
  1535. mips_type=''
  1536. if $test -f /bin/mips && /bin/mips; then
  1537.     echo "Looks like a MIPS system..."
  1538.     $cat >usr.c <<'EOCP'
  1539. #ifdef SYSTYPE_BSD43
  1540. /bsd43
  1541. #endif
  1542. EOCP
  1543.     if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
  1544.         dflt='/bsd43/usr/include'
  1545.         incpath='/bsd43'
  1546.         mips_type='BSD 4.3'
  1547.     else
  1548.         mips_type='System V'
  1549.     fi
  1550.     $rm -f usr.c usr.out
  1551.     echo "and you're compiling with the $mips_type compiler and libraries."
  1552. else
  1553.     echo "Doesn't look like a MIPS system."
  1554.     echo "exit 1" >mips
  1555.     chmod +x mips
  1556.     $eunicefix mips
  1557. fi
  1558. echo " "
  1559. fn=d/
  1560. rp='Where are the include files you want to use?'
  1561. . ./getfile
  1562. usrinc="$ans"
  1563.  
  1564. : Set private lib path
  1565. case "$plibpth" in
  1566. '') if mips; then
  1567.         plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
  1568.     else
  1569.         plibpth="/usr/ccs/lib /usr/lib /usr/ucblib /usr/local/lib"
  1570.     fi;;
  1571. esac
  1572. libpth="$plibpth $libpth"
  1573.  
  1574. : Looking for optional libraries
  1575. echo " "
  1576. echo "Checking for optional libraries..." >&4
  1577. case "$libs" in
  1578. ' '|'') dflt='';;
  1579. *) dflt="$libs";;
  1580. esac
  1581. case "$libswanted" in
  1582. '') libswanted='c_s';;
  1583. esac
  1584. for thislib in $libswanted; do
  1585.     case "$thislib" in
  1586.     dbm) thatlib=ndbm;;
  1587.     *_s) thatlib=NONE;;
  1588.     *) thatlib="${thislib}_s";;
  1589.     *) thatlib=NONE;;
  1590.     esac
  1591.     yyy="$incpath/usr/ccs/lib $incpath/usr/lib $incpath/usr/ucblib"
  1592.     yyy="$yyy $incpath/usr/local/lib $incpath/lib"
  1593.     xxx=`./loc lib$thislib.a X $yyy`
  1594.     if $test -f $xxx; then
  1595.         echo "Found -l$thislib."
  1596.         case "$dflt" in
  1597.         *-l$thislib*|*-l$thatlib*);;
  1598.         *) dflt="$dflt -l$thislib";;
  1599.         esac
  1600.     else
  1601.         xxx=`./loc lib$thislib.a X $libpth`
  1602.         if $test -f $xxx; then
  1603.             echo "Found $xxx."
  1604.             case "$dflt" in
  1605.             *$xxx*);;
  1606.             *) dflt="$dflt $xxx";;
  1607.             esac
  1608.         else
  1609.             xxx=`./loc Slib$thislib.a X $xlibpth`
  1610.             if $test -f $xxx; then
  1611.                 echo "Found -l$thislib."
  1612.                 case "$dflt" in
  1613.                 *-l$thislib*|*-l$thatlib*);;
  1614.                 *) dflt="$dflt -l$thislib";;
  1615.                 esac
  1616.             else
  1617.                 echo "No -l$thislib."
  1618.             fi
  1619.         fi
  1620.     fi
  1621. done
  1622. set X $dflt
  1623. shift
  1624. dflt="$*"
  1625. case "$libs" in
  1626. '') dflt="$dflt";;
  1627. *) dflt="$libs";;
  1628. esac
  1629. case "$dflt" in
  1630. ' '|'') dflt='none';;
  1631. esac
  1632.  
  1633. $cat <<EOM
  1634.  
  1635. Some versions of Unix support shared libraries, which make executables smaller
  1636. but make load time slightly longer.
  1637.  
  1638. On some systems, mostly newer Unix System V's, the shared library is included
  1639. by putting the option "-lc_s" as the last thing on the cc command line when
  1640. linking.  Other systems use shared libraries by default.  There may be other
  1641. libraries needed to compile $package on your machine as well.  If your system
  1642. needs the "-lc_s" option, include it here.  Include any other special libraries
  1643. here as well.  Say "none" for none.
  1644. EOM
  1645.  
  1646. echo " "
  1647. rp="Any additional libraries?"
  1648. . ./myread
  1649. case "$ans" in
  1650. none) libs=' ';;
  1651. *) libs="$ans";;
  1652. esac
  1653.  
  1654. usenm=true
  1655. runnm=$usenm
  1656. case "$reuseval" in
  1657. true) runnm=false;;
  1658. esac
  1659.  
  1660. : nm options which may be necessary
  1661. case "$nm_opt" in
  1662. '') if $test -f /mach_boot; then
  1663.         nm_opt=''
  1664.     elif $test -d /usr/ccs/lib; then
  1665.         nm_opt='-p'
  1666.     elif $test -f /dgux; then
  1667.         nm_opt='-p'
  1668.     else
  1669.         nm_opt=''
  1670.     fi;;
  1671. esac
  1672.  
  1673. case "$runnm" in
  1674. true)
  1675. : get list of predefined functions in a handy place
  1676. echo " "
  1677. case "$libc" in
  1678. '') libc=unknown
  1679.     case "$libs" in
  1680.     *-lc_s*) libc=`./loc libc_s.a $libc $libpth`
  1681.     esac
  1682.     ;;
  1683. esac
  1684. libpth="$plibpth $libpth"
  1685. libnames='';
  1686. case "$libs" in
  1687. '') ;;
  1688. *)  for thislib in $libs; do
  1689.     case "$thislib" in
  1690.     -l*)
  1691.         thislib=`expr X$thislib : 'X-l\(.*\)'`
  1692.         try=`./loc lib$thislib.a blurfl/dyick $libpth`
  1693.         if test ! -f $try; then
  1694.             try=`./loc lib$thislib blurfl/dyick $libpth`
  1695.             if test ! -f $try; then
  1696.                 try=`./loc $thislib blurfl/dyick $libpth`
  1697.                 if test ! -f $try; then
  1698.                     try=`./loc Slib$thislib.a blurfl/dyick $xlibpth`
  1699.                     if test ! -f $try; then
  1700.                         try=''
  1701.                     fi
  1702.                 fi
  1703.             fi
  1704.         fi
  1705.         libnames="$libnames $try"
  1706.         ;;
  1707.     *) libnames="$libnames $thislib" ;;
  1708.     esac
  1709.     done
  1710.     ;;
  1711. esac
  1712. xxx=normal
  1713. case "$libc" in
  1714. unknown)
  1715.     set /usr/ccs/lib/libc.so
  1716.     $test -r $1 || set /usr/lib/libc.so
  1717.     $test -r $1 || set /usr/shlib/libc.so
  1718.     $test -r $1 || set /usr/lib/libc.so.[0-9]*
  1719.     $test -r $1 || set /lib/libsys_s.a
  1720.     eval set \$$#
  1721.     ;;
  1722. *)
  1723.     set blurfl
  1724.     ;;
  1725. esac
  1726. if $test -r "$1"; then
  1727.     echo "Your (shared) C library seems to be in $1."
  1728.     libc="$1"
  1729. elif $test -r /lib/libc && $test -r /lib/clib; then
  1730.     echo "Your C library seems to be in both /lib/clib and /lib/libc."
  1731.     xxx=apollo
  1732.     libc='/lib/clib /lib/libc'
  1733.     if $test -r /lib/syslib; then
  1734.         echo "(Your math library is in /lib/syslib.)"
  1735.         libc="$libc /lib/syslib"
  1736.     fi
  1737. elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
  1738.     echo "Your C library seems to be in $libc, as you said before."
  1739. elif $test -r $incpath/usr/lib/libc.a; then
  1740.     libc=$incpath/usr/lib/libc.a;
  1741.     echo "Your C library seems to be in $libc.  That's fine."
  1742. elif $test -r /lib/libc.a; then
  1743.     libc=/lib/libc.a;
  1744.     echo "Your C library seems to be in $libc.  You're normal."
  1745. else
  1746.     if tans=`./loc libc.a blurfl/dyick $libpth`; $test -r "$tans"; then
  1747.         :
  1748.     elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
  1749.         libnames="$libnames "`./loc clib blurfl/dyick $libpth`
  1750.     elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
  1751.         :
  1752.     elif tans=`./loc Slibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
  1753.         :
  1754.     elif tans=`./loc Mlibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
  1755.         :
  1756.     else
  1757.         tans=`./loc Llibc.a blurfl/dyick $xlibpth`
  1758.     fi
  1759.     if $test -r "$tans"; then
  1760.         echo "Your C library seems to be in $tans, of all places."
  1761.         libc=$tans
  1762.     else
  1763.         libc='blurfl'
  1764.     fi
  1765. fi
  1766. if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
  1767.     dflt="$libc"
  1768.     cat <<EOM
  1769.  
  1770. If the guess above is wrong (which it might be if you're using a strange
  1771. compiler, or your machine supports multiple models), you can override it here.
  1772.  
  1773. EOM
  1774. else
  1775.     dflt=''
  1776.     echo $libpth | tr ' ' '\012' | sort | uniq > libpath
  1777.     cat >&4 <<EOM
  1778. I can't seem to find your C library.  I've looked in the following places:
  1779.  
  1780. EOM
  1781.     $sed 's/^/    /' libpath
  1782.     cat <<EOM
  1783.  
  1784. None of these seems to contain your C library. I need to get its name...
  1785.  
  1786. EOM
  1787. fi
  1788. fn=f
  1789. rp='Where is your C library?'
  1790. . ./getfile
  1791. libc="$ans"
  1792.  
  1793. echo " "
  1794. echo $libc $libnames | tr ' ' '\012' | sort | uniq > libnames
  1795. set X `cat libnames`
  1796. shift
  1797. xxx=files
  1798. case $# in 1) xxx=file; esac
  1799. echo "Extracting names from the following $xxx for later perusal:" >&4
  1800. echo " "
  1801. $sed 's/^/    /' libnames >&4
  1802. echo " "
  1803. $echo $n "This may take a while...$c" >&4
  1804.  
  1805. nm $nm_opt $* 2>/dev/null >libc.tmp
  1806. $echo $n ".$c"
  1807. $grep fprintf libc.tmp > libc.ptf
  1808. xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
  1809. xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
  1810. if com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
  1811.     eval $xscan;\
  1812.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1813.         eval $xrun
  1814. elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
  1815.     eval $xscan;\
  1816.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1817.         eval $xrun
  1818. elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
  1819.     eval $xscan;\
  1820.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1821.         eval $xrun
  1822. elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
  1823.     eval $xscan;\
  1824.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1825.         eval $xrun
  1826. elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
  1827.     eval $xscan;\
  1828.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1829.         eval $xrun
  1830. elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
  1831.     eval $xscan;\
  1832.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1833.         eval $xrun
  1834. elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
  1835.                 -e '/ file/d' -e 's/^\([^     ]*\).*/\1/p'";\
  1836.     eval $xscan;\
  1837.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1838.         eval $xrun
  1839. elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
  1840.     eval $xscan;\
  1841.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1842.         eval $xrun
  1843. elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
  1844.     eval $xscan;\
  1845.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1846.         eval $xrun
  1847. else
  1848.     nm -p $* 2>/dev/null >libc.tmp
  1849.     com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
  1850.     eval "<libc.tmp $com >libc.list"
  1851.     if $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1852.         nm_opt='-p'
  1853.         echo "done" >&4
  1854.     else
  1855.         echo " "
  1856.         echo "nm didn't seem to work right. Trying ar instead..." >&4
  1857.         com=''
  1858.         if ar t $libc > libc.tmp; then
  1859.             for thisname in $libnames; do
  1860.                 ar t $thisname >>libc.tmp
  1861.             done
  1862.             $sed -e 's/\.o$//' < libc.tmp > libc.list
  1863.             echo "Ok." >&4
  1864.         else
  1865.             echo "ar didn't seem to work right." >&4
  1866.             echo "Maybe this is a Cray...trying bld instead..." >&4
  1867.             if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  1868.                 for thisname in $libnames; do
  1869.                     bld t $libnames | \
  1870.                     $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
  1871.                     ar t $thisname >>libc.tmp
  1872.                 done
  1873.                 echo "Ok." >&4
  1874.             else
  1875.                 echo "That didn't work either.  Giving up." >&4
  1876.                 exit 1
  1877.             fi
  1878.         fi
  1879.     fi
  1880. fi
  1881. nm_extract="$com"
  1882. if $test -f /lib/syscalls.exp; then
  1883.     echo " "
  1884.     echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
  1885.     $sed -n 's/^\([^     ]*\)[     ]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
  1886. fi
  1887. ;;
  1888. esac
  1889. $rm -f libnames libpath
  1890.  
  1891. : determine optimize, if desired, or use for debug flag also
  1892. case "$optimize" in
  1893. ' ') dflt="none";;
  1894. '') dflt="-O";;
  1895. *) dflt="$optimize";;
  1896. esac
  1897. $cat <<EOH
  1898.  
  1899. Some C compilers have problems with their optimizers, by default, $package
  1900. compiles with the -O flag to use the optimizer.  Alternately, you might want
  1901. to use the symbolic debugger, which uses the -g flag (on traditional Unix
  1902. systems).  Either flag can be specified here.  To use neither flag, specify
  1903. the word "none".
  1904.  
  1905. EOH
  1906. rp="What optimizer/debugger flag should be used?"
  1907. . ./myread
  1908. optimize="$ans"
  1909. case "$optimize" in
  1910. 'none') optimize=" ";;
  1911. esac
  1912.  
  1913. case "$ccflags" in
  1914. '')    case "$optimize" in
  1915.     *-g*) dflt="-DDEBUG";;
  1916.     *)    dflt='';;
  1917.     esac
  1918.     case "$cc" in
  1919.     *gcc*)    if test -d /etc/conf/kconfig.d &&
  1920.           $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
  1921.         then
  1922.             dflt="$dflt -posix"
  1923.         fi
  1924.         ;;
  1925.     esac
  1926.     ;;
  1927. *) dflt="$ccflags" ;;
  1928. esac
  1929.  
  1930. case "$mips_type" in
  1931. *BSD*) ;;
  1932. '') ;;
  1933. *) inclwanted="$inclwanted $usrinc/bsd";;
  1934. esac
  1935. for thisincl in $inclwanted; do
  1936.     if $test -d $thisincl; then
  1937.         if $test x$thisincl != x$usrinc; then
  1938.             case "$dflt" in
  1939.             *$thisincl*);;
  1940.             *) dflt="$dflt -I$thisincl";;
  1941.             esac
  1942.         fi
  1943.     fi
  1944. done
  1945.  
  1946. inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
  1947.     xxx=true;
  1948. elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
  1949.     xxx=true;
  1950. else
  1951.     xxx=false;
  1952. fi;
  1953. if $xxx; then
  1954.     case "$dflt" in
  1955.     *$2*);;
  1956.     *) dflt="$dflt -D$2";;
  1957.     esac;
  1958. fi'
  1959.  
  1960. if ./osf1; then
  1961.     set signal.h __LANGUAGE_C__; eval $inctest
  1962. else
  1963.     set signal.h LANGUAGE_C; eval $inctest
  1964. fi
  1965. set signal.h NO_PROTOTYPE; eval $inctest
  1966. set signal.h _NO_PROTO; eval $inctest
  1967.  
  1968. case "$dflt" in
  1969. '') dflt=none;;
  1970. esac
  1971. $cat <<EOH
  1972.  
  1973. Your C compiler may want other flags.  For this question you should include
  1974. -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
  1975. but you should NOT include libraries or ld flags like -lwhatever.  If you
  1976. want $package to honor its debug switch, you should include -DDEBUG here.
  1977. To use no flags, specify the word "none".
  1978.  
  1979. EOH
  1980. set X $dflt
  1981. shift
  1982. dflt=${1+"$@"}
  1983. rp="Any additional cc flags?"
  1984. . ./myread
  1985. case "$ans" in
  1986. none) ccflags='';;
  1987. *) ccflags="$ans";;
  1988. esac
  1989.  
  1990. : the following weeds options from ccflags that are of no interest to cpp
  1991. cppflags="$ccflags"
  1992. case "$mips_type" in
  1993. '');;
  1994. *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
  1995. esac
  1996. case "$cppflags" in
  1997. '');;
  1998. *)  set X $cppflags
  1999.     cppflags=''
  2000.     for flag
  2001.     do
  2002.         case $flag in
  2003.         -D*|-I*|-traditional|-ansi|-nostdinc) cppflags="$cppflags $flag";;
  2004.         esac
  2005.     done
  2006.     ;;
  2007. esac
  2008.  
  2009. : flags used in final linking phase
  2010. case "$ldflags" in
  2011. '') if venix; then
  2012.         dflt='-i -z'
  2013.     else
  2014.         dflt='none'
  2015.     fi
  2016.     ;;
  2017. *) dflt="$ldflags";;
  2018. esac
  2019. echo " "
  2020. rp="Any additional ld flags (NOT including libraries)?"
  2021. . ./myread
  2022. case "$ans" in
  2023. none) ldflags='';;
  2024. *)    ldflags="$ans";;
  2025. esac
  2026. rmlist="$rmlist pdp11"
  2027.  
  2028. : is a C symbol defined?
  2029. csym='tlook=$1;
  2030. case "$3" in
  2031. -v) tf=libc.tmp; tc=""; tdc="";;
  2032. -a) tf=libc.tmp; tc="[0]"; tdc=[];;
  2033. *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
  2034. esac;
  2035. tx=yes;
  2036. case "$reuseval-$4" in
  2037. true-) ;;
  2038. true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
  2039. esac;
  2040. case "$tx" in
  2041. yes)
  2042.     case "$runnm" in
  2043.     true)
  2044.         if $contains $tlook $tf >/dev/null 2>&1;
  2045.         then tval=true;
  2046.         else tval=false;
  2047.         fi;;
  2048.     *)
  2049.         echo "main() { extern int $1$tdc; printf(\"%d\", $1$tc); }" > t.c;
  2050.         if $cc $ccflags -o t t.c $ldflags $libs >/dev/null 2>&1;
  2051.         then tval=true;
  2052.         else tval=false;
  2053.         fi;
  2054.         $rm -f t t.c;;
  2055.     esac;;
  2056. *)
  2057.     case "$tval" in
  2058.     $define) tval=true;;
  2059.     *) tval=false;;
  2060.     esac;;
  2061. esac;
  2062. eval "$2=$tval"'
  2063.  
  2064. : set up the script used to warn in case of inconsistency
  2065. cat <<'EOSC' >whoa
  2066. dflt=y
  2067. echo " "
  2068. echo "*** WHOA THERE!!! ***" >&4
  2069. echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
  2070. rp="    Keep the $hint value?"
  2071. . ./myread
  2072. case "$ans" in
  2073. y) td=$was; tu=$was;;
  2074. esac
  2075. EOSC
  2076.  
  2077. : define an is-in-libc? function
  2078. inlibc='echo " "; td=$define; tu=$undef;
  2079. sym=$1; var=$2; eval "was=\$$2";
  2080. tx=yes;
  2081. case "$reuseval$was" in
  2082. true) ;;
  2083. true*) tx=no;;
  2084. esac;
  2085. case "$tx" in
  2086. yes)
  2087.     set $sym tres -f;
  2088.     eval $csym;
  2089.     case "$tres" in
  2090.     true)
  2091.         echo "$sym() found." >&4;
  2092.         case "$was" in $undef) . whoa; esac; eval "$var=\$td";;
  2093.     *)
  2094.         echo "$sym() NOT found." >&4;
  2095.         case "$was" in $define) . whoa; esac; eval "$var=\$tu";;
  2096.     esac;;
  2097. *)
  2098.     case "$was" in
  2099.     $define) echo "$sym() found." >&4;;
  2100.     *) echo "$sym() NOT found." >&4;;
  2101.     esac;;
  2102. esac'
  2103.  
  2104. : see if chsize exists
  2105. set chsize d_chsize
  2106. eval $inlibc
  2107.  
  2108. : see if ftruncate exists
  2109. set ftruncate d_ftrncate
  2110. eval $inlibc
  2111.  
  2112. : see how we invoke the C preprocessor
  2113. echo " "
  2114. echo "Now, how can we feed standard input to your C preprocessor..." >&4
  2115. cat <<'EOT' >testcpp.c
  2116. #define ABC abc
  2117. #define XYZ xyz
  2118. ABC.XYZ
  2119. EOT
  2120. cd ..
  2121. echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
  2122. chmod 755 cppstdin
  2123. wrapper=`pwd`/cppstdin
  2124. cd UU
  2125. if $test "X$cppstdin" != "X" && \
  2126.     $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
  2127.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2128.     echo "You used to use $cppstdin $cppminus so we'll use that again."
  2129. elif $test "$cc" = gcc && \
  2130.     (echo "Using gcc, eh?  We'll try to force gcc -E using a wrapper..."; \
  2131.     $wrapper <testcpp.c >testcpp.out 2>&1; \
  2132.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1) ; then
  2133.     echo "Yup, we can."
  2134.     cppstdin="$wrapper"
  2135.     cppminus='';
  2136. elif echo 'Maybe "'"$cc"' -E" will work...'; \
  2137.     $cc -E <testcpp.c >testcpp.out 2>&1; \
  2138.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2139.     echo "Yup, it does."
  2140.     cppstdin="$cc -E"
  2141.     cppminus='';
  2142. elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
  2143.     $cc -E - <testcpp.c >testcpp.out 2>&1; \
  2144.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2145.     echo "Yup, it does."
  2146.     cppstdin="$cc -E"
  2147.     cppminus='-';
  2148. elif echo 'No such luck, maybe "'$cpp'" will work...'; \
  2149.     $cpp <testcpp.c >testcpp.out 2>&1; \
  2150.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2151.     echo "It works!"
  2152.     cppstdin="$cpp"
  2153.     cppminus='';
  2154. elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
  2155.     $cpp - <testcpp.c >testcpp.out 2>&1; \
  2156.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2157.     echo "Hooray, it works!  I was beginning to wonder."
  2158.     cppstdin="$cpp"
  2159.     cppminus='-';
  2160. elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
  2161.     $cc -P <testcpp.c >testcpp.out 2>&1; \
  2162.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2163.     echo "Yipee, that works!"
  2164.     cppstdin="$cc -P"
  2165.     cppminus='';
  2166. elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
  2167.     $cc -P - <testcpp.c >testcpp.out 2>&1; \
  2168.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2169.     echo "At long last!"
  2170.     cppstdin="$cc -P"
  2171.     cppminus='-';
  2172. elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
  2173.     $wrapper <testcpp.c >testcpp.out 2>&1; \
  2174.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2175.     cppstdin="$wrapper"
  2176.     cppminus=''
  2177.     echo "Eureka!"
  2178. else
  2179.     dflt=''
  2180.     rp="No dice.  I can't find a C preprocessor.  Name one:"
  2181.     . ./myread
  2182.     cppstdin="$ans"
  2183.     $cppstdin <testcpp.c >testcpp.out 2>&1
  2184.     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2185.         echo "OK, that will do." >&4
  2186.     else
  2187. echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
  2188.         exit 1
  2189.     fi
  2190. fi
  2191. case "$cppstdin" in
  2192. "$wrapper") ;;
  2193. *) $rm -f $wrapper;;
  2194. esac
  2195. $rm -f testcpp.c testcpp.out
  2196.  
  2197. : determine filename position in cpp output
  2198. echo " "
  2199. echo "Computing filename position in cpp output for #include directives..." >&4
  2200. echo '#include <stdio.h>' > foo.c
  2201. $cat >fieldn <<EOF
  2202. $startsh
  2203. $cppstdin $cppminus $cppflags <foo.c 2>/dev/null | \
  2204. $grep '^[     ]*#.*stdio\.h' | \
  2205. while read cline; do
  2206.     pos=1
  2207.     set \$cline
  2208.     while $test \$# -gt 0; do
  2209.         if $test -r \`echo \$1 | $tr -d '"'\`; then
  2210.             echo "\$pos"
  2211.             exit 0
  2212.         fi
  2213.         shift
  2214.         pos=\`expr \$pos + 1\`
  2215.     done
  2216. done
  2217. EOF
  2218. chmod +x fieldn
  2219. fieldn=`./fieldn`
  2220. $rm -f foo.c fieldn
  2221. case $fieldn in
  2222. '') pos='???';;
  2223. 1) pos=first;;
  2224. 2) pos=second;;
  2225. 3) pos=third;;
  2226. *) pos="${fieldn}th";;
  2227. esac
  2228. echo "Your cpp writes the filename in the $pos field of the line."
  2229.  
  2230. : locate header file
  2231. $cat >findhdr <<EOF
  2232. $startsh
  2233. wanted=\$1
  2234. name=''
  2235. if test -f $usrinc/\$wanted; then
  2236.     echo "$usrinc/\$wanted"
  2237.     exit 0
  2238. fi
  2239. awkprg='{ print \$$fieldn }'
  2240. echo "#include <\$wanted>" > foo\$\$.c
  2241. $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
  2242. $grep "^[     ]*#.*\$wanted" | \
  2243. while read cline; do
  2244.     name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
  2245.     case "\$name" in
  2246.     */\$wanted) echo "\$name"; exit 0;;
  2247.     *) name='';;
  2248.     esac;
  2249. done;
  2250. $rm -f foo\$\$.c;
  2251. case "\$name" in
  2252. '') exit 1;;
  2253. esac
  2254. EOF
  2255. chmod +x findhdr
  2256.  
  2257. : see if there are directory access routines out there
  2258. echo " "
  2259. if $test `./findhdr ndir.h` && \
  2260.       ( $test -r /usr/lib/libndir.a || $test -r /usr/local/lib/libndir.a ); then
  2261.     echo "Ndir library found." >&4
  2262.     if $test -r /usr/lib/libndir.a; then
  2263.         libndir='-lndir'
  2264.     else
  2265.         libndir="/usr/local/lib/libndir.a"
  2266.     fi
  2267.     d_libndir="$define"
  2268.     d_usendir="$undef"
  2269.     ndirc=''
  2270.     ndiro=''
  2271. else
  2272.     libndir=''
  2273.     d_libndir="$undef"
  2274.     if set readdir val -f; eval $csym; $val; then
  2275.     echo "No ndir library found, but you have readdir() so we'll use that." >&4
  2276.         d_usendir="$undef"
  2277.         ndirc=''
  2278.         ndiro=''
  2279.     else
  2280.         echo "No ndir library found--using ./ndir.c." >&4
  2281.         d_usendir="$define"
  2282.         ndirc='ndir.c'
  2283.         ndiro='ndir.o'
  2284.     fi
  2285. fi
  2286.  
  2287. : see if memcmp exists
  2288. set memcmp d_memcmp
  2289. eval $inlibc
  2290.  
  2291. : see if memcpy exists
  2292. set memcpy d_memcpy
  2293. eval $inlibc
  2294.  
  2295. : see if memset exists
  2296. set memset d_memset
  2297. eval $inlibc
  2298.  
  2299. : function used to set $1 to $val
  2300. setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
  2301. case "$val$was" in
  2302. $define$undef) . whoa; eval "$var=\$td";;
  2303. $undef$define) . whoa; eval "$var=\$tu";;
  2304. *) eval "$var=$val";;
  2305. esac'
  2306.  
  2307. : see if we need -ljobs and if we have sigset, etc.
  2308. echo " "
  2309. if $test -r /usr/lib/libjobs.a || $test -r /usr/local/lib/libjobs.a ; then
  2310.     echo "Jobs library found." >&4
  2311.     val="$undef"
  2312.     jobslib='-ljobs'
  2313. else
  2314.     if bsd; then
  2315.         echo "No jobs library found. (I suppose this is at least 4.2...)" >&4
  2316.     else
  2317.         echo "No jobs library found. (That's okay, we all have our faults.)" >&4
  2318.     fi
  2319.     val="$define"
  2320.     jobslib=''
  2321. fi
  2322. set d_normsig
  2323. eval $setvar
  2324.  
  2325. : check for void type
  2326. echo " "
  2327. $echo "Checking to see how well your C compiler groks the void type..."
  2328. $cat >void.c <<'EOCP'
  2329. void main(){;}
  2330. EOCP
  2331. if $cc -c void.c >/dev/null 2>&1 ; then
  2332.     d_novoid="$undef"
  2333.     $echo "Yup, it does."
  2334. else
  2335.     d_novoid="$define"
  2336.     $echo "Nope, it doesn't (boo hiss).  I will substitute int."
  2337. fi
  2338. $rm void.*
  2339.  
  2340. : see if rename exists
  2341. set rename d_rename
  2342. eval $inlibc
  2343.  
  2344. : see if sighold exists
  2345. set sighold d_sighold
  2346. eval $inlibc
  2347.  
  2348. : see which of string.h or strings.h is needed
  2349. echo " "
  2350. strings=`./findhdr string.h`
  2351. if $test "$strings" && $test -r "$strings"; then
  2352.     echo "Using <string.h> instead of <strings.h>." >&4
  2353.     val="$define"
  2354. else
  2355.     val="$undef"
  2356.     strings=`./findhdr strings.h`
  2357.     if $test "$strings" && $test -r "$strings"; then
  2358.         echo "Using <strings.h> instead of <string.h>." >&4
  2359.     else
  2360.         echo "No string header found -- You'll surely have problems." >&4
  2361.     fi
  2362. fi
  2363. set i_string
  2364. eval $setvar
  2365. case "$i_string" in
  2366. "$undef") strings=`./findhdr strings.h`;;
  2367. *)      strings=`./findhdr string.h`;;
  2368. esac
  2369.  
  2370. : index or strchr
  2371. echo " "
  2372. if set index val -f; eval $csym; $val; then
  2373.     if set strchr val -f d_strchr; eval $csym; $val; then
  2374.         if $contains strchr "$strings" >/dev/null 2>&1 ; then
  2375.             val="$define"
  2376.             echo "strchr() found." >&4
  2377.         else
  2378.             val="$undef"
  2379.             echo "index() found." >&4
  2380.         fi
  2381.     else
  2382.         val="$undef"
  2383.         echo "index() found." >&4
  2384.     fi
  2385. else
  2386.     if set strchr val -f d_strchr; eval $csym; $val; then
  2387.         val="$define"
  2388.         echo "strchr() found." >&4
  2389.     else
  2390.         echo "No index() or strchr() found!" >&4
  2391.         val="$undef"
  2392.     fi
  2393. fi
  2394. set d_strchr
  2395. eval $setvar
  2396.  
  2397. : check if syslog is available and desired
  2398. if set syslog val -f; eval $csym; $val; then
  2399.     case "$d_syslog" in
  2400.     $define) dflt=y ;;
  2401.     *)  dflt=n ;;
  2402.     esac
  2403.     $echo " "
  2404.     $echo "Mthreads can either use a custom log file or the syslog functions for"
  2405.     $echo "maintaining its log messages."
  2406.     rp="Would you prefer to use syslog?"
  2407.     . myread
  2408.     case $ans in
  2409.     n*) syslog=LOG_NEWS
  2410.         d_syslog="$undef"
  2411.         ;;
  2412.     *)  case "$syslog" in
  2413.         LOG_*) dflt="$syslog" ;;
  2414.         *)     dflt=LOG_NEWS ;;
  2415.         esac
  2416.         $cat <<'EOM'
  2417.  
  2418. If your syslog has LOG_NEWS or LOG_DAEMON, you'll probably want to use
  2419. one of these for your logging.  If it doesn't, accept the default and
  2420. we'll figure that out later.
  2421. EOM
  2422.         rp="Syslog priority to use?"
  2423.         . myread
  2424.         syslog="$ans"
  2425.         d_syslog="$define"
  2426.         ;;
  2427.     esac
  2428. else
  2429.         syslog=LOG_NEWS
  2430.     d_syslog="$undef"
  2431. fi
  2432.  
  2433. : see if usleep exists
  2434. set usleep d_usleep
  2435. eval $inlibc
  2436.  
  2437. : backward compatibility for d_hvfork
  2438. if test X$d_hvfork != X; then
  2439.     d_vfork="$d_hvfork"
  2440.     d_hvfork=''
  2441. fi
  2442. : see if there is a vfork
  2443. set vfork d_vfork
  2444. eval $inlibc
  2445.  
  2446. : preserve RCS keywords in files with variable substitution, grrr
  2447. Id='$Id'
  2448. Log='$Log'
  2449.  
  2450. : is AFS running?
  2451. echo " "
  2452. if test -d /afs; then
  2453.     echo "AFS may be running... I'll be extra cautious then..." >&4
  2454.     afs=true
  2455. else
  2456.     echo "AFS does not seem to be running..." >&4
  2457.     afs=false
  2458. fi
  2459.  
  2460. : determine where manual pages go
  2461. $cat <<EOM
  2462.  
  2463. $package has manual pages available in source form.
  2464. EOM
  2465. case "$nroff" in
  2466. nroff)
  2467.     echo "However, you don't have nroff, so they're probably useless to you."
  2468.     case "$mansrc" in
  2469.     '') mansrc="none";;
  2470.     esac;;
  2471. esac
  2472. echo "If you don't want the manual sources installed, answer 'none'."
  2473. case "$mansrc" in
  2474. '')
  2475.     lookpath='/usr/local/man/man1 /usr/local/man/man1 /usr/man/manl'
  2476.     lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
  2477.     lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
  2478.     lookpath="$lookpath /usr/man/man.L"
  2479.     mansrc=`./loc . $lookpath`
  2480.     if $test -d "$mansrc"; then
  2481.         dflt="$mansrc"
  2482.     else
  2483.         dflt="$sysman"
  2484.     fi
  2485.     ;;
  2486. *)  dflt="$mansrc"
  2487.     ;;
  2488. esac
  2489. echo " "
  2490. fn=dn~
  2491. rp='Where do the manual pages (source) go?'
  2492. . ./getfile
  2493. mansrc="$ans"
  2494. mansrcexp="$ansexp"
  2495. if $afs; then
  2496.     $cat <<EOM
  2497.  
  2498. Since you are running AFS, I need to distinguish the directory in which
  2499. manual pages reside from the directory in which they are installed (and from
  2500. which they are presumably copied to the former directory by occult means).
  2501.  
  2502. EOM
  2503.     case "$installmansrc" in
  2504.     '') dflt=`echo $mansrcexp | sed 's#^/afs/#/afs/.#'`;;
  2505.     *) dflt="$installmansrc";;
  2506.     esac
  2507.     fn=de~
  2508.     rp='Where will man pages be installed?'
  2509.     . ./getfile
  2510.     installmansrc="$ans"
  2511. else
  2512.     installmansrc="$mansrcexp"
  2513. fi
  2514.  
  2515.  
  2516. case "$mansrc" in
  2517. '') manext='0';;
  2518. *l) manext=l;;
  2519. *n) manext=n;;
  2520. *o) manext=l;;
  2521. *p) manext=n;;
  2522. *C) manext=C;;
  2523. *L) manext=L;;
  2524. *L1) manext=L1;;
  2525. *L8) manext=L8;;
  2526. *8) manext=8;;
  2527. *) manext=1;;
  2528. esac
  2529.  
  2530. : determine where private executables go
  2531. case "$privlib" in
  2532. '')    dflt=/usr/lib/$package
  2533.     $test -d /usr/local/lib && dflt=/usr/local/lib/$package
  2534.     $test -d /local/lib && dflt=/local/lib/$package ;;
  2535. *)    dflt="$privlib" ;;
  2536. esac
  2537. $cat <<EOM
  2538.  
  2539. Mthreads and its support files should be installed into its own directory.
  2540. If you like, you can choose the same directory as trn's private library
  2541. files.
  2542.  
  2543. EOM
  2544. fn=d~+
  2545. rp='Pathname where mthreads and its files will reside?'
  2546. . ./getfile
  2547. privlib="$ans"
  2548. privlibexp="$ansexp"
  2549. if $afs; then
  2550.     $cat <<EOM
  2551.  
  2552. Since you are running AFS, I need to distinguish the directory in which
  2553. the files reside from the directory in which they are installed (and from
  2554. which they are presumably copied to the former directory by occult means).
  2555.  
  2556. EOM
  2557.     case "$installprivlib" in
  2558.     '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
  2559.     *) dflt="$installprivlib";;
  2560.     esac
  2561.     fn=de~
  2562.     rp='Where will mthreads and its files be installed?'
  2563.     . ./getfile
  2564.     installprivlib="$ans"
  2565. else
  2566.     installprivlib="$privlibexp"
  2567. fi
  2568.  
  2569. : get news administrator name
  2570. case "$newsadmin" in
  2571. '')
  2572.     if $contains "^news:" /etc/passwd >/dev/null 2>&1 ; then
  2573.         dflt=news
  2574.     elif $contains "^usenet:" /etc/passwd >/dev/null 2>&1 ; then
  2575.         dflt=usenet
  2576.     elif eunice; then
  2577.         dflt=system
  2578.     else
  2579.         dflt=root
  2580.     fi
  2581.     ;;
  2582. *)
  2583.     dflt="$newsadmin"
  2584.     ;;
  2585. esac
  2586. $cat <<'EOM'
  2587.  
  2588. Many systems keep their news in a private directory, or have a non-superuser
  2589. in charge of administering news.  (If you don't have such a user, take the
  2590. default answer.)  I need the login name (not directory) which is used for
  2591. news administration.
  2592.  
  2593. EOM
  2594. rp="News admin login?"
  2595. . ./myread
  2596. newsadmin="$ans"
  2597. case "$newsadmin" in
  2598. root) val="$undef" ;;
  2599. *) val="$define" ;;
  2600. esac
  2601. set d_newsadm
  2602. eval $setvar
  2603.  
  2604. : locate news spool directory
  2605. if $test "X$d_nntp" = "X$define" ; then
  2606.     newsspool="/tmp"
  2607. else
  2608.     case "$newsspool" in
  2609.     '') dflt=/usr/spool/news;;
  2610.     *) dflt="$newsspool";;
  2611.     esac
  2612.     $echo " "
  2613.     fn=d~
  2614.     rp='Where is news spooled?'
  2615.     . ./getfile
  2616.     newsspool="$ans"
  2617. fi
  2618.  
  2619. : see if signal is declared as pointer to function returning int or void
  2620. echo " "
  2621. xxx=`./findhdr signal.h`
  2622. $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
  2623. if $contains 'int.*\*[     ]*signal' $$.tmp >/dev/null 2>&1 ; then
  2624.     echo "You have int (*signal())() instead of void." >&4
  2625.     val="$undef"
  2626.     signal_t="int"
  2627. elif $contains 'void.*\*[     ]*signal' $$.tmp >/dev/null 2>&1 ; then
  2628.     echo "You have void (*signal())() instead of int." >&4
  2629.     val="$define"
  2630.     signal_t="void"
  2631. elif $contains 'extern[     ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
  2632.     echo "You have int (*signal())() instead of void." >&4
  2633.     val="$undef"
  2634.     signal_t="int"
  2635. else
  2636.     case "$d_voidsig" in
  2637.     '')
  2638.     echo "I can't determine whether signal handler returns void or int..." >&4
  2639.         dflt=void
  2640.         rp="What type does your signal handler returns?"
  2641.         . ./myread
  2642.         case "$ans" in
  2643.         void) val="$define"; signal_t="void";;
  2644.         *) val="$undef"; signal_t="int";;
  2645.         esac;;
  2646.     *) echo "As you already told me, signal handler returns $signal_t." >&4;;
  2647.     esac
  2648. fi
  2649. set d_voidsig
  2650. eval $setvar
  2651. $rm -f $$.tmp
  2652.  
  2653. : check on .thread file placement
  2654. case "$threaddir" in
  2655. '')    if $test "X$d_nntp" = "X$define" ; then
  2656.         dflt="/usr/spool/threads"
  2657.     else
  2658.         dflt="$newsspool"
  2659.     fi
  2660.     ;;
  2661. *)    dflt="$threaddir";;
  2662. esac
  2663. $echo " "
  2664. $echo "$spackage needs to know the base directory for the thread files"
  2665. $echo "on your system."
  2666. rp="Where do thread files reside?"
  2667. . ./myread
  2668. threaddir="$ans"
  2669.  
  2670. : see if this is a dirent system
  2671. echo " "
  2672. if xinc=`./findhdr dirent.h`; $test "$xinc"; then
  2673.     val="$define"
  2674.     echo "<dirent.h> found." >&4
  2675. else
  2676.     val="$undef"
  2677.     if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
  2678.         echo "<sys/dir.h> found." >&4
  2679.         echo " "
  2680.     else
  2681.         xinc=`./findhdr sys/ndir.h`
  2682.     fi
  2683.     echo "<dirent.h> NOT found." >&4
  2684. fi
  2685. set i_dirent
  2686. eval $setvar
  2687.  
  2688. : define an alternate in-header-list? function
  2689. inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
  2690. cont=true; xxf="echo \"<\$1> found.\" >&4";
  2691. case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
  2692. *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
  2693. esac;
  2694. case $# in 4) instead=instead;; *) instead="at last";; esac;
  2695. while $test "$cont"; do
  2696.     xxx=`./findhdr $1`
  2697.     var=$2; eval "was=\$$2";
  2698.     if $test "$xxx" && $test -r "$xxx";
  2699.     then eval $xxf;
  2700.         eval "case \"\$$var\" in $undef) . whoa; esac"; eval "$var=\$td";
  2701.         cont="";
  2702.     else eval $xxnf;
  2703.         eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu"; fi;
  2704.     set $yyy; shift; shift; yyy=$@;
  2705.     case $# in 0) cont="";;
  2706.     2) xxf="echo \"but I found <\$1> $instead.\" >&4";
  2707.         xxnf="echo \"and I did not find <\$1> either.\" >&4";;
  2708.     *) xxf="echo \"but I found <\$1\> instead.\" >&4";
  2709.         xxnf="echo \"there is no <\$1>, ...\" >&4";;
  2710.     esac;
  2711. done;
  2712. while $test "$yyy";
  2713. do set $yyy; var=$2; eval "was=\$$2";
  2714.     eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu";
  2715.     set $yyy; shift; shift; yyy=$@;
  2716. done'
  2717.  
  2718. : see if stdlib is available
  2719. set stdlib.h i_stdlib
  2720. eval $inhdr
  2721.  
  2722. : see if this is an sysdir system
  2723. set sys/dir.h i_sysdir
  2724. eval $inhdr
  2725.  
  2726. : see if this is an sysndir system
  2727. set sys/ndir.h i_sysndir
  2728. eval $inhdr
  2729.  
  2730. : see if we should include time.h, sys/time.h, or both
  2731. echo " "
  2732. echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
  2733. $echo $n "I'm now running the test program...$c"
  2734. $cat >try.c <<'EOCP'
  2735. #include <sys/types.h>
  2736. #ifdef I_TIME
  2737. #include <time.h>
  2738. #endif
  2739. #ifdef I_SYSTIME
  2740. #include <sys/time.h>
  2741. #endif
  2742. #ifdef I_SYSSELECT
  2743. #include <sys/select.h>
  2744. #endif
  2745. main()
  2746. {
  2747.     struct tm foo;
  2748. #ifdef S_TIMEVAL
  2749.     struct timeval bar;
  2750. #endif
  2751. #ifdef S_TIMEZONE
  2752.     struct timezone tzp;
  2753. #endif
  2754.     if (foo.tm_sec == foo.tm_sec)
  2755.         exit(0);
  2756. #ifdef S_TIMEVAL
  2757.     if (bar.tv_sec == bar.tv_sec)
  2758.         exit(0);
  2759. #endif
  2760.     exit(1);
  2761. }
  2762. EOCP
  2763. flags=''
  2764. for s_timezone in '-DS_TIMEZONE' ''; do
  2765. sysselect=''
  2766. for s_timeval in '-DS_TIMEVAL' ''; do
  2767. for i_time in '' '-DI_TIME'; do
  2768. for i_systime in '-DI_SYSTIME' ''; do
  2769.     case "$flags" in
  2770.     '') $echo $n ".$c"
  2771.         if $cc $ccflags \
  2772.         $i_time $i_systime $sysselect $s_timeval $s_timezone \
  2773.         try.c -o try >/dev/null 2>&1 ; then
  2774.             set X $i_time $i_systime $sysselect $s_timeval
  2775.             shift
  2776.             flags="$*"
  2777.             echo " "
  2778.             $echo $n "Succeeded with $flags$c"
  2779.         fi
  2780.         ;;
  2781.     esac
  2782. done
  2783. done
  2784. done
  2785. done
  2786. echo " "
  2787. case "$flags" in
  2788. *I_TIME*) i_time="$define"
  2789.     echo "We'll include <time.h>." >&4;;
  2790. *) i_time="$undef";;
  2791. esac
  2792. case "$flags" in
  2793. *I_SYSTIME*) i_systime="$define"
  2794.     echo "We'll include <sys/time.h>." >&4;;
  2795. *) i_systime="$undef";;
  2796. esac
  2797. $rm -f try.c try
  2798.  
  2799. : see if this is a unistd.h system
  2800. set unistd.h i_unistd
  2801. eval $inhdr
  2802.  
  2803. : see if this is a vfork system
  2804. set vfork.h i_vfork
  2805. eval $inhdr
  2806.  
  2807. : end of configuration questions
  2808. echo " "
  2809. echo "End of configuration questions."
  2810. echo " "
  2811.  
  2812. : back to where it started
  2813. if test -d ../UU; then
  2814.     mv filexp ..
  2815.     cd ..
  2816. fi
  2817.  
  2818. : configuration may be patched via a 'config.over' file
  2819. if $test -f config.over; then
  2820.     echo " "
  2821.     dflt=y
  2822.     rp='I see a config.over file.  Do you wish to load it?'
  2823.     . UU/myread
  2824.     case "$ans" in
  2825.     n*) echo "OK, I'll ignore it.";;
  2826.     *)    . ./config.over
  2827.         echo "Configuration override changes have been loaded."
  2828.         ;;
  2829.     esac
  2830. fi
  2831.  
  2832. : create config.sh file
  2833. echo " "
  2834. echo "Creating config.sh..." >&4
  2835. $spitshell <<EOT >config.sh
  2836. $startsh
  2837. #
  2838. # This file was produced by running the Configure script. It holds all the
  2839. # definitions figured out by Configure. Should you modify one of these values,
  2840. # do not forget to propagate your changes by running "Configure -der". You may
  2841. # instead choose to run each of the .SH files by yourself, or "Configure -S".
  2842. #
  2843.  
  2844. # Configuration time: $cf_time
  2845. # Configured by: $cf_by
  2846. # Target system: $myuname
  2847.  
  2848. d_bsd='$d_bsd'
  2849. d_eunice='$d_eunice'
  2850. d_xenix='$d_xenix'
  2851. eunicefix='$eunicefix'
  2852. Mcc='$Mcc'
  2853. awk='$awk'
  2854. cat='$cat'
  2855. cpp='$cpp'
  2856. date='$date'
  2857. echo='$echo'
  2858. egrep='$egrep'
  2859. expr='$expr'
  2860. gcc='$gcc'
  2861. grep='$grep'
  2862. lint='$lint'
  2863. mail='$mail'
  2864. mkdir='$mkdir'
  2865. mv='$mv'
  2866. nroff='$nroff'
  2867. rm='$rm'
  2868. sed='$sed'
  2869. sendmail='$sendmail'
  2870. sort='$sort'
  2871. test='$test'
  2872. tr='$tr'
  2873. uname='$uname'
  2874. uniq='$uniq'
  2875. uuname='$uuname'
  2876. vi='$vi'
  2877. hint='$hint'
  2878. myuname='$myuname'
  2879. Id='$Id'
  2880. Log='$Log'
  2881. active='$active'
  2882. acttimes='$acttimes'
  2883. d_acttimes='$d_acttimes'
  2884. myactive='$myactive'
  2885. afs='$afs'
  2886. cc='$cc'
  2887. ccflags='$ccflags'
  2888. cppflags='$cppflags'
  2889. ldflags='$ldflags'
  2890. lkflags='$lkflags'
  2891. optimize='$optimize'
  2892. cf_by='$cf_by'
  2893. cf_time='$cf_time'
  2894. contains='$contains'
  2895. cppminus='$cppminus'
  2896. cppstdin='$cppstdin'
  2897. d_chsize='$d_chsize'
  2898. d_ftrncate='$d_ftrncate'
  2899. d_memcmp='$d_memcmp'
  2900. d_memcpy='$d_memcpy'
  2901. d_memset='$d_memset'
  2902. d_newsadm='$d_newsadm'
  2903. newsadmin='$newsadmin'
  2904. d_nntp='$d_nntp'
  2905. servername='$servername'
  2906. d_normsig='$d_normsig'
  2907. jobslib='$jobslib'
  2908. d_novoid='$d_novoid'
  2909. void='$void'
  2910. d_portable='$d_portable'
  2911. d_rename='$d_rename'
  2912. d_sighold='$d_sighold'
  2913. d_strchr='$d_strchr'
  2914. d_syslog='$d_syslog'
  2915. syslog='$syslog'
  2916. d_libndir='$d_libndir'
  2917. d_usendir='$d_usendir'
  2918. libndir='$libndir'
  2919. ndirc='$ndirc'
  2920. ndiro='$ndiro'
  2921. d_usleep='$d_usleep'
  2922. d_vfork='$d_vfork'
  2923. d_voidsig='$d_voidsig'
  2924. signal_t='$signal_t'
  2925. d_dirnamlen='$d_dirnamlen'
  2926. i_dirent='$i_dirent'
  2927. i_stdlib='$i_stdlib'
  2928. i_string='$i_string'
  2929. strings='$strings'
  2930. i_sysdir='$i_sysdir'
  2931. i_sysndir='$i_sysndir'
  2932. i_systime='$i_systime'
  2933. i_time='$i_time'
  2934. i_unistd='$i_unistd'
  2935. i_vfork='$i_vfork'
  2936. libc='$libc'
  2937. plibpth='$plibpth'
  2938. xlibpth='$xlibpth'
  2939. libs='$libs'
  2940. installmansrc='$installmansrc'
  2941. manext='$manext'
  2942. mansrc='$mansrc'
  2943. mansrcexp='$mansrcexp'
  2944. c='$c'
  2945. n='$n'
  2946. newslib='$newslib'
  2947. newslibexp='$newslibexp'
  2948. newsspool='$newsspool'
  2949. package='$package'
  2950. spackage='$spackage'
  2951. installprivlib='$installprivlib'
  2952. privlib='$privlib'
  2953. privlibexp='$privlibexp'
  2954. sharpbang='$sharpbang'
  2955. shsharp='$shsharp'
  2956. spitshell='$spitshell'
  2957. startsh='$startsh'
  2958. sysman='$sysman'
  2959. threaddir='$threaddir'
  2960. nm_opt='$nm_opt'
  2961. runnm='$runnm'
  2962. usenm='$usenm'
  2963. incpath='$incpath'
  2964. mips='$mips'
  2965. mips_type='$mips_type'
  2966. usrinc='$usrinc'
  2967. EOT
  2968.  
  2969. : add special variables
  2970. $test -f patchlevel.h && \
  2971. awk '/^#define/ {printf "%s=%s %s%s\n",$2,$3,$4,$5}' patchlevel.h >>config.sh
  2972. echo "CONFIG=true" >>config.sh
  2973.  
  2974. : Finish up by extracting the .SH files
  2975. case "$alldone" in
  2976. exit)
  2977.     $rm -rf UU
  2978.     echo "Done."
  2979.     exit 0
  2980.     ;;
  2981. cont)
  2982.     ;;
  2983. '')
  2984.     echo " "
  2985.     dflt=''
  2986.     nostick=true
  2987. echo "If you didn't make any mistakes, then just type a carriage return here."
  2988.     rp="If you need to edit config.sh, do it as a shell escape here:"
  2989.     . UU/myread
  2990.     nostick=''
  2991.     case "$ans" in
  2992.     '') ;;
  2993.     *) : in case they cannot read
  2994.         sh 1>&4 -c "$ans";;
  2995.     esac
  2996.     ;;
  2997. esac
  2998.  
  2999. : if this fails, just run all the .SH files by hand
  3000. . ./config.sh
  3001.  
  3002. echo " "
  3003. exec 1>&4
  3004. . UU/extract
  3005.  
  3006. echo " "
  3007. echo 'Now type "make".'
  3008.  
  3009. $rm -f kit*isdone ark*isdone
  3010. $rm -rf UU
  3011. : End of Configure
  3012.