home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sources / misc / 4101 / Configure.a
Encoding:
Text File  |  1992-11-19  |  35.3 KB  |  1,600 lines

  1. #! /bin/sh
  2. #
  3. # If these # comments don't work, trim them. Don't worry about any
  4. # other 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. # Write to ram@eiffel.com (Raphael Manfredi) and I will send you the
  17. # latest revision of the dist package, which includes metaconfig.)
  18.  
  19. # $Id: Configure,v 2.9 92/07/14 16:46:52 ram Exp $
  20. #
  21. # Generated on Tue Jul 14 14:23:38 PDT 1992 [metaconfig 2.8 PL13]
  22.  
  23. cat >/tmp/c1$$ <<EOF
  24.  
  25. ARGGGHHHH!!!!!
  26.  
  27. SCO csh still thinks true is false.  Write to SCO today and tell them that next
  28. year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
  29.  
  30. (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
  31. we'd have to do is go in and swap the && and || tokens, wherever they are.)
  32.  
  33. [End of diatribe.  We now return you to your regularly scheduled programming...]
  34. EOF
  35. cat >/tmp/c2$$ <<EOF
  36.  
  37. OOPS!  You naughty creature!  You didn't run Configure with sh!
  38. I will attempt to remedy the situation by running sh for you...
  39. EOF
  40.  
  41. true || cat /tmp/c1$$ /tmp/c2$$
  42. true || exec sh $0
  43.  
  44. export PATH || cat /tmp/c2$$
  45. export PATH || exec sh $0
  46. rm -f /tmp/c1$$ /tmp/c2$$
  47.  
  48. : sanity checks
  49. PATH=".:$PATH:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin"
  50. PATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
  51. PATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb'
  52. PATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd:/bsd43/bin:/usr/ccs/bin'
  53. export PATH
  54.  
  55. if test ! -t 0; then
  56.     echo "Say 'sh Configure', not 'sh <Configure'"
  57.     exit 1
  58. fi
  59.  
  60. (alias) >/dev/null 2>&1 && \
  61.     echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
  62.     echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
  63.  
  64. test -d UU || mkdir UU
  65. cd UU && rm -f *
  66.  
  67. case "$1" in
  68. -d) shift; fastread='yes';;
  69. esac
  70.  
  71. d_bsd=''
  72. d_eunice=''
  73. d_xenix=''
  74. eunicefix=''
  75. Mcc=''
  76. awk=''
  77. bison=''
  78. cat=''
  79. chgrp=''
  80. chmod=''
  81. chown=''
  82. compress=''
  83. cp=''
  84. cpio=''
  85. cpp=''
  86. csh=''
  87. date=''
  88. echo=''
  89. egrep=''
  90. emacs=''
  91. expr=''
  92. grep=''
  93. inews=''
  94. less=''
  95. line=''
  96. lint=''
  97. ln=''
  98. lp=''
  99. lpr=''
  100. ls=''
  101. mail=''
  102. mailx=''
  103. make=''
  104. mkdir=''
  105. more=''
  106. mv=''
  107. nroff=''
  108. perl=''
  109. pg=''
  110. pmake=''
  111. pr=''
  112. rm=''
  113. rmail=''
  114. sed=''
  115. sendmail=''
  116. sleep=''
  117. smail=''
  118. sort=''
  119. submit=''
  120. tail=''
  121. tar=''
  122. tbl=''
  123. test=''
  124. touch=''
  125. tr=''
  126. troff=''
  127. uname=''
  128. uniq=''
  129. uuname=''
  130. vi=''
  131. zcat=''
  132. myuname=''
  133. Author=''
  134. Date=''
  135. Header=''
  136. Id=''
  137. Locker=''
  138. Log=''
  139. RCSfile=''
  140. Revision=''
  141. Source=''
  142. State=''
  143. bin=''
  144. cc=''
  145. ccflags=''
  146. cppflags=''
  147. ldflags=''
  148. lkflags=''
  149. optimize=''
  150. contains=''
  151. cppminus=''
  152. cppstdin=''
  153. d_bcopy=''
  154. aphostname=''
  155. d_gethname=''
  156. d_phostname=''
  157. d_uname=''
  158. d_hidnet=''
  159. hiddennet=''
  160. d_index=''
  161. d_portable=''
  162. d_rename=''
  163. d_strerrm=''
  164. d_strerror=''
  165. d_sysernlst=''
  166. d_syserrlst=''
  167. d_time=''
  168. timetype=''
  169. d_uwait=''
  170. d_vfork=''
  171. d_voidsig=''
  172. signal_t=''
  173. hostname=''
  174. mydomain=''
  175. phostname=''
  176. i_fcntl=''
  177. i_string=''
  178. strings=''
  179. i_sysfile=''
  180. i_syswait=''
  181. i_systime=''
  182. i_systimek=''
  183. i_time=''
  184. timeincl=''
  185. timezone=''
  186. intsize=''
  187. libc=''
  188. nm_opt=''
  189. libpth=''
  190. plibpth=''
  191. libs=''
  192. maildir=''
  193. mailfile=''
  194. manext=''
  195. mansrc=''
  196. mkdep=''
  197. huge=''
  198. large=''
  199. medium=''
  200. models=''
  201. small=''
  202. split=''
  203. c=''
  204. n=''
  205. orgname=''
  206. package=''
  207. perlpath=''
  208. pidtype=''
  209. privlib=''
  210. reg10=''
  211. reg11=''
  212. reg12=''
  213. reg13=''
  214. reg14=''
  215. reg15=''
  216. reg16=''
  217. reg1=''
  218. reg2=''
  219. reg3=''
  220. reg4=''
  221. reg5=''
  222. reg6=''
  223. reg7=''
  224. reg8=''
  225. reg9=''
  226. registers=''
  227. scriptdir=''
  228. sharpbang=''
  229. shsharp=''
  230. spitshell=''
  231. startsh=''
  232. sysman=''
  233. uidtype=''
  234. incpath=''
  235. mips=''
  236. mips_type=''
  237. usrinc=''
  238. d_whoami=''
  239. i_sysselct=''
  240. CONFIG=''
  241. : set package name
  242. package=mailagent
  243.  
  244. : Eunice requires " " instead of "", can you believe it
  245. echo " "
  246. : Here we go...
  247. echo "Beginning of configuration questions for $package kit."
  248.  
  249. define='define'
  250. undef='undef'
  251. smallmach='pdp11 i8086 z8000 i80286 iAPX286'
  252. rmlist='ark[1-9]isdone ark[1-9][0-9]isdone'
  253. trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3 15
  254.  
  255. : We must find out about Eunice early
  256. eunicefix=':'
  257. if test -f /etc/unixtovms; then
  258.     eunicefix=/etc/unixtovms
  259. fi
  260. if test -f /etc/unixtovms.exe; then
  261.     eunicefix=/etc/unixtovms.exe
  262. fi
  263.  
  264. : Find out which program gives a meaningful exit status
  265. if ls blurfl >/dev/null 2>&1; then
  266.     if awk '' blurfl >/dev/null 2>&1; then
  267.         check='cat'
  268.     else
  269.         check='awk ""'
  270.     fi
  271. else
  272.     check='ls'
  273. fi
  274.  
  275. : Now test for existence of everything in MANIFEST
  276. echo " "
  277. if test -f ../MANIFEST; then
  278.     echo "First let's make sure your kit is complete.  Checking..."
  279.     : some grep do not return a proper exit status
  280.     grep '^---' ../MANIFEST > .grepmani 2>/dev/null
  281.     if test -s .grepmani; then
  282. (cd ..; eval $check `awk '!/^.*\/$/{if (b) print $1}
  283. /^---/{b=1}' MANIFEST` || kill $$) >/dev/null
  284.     else
  285. (cd ..; eval $check `awk '!/^.*\/$/{print $1}' MANIFEST` || kill $$) >/dev/null
  286.     fi
  287.     echo "Looks good..."
  288. else
  289.     echo "No MANIFEST found. Hope your kit is complete !"
  290. fi
  291. rm -f .grepmani
  292.  
  293. : list of known cpp symbols
  294. attrlist="DGUX M_I186 M_I286 M_I386 M_I8086 M_XENIX UTS __DGUX__"
  295. attrlist="$attrlist _AIX __STDC__ __m88k__ ansi bsd4_2 gcos gimpel"
  296. attrlist="$attrlist hp9000s300 hp9000s500 hp9000s800 hpux"
  297. attrlist="$attrlist i186 i386 i486 i8086 iAPX286 ibm interdata"
  298. attrlist="$attrlist m88k mc300 mc500 mc68000 mc68k mc700 mert"
  299. attrlist="$attrlist mips ns16000 ns32000 nsc32000 os pdp11 posix pyr"
  300. attrlist="$attrlist sinix sony sparc sun tower tower32 tower32_600"
  301. attrlist="$attrlist tower32_800 tss u3b2 u3b20 u3b200 u3b5 ultrix unix"
  302. attrlist="$attrlist vax venix xenix z8000"
  303.  
  304. : no include file wanted by default
  305. inclwanted=''
  306.  
  307. : change the next line if compiling for Xenix/286 on Xenix/386
  308. xlibpath='/usr/lib/386 /lib/386'
  309. libpth='/usr/lib/large /lib '$xlibpth' /lib/large'
  310. libpth=$libpth' /usr/lib/small /lib/small'
  311.  
  312.  
  313. : some greps do not return status, grrr.
  314. echo "grimblepritz" >grimble
  315. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  316.     contains=contains
  317. elif grep grimblepritz grimble >/dev/null 2>&1 ; then
  318.     contains=grep
  319. else
  320.     contains=contains
  321. fi
  322. rm -f grimble
  323. : the following should work in any shell
  324. case "$contains" in
  325. contains*)
  326.     echo " "
  327.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  328.     cat >contains <<'EOSS'
  329. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  330. EOSS
  331. chmod +x contains
  332. esac
  333.  
  334. : first determine how to suppress newline on echo command
  335. echo " "
  336. echo "Checking echo to see how to suppress newlines..."
  337. (echo "hi there\c" ; echo " ") >.echotmp
  338. if $contains c .echotmp >/dev/null 2>&1 ; then
  339.     echo "...using -n."
  340.     n='-n'
  341.     c=''
  342. else
  343.     cat <<'EOM'
  344. ...using \c
  345. EOM
  346.     n=''
  347.     c='\c'
  348. fi
  349. echo $n "The star should be here-->$c"
  350. echo '*'
  351. rm -f .echotmp
  352.  
  353. : set up the echo used in my read
  354. myecho="case \"\$xxxm\" in
  355. '') echo $n \"\$rp $c\";;
  356. *) case \"\$rp\" in
  357.     '') echo $n \"[\$xxxm] $c\";;
  358.     *) echo $n \"\$rp [\$xxxm] $c\";;
  359.     esac;;
  360. esac"
  361.  
  362. : now set up to do reads with possible shell escape and default assignment
  363. cat <<EOSC >myread
  364. xxxm=\$dflt
  365. $myecho
  366. case "\$fastread" in
  367. yes) case "\$dflt" in
  368.     '') ans='!';;
  369.     *) ans=''; echo " " ;;
  370.     esac;;
  371. *) ans='!';;
  372. esac
  373. while expr "X\$ans" : "X!" >/dev/null; do
  374.     read answ
  375.     set x \$xxxm
  376.     shift
  377.     aok=''; eval "ans=\"\$answ\"" && aok=y
  378.     case  "\$answ" in
  379.     "\$ans")
  380.         case "\$ans" in
  381.         !)
  382.             sh
  383.             echo " "
  384.             $myecho
  385.             ;;
  386.         !*)
  387.             set x \`expr "X\$ans" : "X!\(.*\)\$"\`
  388.             shift
  389.             sh -c "\$*"
  390.             echo " "
  391.             $myecho
  392.             ;;
  393.         esac;;
  394.     *)
  395.         case "\$aok" in
  396.         y)
  397.             echo "*** Substitution done -- please confirm."
  398.             xxxm="\$ans"
  399.             ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
  400.             xxxm="\$ans"
  401.             ans=!
  402.             ;;
  403.         *)
  404.             echo "*** Error -- try again."
  405.             ans=!
  406.             ;;
  407.         esac
  408.         $myecho
  409.         ;;
  410.     esac
  411. done
  412. case "\$ans" in
  413. '') ans="\$xxxm";;
  414. esac
  415. EOSC
  416.  
  417. : general instructions
  418. cat <<EOH
  419.  
  420. This installation shell script will examine your system and ask you questions
  421. to determine how the mailagent package should be installed.  If you get stuck
  422. on a question, you may use a ! shell escape to start a subshell or execute a
  423. command.  Many of the questions will have default answers in square brackets;
  424. typing carriage return will give you the default.
  425.  
  426. On some of the questions which ask for file or directory names you are allowed
  427. to use the ~name construct to specify the login directory belonging to "name",
  428. even if you don't have a shell which knows about that.  Questions where this is
  429. allowed will be marked "(~name ok)".
  430.  
  431. EOH
  432. rp=''
  433. dflt="Type carriage return to continue"
  434. . myread
  435. cat <<'EOH'
  436.  
  437. The prompter used in this script allows you to use shell variables and
  438. backticks in your answers.  You may use $1, $2, etc...  to refer to the words
  439. in the default answer, as if the default line was a set of arguments given to a
  440. script shell.  This means you may also use $* to repeat the whole default line,
  441. so you do not have to re-type everything to add something to the default.
  442.  
  443. Everytime there is a substitution, you will have to confirm.  If there is an
  444. error (e.g. an unmatched backtick), the default answer will remain unchanged
  445. and you will be prompted again.
  446.  
  447. If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
  448. the questions and use the computed defaults (or the previous answers if there
  449. was already a config.sh file).
  450.  
  451. EOH
  452. . myread
  453. cat <<EOH
  454.  
  455. Much effort has been expended to ensure that this shell script will run on any
  456. Unix system.  If despite that it blows up on yours, your best bet is to edit
  457. Configure and run it again.  Also, let me (ram@eiffel.com)
  458. know how I blew it.  If you can't run Configure for some reason, you'll have to
  459. generate a config.sh file by hand.
  460.  
  461. This installation script affects things in two ways:
  462.  
  463. 1) it may do direct variable substitutions on some of the files included
  464.    in this kit.
  465. 2) it builds a config.h file for inclusion in C programs.  You may edit
  466.    any of these files as the need arises after running this script.
  467.  
  468. If you make a mistake on a question, there is no easy way to back up to it
  469. currently.  The easiest thing to do is to edit config.sh and rerun all the SH
  470. files.  Configure will offer to let you do this before it runs the SH files.
  471.  
  472. EOH
  473. dflt="Type carriage return to continue"
  474. . myread
  475.  
  476. : see if sh knows # comments
  477. echo " "
  478. echo "Checking your sh to see if it knows about # comments..."
  479. if sh -c '#' >/dev/null 2>&1 ; then
  480.     echo "Your sh handles # comments correctly."
  481.     shsharp=true
  482.     spitshell=cat
  483.     echo " "
  484.     echo "Okay, let's see if #! works on this system..."
  485.     echo "#!/bin/cat" >try
  486.     $eunicefix try
  487.     chmod +x try
  488.     try > today
  489.     if test -s today; then
  490.         echo "It does."
  491.         sharpbang='#!'
  492.     else
  493.         echo "#! /bin/cat" > try
  494.         $eunicefix try
  495.         chmod +x try
  496.         try > today
  497.         if test -s today; then
  498.             echo "It does."
  499.             sharpbang='#! '
  500.         else
  501.             echo "It doesn't."
  502.             sharpbang=': use '
  503.         fi
  504.     fi
  505. else
  506.     echo "Your sh doesn't grok # comments--I will strip them later on."
  507.     shsharp=false
  508.     echo "exec grep -v '^[     ]*#'" >spitshell
  509.     chmod +x spitshell
  510.     $eunicefix spitshell
  511.     spitshell=`pwd`/spitshell
  512.     echo "I presume that if # doesn't work, #! won't work either!"
  513.     sharpbang=': use '
  514. fi
  515. rm -f try today
  516.  
  517. : figure out how to guarantee sh startup
  518. echo " "
  519. echo "Checking out how to guarantee sh startup..."
  520. startsh=$sharpbang'/bin/sh'
  521. echo "Let's see if '$startsh' works..."
  522. cat >try <<EOSS
  523. $startsh
  524. set abc
  525. test "$?abc" != 1
  526. EOSS
  527.  
  528. chmod +x try
  529. $eunicefix try
  530. if try; then
  531.     echo "Yup, it does."
  532. else
  533.     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  534. fi
  535. rm -f try
  536.  
  537. : find out where common programs are
  538. echo " "
  539. echo "Locating common programs..."
  540. cat <<EOSC >loc
  541. $startsh
  542. case \$# in
  543. 0) exit 1;;
  544. esac
  545. thing=\$1
  546. shift
  547. dflt=\$1
  548. shift
  549. for dir in \$*; do
  550.     case "\$thing" in
  551.     .)
  552.     if test -d \$dir/\$thing; then
  553.         echo \$dir
  554.         exit 0
  555.     fi
  556.     ;;
  557.     *)
  558.     if test -f \$dir/\$thing; then
  559.         echo \$dir/\$thing
  560.         exit 0
  561.     elif test -f \$dir/\$thing.exe; then
  562.         : on Eunice apparently
  563.         echo \$dir/\$thing
  564.         exit 0
  565.     fi
  566.     ;;
  567.     esac
  568. done
  569. echo \$dflt
  570. exit 1
  571. EOSC
  572. chmod +x loc
  573. $eunicefix loc
  574. loclist="
  575. awk
  576. cat
  577. chgrp
  578. chmod
  579. chown
  580. echo
  581. expr
  582. grep
  583. mv
  584. rm
  585. sed
  586. sleep
  587. sort
  588. tr
  589. uniq
  590. "
  591. trylist="
  592. Mcc
  593. cpp
  594. date
  595. inews
  596. nroff
  597. perl
  598. test
  599. uname
  600. zcat
  601. "
  602. pth=`echo $PATH | sed -e 's/:/ /g'`
  603. pth="$pth /lib /usr/lib"
  604. for file in $loclist; do
  605.     xxx=`loc $file $file $pth`
  606.     eval $file=$xxx
  607.     eval _$file=$xxx
  608.     case "$xxx" in
  609.     /*)
  610.     echo $file is in $xxx.
  611.     ;;
  612.     *)
  613.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  614.     ;;
  615.     esac
  616. done
  617. echo " "
  618. echo "Don't worry if any of the following aren't found..."
  619. ans=offhand
  620. for file in $trylist; do
  621.     xxx=`loc $file $file $pth`
  622.     eval $file=$xxx
  623.     eval _$file=$xxx
  624.     case "$xxx" in
  625.     /*)
  626.     echo $file is in $xxx.
  627.     ;;
  628.     *)
  629.     echo "I don't see $file out there, $ans."
  630.     ans=either
  631.     ;;
  632.     esac
  633. done
  634. case "$egrep" in
  635. egrep)
  636.     echo "Substituting grep for egrep."
  637.     egrep=$grep
  638.     ;;
  639. esac
  640. case "$test" in
  641. test)
  642.     echo "Hopefully test is built into your sh."
  643.     ;;
  644. /bin/test)
  645.     if sh -c "PATH= test true" >/dev/null 2>&1; then
  646.     echo "Using the test built into your sh."
  647.     test=test
  648.     fi
  649.     ;;
  650. *)
  651.     test=test
  652.     ;;
  653. esac
  654. case "$echo" in
  655. echo)
  656.     echo "Hopefully echo is built into your sh."
  657.     ;;
  658. /bin/echo)
  659.     echo " "
  660.     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  661.     $echo $n "hi there$c" >foo1
  662.     echo $n "hi there$c" >foo2
  663.     if cmp foo1 foo2 >/dev/null 2>&1; then
  664.     echo "They are compatible.  In fact, they may be identical."
  665.     else
  666.     case "$n" in
  667.     '-n') n='' c='\c';;
  668.     *) n='-n' c='';;
  669.     esac
  670.     cat <<FOO
  671. They are not compatible!  You are probably running ksh on a non-USG system.
  672. I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
  673. have echo built in and we may have to run some Bourne shell scripts.  That
  674. means I'll have to use $ans to suppress newlines now.  Life is ridiculous.
  675.  
  676. FOO
  677.     $echo $n "The star should be here-->$c"
  678.     $echo "*"
  679.     fi
  680.     $rm -f foo1 foo2
  681.     ;;
  682. *)
  683.     : cross your fingers
  684.     echo=echo
  685.     ;;
  686. esac
  687. rmlist="$rmlist loc"
  688.  
  689. : try to determine whether config.sh was made on this system
  690. myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
  691. dflt=n
  692. if test -f ../config.sh; then
  693.     xxx=$myuname
  694.     eval "`grep myuname= ../config.sh`"
  695.     if test "X$xxx" = "X$myuname"; then
  696.         dflt=y
  697.     fi
  698. fi
  699.  
  700. : get old answers, if there is a config file out there
  701. hint=default
  702. if test -f ../config.sh; then
  703.     echo " "
  704.     rp="I see a config.sh file.  Did Configure make it on THIS system?"
  705.     . myread
  706.     case "$ans" in
  707.     n*|N*) echo "OK, I'll ignore it.";;
  708.     *)  echo "Fetching default answers from your old config.sh file..."
  709.         tmp="$n"
  710.         ans="$c"
  711.         . ../config.sh
  712.         cp ../config.sh .
  713.         n="$tmp"
  714.         c="$ans"
  715.         hint=previous
  716.         ;;
  717.     esac
  718. fi
  719.  
  720. : restore computed paths
  721. for file in $loclist $trylist; do
  722.     eval $file="\$_$file"
  723. done
  724.  
  725. : preserve RCS keywords in files with variable substitution, grrr
  726. Header='$Header'
  727. Id='$Id'
  728. Log='$Log'
  729.  
  730. : make some quick guesses about what we are up against
  731. echo " "
  732. $echo $n "Hmm...  $c"
  733. $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
  734. if test `echo abc | tr a-z A-Z` = Abc ; then
  735.     xxx=`./loc addbib blurfl $pth`
  736.     if $test -f $xxx; then
  737.         echo "Looks kind of like a USG system with BSD features, but we'll see..."
  738.         echo exit 0 >bsd
  739.         echo exit 0 >usg
  740.         echo exit 1 >v7
  741.     else
  742.         if $contains SIGTSTP foo >/dev/null 2>&1 ; then
  743.             echo "Looks kind of like an extended USG system, but we'll see..."
  744.         else
  745.             echo "Looks kind of like a USG system, but we'll see..."
  746.         fi
  747.         echo exit 1 >bsd
  748.         echo exit 0 >usg
  749.         echo exit 1 >v7
  750.     fi
  751.     d_bsd="$undef"
  752. elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  753.     echo "Looks kind of like a BSD system, but we'll see..."
  754.     d_bsd="$define"
  755.     echo exit 0 >bsd
  756.     echo exit 1 >usg
  757.     echo exit 1 >v7
  758. else
  759.     echo "Looks kind of like a Version 7 system, but we'll see..."
  760.     d_bsd="$undef"
  761.     echo exit 1 >bsd
  762.     echo exit 1 >usg
  763.     echo exit 0 >v7
  764. fi
  765. case "$eunicefix" in
  766. *unixtovms*)
  767.     cat <<'EOI'
  768. There is, however, a strange, musty smell in the air that reminds me of
  769. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  770. EOI
  771.     echo "exit 0" >eunice
  772.     eunicefix=unixtovms
  773.     d_eunice="$define"
  774. : it so happens the Eunice I know will not run shell scripts in Unix format
  775.     ;;
  776. *)
  777.     echo " "
  778.     echo "Congratulations.  You aren't running Eunice."
  779.     eunicefix=':'
  780.     d_eunice="$undef"
  781.     echo "exit 1" >eunice
  782.     ;;
  783. esac
  784. if test -f /xenix; then
  785.     echo "Actually, this looks more like a XENIX system..."
  786.     echo "exit 0" >xenix
  787.     d_xenix="$define"
  788. else
  789.     echo " "
  790.     echo "It's not Xenix..."
  791.     echo "exit 1" >xenix
  792.     d_xenix="$undef"
  793. fi
  794. chmod +x xenix
  795. $eunicefix xenix
  796. if test -f /venix; then
  797.     echo "Actually, this looks more like a VENIX system..."
  798.     echo "exit 0" >venix
  799. else
  800.     echo " "
  801.     if xenix; then
  802.     : null
  803.     else
  804.     echo "Nor is it Venix..."
  805.     fi
  806.     echo "exit 1" >venix
  807. fi
  808. chmod +x bsd usg v7 eunice venix
  809. $eunicefix bsd usg v7 eunice venix
  810. $rm -f foo
  811. rmlist="$rmlist bsd usg v7 eunice venix xenix"
  812.  
  813. : set up shell script to do ~ expansion
  814. cat >filexp <<EOSS
  815. $startsh
  816. : expand filename
  817. case "\$1" in
  818.  ~/*|~)
  819.     echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  820.     ;;
  821.  ~*)
  822.     if $test -f /bin/csh; then
  823.     /bin/csh -f -c "glob \$1"
  824.     echo ""
  825.     else
  826.     name=\`$expr x\$1 : '..\([^/]*\)'\`
  827.     dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  828.     if $test ! -d "\$dir"; then
  829.         me=\`basename \$0\`
  830.         echo "\$me: can't locate home directory for: \$name" >&2
  831.         exit 1
  832.     fi
  833.     case "\$1" in
  834.     */*)
  835.         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  836.         ;;
  837.     *)
  838.         echo \$dir
  839.         ;;
  840.     esac
  841.     fi
  842.     ;;
  843. *)
  844.     echo \$1
  845.     ;;
  846. esac
  847. EOSS
  848. chmod +x filexp
  849. $eunicefix filexp
  850.  
  851. : determine where manual pages are on this system
  852. echo " "
  853. case "$sysman" in
  854. '') sysman=`loc . /usr/man/man1 /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/share/man/man1 /usr/catman/u_man/man1 /usr/man/l_man/man1 /usr/local/man/u_man/man1 /usr/local/man/l_man/man1 /usr/man/man.L`
  855.     ;;
  856. esac
  857. if test -d "$sysman"; then
  858.     echo "System manual is in $sysman."
  859. else
  860.     echo "Could not find manual pages in source form."
  861. fi
  862.  
  863. : see what memory models we can support
  864. case "$models" in
  865. '')
  866.     $cat >pdp11.c <<'EOP'
  867. main() {
  868. #ifdef pdp11
  869.     exit(0);
  870. #else
  871.     exit(1);
  872. #endif
  873. }
  874. EOP
  875.     cc -o pdp11 pdp11.c >/dev/null 2>&1
  876.     if pdp11 2>/dev/null; then
  877.         dflt='unsplit split'
  878.     else
  879.         ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
  880.         case "$ans" in
  881.         X) dflt='none';;
  882.         *) if $test -d /lib/small || $test -d /usr/lib/small; then
  883.                 dflt='small'
  884.             else
  885.                 dflt=''
  886.             fi
  887.             if $test -d /lib/medium || $test -d /usr/lib/medium; then
  888.                 dflt="$dflt medium"
  889.             fi
  890.             if $test -d /lib/large || $test -d /usr/lib/large; then
  891.                 dflt="$dflt large"
  892.             fi
  893.             if $test -d /lib/huge || $test -d /usr/lib/huge; then
  894.                 dflt="$dflt huge"
  895.             fi
  896.         esac
  897.     fi;;
  898. *) dflt="$models";;
  899. esac
  900. $cat <<EOM
  901.  
  902. Some systems have different model sizes.  On most systems they are called
  903. small, medium, large, and huge.  On the PDP11 they are called unsplit and
  904. split.  If your system doesn't support different memory models, say "none".
  905. If you wish to force everything to one memory model, say "none" here and
  906. put the appropriate flags later when it asks you for other cc and ld flags.
  907. Venix systems may wish to put "none" and let the compiler figure things out.
  908. (In the following question multiple model names should be space separated.)
  909.  
  910. EOM
  911. rp="Which models are supported?"
  912. . myread
  913. models="$ans"
  914.  
  915. case "$models" in
  916. none)
  917.     small=''
  918.     medium=''
  919.     large=''
  920.     huge=''
  921.     unsplit=''
  922.     split=''
  923.     ;;
  924. *split)
  925.     case "$split" in
  926.     '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
  927.              $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
  928.             dflt='-i'
  929.         else
  930.             dflt='none'
  931.         fi;;
  932.     *) dflt="$split";;
  933.     esac
  934.     rp="What flag indicates separate I and D space?"
  935.     . myread
  936.     case "$ans" in
  937.     none) ans='';;
  938.     esac
  939.     split="$ans"
  940.     unsplit='';;
  941. *large*|*small*|*medium*|*huge*)
  942.     case "$model" in
  943.     *large*)
  944.         case "$large" in
  945.         '') dflt='-Ml';;
  946.         *) dflt="$large";;
  947.         esac
  948.     rp="What flag indicates large model?"
  949.     . myread
  950.     case "$ans" in
  951.     none) ans='';
  952.     esac
  953.     large="$ans";;
  954.     *) large='';;
  955.     esac
  956.     case "$model" in
  957.     *huge*) case "$huge" in
  958.         '') dflt='-Mh';;
  959.         *) dflt="$huge";;
  960.         esac
  961.         rp="What flag indicates huge model?"
  962.         . myread
  963.         case "$ans" in
  964.         none) ans='';
  965.         esac
  966.         huge="$ans";;
  967.     *) huge="$large";;
  968.     esac
  969.     case "$model" in
  970.     *medium*) case "$medium" in
  971.         '') dflt='-Mm';;
  972.         *) dflt="$medium";;
  973.         esac
  974.         rp="What flag indicates medium model?"
  975.         . myread
  976.         case "$ans" in
  977.         none) ans='';
  978.         esac
  979.         medium="$ans";;
  980.     *) medium="$large";;
  981.     esac
  982.     case "$model" in
  983.     *small*) case "$small" in
  984.         '') dflt='none';;
  985.         *) dflt="$small";;
  986.         esac
  987.         rp="What flag indicates small model?"
  988.         . myread
  989.         case "$ans" in
  990.         none) ans='';
  991.         esac
  992.         small="$ans";;
  993.     *) small='';;
  994.     esac
  995.     ;;
  996. *)
  997.     echo "Unrecognized memory models--you may have to edit Makefile.SH"
  998.     ;;
  999. esac
  1000.  
  1001. : see if we need a special compiler
  1002. echo " "
  1003. if usg; then
  1004.     case "$cc" in
  1005.     '') case "$Mcc" in
  1006.         /*) dflt='Mcc';;
  1007.         *) case "$large" in
  1008.             -M*) dflt='cc';;
  1009.             *)    if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
  1010.                     if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
  1011.                         dflt='cc'
  1012.                     else
  1013.                         dflt='cc -M'
  1014.                     fi
  1015.                 else
  1016.                     dflt='cc'
  1017.                 fi;;
  1018.             esac;;
  1019.         esac;;
  1020.     *)  dflt="$cc";;
  1021.     esac
  1022.     $cat <<'EOM'
  1023. On some systems the default C compiler will not resolve multiple global
  1024. references that happen to have the same name.  On some such systems the "Mcc"
  1025. command may be used to force these to be resolved.  On other systems a "cc -M"
  1026. command is required.  (Note that the -M flag on other systems indicates a
  1027. memory model to use!) If you have the Gnu C compiler, you might wish to use
  1028. that instead.
  1029.  
  1030. EOM
  1031.     rp="What command will force resolution on this system?"
  1032.     . myread
  1033.     cc="$ans"
  1034. else
  1035.     case "$cc" in
  1036.     '') dflt=cc;;
  1037.     *) dflt="$cc";;
  1038.     esac
  1039.     rp="Use which C compiler?"
  1040.     . myread
  1041.     cc="$ans"
  1042. fi
  1043. case "$cc" in
  1044. gcc*) cpp=`loc gcc-cpp $cpp $pth`;;
  1045. esac
  1046.  
  1047. : What should the include directory be ?
  1048. echo " "
  1049. $echo $n "Hmm...  $c"
  1050. case "$usrinc" in
  1051. '') dflt='/usr/include';;
  1052. *) dflt=$usrinc;;
  1053. esac
  1054. incpath=''
  1055. mips_type=''
  1056. if $test -f /bin/mips && /bin/mips; then
  1057.     echo "Looks like a MIPS system..."
  1058.     $cat >usr.c <<'EOCP'
  1059. #ifdef SYSTYPE_BSD43
  1060. /bsd43
  1061. #endif
  1062. EOCP
  1063.     if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
  1064.         dflt='/bsd43/usr/include'
  1065.         incpath='/bsd43'
  1066.         mips_type='BSD 4.3'
  1067.     else
  1068.         mips_type='System V'
  1069.     fi
  1070.     echo "and you're compiling with the $mips_type compiler and libraries."
  1071. else
  1072.     echo "Doesn't look like a MIPS system."
  1073.     echo "exit 1" >mips
  1074.     chmod +x mips
  1075.     $eunicefix mips
  1076. fi
  1077. cont=true
  1078. while $test "$cont"; do
  1079.     echo " "
  1080.     rp="Where are the include files you want to use?"
  1081.     . myread
  1082.     usrinc="$ans"
  1083.     if $test -d "$ans"; then
  1084.         cont=''
  1085.     else
  1086.         if $test "$fastread" = yes; then
  1087.             dflt=y
  1088.         else
  1089.             dflt=n
  1090.         fi
  1091.         rp="Directory $ans doesn't exist.  Use that name anyway?"
  1092.         . myread
  1093.         dflt=''
  1094.         case "$ans" in
  1095.         y*) cont='';;
  1096.         esac
  1097.     fi
  1098. done
  1099. $rm -f usr.c usr.out
  1100.  
  1101. : now get the host name
  1102. echo " "
  1103. echo "Figuring out host name..."
  1104. cont=true
  1105. echo 'Maybe "hostname" will work...'
  1106. if ans=`sh -c hostname 2>&1` ; then
  1107.     hostname=$ans
  1108.     phostname=hostname
  1109.     cont=''
  1110. fi
  1111. if $test "$cont"; then
  1112.     if xenix; then
  1113.         echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
  1114.         if ans=`cat /etc/systemid 2>&1` ; then
  1115.             hostname=$ans
  1116.             phostname='cat /etc/systemid'
  1117.             echo "Whadyaknow.  Xenix always was a bit strange..."
  1118.             cont=''
  1119.         fi
  1120.     elif $test -r /etc/systemid; then
  1121.         echo "(What is a non-Xenix system doing with /etc/systemid?)"
  1122.     fi
  1123. fi
  1124. if $test "$cont"; then
  1125.     echo 'No, maybe "uuname -l" will work...'
  1126.     if ans=`sh -c 'uuname -l' 2>&1` ; then
  1127.         hostname=$ans
  1128.         phostname='uuname -l'
  1129.     else
  1130.         echo 'Strange.  Maybe "uname -n" will work...'
  1131.         if ans=`sh -c 'uname -n' 2>&1` ; then
  1132.             hostname=$ans
  1133.             phostname='uname -n'
  1134.         else
  1135.             echo 'Oh well, maybe I can mine it out of whoami.h...'
  1136.             if ans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
  1137.                 hostname=`echo "$ans" | $sed 's/^.*"\(.*\)"/\1/'`
  1138.                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
  1139.             else
  1140.                 case "$hostname" in
  1141.                 '') echo "Does this machine have an identity crisis or something?"
  1142.                     phostname='';;
  1143.                 *) echo "Well, you said $hostname before...";;
  1144.                 esac
  1145.             fi
  1146.         fi
  1147.     fi
  1148. fi
  1149. : you do not want to know about this
  1150. set $hostname
  1151. hostname=$1
  1152.  
  1153. : translate upper to lower if necessary
  1154. case "$hostname" in
  1155. *[A-Z]*)
  1156.     hostname=`echo $hostname | tr '[A-Z]' '[a-z]'`
  1157.     echo "(Normalizing case in your host name)"
  1158.     ;;
  1159. esac
  1160.  
  1161. : verify guess
  1162. if $test "$hostname" ; then
  1163.     dflt=y
  1164.     rp='Your host name appears to be "'$hostname'".'" Right?"
  1165.     . myread
  1166.     case "$ans" in
  1167.     y*) ;;
  1168.     *) hostname='';;
  1169.     esac
  1170. fi
  1171.  
  1172. : bad guess or no guess
  1173. while $test "X$hostname" = X ; do
  1174.     dflt=''
  1175.     rp="Please type the (one word) name of your host:"
  1176.     . myread
  1177.     hostname="$ans"
  1178. done
  1179.  
  1180. case "$hostname" in
  1181. *.*)
  1182.     dflt=`expr "X$hostname" : "X[^.]*\(\..*\)"`
  1183.     hostname=`expr "X$hostname" : "X\([^.]*\)\."`
  1184.     echo "(Trimming domain name from host name--host name is now $hostname)"
  1185.     ;;
  1186. *) case "$mydomain" in
  1187.     '') dflt=.`$awk "/[0-9].*$hostname/ {for(i=2; i<=NF;i++) print \\\$i}" /etc/hosts|
  1188.         $sort|$uniq|$sed -n -e "s/$hostname\.\([a-zA-Z_.]\)/\1/p"`
  1189.         case "$dflt" in
  1190.         .) echo "(You do not have fully-qualified names in /etc/hosts)"
  1191.             dflt='.uucp';;
  1192.         esac;;
  1193.     *) dflt="$mydomain";;
  1194.     esac;;
  1195. esac
  1196. echo " "
  1197. rp="What is your domain name?"
  1198. . myread
  1199. case "$ans" in
  1200. '') ;;
  1201. .*) ;;
  1202. *) ans=".$ans";;
  1203. esac
  1204. mydomain="$ans"
  1205.  
  1206. : a little sanity check here
  1207. case "$phostname" in
  1208. '') ;;
  1209. *)
  1210.     case `$phostname` in
  1211.     $hostname$mydomain|$hostname) ;;
  1212.     *)
  1213.         case "$phostname" in
  1214.         sed*)
  1215.             echo "(That doesn't agree with your whoami.h file, by the way.)"
  1216.             ;;
  1217.         *)
  1218.             echo "(That doesn't agree with your $phostname command, by the way.)"
  1219.             ;;
  1220.         esac
  1221.     phostname=''
  1222.     ;;
  1223.     esac
  1224.     ;;
  1225. esac
  1226.  
  1227. : decide how portable to be
  1228. case "$d_portable" in
  1229. "$define") dflt=y;;
  1230. *)    dflt=n;;
  1231. esac
  1232. $cat <<'EOH'
  1233.  
  1234. I can set things up so that your shell scripts and binaries are more portable,
  1235. at what may be a noticable cost in performance.  In particular, if you
  1236. ask to be portable, the following happens:
  1237.  
  1238.      1) Shell scripts will rely on the PATH variable rather than using
  1239.     the paths derived above.
  1240.      2) ~username interpretations will be done at run time rather than
  1241.     by Configure.
  1242.      3) The system name will be determined at run time, if at all possible.
  1243.  
  1244. EOH
  1245. rp="Do you expect to run these scripts and binaries on multiple machines?"
  1246. . myread
  1247. case "$ans" in
  1248.     y*) d_portable="$define"
  1249.     for file in $loclist; do
  1250.         eval $file=$file
  1251.     done
  1252.     ;;
  1253.     *)  d_portable="$undef" ;;
  1254. esac
  1255.  
  1256. : Set private lib path
  1257. case "$plibpth" in
  1258. '') if mips; then
  1259.         plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
  1260.     else
  1261.         plibpth="/usr/ccs/lib /usr/lib /usr/ucblib /usr/local/lib"
  1262.     fi;;
  1263. esac
  1264. libpth="$plibpth $libpth"
  1265.  
  1266. : Looking for optional libraries
  1267. echo " "
  1268. echo "Checking for optional libraries..."
  1269. case "$libs" in
  1270. '') dflt='';;
  1271. *) dflt="$libs";;
  1272. esac
  1273. case "$libswanted" in
  1274. '') libswanted='c_s';;
  1275. esac
  1276. for thislib in $libswanted; do
  1277.     case "$thislib" in
  1278.     dbm) thatlib=ndbm;;
  1279.     *_s) thatlib=NONE;;
  1280.     *) thatlib="${thislib}_s";;
  1281.     *) thatlib=NONE;;
  1282.     esac
  1283.     yyy="$incpath/usr/ccs/lib $incpath/usr/lib $incpath/usr/ucblib"
  1284.     yyy="$yyy $incpath/usr/local/lib $incpath/lib"
  1285.     xxx=`loc lib$thislib.a X $yyy`
  1286.     if $test -f $xxx; then
  1287.         echo "Found -l$thislib."
  1288.         case "$dflt" in
  1289.         *-l$thislib*|*-l$thatlib*);;
  1290.         *) dflt="$dflt -l$thislib";;
  1291.         esac
  1292.     else
  1293.         xxx=`loc lib$thislib.a X $libpth`
  1294.         if $test -f $xxx; then
  1295.             echo "Found $xxx."
  1296.             case "$dflt" in
  1297.             *$xxx*);;
  1298.             *) dflt="$dflt $xxx";;
  1299.             esac
  1300.         else
  1301.             xxx=`loc Slib$thislib.a X $xlibpth`
  1302.             if $test -f $xxx; then
  1303.                 echo "Found -l$thislib."
  1304.                 case "$dflt" in
  1305.                 *-l$thislib*|*-l$thatlib*);;
  1306.                 *) dflt="$dflt -l$thislib";;
  1307.                 esac
  1308.             else
  1309.                 echo "No -l$thislib."
  1310.             fi
  1311.         fi
  1312.     fi
  1313. done
  1314. set X $dflt
  1315. shift
  1316. dflt="$*"
  1317. case "$libs" in
  1318. '') dflt="$dflt";;
  1319. *) dflt="$libs";;
  1320. esac
  1321. case "$dflt" in
  1322. '') dflt='none';;
  1323. esac
  1324.  
  1325. $cat <<EOM
  1326.  
  1327. Some versions of Unix support shared libraries, which make executables smaller
  1328. but make load time slightly longer.
  1329.  
  1330. On some systems, mostly newer Unix System V's, the shared library is included
  1331. by putting the option "-lc_s" as the last thing on the cc command line when
  1332. linking.  Other systems use shared libraries by default.  There may be other
  1333. libraries needed to compile $package on your machine as well.  If your system
  1334. needs the "-lc_s" option, include it here.  Include any other special libraries
  1335. here as well.  Say "none" for none.
  1336. EOM
  1337.  
  1338. echo " "
  1339. rp="Any additional libraries?"
  1340. . myread
  1341. case "$ans" in
  1342. none) ans='';
  1343. esac
  1344. libs="$ans"
  1345.  
  1346. : get list of predefined functions in a handy place
  1347. echo " "
  1348. case "$libc" in
  1349. '') libc=unknown;;
  1350. esac
  1351. case "$nm_opt" in
  1352. '') if $test -f /mach_boot; then
  1353.         nm_opt=''
  1354.     elif $test -d /usr/ccs/lib; then
  1355.         nm_opt='-p'
  1356.     elif $test -f /dgux; then
  1357.         nm_opt='-p'
  1358.     else
  1359.         nm_opt=''
  1360.     fi;;
  1361. esac
  1362. libpth="$plibpth $libpth"
  1363. case "$libs" in
  1364. *-lc_s*) libc=`loc libc_s.a $libc $libpth`
  1365. esac
  1366. libnames='';
  1367. case "$libs" in
  1368. '') ;;
  1369. *)  for thislib in $libs; do
  1370.     case "$thislib" in
  1371.     -l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
  1372.         try=`loc lib$thislib.a blurfl/dyick $libpth`
  1373.         if test ! -f $try; then
  1374.         try=`loc lib$thislib blurfl/dyick $libpth`
  1375.         if test ! -f $try; then
  1376.             try=`loc $thislib blurfl/dyick $libpth`
  1377.             if test ! -f $try; then
  1378.             try=`loc Slib$thislib.a blurfl/dyick $xlibpth`
  1379.             if test ! -f $try; then
  1380.                 try=''
  1381.             fi
  1382.             fi
  1383.         fi
  1384.         fi
  1385.         libnames="$libnames $try"
  1386.         ;;
  1387.     *) libnames="$libnames $thislib" ;;
  1388.     esac
  1389.     done
  1390.     ;;
  1391. esac
  1392. set /usr/ccs/lib/libc.so
  1393. $test -f $1 || set /usr/lib/libc.so
  1394. $test -f $1 || set /usr/lib/libc.so.[0-9]*
  1395. $test -f $1 || set /lib/libsys_s.a
  1396. eval set \$$#
  1397. if test -f "$1"; then
  1398.     echo "Your (shared) C library seems to be in $1."
  1399.     libc="$1"
  1400. elif test -f /lib/libc && test -f /lib/clib; then
  1401.     echo "Your C library seems to be in both /lib/clib and /lib/libc."
  1402.     libc='/lib/clib /lib/libc'
  1403.     if test -f /lib/syslib; then
  1404.         echo "(Your math library is in /lib/syslib.)"
  1405.         libc="$libc /lib/syslib"
  1406.     fi
  1407. elif test -f "$libc"; then
  1408.     echo "Your C library seems to be in $libc, as you said before."
  1409. elif test -f $incpath/usr/lib/libc.a; then
  1410.     libc=$incpath/usr/lib/libc.a;
  1411.     echo "Your C library seems to be in $libc.  That's fine."
  1412. elif test -f /lib/libc.a; then
  1413.     libc=/lib/libc.a;
  1414.     echo "Your C library seems to be in $libc.  You're normal."
  1415. else
  1416.     if ans=`./loc libc.a blurfl/dyick $libpth`; test -f "$ans"; then
  1417.         :
  1418.     elif ans=`./loc libc blurfl/dyick $libpth`; test -f "$ans"; then
  1419.         libnames="$libnames "`./loc clib blurfl/dyick $libpth`
  1420.     elif ans=`./loc clib blurfl/dyick $libpth`; test -f "$ans"; then
  1421.         :
  1422.     elif ans=`./loc Slibc.a blurfl/dyick $xlibpth`; test -f "$ans"; then
  1423.         :
  1424.     elif ans=`./loc Mlibc.a blurfl/dyick $xlibpth`; test -f "$ans"; then
  1425.         :
  1426.     else
  1427.         ans=`./loc Llibc.a blurfl/dyick $xlibpth`
  1428.     fi
  1429.     if test -f "$ans"; then
  1430.         echo "Your C library seems to be in $ans, of all places."
  1431.         libc=$ans
  1432.     else
  1433.         libc='blurfl'
  1434.     fi
  1435. fi
  1436. if $test -f "$libc"; then
  1437.     dflt="$libc"
  1438.     cat <<EOM
  1439.  
  1440. If the guess above is wrong (which it might be if you're using a strange
  1441. compiler, or your machine supports multiple models), you can override it here.
  1442.  
  1443. EOM
  1444. else
  1445.     dflt=''
  1446.     echo $libpth | tr ' ' '\012' | sort | uniq > libpath
  1447.     cat <<EOM
  1448. I can't seem to find your C library.  I've looked in the following places:
  1449.  
  1450. EOM
  1451.     $sed 's/^/    /' libpath
  1452.     cat <<EOM
  1453.  
  1454. None of these seems to contain your C library. I need to get its name...
  1455.  
  1456. EOM
  1457. fi
  1458. cont=true
  1459. while $test "$cont"; do
  1460.     rp="Where is your C library?"
  1461.     . myread
  1462.     libc="$ans"
  1463.     if $test -f "$libc"; then
  1464.         cont=''
  1465.     else
  1466.         case "$fastread" in
  1467.         yes) dflt=y;;
  1468.         *) dflt=n;;
  1469.         esac
  1470.         rp="File $libc does not exist. Use that name anyway?"
  1471.         . myread
  1472.         case "$ans" in
  1473.         y*) cont='';;
  1474.         esac
  1475.         dflt=''
  1476.     fi
  1477. done
  1478. echo " "
  1479. echo $libc $libnames | tr ' ' '\012' | sort | uniq > libnames
  1480. set X `cat libnames`
  1481. shift
  1482. xxx=files
  1483. case $# in 1) xxx=file; esac
  1484. echo "Extracting names from the following $xxx for later perusal:"
  1485. echo " "
  1486. $sed 's/^/    /' libnames
  1487. echo " "
  1488. $echo $n "This may take a while...$c"
  1489. nm $nm_opt $* 2>/dev/null >libc.tmp
  1490. $echo $n ".$c"
  1491. $grep fprintf libc.tmp > libc.ptf
  1492. xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c"'
  1493. xrun='eval "<libc.tmp $com >libc.list"; echo "done"'
  1494. if com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
  1495.     eval $xscan;\
  1496.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1497.         eval $xrun
  1498. elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
  1499.     eval $xscan;\
  1500.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1501.         eval $xrun
  1502. elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
  1503.     eval $xscan;\
  1504.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1505.         eval $xrun
  1506. elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
  1507.     eval $xscan;\
  1508.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1509.         eval $xrun
  1510. elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
  1511.     eval $xscan;\
  1512.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1513.         eval $xrun
  1514. elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
  1515.     eval $xscan;\
  1516.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1517.         eval $xrun
  1518. elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
  1519.                 -e '/ file/d' -e 's/^\([^     ]*\).*/\1/p'";\
  1520.     eval $xscan;\
  1521.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1522.         eval $xrun
  1523. elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
  1524.     eval $xscan;\
  1525.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1526.         eval $xrun
  1527. elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
  1528.     eval $xscan;\
  1529.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1530.         eval $xrun
  1531. else
  1532.     nm -p $* 2>/dev/null >libc.tmp
  1533.     com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
  1534.     eval "<libc.tmp $com >libc.list"
  1535.     if $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1536.         nm_opt='-p'
  1537.         echo "done"
  1538.     else
  1539.         echo " "
  1540.         echo "nm didn't seem to work right. Trying ar instead..."
  1541.         com=''
  1542.         if ar t $libc > libc.tmp; then
  1543.             for thisname in $libnames; do
  1544.                 ar t $thisname >>libc.tmp
  1545.             done
  1546.             $sed -e 's/\.o$//' < libc.tmp > libc.list
  1547.             echo "Ok."
  1548.         else
  1549.             echo "ar didn't seem to work right."
  1550.             echo "Maybe this is a Cray...trying bld instead..."
  1551.             if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  1552.                 for thisname in $libnames; do
  1553.                     bld t $libnames | \
  1554.                     $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
  1555.                     ar t $thisname >>libc.tmp
  1556.                 done
  1557.                 echo "Ok."
  1558.             else
  1559.                 echo "That didn't work either.  Giving up."
  1560.                 exit 1
  1561.             fi
  1562.         fi
  1563.     fi
  1564. fi
  1565. nm_extract="$com"
  1566. if test -f /lib/syscalls.exp; then
  1567.     echo " "
  1568.     echo "Also extracting names from /lib/syscalls.exp for good ole AIX..."
  1569.     $sed -n 's/^\([^     ]*\)[     ]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
  1570. fi
  1571. $rm -f libnames libpath
  1572.  
  1573. : see how we will look up host name
  1574. echo " "
  1575. d_uname="$undef"
  1576. d_gethname="$undef"
  1577. d_phostname="$undef"
  1578. if xenix; then
  1579.     echo "(Assuming Xenix uname() is broken.)"
  1580. elif $contains '^gethostname$' libc.list >/dev/null 2>&1 ; then
  1581.     echo "gethostname() found."
  1582.     d_gethname="$define"
  1583.     ans=gethostname
  1584. elif $contains '^uname$' libc.list >/dev/null 2>&1 ; then
  1585.     echo "uname() found."
  1586.     d_uname="$define"
  1587.     ans=uname
  1588. fi
  1589. case "$d_uname$d_gethname" in
  1590. *define*)
  1591.     dflt=n
  1592.     cat <<EOM
  1593.  
  1594. Every now and then someone has a $ans() that lies about the hostname
  1595. but can't be fixed for political or economic reasons.  If you wish, I can
  1596. pretend $ans() isn't there and maybe compile in the hostname or
  1597. compute it from the '$phostname' command at run-time.
  1598.  
  1599. EOM
  1600.