home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume14 / dmake / part11 < prev    next >
Encoding:
Text File  |  1990-07-26  |  39.0 KB  |  1,001 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v14i021: dmake version 3.5 part 11/21
  3. From: dvadura@watdragon.waterloo.edu (Dennis Vadura)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 14, Issue 21
  7. Submitted-by: dvadura@watdragon.waterloo.edu (Dennis Vadura)
  8. Archive-name: dmake/part11
  9.  
  10. #!/bin/sh
  11. # this is part 11 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file man/dmake.p continued
  14. #
  15. CurArch=11
  16. if test ! -r s2_seq_.tmp
  17. then echo "Please unpack part 1 first!"
  18.      exit 1; fi
  19. ( read Scheck
  20.   if test "$Scheck" != $CurArch
  21.   then echo "Please unpack part $Scheck next!"
  22.        exit 1;
  23.   else exit 0; fi
  24. ) < s2_seq_.tmp || exit 1
  25. echo "x - Continuing file man/dmake.p"
  26. sed 's/^X//' << 'SHAR_EOF' >> man/dmake.p
  27. X     $$$$ expands to $, {{{{ expands to {, }}}} expands to }, and the
  28. X     strings <<++ and ++>> are reserved for use in recipe scripts for
  29. X     starting and terminating a text diversion respectively.
  30. X
  31. X     The difference between $? and $^ can best be illustrated by
  32. X     an example, consider:
  33. X
  34. X          fred.out : joe amy hello
  35. X               rules for making fred
  36. X
  37. X          fred.out : my.c your.h his.h her.h   # more prerequisites
  38. X
  39. X     Assume joe, amy, and my.c are newer then fred.out.  When
  40. X     ddmmaakkee executes the recipe for making fred.out the values of
  41. X     the following macros will be:
  42. X
  43. X          $@ --> fred.out
  44. X          $* --> fred
  45. X          $? --> joe amy my.c  # note the difference between $? and $^
  46. X          $^ --> joe amy
  47. X          $< --> joe amy hello
  48. X          $& --> joe amy hello my.c your.h his.h her.h
  49. X
  50. X
  51. XDDYYNNAAMMIICC PPRREERREEQQUUIISSIITTEESS
  52. X     ddmmaakkee looks for prerequisites whose names contain macro
  53. X     expansions during target processing.  Any such prerequisites
  54. X     are expanded and the result of the expansion is used as the
  55. X     prerequisite name.  As an example the line:
  56. X
  57. X          fred : $$@.c
  58. X
  59. X
  60. X
  61. XVersion 3.50                    UW                             25
  62. X
  63. X
  64. X
  65. X
  66. XDMAKE(p)               Unsupported Software               DMAKE(p)
  67. X
  68. X
  69. X
  70. X     causes the $$@ to be expanded when ddmmaakkee is making fred, and
  71. X     it resolves to the target _f_r_e_d.  This enables dynamic prere-
  72. X     quisites to be generated.  The value of @ may be modified by
  73. X     any of the valid macro modifiers.  So you can say for exam-
  74. X     ple:
  75. X
  76. X          fred.out : $$(@:b).c
  77. X
  78. X     where the $$(@:b) expands to _f_r_e_d.  Note the use of $$
  79. X     instead of $ to indicate the dynamic expansion, this is due
  80. X     to the fact that the rule line is expanded when it is ini-
  81. X     tially parsed, and $$ then returns $ which later triggers
  82. X     the dynamic prerequisite expansion.  If you really want a $
  83. X     to be part of a prerequisite name you must use $$$$.
  84. X     Dynamic macro expansion is performed in all user defined
  85. X     rules, and the special targets .SOURCE*, and .INCLUDEDIRS.
  86. X
  87. XBBIINNDDIINNGG TTAARRGGEETTSS
  88. X     This operation takes a target name and binds it to an exist-
  89. X     ing file, if possible.  ddmmaakkee makes a distinction between
  90. X     the internal target name of a target and it's associated
  91. X     external file name.  Thus it is possible for a target's
  92. X     internal name and its external file name to differ.  To per-
  93. X     form the binding, the following set of rules is used.
  94. X     Assume that we are trying to bind a target whose name is of
  95. X     the form _X_._s_u_f_f, where _._s_u_f_f is the suffix and _X is the stem
  96. X     portion (ie. that part which contains the directory and the
  97. X     basename).  ddmmaakkee takes this target name and performs a
  98. X     series of search operations that try to find a suitably
  99. X     named file in the external file system.  The search opera-
  100. X     tion is user controlled via the settings of the various
  101. X     .SOURCE targets.
  102. X
  103. X          1.   If target has the .SYMBOL attribute set then look
  104. X               for it in the library.  If found, replace the tar-
  105. X               get name with the library member name and continue
  106. X               with step 2.  If the name is not found then
  107. X               return.
  108. X
  109. X          2.   Extract the suffix portion (that following the
  110. X               `.') of the target name.  If the suffix is not
  111. X               null, look up the special target .SOURCE.<suff>
  112. X               (<suff> is the suffix). If the special target
  113. X               exists then search each directory given in the
  114. X               .SOURCE.<suff> prerequisite list for the target.
  115. X               If the target's suffix was null (ie. _._s_u_f_f was
  116. X               empty) then perform the above search but use the
  117. X               special target .SOURCE.NULL instead.  If at any
  118. X               point a match is found then terminate the search.
  119. X               If a directory in the prerequisite list is the
  120. X               special name `.NULL ' perform a stat for the full
  121. X               target name without prepending any directory
  122. X
  123. X
  124. X
  125. XVersion 3.50                    UW                             26
  126. X
  127. X
  128. X
  129. X
  130. XDMAKE(p)               Unsupported Software               DMAKE(p)
  131. X
  132. X
  133. X
  134. X               portion (ie. prepend the NULL directory).  (a
  135. X               default target of '.SOURCE : .NULL' is defined by
  136. X               ddmmaakkee at startup, and is user redefinable)
  137. X
  138. X          3.   The search in step 2. failed.  Repeat the same
  139. X               search but this time use the special target
  140. X               .SOURCE.
  141. X
  142. X          4.   The search in step 3. failed.  If the target has
  143. X               the library member attribute (.LIBMEMBER) set then
  144. X               try to find the target in the library which was
  145. X               passed along with the .LIBMEMBER attribute (see
  146. X               the MAKING LIBRARIES section).  The bound file
  147. X               name assigned to a target which is successfully
  148. X               located in a library is the same name that would
  149. X               be assigned had the search failed (see 5.).
  150. X
  151. X          5.   The search failed.  Either the target was not
  152. X               found in any of the search directories or no
  153. X               applicable .SOURCE special targets exist.  If
  154. X               applicable .SOURCE special targets exist, but the
  155. X               target was not found, then ddmmaakkee assigns the first
  156. X               name searched as the bound file name.  If no
  157. X               applicable .SOURCE special targets exist, then the
  158. X               full original target name becomes the bound file
  159. X               name.
  160. X
  161. X     There is potential here for a lot of search operations.  The
  162. X     trick is to define .SOURCE.x special targets with short
  163. X     search lists and leave .SOURCE as short as possible.  The
  164. X     search algorithm has the following useful side effect.  When
  165. X     a target having the .LIBMEMBER (library member) attribute is
  166. X     searched for, it is first searched for as an ordinary file.
  167. X     When a number of library members require updating it is
  168. X     desirable to compile all of them first and to update the
  169. X     library at the end in a single operation.  If one of the
  170. X     members does not compile and ddmmaakkee stops, then the user may
  171. X     fix the error and make again.  ddmmaakkee will not remake any of
  172. X     the targets whose object files have already been generated
  173. X     as long as none of their prerequisite files have been modi-
  174. X     fied as a result of the fix.
  175. X
  176. X     When defining .SOURCE and .SOURCE.x targets the construct
  177. X
  178. X          .SOURCE :
  179. X          .SOURCE : fred gery
  180. X
  181. X     is equivalent to
  182. X
  183. X          .SOURCE :- fred gery
  184. X
  185. X
  186. X
  187. X
  188. X
  189. XVersion 3.50                    UW                             27
  190. X
  191. X
  192. X
  193. X
  194. XDMAKE(p)               Unsupported Software               DMAKE(p)
  195. X
  196. X
  197. X
  198. X     ddmmaakkee correctly handles the UNIX Make variable VPATH.  By
  199. X     definition VPATH contains a list of ':' separated direc-
  200. X     tories to search when looking for a target.  ddmmaakkee maps
  201. X     VPATH to the following special rule:
  202. X
  203. X          .SOURCE :^ $(VPATH:s/:/ /)
  204. X
  205. X     Which takes the value of VPATH and sets .SOURCE to the same
  206. X     set of directories as specified in VPATH.
  207. X
  208. XPPEERRCCEENNTT((%%)) RRUULLEESS AANNDD MMAAKKIINNGG IINNFFEERREENNCCEESS
  209. X     When ddmmaakkee makes a target it's set of prerequisites (if any)
  210. X     must exist and the target must have a recipe which ddmmaakkee can
  211. X     use to make it.  If the makefile does not specify an expli-
  212. X     cit recipe for the target then ddmmaakkee uses special rules to
  213. X     try to infer a recipe which it can use to make the target.
  214. X     Previous versions of Make perform this task by using rules
  215. X     that are defined by targets of the form .<suffix>.<suffix>
  216. X     and by using the .SUFFIXES list of suffixes.  The exact
  217. X     workings of this mechanism were sometimes difficult to
  218. X     understand and often limiting in their usefulness.  Instead,
  219. X     ddmmaakkee supports the concept of _%_-_m_e_t_a rules. The syntax and
  220. X     semantics of these rules differ from standard rule lines as
  221. X     follows:
  222. X
  223. X          _<_%_-_t_a_r_g_e_t_> [_<_a_t_t_r_i_b_u_t_e_s_>] _<_r_u_l_e_o_p_> [_<_%_-_p_r_e_r_e_q_u_i_s_i_t_e_s_>] [;_<_r_e_c_i_p_e_>]
  224. X
  225. X     where _%_-_t_a_r_g_e_t is a target containing exactly a single `%'
  226. X     sign, _a_t_t_r_i_b_u_t_e_s is a list (possibly empty) of attributes,
  227. X     _r_u_l_e_o_p is the standard set of rule operators, _%_-_p_r_e_r_e_-
  228. X     _q_u_i_s_i_t_e_s , if present, is a list of prerequisites containing
  229. X     zero or more `%' signs, and _r_e_c_i_p_e_, if present, is the first
  230. X     line of the recipe.
  231. X
  232. X     The _%_-_t_a_r_g_e_t defines a pattern against which a target whose
  233. X     recipe is being inferred gets matched.  The pattern match
  234. X     goes as follows:  all chars are matched exactly from left to
  235. X     right up to but not including the % sign in the pattern, %
  236. X     then matches the longest string from the actual target name
  237. X     not ending in the suffix given after the % sign in the pat-
  238. X     tern.  Consider the following examples:
  239. X
  240. X          %.c       matches fred.c but not joe.c.Z
  241. X          dir/%.c   matches dir/fred.c but not dd/fred.c
  242. X          fred/%    matches fred/joe.c but not f/joe.c
  243. X          %         matches anything
  244. X
  245. X     In each case the part of the target name that matched the %
  246. X     sign is retained and is substituted for any % signs in the
  247. X     prerequisite list of the %-meta rule when the rule is
  248. X     selected during inference and ddmmaakkee constructs the depen-
  249. X     dency specified by the %-meta rule for the actual target.
  250. X
  251. X
  252. X
  253. XVersion 3.50                    UW                             28
  254. X
  255. X
  256. X
  257. X
  258. XDMAKE(p)               Unsupported Software               DMAKE(p)
  259. X
  260. X
  261. X
  262. X     As an example the following %-meta rules describe the fol-
  263. X     lowing:
  264. X
  265. X          %.c : %.y ; recipe...
  266. X
  267. X     describes how to make any file ending in .c if a correspond-
  268. X     ing file ending in .y can be found.
  269. X
  270. X          foo%.o : fee%.k ; recipe...
  271. X
  272. X     is used to describe how to make fooxxxx.o from feexxxx.k.
  273. X
  274. X          %.a :; recipe...
  275. X
  276. X     describes how to make a file whose suffix is .a without
  277. X     inferring any prerequisites.
  278. X
  279. X          %.c : %.y yaccsrc/%.y ; recipe...
  280. X
  281. X     is a short form for the construct:
  282. X
  283. X          %.c : %.y ; recipe...
  284. X          %.c : yaccsrc/%.y ; recipe...
  285. X
  286. X     ie. It is possible to specify the same recipe for two
  287. X     %-rules by giving more than one prerequisite in the prere-
  288. X     quisite list.  A more interesting example is:
  289. X
  290. X          % : RCS/%,v ; co $@
  291. X
  292. X     which describes how to take any target and check it out of
  293. X     the RCS directory if the corresponding file exists in the
  294. X     RCS directory.  The equivalent SCCS rule would be:
  295. X
  296. X          % : s.% ; get $@
  297. X
  298. X
  299. X     The previous RCS example defines an infinite rule, because
  300. X     it says how to make _a_n_y_t_h_i_n_g from RCS/%,v, and _a_n_y_t_h_i_n_g also
  301. X     includes RCS/fred.c,v.  To limit the size of the graph that
  302. X     results from such rules ddmmaakkee uses the macro variable PREP
  303. X     (stands for % repetition).  By default the value of this
  304. X     variable is 0, which says that no repetitions of a %-rule
  305. X     are to be generated.  If it is set to something greater than
  306. X     0, then that many repetitions of any infinite %-rule are
  307. X     allowed.  If in the above example PREP was set to 1, then
  308. X     ddmmaakkee would generate the dependency graph:
  309. X
  310. X          % --> RCS/%,v --> RCS/RCS/%,v,v
  311. X
  312. X     Where each link is assigned the same recipe as the first
  313. X     link.  PREP should be used only in special cases, since it
  314. X
  315. X
  316. X
  317. XVersion 3.50                    UW                             29
  318. X
  319. X
  320. X
  321. X
  322. XDMAKE(p)               Unsupported Software               DMAKE(p)
  323. X
  324. X
  325. X
  326. X     may result in a large increase in the number of possible
  327. X     prerequisites tested.
  328. X
  329. X     ddmmaakkee supports dynamic prerequisite generation for prere-
  330. X     quisites of %-meta rules.  This is best illustrated by an
  331. X     example.  The RCS rule shown above can infer how to check
  332. X     out a file from a corresponding RCS file only if the target
  333. X     is a simple file name with no directory information.  That
  334. X     is, the above rule can infer how to find _R_C_S_/_f_r_e_d_._c_,_v from
  335. X     the target _f_r_e_d_._c, but cannot infer how to find
  336. X     _s_r_c_d_i_r_/_R_C_S_/_f_r_e_d_._c_,_v from _s_r_c_d_i_r_/_f_r_e_d_._c because the above
  337. X     rule will cause ddmmaakkee to look for RCS/srcdir/fred.c,v; which
  338. X     does not exist (assume that srcdir has it's own RCS direc-
  339. X     tory as is the common case).
  340. X
  341. X     A more versatile formulation of the above RCS check out rule
  342. X     is the following:
  343. X
  344. X          % :  $$(@:d)RCS/$$(@:f),v : co $@
  345. X
  346. X     This rule uses the dynamic macro $@ to specify the prere-
  347. X     quisite to try to infer.  During inference of this rule the
  348. X     macro $@ is set to the value of the target of the %-meta
  349. X     rule and the appropriate prerequisite is generated by
  350. X     extracting the directory portion of the target name (if
  351. X     any), appending the string _R_C_S_/ to it, and appending the
  352. X     target file name with a trailing _,_v attached to the previous
  353. X     result.
  354. X
  355. X     ddmmaakkee can also infer indirect prerequisites.  An inferred
  356. X     target can have a list of prerequisites added that will not
  357. X     show up in the value of $< but will show up in the value of
  358. X     $? and $&.  Indirect prerequisites are specified in an
  359. X     inference rule by quoting the prerequisite with single
  360. X     quotes.  For example, if you had the explicit dependency:
  361. X
  362. X          fred.o : fred.c ; rule to make fred.o
  363. X          fred.o : local.h
  364. X
  365. X     then this can be infered for fred.o from the following
  366. X     inference rule:
  367. X
  368. X          %.o : %.c 'local.h' ; rule to make a .o from a .c
  369. X
  370. X     You may infer indirect prerequisites that are a function of
  371. X     the value of '%' in the current rule.  The meta-rule:
  372. X
  373. X          %.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
  374. X
  375. X     infers an indirect prerequisite found in the INC directory
  376. X     whose name is the same as the expansion of $(INC), and the
  377. X     prerequisite name depends on the base name of the current
  378. X
  379. X
  380. X
  381. XVersion 3.50                    UW                             30
  382. X
  383. X
  384. X
  385. X
  386. XDMAKE(p)               Unsupported Software               DMAKE(p)
  387. X
  388. X
  389. X
  390. X     target.  The set of indirect prerequisites is attached to
  391. X     the meta rule in which they are specified and are inferred
  392. X     only if the rule is used to infer a recipe for a target.
  393. X     They do not play an active role in driving the inference
  394. X     algorithm.  The construct:
  395. X
  396. X          %.o : %.c %.f 'local.h'; recipe
  397. X
  398. X     is equivalent to:
  399. X
  400. X          %.o : %.c 'local.h' : recipe
  401. X          %.o : %.f 'local.h' : recipe
  402. X
  403. X
  404. X     If any of the attributes .SETDIR, .EPILOG, .PROLOG, .SILENT,
  405. X     .PRECIOUS, .LIBRARY, and .IGNORE are given for a %-rule then
  406. X     when that rule is bound to a target as the result of an
  407. X     inference, the target's set of attributes is augmented by
  408. X     the attributes from the above set that are specified in the
  409. X     bound %-rule.  Other attributes specified for %-meta rules
  410. X     are not inherited by the target.  The .SETDIR attribute is
  411. X     treated in a special way.  If the target already had a .SET-
  412. X     DIR attribute set and the bound %-rule also specified a
  413. X     .SETDIR attribute then the one originally specified with the
  414. X     target prevails.  During inference any .SETDIR attributes
  415. X     for the inferred prerequisite are honored.  The directories
  416. X     must exist for a %-meta rule to be selected as a possible
  417. X     inference path.  If the directories do not exist no error
  418. X     message is issued, instead the corresponding path in the
  419. X     inference graph is simply rejected.
  420. X
  421. X     ddmmaakkee also supports the old format special target
  422. X     .<suffix>.<suffix> by identifying any rules of this form and
  423. X     mapping them to the appropriate %-rule.  So for example if
  424. X     an old makefile contains the construct:
  425. X
  426. X          .c.o :; cc -c $< -o $@
  427. X
  428. X     ddmmaakkee maps this into the following %-rule:
  429. X
  430. X          %.o : %.c; cc -c $< -o $@
  431. X
  432. X     Furthermore, ddmmaakkee understands several SYSV AUGMAKE special
  433. X     targets and maps them into corresponding %-meta rules.
  434. X     These transformation must be enabled by providing the -A
  435. X     flag on the command line or by setting the value of AUGMAKE
  436. X     to non NULL.  The construct
  437. X
  438. X          .suff :; recipe
  439. X
  440. X     gets mapped into:
  441. X
  442. X
  443. X
  444. X
  445. XVersion 3.50                    UW                             31
  446. X
  447. X
  448. X
  449. X
  450. XDMAKE(p)               Unsupported Software               DMAKE(p)
  451. X
  452. X
  453. X
  454. X          % : %.suff; recipe
  455. X
  456. X     and the construct
  457. X
  458. X          .c~.o :; recipe
  459. X
  460. X     gets mapped into:
  461. X
  462. X          %.o : s.%.c ; recipe
  463. X
  464. X     In general, a special target of the form .<str>~ is replaced
  465. X     by the %-rule construct s.%.<str>, thereby providing support
  466. X     for the syntax used by SYSV AUGMAKE for providing SCCS sup-
  467. X     port.  When enabled, these mappings allow to processing of
  468. X     existing SYSV makefiles without modifications.
  469. X
  470. X     ddmmaakkee bases all of it's inferences on the inference graph
  471. X     constructed from the %-rules defined in the makefile.  It
  472. X     knows exactly which targets can be made from which prere-
  473. X     quisites by making queries on the inference graph.  For this
  474. X     reason .SUFFIXES is not needed and is completely ignored.
  475. X
  476. X     For a %-meta rule to be inferred as the rule whose recipe
  477. X     will be used to make a target, the target's name must match
  478. X     the %-target pattern, and any inferred %-prerequisite must
  479. X     already exist or have an explicit recipe so that the prere-
  480. X     quisite can be made.  Without _t_r_a_n_s_i_t_i_v_e _c_l_o_s_u_r_e on the
  481. X     inference graph the above rule describes precisely when an
  482. X     inference match terminates the search.  If transitive clo-
  483. X     sure is enabled (the usual case), and a prerequisite does
  484. X     not exist or cannot be made, then ddmmaakkee invokes the infer-
  485. X     ence algorithm recursively on the prerequisite to see if
  486. X     there is some way the prerequisite can be manufactured.  For
  487. X     if the prerequisite can be made then the current target can
  488. X     also be made using the current %-meta rule.  This means that
  489. X     there is no longer a need to give a rule for making a .o
  490. X     from a .y if you have already given a rule for making a .o
  491. X     from a .c and a .c from a .y.  In such cases ddmmaakkee can infer
  492. X     how to make the .o from the .y via the intermediary .c and
  493. X     will remove the .c when the .o is made.  Transitive closure
  494. X     can be disabled by giving the -T switch on the command line.
  495. X
  496. X     A word of caution.  ddmmaakkee bases its transitive closure on
  497. X     the %-meta rule targets.  When it performs transitive clo-
  498. X     sure it infers how to make a target from a prerequisite by
  499. X     performing a pattern match as if the potential prerequisite
  500. X     were a new target.  The set of rules:
  501. X
  502. X          %.o : %.c :; rule for making .o from .c
  503. X          %.c : %.y :; rule for making .c from .y
  504. X          % : RCS/%,v :; check out of RCS file
  505. X
  506. X
  507. X
  508. X
  509. XVersion 3.50                    UW                             32
  510. X
  511. X
  512. X
  513. X
  514. XDMAKE(p)               Unsupported Software               DMAKE(p)
  515. X
  516. X
  517. X
  518. X     will, by performing transitive closure, allow ddmmaakkee to infer
  519. X     how to make a .o from a .y using a .c as an intermediate
  520. X     temporary file.  Additionally it will be able to infer how
  521. X     to make a .y from an RCS file, as long as that RCS file is
  522. X     in the RCS directory and has a name which ends in .y,v.  The
  523. X     transitivity computation is performed dynamically for each
  524. X     target that does not have a recipe.  This has potential to
  525. X     be very slow if the %-meta rules are not carefully speci-
  526. X     fied.  The .NOINFER attribute is used to mark a %-meta node
  527. X     as being a final target during inference.  Any node with
  528. X     this attribute set will not be used for subsequent infer-
  529. X     ences.  As an example the node RCS/%,v is marked as a final
  530. X     node since we know that if the RCS file does not exist there
  531. X     likely is no other way to make it.  Thus the standard
  532. X     startup makefile contains the entry:
  533. X          .NOINFER : RCS/%,v
  534. X     Thereby indicating that the RCS file is the end of the
  535. X     inference chain.
  536. X
  537. X     ddmmaakkee tries to remove intermediate files resulting from
  538. X     transitive closure if the file is not marked as being PRE-
  539. X     CIOUS, or the --uu flag was not given on the command line, and
  540. X     if the inferred intermediate did not previously exist.
  541. X     Intermediate targets that existed prior to being made are
  542. X     never removed.  This is in keeping with the philosophy that
  543. X     ddmmaakkee should never remove things from the file system that
  544. X     it did not add.  If the special target .REMOVE is defined
  545. X     and has a recipe then ddmmaakkee constructs a list of the inter-
  546. X     mediate files to be removed and makes them prerequisites of
  547. X     .REMOVE.  It then makes .REMOVE thereby removing the prere-
  548. X     quisites if the recipe of .REMOVE says to.  Typically
  549. X     .REMOVE is defined in the startup file as:
  550. X
  551. X          ".REMOVE :; $(RM) $<".
  552. X
  553. XMMAAKKIINNGG TTAARRGGEETTSS
  554. X     In order to update a target ddmmaakkee must execute a recipe.
  555. X     When a recipe needs to be executed it is first expanded so
  556. X     that any macros in the recipe text are expanded, and it is
  557. X     then either executed directly or passed to a shell.  ddmmaakkee
  558. X     supports two types of recipes.  The regular recipes and
  559. X     group recipes.
  560. X
  561. X     When a regular recipe is invoked ddmmaakkee executes each line of
  562. X     the recipe separately using a new copy of a shell if a shell
  563. X     is required.  Thus effects of commands do not generally per-
  564. X     sist across recipe lines.  (e.g. cd requests in a recipe
  565. X     line do not carry over to the next recipe line) The decision
  566. X     on whether a shell is required to execute a command is based
  567. X     on the value of the macro SHELLMETAS.  If any character in
  568. X     the value of SHELLMETAS is found in the expanded recipe
  569. X     text-line then the command is executed using a shell,
  570. X
  571. X
  572. X
  573. XVersion 3.50                    UW                             33
  574. X
  575. X
  576. X
  577. X
  578. XDMAKE(p)               Unsupported Software               DMAKE(p)
  579. X
  580. X
  581. X
  582. X     otherwise the command is executed directly.  The shell that
  583. X     is used for execution is given by the value of the macro
  584. X     SHELL.  The flags that are passed to the shell are given by
  585. X     the value of SHELLFLAGS.  Thus ddmmaakkee constructs the command
  586. X     line:
  587. X
  588. X          $(SHELL) $(SHELLFLAGS) $(expanded_recipe_command)
  589. X
  590. X     Normally ddmmaakkee writes the command line that it is about to
  591. X     invoke to standard output.  If the .SILENT attribute is set
  592. X     for the target or for the recipe line (via @), then the
  593. X     recipe line is not echoed.
  594. X
  595. X     Group recipe processing is similar to that of regular
  596. X     recipes, except that a shell is always invoked.  The shell
  597. X     that is invoked is given by the value of the macro GROUP-
  598. X     SHELL, and its flags are taken from the value of the macro
  599. X     GROUPFLAGS.  If a target has the .PROLOG attribute set then
  600. X     ddmmaakkee prepends to the shell script the recipe associated
  601. X     with the special target .GROUPPROLOG, and if the attribute
  602. X     .EPILOG is set as well, then the recipe associated with the
  603. X     special target .GROUPEPILOG is appended to the script file.
  604. X     This facility can be used to always prepend a common header
  605. X     and common trailer to group recipes.  Group recipes are
  606. X     echoed to standard output just like standard recipes, but
  607. X     are enclosed by lines beginning with [ and ].
  608. X
  609. XMMAAKKIINNGG LLIIBBRRAARRIIEESS
  610. X     Libraries are easy to maintain using ddmmaakkee.  A library is a
  611. X     file containing a collection of object files.  Thus to make
  612. X     a library you simply specify it as a target with the
  613. X     .LIBRARY attribute set and specify its list of prere-
  614. X     quisites.  The prerequisites should be the object members
  615. X     that are to go into the library.  When ddmmaakkee makes the
  616. X     library target it uses the .LIBRARY attribute to pass to the
  617. X     prerequisites the .LIBMEMBER attribute and the name of the
  618. X     library.  This enables the file binding mechanism to look
  619. X     for the member in the library if an appropriate object file
  620. X     cannot be found. A small example best illustrates this.
  621. X
  622. X          mylib.a .LIBRARY : mem1.o mem2.o mem3.o
  623. X               rules for making library...
  624. X               # remember to remove .o's when lib is made
  625. X
  626. X          # equivalent to:  '%.o : %.c ; ...'
  627. X          .c.o :; rules for making .o from .c say
  628. X
  629. X     ddmmaakkee will use the .c.o rule for making the library members
  630. X     if appropriate .c files can be found using the search rules.
  631. X     NOTE:  this is not specific in any way to C programs, they
  632. X     are simply used as an example.
  633. X
  634. X
  635. X
  636. X
  637. XVersion 3.50                    UW                             34
  638. X
  639. X
  640. X
  641. X
  642. XDMAKE(p)               Unsupported Software               DMAKE(p)
  643. X
  644. X
  645. X
  646. X     ddmmaakkee tries to handle the old library construct format in a
  647. X     sensible way.  The construct _l_i_b_(_m_e_m_b_e_r_._o_) is separated and
  648. X     the _l_i_b portion is declared as a library target.  The new
  649. X     target is defined with the .LIBRARY attribute set and the
  650. X     _m_e_m_b_e_r_._o portion of the construct is declared as a prere-
  651. X     quisite of the lib target.  If the construct _l_i_b_(_m_e_m_b_e_r_._o_)
  652. X     appears as a prerequisite of a target in the makefile, that
  653. X     target has the new name of the lib assigned as it's prere-
  654. X     quisite.  Thus the following example:
  655. X
  656. X          a.out : ml.a(a.o) ml.a(b.o); $(CC) -o $@  $<
  657. X
  658. X          .c.o :; $(CC) -c $(CFLAGS) -o $@  $<
  659. X          %.a:
  660. X               ar rv $@ $<
  661. X               ranlib $@
  662. X               rm -rf $<
  663. X
  664. X     constructs the following dependency graph.
  665. X
  666. X          a.out : ml.a; $(CC) -o $@  $<
  667. X          ml.a .LIBRARY : a.o b.o
  668. X
  669. X          %.o : %.c ; $(CC) -c $(CFLAGS) -o $@  $<
  670. X          %.a :
  671. X               ar rv $@ $<
  672. X               ranlib $@
  673. X               rm -rf $<
  674. X
  675. X     and making a.out then works as expected.
  676. X
  677. X     The same thing happens for any target of the form
  678. X     _l_i_b_(_(_e_n_t_r_y_)_).  These targets have an additional feature in
  679. X     that the _e_n_t_r_y target has the .SYMBOL attribute set automat-
  680. X     ically.
  681. X
  682. X     NOTE:  If the notion of entry points is supported by the
  683. X     archive and by ddmmaakkee (currently not the case) then ddmmaakkee
  684. X     will search the archive for the entry point and return not
  685. X     only the modification time of the member which defines the
  686. X     entry but also the name of the member file.  This name will
  687. X     then replace _e_n_t_r_y and will be used for making the member
  688. X     file.  Once bound to an archive member the .SYMBOL attribute
  689. X     is removed from the target.  This feature is presently dis-
  690. X     abled as there is little standardization among archive for-
  691. X     mats, and we have yet to find a makefile utilizing this
  692. X     feature (possibly due to the fact that it is unimplemented
  693. X     in most versions of UNIX Make).
  694. X
  695. XMMUULLTTII PPRROOCCEESSSSIINNGG
  696. X     If the architecture supports it then ddmmaakkee is capable of
  697. X     making a target's prerequisites in parallel.  ddmmaakkee will
  698. X
  699. X
  700. X
  701. XVersion 3.50                    UW                             35
  702. X
  703. X
  704. X
  705. X
  706. XDMAKE(p)               Unsupported Software               DMAKE(p)
  707. X
  708. X
  709. X
  710. X     make as much in parallel as it can and use a number of child
  711. X     processes up to the maximum specified by MAXPROCESS or by
  712. X     the value supplied to the -P command line flag.  A parallel
  713. X     make is enabled by setting the value of MAXPROCESS (either
  714. X     directly or via -P option) to a value which is > 1.  ddmmaakkee
  715. X     guarantees that all dependencies as specified in the
  716. X     makefile are honored.  A target will not be made until all
  717. X     of its prerequisites have been made.  If a parallel make is
  718. X     being performed then the following restrictions on parallel-
  719. X     ism are enforced.
  720. X
  721. X          1.   Individual recipe lines in a non-group recipe are
  722. X               performed sequentially in the order in which they
  723. X               are specified within the makefile and in parallel
  724. X               with the recipes of other targets.
  725. X
  726. X          2.   If a target contains multiple recipe definitions
  727. X               (cf. :: rules) then these are performed sequen-
  728. X               tially in the order in which the :: rules are
  729. X               specified within the makefile and in parallel with
  730. X               the recipes of other targets.
  731. X
  732. X          3.   If a target rule contains the `!' modifier, then
  733. X               the recipe is performed sequentially for the list
  734. X               of outdated prerequisites and in parallel with the
  735. X               recipes of other targets.
  736. X
  737. X          4.   If a target has the .SEQUENTIAL attribute set then
  738. X               all of its prerequisites are made sequentially
  739. X               relative to one another (as if MAXPROCESS=1), but
  740. X               in parallel with other targets in the makefile.
  741. X
  742. X     Note:  If you specify a parallel make then the order of tar-
  743. X     get update and the order in which the associated recipes are
  744. X     invoked will not correspond to that displayed by the -n
  745. X     flag.
  746. X
  747. XCCOONNDDIITTIIOONNAALLSS
  748. X     ddmmaakkee supports a makefile construct called a _c_o_n_d_i_t_i_o_n_a_l.
  749. X     It allows the user to conditionally select portions of
  750. X     makefile text for input processing and to discard other por-
  751. X     tions.  This becomes useful for writing makefiles that are
  752. X     intended to function for more than one target host and
  753. X     environment.  The conditional expression is specified as
  754. X     follows:
  755. X
  756. X          .IF  _e_x_p_r_e_s_s_i_o_n
  757. X             ... if text ...
  758. X          .ELSE
  759. X             ... else text ...
  760. X          .END
  761. X
  762. X
  763. X
  764. X
  765. XVersion 3.50                    UW                             36
  766. X
  767. X
  768. X
  769. X
  770. XDMAKE(p)               Unsupported Software               DMAKE(p)
  771. X
  772. X
  773. X
  774. X     The .ELSE portion is optional, and the conditionals may be
  775. X     nested (ie.  the text may contain another conditional).
  776. X     .IF, .ELSE, and .END may appear anywhere in the makefile,
  777. X     but a single conditional expression may not span multiple
  778. X     makefiles.
  779. X
  780. X     _e_x_p_r_e_s_s_i_o_n can be one of the following three forms:
  781. X
  782. X          <text> | <text> == <text> | <text> != <text>
  783. X
  784. X     where _t_e_x_t is either text or a macro expression.  In any
  785. X     case, before the comparison is made, the expression is
  786. X     expanded.  The text portions are then selected and compared.
  787. X     White space at the start and end of the text portion is dis-
  788. X     carded before the comparison.  This means that a macro that
  789. X     evaluates to nothing but white space is considered a NULL
  790. X     value for the purpose of the comparison.  In the first case
  791. X     the expression evaluates TRUE if the text is not NULL other-
  792. X     wise it evaluates FALSE.  The remaining two cases both
  793. X     evaluate the expression on the basis of a string comparison.
  794. X     If a macro expression needs to be equated to a NULL string
  795. X     then compare it to the value of the macro $(NULL).
  796. X
  797. XEEXXAAMMPPLLEESS
  798. X          # A simple example showing how to use make
  799. X          #
  800. X          prgm : a.o b.o
  801. X               cc a.o b.o -o prgm
  802. X          a.o : a.c g.h
  803. X               cc a.c -o $@
  804. X          b.o : b.c g.h
  805. X               cc b.c -o $@
  806. X
  807. X     In the previous example prgm is remade only if a.o and/or
  808. X     b.o is out of date with respect to prgm.  These dependencies
  809. X     can be stated more concisely by using the inference rules
  810. X     defined in the standard startup file.  The default rule for
  811. X     making .o's from .c's looks something like this:
  812. X
  813. X          %.o : %.c; cc -c $(CFLAGS) -o $@ $<
  814. X
  815. X     Since there exists a rule (defined in the startup file) for
  816. X     making .o's from .c's ddmmaakkee will use that rule for manufac-
  817. X     turing a .o from a .c and we can specify our dependencies
  818. X     more concisely.
  819. X
  820. X          prgm : a.o b.o
  821. X               cc -o prgm $<
  822. X          a.o b.o : g.h
  823. X
  824. X     A more general way to say the above using the new macro
  825. X     expansions would be:
  826. X
  827. X
  828. X
  829. XVersion 3.50                    UW                             37
  830. X
  831. X
  832. X
  833. X
  834. XDMAKE(p)               Unsupported Software               DMAKE(p)
  835. X
  836. X
  837. X
  838. X          SRC = a b
  839. X          OBJ = {$(SRC)}.o
  840. X
  841. X          prgm : $(OBJ)
  842. X               cc -o $@ $<
  843. X
  844. X          $(OBJ) : g.h
  845. X
  846. X     If we want to keep the objects in a separate directory,
  847. X     called objdir, then we would write something like this.
  848. X
  849. X          SRC = a b
  850. X          OBJ = {$(SRC)}.o
  851. X
  852. X          prgm : $(OBJ)
  853. X               cc $< -o $@
  854. X
  855. X          $(OBJ) : g.h
  856. X          %.o : %.c
  857. X               $(CC) -c $(CFLAGS) -o $(@:f) $<
  858. X               mv $(@:f) objdir
  859. X
  860. X          .SOURCE.o : objdir       # tell make to look here for .o's
  861. X
  862. X     An example of building library members would go something
  863. X     like this: (NOTE:  The same rules as above will be used to
  864. X     produce .o's from .c's)
  865. X
  866. X          SRC  = a b
  867. X          LIB  = lib
  868. X          LIBm = { $(SRC) }.o
  869. X
  870. X          prgm: $(LIB)
  871. X               cc -o $@ $(LIB)
  872. X
  873. X          $(LIB) .LIBRARY : $(LIBm)
  874. X               ar rv $@ $<
  875. X               rm $<
  876. X
  877. X     Finally, suppose that each of the source files in the previ-
  878. X     ous example had the `:' character in their target name.
  879. X     Then we would write the above example as:
  880. X
  881. X          SRC  = f:a f:b
  882. X          LIB  = lib
  883. X          LIBm = "{ $(SRC) }.o"         # put quotes around each token
  884. X
  885. X          prgm: $(LIB)
  886. X               cc -o $@ $(LIB)
  887. X
  888. X          $(LIB) .LIBRARY : $(LIBm)
  889. X               ar rv $@ $<
  890. X
  891. X
  892. X
  893. XVersion 3.50                    UW                             38
  894. X
  895. X
  896. X
  897. X
  898. XDMAKE(p)               Unsupported Software               DMAKE(p)
  899. X
  900. X
  901. X
  902. X               rm $<
  903. X
  904. XCCOOMMPPAATTIIBBIILLIITTYY
  905. X     There are two notable differences between ddmmaakkee and the
  906. X     standard version of BSD UNIX 4.2/4.3 Make.
  907. X
  908. X          1. BSD UNIX 4.2/4.3 Make supports wild card filename
  909. X             expansion for prerequisite names.  Thus if a direc-
  910. X             tory contains a.h, b.h and c.h, then a line like
  911. X
  912. X                  target: *.h
  913. X
  914. X             will cause UNIX make to expand the *.h into "a.h b.h
  915. X             c.h".  ddmmaakkee does not support this type of filename
  916. X             expansion.
  917. X
  918. X          2. Unlike UNIX make, touching a library member causes
  919. X             ddmmaakkee to search the library for the member name and
  920. X             to update the library time stamp.  This is only
  921. X             implemented in the UNIX version.  MSDOS and other
  922. X             versions may not have librarians that keep file time
  923. X             stamps, as a result ddmmaakkee touches the library file
  924. X             itself, and prints a warning.
  925. X
  926. X     ddmmaakkee is not compatible with GNU Make.  In particular it
  927. X     does not understand GNU Make's macro expansions that query
  928. X     the file system.
  929. X
  930. X     ddmmaakkee is fully compatible with SYSV AUGMAKE, and supports
  931. X     the following AUGMAKE features:
  932. X
  933. X          1. The word iinncclluuddee appearing at the start of a line
  934. X             can be used instead of the ".INCLUDE :" construct
  935. X             understood by ddmmaakkee.
  936. X
  937. X          2. The macro modifier expression $(macro:str=sub) is
  938. X             understood and is equivalent to the expression
  939. X             $(macro:s/str/sub), with the restriction that str
  940. X             must match the following regular expression:
  941. X
  942. X                  str[ |\t][ |\t]*
  943. X
  944. X             (ie. str only matches at the end of a token where
  945. X             str is a suffix and is terminated by a space, a tab,
  946. X             or end of line)
  947. X
  948. X          3. The macro % is defined to be $@ (ie. $% expands to
  949. X             the same value as $@).
  950. X
  951. X          4. The AUGMAKE notion of libraries is handled
  952. X             correctly.
  953. X
  954. X
  955. X
  956. X
  957. XVersion 3.50                    UW                             39
  958. X
  959. X
  960. X
  961. X
  962. XDMAKE(p)               Unsupported Software               DMAKE(p)
  963. X
  964. X
  965. X
  966. X          5. When defining special targets for the inference
  967. X             rules and the AUGMAKE special target mapping is
  968. X             enabled then the special target .X is equivalent to
  969. X             the %-rule "% : %.X".
  970. X
  971. XLLIIMMIITTSS
  972. X     In some environments the length of an argument string is
  973. X     restricted.  (e.g. MSDOS command line arguments cannot be
  974. X     longer than 128 bytes if you are using the standard
  975. X     command.com command interpreter as your shell, ddmmaakkee text
  976. X     diversions may help in these situations.)
  977. X
  978. XPPOORRTTAABBIILLIITTYY
  979. X     To write makefiles that can be moved from one environment to
  980. X     another requires some forethought.  In particular you must
  981. X     define as macros all those things that may be different in
  982. X     the new environment.  ddmmaakkee has two facilities that help to
  983. X     support writing portable makefiles, recursive macros and
  984. X     conditional expressions.  The recursive macros, allow one to
  985. X     define environment configurations that allow different
  986. X     environments for similar types of operating systems.  For
  987. X     example the same make script can be used for SYSV and BSD
  988. X     but with different macro definitions.
  989. X
  990. X     To write a makefile that is portable between UNIX and MSDOS
  991. X     requires both features since in almost all cases you will
  992. X     need to define new recipes for making targets.  The recipes
  993. X     will probably be quite different since the capabilities of
  994. X     the tools on each machine are different.  Different macros
  995. SHAR_EOF
  996. echo "End of part 11"
  997. echo "File man/dmake.p is continued in part 12"
  998. echo "12" > s2_seq_.tmp
  999. exit 0
  1000.  
  1001.