home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume23 / trn / part03 / Configure.1 next >
Encoding:
Text File  |  1991-08-22  |  22.7 KB  |  1,001 lines

  1. #!/bin/sh
  2. #
  3. # If these # comments don't work, trim them.  Don't worry about the other
  4. # shell scripts, Configure will trim # comments from them for you.
  5. #
  6. # $Header: Configure,v 4.3.3.3 91/01/16 02:00:36 davison Trn $
  7. #
  8. # $Log:    Configure,v $
  9. # Revision 4.3.3.3  91/01/16  02:00:36  davison
  10. # Integrated rn patches 48-54 and tweaked sitename handling.
  11. # Revision 4.3.3.2  90/08/20  16:09:59  davison
  12. # Added MMDF support, revised sitename/domain/signal/tzset/PATH.
  13. # Revision 4.3.3.1  90/07/24  21:56:31  davison
  14. # Initial Trn Release
  15. # Revision 4.3.2.37  90/12/30  03:46:54  sob
  16. # Changed "hidden" to "hiddennet" to be like nntp and bnews.
  17. # Made it possible to cancel articles if hiddennet is defined.
  18. # Revision 4.3.2.36  90/12/30  03:31:17  sob
  19. # Better NeXT support and some other problems corrected.
  20. # Revision 4.3.2.35  90/12/04  02:51:20  sob
  21. # Removed redundant "addcflags" label
  22. # Revision 4.3.2.34  90/11/22  17:49:31  sob
  23. # Fixed bug in "hidden" code.
  24. # Revision 4.3.2.33  90/11/22  13:42:44  sob
  25. # Added support for the Uniq System V.3 OS (courtesy of a3@rivm.nl &
  26. # frans@rivm.nl).
  27. # Added support for making all mail and news appear to come from the domain
  28. # itself instead of individual hosts within a domain.
  29. # Revision 4.3.2.32  90/11/22  13:30:37  sob
  30. # Fixes to make using the supplied ndir.c work correctly.
  31. # Fixes to make building rn on an Apollo work correctly.
  32. # Revision 4.3.2.31  90/11/10  00:08:08  sob
  33. # This one appears to work for Interactive Unix.
  34. # Revision 4.3.2.30  90/11/09  23:29:16  sob
  35. # Added a few line for making rrn under Interactive Unix easier.
  36. # Revision 4.3.2.29  90/11/05  23:26:21  sob
  37. # Added detection of /usr/include/sys/ptem.h for more recent versions
  38. # of System V.
  39. # Revision 4.3.2.28  90/11/04  03:35:01  sob
  40. # Added better detection for getwd() and getcwd(). This will hopefully be
  41. # the last hurrah of this problem (naive, aren't I?)
  42. # Revision 4.3.2.27  90/10/06  11:54:56  sob
  43. # Added check for memcpy/bcopy.
  44. # Revision 4.3.2.26  90/10/01  01:39:43  sob
  45. # Altered the FLAGS for SCO Xenix 286. The old one are commented out. Let's
  46. # see if this works better.
  47. # Revision 4.3.2.25  90/05/12  17:34:53  sob
  48. # Still more XENIX fixes and fixes for using socketlib when rrn and not when
  49. # just rn.
  50. # Revision 4.3.2.24  90/05/12  14:07:43  sob
  51. # Fixed up LDFLAGS for xenix 286
  52. # Revision 4.3.2.23  90/05/04  00:42:31  sob
  53. # Fixes for Pyramids, more on the return value of signal() and
  54. # syncing up the use of socketlib.
  55. # Revision 4.3.2.22  90/04/17  15:44:24  sob
  56. # Added better directory structure detection.
  57. # Revision 4.3.2.21  90/04/14  19:36:38  sob
  58. # Added better support for the NeXT.
  59. # Revision 4.3.2.20  90/04/14  01:53:36  sob
  60. # Spelling Problem!
  61. # Revision 4.3.2.19  90/03/17  21:33:21  sob
  62. # Reworked VOIDSIG into SIGRET.
  63. # Revision 4.3.2.18  90/03/17  17:45:25  sob
  64. # Changes to detect when to use termio and when not to.
  65. # Revision 4.3.2.17  90/03/17  16:53:11  sob
  66. # Applied a patch to correctly determine being on a Sun running OS 4.0 or
  67. # later.
  68. # Revision 4.3.2.16  89/12/20  23:20:38  sob
  69. # Added hp-ux support suggested by tml@hemuli.atk.vtt.fi. Also,
  70. # corrected some bugs reported by tml@hemuli.atk.vtt.fi.
  71. # Revision 4.3.2.15  89/12/18  00:02:04  sob
  72. # Fixed bug reported by Jim Thompson <jthomp@sun.com> on the
  73. # use of ypmatch against the so-called services.byname YP map.
  74. # Sigh. Will YP EVER work?
  75. # Revision 4.3.2.14  89/12/17  12:55:39  sob
  76. # Minor bug fix to yp detection code.
  77. # Revision 4.3.2.13  89/12/17  01:53:21  sob
  78. # Changed from using ypcat to using ypmatch
  79. # Revision 4.3.2.12  89/12/15  19:35:20  sob
  80. # getpwent was not getting defined when YP is present.
  81. # bug reported by dglo@ads.com
  82. # Revision 4.3.2.11  89/12/13  00:42:59  sob
  83. # Included suggested patches by weening@gang-of-four.stanford.edu.
  84. # Revision 4.3.2.10  89/12/09  01:47:49  sob
  85. # Configure now removes myread when exiting.
  86. # Revision 4.3.2.9  89/12/08  22:41:14  sob
  87. # Added minor changes suggested by weening@Gang-of-Four.Stanford.EDU and
  88. # jik@pit-manager.mit.edu
  89. # Revision 4.3.2.8  89/11/28  00:30:06  sob
  90. # Attempted to make some of the references to the news software version
  91. # levels more clear for the benefit of novice news installers.
  92. # Revision 4.3.2.7  89/11/27  02:25:26  sob
  93. # Better detection of SunOS 4.0 and getpwent will be used on systems
  94. # that support YP, just in case.
  95. # Revision 4.3.2.6  89/11/27  01:32:56  sob
  96. # Added some changes suggested by various usenet postings.
  97. # Limited support for NeXT.
  98. # Revision 4.3.2.5  89/11/08  04:47:27  sob
  99. # Added VOIDSIG handling for SunOS 4.X
  100. # Revision 4.3.2.4  89/11/06  00:05:38  sob
  101. # Added RRN support originally distributed with NNTP 1.5
  102. # Revision 4.3.2.3  89/11/05  23:35:43  sob
  103. # Added checks for ultrix and sun
  104. #
  105. # Revision 4.3.1.6  86/07/24  14:41:18  lwall
  106. # Handles missing Relay-Version: from news 2.10.3 headers.
  107. #
  108. # Revision 4.3.1.5  85/05/23  11:23:22  lwall
  109. # filexp flubs sed command.
  110. # Revision 4.3.1.4  85/05/20  17:13:11  lwall
  111. # Makes sure -lcurses is really a terminfo library.
  112. # Puts single instead of double quotes around defs in config.sh.
  113. # Revision 4.3.1.3  85/05/16  16:48:48  lwall
  114. # Took space from end of filexp output.
  115. # Revision 4.3.1.2  85/05/13  15:54:35  lwall
  116. # Libraries in /usr/local/lib shouldn't use -l switch.
  117. # Revision 4.3.1.1  85/05/10  11:29:20  lwall
  118. # Branch for patches.
  119. # Revision 4.3  85/05/01  11:31:23  lwall
  120. # Baseline for release with 4.3bsd.
  121.  
  122. # Yes, you may rip this off to use in other distribution packages.
  123.  
  124. WHITE='[     ]'; : there should be a tab and a space between the brackets.
  125. CTRLA=''; : there should be a control-A between the single-quotes.
  126.  
  127. n=''
  128. c=''
  129. libc=''
  130. eunicefix=''
  131. eunice=''
  132. cpp=''
  133. shsharp=''
  134. spitshell=''
  135. startsh=''
  136. test=''
  137. expr=''
  138. sed=''
  139. echo=''
  140. cat=''
  141. rm=''
  142. mv=''
  143. cp=''
  144. tail=''
  145. tr=''
  146. mkdir=''
  147. sort=''
  148. uniq=''
  149. inews=''
  150. grep=''
  151. egrep=''
  152. nidump=''
  153. ypmatch=''
  154. contains=''
  155. lib=''
  156. nametype=''
  157. cc=''
  158. iandd=''
  159. include=''
  160. rrninclude=''
  161. termlib=''
  162. jobslib=''
  163. ndirlib=''
  164. socketlib=''
  165. dirtype=''
  166. dirinc=''
  167. libndir=''
  168. usendir=''
  169. ndirc=''
  170. ndiro=''
  171. pager=''
  172. mailer=''
  173. internet=''
  174. rnbin=''
  175. filexp=''
  176. distlist=''
  177. Log=''
  178. Header=''
  179. sitename=''
  180. hostfile=''
  181. domain=''
  182. orgname=''
  183. isadmin=''
  184. newsadmin=''
  185. rnlib=''
  186. mansrc=''
  187. manext=''
  188. maildir=''
  189. spool=''
  190. active=''
  191. myactive=''
  192. mininact=''
  193. pref=''
  194. defeditor=''
  195. rootid=''
  196. mboxchar=''
  197. locpref=''
  198. orgpref=''
  199. citypref=''
  200. statepref=''
  201. cntrypref=''
  202. contpref=''
  203. strchr=''
  204. memcpy=''
  205. rename=''
  206. truncate=''
  207. chsize=''
  208. tzset=''
  209. threaddef=''
  210. selectdef=''
  211. threaddir=''
  212. novoid=''
  213. novfork=''
  214. portable=''
  215. passnam=''
  216. berknam=''
  217. usgnam=''
  218. whoami=''
  219. termio=''
  220. fcntl=''
  221. ioctl=''
  222. ptem=''
  223. normsig=''
  224. sigblock=''
  225. sigret=''
  226. getuidgid=''
  227. getcwd=''
  228. getwd=''
  229. havetlib=''
  230. getpwent=''
  231. gethostname=''
  232. douname=''
  233. phostname=''
  234. hostcmd=''
  235. norelay=''
  236. isrrn=''
  237. rdchk=''
  238. serverfile=''
  239. NNTPSRC=''
  240. CONFIG=''
  241. hiddennet=''
  242.  
  243. echo "Beginning of configuration questions for trn."
  244. : Eunice requires " " instead of "", can you believe it
  245. echo " "
  246.  
  247. : sanity checks
  248. PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/bsd'
  249. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  250.  
  251. if test ! -t 0; then
  252.     echo "Type 'sh Configure', not 'sh <Configure'"
  253.     exit 1
  254. fi
  255.  
  256. : some greps do not return status, grrr.
  257. echo "grimblepritz" >grimble
  258. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  259.     contains=contains
  260. else
  261.     if grep grimblepritz grimble >/dev/null 2>&1 ; then
  262.     contains=grep
  263.     else
  264.     contains=contains
  265.     fi
  266. fi
  267.  
  268. : the following should work in any shell
  269. case $contains in
  270. contains*)
  271.     echo " "
  272.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  273.     cat >contains <<'EOSS'
  274. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  275. EOSS
  276. chmod 755 contains
  277. esac
  278.  
  279. : first determine how to suppress newline on echo command
  280. echo "Checking echo to see how to suppress newlines..."
  281. (echo "hi there\c" ; echo " ") >.echotmp
  282. if $contains c .echotmp >/dev/null 2>&1 ; then
  283.     echo "...using -n."
  284.     n='-n'
  285.     c=''
  286. else
  287.     echo "...using \\\c."
  288.     n=''
  289.     c='\c'
  290. fi
  291. echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
  292. read ans
  293. rm .echotmp
  294.  
  295. : now set up to do reads with possible shell escape
  296. : if this does not work on your machine, 1,$s/. myread/read ans/
  297. cat <<EOSC >myread
  298. ans='!'
  299. while expr "X\$ans" : "X!" >/dev/null; do
  300.     read ans
  301.     case "\$ans" in
  302.     !)
  303.     sh
  304.     echo " "
  305.     echo $n "Your answer: $c"
  306.     ;;
  307.     !*)
  308.     set \`expr "X\$ans" : "X!\(.*\)\$"\`
  309.     sh -c "\$*"
  310.     echo " "
  311.     echo $n "Your answer: $c"
  312.     ;;
  313.     esac
  314. done
  315. EOSC
  316.  
  317. : general instructions
  318. cat <<'EOH'
  319.  
  320. This installation shell script will examine your system and ask you questions
  321. to determine how trn and its auxiliary files should be installed.  If you
  322. get stuck on a question, you may use a ! shell escape to start a subshell or
  323. execute a command.  Many of the questions will have default answers in
  324. square brackets--typing carriage return will give you the default.
  325.  
  326. On some of the questions which ask for file or directory names you are
  327. allowed to use the ~name construct to specify the login directory belonging
  328. to "name", even if you don't have a shell which knows about that.  Questions
  329. where this is allowed will be marked "(~name ok)".
  330.  
  331. Much effort has been expended to ensure that this shell script will run
  332. on any Unix system.  If despite that it blows up on you, your best bet is to
  333. edit Configure and run it again.  (Trying to install trn without having run
  334. Configure is well nigh impossible.)  Also, tell Wayne (davison@dri.com)
  335. how he blew it.
  336.  
  337. This installation script affects things in two ways: 1) it does direct
  338. variable substitutions on some of the files included in this kit, and
  339. 2) it builds a config.h file for inclusion in C programs.  You may edit
  340. any of these files as the need arises after running this script.
  341.  
  342. EOH
  343. echo $n "[Type carriage return to continue] $c"
  344. . myread
  345. Xn=$n
  346. Xc=$c
  347. : get old answers, if there is a config file out there
  348. if test -f config.sh; then
  349.     echo " "
  350.     echo "(Fetching default answers from your old config.sh file...)"
  351.     . ./config.sh
  352. fi
  353. n=$Xn
  354. c=$Xc
  355.  
  356. : get list of predefined functions in a handy place
  357. echo " "
  358. if test -f /lib/libc.a; then
  359.     echo "Your C library is in /lib/libc.a.  You're normal."
  360.     libc=/lib/libc.a
  361. else
  362.     if test -f /lib/Llibc.a; then
  363.     echo "Your C library is in /lib/Llibc.a.  I smell Xenix!"
  364.     libc=/lib/Llibc.a
  365.     else
  366.     if test -f /usr/lib/libc.a; then
  367.         echo "Your C library is in /usr/lib/libc.a, of all places."
  368.         libc=/usr/lib/libc.a
  369.     else
  370.         if test -f /lib/clib; then
  371.         echo "Your C library is in /lib/clib.  How nonstandard, must be Apollo."
  372.         libc=/lib/clib
  373.         else
  374.         if test -f "$libc"; then
  375.             echo "Your C library is in $libc, like you said before."
  376.         else
  377.             cat <<'EOM'
  378.  
  379. I can't seem to find your C library.  I've looked for /lib/libc.a and
  380. /usr/lib/libc.a, but neither of those are there. Perhaps you can find
  381. out by reading `man 3 intro' if you have the 'man' facility installed.
  382.  
  383. EOM
  384.             echo $n "What is the full name of your C library? $c"
  385.             . myread
  386.             libc="$ans"
  387.         fi
  388.         fi
  389.     fi
  390.     fi
  391. fi
  392. echo " "
  393. echo $n "Extracting names from $libc for later perusal...$c"
  394. if ar t $libc >libc.list 2>/dev/null; then
  395.     echo "done"
  396. else
  397.      if test $libc = /lib/clib; then
  398.     if nm -g $libc | sed -e 's/$/.o/' >libc.list; then
  399.         echo "done"
  400.     else
  401.         echo " "
  402.         echo "Apparently $libc is not an object module. Try again."
  403.         exit 1
  404.     fi
  405.     else
  406.     echo " "
  407.     echo "The archiver doesn't think $libc is a reasonable library."
  408.     exit 1
  409.     fi
  410. fi
  411. : make some quick guesses about what we are up against
  412. echo " "
  413. echo $n "Hmm...  $c"
  414. if $contains sigvec.o libc.list >/dev/null 2>&1 ; then
  415.     echo "Looks kind of like a BSD system, but we'll see..."
  416.     echo exit 0 >bsd
  417.     echo exit 1 >usg
  418.     echo exit 1 >v7
  419. else
  420.     if $contains dup2.o libc.list >/dev/null 2>&1 ; then
  421.     echo "Looks sort of like a V7 system, but we'll see..."
  422.     echo exit 1 >bsd
  423.     echo exit 1 >usg
  424.     echo exit 0 >v7
  425.     else
  426.         echo "Looks kind of like a USG system, but we'll see..."
  427.         echo exit 1 >bsd
  428.         echo exit 0 >usg
  429.         echo exit 1 >v7
  430.     fi
  431. fi
  432. :
  433. if test -f /etc/inittab; then
  434.     echo "You have an inittab file. You must be a USG system!"
  435.     echo exit 1 >bsd
  436.     echo exit 0 >usg
  437.     echo exit 1 >v7
  438. fi
  439. if $contains vmssystem.o libc.list >/dev/null 2>&1 ; then
  440.     cat <<'EOI'
  441. There is, however, a strange, musty smell in the air that reminds me of
  442. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  443. EOI
  444.     echo "exit 0" >eunice
  445.     eunicefix=unixtovms
  446.     eunice=define
  447. : it so happens the Eunice I know will not run shell scripts in Unix format
  448. else
  449.     echo " "
  450.     echo "Congratulations.  You aren't running Eunice."
  451.     eunicefix=':'
  452.     eunice=undef
  453.     echo "exit 1" >eunice
  454. fi
  455. chmod 755 bsd usg v7 eunice
  456. $eunicefix bsd usg v7 eunice
  457. : see how we invoke the C preprocessor
  458. echo " "
  459. echo "Checking to see how your C preprocessor is invoked..."
  460. cat <<'EOT' >testcpp.c
  461. #define ABC abc
  462. #define XYZ xyz
  463. ABC+XYZ
  464. EOT
  465. echo 'Maybe "cc -E" will work...'
  466. cc -E testcpp.c >testcpp.out 2>&1
  467. if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  468.     echo "Yup, it does."
  469.     cpp='cc -E'
  470. else
  471.     echo 'Nope...maybe "cc -P" will work...'
  472.     cc -P testcpp.c >testcpp.out 2>&1
  473.     if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  474.     echo "Yup, that does."
  475.     cpp='cc -P'
  476.     else
  477.     echo 'Nixed again...maybe "/lib/cpp" will work...'
  478.     /lib/cpp testcpp.c >testcpp.out 2>&1
  479.     if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  480.         echo "Hooray, it works!  I was beginning to wonder."
  481.         cpp='/lib/cpp'
  482.     else
  483.         if $contains 'abc +xyz' testcpp.out >/dev/null 2>&1 ; then
  484.         echo "Found it!  You're on a NeXT, aren't you?"
  485.         cpp='/lib/cpp'
  486.         else
  487.         echo 'Hmm...maybe you already told me...'
  488.         case "$cpp" in
  489.         '') ;;
  490.         *) $cpp testcpp.c >testcpp.out 2>&1;;
  491.         esac
  492.         if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  493.             echo "Hooray, you did!  I was beginning to wonder."
  494.         else
  495.             echo "Nope. I can't find a C preprocessor.  Name one: $c"
  496.             . myread
  497.             cpp="$ans"
  498.             $cpp testcpp.c >testcpp.out 2>&1
  499.             if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  500.             echo "OK, that will do."
  501.             else
  502.             echo "Sorry, I can't get that to work.  Go find one."
  503.             exit 1
  504.             fi
  505.         fi
  506.         fi
  507.     fi
  508.     fi
  509. fi
  510. rm -f testcpp.c testcpp.out
  511. : check for pdp11
  512. echo " "
  513. cat <<'EOT' >pdp11.c
  514. #ifdef pdp11
  515. exit 0
  516. #else
  517. exit 1
  518. #endif
  519. EOT
  520. $cpp pdp11.c | grep exit >pdp11
  521. chmod 755 pdp11
  522. $eunicefix pdp11
  523. rm pdp11.c
  524. if pdp11; then
  525.     echo "This looks like a pdp11 to me."
  526. fi
  527. : check for ultrix
  528. cat <<'EOT' >ultrix.c
  529. #ifdef ultrix
  530. exit 0
  531. #else
  532. exit 1
  533. #endif
  534. EOT
  535. $cpp ultrix.c | grep exit >ultrix
  536. chmod 755 ultrix
  537. $eunicefix ultrix
  538. rm ultrix.c
  539. if ultrix; then
  540.     echo "Running ultrix, eh?"
  541. fi
  542.  
  543. : check for sun 4.0
  544. cat <<'EOT' >sun.c
  545. #ifdef sun
  546. exit 0
  547. #else
  548. exit 1
  549. #endif
  550. EOT
  551. $cpp sun.c | grep exit >sun
  552. chmod 755 sun
  553. $eunicefix sun
  554. rm sun.c
  555. if sun; then
  556.     echo "This looks like a sun to me."
  557.     if test -f /etc/ld.so.cache ; then
  558.     echo "And it appears you are running SunOS 4.0 or greater."
  559.     fi
  560. fi
  561. : check for hp-ux
  562. cat <<'EOT' >hp-ux.c
  563. #ifdef hpux
  564. exit 0
  565. #else
  566. exit 1
  567. #endif
  568. EOT
  569. $cpp hp-ux.c | grep exit >hp-ux
  570. chmod 755 hp-ux
  571. $eunicefix hp-ux
  572. rm hp-ux.c
  573. if hp-ux; then
  574.     echo "Hewlett-Packard must have built this..."
  575.     socketlib=-lbsdipc
  576. fi
  577.  
  578. : check for sgi
  579. cat <<'EOT' >sgi.c
  580. #ifdef sgi
  581. exit 0
  582. #else
  583. exit 1
  584. #endif
  585. EOT
  586. $cpp sgi.c | grep exit >sgi
  587. chmod 755 sgi
  588. $eunicefix sgi
  589. rm sgi.c
  590. if sgi; then
  591.     echo "Silicon Graphics must have built this..."
  592.     include=-I/usr/include/bsd
  593.     rrninclude="-I/usr/include/bsd -DUSG"
  594.     socketlib=-lbsd
  595. fi
  596.  
  597. : check for XENIX
  598. cat <<'EOT' >xenix
  599. test -f /xenix; exit $?
  600. EOT
  601. chmod 755 xenix
  602. $eunicefix xenix
  603. if xenix; then
  604.     echo "Kinda looks like XENIX....hmmm"
  605.     rrninclude="-DUSG -DLAI_TCP"
  606.     socketlib=-lsocket
  607.     rdchk=define
  608.     dirtype=dirent
  609. else
  610.     rdchk=undef
  611. fi
  612.  
  613. : check for Pyramid OSx
  614. cat <<'EOT' >pyr.c
  615. #ifdef pyr
  616. exit 0
  617. #else
  618. exit 1
  619. #endif
  620. EOT
  621. $cpp pyr.c | grep exit >pyr
  622. chmod 755 pyr
  623. $eunicefix pyr
  624. rm pyr.c
  625. if pyr; then
  626.     echo "This looks like a Pyramid to me."
  627. fi
  628.  
  629. : check for NeXT
  630. cat <<'EOT' >next.c
  631. #ifdef NeXT
  632. exit 0
  633. #else
  634. exit 1
  635. #endif
  636. EOT
  637. $cpp next.c | grep exit >next
  638. chmod 755 next
  639. $eunicefix next
  640. rm next.c
  641. if next; then
  642.     echo "My, you really ARE on a NeXT."
  643.     addcflags='-bsd'
  644. fi
  645.  
  646. if bsd; then
  647.     getuidgid=define
  648. else
  649.     getuidgid=undef
  650. fi
  651.  
  652. cat <<'EOT' > s5uniq
  653. if test -f /bin/uname
  654. then
  655.     case `uname -r -m` in
  656.     "5.3 vax-"*)
  657.         if [ -f /usr/lib/libnet.a \
  658.           -a -f /usr/lib/libhdb.a \
  659.           -a -f /usr/lib/libbbn.a \
  660.           -a -f /usr/lib/libstr.a ]
  661.         then
  662.             exit 0
  663.         fi;;
  664.     esac
  665. fi
  666. exit 1
  667. EOT
  668. chmod 755 s5uniq
  669. if s5uniq; then
  670.     echo "This looks like Uniq.  What a pity."
  671.     socketlib="-lnet -lhdb -lbbn -lstr"
  672.     rrninclude="-DR_UNIQ -DUSG"
  673.     # -DR_UNIQ and -DUSG are needed for ~nntp/common/clientlib.c
  674. fi
  675.  
  676. : see if sh knows # comments
  677. echo " "
  678. echo "Checking your sh to see if it knows about # comments..."
  679. if sh -c '#' >/dev/null 2>&1 ; then
  680.     echo "Your sh handles # comments correctly."
  681.     shsharp=true
  682.     spitshell=cat
  683.     echo " "
  684.     echo "Okay, let's see if #! works on this system..."
  685.     echo "#!/bin/echo hi" > try
  686.     $eunicefix try
  687.     chmod 755 try
  688.     try > today
  689.     if test -s today; then
  690.     echo "It does."
  691.     sharpbang='#!'
  692.     else
  693.     echo "#! /bin/echo hi" > try
  694.     $eunicefix try
  695.     chmod 755 try
  696.     try > today
  697.     if test -s today; then
  698.         echo "It does."
  699.         sharpbang='#! '
  700.     else
  701.         echo "It doesn't."
  702.         sharpbang=': use '
  703.     fi
  704.     fi
  705. else
  706.     echo "Your sh doesn't grok # comments--I will strip them later on."
  707.     shsharp=false
  708.     echo "exec grep -v '^#'" >spitshell
  709.     chmod 755 spitshell
  710.     $eunicefix spitshell
  711.     spitshell=`pwd`/spitshell
  712.     echo "I presume that if # doesn't work, #! won't work either!"
  713.     sharpbang=': use '
  714. fi
  715.  
  716. : figure out how to guarantee sh startup
  717. echo " "
  718. echo "Checking out how to guarantee sh startup..."
  719. startsh=$sharpbang'/bin/sh'
  720. echo "Let's see if '$startsh' works..."
  721. cat >try <<EOSS
  722. $startsh
  723. set abc
  724. test "$?abc" != 1
  725. EOSS
  726.  
  727. chmod 755 try
  728. $eunicefix try
  729. if try; then
  730.     echo "Yup, it does."
  731. else
  732.     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  733. fi
  734. rm -f try today
  735.  
  736. : find out where common programs are
  737. echo " "
  738. echo "Locating common programs..."
  739. pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /usr/etc /usr/5bin"
  740. cat <<EOSC >loc
  741. $startsh
  742. thing=\$1
  743. shift
  744. dflt=\$1
  745. shift
  746. for dir in \$*; do
  747.     case "\$thing" in
  748.     .)
  749.     if test -d \$dir/\$thing; then
  750.         echo \$dir
  751.         exit 0
  752.     fi
  753.     ;;
  754.     *)
  755.     if test -f \$dir/\$thing; then
  756.         echo \$dir/\$thing
  757.         exit 0
  758.     fi
  759.     ;;
  760.     esac
  761. done
  762. echo \$dflt
  763. exit 1
  764. EOSC
  765. chmod 755 loc
  766. $eunicefix loc
  767. loclist="expr sed echo cat rm mv cp tail tr mkdir sort uniq grep"
  768. trylist="test inews egrep more pg Mcc nidump ypmatch"
  769. for file in $loclist; do
  770.     xxx=`loc $file $file $pth`
  771.     eval $file=$xxx
  772.     case "$xxx" in
  773.     /*)
  774.     echo $file is in $xxx.
  775.     ;;
  776.     *)
  777.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  778.     ;;
  779.     esac
  780. done
  781. echo " "
  782. echo "Don't worry if any of the following aren't found..."
  783. for file in $trylist; do
  784.     xxx=`loc $file $file $pth`
  785.     eval $file=$xxx
  786.     case "$xxx" in
  787.     /*)
  788.     echo $file is in $xxx.
  789.     ;;
  790.     *)
  791.     echo "I don't see $file out there, offhand."
  792.     ;;
  793.     esac
  794. done
  795. case $egrep in
  796. egrep)
  797.     echo "Substituting grep for egrep."
  798.     egrep=$grep
  799.     ;;
  800. esac
  801. case $test in
  802. test)
  803.     echo "Hopefully test is built into your sh."
  804.     ;;
  805. /bin/test)
  806.     echo " "
  807.     echo $n 'Is your "test" built into sh? [n] (OK to guess) '"$c"
  808.     . myread
  809.     case $ans in
  810.     y*) test=test ;;
  811.     esac
  812.     ;;
  813. *)
  814.     test=test
  815.     ;;
  816. esac
  817. case $echo in
  818. echo)
  819.     echo "Hopefully echo is built into your sh."
  820.     ;;
  821. /bin/echo)
  822.     echo " "
  823.     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  824.     $echo $n "hi there$c" >foo1
  825.     echo $n "hi there$c" >foo2
  826.     if cmp foo1 foo2 >/dev/null 2>&1; then
  827.     echo "They are compatible.  In fact, they may be identical."
  828.     else
  829.     echo "They are not compatible--the echo builtin will be used."
  830.     echo=echo
  831.     fi
  832.     $rm -f foo1 foo2
  833.     ;;
  834. *)
  835.     echo=echo
  836.     ;;
  837. esac
  838. $echo " "
  839. : test yp
  840. case $ypmatch in
  841. ypmatch)
  842.     $echo "I don't see ypmatch out there, so YP is not available. We'll search the"
  843.     $echo "passwd file the old fashioned way!"
  844.     ;;
  845. *)
  846.     $ypmatch 513/tcp services > /dev/null 2>/dev/null
  847.     status=$?
  848.     if $test $status  -ne 0 ; then
  849.     $echo "YP installed, but not operational. We won't use it."
  850.     ypmatch=""
  851.     else
  852.         $echo "YP installed and operational."
  853.     fi
  854.     
  855.     ;;
  856. esac
  857. if $test "$nidump" = "nidump"; then
  858.     nidump=""
  859. fi
  860. if $test "$ypmatch" = "ypmatch"; then
  861.     ypmatch=""
  862. fi
  863.  
  864. : decide how portable to be
  865. case "$portable" in
  866. define) dflt=y;;
  867. *)    dflt=n;;
  868. esac
  869. $cat <<'EOH'
  870.  
  871. I can set things up so that your shell scripts and binaries are more portable,
  872. at what may be a noticable cost in performance.  In particular, if you
  873. ask to be portable, the following happens:
  874.  
  875.      1) shell scripts will rely on the PATH variable rather than using
  876.     the paths derived above.
  877.      2) ~username interpretations will be done at run time rather than
  878.     by Configure.
  879.      3) the system name will be determined at run time, if at all possible.
  880.  
  881. EOH
  882. $echo $n "Do you expect to run these scripts and binaries on multiple machines? [$dflt] $c"
  883. . myread
  884. case $ans in
  885. '') ans=$dflt;;
  886. esac
  887. case $ans in
  888.     y*) portable=define
  889.     for file in $loclist; do
  890.         eval $file=$file
  891.     done
  892.     ;;
  893.     *)  portable=undef ;;
  894. esac
  895.  
  896. : set up shell script to do ~ expansion
  897. cat >filexp <<EOSS
  898. $startsh
  899. : expand filename
  900. case \$1 in
  901. ~/*|~)
  902.     $echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  903.     ;;
  904. ~*)
  905.     if $test -f /bin/csh; then
  906.     /bin/csh -f -c "glob \$1"
  907.     $echo ""
  908.     else
  909.     name=\`$expr x\$1 : '..\([^/]*\)'\`
  910.     if $test "$ypmatch" != ""; then
  911.          dir=\`$ypmatch \$name passwd 2>/dev/null | $sed "s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/"'\`
  912.     elif $test "$nidump" != ""; then
  913.         dir=\`$nidump passwd / | $sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}'\`
  914.     fi
  915.     if $test "\$dir" = ""; then
  916.         dir=\`$sed </etc/passwd -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}'\`
  917.     fi
  918.     if $test ! -d "\$dir"; then
  919.         me=\`basename \$0\`
  920.         $echo "\$me: can't locate home directory for: \$name" >&2
  921.         exit 1
  922.     fi
  923.     case \$1 in
  924.     */*)
  925.         $echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  926.         ;;
  927.     *)
  928.         $echo \$dir
  929.         ;;
  930.     esac
  931.     fi
  932.     ;;
  933. *)
  934.     $echo \$1
  935.     ;;
  936. esac
  937. EOSS
  938. chmod 755 filexp
  939. $eunicefix filexp
  940.  
  941. : try to deal with domains
  942. $cat << 'EOH'
  943.  
  944. Please enter your domain name.  This will be used in conjunction with the
  945. site name for return addresses on news articles and mail.  If you use the
  946. 4.3ism of having your domain in your hostname, all the posting programs
  947. will figure this out on the fly, so don't worry.
  948.  
  949. Examples of some valid domains:
  950.     berkeley.edu
  951.     nasa.gov
  952. Example of an invalid domain in common use:
  953.     uucp
  954. EOH
  955.  
  956. case "$domain" in
  957. '') dflt="uucp";;
  958.