home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume19 / dmake / part19 < prev    next >
Encoding:
Text File  |  1991-05-11  |  40.4 KB  |  1,092 lines

  1. Newsgroups: comp.sources.misc
  2. From: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  3. Subject:  v19i040:  dmake - dmake version 3.7, Part19/37
  4. Message-ID: <1991May12.002052.9431@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 3680515260985871333f8cefd23f0ad0
  6. Date: Sun, 12 May 1991 00:20:52 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  10. Posting-number: Volume 19, Issue 40
  11. Archive-name: dmake/part19
  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.19 (part 19 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file dmake/man/dmake.tf 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" != 19; 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.tf' &&
  34. are escaped by \\.
  35. A set of continued lines may be commented out by placing a single # at the
  36. start of the first line.
  37. A continued line cannot span more than one makefile.
  38. .PP
  39. \fBwhite space\fP is defined to be any combination of
  40. <space>, <tab>, and the sequence \\<nl>
  41. when \\<nl> is used to terminate a LINE.
  42. When processing \fBmacro\fP definition lines,
  43. any amount of white space is allowed on either side of the macro operator
  44. (=, *=, :=, *:=, += or +:=), and
  45. white space is stripped from both before and after the macro
  46. value string.
  47. The sequence \\<nl> is treated as
  48. white space during recipe expansion
  49. and is deleted from the final recipe string.
  50. You must escape the \\<nl> with another \\ in order to get a \\ at the end
  51. of a recipe line.
  52. The \\<nl> sequence is deleted from macro values when they are expanded.
  53. .PP
  54. When processing \fBtarget\fP definition lines,
  55. the recipe for a target must, in general, follow the first definition
  56. of the target (See the RULES AND TARGETS section for an exception), and
  57. the recipe may not span across multiple makefiles.
  58. Any targets and prerequisites found on a target definition line are taken
  59. to be white space separated tokens.
  60. The rule operator (\fIop\fP in SYNTAX section) is also considered
  61. to be a token but does not require
  62. white space to precede or follow it.  Since the rule operator begins with a `:',
  63. traditional versions of make do not allow the `:' character to
  64. form a valid target name.  \fBdmake\fP allows `:' to be present in
  65. target/prerequisite names as long as the entire target/prerequisite name is
  66. quoted.  For example:
  67. .sp
  68. \ta:fred : test
  69. .sp
  70. would be parsed as TARGET = a, PREREQUISITES={fred, :, test}, which
  71. is not what was intended.  To fix this you must write:
  72. .sp
  73. \t"a:fred" : test
  74. .sp
  75. Which will be parsed as expected.
  76. See the EXAMPLES section for how to apply \fB"\fP quoting
  77. to a list of targets.
  78. .SH ATTRIBUTES
  79. .B dmake
  80. defines several target attributes.  Attributes may be
  81. assigned to a single target, a group of targets, or to all targets in the
  82. makefile.  Attributes are used to modify
  83. \fBdmake\fP actions during target update.
  84. The recognized attributes are:
  85. .sp
  86. .IP \fB.EPILOG\fP 1.2i
  87. Insert shell epilog code when executing a group recipe associated with
  88. any target having this attribute set.
  89. .IP \fB.IGNORE\fP 1.2i
  90. Ignore an error when trying to make any target with this attribute set.
  91. .IP \fB.LIBRARY\fP 1.2i
  92. Target is a library.
  93. .IP \fB.MKSARGS\fP 1.2i
  94. If running in an MSDOS environment then use MKS extended argument passing
  95. conventions to pass arguments to commands.  Non-MSDOS
  96. environments ignore this attribute.
  97. .IP \fB.NOINFER\fP 1.2i
  98. Any target with this attribute set will not be subjected
  99. to transitive closure if it is inferred as a prerequisite 
  100. of a target whose recipe and prerequisites are being inferred.
  101. (i.e. the inference algorithm will not use any prerequisite with this attribute 
  102. set, as a target)
  103. If specified as '.NOINFER:' (ie. with no prerequisites or targets) then the
  104. effect is equivalent to specifying \fB-T\fP on the command line.
  105. .IP \fB.NOSTATE\fP 1.2i
  106. Any target with this attribute set will not have command line flag
  107. information stored in the state file if .KEEP_STATE has been enabled.
  108. .IP \fB.PHONY\fP 1.2i
  109. Any target with this attribute set will have its recipe executed
  110. each time the target is made even if a file matching the target name can
  111. be located.  Any targets that have a .PHONY attributed target as a
  112. prerequisite will be made each time the .PHONY attributed prerequisite is
  113. made.
  114. .IP \fB.PRECIOUS\fP 1.2i
  115. Do not remove associated target under any circumstances.
  116. Set by default for any targets whose corresponding files exist in the file
  117. system prior to the execution of \fBdmake\fP.
  118. .IP \fB.PROLOG\fP 1.2i
  119. Insert shell prolog code when executing a group recipe associated with
  120. any target having this attribute set.
  121. .IP \fB.SEQUENTIAL\fP 1.2i
  122. Force a sequential make of the associated target's prerequisites.
  123. .IP \fB.SETDIR\fP 1.2i
  124. Change current working directory to specified directory when making the
  125. associated target.  You must
  126. specify the directory at the time the attribute is specified.  To do this
  127. simply give \fI.SETDIR=path\fP as the attribute.  \fIpath\fP is expanded and
  128. the result is used as the value of the directory to change to.
  129. If path is surrounded by single quotes then path is not expanded, and is used
  130. literally as the directory name.
  131. If the \fIpath\fP contains any `:' characters then the entire attribute string
  132. must be quoted using ".
  133. If a target having this attribute set also has the .IGNORE
  134. attribute set then if the change to the specified directory fails it will be
  135. ignored, and no error message will be issued.
  136. .IP \fB.SILENT\fP 1.2i
  137. Do not echo the recipe lines when making any target with this attribute set,
  138. and do not issue any warnings.
  139. .IP \fB.SWAP\fP 1.2i
  140. Under MSDOS
  141. when making a target with this attribute set swap the \fBdmake\fP executable
  142. to disk prior to executing the recipe line.  Also see the '%' recipe line
  143. flag defined in the RECIPES section.
  144. .IP \fB.SYMBOL\fP 1.2i
  145. Target is a library member and is an entry point into a module in the
  146. library.  This attribute is used only when searching a library for a target.
  147. Targets of the form lib((entry)) have this attribute set automatically.
  148. .IP \fB.USESHELL\fP 1.2i
  149. Force each recipe line of a target to be executed using a shell.
  150. Specifying this attribute is equivalent to specifying the '+' character at the
  151. start of each line of a non-group recipe.
  152. .IP \fB.UPDATEALL\fP 1.2i
  153. Indicates that all the targets listed in this rule are updated by the
  154. execution of the accompanying recipe.
  155. A common example is the production of the
  156. .I y.tab.c
  157. and
  158. .I y.tab.h
  159. files by
  160. .B yacc
  161. when it is run on a grammar.  Specifying .UPDATEALL in such a rule
  162. prevents the running of yacc twice, once for the y.tab.c file and once
  163. for the y.tab.h file.
  164. .sp
  165. .PP
  166. All attributes are user setable and except for .UPDATEALL, .SETDIR and .MKSARGS
  167. may be used in one of two forms.
  168. The .MKSARGS attribute is restricted to use as a global attribute, and
  169. the use of the .UPDATEALL and .SETDIR attributes is restricted to rules
  170. of the second form only.
  171. .sp
  172. \tATTRIBUTE_LIST : \fItargets\fP
  173. .sp
  174. assigns the attributes specified by ATTRIBUTE_LIST to each target in
  175. .I targets
  176. or
  177. .sp
  178. \t\fItargets\fP ATTRIBUTE_LIST : ...
  179. .sp
  180. assigns the attributes specified by ATTRIBUTE_LIST to each target in
  181. .I targets.
  182. In the first form if
  183. .I targets
  184. is empty (ie. a NULL list), then the
  185. list of attributes will apply to all targets in the makefile
  186. (this is equivalent to the common Make construct of \fI".IGNORE :"\fP
  187. but has been modified to the notion of an attribute instead of
  188. a special target).
  189. Not all of the attributes have global meaning.
  190. In particular, .LIBRARY, .SYMBOL, and .UPDATEALL
  191. have no assigned global meaning.
  192. .PP
  193. Any attribute may be used with any target, even with the special targets.
  194. Some combinations are useless (e.g. .INCLUDE .PRECIOUS: ... ),
  195. while others are useful (e.g. .INCLUDE .IGNORE : "file.mk" will not complain
  196. if file.mk cannot be found using the include file search rules,
  197. see the section on SPECIAL TARGETS for a description of .INCLUDE).
  198. If a specified attribute will not be used with the special target a warning
  199. is issued and the attribute is ignored.
  200. .SH MACROS
  201. .B dmake
  202. supports six types of macro assignment.
  203. .sp
  204. .IP "\fBMACRO = LINE\fP" 1.55i
  205. This is the most common and familiar form of macro assignment.  It assigns
  206. LINE literally as the value of MACRO.
  207. Future expansions of MACRO recursively expand its value.
  208. .IP "\fBMACRO *= LINE\fP" 1.55i
  209. This form behaves exactly as the simple '=' form with the exception that if
  210. MACRO already has a value then the assignment is not performed.
  211. .IP "\fBMACRO := LINE\fP" 1.55i
  212. This form differs from the simple '=' form in that it expands LINE
  213. prior to assigning it as the value of MACRO.
  214. Future expansions of MACRO do not recursively expand its value.
  215. .IP "\fBMACRO *:= LINE\fP" 1.55i
  216. This form behaves exactly as the ':=' form with the exception that if
  217. MACRO already has a value then the assignment and expansion are not performed.
  218. .IP "\fBMACRO += LINE\fP" 1.55i
  219. This form of macro assignment allows macro values to grow.  It takes the
  220. literal value of LINE and appends it to the previous value of MACRO separating
  221. the two by a single space.
  222. Future expansions of MACRO recursively expand its value.
  223. .IP "\fBMACRO +:= LINE\fP" 1.55i
  224. This form is similar to the '+=' form except that the value of LINE is expanded
  225. prior to being added to the value of MACRO.
  226. .PP
  227. Macro expressions specified on the command line allow the macro value
  228. to be redefined within the makefile only if the macro is defined using
  229. the '+=' and '+:=' operators.  Other operators will define a macro that cannot
  230. be further modified.
  231. .PP
  232. When \fBdmake\fP defines a non-environment macro it strips leading and
  233. trailing white space from the macro value.
  234. Macros imported from the environment via either the .IMPORT special
  235. target (see the SPECIAL TARGETS section), or the \fB-e\fP, or \fB-E\fP flags
  236. are an exception to this rule.  Their values are
  237. always taken literally and white space is never stripped.
  238. In addition, named macros defined using the .IMPORT special target do
  239. not have their values expanded when they are used within a makefile.
  240. In contrast, environment macros that are imported
  241. due to the specification of the \fB-e\fP or \fB-E\fP flags
  242. are subject to expansion when used.
  243. .PP
  244. To specify a macro expansion
  245. enclose the name in () or {} and precede it with a dollar sign $.
  246. Thus $(TEST) represents an expansion of the macro variable named TEST.
  247. If TEST is
  248. defined then $(TEST) is replaced by its expanded value.  If TEST is not
  249. defined then $(TEST) expands to the NULL string (this is equivalent to
  250. defining a macro as 'TEST=' ).  A short form may be used for single character
  251. named macros.  In this case the parentheses are optional, and $(I) is
  252. equivalent to $I.
  253. Macro expansion is recursive, hence, if the value string contains an expression
  254. representing a macro expansion, the expansion is performed.  Circular macro
  255. expansions are detected and cause an error to be issued.
  256. .PP
  257. When defining a macro the given macro name is first expanded before being used
  258. to define the macro.  Thus it is possible to define macros whose names
  259. depend on values of other macros.  For example, suppose CWD is defined as
  260. .sp
  261. \tCWD = $(PWD:b)
  262. .sp
  263. then the value of $(CWD) is the name of the current directory.
  264. This can be used to define macros specific to this directory, for
  265. example:
  266. .sp
  267. \t_$(CWD).prt = list of files to print...
  268. .sp
  269. The actual name of the defined macro is a function of the current directory.
  270. A construct such as this is useful when processing a hierarchy of directories
  271. using .SETDIR attributed targets and a collection of small distributed
  272. makefile stubs.
  273. .PP
  274. Macro variables may be defined within the makefile, on the command
  275. line, or imported from the environment.
  276. .PP
  277. .B \fBdmake\fR
  278. supports several non-standard macro expansions:
  279. The first is of the form:
  280. .RS
  281. .IP \fI$(macro_name:modifier_list:modifier_list:...)\fR
  282. .RE
  283. .LP
  284. where
  285. .I modifier_list
  286. is chosen from the set { D or d, F or f, B or b, S or s, T or t } and
  287. .RS
  288. .sp
  289. .Is "d "
  290. .Ii "d "
  291. \- directory portion of all path names
  292. .Ii "f"
  293. \- file (including suffix) portion of path names
  294. .Ii "b"
  295. \- file (not including suffix) portion of path names
  296. .Ii "s"
  297. \- simple pattern substitution
  298. .Ii "t"
  299. \- tokenization.
  300. .sp
  301. .RE
  302. Thus if we have the example:
  303. .LP
  304. \ttest = d1/d2/d3/a.out f.out d1/k.out
  305. .LP
  306. The following macro expansions produce the values on the right of '-->' after
  307. expansion.
  308. .RS
  309. .sp
  310. .Is "$(test:s/out/in/:f)  "
  311. .Ii "$(test:d)"
  312. --> d1/d2/d3/ d1/
  313. .Ii "$(test:b)"
  314. --> a f k
  315. .Ii "$(test:f)"
  316. --> a.out f.out k.out
  317. .Ii "${test:db}"
  318. --> d1/d2/d3/a f d1/k
  319. .Ii "${test:s/out/in/:f}"
  320. --> a.in f.in k.in
  321. .Ii $(test:f:t"+")
  322. --> a.out+f.out+k.out
  323. .RE
  324. .PP
  325. If a token ends in a string composed from the value of the macro DIRBRKSTR
  326. (ie. ends in a directory separator string, e.g. '/' in UNIX) and you use the
  327. \fB:d\fP modifier then the expansion returns the directory name less the
  328. final directory separator string.  Thus successive pairs of :d modifiers
  329. each remove a level of directory in the token string.
  330. .PP
  331. The tokenization modifier takes all white space separated tokens from the
  332. macro value and separates them by the quoted separator string.  The separator
  333. string may contain the following escape codes \\a => <bel>,
  334. \&\\b => <backspace>, \\f => <formfeed>, \\n => <nl>, \\r => <cr>,
  335. \&\\t => <tab>, \\v => <vertical tab>, \\" => ", and \\xxx => <xxx> where
  336. xxx is the octal representation of a character.  Thus the
  337. expansion:
  338. .LP
  339. .RS
  340. .nf
  341. $(test:f:t"+\\n")
  342. .RE
  343. produces:
  344. .RS
  345. a.out+
  346. f.out+
  347. k.out
  348. .fi
  349. .RE
  350. .PP
  351. The second non-standard form of macro expansion allows for recursive macros.
  352. It is possible to specify a $(\fImacro_name\fR) or ${\fImacro_name\fR} expansion
  353. where \fImacro_name\fR contains more $( ... ) or ${ ... } macro expansions
  354. itself.
  355. .PP
  356. For example $(CC$(_HOST)$(_COMPILER)) will first expand CC$(_HOST)$(_COMPILER)
  357. to get a result and use that result as the name of the macro to expand.
  358. This is useful for writing a makefile for more than one target
  359. environment.  As an example consider the following hypothetical case. 
  360. Suppose that _HOST and _COMPILER are imported from the environment
  361. and are set to represent the host machine type and the host compiler
  362. respectively.
  363. .RS
  364. .sp
  365. .nf
  366. CFLAGS_VAX_CC = -c -O    # _HOST == "_VAX", _COMPILER == "_CC"
  367. CFLAGS_PC_MSC = -c -ML    # _HOST == "_PC",  _COMPILER == "_MSC"
  368. .sp
  369. # redefine CFLAGS macro as:
  370. .sp
  371. CFLAGS := $(CFLAGS$(_HOST)$(_COMPILER))
  372. .fi
  373. .sp
  374. .RE
  375. This causes CFLAGS to take on a value that corresponds to the
  376. environment in which the make is being invoked.
  377. .PP
  378. The final non-standard macro expansion is of the form:
  379. .RS
  380. .sp
  381. string1{token_list}string2
  382. .RE
  383. .LP
  384. where string1, string2 and token_list are expanded.  After expansion,
  385. string1 is prepended to each token found in token_list and
  386. string2 is appended to each resulting token from the previous prepend.
  387. string1 and string2 are not delimited by white space
  388. whereas the tokens in token_list are.
  389. A null token in the token list 
  390. is specified using "".
  391. Thus using another example we have:
  392. .RS
  393. .sp
  394. .Is "test/{f1  f2}.o    "
  395. .Ii "test/{f1 f2}.o"
  396. --> test/f1.o test/f2.o
  397. .Ii "test/ {f1 f2}.o"
  398. --> test/ f1.o f2.o
  399. .Ii "test/{f1 f2} .o"
  400. --> test/f1 test/f2 .o
  401. .Ii "test/{""f1""  """"}.o"
  402. --> test/f1.o test/.o
  403. .sp
  404. .Ii and
  405. .sp
  406. .Is "test/{d1 d2}/{f1 f2}.o --> "
  407. .Ii "test/{d1 d2}/{f1 f2}.o --> "
  408. test/d1/f1.o test/d1/f2.o
  409. test/d2/f1.o test/d2/f2.o
  410. .sp
  411. .RE
  412. This last expansion is activated only when the first characters of
  413. .I token_list
  414. appear immediately after the opening '{' with no intervening white space.
  415. The reason for this restriction is the following incompatibility with
  416. Bourne Shell recipes.  The line
  417. .RS
  418. .sp
  419. { echo hello;}
  420. .sp
  421. .RE
  422. is valid /bin/sh syntax; while
  423. .RS
  424. .sp
  425. {echo hello;}
  426. .sp
  427. .RE
  428. is not.
  429. Hence the latter triggers the enhanced macro expansion while the former
  430. causes it to be suppressed.
  431. See the SPECIAL MACROS section for a description of the special macros that
  432. \fBdmake\fP defines and understands.
  433. .SH "RULES AND TARGETS"
  434. A makefile contains a series of entries that specify dependencies.
  435. Such entries are called \fItarget/prerequisite\fP or \fIrule\fP definitions.
  436. Each rule definition
  437. is optionally followed by a set of lines that provide a recipe for updating
  438. any targets defined by the rule.
  439. Whenever
  440. .B dmake
  441. attempts to bring a target up to date and an explicit recipe is provided with
  442. a rule defining the target, that recipe is used to update the
  443. target.  A rule definition begins with a line having the following syntax:
  444. .sp
  445. .RS
  446. .nf
  447. \fI<targets>\fP [\fI<attributes>\fP] \fI<ruleop>\fP [\fI<prerequisites>\fP] [;\fI<recipe>\fP]
  448. .fi
  449. .RE
  450. .sp
  451. .I targets
  452. is a non-empty list of targets.  If the target is a
  453. special target (see SPECIAL TARGETS section below) then it must appear alone
  454. on the rule line.  For example:
  455. .sp
  456. .RS
  457. \&.IMPORT .ERROR : ...
  458. .RE
  459. .sp
  460. is not allowed since both .IMPORT and .ERROR are special targets.
  461. Special targets are not used in the construction of the dependency graph and
  462. will not be made.
  463. .PP
  464. .I attributes
  465. is a possibly empty list of attributes.  Any attribute defined in the
  466. ATTRIBUTES section above may be specified.  All attributes will be applied to
  467. the list of named targets in the rule definition.  No other targets will
  468. be affected.
  469. .sp
  470. .IP NOTE: 0.75i
  471. As stated earlier,
  472. if both the target list and prerequisite list are empty but the attributes
  473. list is not, then the specified attributes affect all targets in the makefile.
  474. .sp
  475. .PP
  476. .I ruleop
  477. is a separator which is used to identify the targets from the prerequisites.
  478. Optionally it also provides a facility for modifying the way in which
  479. .B dmake
  480. handles the making of the associated targets.
  481. In its simplest form the operator is a single ':', and need not be separated
  482. by white space from its neighboring tokens.  It may additionally be followed
  483. by any of the modifiers { !, ^, -, : }, where:
  484. .sp
  485. .IP \fB!\fP
  486. says execute the recipe for the associated targets once for each out of date
  487. prerequisite.  Ordinarily the recipe is executed
  488. once for all out of date prerequisites at the same time.
  489. .IP \fB^\fP
  490. says to insert the specified prerequisites, if any, before any
  491. other prerequisites already associated with the specified targets.
  492. In general, it is not useful to specify ^ with an empty
  493. list of prerequisites.
  494. .IP \fB-\fP
  495. says to clear the previous list of prerequisites before adding
  496. the new prerequisites.  Thus,
  497. .sp
  498. \t.SUFFIXES :
  499. .br
  500. \t.SUFFIXES : .a .b
  501. .sp
  502. can be replaced by
  503. .sp
  504. \t.SUFFIXES :- .a .b
  505. .sp
  506. however the old form still works as expected.  NOTE:  .SUFFIXES is ignored by
  507. .B dmake
  508. it is used here simply as an example.
  509. .IP \fB:\fP
  510. When the rule operator is not modified by a second ':'
  511. only one set of rules may be specified for making a target.
  512. Multiple definitions may be used to add to the
  513. list of prerequisites that a target depends on.
  514. However, if a target is multiply defined
  515. only one definition may specify a recipe
  516. for making the target.
  517. .sp
  518. When a target's rule operator is modified by a second ':'
  519. (:: for example) then this definition may not be the only
  520. definition with a recipe for the target.  There may be other :: target
  521. definition lines that specify a different set of prerequisites with a
  522. different recipe for updating the target.  
  523. Any such target is made if any of the definitions
  524. find it to be out of date
  525. with respect to the related prerequisites
  526. and the corresponding recipe is used to update the
  527. target.
  528. .sp 
  529. In the following simple example, each rule has a `::' \fIruleop\fP.  In such an
  530. operator we call the first `:' the operator, and the second `:' the modifier.
  531. .sp
  532. .nf
  533. a.o :: a.c b.h
  534. X   first recipe for making a.o
  535. X
  536. a.o :: a.y b.h
  537. X   second recipe for making a.o
  538. .fi
  539. .sp
  540. If a.o is found to be out of date with respect to a.c then the first recipe
  541. is used to make a.o.  If it is found out of date with respect to a.y then
  542. the second recipe is used.  If a.o is out of date with respect to
  543. b.h then both recipes are invoked to make a.o.
  544. In the last case the order of invocation corresponds to the order in which the
  545. rule definitions appear in the makefile.
  546. .PP
  547. Targets defined using a single `:' operator
  548. with a recipe may be redefined again with a new recipe by using a
  549. `:' operator with a `:' modifier.
  550. This is equivalent to a target having been
  551. initially defined with a rule using a `:' modifier.
  552. Once a target is defined using a `:'
  553. modifier it may not be defined again with a recipe using only the `:' operator
  554. with no `:' modifier.  In both cases the use of a `:' modifier creates a new
  555. list of prerequisites and makes it the current prerequisite list for the target.
  556. The `:' operator with no recipe always modifies the current list
  557. of prerequisites.
  558. Thus assuming each of the following definitions has a recipe attached, then:
  559. .RS
  560. .sp
  561. .nf
  562. joe :  fred ...    (1)
  563. joe :: more ...    (2)
  564. .sp
  565. and
  566. .sp
  567. joe :: fred ...    (3)
  568. joe :: more ...    (4)
  569. .sp
  570. .fi
  571. .RE
  572. are legal and mean:  add the recipe associated with (2), or (4) to the set
  573. of recipes for joe, placing them after existing recipes for
  574. making joe.
  575. The constructs:
  576. .RS
  577. .sp
  578. .nf
  579. joe :: fred ...    (5)
  580. joe : more ...    (6)
  581. .sp
  582. and
  583. .sp
  584. joe : fred ...    (7)
  585. joe : more ...    (8)
  586. .sp
  587. .fi
  588. .RE
  589. are errors since we have two sets of perfectly good recipes for
  590. making the target.
  591. .PP
  592. .I prerequisites
  593. is a possibly empty list of targets that must be brought up to date before
  594. making the current target.
  595. .PP
  596. .I recipe
  597. is a short form and allows the user to specify short rule definitions
  598. on a single line.
  599. It is taken to be the first recipe line in a larger recipe
  600. if additional lines follow the rule definition.
  601. If the semi-colon is present but the recipe line is empty (ie. null string)
  602. then it is taken
  603. to be an empty rule.  Any target so defined causes the
  604. .I "Don't know how to make ..."
  605. error message to be suppressed when
  606. .B dmake
  607. tries to make the target and fails.
  608. This silence is maintained for rules that are terminated
  609. by a semicolon and have no following recipe lines, for targets listed on the
  610. command line, for the first target found in the makefile, and for any target
  611. having no recipe but containing a list of prerequisites (see the COMPATIBILITY
  612. section for an exception to this rule if the AUGMAKE (\fB-A\fP) flag
  613. was specified.
  614. .SH "RECIPES"
  615. The traditional format used by most versions of Make defines the recipe
  616. lines as arbitrary strings that may contain macro expansions.  They
  617. follow a rule definition line and may be spaced
  618. apart by comment or blank lines.
  619. The list of recipe lines defining the recipe is terminated by a new target
  620. definition, a macro definition, or end-of-file.
  621. Each recipe line
  622. .B MUST
  623. begin with a \fB<TAB>\fP character which
  624. may optionally be followed with one or all
  625. of the characters
  626. .IR "'@%+\-'" "."
  627. The
  628. .I "'\-'"
  629. indicates that non-zero exit values (ie. errors)
  630. are to be ignored when this recipe line is executed, the
  631. .I "'\+'"
  632. indicates that the current recipe line is to be executed using the shell, the
  633. .I "'%'"
  634. indicates that
  635. .B dmake
  636. should swap itself out to secondary storage (MSDOS only) before running the
  637. recipe and the
  638. .I "'@'"
  639. indicates that the recipe line should NOT be echoed to the terminal prior to
  640. being executed.  Each switch is off by default
  641. (ie. by default, errors are significant, commands are echoed, no swapping is
  642. done and a shell is
  643. used only if the recipe line contains a character found in the value of the
  644. SHELLMETAS macro).
  645. Global settings activated via command line options or special attribute or
  646. target names may also affect these settings.
  647. An example recipe:
  648. .sp
  649. .RS
  650. .nf
  651. target :
  652. \tfirst recipe line
  653. \tsecond recipe line, executed independently of the first.
  654. \t@a recipe line that is not echoed
  655. \t\-and one that has errors ignored
  656. \t%and one that causes dmake to swap out
  657. \t\+and one that is executed using a shell.
  658. .fi
  659. .RE
  660. .PP
  661. The second and new format of the recipe block begins the block with the
  662. character '[' (the open group character) in the last non-white space
  663. position of a line, and terminates the
  664. block with the character ']' (the close group character)
  665. in the first non-white space position of a line.
  666. In this form each recipe line need not have a leading TAB.  This is
  667. called a recipe group.  Groups so defined are fed intact as a single
  668. unit to a shell for execution whenever the corresponding target needs to
  669. be updated.  If the open group character '[' is preceded
  670. by one or all of \-, @ or %
  671. then they apply to the entire group in the same way that they
  672. apply to single recipe lines.  You may also specify '+' but it is
  673. redundant as a shell is already being used to run the recipe.
  674. See the MAKING TARGETS section for a description of how
  675. .B dmake
  676. invokes recipes.
  677. Here is an example of a group recipe:
  678. .sp
  679. .RS
  680. .nf
  681. target :
  682. [
  683. \tfirst recipe line
  684. \tsecond recipe line
  685. \tall of these recipe lines are fed to a
  686. \tsingle copy of a shell for execution.
  687. ]
  688. .fi
  689. .RE
  690. .sp
  691. .SH "TEXT DIVERSIONS"
  692. .B dmake
  693. supports the notion of text diversions.
  694. If a recipe line contains the macro expression
  695. .RS
  696. .sp
  697. $(mktmp[,[\fIfile\fP][,\fItext\fP]] \fIdata\fP)
  698. .sp
  699. .RE
  700. then all text contained in the \fIdata\fP expression is expanded and
  701. is written to a temporary file.  The return
  702. value of the macro is the name of the temporary file.
  703. .PP
  704. .I data
  705. can be any text and must be separated from the 'mktmp' portion of the
  706. macro name by white-space.  The only restriction on the data text is that
  707. it must contain a balanced number of parentheses of the same kind as are
  708. used to initiate the $(mktmp ...) expression.  For example:
  709. .sp
  710. \t$(mktmp $(XXX))
  711. .sp
  712. is legal and works as expected, but:
  713. .sp
  714. \t$(mktmp text (to dump to file)
  715. .sp
  716. is not legal.  You can achieve what you wish by either defining a macro that
  717. expands to '(' or by using {} in the macro expression; like this:
  718. .sp
  719. \t${mktmp text (to dump to file}
  720. .sp
  721. Since the temporary file is opened when the
  722. macro containing the text diversion expression is expanded, diversions may
  723. now be nested and any diversions that are created as part of ':=' macro
  724. expansions persist for the duration of the
  725. .B dmake
  726. run.
  727. The diversion text may contain
  728. the same escape codes as those described in the MACROS section.
  729. Thus if the \fIdata\fP text is to contain new lines they must be inserted
  730. using the \\n escape sequence.  For example the expression:
  731. .RS
  732. .sp
  733. .nf
  734. all:
  735. X    cat $(mktmp this is a\\n\\
  736. X    test of the text diversion\\n)
  737. .fi
  738. .sp
  739. .RE
  740. is replaced by:
  741. .RS
  742. .sp
  743. cat /tmp/mk12294AA
  744. .sp
  745. .RE
  746. where the temporary file contains two lines both of which are terminated
  747. by a new-line.  If the \fIdata\fP text spans multiple lines in the makefile
  748. then each line must be continued via the use of a \\.
  749. A second more illustrative example generates a response file to an MSDOS
  750. link command:
  751. .RS
  752. .sp
  753. .nf
  754. OBJ = fred.obj mary.obj joe.obj
  755. all : $(OBJ)
  756. X    link @$(mktmp $(^:t"+\\n")\\n)
  757. .fi
  758. .sp
  759. .RE
  760. The result of making `all' in the second example is the command:
  761. .RS
  762. .sp
  763. link @/tmp/mk02394AA
  764. .sp
  765. .RE
  766. where the temporary file contains:
  767. .RS
  768. .sp
  769. .nf
  770. fred.obj+
  771. mary.obj+
  772. joe.obj
  773. .fi
  774. .sp
  775. .RE
  776. The last line of the file is terminated by a new-line which is inserted
  777. due to the \\n found at the end of the \fIdata\fP string.
  778. .PP
  779. If the optional \fIfile\fP specifier is present then its expanded value
  780. is the name of the temporary file to create.  Whenever a $(mktmp ...) macro
  781. is expanded the macro $(TMPFILE) is set to a new temporary file name.  Thus
  782. the construct:
  783. .RS
  784. .sp
  785. $(mktmp,$(TMPFILE) data)
  786. .sp
  787. .RE
  788. is completely equivalent to not specifying the $(TMPFILE) optional argument.
  789. Another example that would be useful for MSDOS users with a Turbo-C compiler
  790. .RS
  791. .sp
  792. $(mktmp,turboc.cfg $(CFLAGS))
  793. .sp
  794. .RE
  795. will place the contents of CFLAGS into a local \fIturboc.cfg\fP file.
  796. The second optional argument, \fItext\fP, if present alters the name
  797. of the value returned by the $(mktmp ...) macro.
  798. .PP
  799. Under MS-DOS text diversions may be a problem.  Many DOS tools require
  800. that path names which contain directories use the \\ character to delimit
  801. the directories.  Some users however wish to use the '/' to delimit pathnames
  802. and use environments that allow them to do so.
  803. The macro USESHELL is set to "yes" if the
  804. current recipe is forced to use a shell via the .USESHELL or '+' directives,
  805. otherwise its value is "no".
  806. The
  807. .B dmake
  808. startup files define the macro DIVFILE whose value is either the
  809. value of TMPFILE or the value of TMPFILE edited to replace any '/' characters
  810. to the appropriate value based on the current shell and whether it will be
  811. used to execute the recipe.
  812. .PP
  813. Previous versions of
  814. .B dmake
  815. defined text diversions using <+, +> strings,
  816. where <+ started a text diversion and +> terminated one.
  817. .B dmake
  818. is backward compatible with this construct if the <+ and +> appear literally
  819. on the same recipe line or in the same macro value string.  In such instances
  820. the expression:
  821. .sp
  822. \t<+data+>
  823. .sp
  824. is mapped to:
  825. .sp
  826. \t$(mktmp data)
  827. .sp
  828. which is fully output compatible with the earlier construct.  <+, +>
  829. constructs whose text spans multiple lines must be converted by hand to use
  830. $(mktmp ...).
  831. .PP
  832. If the environment variable TMPDIR is defined then the
  833. temporary file is placed into the directory specified by that variable.
  834. A makefile can modify the location of temporary files by
  835. defining a macro named TMPDIR and exporting it using the .EXPORT special
  836. target.
  837. .SH "SPECIAL TARGETS"
  838. This section describes the special targets that are recognized by \fBdmake\fP.
  839. Some are affected by attributes and others are not.
  840. .IP \fB.ERROR\fP 1.4i
  841. If defined then the recipe associated with this target is executed
  842. whenever an error condition is detected by \fBdmake\fP.  All attributes that
  843. can be used with any other target may be used with this target.  Any
  844. prerequisites of this target will be brought up to date during its processing.
  845. NOTE:  errors will be ignored while making this target, in extreme cases this
  846. may cause some problems.
  847. .IP \fB.EXPORT\fP 1.4i
  848. All prerequisites associated with this target are assumed to
  849. correspond to macro names and they and their values
  850. are exported to the environment as environment strings at the point in
  851. the makefile at which this target appears.
  852. Any attributes specified with this target are ignored.
  853. Only macros which have been assigned a value in the makefile prior to the
  854. export directive are exported, macros as yet undefined are not exported.
  855. .IP \fB.IMPORT\fP 1.4i
  856. Prerequisite names specified for this target are searched for in the
  857. environment and defined as macros with their value taken from the environment.
  858. If the special name \fB.EVERYTHING\fP is used as a prerequisite name then
  859. all environment variables defined in the environment are imported.
  860. The functionality of the \fB-e\fP flag can be forced by placing the construct
  861. \&\fI.IMPORT : .EVERYTHING\fP at the start of a makefile.  Similarly, by
  862. placing the construct at the end, one can emulate the effect of the \fB-E\fP
  863. command line flag.
  864. If a prerequisite name cannot be found in the environment
  865. an error message is issued.
  866. \&.IMPORT accepts the .IGNORE attribute.  When given, it causes \fBdmake\fP
  867. to ignore the above error.
  868. See the MACROS section for a description of the processing of imported macro
  869. values.
  870. .IP \fB.INCLUDE\fP 1.4i
  871. Parse another makefile just as if it had been located at the point of the
  872. \&.INCLUDE in the current makefile.  The list of prerequisites gives the list of
  873. makefiles to try to read.  If the list contains multiple makefiles then they
  874. are read in order from left to right.  The following search rules are used
  875. when trying to locate the file.  If the filename is surrounded by " or just
  876. by itself then it is searched for in the current directory.  If it is not
  877. found it is then searched for in each of the directories specified for the
  878. \&.INCLUDEDIRS special target.  If the file name is surrounded by < and >, (ie.
  879. <my_spiffy_new_makefile>) then it is searched for only in the directories
  880. given by the .INCLUDEDIRS special target.  In both cases if the file name is a
  881. fully qualified name starting at the root of the file system then it is only
  882. searched for once, and the .INCLUDEDIRS list is ignored.  .INCLUDE accepts
  883. the .IGNORE and .SETDIR attributes.  If .IGNORE attribute is given and the file
  884. cannot be found then \fBdmake\fP continues processing,
  885. otherwise an error message is generated.
  886. The .SETDIR attribute causes
  887. .B dmake
  888. to change directories to the specified directory prior to attempting the
  889. include operation.
  890. .IP \fB.INCLUDEDIRS\fP 1.4i
  891. The list of prerequisites specified for this target defines the set of
  892. directories to search when trying to include a makefile.
  893. .IP \fB.KEEP_STATE\fP 1.4i
  894. This special target is a synonym for the macro definition
  895. .sp
  896. \&\t.KEEP_STATE := _state.mk
  897. .sp
  898. It's effect is to turn on STATE keeping and to define \fI_state.mk\fP
  899. as the state file.
  900. .IP \fB.MAKEFILES\fP 1.4i
  901. The list of prerequisites is the set of files to try to read as the default
  902. makefile.  By default this target is defined as: 
  903. .sp
  904. \t\&.MAKEFILES : makefile.mk Makefile makefile
  905. .sp
  906. .IP \fB.SOURCE\fP 1.4i
  907. The prerequisite list of this target defines a set of directories to check
  908. when trying to locate a target file name.  See the section on BINDING of
  909. targets for more information.
  910. .IP \fB.SOURCE.suff\fP 1.4i
  911. The same as .SOURCE, except that the .SOURCE.suff list is searched first when
  912. trying to locate a file matching the a target whose name ends in the suffix
  913. \&.suff.
  914. .IP \fB.REMOVE\fP 1.4i
  915. The recipe of this target is used whenever \fBdmake\fP needs to remove
  916. intermediate targets that were made but do not need to be kept around.
  917. Such targets result from the application of transitive closure on the
  918. dependency graph.
  919. .PP
  920. In addition to the special targets above,
  921. several other forms of targets are recognized and are considered special,
  922. their exact form and use is defined in the sections that follow.
  923. .SH "SPECIAL MACROS"
  924. .B dmake
  925. defines a number of special macros.  They are divided into three classes:
  926. control macros, run-time macros, and function macros.
  927. The control macros are used by
  928. .B dmake
  929. to configure its actions, and are the preferred method of doing so.
  930. In the case when a control macro has the same function as a special 
  931. target or attribute they share the same name as the special target or
  932. attribute.
  933. The run-time macros are defined when
  934. .B dmake
  935. makes targets and may be used by the user inside recipes.
  936. The function macros provide higher level functions dealing with macro
  937. expansion and diversion file processing.
  938. .SH "CONTROL MACROS"
  939. To use the control macros simply assign them a value just like any other
  940. macro.  The control macros are divided into three groups:
  941. string valued macros, character valued macros, and boolean valued macros.
  942. .PP
  943. The following are all of the string valued macros.
  944. This list is divided into two groups.  The first group gives the string
  945. valued macros that are defined internally and cannot be directly set by the
  946. user.
  947. .IP \fBDIRBRKSTR\fP 1.4i
  948. Contains the string of chars used to terminate
  949. the name of a directory in a pathname.
  950. Under UNIX its value is "/", under MSDOS its value is "/\\:".
  951. .IP \fBINCDEPTH\fP 1.4i
  952. This macro's value is a string of digits representing
  953. the current depth of makefile inclusion.
  954. In the first makefile level this value is zero.
  955. .IP \fBMFLAGS\fP 1.4i
  956. Is the list of flags
  957. that were given on the command line including a leading switch character.
  958. The -f flag is not included in this list.
  959. .IP \fBMAKECMD\fP 1.4i
  960. Is the name with which \fBdmake\fP was invoked.
  961. .IP \fBMAKEDIR\fP 1.4i
  962. Is the full path to the initial directory in which
  963. .B dmake
  964. was invoked.
  965. .IP \fBMAKEFILE\fP 1.4i
  966. Contains the string "-f \fImakefile\fP" where, \fImakefile\fP is the name
  967. of initial user makefile that was first read.
  968. .IP \fBMAKEFLAGS\fP 1.4i
  969. Is the same as $(MFLAGS) but has no leading switch
  970. character. (ie. MFLAGS = -$(MAKEFLAGS))
  971. .IP \fBMAKEMACROS\fP 1.4i
  972. Contains the complete list of macro expressions that were specified on the
  973. command line.
  974. .IP \fBMAKETARGETS\fP 1.4i
  975. Contains the name(s) of the target(s), if any, that were
  976. specified on the command line.
  977. .IP \fBMAXPROCESSLIMIT\fP 1.4i
  978. Is a numeric string representing the maximum number of processes that 
  979. \fBdmake\fP can use when making targets using parallel mode.
  980. .IP \fBNULL\fP 1.4i
  981. Is permanently defined to be the NULL string.
  982. This is useful when comparing a conditional expression to an NULL value.
  983. .IP \fBPWD\fP 1.4i
  984. Is the full path to the
  985. current directory in which make is executing.
  986. .IP \fBTMPFILE\fP 1.4i
  987. Is set to the name of the most recent temporary file opened by \fBdmake\fP.
  988. Temporary files are used for text diversions and for group recipe processing.
  989. .IP \fBTMD\fP 1.4i
  990. Stands for "To Make Dir", and
  991. is the path from the present directory (value of $(PWD)) to the directory
  992. that \fBdmake\fP was started up in (value of $(MAKEDIR)).
  993. This macro is modified when .SETDIR attributes are processed.
  994. .IP \fBUSESHELL\fP 1.4i
  995. The value of this macro is set to "yes" if the current recipe is forced to
  996. use a shell for its execution via the .USESHELL or '+' directives, its value
  997. is "no" otherwise.
  998. .sp
  999. .PP
  1000. The second group of string valued macros control
  1001. .B dmake
  1002. behavior and may be set by the user.
  1003. .IP \fB.SETDIR\fP 1.6i
  1004. If this macro is assigned a value then \fBdmake\fP will
  1005. change to the directory given by that value before making any targets.
  1006. .IP \fBAUGMAKE\fP 1.6i
  1007. If set to a non NULL value will enable the transformation of special
  1008. meta targets to support special AUGMAKE inferences (See the COMPATIBILITY
  1009. section).
  1010. .IP \fBDIRSEPSTR\fP 1.6i
  1011. Contains the string that is used to separate directory components when
  1012. path names are constructed.  It is defined with a default value at startup.
  1013. .IP \fBDIVFILE\fP 1.6i
  1014. Is defined in the startup file and gives the name that should be returned for
  1015. the diversion file name when used in
  1016. $(mktmp ...) expansions, see the TEXT DIVERSION section for details.
  1017. .IP \fB.KEEP_STATE\fP 1.6i
  1018. Assigning this macro a value tells
  1019. .B dmake
  1020. the name of the state file to use and turns on the keeping of state
  1021. information for any targets that are brought up to date by the make.
  1022. .IP \fBGROUPFLAGS\fP 1.6i
  1023. This macro gives the set of flags to pass to the shell when
  1024. invoking it to execute a group recipe.  The value of the macro is the
  1025. list of flags with a leading switch indicator.  (ie. `-' under UNIX)
  1026. .IP \fBGROUPSHELL\fP 1.6i
  1027. This macro defines the full
  1028. path to the executable image to be used as the shell when
  1029. processing group recipes.  This macro must be defined if group recipes are
  1030. used.  It is assigned a default value in the startup makefile.  Under UNIX
  1031. this value is /bin/sh.
  1032. .IP \fBGROUPSUFFIX\fP 1.6i
  1033. If defined, this macro gives the string to use as a suffix
  1034. when creating group recipe files to be handed to the command interpreter.
  1035. For example, if it is defined as .sh, then all
  1036. temporary files created by \fBdmake\fP will end in the suffix .sh.
  1037. Under MSDOS if you are using command.com as your GROUPSHELL, then this suffix
  1038. must be set to .bat in order for group recipes to function correctly.
  1039. The setting of GROUPSUFFIX and GROUPSHELL is done automatically for
  1040. command.com in the startup.mk files.
  1041. .IP \fBMAKE\fP 1.6i
  1042. Is defined in the startup file by default.
  1043. The string $(MAKE) is recognized when
  1044. using the -n option for single line recipes.  Initially this macro is defined
  1045. to have the value "$(MAKECMD) $(MFLAGS)".
  1046. .IP \fBMAKESTARTUP\fP 1.6i
  1047. This macro defines the full path to the initial startup
  1048. makefile.  Use the \fB-V\fP command line option to discover its initial
  1049. value.
  1050. .IP \fBMAXLINELENGTH\fP 1.6i
  1051. This macro defines the maximum size of a single line of
  1052. makefile input text.  The size is specified as a number, the default value
  1053. is defined internally and is shown via the \fB-V\fP option.
  1054. A buffer of this size plus 2 is allocated for reading makefile text.  The
  1055. buffer is freed before any targets are made, thereby allowing files containing
  1056. long input lines to be processed without consuming memory during the actual
  1057. make.
  1058. .IP \fBMAXPROCESS\fP 1.6i
  1059. Specify the maximum number of child processes to use when making targets.
  1060. The default value of this macro is "1" and its value cannot exceed the value
  1061. of the macro MAXPROCESSLIMIT.  Setting the value of MAXPROCESS on the command
  1062. line or in the makefile is equivalent to supplying a corresponding value to
  1063. the -P flag on the command line.
  1064. .IP \fBPREP\fP 1.6i
  1065. This macro defines the number of iterations to be expanded
  1066. automatically when processing % rule definitions of the form:
  1067. .sp
  1068. % : %.suff
  1069. .sp
  1070. See the sections on PERCENT(%) RULES for details on how PREP is used.
  1071. .IP \fBSHELL\fP 1.6i
  1072. This macro defines the full path to the executable
  1073. image to be used as the shell when
  1074. processing single line recipes.  This macro must be defined if recipes
  1075. requiring the shell for execution are to be used.
  1076. It is assigned a default value in the startup makefile.
  1077. Under UNIX this value is /bin/sh.
  1078. .IP \fBSHELLFLAGS\fP 1.6i
  1079. SHAR_EOF
  1080. true || echo 'restore of dmake/man/dmake.tf failed'
  1081. fi
  1082. echo 'End of part 19, continue with part 20'
  1083. echo 20 > _shar_seq_.tmp
  1084. exit 0
  1085.  
  1086. exit 0 # Just in case...
  1087. -- 
  1088. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1089. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1090. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1091. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1092.