home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume19 / dmake / part14 < prev    next >
Encoding:
Text File  |  1991-05-11  |  40.4 KB  |  1,029 lines

  1. Newsgroups: comp.sources.misc
  2. From: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  3. Subject:  v19i035:  dmake - dmake version 3.7, Part14/37
  4. Message-ID: <1991May12.001753.9114@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 8db0556316dc2c75d909ad2e17e14eec
  6. Date: Sun, 12 May 1991 00:17:53 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  10. Posting-number: Volume 19, Issue 35
  11. Archive-name: dmake/part14
  12. Supersedes: dmake-3.6: Volume 15, Issue 52-77
  13.  
  14. ---- Cut Here and feed the following to sh ----
  15. #!/bin/sh
  16. # this is dmake.shar.14 (part 14 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file dmake/man/dmake.nc continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 14; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test -f _shar_wnt_.tmp; then
  33. sed 's/^X//' << 'SHAR_EOF' >> 'dmake/man/dmake.nc' &&
  34. X                     files to be handed to the command inter-
  35. X                     preter.  For example, if it is defined as
  36. X                     .sh, then all temporary files created by
  37. X                     dmake will end in the suffix .sh.  Under
  38. X                     MSDOS if you are using command.com as your
  39. X                     GROUPSHELL, then this suffix must be set to
  40. X                     .bat in order for group recipes to function
  41. X                     correctly.  The setting of GROUPSUFFIX and
  42. X                     GROUPSHELL is done automatically for
  43. X                     command.com in the startup.mk files.
  44. X
  45. X     MAKE            Is defined in the startup file by default.
  46. X                     The string $(MAKE) is recognized when using
  47. X                     the -n option for single line recipes.  Ini-
  48. X                     tially this macro is defined to have the
  49. X                     value "$(MAKECMD) $(MFLAGS)".
  50. X
  51. X     MAKESTARTUP     This macro defines the full path to the ini-
  52. X                     tial startup makefile.  Use the -V command
  53. X                     line option to discover its initial value.
  54. X
  55. X
  56. X
  57. X
  58. X
  59. Version 3.70                    UW                             27
  60. X
  61. X
  62. X
  63. X
  64. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  65. X
  66. X
  67. X
  68. X     MAXLINELENGTH   This macro defines the maximum size of a
  69. X                     single line of makefile input text.  The
  70. X                     size is specified as a number, the default
  71. X                     value is defined internally and is shown via
  72. X                     the -V option.  A buffer of this size plus 2
  73. X                     is allocated for reading makefile text.  The
  74. X                     buffer is freed before any targets are made,
  75. X                     thereby allowing files containing long input
  76. X                     lines to be processed without consuming
  77. X                     memory during the actual make.
  78. X
  79. X     MAXPROCESS      Specify the maximum number of child
  80. X                     processes to use when making targets.  The
  81. X                     default value of this macro is "1" and its
  82. X                     value cannot exceed the value of the macro
  83. X                     MAXPROCESSLIMIT.  Setting the value of MAX-
  84. X                     PROCESS on the command line or in the
  85. X                     makefile is equivalent to supplying a
  86. X                     corresponding value to the -P flag on the
  87. X                     command line.
  88. X
  89. X     PREP            This macro defines the number of iterations
  90. X                     to be expanded automatically when processing
  91. X                     % rule definitions of the form:
  92. X
  93. X                     % : %.suff
  94. X
  95. X                     See the sections on PERCENT(%) RULES for
  96. X                     details on how PREP is used.
  97. X
  98. X     SHELL           This macro defines the full path to the exe-
  99. X                     cutable image to be used as the shell when
  100. X                     processing single line recipes.  This macro
  101. X                     must be defined if recipes requiring the
  102. X                     shell for execution are to be used.  It is
  103. X                     assigned a default value in the startup
  104. X                     makefile.  Under UNIX this value is /bin/sh.
  105. X
  106. X     SHELLFLAGS      This macro gives the set of flags to pass to
  107. X                     the shell when invoking it to execute a sin-
  108. X                     gle line recipe.  The value of the macro is
  109. X                     the list of flags with a leading switch
  110. X                     indicator.  (ie. `-' under UNIX)
  111. X
  112. X     SHELLMETAS      Each time dmake executes a single recipe
  113. X                     line (not a group recipe) the line is
  114. X                     searched for any occurrence of a character
  115. X                     defined in the value of SHELLMETAS.  If such
  116. X                     a character is found the recipe line is
  117. X                     defined to require a shell to ensure its
  118. X                     correct execution.  In such instances a
  119. X                     shell is used to invoke the recipe line.  If
  120. X
  121. X
  122. X
  123. Version 3.70                    UW                             28
  124. X
  125. X
  126. X
  127. X
  128. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  129. X
  130. X
  131. X
  132. X                     no match is found the recipe line is exe-
  133. X                     cuted without the use of a shell.
  134. X
  135. X
  136. X     There is only one character valued macro defined by dmake:
  137. X     SWITCHAR contains the switch character used to introduce
  138. X     options on command lines.  For UNIX its value is '-', and
  139. X     for MSDOS its value may be '/' or '-'.  The macro is inter-
  140. X     nally defined and is not user setable.  The MSDOS version of
  141. X     dmake attempts to first extract SWITCHAR from an environment
  142. X     variable of the same name.  If that fails it then attempts
  143. X     to use the undocumented getswitchar system call, and returns
  144. X     the result of that.  Under MSDOS version 4.0 you must set
  145. X     the value of the environment macro SWITCHAR to '/' to obtain
  146. X     predictable behavior.
  147. X
  148. X     All boolean macros currently understood by dmake correspond
  149. X     directly to the previously defined attributes.  These macros
  150. X     provide a second way to apply global attributes, and
  151. X     represent the preferred method of doing so.  They are used
  152. X     by assigning them a value.  If the value is not a NULL
  153. X     string then the boolean condition is set to on.  If the
  154. X     value is a NULL string then the condition is set to off.
  155. X     There are five conditions defined and they correspond
  156. X     directly to the attributes of the same name.  Their meanings
  157. X     are defined in the ATTRIBUTES section above.  The macros
  158. X     are: .EPILOG, .IGNORE, .MKSARGS, .NOINFER, .PRECIOUS, .PRO-
  159. X     LOG, .SEQUENTIAL, .SILENT, .SWAP, and .USESHELL.  Assigning
  160. X     any of these a non NULL value will globally set the
  161. X     corresponding attribute to on.
  162. X
  163. RUN_TIME MACROS
  164. X     These macros are defined when dmake is making targets, and
  165. X     may take on different values for each target.  $@ is defined
  166. X     to be the full target name, $? is the list of all out of
  167. X     date prerequisites, $& is the list of all prerequisites, $>
  168. X     is the name of the library if the current target is a
  169. X     library member, and $< is the list of prerequisites speci-
  170. X     fied in the current rule.  If the current target had a
  171. X     recipe inferred then $< is the name of the inferred prere-
  172. X     quisite even if the target had a list of prerequisites sup-
  173. X     plied using an explicit rule that did not provide a recipe.
  174. X     In such situations $& gives the full list of prerequisites.
  175. X
  176. X     $* is defined as $(@:db) when making targets with explicit
  177. X     recipes and is defined as the value of % when making targets
  178. X     whose recipe is the result of an inference.  In the first
  179. X     case $* is the target name with no suffix, and in the second
  180. X     case, is the value of the matched % pattern from the associ-
  181. X     ated %-rule.  $^ expands to the set of out of date prere-
  182. X     quisites taken from the current value of $<.  In addition to
  183. X     these, $$ expands to $, {{ expands to {, }} expands to },
  184. X
  185. X
  186. X
  187. Version 3.70                    UW                             29
  188. X
  189. X
  190. X
  191. X
  192. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  193. X
  194. X
  195. X
  196. X     and the strings <+ and +> are recognized as respectively
  197. X     starting and terminating a text diversion when they appear
  198. X     literally together in the same input line.
  199. X
  200. X     The difference between $? and $^ can best be illustrated by
  201. X     an example, consider:
  202. X
  203. X          fred.out : joe amy hello
  204. X               rules for making fred
  205. X
  206. X          fred.out : my.c your.h his.h her.h   # more prerequisites
  207. X
  208. X     Assume joe, amy, and my.c are newer then fred.out.  When
  209. X     dmake executes the recipe for making fred.out the values of
  210. X     the following macros will be:
  211. X
  212. X          $@ --> fred.out
  213. X          $* --> fred
  214. X          $? --> joe amy my.c  # note the difference between $? and $^
  215. X          $^ --> joe amy
  216. X          $< --> joe amy hello
  217. X          $& --> joe amy hello my.c your.h his.h her.h
  218. X
  219. X
  220. FUNCTION MACROS
  221. X     dmake supports a full set of functional macros.  One of
  222. X     these, the $(mktmp ...) macro, is discussed in detail in the
  223. X     TEXT DIVERSION section and is not covered here.
  224. X
  225. X
  226. X          $(null,text true false)
  227. X               expands the value of text. If it is NULL then the
  228. X               macro returns the value of the expansion of true
  229. X               and the expansion of false otherwise.  The terms
  230. X               true, and false must be strings containing no
  231. X               white-space.
  232. X
  233. X          $(!null,text true false)
  234. X               Behaves identically to the previous macro except
  235. X               that the true string is chosen if the expansion of
  236. X               text is not NULL.
  237. X
  238. X          $(eq,text_a,text_b true false)
  239. X               expands text_a and text_b and compares their
  240. X               results.  If equal it returns the result of the
  241. X               expansion of the true term, otherwise it returns
  242. X               the expansion of the false term.
  243. X
  244. X          $(!eq,text_a,text_b true false)
  245. X               Behaves identically to the previous macro except
  246. X               that the true string is chosen if the expansions
  247. X               of the two strings are not equal
  248. X
  249. X
  250. X
  251. Version 3.70                    UW                             30
  252. X
  253. X
  254. X
  255. X
  256. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  257. X
  258. X
  259. X
  260. X          $(shell command)
  261. X               Runs command as if it were part of a recipe and
  262. X               returns, separated by a single space, all the
  263. X               non-white space terms written to stdout by the
  264. X               command.  For example:
  265. X
  266. X                    $(shell ls *.c)
  267. X
  268. X               will return "a.c b.c c.c d.c" if the files exist
  269. X               in the current directory.  The recipe modification
  270. X               flags [+@%-] are honored if they appear as the
  271. X               first characters in the command.  For example:
  272. X
  273. X                    $(shell +ls *.c)
  274. X
  275. X               will run the command using the current shell.
  276. X
  277. X          $(sort list)
  278. X               Will take all white-space separated tokens in list
  279. X               and will return their sorted equivalent list.
  280. X
  281. X          $(strip data)
  282. X               Will replace all strings of white-space in data by
  283. X               a single space.
  284. X
  285. X          $(subst,pat,replacement data)
  286. X               Will search for pat in data and will replace any
  287. X               occurrence of pat with the replacement string.
  288. X               The expansion
  289. X
  290. X                    $(subst,.o,.c $(OBJECTS))
  291. X
  292. X               is equivalent to:
  293. X
  294. X                    $(OBJECTS:s/.o/.c/)
  295. X
  296. X
  297. DYNAMIC PREREQUISITES
  298. X     dmake looks for prerequisites whose names contain macro
  299. X     expansions during target processing.  Any such prerequisites
  300. X     are expanded and the result of the expansion is used as the
  301. X     prerequisite name.  As an example the line:
  302. X
  303. X          fred : $$@.c
  304. X
  305. X     causes the $$@ to be expanded when dmake is making fred, and
  306. X     it resolves to the target fred.  This enables dynamic prere-
  307. X     quisites to be generated.  The value of @ may be modified by
  308. X     any of the valid macro modifiers.  So you can say for exam-
  309. X     ple:
  310. X
  311. X          fred.out : $$(@:b).c
  312. X
  313. X
  314. X
  315. Version 3.70                    UW                             31
  316. X
  317. X
  318. X
  319. X
  320. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  321. X
  322. X
  323. X
  324. X     where the $$(@:b) expands to fred.  Note the use of $$
  325. X     instead of $ to indicate the dynamic expansion, this is due
  326. X     to the fact that the rule line is expanded when it is ini-
  327. X     tially parsed, and $$ then returns $ which later triggers
  328. X     the dynamic prerequisite expansion.  If you really want a $
  329. X     to be part of a prerequisite name you must use $$$$.
  330. X     Dynamic macro expansion is performed in all user defined
  331. X     rules, and the special targets .SOURCE*, and .INCLUDEDIRS.
  332. X
  333. BINDING TARGETS
  334. X     This operation takes a target name and binds it to an exist-
  335. X     ing file, if possible.  dmake makes a distinction between
  336. X     the internal target name of a target and its associated
  337. X     external file name.  Thus it is possible for a target's
  338. X     internal name and its external file name to differ.  To per-
  339. X     form the binding, the following set of rules is used.
  340. X     Assume that we are trying to bind a target whose name is of
  341. X     the form X.suff, where .suff is the suffix and X is the stem
  342. X     portion (ie. that part which contains the directory and the
  343. X     basename).  dmake takes this target name and performs a
  344. X     series of search operations that try to find a suitably
  345. X     named file in the external file system.  The search opera-
  346. X     tion is user controlled via the settings of the various
  347. X     .SOURCE targets.
  348. X
  349. X          1.   If target has the .SYMBOL attribute set then look
  350. X               for it in the library.  If found, replace the tar-
  351. X               get name with the library member name and continue
  352. X               with step 2.  If the name is not found then
  353. X               return.
  354. X
  355. X          2.   Extract the suffix portion (that following the
  356. X               `.') of the target name.  If the suffix is not
  357. X               null, look up the special target .SOURCE.<suff>
  358. X               (<suff> is the suffix). If the special target
  359. X               exists then search each directory given in the
  360. X               .SOURCE.<suff> prerequisite list for the target.
  361. X               If the target's suffix was null (ie. .suff was
  362. X               empty) then perform the above search but use the
  363. X               special target .SOURCE.NULL instead.  If at any
  364. X               point a match is found then terminate the search.
  365. X               If a directory in the prerequisite list is the
  366. X               special name `.NULL ' perform a search for the
  367. X               full target name without prepending any directory
  368. X               portion (ie. prepend the NULL directory).  (a
  369. X               default target of '.SOURCE : .NULL' is defined by
  370. X               dmake at startup, and is user redefinable)
  371. X
  372. X          3.   The search in step 2. failed.  Repeat the same
  373. X               search but this time use the special target
  374. X               .SOURCE.
  375. X
  376. X
  377. X
  378. X
  379. Version 3.70                    UW                             32
  380. X
  381. X
  382. X
  383. X
  384. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  385. X
  386. X
  387. X
  388. X          4.   The search in step 3. failed.  If the target has
  389. X               the library member attribute (.LIBMEMBER) set then
  390. X               try to find the target in the library which was
  391. X               passed along with the .LIBMEMBER attribute (see
  392. X               the MAKING LIBRARIES section).  The bound file
  393. X               name assigned to a target which is successfully
  394. X               located in a library is the same name that would
  395. X               be assigned had the search failed (see 5.).
  396. X
  397. X          5.   The search failed.  Either the target was not
  398. X               found in any of the search directories or no
  399. X               applicable .SOURCE special targets exist.  If
  400. X               applicable .SOURCE special targets exist, but the
  401. X               target was not found, then dmake assigns the first
  402. X               name searched as the bound file name.  If no
  403. X               applicable .SOURCE special targets exist, then the
  404. X               full original target name becomes the bound file
  405. X               name.
  406. X
  407. X     There is potential here for a lot of search operations.  The
  408. X     trick is to define .SOURCE.x special targets with short
  409. X     search lists and leave .SOURCE as short as possible.  The
  410. X     search algorithm has the following useful side effect.  When
  411. X     a target having the .LIBMEMBER (library member) attribute is
  412. X     searched for, it is first searched for as an ordinary file.
  413. X     When a number of library members require updating it is
  414. X     desirable to compile all of them first and to update the
  415. X     library at the end in a single operation.  If one of the
  416. X     members does not compile and dmake stops, then the user may
  417. X     fix the error and make again.  dmake will not remake any of
  418. X     the targets whose object files have already been generated
  419. X     as long as none of their prerequisite files have been modi-
  420. X     fied as a result of the fix.
  421. X
  422. X     When defining .SOURCE and .SOURCE.x targets the construct
  423. X
  424. X          .SOURCE :
  425. X          .SOURCE : fred gery
  426. X
  427. X     is equivalent to
  428. X
  429. X          .SOURCE :- fred gery
  430. X
  431. X     dmake correctly handles the UNIX Make variable VPATH.  By
  432. X     definition VPATH contains a list of ':' separated direc-
  433. X     tories to search when looking for a target.  dmake maps
  434. X     VPATH to the following special rule:
  435. X
  436. X          .SOURCE :^ $(VPATH:s/:/ /)
  437. X
  438. X     Which takes the value of VPATH and sets .SOURCE to the same
  439. X     set of directories as specified in VPATH.
  440. X
  441. X
  442. X
  443. Version 3.70                    UW                             33
  444. X
  445. X
  446. X
  447. X
  448. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  449. X
  450. X
  451. X
  452. PERCENT(%) RULES AND MAKING INFERENCES
  453. X     When dmake makes a target, the target's set of prerequisites
  454. X     (if any) must exist and the target must have a recipe which
  455. X     dmake can use to make it.  If the makefile does not specify
  456. X     an explicit recipe for the target then dmake uses special
  457. X     rules to try to infer a recipe which it can use to make the
  458. X     target.  Previous versions of Make perform this task by
  459. X     using rules that are defined by targets of the form
  460. X     .<suffix>.<suffix> and by using the .SUFFIXES list of suf-
  461. X     fixes.  The exact workings of this mechanism were sometimes
  462. X     difficult to understand and often limiting in their useful-
  463. X     ness.  Instead, dmake supports the concept of %-meta rules.
  464. X     The syntax and semantics of these rules differ from standard
  465. X     rule lines as follows:
  466. X
  467. X          <%-target> [<attributes>] <ruleop> [<%-prerequisites>] [;<recipe>]
  468. X
  469. X     where %-target is a target containing exactly a single `%'
  470. X     sign, attributes is a list (possibly empty) of attributes,
  471. X     ruleop is the standard set of rule operators, %-prere-
  472. X     quisites , if present, is a list of prerequisites containing
  473. X     zero or more `%' signs, and recipe, if present, is the first
  474. X     line of the recipe.
  475. X
  476. X     The %-target defines a pattern against which a target whose
  477. X     recipe is being inferred gets matched.  The pattern match
  478. X     goes as follows:  all chars are matched exactly from left to
  479. X     right up to but not including the % sign in the pattern, %
  480. X     then matches the longest string from the actual target name
  481. X     not ending in the suffix given after the % sign in the pat-
  482. X     tern.  Consider the following examples:
  483. X
  484. X          %.c       matches fred.c but not joe.c.Z
  485. X          dir/%.c   matches dir/fred.c but not dd/fred.c
  486. X          fred/%    matches fred/joe.c but not f/joe.c
  487. X          %         matches anything
  488. X
  489. X     In each case the part of the target name that matched the %
  490. X     sign is retained and is substituted for any % signs in the
  491. X     prerequisite list of the %-meta rule when the rule is
  492. X     selected during inference and dmake constructs the new
  493. X     dependency.  As an example the following %-meta rules
  494. X     describe the following:
  495. X
  496. X          %.c : %.y ; recipe...
  497. X
  498. X     describes how to make any file ending in .c if a correspond-
  499. X     ing file ending in .y can be found.
  500. X
  501. X          foo%.o : fee%.k ; recipe...
  502. X
  503. X     is used to describe how to make fooxxxx.o from feexxxx.k.
  504. X
  505. X
  506. X
  507. Version 3.70                    UW                             34
  508. X
  509. X
  510. X
  511. X
  512. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  513. X
  514. X
  515. X
  516. X          %.a :; recipe...
  517. X
  518. X     describes how to make a file whose suffix is .a without
  519. X     inferring any prerequisites.
  520. X
  521. X          %.c : %.y yaccsrc/%.y ; recipe...
  522. X
  523. X     is a short form for the construct:
  524. X
  525. X          %.c : %.y ; recipe...
  526. X          %.c : yaccsrc/%.y ; recipe...
  527. X
  528. X     ie. It is possible to specify the same recipe for two
  529. X     %-rules by giving more than one prerequisite in the prere-
  530. X     quisite list.  A more interesting example is:
  531. X
  532. X          % : RCS/%,v ; co $@
  533. X
  534. X     which describes how to take any target and check it out of
  535. X     the RCS directory if the corresponding file exists in the
  536. X     RCS directory.  The equivalent SCCS rule would be:
  537. X
  538. X          % : s.% ; get $@
  539. X
  540. X
  541. X     The previous RCS example defines an infinite rule, because
  542. X     it says how to make anything from RCS/%,v, and anything also
  543. X     includes RCS/fred.c,v.  To limit the size of the graph that
  544. X     results from such rules dmake uses the macro variable PREP
  545. X     (stands for % repetition).  By default the value of this
  546. X     variable is 0, which says that no repetitions of a %-rule
  547. X     are to be generated.  If it is set to something greater than
  548. X     0, then that many repetitions of any infinite %-rule are
  549. X     allowed.  If in the above example PREP was set to 1, then
  550. X     dmake would generate the dependency graph:
  551. X
  552. X          % --> RCS/%,v --> RCS/RCS/%,v,v
  553. X
  554. X     Where each link is assigned the same recipe as the first
  555. X     link.  PREP should be used only in special cases, since it
  556. X     may result in a large increase in the number of possible
  557. X     prerequisites tested.  dmake further assumes that any target
  558. X     that has no suffix can be made from a prerequisite that has
  559. X     at least one suffix.
  560. X
  561. X     dmake supports dynamic prerequisite generation for prere-
  562. X     quisites of %-meta rules.  This is best illustrated by an
  563. X     example.  The RCS rule shown above can infer how to check
  564. X     out a file from a corresponding RCS file only if the target
  565. X     is a simple file name with no directory information.  That
  566. X     is, the above rule can infer how to find RCS/fred.c,v from
  567. X     the target fred.c, but cannot infer how to find
  568. X
  569. X
  570. X
  571. Version 3.70                    UW                             35
  572. X
  573. X
  574. X
  575. X
  576. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  577. X
  578. X
  579. X
  580. X     srcdir/RCS/fred.c,v from srcdir/fred.c because the above
  581. X     rule will cause dmake to look for RCS/srcdir/fred.c,v; which
  582. X     does not exist (assume that srcdir has its own RCS directory
  583. X     as is the common case).
  584. X
  585. X     A more versatile formulation of the above RCS check out rule
  586. X     is the following:
  587. X
  588. X          % :  $$(@:d)RCS/$$(@:f),v : co $@
  589. X
  590. X     This rule uses the dynamic macro $@ to specify the prere-
  591. X     quisite to try to infer.  During inference of this rule the
  592. X     macro $@ is set to the value of the target of the %-meta
  593. X     rule and the appropriate prerequisite is generated by
  594. X     extracting the directory portion of the target name (if
  595. X     any), appending the string RCS/ to it, and appending the
  596. X     target file name with a trailing ,v attached to the previous
  597. X     result.
  598. X
  599. X     dmake can also infer indirect prerequisites.  An inferred
  600. X     target can have a list of prerequisites added that will not
  601. X     show up in the value of $< but will show up in the value of
  602. X     $? and $&.  Indirect prerequisites are specified in an
  603. X     inference rule by quoting the prerequisite with single
  604. X     quotes.  For example, if you had the explicit dependency:
  605. X
  606. X          fred.o : fred.c ; rule to make fred.o
  607. X          fred.o : local.h
  608. X
  609. X     then this can be inferred for fred.o from the following
  610. X     inference rule:
  611. X
  612. X          %.o : %.c 'local.h' ; rule to make a .o from a .c
  613. X
  614. X     You may infer indirect prerequisites that are a function of
  615. X     the value of '%' in the current rule.  The meta-rule:
  616. X
  617. X          %.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
  618. X
  619. X     infers an indirect prerequisite found in the INC directory
  620. X     whose name is the same as the expansion of $(INC), and the
  621. X     prerequisite name depends on the base name of the current
  622. X     target.  The set of indirect prerequisites is attached to
  623. X     the meta rule in which they are specified and are inferred
  624. X     only if the rule is used to infer a recipe for a target.
  625. X     They do not play an active role in driving the inference
  626. X     algorithm.  The construct:
  627. X
  628. X          %.o : %.c %.f 'local.h'; recipe
  629. X
  630. X     is equivalent to:
  631. X
  632. X
  633. X
  634. X
  635. Version 3.70                    UW                             36
  636. X
  637. X
  638. X
  639. X
  640. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  641. X
  642. X
  643. X
  644. X          %.o : %.c 'local.h' : recipe
  645. X          %.o : %.f 'local.h' : recipe
  646. X
  647. X
  648. X     If any of the attributes .SETDIR, .EPILOG, .PROLOG, .SILENT,
  649. X     .USESHELL, .SWAP, .PRECIOUS, .LIBRARY, .NOSTATE and .IGNORE
  650. X     are given for a %-rule then when that rule is bound to a
  651. X     target as the result of an inference, the target's set of
  652. X     attributes is augmented by the attributes from the above set
  653. X     that are specified in the bound %-rule.  Other attributes
  654. X     specified for %-meta rules are not inherited by the target.
  655. X     The .SETDIR attribute is treated in a special way.  If the
  656. X     target already had a .SETDIR attribute set then dmake
  657. X     changes to that directory prior to performing the inference.
  658. X     During inference any .SETDIR attributes for the inferred
  659. X     prerequisite are honored.  The directories must exist for a
  660. X     %-meta rule to be selected as a possible inference path.  If
  661. X     the directories do not exist no error message is issued,
  662. X     instead the corresponding path in the inference graph is
  663. X     rejected.
  664. X
  665. X     dmake also supports the old format special target
  666. X     .<suffix>.<suffix> by identifying any rules of this form and
  667. X     mapping them to the appropriate %-rule.  So for example if
  668. X     an old makefile contains the construct:
  669. X
  670. X          .c.o :; cc -c $< -o $@
  671. X
  672. X     dmake maps this into the following %-rule:
  673. X
  674. X          %.o : %.c; cc -c $< -o $@
  675. X
  676. X     Furthermore, dmake understands several SYSV AUGMAKE special
  677. X     targets and maps them into corresponding %-meta rules.
  678. X     These transformation must be enabled by providing the -A
  679. X     flag on the command line or by setting the value of AUGMAKE
  680. X     to non-NULL.  The construct
  681. X
  682. X          .suff :; recipe
  683. X
  684. X     gets mapped into:
  685. X
  686. X          % : %.suff; recipe
  687. X
  688. X     and the construct
  689. X
  690. X          .c~.o :; recipe
  691. X
  692. X     gets mapped into:
  693. X
  694. X          %.o : s.%.c ; recipe
  695. X
  696. X
  697. X
  698. X
  699. Version 3.70                    UW                             37
  700. X
  701. X
  702. X
  703. X
  704. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  705. X
  706. X
  707. X
  708. X     In general, a special target of the form .<str>~ is replaced
  709. X     by the %-rule construct s.%.<str>, thereby providing support
  710. X     for the syntax used by SYSV AUGMAKE for providing SCCS sup-
  711. X     port.  When enabled, these mappings allow processing of
  712. X     existing SYSV makefiles without modifications.
  713. X
  714. X     dmake bases all of its inferences on the inference graph
  715. X     constructed from the %-rules defined in the makefile.  It
  716. X     knows exactly which targets can be made from which prere-
  717. X     quisites by making queries on the inference graph.  For this
  718. X     reason .SUFFIXES is not needed and is completely ignored.
  719. X
  720. X     For a %-meta rule to be inferred as the rule whose recipe
  721. X     will be used to make a target, the target's name must match
  722. X     the %-target pattern, and any inferred %-prerequisite must
  723. X     already exist or have an explicit recipe so that the prere-
  724. X     quisite can be made.  Without transitive closure on the
  725. X     inference graph the above rule describes precisely when an
  726. X     inference match terminates the search.  If transitive clo-
  727. X     sure is enabled (the usual case), and a prerequisite does
  728. X     not exist or cannot be made, then dmake invokes the infer-
  729. X     ence algorithm recursively on the prerequisite to see if
  730. X     there is some way the prerequisite can be manufactured.
  731. X     For, if the prerequisite can be made then the current target
  732. X     can also be made using the current %-meta rule.  This means
  733. X     that there is no longer a need to give a rule for making a
  734. X     .o from a .y if you have already given a rule for making a
  735. X     .o from a .c and a .c from a .y.  In such cases dmake can
  736. X     infer how to make the .o from the .y via the intermediary .c
  737. X     and will remove the .c when the .o is made.  Transitive clo-
  738. X     sure can be disabled by giving the -T switch on the command
  739. X     line.
  740. X
  741. X     A word of caution.  dmake bases its transitive closure on
  742. X     the %-meta rule targets.  When it performs transitive clo-
  743. X     sure it infers how to make a target from a prerequisite by
  744. X     performing a pattern match as if the potential prerequisite
  745. X     were a new target.  The set of rules:
  746. X
  747. X          %.o : %.c :; rule for making .o from .c
  748. X          %.c : %.y :; rule for making .c from .y
  749. X          % : RCS/%,v :; check out of RCS file
  750. X
  751. X     will, by performing transitive closure, allow dmake to infer
  752. X     how to make a .o from a .y using a .c as an intermediate
  753. X     temporary file.  Additionally it will be able to infer how
  754. X     to make a .y from an RCS file, as long as that RCS file is
  755. X     in the RCS directory and has a name which ends in .y,v.  The
  756. X     transitivity computation is performed dynamically for each
  757. X     target that does not have a recipe.  This has potential to
  758. X     be costly if the %-meta rules are not carefully specified.
  759. X     The .NOINFER attribute is used to mark a %-meta node as
  760. X
  761. X
  762. X
  763. Version 3.70                    UW                             38
  764. X
  765. X
  766. X
  767. X
  768. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  769. X
  770. X
  771. X
  772. X     being a final target during inference.  Any node with this
  773. X     attribute set will not be used for subsequent inferences.
  774. X     As an example the node RCS/%,v is marked as a final node
  775. X     since we know that if the RCS file does not exist there
  776. X     likely is no other way to make it.  Thus the standard
  777. X     startup makefile contains an entry similar to:
  778. X          .NOINFER : RCS/%,v
  779. X     Thereby indicating that the RCS file is the end of the
  780. X     inference chain.
  781. X
  782. X     Whenever the inference algorithm determines that a target
  783. X     can be made from more than one prerequisite and the infer-
  784. X     ence chains for the two methods are the same length the
  785. X     algorithm reports an ambiguity and prints the ambiguous
  786. X     inference chains.
  787. X
  788. X     dmake tries to remove intermediate files resulting from
  789. X     transitive closure if the file is not marked as being PRE-
  790. X     CIOUS, or the -u flag was not given on the command line, and
  791. X     if the inferred intermediate did not previously exist.
  792. X     Intermediate targets that existed prior to being made are
  793. X     never removed.  This is in keeping with the philosophy that
  794. X     dmake should never remove things from the file system that
  795. X     it did not add.  If the special target .REMOVE is defined
  796. X     and has a recipe then dmake constructs a list of the inter-
  797. X     mediate files to be removed and makes them prerequisites of
  798. X     .REMOVE.  It then makes .REMOVE thereby removing the prere-
  799. X     quisites if the recipe of .REMOVE says to.  Typically
  800. X     .REMOVE is defined in the startup file as:
  801. X
  802. X          .REMOVE :; $(RM) $<
  803. X
  804. MAKING TARGETS
  805. X     In order to update a target dmake must execute a recipe.
  806. X     When a recipe needs to be executed it is first expanded so
  807. X     that any macros in the recipe text are expanded, and it is
  808. X     then either executed directly or passed to a shell.  dmake
  809. X     supports two types of recipes.  The regular recipes and
  810. X     group recipes.
  811. X
  812. X     When a regular recipe is invoked dmake executes each line of
  813. X     the recipe separately using a new copy of a shell if a shell
  814. X     is required.  Thus effects of commands do not generally per-
  815. X     sist across recipe lines.  (e.g. cd requests in a recipe
  816. X     line do not carry over to the next recipe line) The decision
  817. X     on whether a shell is required to execute a command is based
  818. X     on the value of the macro SHELLMETAS or on the specification
  819. X     of '+' or .USESHELL for the current recipe or target respec-
  820. X     tively.  If any character in the value of SHELLMETAS is
  821. X     found in the expanded recipe text-line or the use of a shell
  822. X     is requested explicitly via '+' or .USESHELL then the com-
  823. X     mand is executed using a shell, otherwise the command is
  824. X
  825. X
  826. X
  827. Version 3.70                    UW                             39
  828. X
  829. X
  830. X
  831. X
  832. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  833. X
  834. X
  835. X
  836. X     executed directly.  The shell that is used for execution is
  837. X     given by the value of the macro SHELL.  The flags that are
  838. X     passed to the shell are given by the value of SHELLFLAGS.
  839. X     Thus dmake constructs the command line:
  840. X
  841. X          $(SHELL) $(SHELLFLAGS) $(expanded_recipe_command)
  842. X
  843. X     Normally dmake writes the command line that it is about to
  844. X     invoke to standard output.  If the .SILENT attribute is set
  845. X     for the target or for the recipe line (via @), then the
  846. X     recipe line is not echoed.
  847. X
  848. X     Group recipe processing is similar to that of regular
  849. X     recipes, except that a shell is always invoked.  The shell
  850. X     that is invoked is given by the value of the macro GROUP-
  851. X     SHELL, and its flags are taken from the value of the macro
  852. X     GROUPFLAGS.  If a target has the .PROLOG attribute set then
  853. X     dmake prepends to the shell script the recipe associated
  854. X     with the special target .GROUPPROLOG, and if the attribute
  855. X     .EPILOG is set as well, then the recipe associated with the
  856. X     special target .GROUPEPILOG is appended to the script file.
  857. X     This facility can be used to always prepend a common header
  858. X     and common trailer to group recipes.  Group recipes are
  859. X     echoed to standard output just like standard recipes, but
  860. X     are enclosed by lines beginning with [ and ].
  861. X
  862. X     The recipe flags [+,-,%,@] are recognized at the start of a
  863. X     recipe line even if they appear in a macro.  For example:
  864. X
  865. X          SH = +
  866. X          all:
  867. X               $(SH)echo hi
  868. X
  869. X     is completely equivalent to writing
  870. X
  871. X          SH = +
  872. X          all:
  873. X               +echo hi
  874. X
  875. X
  876. X     The last step performed by dmake prior to running a recipe
  877. X     is to set the macro CMNDNAME to the name of the command to
  878. X     execute (determined by finding the first white-space ending
  879. X     token in the command line).  It then sets the macro CMNDARGS
  880. X     to be the remainder of the line.  dmake then expands the
  881. X     macro COMMAND which by default is set to
  882. X
  883. X          COMMAND = $(CMNDNAME) $(CMNDARGS)
  884. X
  885. X     The result of this final expansion is the command that will
  886. X     be executed.  The reason for this expansion is to allow for
  887. X     a different interface to the argument passing facilities
  888. X
  889. X
  890. X
  891. Version 3.70                    UW                             40
  892. X
  893. X
  894. X
  895. X
  896. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  897. X
  898. X
  899. X
  900. X     (esp. under DOS) than that provided by dmake. You can for
  901. X     example define COMMAND to be
  902. X
  903. X          COMMAND = $(CMNDNAME) @$(mktmp $(CMNDARGS))
  904. X
  905. X     which dumps the arguments into a temporary file and runs the
  906. X     command
  907. X
  908. X          $(CMNDNAME) @/tmp/ASAD23043
  909. X
  910. X     which has a much shorter argument list.  It is now up to the
  911. X     command to use the supplied argument as the source for all
  912. X     other arguments.  As an optimization, if COMMAND is not
  913. X     defined dmake does not perform the above expansion.  On sys-
  914. X     tems, such as UNIX, that handle long command lines this pro-
  915. X     vides a slight saving in processing the makefiles.
  916. X
  917. MAKING LIBRARIES
  918. X     Libraries are easy to maintain using dmake.  A library is a
  919. X     file containing a collection of object files.  Thus to make
  920. X     a library you simply specify it as a target with the
  921. X     .LIBRARY attribute set and specify its list of prere-
  922. X     quisites.  The prerequisites should be the object members
  923. X     that are to go into the library.  When dmake makes the
  924. X     library target it uses the .LIBRARY attribute to pass to the
  925. X     prerequisites the .LIBMEMBER attribute and the name of the
  926. X     library.  This enables the file binding mechanism to look
  927. X     for the member in the library if an appropriate object file
  928. X     cannot be found. A small example best illustrates this.
  929. X
  930. X          mylib.a .LIBRARY : mem1.o mem2.o mem3.o
  931. X               rules for making library...
  932. X               # remember to remove .o's when lib is made
  933. X
  934. X          # equivalent to:  '%.o : %.c ; ...'
  935. X          .c.o :; rules for making .o from .c say
  936. X
  937. X     dmake will use the .c.o rule for making the library members
  938. X     if appropriate .c files can be found using the search rules.
  939. X     NOTE:  this is not specific in any way to C programs, they
  940. X     are simply used as an example.
  941. X
  942. X     dmake tries to handle the old library construct format in a
  943. X     sensible way.  The construct lib(member.o) is separated and
  944. X     the lib portion is declared as a library target.  The new
  945. X     target is defined with the .LIBRARY attribute set and the
  946. X     member.o portion of the construct is declared as a prere-
  947. X     quisite of the lib target.  If the construct lib(member.o)
  948. X     appears as a prerequisite of a target in the makefile, that
  949. X     target has the new name of the lib assigned as its prere-
  950. X     quisite.  Thus the following example:
  951. X
  952. X
  953. X
  954. X
  955. Version 3.70                    UW                             41
  956. X
  957. X
  958. X
  959. X
  960. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  961. X
  962. X
  963. X
  964. X          a.out : ml.a(a.o) ml.a(b.o); $(CC) -o $@  $<
  965. X
  966. X          .c.o :; $(CC) -c $(CFLAGS) -o $@  $<
  967. X          %.a:
  968. X               ar rv $@ $<
  969. X               ranlib $@
  970. X               rm -rf $<
  971. X
  972. X     constructs the following dependency graph.
  973. X
  974. X          a.out : ml.a; $(CC) -o $@  $<
  975. X          ml.a .LIBRARY : a.o b.o
  976. X
  977. X          %.o : %.c ; $(CC) -c $(CFLAGS) -o $@  $<
  978. X          %.a :
  979. X               ar rv $@ $<
  980. X               ranlib $@
  981. X               rm -rf $<
  982. X
  983. X     and making a.out then works as expected.
  984. X
  985. X     The same thing happens for any target of the form
  986. X     lib((entry)).  These targets have an additional feature in
  987. X     that the entry target has the .SYMBOL attribute set automat-
  988. X     ically.
  989. X
  990. X     NOTE:  If the notion of entry points is supported by the
  991. X     archive and by dmake (currently not the case) then dmake
  992. X     will search the archive for the entry point and return not
  993. X     only the modification time of the member which defines the
  994. X     entry but also the name of the member file.  This name will
  995. X     then replace entry and will be used for making the member
  996. X     file.  Once bound to an archive member the .SYMBOL attribute
  997. X     is removed from the target.  This feature is presently dis-
  998. X     abled as there is little standardization among archive for-
  999. X     mats, and we have yet to find a makefile utilizing this
  1000. X     feature (possibly due to the fact that it is unimplemented
  1001. X     in most versions of UNIX Make).
  1002. X
  1003. X     Finally, when dmake looks for a library member it must first
  1004. X     locate the library file.  It does so by first looking for
  1005. X     the library relative to the current directory and if it is
  1006. X     not found it then looks relative to the current value of
  1007. X     $(TMD).  This allows commonly used libraries to be kept near
  1008. X     the root of a source tree and to be easily found by dmake.
  1009. X
  1010. KEEP STATE
  1011. X     dmake supports the keeping of state information for targets
  1012. X     that it makes whenever the macro .KEEP_STATE is assigned a
  1013. X     value.  The value of the macro should be the name of a state
  1014. X     file that will contain the state information.  If state
  1015. X     keeping is enabled then each target that does not poses the
  1016. SHAR_EOF
  1017. true || echo 'restore of dmake/man/dmake.nc failed'
  1018. fi
  1019. echo 'End of part 14, continue with part 15'
  1020. echo 15 > _shar_seq_.tmp
  1021. exit 0
  1022.  
  1023. exit 0 # Just in case...
  1024. -- 
  1025. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1026. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1027. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1028. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1029.