home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume27 / dmake / part16 < prev    next >
Encoding:
Text File  |  1992-01-29  |  40.0 KB  |  1,144 lines

  1. Newsgroups: comp.sources.misc
  2. From: dvadura@plg.waterloo.edu (Dennis Vadura)
  3. Subject:  v27i117:  dmake - dmake Version 3.8, Part16/41
  4. Message-ID: <1992Jan28.214023.18895@sparky.imd.sterling.com>
  5. X-Md4-Signature: e3f80b504f43bb68bdf03c7d50bed860
  6. Date: Tue, 28 Jan 1992 21:40:23 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: dvadura@plg.waterloo.edu (Dennis Vadura)
  10. Posting-number: Volume 27, Issue 117
  11. Archive-name: dmake/part16
  12. Environment: Atari-ST, Coherent, Mac, MSDOS, OS/2, UNIX
  13. Supersedes: dmake: Volume 19, Issue 22-58
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. # this is dmake.shar.16 (part 16 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" != 16; 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
  35. X     Which takes the value of VPATH and sets .SOURCE to the same
  36. X     set of directories as specified in VPATH.
  37. X
  38. PERCENT(%) RULES AND MAKING INFERENCES
  39. X     When dmake makes a target, the target's set of prerequisites
  40. X     (if any) must exist and the target must have a recipe which
  41. X     dmake can use to make it.  If the makefile does not specify
  42. X     an explicit recipe for the target then dmake uses special
  43. X     rules to try to infer a recipe which it can use to make the
  44. X     target.  Previous versions of Make perform this task by
  45. X     using rules that are defined by targets of the form
  46. X     .<suffix>.<suffix> and by using the .SUFFIXES list of suf-
  47. X     fixes.  The exact workings of this mechanism were sometimes
  48. X     difficult to understand and often limiting in their useful-
  49. X     ness.  Instead, dmake supports the concept of %-meta rules.
  50. X     The syntax and semantics of these rules differ from standard
  51. X     rule lines as follows:
  52. X
  53. X          <%-target> [<attributes>] <ruleop> [<%-prerequisites>] [;<recipe>]
  54. X
  55. X     where %-target is a target containing exactly a single `%'
  56. X
  57. X
  58. X
  59. Version 3.70                    UW                             34
  60. X
  61. X
  62. X
  63. X
  64. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  65. X
  66. X
  67. X
  68. X     sign, attributes is a list (possibly empty) of attributes,
  69. X     ruleop is the standard set of rule operators, %-prere-
  70. X     quisites , if present, is a list of prerequisites containing
  71. X     zero or more `%' signs, and recipe, if present, is the first
  72. X     line of the recipe.
  73. X
  74. X     The %-target defines a pattern against which a target whose
  75. X     recipe is being inferred gets matched.  The pattern match
  76. X     goes as follows:  all chars are matched exactly from left to
  77. X     right up to but not including the % sign in the pattern, %
  78. X     then matches the longest string from the actual target name
  79. X     not ending in the suffix given after the % sign in the pat-
  80. X     tern.  Consider the following examples:
  81. X
  82. X          %.c       matches fred.c but not joe.c.Z
  83. X          dir/%.c   matches dir/fred.c but not dd/fred.c
  84. X          fred/%    matches fred/joe.c but not f/joe.c
  85. X          %         matches anything
  86. X
  87. X     In each case the part of the target name that matched the %
  88. X     sign is retained and is substituted for any % signs in the
  89. X     prerequisite list of the %-meta rule when the rule is
  90. X     selected during inference and dmake constructs the new
  91. X     dependency.  As an example the following %-meta rules
  92. X     describe the following:
  93. X
  94. X          %.c : %.y ; recipe...
  95. X
  96. X     describes how to make any file ending in .c if a correspond-
  97. X     ing file ending in .y can be found.
  98. X
  99. X          foo%.o : fee%.k ; recipe...
  100. X
  101. X     is used to describe how to make fooxxxx.o from feexxxx.k.
  102. X
  103. X          %.a :; recipe...
  104. X
  105. X     describes how to make a file whose suffix is .a without
  106. X     inferring any prerequisites.
  107. X
  108. X          %.c : %.y yaccsrc/%.y ; recipe...
  109. X
  110. X     is a short form for the construct:
  111. X
  112. X          %.c : %.y ; recipe...
  113. X          %.c : yaccsrc/%.y ; recipe...
  114. X
  115. X     ie. It is possible to specify the same recipe for two
  116. X     %-rules by giving more than one prerequisite in the prere-
  117. X     quisite list.  A more interesting example is:
  118. X
  119. X          % : RCS/%,v ; co $<
  120. X
  121. X
  122. X
  123. Version 3.70                    UW                             35
  124. X
  125. X
  126. X
  127. X
  128. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  129. X
  130. X
  131. X
  132. X     which describes how to take any target and check it out of
  133. X     the RCS directory if the corresponding file exists in the
  134. X     RCS directory.  The equivalent SCCS rule would be:
  135. X
  136. X          % : s.% ; get $<
  137. X
  138. X
  139. X     The previous RCS example defines an infinite rule, because
  140. X     it says how to make anything from RCS/%,v, and anything also
  141. X     includes RCS/fred.c,v.  To limit the size of the graph that
  142. X     results from such rules dmake uses the macro variable PREP
  143. X     (stands for % repetition).  By default the value of this
  144. X     variable is 0, which says that no repetitions of a %-rule
  145. X     are to be generated.  If it is set to something greater than
  146. X     0, then that many repetitions of any infinite %-rule are
  147. X     allowed.  If in the above example PREP was set to 1, then
  148. X     dmake would generate the dependency graph:
  149. X
  150. X          % --> RCS/%,v --> RCS/RCS/%,v,v
  151. X
  152. X     Where each link is assigned the same recipe as the first
  153. X     link.  PREP should be used only in special cases, since it
  154. X     may result in a large increase in the number of possible
  155. X     prerequisites tested.  dmake further assumes that any target
  156. X     that has no suffix can be made from a prerequisite that has
  157. X     at least one suffix.
  158. X
  159. X     dmake supports dynamic prerequisite generation for prere-
  160. X     quisites of %-meta rules.  This is best illustrated by an
  161. X     example.  The RCS rule shown above can infer how to check
  162. X     out a file from a corresponding RCS file only if the target
  163. X     is a simple file name with no directory information.  That
  164. X     is, the above rule can infer how to find RCS/fred.c,v from
  165. X     the target fred.c, but cannot infer how to find
  166. X     srcdir/RCS/fred.c,v from srcdir/fred.c because the above
  167. X     rule will cause dmake to look for RCS/srcdir/fred.c,v; which
  168. X     does not exist (assume that srcdir has its own RCS directory
  169. X     as is the common case).
  170. X
  171. X     A more versatile formulation of the above RCS check out rule
  172. X     is the following:
  173. X
  174. X          % :  $$(@:d)RCS/$$(@:f),v : co $@
  175. X
  176. X     This rule uses the dynamic macro $@ to specify the prere-
  177. X     quisite to try to infer.  During inference of this rule the
  178. X     macro $@ is set to the value of the target of the %-meta
  179. X     rule and the appropriate prerequisite is generated by
  180. X     extracting the directory portion of the target name (if
  181. X     any), appending the string RCS/ to it, and appending the
  182. X     target file name with a trailing ,v attached to the previous
  183. X     result.
  184. X
  185. X
  186. X
  187. Version 3.70                    UW                             36
  188. X
  189. X
  190. X
  191. X
  192. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  193. X
  194. X
  195. X
  196. X     dmake can also infer indirect prerequisites.  An inferred
  197. X     target can have a list of prerequisites added that will not
  198. X     show up in the value of $< but will show up in the value of
  199. X     $? and $&.  Indirect prerequisites are specified in an
  200. X     inference rule by quoting the prerequisite with single
  201. X     quotes.  For example, if you had the explicit dependency:
  202. X
  203. X          fred.o : fred.c ; rule to make fred.o
  204. X          fred.o : local.h
  205. X
  206. X     then this can be inferred for fred.o from the following
  207. X     inference rule:
  208. X
  209. X          %.o : %.c 'local.h' ; rule to make a .o from a .c
  210. X
  211. X     You may infer indirect prerequisites that are a function of
  212. X     the value of '%' in the current rule.  The meta-rule:
  213. X
  214. X          %.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
  215. X
  216. X     infers an indirect prerequisite found in the INC directory
  217. X     whose name is the same as the expansion of $(INC), and the
  218. X     prerequisite name depends on the base name of the current
  219. X     target.  The set of indirect prerequisites is attached to
  220. X     the meta rule in which they are specified and are inferred
  221. X     only if the rule is used to infer a recipe for a target.
  222. X     They do not play an active role in driving the inference
  223. X     algorithm.  The construct:
  224. X
  225. X          %.o : %.c %.f 'local.h'; recipe
  226. X
  227. X     is equivalent to:
  228. X
  229. X          %.o : %.c 'local.h' : recipe
  230. X          %.o : %.f 'local.h' : recipe
  231. X
  232. X
  233. X     If any of the attributes .SETDIR, .EPILOG, .PROLOG, .SILENT,
  234. X     .USESHELL, .SWAP, .PRECIOUS, .LIBRARY, .NOSTATE and .IGNORE
  235. X     are given for a %-rule then when that rule is bound to a
  236. X     target as the result of an inference, the target's set of
  237. X     attributes is augmented by the attributes from the above set
  238. X     that are specified in the bound %-rule.  Other attributes
  239. X     specified for %-meta rules are not inherited by the target.
  240. X     The .SETDIR attribute is treated in a special way.  If the
  241. X     target already had a .SETDIR attribute set then dmake
  242. X     changes to that directory prior to performing the inference.
  243. X     During inference any .SETDIR attributes for the inferred
  244. X     prerequisite are honored.  The directories must exist for a
  245. X     %-meta rule to be selected as a possible inference path.  If
  246. X     the directories do not exist no error message is issued,
  247. X     instead the corresponding path in the inference graph is
  248. X
  249. X
  250. X
  251. Version 3.70                    UW                             37
  252. X
  253. X
  254. X
  255. X
  256. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  257. X
  258. X
  259. X
  260. X     rejected.
  261. X
  262. X     dmake also supports the old format special target
  263. X     .<suffix>.<suffix> by identifying any rules of this form and
  264. X     mapping them to the appropriate %-rule.  So for example if
  265. X     an old makefile contains the construct:
  266. X
  267. X          .c.o :; cc -c $< -o $@
  268. X
  269. X     dmake maps this into the following %-rule:
  270. X
  271. X          %.o : %.c; cc -c $< -o $@
  272. X
  273. X     Furthermore, dmake understands several SYSV AUGMAKE special
  274. X     targets and maps them into corresponding %-meta rules.
  275. X     These transformation must be enabled by providing the -A
  276. X     flag on the command line or by setting the value of AUGMAKE
  277. X     to non-NULL.  The construct
  278. X
  279. X          .suff :; recipe
  280. X
  281. X     gets mapped into:
  282. X
  283. X          % : %.suff; recipe
  284. X
  285. X     and the construct
  286. X
  287. X          .c~.o :; recipe
  288. X
  289. X     gets mapped into:
  290. X
  291. X          %.o : s.%.c ; recipe
  292. X
  293. X     In general, a special target of the form .<str>~ is replaced
  294. X     by the %-rule construct s.%.<str>, thereby providing support
  295. X     for the syntax used by SYSV AUGMAKE for providing SCCS sup-
  296. X     port.  When enabled, these mappings allow processing of
  297. X     existing SYSV makefiles without modifications.
  298. X
  299. X     dmake bases all of its inferences on the inference graph
  300. X     constructed from the %-rules defined in the makefile.  It
  301. X     knows exactly which targets can be made from which prere-
  302. X     quisites by making queries on the inference graph.  For this
  303. X     reason .SUFFIXES is not needed and is completely ignored.
  304. X
  305. X     For a %-meta rule to be inferred as the rule whose recipe
  306. X     will be used to make a target, the target's name must match
  307. X     the %-target pattern, and any inferred %-prerequisite must
  308. X     already exist or have an explicit recipe so that the prere-
  309. X     quisite can be made.  Without transitive closure on the
  310. X     inference graph the above rule describes precisely when an
  311. X     inference match terminates the search.  If transitive
  312. X
  313. X
  314. X
  315. Version 3.70                    UW                             38
  316. X
  317. X
  318. X
  319. X
  320. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  321. X
  322. X
  323. X
  324. X     closure is enabled (the usual case), and a prerequisite does
  325. X     not exist or cannot be made, then dmake invokes the infer-
  326. X     ence algorithm recursively on the prerequisite to see if
  327. X     there is some way the prerequisite can be manufactured.
  328. X     For, if the prerequisite can be made then the current target
  329. X     can also be made using the current %-meta rule.  This means
  330. X     that there is no longer a need to give a rule for making a
  331. X     .o from a .y if you have already given a rule for making a
  332. X     .o from a .c and a .c from a .y.  In such cases dmake can
  333. X     infer how to make the .o from the .y via the intermediary .c
  334. X     and will remove the .c when the .o is made.  Transitive clo-
  335. X     sure can be disabled by giving the -T switch on the command
  336. X     line.
  337. X
  338. X     A word of caution.  dmake bases its transitive closure on
  339. X     the %-meta rule targets.  When it performs transitive clo-
  340. X     sure it infers how to make a target from a prerequisite by
  341. X     performing a pattern match as if the potential prerequisite
  342. X     were a new target.  The set of rules:
  343. X
  344. X          %.o : %.c :; rule for making .o from .c
  345. X          %.c : %.y :; rule for making .c from .y
  346. X          % : RCS/%,v :; check out of RCS file
  347. X
  348. X     will, by performing transitive closure, allow dmake to infer
  349. X     how to make a .o from a .y using a .c as an intermediate
  350. X     temporary file.  Additionally it will be able to infer how
  351. X     to make a .y from an RCS file, as long as that RCS file is
  352. X     in the RCS directory and has a name which ends in .y,v.  The
  353. X     transitivity computation is performed dynamically for each
  354. X     target that does not have a recipe.  This has potential to
  355. X     be costly if the %-meta rules are not carefully specified.
  356. X     The .NOINFER attribute is used to mark a %-meta node as
  357. X     being a final target during inference.  Any node with this
  358. X     attribute set will not be used for subsequent inferences.
  359. X     As an example the node RCS/%,v is marked as a final node
  360. X     since we know that if the RCS file does not exist there
  361. X     likely is no other way to make it.  Thus the standard
  362. X     startup makefile contains an entry similar to:
  363. X          .NOINFER : RCS/%,v
  364. X     Thereby indicating that the RCS file is the end of the
  365. X     inference chain.
  366. X
  367. X     Whenever the inference algorithm determines that a target
  368. X     can be made from more than one prerequisite and the infer-
  369. X     ence chains for the two methods are the same length the
  370. X     algorithm reports an ambiguity and prints the ambiguous
  371. X     inference chains.
  372. X
  373. X     dmake tries to remove intermediate files resulting from
  374. X     transitive closure if the file is not marked as being PRE-
  375. X     CIOUS, or the -u flag was not given on the command line, and
  376. X
  377. X
  378. X
  379. Version 3.70                    UW                             39
  380. X
  381. X
  382. X
  383. X
  384. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  385. X
  386. X
  387. X
  388. X     if the inferred intermediate did not previously exist.
  389. X     Intermediate targets that existed prior to being made are
  390. X     never removed.  This is in keeping with the philosophy that
  391. X     dmake should never remove things from the file system that
  392. X     it did not add.  If the special target .REMOVE is defined
  393. X     and has a recipe then dmake constructs a list of the inter-
  394. X     mediate files to be removed and makes them prerequisites of
  395. X     .REMOVE.  It then makes .REMOVE thereby removing the prere-
  396. X     quisites if the recipe of .REMOVE says to.  Typically
  397. X     .REMOVE is defined in the startup file as:
  398. X
  399. X          .REMOVE :; $(RM) $<
  400. X
  401. MAKING TARGETS
  402. X     In order to update a target dmake must execute a recipe.
  403. X     When a recipe needs to be executed it is first expanded so
  404. X     that any macros in the recipe text are expanded, and it is
  405. X     then either executed directly or passed to a shell.  dmake
  406. X     supports two types of recipes.  The regular recipes and
  407. X     group recipes.
  408. X
  409. X     When a regular recipe is invoked dmake executes each line of
  410. X     the recipe separately using a new copy of a shell if a shell
  411. X     is required.  Thus effects of commands do not generally per-
  412. X     sist across recipe lines.  (e.g. cd requests in a recipe
  413. X     line do not carry over to the next recipe line) The decision
  414. X     on whether a shell is required to execute a command is based
  415. X     on the value of the macro SHELLMETAS or on the specification
  416. X     of '+' or .USESHELL for the current recipe or target respec-
  417. X     tively.  If any character in the value of SHELLMETAS is
  418. X     found in the expanded recipe text-line or the use of a shell
  419. X     is requested explicitly via '+' or .USESHELL then the com-
  420. X     mand is executed using a shell, otherwise the command is
  421. X     executed directly.  The shell that is used for execution is
  422. X     given by the value of the macro SHELL.  The flags that are
  423. X     passed to the shell are given by the value of SHELLFLAGS.
  424. X     Thus dmake constructs the command line:
  425. X
  426. X          $(SHELL) $(SHELLFLAGS) $(expanded_recipe_command)
  427. X
  428. X     Normally dmake writes the command line that it is about to
  429. X     invoke to standard output.  If the .SILENT attribute is set
  430. X     for the target or for the recipe line (via @), then the
  431. X     recipe line is not echoed.
  432. X
  433. X     Group recipe processing is similar to that of regular
  434. X     recipes, except that a shell is always invoked.  The shell
  435. X     that is invoked is given by the value of the macro GROUP-
  436. X     SHELL, and its flags are taken from the value of the macro
  437. X     GROUPFLAGS.  If a target has the .PROLOG attribute set then
  438. X     dmake prepends to the shell script the recipe associated
  439. X     with the special target .GROUPPROLOG, and if the attribute
  440. X
  441. X
  442. X
  443. Version 3.70                    UW                             40
  444. X
  445. X
  446. X
  447. X
  448. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  449. X
  450. X
  451. X
  452. X     .EPILOG is set as well, then the recipe associated with the
  453. X     special target .GROUPEPILOG is appended to the script file.
  454. X     This facility can be used to always prepend a common header
  455. X     and common trailer to group recipes.  Group recipes are
  456. X     echoed to standard output just like standard recipes, but
  457. X     are enclosed by lines beginning with [ and ].
  458. X
  459. X     The recipe flags [+,-,%,@] are recognized at the start of a
  460. X     recipe line even if they appear in a macro.  For example:
  461. X
  462. X          SH = +
  463. X          all:
  464. X               $(SH)echo hi
  465. X
  466. X     is completely equivalent to writing
  467. X
  468. X          SH = +
  469. X          all:
  470. X               +echo hi
  471. X
  472. X
  473. X     The last step performed by dmake prior to running a recipe
  474. X     is to set the macro CMNDNAME to the name of the command to
  475. X     execute (determined by finding the first white-space ending
  476. X     token in the command line).  It then sets the macro CMNDARGS
  477. X     to be the remainder of the line.  dmake then expands the
  478. X     macro COMMAND which by default is set to
  479. X
  480. X          COMMAND = $(CMNDNAME) $(CMNDARGS)
  481. X
  482. X     The result of this final expansion is the command that will
  483. X     be executed.  The reason for this expansion is to allow for
  484. X     a different interface to the argument passing facilities
  485. X     (esp. under DOS) than that provided by dmake. You can for
  486. X     example define COMMAND to be
  487. X
  488. X          COMMAND = $(CMNDNAME) @$(mktmp $(CMNDARGS))
  489. X
  490. X     which dumps the arguments into a temporary file and runs the
  491. X     command
  492. X
  493. X          $(CMNDNAME) @/tmp/ASAD23043
  494. X
  495. X     which has a much shorter argument list.  It is now up to the
  496. X     command to use the supplied argument as the source for all
  497. X     other arguments.  As an optimization, if COMMAND is not
  498. X     defined dmake does not perform the above expansion.  On sys-
  499. X     tems, such as UNIX, that handle long command lines this pro-
  500. X     vides a slight saving in processing the makefiles.
  501. X
  502. X
  503. X
  504. X
  505. X
  506. X
  507. Version 3.70                    UW                             41
  508. X
  509. X
  510. X
  511. X
  512. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  513. X
  514. X
  515. X
  516. MAKING LIBRARIES
  517. X     Libraries are easy to maintain using dmake.  A library is a
  518. X     file containing a collection of object files.  Thus to make
  519. X     a library you simply specify it as a target with the
  520. X     .LIBRARY attribute set and specify its list of prere-
  521. X     quisites.  The prerequisites should be the object members
  522. X     that are to go into the library.  When dmake makes the
  523. X     library target it uses the .LIBRARY attribute to pass to the
  524. X     prerequisites the .LIBMEMBER attribute and the name of the
  525. X     library.  This enables the file binding mechanism to look
  526. X     for the member in the library if an appropriate object file
  527. X     cannot be found. A small example best illustrates this.
  528. X
  529. X          mylib.a .LIBRARY : mem1.o mem2.o mem3.o
  530. X               rules for making library...
  531. X               # remember to remove .o's when lib is made
  532. X
  533. X          # equivalent to:  '%.o : %.c ; ...'
  534. X          .c.o :; rules for making .o from .c say
  535. X
  536. X     dmake will use the .c.o rule for making the library members
  537. X     if appropriate .c files can be found using the search rules.
  538. X     NOTE:  this is not specific in any way to C programs, they
  539. X     are simply used as an example.
  540. X
  541. X     dmake tries to handle the old library construct format in a
  542. X     sensible way.  The construct lib(member.o) is separated and
  543. X     the lib portion is declared as a library target.  The new
  544. X     target is defined with the .LIBRARY attribute set and the
  545. X     member.o portion of the construct is declared as a prere-
  546. X     quisite of the lib target.  If the construct lib(member.o)
  547. X     appears as a prerequisite of a target in the makefile, that
  548. X     target has the new name of the lib assigned as its prere-
  549. X     quisite.  Thus the following example:
  550. X
  551. X          a.out : ml.a(a.o) ml.a(b.o); $(CC) -o $@  $<
  552. X
  553. X          .c.o :; $(CC) -c $(CFLAGS) -o $@  $<
  554. X          %.a:
  555. X               ar rv $@ $?
  556. X               ranlib $@
  557. X               rm -rf $?
  558. X
  559. X     constructs the following dependency graph.
  560. X
  561. X          a.out : ml.a; $(CC) -o $@  $<
  562. X          ml.a .LIBRARY : a.o b.o
  563. X
  564. X          %.o : %.c ; $(CC) -c $(CFLAGS) -o $@  $<
  565. X          %.a :
  566. X               ar rv $@ $?
  567. X               ranlib $@
  568. X
  569. X
  570. X
  571. Version 3.70                    UW                             42
  572. X
  573. X
  574. X
  575. X
  576. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  577. X
  578. X
  579. X
  580. X               rm -rf $?
  581. X
  582. X     and making a.out then works as expected.
  583. X
  584. X     The same thing happens for any target of the form
  585. X     lib((entry)).  These targets have an additional feature in
  586. X     that the entry target has the .SYMBOL attribute set automat-
  587. X     ically.
  588. X
  589. X     NOTE:  If the notion of entry points is supported by the
  590. X     archive and by dmake (currently not the case) then dmake
  591. X     will search the archive for the entry point and return not
  592. X     only the modification time of the member which defines the
  593. X     entry but also the name of the member file.  This name will
  594. X     then replace entry and will be used for making the member
  595. X     file.  Once bound to an archive member the .SYMBOL attribute
  596. X     is removed from the target.  This feature is presently dis-
  597. X     abled as there is little standardization among archive for-
  598. X     mats, and we have yet to find a makefile utilizing this
  599. X     feature (possibly due to the fact that it is unimplemented
  600. X     in most versions of UNIX Make).
  601. X
  602. X     Finally, when dmake looks for a library member it must first
  603. X     locate the library file.  It does so by first looking for
  604. X     the library relative to the current directory and if it is
  605. X     not found it then looks relative to the current value of
  606. X     $(TMD).  This allows commonly used libraries to be kept near
  607. X     the root of a source tree and to be easily found by dmake.
  608. X
  609. KEEP STATE
  610. X     dmake supports the keeping of state information for targets
  611. X     that it makes whenever the macro .KEEP_STATE is assigned a
  612. X     value.  The value of the macro should be the name of a state
  613. X     file that will contain the state information.  If state
  614. X     keeping is enabled then each target that does not poses the
  615. X     .NOSTATE attribute will have a record written into the state
  616. X     file indicating the target's name, the current directory,
  617. X     the command used to update the target, and which, if any, ::
  618. X     rule is being used.  When you make this target again if any
  619. X     of this information does not match the previous settings and
  620. X     the target is not out dated it will still be re-made.  The
  621. X     assumption is that one of the conditions above has changed
  622. X     and that we wish to remake the target.  For example, state
  623. X     keeping is used in the maintenance of dmake to test compile
  624. X     different versions of the source using different compilers.
  625. X     Changing the compiler causes the compilation flags to be
  626. X     modified and hence all sources to be recompiled.
  627. X
  628. X     The state file is an ascii file and is portable, however it
  629. X     is not in human readable form as the entries represent hash
  630. X     keys of the above information.
  631. X
  632. X
  633. X
  634. X
  635. Version 3.70                    UW                             43
  636. X
  637. X
  638. X
  639. X
  640. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  641. X
  642. X
  643. X
  644. X     The Sun Microsystem's Make construct
  645. X
  646. X          .KEEP_STATE :
  647. X
  648. X     is recognized and is mapped to .KEEP_STATE:=_state.mk.  The
  649. X     dmake version of state keeping does not include scanning C
  650. X     source files for dependencies like Sun Make.  This is
  651. X     specific to C programs and it was felt that it does not
  652. X     belong in make.  dmake instead provides the tool, cdepend,
  653. X     to scan C source files and to produce depedency information.
  654. X     Users are free to modify cdepend to produce other dependency
  655. X     files.  (NOTE: cdepend does not come with the distribution
  656. X     at this time, but will be available in a patch in the near
  657. X     future)
  658. X
  659. MULTI PROCESSING
  660. X     If the architecture supports it then dmake is capable of
  661. X     making a target's prerequisites in parallel.  dmake will
  662. X     make as much in parallel as it can and use a number of child
  663. X     processes up to the maximum specified by MAXPROCESS or by
  664. X     the value supplied to the -P command line flag.  A parallel
  665. X     make is enabled by setting the value of MAXPROCESS (either
  666. X     directly or via -P option) to a value which is > 1.  dmake
  667. X     guarantees that all dependencies as specified in the
  668. X     makefile are honored.  A target will not be made until all
  669. X     of its prerequisites have been made.  If a parallel make is
  670. X     being performed then the following restrictions on parallel-
  671. X     ism are enforced.
  672. X
  673. X          1.   Individual recipe lines in a non-group recipe are
  674. X               performed sequentially in the order in which they
  675. X               are specified within the makefile and in parallel
  676. X               with the recipes of other targets.
  677. X
  678. X          2.   If a target contains multiple recipe definitions
  679. X               (cf. :: rules) then these are performed sequen-
  680. X               tially in the order in which the :: rules are
  681. X               specified within the makefile and in parallel with
  682. X               the recipes of other targets.
  683. X
  684. X          3.   If a target rule contains the `!' modifier, then
  685. X               the recipe is performed sequentially for the list
  686. X               of outdated prerequisites and in parallel with the
  687. X               recipes of other targets.
  688. X
  689. X          4.   If a target has the .SEQUENTIAL attribute set then
  690. X               all of its prerequisites are made sequentially
  691. X               relative to one another (as if MAXPROCESS=1), but
  692. X               in parallel with other targets in the makefile.
  693. X
  694. X     Note:  If you specify a parallel make then the order of tar-
  695. X     get update and the order in which the associated recipes are
  696. X
  697. X
  698. X
  699. Version 3.70                    UW                             44
  700. X
  701. X
  702. X
  703. X
  704. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  705. X
  706. X
  707. X
  708. X     invoked will not correspond to that displayed by the -n
  709. X     flag.
  710. X
  711. CONDITIONALS
  712. X     dmake supports a makefile construct called a conditional.
  713. X     It allows the user to conditionally select portions of
  714. X     makefile text for input processing and to discard other por-
  715. X     tions.  This becomes useful for writing makefiles that are
  716. X     intended to function for more than one target host and
  717. X     environment.  The conditional expression is specified as
  718. X     follows:
  719. X
  720. X          .IF  expression
  721. X             ... if text ...
  722. X          .ELIF  expression
  723. X             ... if text ...
  724. X          .ELSE
  725. X             ... else text ...
  726. X          .END
  727. X
  728. X     The .ELSE and .ELIF portions are optional, and the condi-
  729. X     tionals may be nested (ie.  the text may contain another
  730. X     conditional).  .IF, .ELSE, and .END may appear anywhere in
  731. X     the makefile, but a single conditional expression may not
  732. X     span multiple makefiles.
  733. X
  734. X     expression can be one of the following three forms:
  735. X
  736. X          <text> | <text> == <text> | <text> != <text>
  737. X
  738. X     where text is either text or a macro expression.  In any
  739. X     case, before the comparison is made, the expression is
  740. X     expanded.  The text portions are then selected and compared.
  741. X     White space at the start and end of the text portion is dis-
  742. X     carded before the comparison.  This means that a macro that
  743. X     evaluates to nothing but white space is considered a NULL
  744. X     value for the purpose of the comparison.  In the first case
  745. X     the expression evaluates TRUE if the text is not NULL other-
  746. X     wise it evaluates FALSE.  The remaining two cases both
  747. X     evaluate the expression on the basis of a string comparison.
  748. X     If a macro expression needs to be equated to a NULL string
  749. X     then compare it to the value of the macro $(NULL).  You can
  750. X     use the $(shell ...) macro to construct more complex test
  751. X     expressions.
  752. X
  753. EXAMPLES
  754. X          # A simple example showing how to use make
  755. X          #
  756. X          prgm : a.o b.o
  757. X               cc a.o b.o -o prgm
  758. X          a.o : a.c g.h
  759. X               cc a.c -o $@
  760. X
  761. X
  762. X
  763. Version 3.70                    UW                             45
  764. X
  765. X
  766. X
  767. X
  768. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  769. X
  770. X
  771. X
  772. X          b.o : b.c g.h
  773. X               cc b.c -o $@
  774. X
  775. X     In the previous example prgm is remade only if a.o and/or
  776. X     b.o is out of date with respect to prgm.  These dependencies
  777. X     can be stated more concisely by using the inference rules
  778. X     defined in the standard startup file.  The default rule for
  779. X     making .o's from .c's looks something like this:
  780. X
  781. X          %.o : %.c; cc -c $(CFLAGS) -o $@ $<
  782. X
  783. X     Since there exists a rule (defined in the startup file) for
  784. X     making .o's from .c's dmake will use that rule for manufac-
  785. X     turing a .o from a .c and we can specify our dependencies
  786. X     more concisely.
  787. X
  788. X          prgm : a.o b.o
  789. X               cc -o prgm $<
  790. X          a.o b.o : g.h
  791. X
  792. X     A more general way to say the above using the new macro
  793. X     expansions would be:
  794. X
  795. X          SRC = a b
  796. X          OBJ = {$(SRC)}.o
  797. X
  798. X          prgm : $(OBJ)
  799. X               cc -o $@ $<
  800. X
  801. X          $(OBJ) : g.h
  802. X
  803. X     If we want to keep the objects in a separate directory,
  804. X     called objdir, then we would write something like this.
  805. X
  806. X          SRC = a b
  807. X          OBJ = {$(SRC)}.o
  808. X
  809. X          prgm : $(OBJ)
  810. X               cc $< -o $@
  811. X
  812. X          $(OBJ) : g.h
  813. X          %.o : %.c
  814. X               $(CC) -c $(CFLAGS) -o $(@:f) $<
  815. X               mv $(@:f) objdir
  816. X
  817. X          .SOURCE.o : objdir       # tell make to look here for .o's
  818. X
  819. X     An example of building library members would go something
  820. X     like this: (NOTE:  The same rules as above will be used to
  821. X     produce .o's from .c's)
  822. X
  823. X          SRC  = a b
  824. X
  825. X
  826. X
  827. Version 3.70                    UW                             46
  828. X
  829. X
  830. X
  831. X
  832. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  833. X
  834. X
  835. X
  836. X          LIB  = lib
  837. X          LIBm = { $(SRC) }.o
  838. X
  839. X          prgm: $(LIB)
  840. X               cc -o $@ $(LIB)
  841. X
  842. X          $(LIB) .LIBRARY : $(LIBm)
  843. X               ar rv $@ $<
  844. X               rm $<
  845. X
  846. X     Finally, suppose that each of the source files in the previ-
  847. X     ous example had the `:' character in their target name.
  848. X     Then we would write the above example as:
  849. X
  850. X          SRC  = f:a f:b
  851. X          LIB  = lib
  852. X          LIBm = "{ $(SRC) }.o"         # put quotes around each token
  853. X
  854. X          prgm: $(LIB)
  855. X               cc -o $@ $(LIB)
  856. X
  857. X          $(LIB) .LIBRARY : $(LIBm)
  858. X               ar rv $@ $<
  859. X               rm $<
  860. X
  861. COMPATIBILITY
  862. X     There are two notable differences between dmake and the
  863. X     standard version of BSD UNIX 4.2/4.3 Make.
  864. X
  865. X          1. BSD UNIX 4.2/4.3 Make supports wild card filename
  866. X             expansion for prerequisite names.  Thus if a direc-
  867. X             tory contains a.h, b.h and c.h, then a line like
  868. X
  869. X                  target: *.h
  870. X
  871. X             will cause UNIX make to expand the *.h into "a.h b.h
  872. X             c.h".  dmake does not support this type of filename
  873. X             expansion.
  874. X
  875. X          2. Unlike UNIX make, touching a library member causes
  876. X             dmake to search the library for the member name and
  877. X             to update the library time stamp.  This is only
  878. X             implemented in the UNIX version.  MSDOS and other
  879. X             versions may not have librarians that keep file time
  880. X             stamps, as a result dmake touches the library file
  881. X             itself, and prints a warning.
  882. X
  883. X     dmake is not compatible with GNU Make.  In particular it
  884. X     does not understand GNU Make's macro expansions that query
  885. X     the file system.
  886. X
  887. X
  888. X
  889. X
  890. X
  891. Version 3.70                    UW                             47
  892. X
  893. X
  894. X
  895. X
  896. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  897. X
  898. X
  899. X
  900. X     dmake is fully compatible with SYSV AUGMAKE, and supports
  901. X     the following AUGMAKE features:
  902. X
  903. X          1. The word include appearing at the start of a line
  904. X             can be used instead of the ".INCLUDE :" construct
  905. X             understood by dmake.
  906. X
  907. X          2. The macro modifier expression $(macro:str=sub) is
  908. X             understood and is equivalent to the expression
  909. X             $(macro:s/str/sub), with the restriction that str
  910. X             must match the following regular expression:
  911. X
  912. X                  str[ |\t][ |\t]*
  913. X
  914. X             (ie. str only matches at the end of a token where
  915. X             str is a suffix and is terminated by a space, a tab,
  916. X             or end of line) Normally sub is expanded before the
  917. X             substitution is made, if you specify -A on the com-
  918. X             mand line then sub is not expanded.
  919. X
  920. X          3. The macro % is defined to be $@ (ie. $% expands to
  921. X             the same value as $@).
  922. X
  923. X          4. The AUGMAKE notion of libraries is handled
  924. X             correctly.
  925. X
  926. X          5. When defining special targets for the inference
  927. X             rules and the AUGMAKE special target handling is
  928. X             enabled then the special target .X is equivalent to
  929. X             the %-rule "% : %.X".
  930. X
  931. X          6. Directories are always made if you specify -A.  This
  932. X             is consistent with other UNIX versions of Make.
  933. X
  934. X          7. Makefiles that utilize virtual targets to force mak-
  935. X             ing of other targets work as expected if AUGMAKE
  936. X             special target handling is enabled.  For example:
  937. X
  938. X                  FRC:
  939. X                  myprog.o : myprog.c $(FRC) ; ...
  940. X
  941. X             Works as expected if you issue the command
  942. X
  943. X                  'dmake -A FRC=FRC'
  944. X
  945. X             but fails with a 'don't know how to make FRC' error
  946. X             message if you do not specify AUGMAKE special target
  947. X             handling via the -A flag (or by setting AUGMAKE:=yes
  948. X             internally).
  949. X
  950. X
  951. X
  952. X
  953. X
  954. X
  955. Version 3.70                    UW                             48
  956. X
  957. X
  958. X
  959. X
  960. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  961. X
  962. X
  963. X
  964. LIMITS
  965. X     In some environments the length of an argument string is
  966. X     restricted.  (e.g. MSDOS command line arguments cannot be
  967. X     longer than 128 bytes if you are using the standard
  968. X     command.com command interpreter as your shell, dmake text
  969. X     diversions may help in these situations.)
  970. X
  971. PORTABILITY
  972. X     To write makefiles that can be moved from one environment to
  973. X     another requires some forethought.  In particular you must
  974. X     define as macros all those things that may be different in
  975. X     the new environment.  dmake has two facilities that help to
  976. X     support writing portable makefiles, recursive macros and
  977. X     conditional expressions.  The recursive macros, allow one to
  978. X     define environment configurations that allow different
  979. X     environments for similar types of operating systems.  For
  980. X     example the same make script can be used for SYSV and BSD
  981. X     but with different macro definitions.
  982. X
  983. X     To write a makefile that is portable between UNIX and MSDOS
  984. X     requires both features since in almost all cases you will
  985. X     need to define new recipes for making targets.  The recipes
  986. X     will probably be quite different since the capabilities of
  987. X     the tools on each machine are different.  Different macros
  988. X     will be needed to help handle the smaller differences in the
  989. X     two environments.
  990. X
  991. FILES
  992. X     Makefile, makefile, startup.mk (use dmake -V to tell you
  993. X     where the startup file is)
  994. X
  995. SEE ALSO
  996. X     sh(1), csh(1), touch(1), f77(1), pc(1), cc(1)
  997. X     S.I. Feldman  Make - A Program for Maintaining Computer Pro-
  998. X     grams
  999. X
  1000. AUTHOR
  1001. X     Dennis Vadura, CS Dept. University of Waterloo.
  1002. X     dvadura@watdragon.uwaterloo.ca
  1003. X     Many thanks to Carl Seger for his helpful suggestions, and
  1004. X     to Trevor John Thompson for his many excellent ideas and
  1005. X     informative bug reports.
  1006. X
  1007. BUGS
  1008. X     Some system commands return non-zero status inappropriately.
  1009. X     Use -i (`-' within the makefile) to overcome the difficulty.
  1010. X
  1011. X     Some systems do not have easily accessible time stamps for
  1012. X     library members (MSDOS, AMIGA, etc) for these dmake uses the
  1013. X     time stamp of the library instead and prints a warning the
  1014. X     first time it does so.  This is almost always ok, except
  1015. X     when multiple makefiles update a single library file.  In
  1016. X
  1017. X
  1018. X
  1019. Version 3.70                    UW                             49
  1020. X
  1021. X
  1022. X
  1023. X
  1024. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1025. X
  1026. X
  1027. X
  1028. X     these instances it is possible to miss an update if one is
  1029. X     not careful.
  1030. X
  1031. X     This man page is way too long.
  1032. X
  1033. WARNINGS
  1034. X     Rules supported by make(1) may not work if transitive clo-
  1035. X     sure is turned off (-T, .NOINFER).
  1036. X
  1037. X     PWD from csh/ksh will cause problems if a cd operation is
  1038. X     performed and -e or -E option is used.
  1039. X
  1040. X     Using internal macros such as COMMAND, may wreak havoc if
  1041. X     you don't understand their functionality.
  1042. X
  1043. X     If multiple MACRO=line arguments appear on the command line,
  1044. X     only the first is used.  Beware of this in conjunction with
  1045. X     the MAKEMACROS variable.
  1046. X
  1047. X
  1048. X
  1049. X
  1050. X
  1051. X
  1052. X
  1053. X
  1054. X
  1055. X
  1056. X
  1057. X
  1058. X
  1059. X
  1060. X
  1061. X
  1062. X
  1063. X
  1064. X
  1065. X
  1066. X
  1067. X
  1068. X
  1069. X
  1070. X
  1071. X
  1072. X
  1073. X
  1074. X
  1075. X
  1076. X
  1077. X
  1078. X
  1079. X
  1080. X
  1081. X
  1082. X
  1083. Version 3.70                    UW                             50
  1084. SHAR_EOF
  1085. chmod 0640 dmake/man/dmake.nc ||
  1086. echo 'restore of dmake/man/dmake.nc failed'
  1087. Wc_c="`wc -c < 'dmake/man/dmake.nc'`"
  1088. test 119471 -eq "$Wc_c" ||
  1089.     echo 'dmake/man/dmake.nc: original size 119471, current size' "$Wc_c"
  1090. rm -f _shar_wnt_.tmp
  1091. fi
  1092. # ============= dmake/man/dmake.tf ==============
  1093. if test -f 'dmake/man/dmake.tf' -a X"$1" != X"-c"; then
  1094.     echo 'x - skipping dmake/man/dmake.tf (File already exists)'
  1095.     rm -f _shar_wnt_.tmp
  1096. else
  1097. > _shar_wnt_.tmp
  1098. sed 's/^X//' << 'SHAR_EOF' > 'dmake/man/dmake.tf' &&
  1099. .\" Copyright (c) 1990 Dennis Vadura, All rights reserved.
  1100. .\"
  1101. .ds TB "0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.5i +0.5i +2.0i
  1102. .de Ip
  1103. .fi
  1104. .nr Ip \w'\\$1 'u
  1105. .IP "\\$1" \\n(Ipu
  1106. \\$2
  1107. .nf
  1108. ..
  1109. .de Is
  1110. .nr )I \w'\\$1'u
  1111. ..
  1112. .de Ii
  1113. .in \\n()Ru
  1114. .nr )E 1
  1115. .ns
  1116. .ne 1.1v
  1117. .it 1 }N
  1118. .di ]B
  1119. \&\\$1
  1120. ..
  1121. .TH DMAKE p  "UW" "Version 3.70" "Unsupported Free Software"
  1122. .SH NAME
  1123. \fBdmake\fR \- maintain program groups, or interdependent files
  1124. .SH SYNOPSIS
  1125. .B dmake
  1126. [\-ABceEhiknpqrsStTuVx] [\-v{dfimt}] [\-P#] [\-{f|C|K} file]
  1127. [macro[*][+][:]=\fIvalue\fP ...] [target ...]
  1128. .SH DESCRIPTION
  1129. .PP
  1130. .B dmake
  1131. executes commands found in an external file called a
  1132. .I makefile
  1133. to update one or more target names.
  1134. Each target may depend on zero or more prerequisite targets.
  1135. If any of the target's prerequisites is newer than the target or if the target
  1136. itself does not exist, then
  1137. SHAR_EOF
  1138. true || echo 'restore of dmake/man/dmake.tf failed'
  1139. fi
  1140. echo 'End of part 16, continue with part 17'
  1141. echo 17 > _shar_seq_.tmp
  1142. exit 0
  1143. exit 0 # Just in case...
  1144.