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

  1. Newsgroups: comp.sources.misc
  2. subject: v14i018: dmake version 3.5 part 8/21
  3. From: dvadura@watdragon.waterloo.edu (Dennis Vadura)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 14, Issue 18
  7. Submitted-by: dvadura@watdragon.waterloo.edu (Dennis Vadura)
  8. Archive-name: dmake/part08
  9.  
  10. #!/bin/sh
  11. # this is part 8 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file man/dmake.tf continued
  14. #
  15. CurArch=8
  16. if test ! -r s2_seq_.tmp
  17. then echo "Please unpack part 1 first!"
  18.      exit 1; fi
  19. ( read Scheck
  20.   if test "$Scheck" != $CurArch
  21.   then echo "Please unpack part $Scheck next!"
  22.        exit 1;
  23.   else exit 0; fi
  24. ) < s2_seq_.tmp || exit 1
  25. echo "x - Continuing file man/dmake.tf"
  26. sed 's/^X//' << 'SHAR_EOF' >> man/dmake.tf
  27. Xand
  28. X.sp
  29. Xjoe : fred ...    (7)
  30. Xjoe : more ...    (8)
  31. X.sp
  32. X.fi
  33. X.RE
  34. Xare errors since we have two sets of perfectly good recipes for
  35. Xmaking the target.
  36. X.PP
  37. X.I prerequisites
  38. Xis a possibly empty list of targets that must be brought up to date before
  39. Xmaking the current target.
  40. X.PP
  41. X.I recipe
  42. Xis a short form and allows the user to specify short rule definitions
  43. Xon a single line.
  44. XIt is taken to be the first recipe line in a larger recipe
  45. Xif additional lines follow the rule definition.
  46. XIf the semi-colon is present but the recipe line is empty (ie. null string)
  47. Xthen it is taken
  48. Xto be an empty rule.  Any target so defined causes the
  49. X.I "Don't know how to make ..."
  50. Xerror message to be suppressed when
  51. X.B dmake 
  52. Xtries to make the target and fails.
  53. XThis silence is maintained for rules that are terminated
  54. Xby a semicolon and have no following recipe lines, for targets listed on the
  55. Xcommand line, and for the first target found in the makefile.
  56. X.SH "RECIPES"
  57. XThe traditional format used by most versions of Make defines the recipe
  58. Xlines as arbitrary strings that may contain macro expansions.  They
  59. Xfollow a rule definition line and may be spaced
  60. Xapart by comment or blank lines.
  61. XThe list of recipe lines defining the recipe is terminated by a new target
  62. Xdefinition, a macro definition, or end-of-file.
  63. XEach recipe line
  64. X.B MUST
  65. Xbegin with a \fB<TAB>\fP character which
  66. Xmay optionally be followed with one or both
  67. Xof the characters
  68. X.IR "'\-@'" "."
  69. XThe
  70. X.I "'\-'"
  71. Xindicates that non-zero exit values (ie. errors)
  72. Xare to be ignored when this recipe line is executed, and the
  73. X.I "'@'"
  74. Xindicates that the recipe line should NOT be echoed to the terminal prior to
  75. Xbeing executed.  Both switches are off by default
  76. X(ie. by default, errors are significant and commands are echoed).
  77. XGlobal settings activated via command line options or special attribute or
  78. Xtarget names may also affect these settings.
  79. XAn example recipe:
  80. X.sp
  81. X.RS
  82. X.nf
  83. Xtarget :
  84. X\tfirst recipe line
  85. X\tsecond recipe line, executed independently of the first.
  86. X\t@a recipe line that is not echoed
  87. X\t\-and one that has errors ignored.
  88. X.fi
  89. X.RE
  90. X.PP
  91. XThe second and new format of the recipe block begins the block with the
  92. Xcharacter '[' (the open group character) in the last non-white space
  93. Xposition of a line, and terminates the
  94. Xblock with the character ']' (the close group character)
  95. Xin the first non-white space position of a line.
  96. XIn this form each recipe line need not have a leading TAB.  This is
  97. Xcalled a recipe group.  Groups so defined are fed intact as a single
  98. Xunit to a shell for execution whenever the corresponding target needs to
  99. Xbe updated.  If the open group character '[' is preceded
  100. Xby one or both
  101. Xof \- or @ then they apply to the entire group in the same way that the \-
  102. Xand @ apply to single recipe lines.
  103. XSee the MAKING TARGETS section for a description of how
  104. X.B dmake
  105. Xinvokes recipes.
  106. XHere is an example of a group recipe:
  107. X.sp
  108. X.RS
  109. X.nf
  110. Xtarget :
  111. X[
  112. X\tfirst recipe line
  113. X\tsecond recipe line
  114. X\tall of these recipe lines are fed to a
  115. X\tsingle copy of a shell for execution.
  116. X]
  117. X.fi
  118. X.RE
  119. X.sp
  120. X.SH "TEXT DIVERSIONS"
  121. X.B dmake
  122. Xsupports the notion of text diversions in recipes.  If a recipe line contains
  123. Xthe character sequence \fB<+\fP it is recognized and a text diversion is
  124. Xstarted.  This causes
  125. X.B dmake
  126. Xto open a temporary file and to copy into that file all text that is found
  127. Xup to but not including the text diversion termination sequence \fB+>\fP.
  128. XAny diversions started with a \fB<+\fP must be terminated with a
  129. Xcorresponding \fB+>\fP; the terminating \fB+>\fP may appear on the same
  130. Xor on a subsequent recipe line.  Nesting of diversions is not
  131. Xsupported.  New\-lines provided in the recipe that forms the text of a
  132. Xdiversion are inserted into the resulting temporary file at the
  133. Xappropriate locations.  The diversion text may contain
  134. Xthe same escape codes as those described in the MACROS section.
  135. X.PP
  136. XThe primary use of diversions is on systems (like MSDOS) that do not
  137. Xsupport long command lines.  The diversion makes it possible to produce
  138. Xa temporary file containing the arguments which can then be supplied to
  139. Xa utility via the temporary file.
  140. X.PP
  141. XHere are some examples:
  142. X.RS
  143. X.sp
  144. X.nf
  145. Xall:
  146. X    cat <+this is a
  147. X    test of the text diversion+>
  148. X.fi
  149. X.sp
  150. X.RE
  151. XThe above will cause
  152. X.B dmake
  153. Xto execute the command:
  154. X.RS
  155. X.sp
  156. Xcat /tmp/mk12294AA
  157. X.sp
  158. X.RE
  159. Xand the contents of the temporary file will be the text found between the
  160. X.B <+
  161. Xand
  162. X.B +>
  163. Xstrings of the above recipe.
  164. X.RS
  165. X.sp
  166. X.nf
  167. XOBJ = fred.obj mary.obj joe.obj
  168. Xall : $(OBJ)
  169. X    link @<+$(^:t"+\\n")\\n+>
  170. X.fi
  171. X.sp
  172. X.RE
  173. XThe result of making `all' in the second example is the command:
  174. X.RS
  175. X.sp
  176. Xlink @/tmp/mk02394AA
  177. X.sp
  178. X.RE
  179. Xwhere the temporary file contains:
  180. X.RS
  181. X.sp
  182. X.nf
  183. Xfred.obj+
  184. Xmary.obj+
  185. Xjoe.obj
  186. X.fi
  187. X.sp
  188. X.RE
  189. XThe last line of the file is terminated by a new-line which is inserted
  190. Xdue to the \\n placed immediately before the \fB+>\fP text diversion
  191. Xterminator.
  192. X.PP
  193. XIf the environment variable TMPDIR is defined then the
  194. Xtemporary file is created in the directory specified by that variable.
  195. XA makefile can change where temporary files are created by
  196. Xdefining a macro named TMPDIR and exporting it using the .EXPORT special
  197. Xtarget.
  198. X.SH "SPECIAL TARGETS"
  199. XThis section describes the special targets that are recognized by \fBdmake\fP.
  200. XSome are affected by attributes and others are not.
  201. X.IP \fB.ERROR\fP 1.4i
  202. XIf defined then the recipe associated with this target is executed
  203. Xwhenever an error condition is detected by \fBdmake\fP.  All attributes that
  204. Xcan be used with any other target may be used with this target.  Any
  205. Xprerequisites of this target will be brought up to date during it's processing.
  206. XNOTE:  errors will be ignored while making this target, in extreme cases this
  207. Xmay cause some problems.
  208. X.IP \fB.EXPORT\fP 1.4i
  209. XAll prerequisites associated with this target are assumed to
  210. Xcorrespond to macro names and they and their values
  211. Xare exported to the environment as environment strings at the point in
  212. Xthe makefile at which this target appears.
  213. XAny attributes specified with this target are ignored.
  214. XOnly macros which have been assigned a value in the makefile prior to the
  215. Xexport directive are exported, macros as yet undefined are not exported.
  216. X.IP \fB.IMPORT\fP 1.4i
  217. XPrerequisite names specified for this target are searched for in the
  218. Xenvironment and defined as macros with their value taken from the environment.
  219. XIf the name cannot be found in the environment an error message is issued.
  220. X\&.IMPORT accepts the .IGNORE attribute.  When given, it causes \fBdmake\fP
  221. Xto ignore the above error.
  222. XSee the MACROS section for a description of the processing of imported macro
  223. Xvalues.
  224. X.IP \fB.INCLUDE\fP 1.4i
  225. XParse another makefile just as if it had been located at the point of the
  226. X\&.INCLUDE in the current makefile.  The list of prerequisites gives the list of
  227. Xmakefiles to try to read.  If the list contains multiple makefiles then they
  228. Xare read in order from left to right.  The following search rules are used
  229. Xwhen trying to locate the file.  If the filename is surrounded by " or just
  230. Xby itself then it is searched for in the current directory.  If it is not
  231. Xfound it is then searched for in each of the directories specified for the
  232. X\&.INCLUDEDIRS special target.  If the file name is surrounded by < and >, (ie.
  233. X<my_spiffy_new_makefile>) then it is searched for only in the directories
  234. Xgiven by the .INCLUDEDIRS special target.  In both cases if the file name is a
  235. Xfully qualified name starting at the root of the file system then it is only
  236. Xsearched for once, and the .INCLUDEDIRS list is ignored.  .INCLUDE accepts
  237. Xthe .IGNORE and .SETDIR attributes.  If .IGNORE attribute is given and the file
  238. Xcannot be found then \fBdmake\fP continues processing,
  239. Xotherwise an error message is generated.
  240. XThe .SETDIR attribute causes
  241. X.B dmake
  242. Xto change directories to the specified directory prior to attempting the
  243. Xinclude operation.
  244. X.IP \fB.INCLUDEDIRS\fP 1.4i
  245. XThe list of prerequisites specified for this target defines the set of
  246. Xdirectories to search when trying to include a makefile.
  247. X.IP \fB.MAKEFILES\fP 1.4i
  248. XThe list of prerequisites is the set of files to try to read as the default
  249. Xmakefile.  By default this target is defined as: 
  250. X.sp
  251. X\t\&.MAKEFILES : makefile.mk Makefile makefile
  252. X.sp
  253. X.IP \fB.SOURCE\fP 1.4i
  254. XThe prerequisite list of this target defines a set of directories to check
  255. Xwhen trying to locate a target file name.  See the section on BINDING of
  256. Xtargets for more information.
  257. X.IP \fB.SOURCE.suff\fP 1.4i
  258. XThe same as .SOURCE, except that the .SOURCE.suff list is searched first when
  259. Xtrying to locate a file matching the a target whose name ends in the suffix
  260. X\&.suff.
  261. X.IP \fB.REMOVE\fP 1.4i
  262. XThe recipe of this target is used whenever \fBdmake\fP needs to remove
  263. Xintermediate targets that were made but do not need to be kept around.
  264. XSuch targets result from the application of transitive closure on the
  265. Xdependency graph.
  266. X.PP
  267. XIn addition to the special targets above,
  268. Xseveral other forms of targets are recognized and are considered special,
  269. Xtheir exact form and use is defined in the sections that follow.
  270. X.SH "SPECIAL MACROS"
  271. X.B dmake
  272. Xdefines a number of special macros.  They are divided into two classes:
  273. Xcontrol macros and run-time macros.  The control macros are used by
  274. X.B dmake
  275. Xto configure it's actions, and are the preferred method of doing so.
  276. XIn the case when a control macro has the same function as a special 
  277. Xtarget or attribute they share the same name as the special target or
  278. Xattribute.
  279. XThe run-time macros are defined when
  280. X.B dmake
  281. Xmakes targets and may be used by the user inside recipes.
  282. XWe first give the control macros and their meanings.
  283. X.PP
  284. XTo use the control macros simply assign them a value just like any other
  285. Xmacro.  The control macros are divided into three groups:
  286. Xstring valued macros, character valued macros, and boolean valued macros.
  287. X.PP
  288. XThe following are all of the string valued macros.
  289. XThis list is also divided into three groups.  The first group gives the string
  290. Xvalued macros that are defined internally and cannot be directly set by the
  291. Xuser.
  292. X.IP \fBDIRBRKSTR\fP 1.4i
  293. XContains the string of chars used to terminate
  294. Xthe name of a directory in a pathname.
  295. XUnder UNIX it's value is "/", under MSDOS it's value is "/\\:".
  296. X.IP \fBINCDEPTH\fP 1.4i
  297. XThis macro's value is a string of digits representing
  298. Xthe current depth of makefile inclusion.
  299. XIn the first makefile level this value is zero.
  300. X.IP \fBMFLAGS\fP 1.4i
  301. XIs the list of flags
  302. Xthat were given on the command line including a leading switch character.
  303. XThe -f flag is not included in this list.
  304. X.IP \fBMAKECMD\fP 1.4i
  305. XIs the name with which \fBdmake\fP was invoked.
  306. X.IP \fBMAKEDIR\fP 1.4i
  307. XIs the full path to the initial directory in which
  308. X.B dmake
  309. Xwas invoked.
  310. X.IP \fBMAKEFILE\fP 1.4i
  311. XContains the string "-f \fImakefile\fP" where, \fImakefile\fP is the name
  312. Xof initial user makefile that was first read.
  313. X.IP \fBMAKEFLAGS\fP 1.4i
  314. XIs the same as $(MFLAGS) but has no leading switch
  315. Xcharacter. (ie. MFLAGS = -$(MAKEFLAGS))
  316. X.IP \fBMAKEMACROS\fP 1.4i
  317. XContains the complete list of macro expressions that were specified on the
  318. Xcommand line.
  319. X.IP \fBMAXPROCESSLIMIT\fP 1.4i
  320. XIs a numeric string representing the maximum number of processes that 
  321. X\fBdmake\fP can use when making targets in the parallel mode.
  322. X.IP \fBNULL\fP 1.4i
  323. XIs permanently defined to be the NULL string.
  324. XThis is useful when comparing a conditional expression to an NULL value.
  325. X.IP \fBPWD\fP 1.4i
  326. XIs the full path to the
  327. Xcurrent directory in which make is executing.
  328. X.IP \fBTMD\fP 1.4i
  329. XStands for "To Make Dir", and
  330. Xis the path from the present directory (value of $(PWD)) to the directory
  331. Xthat \fBdmake\fP was started up in (value of $(MAKEDIR)).
  332. XThis macro is modified when .SETDIR attributes are processed.
  333. X.sp
  334. X.PP
  335. XThe second group of string valued macros control
  336. X.B dmake
  337. Xbehavior and may be set by the user.
  338. X.IP \fB.SETDIR\fP 1.6i
  339. XIf this macro is assigned a value then \fBdmake\fP will
  340. Xchange to the directory given by that value before making any targets.  This
  341. Xmacro is equivalent to the .SETDIR attribute.  Thus the two lines:
  342. X.sp
  343. X\&.SETDIR=fred/hello :
  344. X.sp
  345. X\&.SETDIR := fred/hello
  346. X.sp
  347. Xare completely equivalent.  The difference being that the first is processed
  348. Xas a rule definition and the other as a macro.
  349. X.IP \fBAUGMAKE\fP 1.6i
  350. XIf set to a non NULL value will enable the transformation of special
  351. Xmeta targets to support special AUGMAKE inferences.
  352. X.IP \fBDIRSEPSTR\fP 1.6i
  353. XContains the string that is used to separate directory components when
  354. Xpath names are constructed.  It is defined with a default value at startup.
  355. X.IP \fBGROUPFLAGS\fP 1.6i
  356. XThis macro gives the set of flags to pass to the shell when
  357. Xinvoking it to execute a group recipe.  The value of the macro is the
  358. Xlist of flags with a leading switch indicator.  (ie. `-' under UNIX)
  359. X.IP \fBGROUPSHELL\fP 1.6i
  360. XThis macro defines the full
  361. Xpath to the executable image to be used as the shell when
  362. Xprocessing group recipes.  This macro must be defined if group recipes are
  363. Xused.  It is assigned a default value in the startup makefile.  Under UNIX
  364. Xthis value is /bin/sh.
  365. X.IP \fBGROUPSUFFIX\fP 1.6i
  366. XIf defined, this macro gives the string to use as a suffix
  367. Xwhen creating group recipe files to be handed to the command interpreter.
  368. XFor example, if it is defined as .sh, then all
  369. Xtemporary files created by \fBdmake\fP will end in the suffix .sh.
  370. XUnder MSDOS if you are using command.com as your GROUPSHELL, then this suffix
  371. Xmust be set to .bat in order for group recipes to work correctly.
  372. X.IP \fBMAKE\fP 1.6i
  373. XIt is defined in the startup file by default.
  374. XThe string $(MAKE) is recognized when
  375. Xusing the -n option for single line recipes.  Initially this macro is defined
  376. Xto have the value "$(MAKECMD) $(MFLAGS)".
  377. X.IP \fBMAKESTARTUP\fP 1.6i
  378. XThis macro defines the full path to the initial startup
  379. Xmakefile.  Use the \fB-V\fP command line option to discover it's initial
  380. Xvalue.
  381. X.IP \fBMAXLINELENGTH\fP 1.6i
  382. XThis macro defines the maximum size of a single line of
  383. Xmakefile input text.  The size is specified as a number, the default value
  384. Xis defined internally and is shown via the \fB-V\fP option.
  385. XA buffer of this size plus 2 is allocated for reading makefile text.  The
  386. Xbuffer is freed before any targets are made, thereby allowing files containing
  387. Xlong input lines to be processed without consuming memory during the actual
  388. Xmake.
  389. X.IP \fBMAXPROCESS\fP 1.6i
  390. XSpecify the maximum number of child processes to use when making targets.
  391. XThe default value of this macro is "1" and it's value cannot exceed the value
  392. Xof the macro MAXPROCESSLIMIT.  Setting the value of MAXPROCESS on the command
  393. Xline or in the makefile is equivalent to supplying a corresponding value to
  394. Xthe -P flag on the command line.
  395. X.IP \fBPREP\fP 1.6i
  396. XThis macro defines the number of iterations to be expanded
  397. Xautomatically when processing % rule definitions of the form:
  398. X.sp
  399. X% : %.suff
  400. X.sp
  401. XSee the sections on PERCENT(%) RULES for details on how PREP is used.
  402. X.IP \fBSHELL\fP 1.6i
  403. XThis macro defines the full path to the executable
  404. Ximage to be used as the shell when
  405. Xprocessing single line recipes.  This macro must be defined if recipes
  406. Xrequiring the shell for execution are to be used.
  407. XIt is assigned a default value in the startup makefile.
  408. XUnder UNIX this value is /bin/sh.
  409. X.IP \fBSHELLFLAGS\fP 1.6i
  410. XThis macro gives the set of flags to pass to the shell when
  411. Xinvoking it to execute a single line recipe.  The value of the macro is the
  412. Xlist of flags with a leading switch indicator.  (ie. `-' under UNIX)
  413. X.IP \fBSHELLMETAS\fP 1.6i
  414. XEach time
  415. X.B dmake
  416. Xexecutes a single recipe line (not a group recipe) the line is
  417. Xsearched for any occurrence of a character defined in the value of SHELLMETAS.
  418. XIf such a character is found the recipe line is defined to require a shell
  419. Xto ensure it's correct execution.  In such instances
  420. Xa shell is used to invoke the recipe line.
  421. XIf no match is found the recipe line is executed without the use of a shell.
  422. X.sp
  423. X.PP
  424. XThere is only one character valued macro defined by \fBdmake\fP:
  425. X\fBSWITCHAR\fP contains the switch character used
  426. Xto introduce options on command lines.  On UNIX it's value is '-', on
  427. XMSDOS it's value may be '/' or '-'.
  428. XThe macro is internally defined and is not user setable.
  429. X.PP
  430. XAll boolean macros currently understood by 
  431. X.B dmake
  432. Xcorrespond directly to the previously defined attributes.
  433. XThese macros provide
  434. Xa second way to apply global attributes, and represent the
  435. Xpreferred method of doing so.  They are used by assigning them a
  436. Xvalue.  If the value is not a NULL string then the boolean condition
  437. Xis set to on.
  438. XIf the value is a NULL string then the condition is set to off.
  439. XThere are five conditions defined and they correspond directly to the
  440. Xattributes of the same name.  Their meanings are defined in the ATTRIBUTES
  441. Xsection above.
  442. XThe macros are:
  443. X\&\fB.EPILOG\fP,
  444. X\&\fB.IGNORE\fP,
  445. X\&\fB.PRECIOUS\fP,
  446. X\&\fB.PROLOG\fP, and
  447. X\&\fB.SILENT\fP.
  448. XAssigning any of these a non NULL value will turn on the corresponding
  449. Xattribute on a global scale.
  450. X.PP
  451. XThe second class of macros is the run-time macros.  These macros are defined
  452. Xwhen \fBdmake\fP is making targets, and may take on different values for each
  453. Xtarget.  \fB$@\fP is defined to be the full target name, \fB$?\fP is the
  454. Xlist of all out of date prerequisites, \fB$&\fP is the list of all
  455. Xprerequisites, \fB$>\fP is the name of the library if the current target is a
  456. Xlibrary member,
  457. X\fB$<\fP is the list of prerequisites specified in the current rule (this
  458. Xincludes any inferred prerequisites),
  459. X\fB$*\fP is defined as
  460. X\fB$(@:db)\fP when making targets with explicit recipes and is defined as the
  461. Xvalue of % when making targets whose recipe is the result of an inference.
  462. XIn the first case \fB$*\fP is the target name with no suffix,
  463. Xand in the latter is the value of the matched % pattern from
  464. Xthe associated %-rule.
  465. X\fB$^\fP expands to the set of out of date prerequisites taken from the
  466. Xcurrent value of \fB$<\fP.
  467. XIn addition to these,
  468. X\fB$$\fP expands to $, \fB{{\fP expands to {, \fB}}\fP expands to }, and the
  469. Xstrings \fB<+\fP and \fB+>\fP are reserved for use in recipe scripts
  470. Xfor starting and terminating a text diversion respectively.
  471. X.PP
  472. XThe difference between $? and $^ can best be illustrated by an example,
  473. Xconsider:
  474. X.RS
  475. X.sp
  476. X.nf
  477. Xfred.out : joe amy hello
  478. X\trules for making fred
  479. X
  480. Xfred.out : my.c your.h his.h her.h      # more prerequisites
  481. X.fi
  482. X.sp
  483. X.RE
  484. XAssume joe, amy, and my.c are newer then fred.out.  When
  485. X.B dmake
  486. Xexecutes the recipe for making fred.out the values of the following macros
  487. Xwill be:
  488. X.RS
  489. X.sp
  490. X.nf
  491. X.Is "$@ "
  492. X.Ii "$@"
  493. X--> fred.out
  494. X.Ii "$*"
  495. X--> fred
  496. X.Ii "$?"
  497. X--> joe amy my.c  # note the difference between $? and $^
  498. X.Ii "$^"
  499. X--> joe amy
  500. X.Ii "$<"
  501. X--> joe amy hello
  502. X.Ii "$&"
  503. X--> joe amy hello my.c your.h his.h her.h
  504. X.fi
  505. X.sp
  506. X.RE
  507. X.SH "DYNAMIC PREREQUISITES"
  508. X.B dmake
  509. Xlooks for prerequisites whose names contain macro expansions during target
  510. Xprocessing.  Any such prerequisites are expanded and the result of the
  511. Xexpansion is used as the prerequisite name.  As an example the line:
  512. X.sp
  513. X\tfred : $$@.c
  514. X.sp
  515. Xcauses the $$@ to be expanded when \fBdmake\fP is making fred, and it resolves
  516. Xto the target \fIfred\fP.
  517. XThis enables dynamic prerequisites to be generated.  The value
  518. Xof @ may be modified by any of the valid macro modifiers.  So you can say for
  519. Xexample:
  520. X.sp
  521. X\tfred.out : $$(@:b).c
  522. X.sp
  523. Xwhere the $$(@:b) expands to \fIfred\fP.
  524. XNote the use of $$ instead of $ to indicate the dynamic expansion, this
  525. Xis due to the fact that the rule line is expanded when it is initially parsed,
  526. Xand $$ then returns $ which later triggers the dynamic prerequisite expansion.
  527. XIf you really want a $ to be part of a prerequisite name you must use $$$$.
  528. XDynamic macro expansion is performed in all user defined rules,
  529. Xand the special targets .SOURCE*, and .INCLUDEDIRS.
  530. X.SH "BINDING TARGETS"
  531. XThis operation takes a target name and binds it to an existing file, if
  532. Xpossible.
  533. X.B dmake
  534. Xmakes a distinction between the internal target name of a target and it's
  535. Xassociated external file name.
  536. XThus it is possible for a target's internal name and its external
  537. Xfile name to differ.
  538. XTo perform the binding, the following set of rules is used.
  539. XAssume that we are
  540. Xtrying to bind a target whose name is of the form \fIX.suff\fP,
  541. Xwhere \fI.suff\fP is the suffix and \fIX\fP is the stem portion
  542. X(ie. that part which contains the directory and the basename).
  543. X.B dmake
  544. Xtakes this target name and performs a series of search operations that try to
  545. Xfind a suitably named file in the external file system.
  546. XThe search operation is user controlled
  547. Xvia the settings of the various .SOURCE targets.
  548. X.RS
  549. X.IP 1.
  550. XIf target has the .SYMBOL attribute set then look for it in the library.
  551. XIf found, replace the target name with the library member name and continue
  552. Xwith step 2.  If the name is not found then return.
  553. X.IP 2.
  554. XExtract the suffix portion (that following the `.') of the target name.
  555. XIf the suffix is not null, look up the special target .SOURCE.<suff>
  556. X(<suff> is the suffix).  
  557. XIf the special target exists then search each directory given in
  558. Xthe .SOURCE.<suff> prerequisite list for the target.
  559. XIf the target's suffix was null (ie. \fI.suff\fP was empty) then 
  560. Xperform the above search but use the special target .SOURCE.NULL instead.
  561. XIf at any point a match is found then terminate the search.
  562. XIf a directory in the prerequisite list is the special name `.NULL ' perform
  563. Xa stat for the full target name without prepending any directory portion
  564. X(ie. prepend the NULL directory).
  565. X(a default target of '.SOURCE : .NULL' is defined by \fBdmake\fP at startup,
  566. Xand is user redefinable)
  567. X.IP 3.
  568. XThe search in step 2. failed.  Repeat the same search but this time
  569. Xuse the special target .SOURCE.
  570. X.IP 4.
  571. XThe search in step 3. failed.
  572. XIf the target has the library member attribute (.LIBMEMBER)
  573. Xset then try to find the target in the library which was passed along
  574. Xwith the .LIBMEMBER attribute (see the MAKING LIBRARIES section).
  575. XThe bound file name assigned to a target which is successfully
  576. Xlocated in a library is the same name that would be assigned had the search
  577. Xfailed (see 5.).
  578. X.IP 5.
  579. XThe search failed.  Either the target was not found in any of the search
  580. Xdirectories or no applicable .SOURCE special targets exist.
  581. XIf applicable .SOURCE special targets exist, but the target was not found,
  582. Xthen \fBdmake\fP assigns the first name searched as the bound file name.
  583. XIf no applicable .SOURCE special targets exist,
  584. Xthen the full original target name becomes the bound file name.
  585. X.RE
  586. X.PP
  587. XThere is potential here for a lot of search operations.  The trick is to
  588. Xdefine .SOURCE.x special targets with short search lists and leave .SOURCE
  589. Xas short as possible.
  590. XThe search algorithm has the following useful side effect.
  591. XWhen a target having the .LIBMEMBER (library member) attribute is searched for,
  592. Xit is first searched for as an ordinary file.
  593. XWhen a number of library members require updating it is desirable to compile
  594. Xall of them first and to update the library at the end in a single operation.
  595. XIf one of the members does not compile and \fBdmake\fP stops, then
  596. Xthe user may fix the error and make again.  \fBdmake\fP will not remake any
  597. Xof the targets whose object files have already been generated as long as
  598. Xnone of their prerequisite files have been modified as a result of the fix.
  599. X.PP
  600. XWhen defining .SOURCE and .SOURCE.x targets the construct
  601. X.sp
  602. X\t.SOURCE :
  603. X.br
  604. X\t.SOURCE : fred gery
  605. X.sp
  606. Xis equivalent to
  607. X.sp
  608. X\t.SOURCE :- fred gery
  609. X.PP
  610. X\fBdmake\fP correctly handles the UNIX Make variable VPATH.  By definition VPATH
  611. Xcontains a list of ':' separated directories to search when looking for a
  612. Xtarget.  \fBdmake\fP maps VPATH to the following special rule:
  613. X.sp
  614. X\t.SOURCE :^ $(VPATH:s/:/ /)
  615. X.sp
  616. XWhich takes the value of VPATH and sets .SOURCE to the same set of directories
  617. Xas specified in VPATH.
  618. X.SH "PERCENT(%) RULES AND MAKING INFERENCES"
  619. XWhen \fBdmake\fP makes a target it's set of prerequisites (if any)
  620. Xmust exist and the target must have a recipe which \fBdmake\fP
  621. Xcan use to make it.
  622. XIf the makefile does not specify an explicit recipe for the target then
  623. X.B dmake
  624. Xuses special rules to try to infer a recipe which it can use
  625. Xto make the target.  Previous versions of Make perform this task by using
  626. Xrules that are defined by targets of the form .<suffix>.<suffix> and by
  627. Xusing the .SUFFIXES list of suffixes.  The exact workings of this mechanism
  628. Xwere sometimes difficult to understand and often limiting in their usefulness.
  629. XInstead, \fBdmake\fP supports the concept of \fI%-meta\fP rules.  
  630. XThe syntax and semantics of these rules differ from standard rule lines as
  631. Xfollows:
  632. X.sp
  633. X.nf
  634. X.RS
  635. X\fI<%-target>\fP [\fI<attributes>\fP] \fI<ruleop>\fP [\fI<%-prerequisites>\fP] [;\fI<recipe>\fP]
  636. X.RE
  637. X.fi
  638. X.sp
  639. Xwhere \fI%-target\fP is a target containing exactly a single `%' sign,
  640. X.I attributes
  641. Xis a list (possibly empty) of attributes,
  642. X.I ruleop
  643. Xis the standard set of rule operators,
  644. X.I "%-prerequisites"
  645. X\&, if present, is a list of prerequisites containing zero or more `%' signs,
  646. Xand
  647. X.I recipe,
  648. Xif present, is the first line of the recipe.
  649. X.PP
  650. XThe
  651. X.I %-target
  652. Xdefines a pattern against which a target whose recipe is
  653. Xbeing inferred gets matched.  The pattern match goes as follows:  all chars are
  654. Xmatched exactly from left to right up to but not including the % sign in the
  655. Xpattern, % then matches the longest string from the actual target name
  656. Xnot ending in
  657. Xthe suffix given after the % sign in the pattern.
  658. XConsider the following examples:
  659. X.RS
  660. X.sp
  661. X.nf
  662. X.Is "dir/%.c   "
  663. X.Ii "%.c"
  664. Xmatches fred.c but not joe.c.Z
  665. X.Ii "dir/%.c"
  666. Xmatches dir/fred.c but not dd/fred.c
  667. X.Ii "fred/%"
  668. Xmatches fred/joe.c but not f/joe.c
  669. X.Ii "%"
  670. Xmatches anything
  671. X.fi
  672. X.sp
  673. X.RE
  674. XIn each case the part of the target name that matched the % sign is retained
  675. Xand is substituted for any % signs in the prerequisite list of the %-meta rule
  676. Xwhen the rule is selected during inference and
  677. X.B dmake
  678. Xconstructs the dependency specified by the %-meta rule for the actual target.
  679. XAs an example the following %-meta rules describe the following:
  680. X.RS
  681. X.sp
  682. X%.c : %.y ; recipe...
  683. X.sp
  684. X.RE
  685. Xdescribes how to make any file ending in .c if a corresponding file ending
  686. Xin .y can be found.
  687. X.RS
  688. X.sp
  689. Xfoo%.o : fee%.k ; recipe...
  690. X.sp
  691. X.RE
  692. Xis used to describe how to make fooxxxx.o from feexxxx.k.
  693. X.RS
  694. X.sp
  695. X%.a :; recipe...
  696. X.sp
  697. X.RE
  698. Xdescribes how to make a file whose suffix is .a without inferring any
  699. Xprerequisites.
  700. X.RS
  701. X.sp
  702. X%.c : %.y yaccsrc/%.y ; recipe...
  703. X.sp
  704. X.RE
  705. Xis a short form for the construct:
  706. X.RS
  707. X.sp
  708. X%.c : %.y ; recipe...
  709. X.br
  710. X%.c : yaccsrc/%.y ; recipe...
  711. X.sp
  712. X.RE
  713. Xie. It is possible to specify the same recipe for two %-rules by giving
  714. Xmore than one prerequisite in the prerequisite list.
  715. XA more interesting example is:
  716. X.RS
  717. X.sp
  718. X% : RCS/%,v ; co $@
  719. X.sp
  720. X.RE
  721. Xwhich describes how to take any target and check it out of
  722. Xthe RCS directory if the corresponding file exists in the RCS directory.
  723. XThe equivalent SCCS rule would be:
  724. X.RS
  725. X.sp
  726. X% : s.% ; get $@
  727. X.sp
  728. X.RE
  729. X.PP
  730. XThe previous RCS example defines an infinite rule, because it says how to make
  731. X.I anything
  732. Xfrom RCS/%,v, and
  733. X.I anything
  734. Xalso includes RCS/fred.c,v.
  735. XTo limit the size of the graph that results from such rules
  736. X.B dmake
  737. Xuses the macro variable PREP (stands for % repetition).  By default the value
  738. Xof this variable is 0, which says that no repetitions of a %-rule are to be
  739. Xgenerated.  If it is set to something greater than 0, then that many
  740. Xrepetitions of any infinite %-rule are allowed.  If in the above
  741. Xexample PREP was set to 1, then \fBdmake\fP would generate the dependency
  742. Xgraph:
  743. X.RS
  744. X.sp
  745. X% --> RCS/%,v --> RCS/RCS/%,v,v
  746. X.sp
  747. X.RE
  748. XWhere each link is assigned the same recipe as the first link.
  749. XPREP should be used only in special cases, since it may result in
  750. Xa large increase in the number of possible prerequisites tested.
  751. X.PP
  752. X.B dmake
  753. Xsupports dynamic prerequisite generation for prerequisites of %-meta rules.
  754. XThis is best illustrated by an example.  The RCS rule shown above can infer
  755. Xhow to check out a file from a corresponding RCS file only if the target
  756. Xis a simple file name with no directory information.  That is, the above rule
  757. Xcan infer how to find \fIRCS/fred.c,v\fP from the target \fIfred.c\fP,
  758. Xbut cannot infer how to find \fIsrcdir/RCS/fred.c,v\fP from \fIsrcdir/fred.c\fP
  759. Xbecause the above rule will cause \fBdmake\fP to look for RCS/srcdir/fred.c,v;
  760. Xwhich does not exist (assume that srcdir has it's own RCS directory as is the
  761. Xcommon case).
  762. X.PP
  763. XA more versatile formulation of the above RCS check out rule is the following:
  764. X.RS
  765. X.sp
  766. X% :  $$(@:d)RCS/$$(@:f),v : co $@
  767. X.sp
  768. X.RE
  769. XThis rule uses the dynamic macro $@ to specify the prerequisite to try to
  770. Xinfer.  During inference of this rule the macro $@ is set to the value of
  771. Xthe target of the %-meta rule and the appropriate prerequisite is generated by
  772. Xextracting the directory portion of the target name (if any), appending the
  773. Xstring \fIRCS/\fP to it, and appending the target file name with a trailing
  774. X\fI,v\fP attached to the previous result.
  775. X.PP
  776. X.B dmake
  777. Xcan also infer indirect prerequisites.
  778. XAn inferred target can have a list of prerequisites added that will not
  779. Xshow up in the value of $< but will show up in the value of $? and $&.
  780. XIndirect prerequisites are specified in an inference rule by quoting the
  781. Xprerequisite with single quotes.  For example, if you had the explicit
  782. Xdependency:
  783. X.RS
  784. X.sp
  785. X.nf
  786. Xfred.o : fred.c ; rule to make fred.o
  787. Xfred.o : local.h
  788. X.fi
  789. X.sp
  790. X.RE
  791. Xthen this can be infered for fred.o from the following inference rule:
  792. X.RS
  793. X.sp
  794. X%.o : %.c 'local.h' ; rule to make a .o from a .c
  795. X.sp
  796. X.RE
  797. XYou may infer indirect prerequisites that are a function of the value of '%'
  798. Xin the current rule.  The meta-rule:
  799. X.RS
  800. X.sp
  801. X%.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
  802. X.sp
  803. X.RE
  804. Xinfers an indirect prerequisite found in the INC directory whose name is the
  805. Xsame as the expansion of $(INC), and the prerequisite name depends on the
  806. Xbase name of the current target.
  807. XThe set of indirect prerequisites is attached to the meta rule in which they
  808. Xare specified and are inferred only if the rule is used to infer a recipe
  809. Xfor a target.  They do not play an active role in driving the inference
  810. Xalgorithm.
  811. XThe construct:
  812. X.RS
  813. X.sp
  814. X%.o : %.c %.f 'local.h'; recipe
  815. X.sp
  816. X.RE
  817. Xis equivalent to:
  818. X.RS
  819. X.sp
  820. X.nf
  821. X%.o : %.c 'local.h' : recipe
  822. X%.o : %.f 'local.h' : recipe
  823. X.fi
  824. X.sp
  825. X.RE
  826. X.PP
  827. XIf any of the attributes .SETDIR, .EPILOG, .PROLOG, .SILENT, .PRECIOUS,
  828. X\&.LIBRARY, and .IGNORE
  829. Xare given for a %-rule then when that rule is bound to a target
  830. Xas the result of an inference, the target's set of attributes is augmented by
  831. Xthe attributes from the above set that are specified in the bound %-rule.
  832. XOther attributes specified for %-meta rules are not inherited by the target.
  833. XThe .SETDIR attribute is treated in a special way.
  834. XIf the target already had a .SETDIR attribute set and the bound %-rule also
  835. Xspecified a .SETDIR attribute then the one
  836. Xoriginally specified with the target prevails.
  837. XDuring inference any .SETDIR attributes for the inferred prerequisite
  838. Xare honored.
  839. XThe directories must exist for a %-meta rule to be selected as a possible
  840. Xinference path.  If the directories do not exist no error message is issued,
  841. Xinstead the corresponding path in the inference graph is simply rejected.
  842. X.PP
  843. X.B dmake
  844. Xalso supports the old format special target .<suffix>.<suffix>
  845. Xby identifying any rules
  846. Xof this form and mapping them to the appropriate %-rule.  So for example if
  847. Xan old makefile contains the construct:
  848. X.RS
  849. X.sp
  850. X\&.c.o :; cc -c $< -o $@
  851. X.sp
  852. X.RE
  853. X.B dmake
  854. Xmaps this into the following %-rule:
  855. X.RS
  856. X.sp
  857. X%.o : %.c; cc -c $< -o $@
  858. X.sp
  859. X.RE
  860. XFurthermore,
  861. X.B dmake
  862. Xunderstands several SYSV AUGMAKE special targets and maps them into
  863. Xcorresponding %-meta rules.  These transformation must be enabled by providing
  864. Xthe -A flag on the command line or by setting the value of AUGMAKE to non
  865. XNULL.
  866. XThe construct
  867. X.RS
  868. X.sp
  869. X\&.suff :; recipe
  870. X.sp
  871. X.RE
  872. Xgets mapped into:
  873. X.RS
  874. X.sp
  875. X% : %.suff; recipe
  876. X.sp
  877. X.RE
  878. Xand the construct
  879. X.RS
  880. X.sp
  881. X\&.c~.o :; recipe
  882. X.sp
  883. X.RE
  884. Xgets mapped into:
  885. X.RS
  886. X.sp
  887. X%.o : s.%.c ; recipe
  888. X.sp
  889. X.RE
  890. XIn general, a special target of the form .<str>~ is replaced by the %-rule
  891. Xconstruct s.%.<str>, thereby providing support for the syntax used by SYSV
  892. XAUGMAKE for providing SCCS support.
  893. XWhen enabled, these mappings allow to processing of existing SYSV
  894. Xmakefiles without modifications.
  895. X.PP
  896. X.B dmake
  897. Xbases all of it's inferences on the inference graph constructed from the
  898. X%-rules defined in the makefile.
  899. XIt knows exactly which targets can be made from which prerequisites by
  900. Xmaking queries on the inference graph.  For this reason .SUFFIXES is not
  901. Xneeded and is completely ignored.
  902. X.PP
  903. XFor a %-meta rule to be inferred as the
  904. Xrule whose recipe will be used to make a target, the target's name must match
  905. Xthe %-target pattern, and any inferred %-prerequisite must already exist or
  906. Xhave an explicit recipe so that the prerequisite can be made.
  907. XWithout \fItransitive closure\fP on the inference graph the above rule
  908. Xdescribes precisely when an inference match terminates the search.
  909. XIf transitive closure is enabled (the usual case), and a prerequisite does
  910. Xnot exist or cannot be made, then
  911. X.B dmake
  912. Xinvokes the inference algorithm recursively on the prerequisite to see if
  913. Xthere is some way the prerequisite can be manufactured.  For if the
  914. Xprerequisite can be made then the current target can also be made using the
  915. Xcurrent %-meta rule.
  916. XThis means that there is no longer a need to give a rule
  917. Xfor making a .o from a .y if you have already given a rule for making a .o
  918. Xfrom a .c and a .c from a .y.  In such cases
  919. X.B dmake
  920. Xcan infer how to make the
  921. X\&.o from the .y via the intermediary .c and will remove the .c when the .o is
  922. Xmade.  Transitive closure can be disabled by giving the -T switch on the
  923. Xcommand line.
  924. X.PP
  925. XA word of caution.
  926. X.B dmake
  927. Xbases its transitive closure on the %-meta rule targets.
  928. XWhen it performs transitive closure it infers how to make a target from a
  929. Xprerequisite by performing a pattern match as if the potential prerequisite
  930. Xwere a new target.
  931. XThe set of rules:
  932. X.RS
  933. X.nf
  934. X.sp
  935. X%.o : %.c :; rule for making .o from .c
  936. X%.c : %.y :; rule for making .c from .y
  937. X% : RCS/%,v :; check out of RCS file
  938. X.fi
  939. X.sp
  940. X.RE
  941. Xwill, by performing transitive closure, allow \fBdmake\fP to infer how to make
  942. Xa .o from a .y using a .c as an intermediate temporary file.  Additionally
  943. Xit will be able to infer how to make a .y from an RCS file, as long as that
  944. XRCS file is in the RCS directory and has a name which ends in .y,v.
  945. XThe transitivity computation is performed dynamically for each target that
  946. Xdoes not have a recipe.  This has potential to be very slow if the %-meta
  947. Xrules are not carefully specified.  The .NOINFER attribute is used to mark
  948. Xa %-meta node as being a final target during inference.  Any node with this
  949. Xattribute set will not be used for subsequent inferences.  As an example
  950. Xthe node RCS/%,v is marked as a final node since we know that if the RCS file
  951. Xdoes not exist there likely is no other way to make it.  Thus the standard
  952. Xstartup makefile contains the entry:
  953. X.RS
  954. X.nf
  955. X\&.NOINFER : RCS/%,v
  956. X.fi
  957. X.RE
  958. XThereby indicating that the RCS file is the end of the inference chain.
  959. X.PP
  960. X.B dmake
  961. Xtries to
  962. Xremove intermediate files resulting from transitive closure if the file
  963. Xis not marked as being PRECIOUS, or the \fB-u\fP flag was not given on the
  964. Xcommand line, and if the inferred intermediate did not previously exist.
  965. XIntermediate targets that existed prior to being made are never removed.
  966. XThis is in keeping with the philosophy that
  967. X.B dmake
  968. Xshould never remove things from the file system that it did not add.
  969. XIf the special target .REMOVE is defined and has a recipe then
  970. X.B dmake
  971. Xconstructs a list of the intermediate files to be removed and makes them
  972. Xprerequisites of .REMOVE.  It then makes .REMOVE thereby removing the
  973. Xprerequisites if the recipe of .REMOVE says to.  Typically .REMOVE is defined
  974. Xin the startup file as:
  975. X.sp
  976. X\t".REMOVE :; $(RM) $<".
  977. X.SH "MAKING TARGETS"
  978. XIn order to update a target \fBdmake\fP must execute a recipe.
  979. XWhen a recipe needs to be executed it is first expanded so that any macros
  980. Xin the recipe text are expanded, and it is then either executed directly or
  981. Xpassed to a shell.
  982. X.B dmake
  983. Xsupports two types of recipes.  The regular recipes and group recipes.
  984. X.PP
  985. XWhen a regular recipe is invoked \fBdmake\fP executes each line of the recipe
  986. Xseparately using a new copy of a shell if a shell is required.
  987. XThus effects of commands do not generally persist across recipe lines.
  988. X(e.g. cd requests in a recipe line do not carry over to the next recipe line)
  989. XThe decision on whether a shell is required to execute a command is based on
  990. Xthe value of the macro SHELLMETAS.  If any character in the value of
  991. X\&SHELLMETAS is found in the expanded recipe text-line then the command is
  992. Xexecuted using a shell, otherwise the command is executed directly.
  993. XThe shell that is used for execution is given by the value of the macro SHELL.
  994. XThe flags that are passed to the shell are given by the value of SHELLFLAGS.
  995. XThus \fBdmake\fP constructs the command line:
  996. X.sp
  997. X\t$(SHELL) $(SHELLFLAGS) $(expanded_recipe_command)
  998. X.sp
  999. XNormally
  1000. X.B dmake
  1001. Xwrites the command line that it is about to invoke to standard output.
  1002. XIf the .SILENT attribute is set for the target or for
  1003. Xthe recipe line (via @), then the recipe line is not echoed.
  1004. X.PP
  1005. XGroup recipe processing is similar to that of regular recipes, except that
  1006. Xa shell is always invoked.  The shell that is invoked is given by the value of
  1007. Xthe macro GROUPSHELL, and its flags are taken from the value of the macro
  1008. XGROUPFLAGS.  If a target has the .PROLOG attribute set then
  1009. X.B dmake
  1010. Xprepends to the shell script the recipe associated with the special target
  1011. X\&.GROUPPROLOG, and if the attribute .EPILOG is set as well, then the recipe
  1012. Xassociated with the special target .GROUPEPILOG is appended to the script
  1013. Xfile.
  1014. XThis facility can be used to always prepend a common header and common trailer
  1015. Xto group recipes.
  1016. XGroup recipes are echoed to standard output just like standard recipes, but
  1017. Xare enclosed by lines beginning with [ and ].
  1018. X.SH "MAKING LIBRARIES"
  1019. XLibraries are easy to maintain using \fBdmake\fP.  A library is a file
  1020. SHAR_EOF
  1021. echo "End of part 8"
  1022. echo "File man/dmake.tf is continued in part 9"
  1023. echo "9" > s2_seq_.tmp
  1024. exit 0
  1025.  
  1026.