home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume16 / dist2 / part01 next >
Text File  |  1988-10-13  |  50KB  |  1,876 lines

  1. Subject:  v16i034:  Larry Wall's Configure generator, etc., Part01/07
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall)
  7. Posting-number: Volume 16, Issue 34
  8. Archive-name: dist2/part01
  9.  
  10. #! /bin/sh
  11.  
  12. # Make a new directory for the dist sources, cd to it, and run kits 1
  13. # thru 7 through sh.  When all 7 kits have been run, read README.
  14.  
  15. echo "This is dist 2.0 kit 1 (of 7).  If kit 1 is complete, the line"
  16. echo '"'"End of kit 1 (of 7)"'" will echo at the end.'
  17. echo ""
  18. export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
  19. mkdir kit mcon mcon/U pat 2>/dev/null
  20. echo Extracting mcon/README
  21. sed >mcon/README <<'!STUFFY!FUNK!' -e 's/X//'
  22. XHow to create a Configuration script:
  23. X
  24. X     1) Consult the Glossary and write your shell scripts and C programs
  25. X    in terms of the symbols that metaconfig knows how to define.  If
  26. X    your Glossary is out of date you can rebuild it by saying make gloss.
  27. X
  28. X     2) Copy any .U files that you want to modify to your private U directory
  29. X    in the current directory.  Any .U files in your private U directory
  30. X    will be used in preference to the standard one.  One way to force
  31. X    inclusion of any unit is to copy the End.U file to your .U directory
  32. X    and add the name of the unit you want as a dependency on the end
  33. X    of the ?MAKE: line.  Certain units can ONLY be forced in this way,
  34. X    namely those of the form Warn_*.U and Chk_*.U.  You can also customize
  35. X    certain default Configure variables by copying Myinit.U to your
  36. X    package's private U directory and setting the variables in that.
  37. X    For example, you can specify what types of void support your program
  38. X    needs--see $defvoidused in voidflags.U.
  39. X
  40. X     3) If you have run metaconfig before in this directory, it created a
  41. X    Wanted file.  If you want to reuse this file, use the -w switch with
  42. X    metaconfig, and it will skip the scan of your programs for symbols.
  43. X    This is useful when you are developing a new unit file for metaconfig,
  44. X    and the programs in question haven't really changed.  If you HAVE
  45. X    changed the symbols you refer to, do not use the -w switch, and
  46. X    a new Wanted file will be created.  Note that you can force inclusion
  47. X    of a unit by adding its name to the Wanted file, but if you delete
  48. X    the Wanted file you'll lose that info.
  49. X
  50. X     4) Say "metaconfig".  This should eventually produce Configure.
  51. X
  52. XHow to add a new unit:
  53. X
  54. X     1) Copy a similar unit to a new .U file.  The name you choose should
  55. X    be the name of a variable generated by the unit.  It should be 12
  56. X    or less characters to prevent filename chopping.  Actually, it
  57. X    should probably be 10 or less so that those who want to use RCS
  58. X    can have a .U,v on the end without chopping.  Metaconfig uses
  59. X    the case of the first letter to determine if any variable is
  60. X    actually produced by this unit, so don't Capitalize your unit
  61. X    name if it is supposed to produce a shell variable variable.
  62. X
  63. X     2) Edit the new .U file to do what you want.  The first ?MAKE: line
  64. X    indicates the dependencies; list before the final colon all the
  65. X    variables defined, and after the final colon all the variables (or
  66. X    other units) on which this unit depends.  It is very important that
  67. X    these lists be accurate.  IMPORTANT: The first symbol after ?MAKE:
  68. X    *must* be the name of the file without the .U.
  69. X
  70. X     3) To the extent possible, parameterize your unit based on shell
  71. X    variable defined on ?INIT: lines.  This will move the variable
  72. X    definitions up to the Init.U unit, where they can be overridden
  73. X    by definitions in Myinit.U, which is included after Init.U.
  74. X
  75. X     4) Add the definition of any C symbols desired as ?H: lines.  A line
  76. X    beginning with ?H:?%1: in the .U file will be added to the eventual
  77. X    config.h file if and only if metaconfig decides that the first symbol
  78. X    on the ?MAKE: line is needed.  The %1 stands for that first symbol,
  79. X    which happens to be the name of the file too (without .U).  Always put
  80. X    a comment on each ?H: line in case one of the variable substitutions
  81. X    earlier on the line starts a comment without finishing it.  Any shell
  82. X    variable starting with d_ may do this, so beware.
  83. X
  84. X     5) Add glossary definitions as ?S: lines for shell variables and ?C:
  85. X    lines for C preprocessor variables.  Entries are sorted by lines
  86. X    that match /[a-zA-Z_]:/ (after the ?[CS]:), so start any continuation
  87. X    lines with tabs (after the ?[CS]:).  See a current unit for examples.
  88. X    It is VERY important to start each entry with a left justified symbol
  89. X    name, and end each entry with with a ?C:. or ?S:. line.  The algorithm
  90. X    that translates C preprocessor symbol entries for the Glossary into
  91. X    comments for config.h depends on this.
  92. X
  93. X     6) Make sure the order of all your ? lines is right.  The correct order is:
  94. X
  95. X    ?RCS: and ?X: lines        -- basically just comments
  96. X    ?MAKE: lines            -- metaconfig dependencies
  97. X    ?C: and ?S: lines        -- Glossary definitions
  98. X    ?H: lines            -- config.h definitions
  99. X
  100. X    ?INIT: lines can go anywhere.
  101. X
  102. X     7) Rerun metaconfig.
  103. X
  104. X     8) Send unit to lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) for inclusion
  105. X    in the master copy, if you think it's of general interest.
  106. X
  107. XHow to add a new program to be located:
  108. X
  109. X     1) Edit Loc.U, and add the name of the program both to the ?MAKE: line
  110. X    (between the two colons) and to either loclist or trylist (depending
  111. X    on whether the program is mandatory or not).
  112. X
  113. X     2) Rerun metaconfig.
  114. X
  115. X     8) Send unit to lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) for inclusion
  116. X    in the master copy, if you think it's of general interest.
  117. X
  118. XNotes for writing .U files:
  119. X
  120. X    Always use "rm -f" because there are systems where rm is interactive by
  121. X    default.  Files which need to be removed at the end of Configure
  122. X    should be added to the rmlist variable.  (rmlist="$rmlist tmpfile")
  123. X
  124. X    Always use echo " " (with a space) because of Eunice systems.
  125. X
  126. X    Use only programs that came with V7, so that you know everyone has
  127. X    them.
  128. X
  129. X    Use $contains when you want to grep conditionally, since not all
  130. X    greps return a reasonable status.
  131. X
  132. X    Use "if test" rather than "if [...]" since not every sh knows the
  133. X    latter construct.
  134. X
  135. X    Use the myread script for inputs so that they can do shell escapes
  136. X    and default evaluation.  The general form is
  137. X
  138. X        case "$grimble" in
  139. X        '') dflt=452;;
  140. X        *) dflt="$grimble";;
  141. X        esac
  142. X        rp="How many grimbles do you have? [$dflt]"
  143. X        echo $n "$rp $c"
  144. X        . myread
  145. X        grimble="$ans"
  146. X
  147. X    Always try to determine whether a feature is present in the most
  148. X    specific way--don't say "if bsd" when you can grep libc.  There
  149. X    are many hybrid systems out there, and each feature should stand
  150. X    or fall by itself.
  151. X
  152. X    When in doubt, set a default and ask.  Don't assume anything.
  153. X
  154. X    If you think the user is wrong, allow for the fact that he may be right.
  155. X    For instance, he could be running Configure on a different system than
  156. X    he is going to use the final product on.
  157. X
  158. XMetaconfig reserves the following names in your directory, and if you use such
  159. Xa name it may get clobbered or have other unforeseen effects:
  160. X
  161. X    .MT/*
  162. X    Configure
  163. X    Wanted
  164. X    UU/*
  165. X
  166. XAdditionally, Configure may clobber these names in the directory it is run in:
  167. X
  168. X    UU/*
  169. X    config.sh
  170. X    config.h
  171. !STUFFY!FUNK!
  172. echo Extracting README
  173. sed >README <<'!STUFFY!FUNK!' -e 's/X//'
  174. X            Dist Kit, Version 2.0
  175. X
  176. X            Copyright (c) 1988, Larry Wall
  177. X
  178. XYou may copy the dist kit in whole or in part as long as you don't try to
  179. Xmake money off it, or pretend that you wrote it.
  180. X--------------------------------------------------------------------------
  181. X
  182. XPlease read all the directions below before you proceed any further, and
  183. Xthen follow them carefully.  Failure to do so may void your warranty. :-)
  184. X
  185. XAfter you have unpacked your kit, you should have all the files listed
  186. Xin MANIFEST.  Be sure to put everything in a place that is visible to
  187. Xeveryone who will be using this package, since there are files in various
  188. Xsubdirectories that are referenced.  Somewhere in /usr/lib might be
  189. Xappropriate.
  190. X
  191. XInstallation
  192. X
  193. X1)  Run Configure.  This will figure out various things about your system.
  194. X    Some things Configure will figure out for itself, other things it will
  195. X    ask you about.  It will then proceed to make config.h, config.sh, and
  196. X    Makefile.
  197. X
  198. X    You might possibly have to trim # comments from the front of Configure
  199. X    if your sh doesn't handle them, but all other # comments will be taken
  200. X    care of.
  201. X
  202. X3)  make
  203. X
  204. X    This will attempt to make various things.
  205. X
  206. X4)  make install
  207. X
  208. X    This will put several executables into a public directory.  It will
  209. X    also try to put the man pages in a reasonable place.
  210. X
  211. X5)  Read the manual entries before running.
  212. X
  213. X6)  IMPORTANT!  Help save the world!  Communicate any problems and
  214. X    suggested patches to me, lwall@jpl-devvax.jpl.nasa.gov (Larry Wall),
  215. X    so we can keep the world in sync.  If you have a problem, there's
  216. X    someone else out there who either has had or will have the same problem.
  217. X
  218. X    If possible, send in patches such that the patch program will apply them.
  219. X    Context diffs are the best, then normal diffs.  Don't send ed scripts--
  220. X    I've probably changed my copy since the version you have.
  221. X
  222. X    Watch for dist patches in comp.sources.bugs.  If you are just now bringing
  223. X    up dist and aren't sure how many patches there are, write to me and I'll
  224. X    send any you don't have.  In fact, I have an automatic patch sender--if
  225. X    you read a current patch it will tell you how to get any old ones.
  226. X
  227. X------------------------------------------------------------------------
  228. X
  229. XThe dist package consists of three parts:
  230. X
  231. X    1) The Configure generator (metaconfig) and its supporting files.
  232. X    2) The distribution kit maker (makedist) and its supporting files.
  233. X    3) The patch distribution system (pat*) and its supporting files.
  234. X
  235. XEach of these can be used separately from the others.  Before you can use
  236. Xany of them, however, the directory containing your package (not this
  237. Xpackage) must be initialized by putting a .package file into it.  This
  238. Xcan be done by running packinit in that directory.
  239. X
  240. X
  241. XNotes:
  242. X
  243. X    If you are running on a system with <= 14 char filenames, don't
  244. X    distribute any files with filenames longer than 11 chars (with the
  245. X    exception of patchlevel.h), so that there will be room for a
  246. X    2-digit extension indicating patch number in your bugs direcory.
  247. X    This includes .SH files, so any shell script built by a .SH file
  248. X    should be 8 or less characters.  On systems with flexfilenames you
  249. X    don't have to worry about it.
  250. !STUFFY!FUNK!
  251. echo Extracting pat/README
  252. sed >pat/README <<'!STUFFY!FUNK!' -e 's/X//'
  253. XThis directory contains an automatic patch generator.  You must have RCS
  254. Xto use this.  You must also have run packinit in the top level directory
  255. Xof your package to create a .package file.
  256. X
  257. XWhen you've modified a file in your package, the pat program is used to
  258. Xcontrol the whole process.  The other programs can be called by hand, but
  259. Xusually needn't be.  Run pat from the top level directory of your package.
  260. X
  261. XThere is also program called mailagent that will read your incoming mail and
  262. Xmail patches to people automatically.  You'll have to customize mailpatch
  263. Xfor yourself.
  264. X
  265. XThe pat, patcil, patdiff, and patbase programs take a list of filenames as
  266. Xarguments.  Alternately, a -a means all files listed in MANIFEST.new.
  267. X
  268. XPatcil will create an RCS directory if necessary.  However, it may not check in
  269. Xthings which require special initializaton properly.  For example, if you
  270. Xwant to check in a shell script, you'd better make your RCS directory yourself
  271. Xand then say
  272. X
  273. X    rcs -i -c'# ' blurfl.xsh
  274. X
  275. Xbefore running pat or patcil.  Otherwise the RCS log may not be commented
  276. Xproperly.
  277. X
  278. XPatdiff will create a bugs directory in your top level directory, and will want
  279. Xto find a patchlevel.h file in that same directory.  Everything is done from
  280. Xthat top level directory--don't put any patchlevel.h or bugs directories in
  281. Xyour subdirectories.  Each subdirectory has its own RCS directory though.
  282. X
  283. XPatpost, patsend and patftp may be used to post to Usenet, mail to someone,
  284. Xor copy patches to your ftp directory.  They take a destination and a list
  285. Xof patches to process.
  286. !STUFFY!FUNK!
  287. echo Extracting kit/README
  288. sed >kit/README <<'!STUFFY!FUNK!' -e 's/X//'
  289. XThis directory contains a rudimentary kit maker.  Depending on where you
  290. Xare going to send your kits you might prefer to use Rich $alz's kit maker
  291. Xinstead--it makes more robust kits but assumes more about the target
  292. Xsystem.
  293. X
  294. XYou run makedist in the top level directory of your package and it uses
  295. Xthe MANIFEST.new file to generate shar scripts of about 50000 bytes each.
  296. X
  297. XMakedist takes no arguments (except a -v for verbose).  Just make sure
  298. XMANIFEST.new contains everything you want, including any Configure,
  299. Xconfig.h.SH, or patchlevel.h files.  A prototype patchlevel.h may be
  300. Xfound in ../pat/patchlevel.h
  301. !STUFFY!FUNK!
  302. echo Extracting Configure
  303. sed >Configure <<'!STUFFY!FUNK!' -e 's/X//'
  304. X#! /bin/sh
  305. X#
  306. X# If these # comments don't work, trim them.  Don't worry about any other
  307. X# shell scripts, Configure will trim # comments from them for you.
  308. X#
  309. X# (If you are trying to port this package to a machine without sh, I would
  310. X# suggest you cut out the prototypical config.h from the end of Configure
  311. X# and edit it to reflect your system.  Some packages may include samples
  312. X# of config.h for certain machines, so you might look for one of those.)
  313. X#
  314. X# $Header: Configure,v 2.0 88/06/28 23:11:40 lwall Locked $
  315. X#
  316. X# Yes, you may rip this off to use in other distribution packages.
  317. X# (Note: this Configure script was generated automatically.  Rather than
  318. X# working with this copy of Configure, you may wish to get metaconfig.)
  319. X
  320. X: sanity checks
  321. XPATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin'
  322. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  323. X
  324. Xif test ! -t 0; then
  325. X    echo "Say 'sh Configure', not 'sh <Configure'"
  326. X    exit 1
  327. Xfi
  328. X
  329. X(alias) >/dev/null 2>&1 && \
  330. X    echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
  331. X    echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
  332. X
  333. Xif test ! -d ../UU; then
  334. X    if test ! -d UU; then
  335. X    mkdir UU
  336. X    fi
  337. X    cd UU
  338. Xfi
  339. X
  340. Xcase "$1" in
  341. X-d) shift; fastread='yes';;
  342. Xesac
  343. X
  344. Xd_eunice=''
  345. Xeunicefix=''
  346. Xdefine=''
  347. Xloclist=''
  348. Xexpr=''
  349. Xsed=''
  350. Xecho=''
  351. Xcat=''
  352. Xrm=''
  353. Xmv=''
  354. Xcp=''
  355. Xtail=''
  356. Xtr=''
  357. Xmkdir=''
  358. Xsort=''
  359. Xuniq=''
  360. Xgrep=''
  361. Xtrylist=''
  362. Xtest=''
  363. Xinews=''
  364. Xegrep=''
  365. Xmore=''
  366. Xpg=''
  367. XMcc=''
  368. Xvi=''
  369. Xmailx=''
  370. Xmail=''
  371. Xcpp=''
  372. XLog=''
  373. XHeader=''
  374. Xbin=''
  375. Xcontains=''
  376. Xdefeditor=''
  377. Xhostname=''
  378. Xphostname=''
  379. Xmydomain=''
  380. Xlibc=''
  381. Xmansrc=''
  382. Xmanext=''
  383. Xn=''
  384. Xc=''
  385. Xnametype=''
  386. Xd_passnames=''
  387. Xd_berknames=''
  388. Xd_usgnames=''
  389. Xpasscat=''
  390. Xorgname=''
  391. Xpackage=''
  392. Xspitshell=''
  393. Xshsharp=''
  394. Xsharpbang=''
  395. Xstartsh=''
  396. XCONFIG=''
  397. X: set package name
  398. Xpackage=dist
  399. X
  400. Xecho " "
  401. Xecho "Beginning of configuration questions for $package kit."
  402. X: Eunice requires " " instead of "", can you believe it
  403. Xecho " "
  404. X
  405. Xdefine='define'
  406. Xundef='undef'
  407. Xlibpth='/usr/lib /usr/local/lib /lib'
  408. Xsmallmach='pdp11 i8086 z8000 i80286 iAPX286'
  409. Xrmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
  410. Xtrap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
  411. X
  412. X: We must find out about Eunice early
  413. Xeunicefix=':'
  414. Xif test -f /etc/unixtovms; then
  415. X    eunicefix=/etc/unixtovms
  416. Xfi
  417. Xif test -f /etc/unixtovms.exe; then
  418. X    eunicefix=/etc/unixtovms.exe
  419. Xfi
  420. X
  421. Xattrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
  422. Xattrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
  423. Xattrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
  424. Xattrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
  425. Xattrlist="$attrlist $mc68k __STDC__"
  426. Xpth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /lib"
  427. Xd_newshome="../../NeWS"
  428. Xdefvoidused=7
  429. X
  430. X: some greps do not return status, grrr.
  431. Xecho "grimblepritz" >grimble
  432. Xif grep blurfldyick grimble >/dev/null 2>&1 ; then
  433. X    contains=contains
  434. Xelif grep grimblepritz grimble >/dev/null 2>&1 ; then
  435. X    contains=grep
  436. Xelse
  437. X    contains=contains
  438. Xfi
  439. Xrm -f grimble
  440. X: the following should work in any shell
  441. Xcase "$contains" in
  442. Xcontains*)
  443. X    echo " "
  444. X    echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  445. X    cat >contains <<'EOSS'
  446. Xgrep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  447. XEOSS
  448. Xchmod +x contains
  449. Xesac
  450. X
  451. X: first determine how to suppress newline on echo command
  452. Xecho "Checking echo to see how to suppress newlines..."
  453. X(echo "hi there\c" ; echo " ") >.echotmp
  454. Xif $contains c .echotmp >/dev/null 2>&1 ; then
  455. X    echo "...using -n."
  456. X    n='-n'
  457. X    c=''
  458. Xelse
  459. X    cat <<'EOM'
  460. X...using \c
  461. XEOM
  462. X    n=''
  463. X    c='\c'
  464. Xfi
  465. Xecho $n "Type carriage return to continue.  Your cursor should be here-->$c"
  466. Xread ans
  467. Xrm -f .echotmp
  468. X
  469. X: now set up to do reads with possible shell escape and default assignment
  470. Xcat <<EOSC >myread
  471. Xcase "\$fastread" in
  472. Xyes) ans=''; echo " " ;;
  473. X*) ans='!';;
  474. Xesac
  475. Xwhile expr "X\$ans" : "X!" >/dev/null; do
  476. X    read ans
  477. X    case "\$ans" in
  478. X    !)
  479. X    sh
  480. X    echo " "
  481. X    echo $n "\$rp $c"
  482. X    ;;
  483. X    !*)
  484. X    set \`expr "X\$ans" : "X!\(.*\)\$"\`
  485. X    sh -c "\$*"
  486. X    echo " "
  487. X    echo $n "\$rp $c"
  488. X    ;;
  489. X    esac
  490. Xdone
  491. Xrp='Your answer:'
  492. Xcase "\$ans" in
  493. X'') ans="\$dflt";;
  494. Xesac
  495. XEOSC
  496. X
  497. X: general instructions
  498. Xcat <<EOH
  499. XThis installation shell script will examine your system and ask you questions
  500. Xto determine how the $package package should be installed.  If you get stuck
  501. Xon a question, you may use a ! shell escape to start a subshell or execute
  502. Xa command.  Many of the questions will have default answers in square
  503. Xbrackets--typing carriage return will give you the default.
  504. X
  505. XOn some of the questions which ask for file or directory names you are
  506. Xallowed to use the ~name construct to specify the login directory belonging
  507. Xto "name", even if you don't have a shell which knows about that.  Questions
  508. Xwhere this is allowed will be marked "(~name ok)".
  509. X
  510. XEOH
  511. Xrp="[Type carriage return to continue]"
  512. Xecho $n "$rp $c"
  513. X. myread
  514. Xcat <<EOH
  515. X
  516. XMuch effort has been expended to ensure that this shell script will run
  517. Xon any Unix system.  If despite that it blows up on you, your best bet is
  518. Xto edit Configure and run it again. Also, let me (lwall@jpl-devvax.jpl.nasa.gov)
  519. Xknow how I blew it.  If you can't run Configure for some reason, you'll have
  520. Xto generate a config.sh file by hand.
  521. X
  522. XThis installation script affects things in two ways: 1) it may do direct
  523. Xvariable substitutions on some of the files included in this kit, and
  524. X2) it builds a config.h file for inclusion in C programs.  You may edit
  525. Xany of these files as the need arises after running this script.
  526. X
  527. XIf you make a mistake on a question, there is no easy way to back up to it
  528. Xcurrently.  The easiest thing to do is to edit config.sh and rerun all the
  529. XSH files.  Configure will offer to let you do this before it runs the SH files.
  530. X
  531. XEOH
  532. Xrp="[Type carriage return to continue]"
  533. Xecho $n "$rp $c"
  534. X. myread
  535. X
  536. X: get old answers, if there is a config file out there
  537. Xif test -f ../config.sh; then
  538. X    echo " "
  539. X    dflt=y
  540. X    rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
  541. X    echo $n "$rp $c"
  542. X    . myread
  543. X    case "$ans" in
  544. X    n*) echo "OK, I'll ignore it.";;
  545. X    *)  echo "Fetching default answers from your old config.sh file..."
  546. X    tmp="$n"
  547. X    ans="$c"
  548. X        . ../config.sh
  549. X    n="$tmp"
  550. X    c="$ans"
  551. X    ;;
  552. X    esac
  553. Xfi
  554. X
  555. X: find out where common programs are
  556. Xecho " "
  557. Xecho "Locating common programs..."
  558. Xcat <<EOSC >loc
  559. X$startsh
  560. Xcase \$# in
  561. X0) exit 1;;
  562. Xesac
  563. Xthing=\$1
  564. Xshift
  565. Xdflt=\$1
  566. Xshift
  567. Xfor dir in \$*; do
  568. X    case "\$thing" in
  569. X    .)
  570. X    if test -d \$dir/\$thing; then
  571. X        echo \$dir
  572. X        exit 0
  573. X    fi
  574. X    ;;
  575. X    *)
  576. X    if test -f \$dir/\$thing; then
  577. X        echo \$dir/\$thing
  578. X        exit 0
  579. X    elif test -f \$dir/\$thing.exe; then
  580. X        : on Eunice apparently
  581. X        echo \$dir/\$thing
  582. X        exit 0
  583. X    fi
  584. X    ;;
  585. X    esac
  586. Xdone
  587. Xecho \$dflt
  588. Xexit 1
  589. XEOSC
  590. Xchmod +x loc
  591. X$eunicefix loc
  592. Xloclist="
  593. Xexpr
  594. Xsed
  595. Xecho
  596. Xcat
  597. Xrm
  598. Xgrep
  599. X"
  600. Xtrylist="
  601. Xtest
  602. Xinews
  603. Xvi
  604. X"
  605. Xfor file in $loclist; do
  606. X    xxx=`loc $file $file $pth`
  607. X    eval $file=$xxx
  608. X    eval _$file=$xxx
  609. X    case "$xxx" in
  610. X    /*)
  611. X    echo $file is in $xxx.
  612. X    ;;
  613. X    *)
  614. X    echo "I don't know where $file is.  I hope it's in everyone's PATH."
  615. X    ;;
  616. X    esac
  617. Xdone
  618. Xecho " "
  619. Xecho "Don't worry if any of the following aren't found..."
  620. Xans=offhand
  621. Xfor file in $trylist; do
  622. X    xxx=`loc $file $file $pth`
  623. X    eval $file=$xxx
  624. X    eval _$file=$xxx
  625. X    case "$xxx" in
  626. X    /*)
  627. X    echo $file is in $xxx.
  628. X    ;;
  629. X    *)
  630. X    echo "I don't see $file out there, $ans."
  631. X    ans=either
  632. X    ;;
  633. X    esac
  634. Xdone
  635. Xcase "$egrep" in
  636. Xegrep)
  637. X    echo "Substituting grep for egrep."
  638. X    egrep=$grep
  639. X    ;;
  640. Xesac
  641. Xcase "$test" in
  642. Xtest)
  643. X    echo "Hopefully test is built into your sh."
  644. X    ;;
  645. X/bin/test)
  646. X    echo " "
  647. X    dflt=n
  648. X    rp="Is your "'"'"test"'"'" built into sh? [$dflt] (OK to guess)"
  649. X    echo $n "$rp $c"
  650. X    . myread
  651. X    case "$ans" in
  652. X    y*) test=test ;;
  653. X    esac
  654. X    ;;
  655. X*)
  656. X    test=test
  657. X    ;;
  658. Xesac
  659. Xcase "$echo" in
  660. Xecho)
  661. X    echo "Hopefully echo is built into your sh."
  662. X    ;;
  663. X/bin/echo)
  664. X    echo " "
  665. X    echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  666. X    $echo $n "hi there$c" >foo1
  667. X    echo $n "hi there$c" >foo2
  668. X    if cmp foo1 foo2 >/dev/null 2>&1; then
  669. X    echo "They are compatible.  In fact, they may be identical."
  670. X    else
  671. X    case "$n" in
  672. X    '-n') n='' c='\c' ans='\c' ;;
  673. X    *) n='-n' c='' ans='-n' ;;
  674. X    esac
  675. X    cat <<FOO
  676. XThey are not compatible!  You are probably running ksh on a non-USG system.
  677. XI'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
  678. Xhave echo built in and we may have to run some Bourne shell scripts.  That
  679. Xmeans I'll have to use $ans to suppress newlines now.  Life is ridiculous.
  680. X
  681. XFOO
  682. X    rp="Your cursor should be here-->"
  683. X    $echo $n "$rp$c"
  684. X    . myread
  685. X    fi
  686. X    $rm -f foo1 foo2
  687. X    ;;
  688. X*)
  689. X    : cross your fingers
  690. X    echo=echo
  691. X    ;;
  692. Xesac
  693. Xrmlist="$rmlist loc"
  694. X
  695. X: get list of predefined functions in a handy place
  696. Xecho " "
  697. Xif test -f /lib/libc.a; then
  698. X    echo "Your C library is in /lib/libc.a.  You're normal."
  699. X    libc=/lib/libc.a
  700. Xelse
  701. X    ans=`loc libc.a blurfl/dyick $libpth`
  702. X    if test ! -f $ans; then
  703. X    ans=`loc clib blurfl/dyick $libpth`
  704. X    fi
  705. X    if test ! -f $ans; then
  706. X    ans=`loc libc blurfl/dyick $libpth`
  707. X    fi
  708. X    if test -f $ans; then
  709. X    echo "Your C library is in $ans, of all places."
  710. X    libc=$ans
  711. X    else
  712. X    if test -f "$libc"; then
  713. X        echo "Your C library is in $libc, like you said before."
  714. X    else
  715. X        cat <<EOM
  716. XI can't seem to find your C library.  I've looked in the following places:
  717. X
  718. X    $libpth
  719. X
  720. XNone of these seems to contain your C library.  What is the full name
  721. XEOM
  722. X        dflt=None
  723. X        $echo $n "of your C library? $c"
  724. X        rp='C library full name?'
  725. X        . myread
  726. X        libc="$ans"
  727. X    fi
  728. X    fi
  729. Xfi
  730. Xecho " "
  731. X$echo $n "Extracting names from $libc for later perusal...$c"
  732. Xnm $libc 2>/dev/null | sed -n -e 's/^.* T _//p' -e 's/^.* T //p' > libc.list
  733. Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
  734. X    echo "done"
  735. Xelse
  736. X    nm $libc 2>/dev/null | sed -n -e 's/^.* D _//p' -e 's/^.* D //p' > libc.list
  737. X    if $contains '^printf$' libc.list >/dev/null 2>&1; then
  738. X    echo "done"
  739. X    else
  740. X    echo " "
  741. X    echo "nm didn't seem to work right."
  742. X    echo "Trying ar instead..."
  743. X    rmlist="$rmlist libc.tmp"
  744. X    if ar t $libc > libc.tmp; then
  745. X        sed -e 's/\.o$//' < libc.tmp > libc.list
  746. X        echo "Ok."
  747. X    else
  748. X        echo "ar didn't seem to work right."
  749. X        echo "Maybe this is a Cray...trying bld instead..."
  750. X        if bld t $libc | sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  751. X        echo "Ok."
  752. X        else
  753. X            echo "That didn't work either.  Giving up."
  754. X            exit 1
  755. X        fi
  756. X    fi
  757. X    fi
  758. Xfi
  759. Xrmlist="$rmlist libc.list"
  760. X
  761. X: make some quick guesses about what we are up against
  762. Xecho " "
  763. X$echo $n "Hmm...  $c"
  764. Xif $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then
  765. X    echo "Looks kind of like a BSD system, but we'll see..."
  766. X    echo exit 0 >bsd
  767. X    echo exit 1 >usg
  768. X    echo exit 1 >v7
  769. Xelif $contains '^fcntl$' libc.list >/dev/null 2>&1 ; then
  770. X    echo "Looks kind of like a USG system, but we'll see..."
  771. X    echo exit 1 >bsd
  772. X    echo exit 0 >usg
  773. X    echo exit 1 >v7
  774. Xelse
  775. X    echo "Looks kind of like a version 7 system, but we'll see..."
  776. X    echo exit 1 >bsd
  777. X    echo exit 1 >usg
  778. X    echo exit 0 >v7
  779. Xfi
  780. Xif $contains '^vmssystem$' libc.list >/dev/null 2>&1 ; then
  781. X    cat <<'EOI'
  782. XThere is, however, a strange, musty smell in the air that reminds me of
  783. Xsomething...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  784. XEOI
  785. X    echo "exit 0" >eunice
  786. X    eunicefix=unixtovms
  787. X    d_eunice="$define"
  788. X: it so happens the Eunice I know will not run shell scripts in Unix format
  789. Xelse
  790. X    echo " "
  791. X    echo "Congratulations.  You aren't running Eunice."
  792. X    eunicefix=':'
  793. X    d_eunice="$undef"
  794. X    echo "exit 1" >eunice
  795. Xfi
  796. Xif test -f /xenix; then
  797. X    echo "Actually, this looks more like a XENIX system..."
  798. X    echo "exit 0" >xenix
  799. Xelse
  800. X    echo " "
  801. X    echo "It's not Xenix..."
  802. X    echo "exit 1" >xenix
  803. Xfi
  804. Xchmod +x xenix
  805. X$eunicefix xenix
  806. Xif test -f /venix; then
  807. X    echo "Actually, this looks more like a VENIX system..."
  808. X    echo "exit 0" >venix
  809. Xelse
  810. X    echo " "
  811. X    if xenix; then
  812. X    : null
  813. X    else
  814. X    echo "Nor is it Venix..."
  815. X    fi
  816. X    echo "exit 1" >venix
  817. Xfi
  818. Xchmod +x bsd usg v7 eunice venix
  819. X$eunicefix bsd usg v7 eunice venix
  820. Xrmlist="$rmlist bsd usg v7 eunice venix xenix"
  821. X
  822. X: see if sh knows # comments
  823. Xecho " "
  824. Xecho "Checking your sh to see if it knows about # comments..."
  825. Xif sh -c '#' >/dev/null 2>&1 ; then
  826. X    echo "Your sh handles # comments correctly."
  827. X    shsharp=true
  828. X    spitshell=cat
  829. X    echo " "
  830. X    echo "Okay, let's see if #! works on this system..."
  831. X    echo "#!/bin/echo hi" > try
  832. X    $eunicefix try
  833. X    chmod +x try
  834. X    try > today
  835. X    if $contains hi today >/dev/null 2>&1; then
  836. X    echo "It does."
  837. X    sharpbang='#!'
  838. X    else
  839. X    echo "#! /bin/echo hi" > try
  840. X    $eunicefix try
  841. X    chmod +x try
  842. X    try > today
  843. X    if test -s today; then
  844. X        echo "It does."
  845. X        sharpbang='#! '
  846. X    else
  847. X        echo "It doesn't."
  848. X        sharpbang=': use '
  849. X    fi
  850. X    fi
  851. Xelse
  852. X    echo "Your sh doesn't grok # comments--I will strip them later on."
  853. X    shsharp=false
  854. X    echo "exec grep -v '^#'" >spitshell
  855. X    chmod +x spitshell
  856. X    $eunicefix spitshell
  857. X    spitshell=`pwd`/spitshell
  858. X    echo "I presume that if # doesn't work, #! won't work either!"
  859. X    sharpbang=': use '
  860. Xfi
  861. X
  862. X: figure out how to guarantee sh startup
  863. Xecho " "
  864. Xecho "Checking out how to guarantee sh startup..."
  865. Xstartsh=$sharpbang'/bin/sh'
  866. Xecho "Let's see if '$startsh' works..."
  867. Xcat >try <<EOSS
  868. X$startsh
  869. Xset abc
  870. Xtest "$?abc" != 1
  871. XEOSS
  872. X
  873. Xchmod +x try
  874. X$eunicefix try
  875. Xif try; then
  876. X    echo "Yup, it does."
  877. Xelse
  878. X    echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  879. Xfi
  880. Xrm -f try today
  881. X
  882. X: preserve RCS keywords in files with variable substitution, grrr
  883. XLog='$Log'
  884. XHeader='$Header'
  885. X
  886. X: set up shell script to do ~ expansion
  887. Xcat >filexp <<EOSS
  888. X$startsh
  889. X: expand filename
  890. Xcase "\$1" in
  891. X ~/*|~)
  892. X    echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  893. X    ;;
  894. X ~*)
  895. X    if $test -f /bin/csh; then
  896. X    /bin/csh -f -c "glob \$1"
  897. X    echo ""
  898. X    else
  899. X    name=\`$expr x\$1 : '..\([^/]*\)'\`
  900. X    dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  901. X    if $test ! -d "\$dir"; then
  902. X        me=\`basename \$0\`
  903. X        echo "\$me: can't locate home directory for: \$name" >&2
  904. X        exit 1
  905. X    fi
  906. X    case "\$1" in
  907. X    */*)
  908. X        echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  909. X        ;;
  910. X    *)
  911. X        echo \$dir
  912. X        ;;
  913. X    esac
  914. X    fi
  915. X    ;;
  916. X*)
  917. X    echo \$1
  918. X    ;;
  919. Xesac
  920. XEOSS
  921. Xchmod +x filexp
  922. X$eunicefix filexp
  923. X
  924. X: determine where public executables go
  925. Xcase "$bin" in
  926. X'')
  927. X    dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
  928. X    ;;
  929. X*)  dflt="$bin"
  930. X    ;;
  931. Xesac
  932. Xcont=true
  933. Xwhile $test "$cont" ; do
  934. X    echo " "
  935. X    rp="Where do you want to put the public executables? [$dflt]"
  936. X    $echo $n "$rp $c"
  937. X    . myread
  938. X    bin="$ans"
  939. X    bin=`filexp $bin`
  940. X    if test -d $bin; then
  941. X    cont=''
  942. X    else
  943. X    dflt=n
  944. X    rp="Directory $bin doesn't exist.  Use that name anyway? [$dflt]"
  945. X    $echo $n "$rp $c"
  946. X    . myread
  947. X    dflt=''
  948. X    case "$ans" in
  949. X    y*) cont='';;
  950. X    esac
  951. X    fi
  952. Xdone
  953. X
  954. X: determine default editor
  955. Xcase "$defeditor" in
  956. X'')
  957. X    case "$_vi" in
  958. X    */*) dflt="$_vi";;
  959. X    *) dflt=/usr/ucb/vi;;
  960. X    esac
  961. X    ;;
  962. X*)  dflt="$defeditor"
  963. X    ;;
  964. Xesac
  965. Xcont=true
  966. Xwhile $test "$cont" ; do
  967. X    echo " "
  968. X    rp="What is the default editor on your system? [$dflt]"
  969. X    $echo $n "$rp $c"
  970. X    . myread
  971. X    defeditor="$ans"
  972. X    if test -f $ans; then
  973. X    cont=''
  974. X    else
  975. X    dflt=n
  976. X    rp="File $ans doesn't exist.  Use that name anyway? [$dflt]"
  977. X    $echo $n "$rp $c"
  978. X    . myread
  979. X    dflt=''
  980. X    case "$ans" in
  981. X    y*) cont='';;
  982. X    esac
  983. X    fi
  984. Xdone
  985. X
  986. X: now get the host name
  987. Xecho " "
  988. Xecho "Figuring out host name..."
  989. Xecho 'Maybe "hostname" will work...'
  990. Xif ans=`sh -c hostname 2>&1` ; then
  991. X    hostname=$ans
  992. X    phostname=hostname
  993. Xelse
  994. X    echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
  995. X    if ans=`cat /etc/systemid 2>&1` ; then
  996. X    hostname=$ans
  997. X    phostname='cat /etc/systemid'
  998. X    if xenix; then
  999. X        echo "Whadyaknow.  Xenix always was a bit strange..."
  1000. X    else
  1001. X        echo "What is a non-Xenix system doing with /etc/systemid?"
  1002. X    fi
  1003. X    else
  1004. X    echo 'No, maybe "uuname -l" will work...'
  1005. X    if ans=`sh -c 'uuname -l' 2>&1` ; then
  1006. X        hostname=$ans
  1007. X        phostname='uuname -l'
  1008. X    else
  1009. X        echo 'Strange.  Maybe "uname -n" will work...'
  1010. X        if ans=`sh -c 'uname -n' 2>&1` ; then
  1011. X        hostname=$ans
  1012. X        phostname='uname -n'
  1013. X        else
  1014. X        echo 'Oh well, maybe I can mine it out of whoami.h...'
  1015. X        if ans=`sh -c $contains' sysname /usr/include/whoami.h' 2>&1` ; then
  1016. X            hostname=`echo "$ans" | $sed 's/^.*"\(.*\)"/\1/'`
  1017. X            phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' </usr/include/whoami.h"
  1018. X        else
  1019. X            case "$hostname" in
  1020. X            '') echo "Does this machine have an identity crisis or something?"
  1021. X            phostname=''
  1022. X            ;;
  1023. X            *)  echo "Well, you said $hostname before...";;
  1024. X            esac
  1025. X        fi
  1026. X        fi
  1027. X    fi
  1028. X    fi
  1029. Xfi
  1030. X: you do not want to know about this
  1031. Xset $hostname
  1032. Xhostname=$1
  1033. X
  1034. X: translate upper to lower if necessary
  1035. Xcase "$hostname" in
  1036. X    *[A-Z]*)
  1037. X    hostname=`echo $hostname | tr '[A-Z]' '[a-z]'`
  1038. X    echo "(Normalizing case in your host name)"
  1039. X    ;;
  1040. Xesac
  1041. X
  1042. X: verify guess
  1043. Xif $test "$hostname" ; then
  1044. X    dflt=y
  1045. X    echo 'Your host name appears to be "'$hostname'".'
  1046. X    $echo $n "Is this correct? [$dflt] $c"
  1047. X    rp="Sitename is $hostname? [$dflt]"
  1048. X    . myread
  1049. X    case "$ans" in
  1050. X      y*)  ;;
  1051. X      *)      hostname='' ;;
  1052. X    esac
  1053. Xfi
  1054. X
  1055. X: bad guess or no guess
  1056. Xwhile $test "X$hostname" = X ; do
  1057. X    dflt=''
  1058. X    rp="Please type the (one word) name of your host:"
  1059. X    $echo $n "$rp $c"
  1060. X    . myread
  1061. X    hostname="$ans"
  1062. Xdone
  1063. X
  1064. Xecho " "
  1065. Xcase "$hostname" in
  1066. X*.*)
  1067. X    dflt=`expr "X$hostname" : "X[^.]*\(\..*\)"`
  1068. X    hostname=`expr "X$hostname" : "X\([^.]*\)\."`
  1069. X    echo "(Trimming domain name from host name--host name is now $hostname)"
  1070. X    ;;
  1071. X*)
  1072. X    dflt='.uucp'
  1073. X    ;;
  1074. Xesac
  1075. Xrp="What is your domain name? [$dflt]"
  1076. X$echo $n "$rp $c"
  1077. X. myread
  1078. Xcase "$ans" in
  1079. X'') ;;
  1080. X.*) ;;
  1081. X*) ans=".$ans";;
  1082. Xesac
  1083. Xmydomain="$ans"
  1084. X
  1085. X: a little sanity check here
  1086. Xcase "$phostname" in
  1087. X'') ;;
  1088. X*)  case `$phostname` in
  1089. X    $hostname$mydomain|$hostname) ;;
  1090. X    *)
  1091. X    case "$phostname" in
  1092. X    sed*)
  1093. X        echo "(That doesn't agree with your whoami.h file, by the way.)"
  1094. X        ;;
  1095. X    *)
  1096. X        echo "(That doesn't agree with your $phostname command, by the way.)"
  1097. X        ;;
  1098. X    esac
  1099. X    phostname=''
  1100. X    ;;
  1101. X    esac
  1102. X    ;;
  1103. Xesac
  1104. X
  1105. X: determine where manual pages go
  1106. Xcase "$mansrc" in
  1107. X'')
  1108. X    dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
  1109. X    ;;
  1110. X*)  dflt="$mansrc"
  1111. X    ;;
  1112. Xesac
  1113. Xcont=true
  1114. Xwhile $test "$cont" ; do
  1115. X    echo " "
  1116. X    rp="Where do the manual pages (source) go? [$dflt]"
  1117. X    $echo $n "$rp $c"
  1118. X    . myread
  1119. X    mansrc=`filexp "$ans"`
  1120. X    if test -d $mansrc; then
  1121. X    cont=''
  1122. X    else
  1123. X    dflt=n
  1124. X    rp="Directory $mansrc doesn't exist.  Use that name anyway? [$dflt]"
  1125. X    $echo $n "$rp $c"
  1126. X    . myread
  1127. X    dflt=''
  1128. X    case "$ans" in
  1129. X    y*) cont='';;
  1130. X    esac
  1131. X    fi
  1132. Xdone
  1133. Xcase "$mansrc" in
  1134. X*l)
  1135. X    manext=l
  1136. X    ;;
  1137. X*n)
  1138. X    manext=n
  1139. X    ;;
  1140. X*C)
  1141. X    manext=C
  1142. X    ;;
  1143. X*)
  1144. X    manext=1
  1145. X    ;;
  1146. Xesac
  1147. X
  1148. X: find out how to find out full name
  1149. Xecho " "
  1150. Xcase "$d_berknames" in
  1151. X"$define")
  1152. X    dflt=y;;
  1153. X"$undef")
  1154. X    dflt=n;;
  1155. X*)
  1156. X    if bsd; then
  1157. X    dflt=y
  1158. X    else
  1159. X    dflt=n
  1160. X    fi
  1161. X    ;;
  1162. Xesac
  1163. Xecho "Does your /etc/passwd file keep full names in Berkeley/V7 format (name first"
  1164. X$echo $n "thing after ':' in GCOS field)? [$dflt] $c"
  1165. Xrp="Berkeley/V7 format full name? [$dflt]"
  1166. X. myread
  1167. Xcase "$ans" in
  1168. X  y*)
  1169. X    d_passnames="$define"
  1170. X    d_berknames="$define"
  1171. X    d_usgnames="$undef"
  1172. X    nametype=bsd
  1173. X    ;;
  1174. X  *)
  1175. X    echo " "
  1176. X    case "$d_usgnames" in
  1177. X    "$define")
  1178. X    dflt=y;;
  1179. X    "$undef")
  1180. X    dflt=n;;
  1181. X    *)
  1182. X    if usg; then
  1183. X        dflt=y
  1184. X    else
  1185. X        dflt=n
  1186. X    fi
  1187. X    ;;
  1188. X    esac
  1189. X    echo "Does your passwd file keep full names in USG format (name sandwiched"
  1190. X    $echo $n "between a '-' and a '(')? [$dflt] $c"
  1191. X    rp="USG format full name? [$dflt]"
  1192. X    . myread
  1193. X    case "$ans" in
  1194. X      n*)
  1195. X    echo "Full name will be taken from ~/.fullname"
  1196. X    d_passnames="$undef"
  1197. X    d_berknames="$undef"
  1198. X    d_usgnames="$undef"
  1199. X    nametype=other
  1200. X    ;;
  1201. X      *)
  1202. X    d_passnames="$define"
  1203. X    d_berknames="$undef"
  1204. X    d_usgnames="$define"
  1205. X    nametype=usg
  1206. X    ;;
  1207. X    esac
  1208. X    ;;
  1209. Xesac
  1210. X
  1211. X: see if we have to deal with yellow pages
  1212. Xif $test -d /usr/etc/yp; then
  1213. X    if $contains '^\+:' /etc/passwd; then
  1214. X    dflt=y
  1215. X    else
  1216. X    dflt=n
  1217. X    fi
  1218. X    rp="Are you getting the passwd file via yellow pages? [$dflt]"
  1219. X    $echo $n "$rp $c"
  1220. X    . myread
  1221. X    case "$ans" in
  1222. X    y*) passcat='ypcat passwd';;
  1223. X    *) passcat='cat /etc/passwd';;
  1224. X    esac
  1225. Xelse
  1226. X    passcat='cat /etc/passwd'
  1227. Xfi
  1228. X
  1229. X: get organizaton name
  1230. Xlongshots='/usr/src/new /usr/src/local /usr/local/src'
  1231. Xcase "$orgname" in
  1232. X'') if xxx=`loc news/src/defs.h x $longshots`; then
  1233. X    dflt=`$sed -n 's/^.*MYORG[     ]*"\(.*\)".*$/\1/p' $xxx`
  1234. X    else
  1235. X    dflt='no default'
  1236. X    fi
  1237. X    ;;
  1238. X*)  dflt="$orgname";;
  1239. Xesac
  1240. X$cat << 'EOH'
  1241. XPlease type the name of your organization as you want it to appear on the
  1242. XOrganization line of outgoing articles.  (It's nice if this also specifies
  1243. Xyour location.  Your city name is probably sufficient if well known.)
  1244. XFor example:
  1245. X
  1246. X    University of Southern North Dakota, Hoople
  1247. X
  1248. XYou may also put the name of a file, as long as it begins with a slash.
  1249. XFor example:
  1250. X
  1251. X    /etc/organization
  1252. X
  1253. XEOH
  1254. Xorgname="no default"
  1255. Xwhile test "X$orgname" = "Xno default"; do
  1256. X    rp="Organization: [$dflt]"
  1257. X    $echo $n "$rp $c"
  1258. X    . myread
  1259. X    orgname="$ans"
  1260. Xdone
  1261. X
  1262. Xecho " "
  1263. Xecho "End of configuration questions."
  1264. Xecho " "
  1265. X
  1266. X: create config.sh file
  1267. Xecho " "
  1268. Xif test -d ../UU; then
  1269. X    cd ..
  1270. Xfi
  1271. Xecho "Creating config.sh..."
  1272. X$spitshell <<EOT >config.sh
  1273. X$startsh
  1274. X# config.sh
  1275. X# This file was produced by running the Configure script.
  1276. X
  1277. Xd_eunice='$d_eunice'
  1278. Xeunicefix='$eunicefix'
  1279. Xdefine='$define'
  1280. Xloclist='$loclist'
  1281. Xexpr='$expr'
  1282. Xsed='$sed'
  1283. Xecho='$echo'
  1284. Xcat='$cat'
  1285. Xrm='$rm'
  1286. Xmv='$mv'
  1287. Xcp='$cp'
  1288. Xtail='$tail'
  1289. Xtr='$tr'
  1290. Xmkdir='$mkdir'
  1291. Xsort='$sort'
  1292. Xuniq='$uniq'
  1293. Xgrep='$grep'
  1294. Xtrylist='$trylist'
  1295. Xtest='$test'
  1296. Xinews='$inews'
  1297. Xegrep='$egrep'
  1298. Xmore='$more'
  1299. Xpg='$pg'
  1300. XMcc='$Mcc'
  1301. Xvi='$vi'
  1302. Xmailx='$mailx'
  1303. Xmail='$mail'
  1304. Xcpp='$cpp'
  1305. XLog='$Log'
  1306. XHeader='$Header'
  1307. Xbin='$bin'
  1308. Xcontains='$contains'
  1309. Xdefeditor='$defeditor'
  1310. Xhostname='$hostname'
  1311. Xphostname='$phostname'
  1312. Xmydomain='$mydomain'
  1313. Xlibc='$libc'
  1314. Xmansrc='$mansrc'
  1315. Xmanext='$manext'
  1316. Xn='$n'
  1317. Xc='$c'
  1318. Xnametype='$nametype'
  1319. Xd_passnames='$d_passnames'
  1320. Xd_berknames='$d_berknames'
  1321. Xd_usgnames='$d_usgnames'
  1322. Xpasscat='$passcat'
  1323. Xorgname='$orgname'
  1324. Xpackage='$package'
  1325. Xspitshell='$spitshell'
  1326. Xshsharp='$shsharp'
  1327. Xsharpbang='$sharpbang'
  1328. Xstartsh='$startsh'
  1329. XCONFIG=true
  1330. XEOT
  1331. X
  1332. XCONFIG=true
  1333. X
  1334. Xecho " "
  1335. Xdflt=''
  1336. Xfastread=''
  1337. Xecho "If you didn't make any mistakes, then just type a carriage return here."
  1338. Xrp="If you need to edit config.sh, do it as a shell escape here:"
  1339. X$echo $n "$rp $c"
  1340. X. UU/myread
  1341. Xcase "$ans" in
  1342. X'') ;;
  1343. X*) : in case they cannot read
  1344. X    eval $ans;;
  1345. Xesac
  1346. X. ./config.sh
  1347. X
  1348. Xecho " "
  1349. Xecho "Doing variable substitutions on .SH files..."
  1350. Xset x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
  1351. Xshift
  1352. Xcase $# in
  1353. X0) set x *.SH; shift;;
  1354. Xesac
  1355. Xif test ! -f $1; then
  1356. X    shift
  1357. Xfi
  1358. Xfor file in $*; do
  1359. X    case "$file" in
  1360. X    */*)
  1361. X    dir=`$expr X$file : 'X\(.*\)/'`
  1362. X    file=`$expr X$file : 'X.*/\(.*\)'`
  1363. X    (cd $dir && . $file)
  1364. X    ;;
  1365. X    *)
  1366. X    . $file
  1367. X    ;;
  1368. X    esac
  1369. Xdone
  1370. Xif test -f config.h.SH; then
  1371. X    if test ! -f config.h; then
  1372. X    : oops, they left it out of MANIFEST, probably, so do it anyway.
  1373. X    . config.h.SH
  1374. X    fi
  1375. Xfi
  1376. X
  1377. Xif $contains '^depend:' Makefile >/dev/null 2>&1; then
  1378. X    dflt=n
  1379. X    $cat <<EOM
  1380. X
  1381. XNow you need to generate make dependencies by running "make depend".
  1382. XYou might prefer to run it in background: "make depend > makedepend.out &"
  1383. XIt can take a while, so you might not want to run it right now.
  1384. X
  1385. XEOM
  1386. X    rp="Run make depend now? [$dflt]"
  1387. X    $echo $n "$rp $c"
  1388. X    . UU/myread
  1389. X    case "$ans" in
  1390. X    y*) make depend
  1391. X    echo "Now you must run a make."
  1392. X    ;;
  1393. X    *)  echo "You must run 'make depend' then 'make'."
  1394. X    ;;
  1395. X    esac
  1396. Xelif test -f Makefile; then
  1397. X    echo " "
  1398. X    echo "Now you must run a make."
  1399. Xelse
  1400. X    echo "Done."
  1401. Xfi
  1402. X
  1403. X$rm -f kit*isdone
  1404. X: the following is currently useless
  1405. Xcd UU && $rm -f $rmlist
  1406. X: since this removes it all anyway
  1407. Xcd .. && $rm -rf UU
  1408. X: end of Configure
  1409. !STUFFY!FUNK!
  1410. echo Extracting mcon/metaconfig.SH
  1411. sed >mcon/metaconfig.SH <<'!STUFFY!FUNK!' -e 's/X//'
  1412. Xcase $CONFIG in
  1413. X'')
  1414. X    if test ! -f config.sh; then
  1415. X    ln ../config.sh . || \
  1416. X    ln ../../config.sh . || \
  1417. X    ln ../../../config.sh . || \
  1418. X    (echo "Can't find config.sh."; exit 1)
  1419. X    echo "Using config.sh from above..."
  1420. X    fi
  1421. X    . ./config.sh
  1422. X    ;;
  1423. Xesac
  1424. X: This forces SH files to create target in same directory as SH file.
  1425. X: This is so that make depend always knows where to find SH derivatives.
  1426. Xcase "$0" in
  1427. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1428. Xesac
  1429. Xecho "Extracting metaconfig (with variable substitutions)"
  1430. Xcat >metaconfig <<!GROK!THIS!
  1431. X#!/usr/bin/perl
  1432. X        eval "exec /usr/bin/perl -S \$0 \$*"
  1433. X        if \$running_under_some_shell;
  1434. X
  1435. X# $Header: metaconfig.SH,v 2.0 88/06/28 23:18:46 lwall Locked $
  1436. X#
  1437. X# $Log:    metaconfig.SH,v $
  1438. X# Revision 2.0  88/06/28  23:18:46  lwall
  1439. X# Baseline.
  1440. X# 
  1441. X
  1442. X\$MC='`pwd`';
  1443. X!GROK!THIS!
  1444. X
  1445. X: in the following dollars and backticks do not need the extra backslash
  1446. X$spitshell >>metaconfig <<'!NO!SUBS!'
  1447. X$ENV{'MC'} = $MC;
  1448. Xchop($WD=`pwd`);
  1449. X$ENV{'WD'} = $WD;
  1450. X
  1451. Xdo 'getopt.pl';
  1452. Xdo Getopt("");
  1453. X
  1454. X++$opt_v if $opt_V;
  1455. X
  1456. Xunlink 'Wanted' unless $opt_w;
  1457. X
  1458. X$NEWMANI = 'MANIFEST.new';
  1459. X$MANI = 'MANIFEST';
  1460. X
  1461. Xdo readpackage();
  1462. X
  1463. X$ENV{'package'} = $package;
  1464. X
  1465. X`mkdir .MT 2>&1` unless -d '.MT';
  1466. X
  1467. Xprint "Locating units...\n" if $opt_v;
  1468. Xif (-d 'U') {
  1469. X    chdir 'U';
  1470. X    foreach $file (<*.U>) {
  1471. X    push(@myUlist,"$WD/U/$file");
  1472. X    $myUseen{$file} = 1;
  1473. X    }
  1474. X    chdir '..';
  1475. X}
  1476. X
  1477. Xchdir "$MC/U" || die "Can't find $MC/U.\n";
  1478. Xforeach $file (<*.U>) {
  1479. X    if ($myUseen{$file}) {
  1480. X    print "    Your private U/$file overrides the public one.\n" if $opt_v;
  1481. X    }
  1482. X    else {
  1483. X    push(@ARGV,$file);
  1484. X    }
  1485. X}
  1486. Xpush(@ARGV,@myUlist);
  1487. X
  1488. Xif ($opt_V) {
  1489. X    print "\t";
  1490. X    $, = "\n\t";
  1491. X    print @ARGV;
  1492. X    $, = '';
  1493. X    print "\n";
  1494. X}
  1495. X
  1496. Xprint "Extracting dependency lists from units...\n" if $opt_v;
  1497. X$dependencies = ' ' x 10000;    # pre-extend
  1498. X$dependencies = '';
  1499. Xopen(INIT,">$WD/.MT/.Init.U")      || die "Can't create $WD/.MT/.Init.U\n";
  1500. Xopen(CONF_H,">$WD/.MT/.Config_h.U") || die "Can't create $WD/.MT/.Config_h.U\n";
  1501. Xline: while (<>) {
  1502. X    if (/^\?MAKE:[\w ]*:/) {
  1503. X    s|^\?MAKE:\s*||;
  1504. X    $dependencies .= $_;
  1505. X    chop;
  1506. X    s/:.*//;
  1507. X    @ary = split(' ');
  1508. X    $hold = join(' ',@ary);
  1509. X    $unit = $ary[0];
  1510. X    foreach $sym (@ary) {
  1511. X        if ($sym =~ /^([a-z]|Mcc|Log|Header)/) {
  1512. X        $shmaster{"\$$sym"} = '#';
  1513. X        push(@Master,"?$unit:$sym=''\n");
  1514. X        }
  1515. X    }
  1516. X    next line;
  1517. X    }
  1518. X    if (/^\?C:/) {
  1519. X    s|^\?C:([A-Za-z_])|?H:?%1:/* $1|;
  1520. X    s|^\?C:\.\s*$|?H:?%1: */\n|;
  1521. X    s|^\?C:(.*)|?H:?%1: *$1|;
  1522. X    }
  1523. X    s/%\*/$hold/;
  1524. X    s/%1/$unit/;
  1525. X    $dependencies .= $_        if s|^\?MAKE:||;
  1526. X    print INIT            if s|^\?INIT:||;
  1527. X    print CONF_H        if s|^\?H:||;
  1528. X}
  1529. Xprint $dependencies if $opt_V;
  1530. Xprint CONF_H "!GROK!THIS!\n";
  1531. Xclose DEP;
  1532. Xclose INIT;
  1533. Xclose CONF_H;
  1534. Xclose MASTER;
  1535. X
  1536. Xchdir $WD;
  1537. X
  1538. Xunless (-f 'Wanted') {
  1539. X    print "Building a Wanted file...\n" if $opt_v;
  1540. X    open(WANTED,"| sort | uniq >Wanted") || die "Can't create Wanted.\n";
  1541. X    unless (-f $NEWMANI) {
  1542. X    do manifake();
  1543. X    die "No $NEWMANI--can't build a Wanted file.\n" unless -f $NEWMANI;
  1544. X    }
  1545. X
  1546. X    print "    Extracting filenames (*.[chy] and *.SH) from $NEWMANI...\n"
  1547. X      if $opt_v;
  1548. X    open(NEWMANI,$NEWMANI) || die "Can't open $NEWMANI";
  1549. X    while (<NEWMANI>) {
  1550. X    ($file) = split(' ');
  1551. X    next if $file eq 'config.h.SH';
  1552. X    push(@SHlist,$file) if $file =~ /\.SH$/;
  1553. X    push(@clist,$file) if $file =~ /\.[chy]$/;
  1554. X    }
  1555. X
  1556. X    print "    Extracting symbols from Config_h.U...\n" if $opt_v;
  1557. X    if (-f 'U/Config_h.U') {
  1558. X    @ARGV = ('U/Config_h.U', '.MT/.Config_h.U');
  1559. X    }
  1560. X    else {
  1561. X    @ARGV = ("$MC/U/Config_h.U", '.MT/.Config_h.U');
  1562. X    }
  1563. X    while (<>) {
  1564. X    next unless /^\?\w*:#.*\$/;
  1565. X    s|^[^#]*#||;
  1566. X    if (s|^\$(\w+)\s*(\w+).*\$(\w+).*$|$2 $1\n$2 $3|) {
  1567. X        $cmaster{$2} = '#';
  1568. X        $cwanted{$2} = "$1\n$3";
  1569. X    }
  1570. X    elsif (s|^\$(\w+)\s*(\w+).*$|$2 $1|) {
  1571. X        $cmaster{$2} = '#';
  1572. X        $cwanted{$2} = $1;
  1573. X    }
  1574. X    elsif (s|^define\s*(\w+).*\$(\w+).*$|$1 $2|) {
  1575. X        $cmaster{$1} = '#';
  1576. X        $cwanted{$1} = $2;
  1577. X    }
  1578. X    }
  1579. X
  1580. X    # Now we are a little clever, and build a loop to eval so that we don't
  1581. X    # have to recompile our patterns on every file.  We also use "study" since
  1582. X    # we are searching the same string for many different things.  Hauls!
  1583. X
  1584. X    unless ($#clist < 0) {
  1585. X    print "    Scanning .c and .h files for symbols...\n" if $opt_v;
  1586. X    $search = "while (<>) {study;\n";    # init loop over ARGV
  1587. X    foreach $key (keys(cmaster)) {
  1588. X        $search .= "\$cmaster{'$key'}++ if /\\b$key\\b/;\n";
  1589. X    }
  1590. X    $search .= "}\n";            # terminate loop
  1591. X    @ARGV = @clist;
  1592. X    $/ = "\001";    # swallow each file whole (delete if memory is limited)
  1593. X    eval $search;
  1594. X    $/ = "\n";
  1595. X    while (($key,$value) = each(cmaster)) {
  1596. X        if ($value ne '#') {
  1597. X        print WANTED $cwanted{$key}, "\n";
  1598. X        }
  1599. X    }
  1600. X    }
  1601. X
  1602. X    print "    Scanning .SH files for symbols...\n" if $opt_v;
  1603. X    close WANTED;
  1604. X    open(WANTED,"| sort | uniq >>Wanted") || die "Can't create Wanted.\n";
  1605. X    $search = "while (<>) {study;\n";
  1606. X    foreach $key (keys(shmaster)) {
  1607. X    $search .= "\$shmaster{'$key'}++ if /\\$key\\b/;\n";
  1608. X    }
  1609. X    $search .= "}\n";
  1610. X    @ARGV = @SHlist;
  1611. X    $/ = "\001";        # (delete if memory is limited)
  1612. X    eval $search;
  1613. X    $/ = "\n";
  1614. X#    while (<>) {
  1615. X#    @ary = split(/[^\w\$]+/);
  1616. X#    for (@ary) {
  1617. X#        $shmaster{$_}++ if $shmaster{$_};    # assuming most don't match
  1618. X#    }
  1619. X#    }
  1620. X    while (($key,$value) = each(shmaster)) {
  1621. X    if ($value ne '#') {
  1622. X        $key =~ s/^\$//;
  1623. X        print WANTED $key, "\n";
  1624. X    }
  1625. X    }
  1626. X}
  1627. Xclose WANTED;
  1628. X
  1629. Xdie "No desirable symbols found--aborting.\n" unless -s 'Wanted';
  1630. X
  1631. Xprint "Building private make file...\n" if $opt_v;
  1632. X$/ = "\001";            # change record separtor to nonexistent char
  1633. Xopen(WANTED,"Wanted") || die "Can't reopen Wanted.\n";
  1634. X$_ = <WANTED>;            # slurp whole file;
  1635. X$/ = "\n";
  1636. Xy/\n/ /;
  1637. Xopen(MAKEFILE,">.MT/.Makefile") || die "Can't create .MT/.Makefile.\n";
  1638. Xprint MAKEFILE "W = $_\n";
  1639. Xprint MAKEFILE $dependencies;
  1640. Xclose MAKEFILE;
  1641. X
  1642. Xprint "Determining the correct order for the units...\n" if $opt_v;
  1643. Xchdir '.MT' || die "Can't chdir to .MT";
  1644. Xopen(MAKE, "make -n -f .Makefile|") || die "Can't run make";
  1645. Xwhile (<MAKE>) {
  1646. X    print "\t$_" if $opt_V;
  1647. X    if (/^pick/) {
  1648. X    ($pick,$cmd,$symbol,$unit) = split(' ');
  1649. X    $symwanted{$symbol}++;
  1650. X    unless ($unitseen{$unit}++) {
  1651. X        push(@cmdwanted,"$cmd $unit");
  1652. X        $symwanted{$unit}++;
  1653. X    }
  1654. X    }
  1655. X    else {
  1656. X    chop;
  1657. X    system;
  1658. X    }
  1659. X}
  1660. Xclose MAKE;
  1661. X
  1662. Xprint "Creating Configure...\n" if $opt_v;
  1663. Xopen(CONFIGURE,">$WD/Configure") || die "Can't create Configure.\n";
  1664. Xopen(CONF_H,">$WD/config.h.SH") || die "Can't create config.h.SH.\n";
  1665. Xfor (@cmdwanted) {
  1666. X    ($cmd,$unit) = split;
  1667. X    $dir = ($myUseen{$unit} ? $WD : $MC);
  1668. X    $unit .= '.U';
  1669. X    if (m|/|) {
  1670. X    $file = $unit;            # they must know what they're doing
  1671. X    }
  1672. X    elsif ($myUseen{$unit}) {
  1673. X    $file = "$WD/U/$unit";        # they MIGHT know what they're doing
  1674. X    }
  1675. X    else {
  1676. X    $file = "$MC/U/$unit";        # normal case
  1677. X    }
  1678. X    die "Can't open $file" unless open(UNIT,$file);
  1679. X    print "\t$cmd $file\n" if $opt_V;
  1680. X    if ($cmd eq 'add') {
  1681. X    while (<UNIT>) {
  1682. X        print CONFIGURE unless /^\?/;
  1683. X    }
  1684. X    }
  1685. X    elsif ($cmd eq 'weed') {
  1686. X    while (<UNIT>) {
  1687. X        if (/^\?(\w+):/) {
  1688. X        s/^\?\w+:// if $symwanted{$1};
  1689. X        }
  1690. X        print CONFIGURE unless /^\?/;
  1691. X    }
  1692. X    }
  1693. X    elsif ($cmd eq 'add.package') {
  1694. X    while (<UNIT>) {
  1695. X        s/PACKAGENAME/$package/g;
  1696. X        print CONFIGURE unless /^\?/;
  1697. X    }
  1698. X    }
  1699. X    elsif ($cmd eq 'add.Null') {
  1700. X    for (@Master) {
  1701. X        if (/^\?(\w+):/) {
  1702. X        s/^\?\w+:// if $symwanted{$1};
  1703. X        }
  1704. X        print CONFIGURE unless /^\?/;
  1705. X    }
  1706. X    while (<UNIT>) {
  1707. X        print CONFIGURE unless /^\?/;
  1708. X    }
  1709. X    print CONFIGURE "CONFIG=''\n";
  1710. X    }
  1711. X    elsif ($cmd eq 'add.Config_sh') {
  1712. X    while (<UNIT>) {
  1713. X        print CONFIGURE unless /^\?/;
  1714. X    }
  1715. X    for (@Master) {
  1716. X        if (/^\?(\w+):/) {
  1717. X        s/^\?\w+:// if $symwanted{$1};
  1718. X        }
  1719. X        s/^(\w+)=''/$1='\$$1'/;
  1720. X        print CONFIGURE unless /^\?/;
  1721. X    }
  1722. X    print CONFIGURE "CONFIG=true\nEOT\n\n";
  1723. X    }
  1724. X    elsif ($cmd eq 'c_h_weed') {
  1725. X    while (<UNIT>) {
  1726. X        if (/^\?(\w+):/) {
  1727. X        s/^\?\w+:// if $symwanted{$1};
  1728. X        }
  1729. X        print CONF_H unless /^\?/;
  1730. X    }
  1731. X    }
  1732. X    else {
  1733. X    die "Unrecognized command from .Makefile: $cmd\n";
  1734. X    }
  1735. X    close UNIT;
  1736. X}
  1737. Xclose CONFIGURE;
  1738. Xclose CONF_H;
  1739. X
  1740. Xchdir $WD || die "Can't cd back to $WD\n";
  1741. X`chmod +x Configure`;
  1742. X
  1743. Xif (-f 'config.h.SH') {
  1744. X    open(NEWMANI,$NEWMANI);
  1745. X    $/ = "\001";
  1746. X    $_ = <NEWMANI>;
  1747. X    $/ = "\n";
  1748. X    close NEWMANI;
  1749. X    unless (/config\.h\.SH/) {
  1750. X    print "Adding config.h.SH to your $NEWMANI file...\n" if $opt_v;
  1751. X    `echo "config.h.SH    Produces config.h." >>$NEWMANI`;
  1752. X    }
  1753. X}
  1754. Xif ($opt_V) {
  1755. X    print "Leaving subdirectory .MT unremoved so you can peruse it.\n";
  1756. X}
  1757. Xelse {
  1758. X    `rm -rf .MT 2>&1`;
  1759. X}
  1760. Xprint "Done.\n" if $opt_v;
  1761. X
  1762. Xsub readpackage {
  1763. X    if (! -f '.package') {
  1764. X        if (-f '../.package' || -f '../../.package') {
  1765. X            die "Run in top level directory only.\n";
  1766. X        }
  1767. X        else {
  1768. X            die "No .package file!  Run packinit.\n";
  1769. X        }
  1770. X    }
  1771. X    open(package,'.package');
  1772. X    while (<package>) {
  1773. X        next if /^:/;
  1774. X        next if /^#/;
  1775. X        if (($var,$val) = /^\s*(\w+)=(.*)/) {
  1776. X            $val = "\"$val\"" unless $val =~ /^['"]/;
  1777. X            eval "\$$var = $val;";
  1778. X        }
  1779. X    }
  1780. X    close package;
  1781. X}
  1782. X
  1783. Xsub manifake {
  1784. X    # make MANIFEST and MANIFEST.new say the same thing
  1785. X    if (! -f $NEWMANI) {
  1786. X        if (-f $MANI) {
  1787. X            open(IN,$MANI) || die "Can't open $MANI";
  1788. X            open(OUT,">$NEWMANI") || die "Can't create $NEWMANI";
  1789. X            while (<IN>) {
  1790. X                next if 1 .. /---/;
  1791. X                s/(\s+)[0-9]*\s*/$1/;
  1792. X            }
  1793. X            close IN; close OUT;
  1794. X        }
  1795. X        else {
  1796. Xdie "You need to make a MANIFEST.new file, with names and descriptions.\n";
  1797. X        }
  1798. X    }
  1799. X}
  1800. X!NO!SUBS!
  1801. Xchmod +x metaconfig
  1802. X$eunicefix metaconfig
  1803. !STUFFY!FUNK!
  1804. echo Extracting mcon/U/mailfile.U
  1805. sed >mcon/U/mailfile.U <<'!STUFFY!FUNK!' -e 's/X//'
  1806. X?RCS:$Header: mailfile.U,v 2.0 88/06/28 23:17:09 lwall Locked $
  1807. X?RCS: $Log:    mailfile.U,v $
  1808. X?RCS: Revision 2.0  88/06/28  23:17:09  lwall
  1809. X?RCS: Baseline.
  1810. X?RCS: 
  1811. X?MAKE:mailfile: test echo n c Myread Loc Filexp Oldconfig
  1812. X?MAKE:    -pick add $@ %*
  1813. X?S:mailfile:
  1814. X?S:    This variable contains the eventual value of the MAILFILE symbol,
  1815. X?S:    which contains an interpretable name of the mail spool file for the
  1816. X?S:    current user.
  1817. X?S:.
  1818. X?C:MAILFILE:
  1819. X?C:    This symbol contains the interpretable name of the mail spool file
  1820. X?C:    for the current user.  The program must be prepared to substitute
  1821. X?C:    the HOME directory for %~, and the login id for %L.
  1822. X?C:.
  1823. X?H:?%1:#define MAILFILE "$mailfile"        /**/
  1824. X?H:?%1:
  1825. X: determine where mail is spooled
  1826. Xcase "$mailfile" in
  1827. X'')
  1828. X    dflt=`loc . XXX /usr/spool/mail /usr/mail`
  1829. X    case "$dflt" in
  1830. X    XXX) dflt='%~/mailbox';;
  1831. X    *) dflt="$dflt/%L";;
  1832. X    esac
  1833. X    ;;
  1834. X*)  dflt="$mailfile"
  1835. X    ;;
  1836. Xesac
  1837. Xcat <<'EOM'
  1838. X
  1839. XIn the following question, you may use %~ to represent the user's home
  1840. Xdirectory, and %L to represent a users name.
  1841. X
  1842. XEOM
  1843. Xrp="Where is yet-to-be-read mail spooled? [$dflt]"
  1844. X$echo $n "$rp $c"
  1845. X. myread
  1846. Xmailfile=`filexp "$ans"`
  1847. X
  1848. !STUFFY!FUNK!
  1849. echo ""
  1850. echo "End of kit 1 (of 7)"
  1851. cat /dev/null >kit1isdone
  1852. run=''
  1853. config=''
  1854. for iskit in 1 2 3 4 5 6 7; do
  1855.     if test -f kit${iskit}isdone; then
  1856.     run="$run $iskit"
  1857.     else
  1858.     todo="$todo $iskit"
  1859.     fi
  1860. done
  1861. case $todo in
  1862.     '')
  1863.     echo "You have run all your kits.  Please read README and then type Configure."
  1864.     chmod 755 Configure
  1865.     ;;
  1866.     *)  echo "You have run$run."
  1867.     echo "You still need to run$todo."
  1868.     ;;
  1869. esac
  1870. : Someone might mail this, so...
  1871. exit
  1872.  
  1873.