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

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