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

  1. Newsgroups: comp.sources.misc
  2. From: dvadura@plg.waterloo.edu (Dennis Vadura)
  3. Subject:  v27i119:  dmake - dmake Version 3.8, Part18/41
  4. Message-ID: <1992Jan28.214138.19050@sparky.imd.sterling.com>
  5. X-Md4-Signature: 7fdf4a53c7fbf586bb2803b75065e813
  6. Date: Tue, 28 Jan 1992 21:41:38 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: dvadura@plg.waterloo.edu (Dennis Vadura)
  10. Posting-number: Volume 27, Issue 119
  11. Archive-name: dmake/part18
  12. Environment: Atari-ST, Coherent, Mac, MSDOS, OS/2, UNIX
  13. Supersedes: dmake: Volume 19, Issue 22-58
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. # this is dmake.shar.18 (part 18 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" != 18; 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. .sp
  35. Since the temporary file is opened when the
  36. macro containing the text diversion expression is expanded, diversions may
  37. now be nested and any diversions that are created as part of ':=' macro
  38. expansions persist for the duration of the
  39. .B dmake
  40. run.
  41. The diversion text may contain
  42. the same escape codes as those described in the MACROS section.
  43. Thus if the \fIdata\fP text is to contain new lines they must be inserted
  44. using the \en escape sequence.  For example the expression:
  45. .RS
  46. .sp
  47. .nf
  48. all:
  49. X    cat $(mktmp this is a\en\e
  50. X    test of the text diversion\en)
  51. .fi
  52. .sp
  53. .RE
  54. is replaced by:
  55. .RS
  56. .sp
  57. cat /tmp/mk12294AA
  58. .sp
  59. .RE
  60. where the temporary file contains two lines both of which are terminated
  61. by a new-line.  If the \fIdata\fP text spans multiple lines in the makefile
  62. then each line must be continued via the use of a \e.
  63. A second more illustrative example generates a response file to an MSDOS
  64. link command:
  65. .RS
  66. .sp
  67. .nf
  68. OBJ = fred.obj mary.obj joe.obj
  69. all : $(OBJ)
  70. X    link @$(mktmp $(^:t"+\en")\en)
  71. .fi
  72. .sp
  73. .RE
  74. The result of making `all' in the second example is the command:
  75. .RS
  76. .sp
  77. link @/tmp/mk02394AA
  78. .sp
  79. .RE
  80. where the temporary file contains:
  81. .RS
  82. .sp
  83. .nf
  84. fred.obj+
  85. mary.obj+
  86. joe.obj
  87. .fi
  88. .sp
  89. .RE
  90. The last line of the file is terminated by a new-line which is inserted
  91. due to the \en found at the end of the \fIdata\fP string.
  92. .PP
  93. If the optional \fIfile\fP specifier is present then its expanded value
  94. is the name of the temporary file to create.  Whenever a $(mktmp ...) macro
  95. is expanded the macro $(TMPFILE) is set to a new temporary file name.  Thus
  96. the construct:
  97. .RS
  98. .sp
  99. $(mktmp,$(TMPFILE) data)
  100. .sp
  101. .RE
  102. is completely equivalent to not specifying the $(TMPFILE) optional argument.
  103. Another example that would be useful for MSDOS users with a Turbo-C compiler
  104. .RS
  105. .sp
  106. $(mktmp,turboc.cfg $(CFLAGS))
  107. .sp
  108. .RE
  109. will place the contents of CFLAGS into a local \fIturboc.cfg\fP file.
  110. The second optional argument, \fItext\fP, if present alters the name
  111. of the value returned by the $(mktmp ...) macro.
  112. .PP
  113. Under MS-DOS text diversions may be a problem.  Many DOS tools require
  114. that path names which contain directories use the \e character to delimit
  115. the directories.  Some users however wish to use the '/' to delimit pathnames
  116. and use environments that allow them to do so.
  117. The macro USESHELL is set to "yes" if the
  118. current recipe is forced to use a shell via the .USESHELL or '+' directives,
  119. otherwise its value is "no".
  120. The
  121. .B dmake
  122. startup files define the macro DIVFILE whose value is either the
  123. value of TMPFILE or the value of TMPFILE edited to replace any '/' characters
  124. to the appropriate value based on the current shell and whether it will be
  125. used to execute the recipe.
  126. .PP
  127. Previous versions of
  128. .B dmake
  129. defined text diversions using <+, +> strings,
  130. where <+ started a text diversion and +> terminated one.
  131. .B dmake
  132. is backward compatible with this construct if the <+ and +> appear literally
  133. on the same recipe line or in the same macro value string.  In such instances
  134. the expression:
  135. .sp
  136. \t<+data+>
  137. .sp
  138. is mapped to:
  139. .sp
  140. \t$(mktmp data)
  141. .sp
  142. which is fully output compatible with the earlier construct.  <+, +>
  143. constructs whose text spans multiple lines must be converted by hand to use
  144. $(mktmp ...).
  145. .PP
  146. If the environment variable TMPDIR is defined then the
  147. temporary file is placed into the directory specified by that variable.
  148. A makefile can modify the location of temporary files by
  149. defining a macro named TMPDIR and exporting it using the .EXPORT special
  150. target.
  151. .SH "SPECIAL TARGETS"
  152. This section describes the special targets that are recognized by \fBdmake\fP.
  153. Some are affected by attributes and others are not.
  154. .IP \fB.ERROR\fP 1.4i
  155. If defined then the recipe associated with this target is executed
  156. whenever an error condition is detected by \fBdmake\fP.  All attributes that
  157. can be used with any other target may be used with this target.  Any
  158. prerequisites of this target will be brought up to date during its processing.
  159. NOTE:  errors will be ignored while making this target, in extreme cases this
  160. may cause some problems.
  161. .IP \fB.EXPORT\fP 1.4i
  162. All prerequisites associated with this target are assumed to
  163. correspond to macro names and they and their values
  164. are exported to the environment as environment strings at the point in
  165. the makefile at which this target appears.
  166. Any attributes specified with this target are ignored.
  167. Only macros which have been assigned a value in the makefile prior to the
  168. export directive are exported, macros as yet undefined
  169. or macros whose value contains any of the characters "+=:*"
  170. are not exported.
  171. is suppre
  172. .IP \fB.IMPORT\fP 1.4i
  173. Prerequisite names specified for this target are searched for in the
  174. environment and defined as macros with their value taken from the environment.
  175. If the special name \fB.EVERYTHING\fP is used as a prerequisite name then
  176. all environment variables defined in the environment are imported.
  177. The functionality of the \fB\-E\fP flag can be forced by placing the construct
  178. \&\fI.IMPORT : .EVERYTHING\fP at the start of a makefile.  Similarly, by
  179. placing the construct at the end, one can emulate the effect of the \fB\-e\fP
  180. command line flag.
  181. If a prerequisite name cannot be found in the environment
  182. an error message is issued.
  183. \&.IMPORT accepts the .IGNORE attribute.  When given, it causes \fBdmake\fP
  184. to ignore the above error.
  185. See the MACROS section for a description of the processing of imported macro
  186. values.
  187. .IP \fB.INCLUDE\fP 1.4i
  188. Parse another makefile just as if it had been located at the point of the
  189. \&.INCLUDE in the current makefile.  The list of prerequisites gives the list of
  190. makefiles to try to read.  If the list contains multiple makefiles then they
  191. are read in order from left to right.  The following search rules are used
  192. when trying to locate the file.  If the filename is surrounded by " or just
  193. by itself then it is searched for in the current directory.  If it is not
  194. found it is then searched for in each of the directories specified for the
  195. \&.INCLUDEDIRS special target.  If the file name is surrounded by < and >, (ie.
  196. <my_spiffy_new_makefile>) then it is searched for only in the directories
  197. given by the .INCLUDEDIRS special target.  In both cases if the file name is a
  198. fully qualified name starting at the root of the file system then it is only
  199. searched for once, and the .INCLUDEDIRS list is ignored.  .INCLUDE accepts
  200. the .IGNORE and .SETDIR attributes.  If .IGNORE attribute is given and the file
  201. cannot be found then \fBdmake\fP continues processing,
  202. otherwise an error message is generated.
  203. The .SETDIR attribute causes
  204. .B dmake
  205. to change directories to the specified directory prior to attempting the
  206. include operation.
  207. .IP \fB.INCLUDEDIRS\fP 1.4i
  208. The list of prerequisites specified for this target defines the set of
  209. directories to search when trying to include a makefile.
  210. .IP \fB.KEEP_STATE\fP 1.4i
  211. This special target is a synonym for the macro definition
  212. .sp
  213. \&\t.KEEP_STATE := _state.mk
  214. .sp
  215. It's effect is to turn on STATE keeping and to define \fI_state.mk\fP
  216. as the state file.
  217. .IP \fB.MAKEFILES\fP 1.4i
  218. The list of prerequisites is the set of files to try to read as the default
  219. makefile.  By default this target is defined as: 
  220. .sp
  221. \t\&.MAKEFILES : makefile.mk Makefile makefile
  222. .sp
  223. .IP \fB.SOURCE\fP 1.4i
  224. The prerequisite list of this target defines a set of directories to check
  225. when trying to locate a target file name.  See the section on BINDING of
  226. targets for more information.
  227. .IP \fB.SOURCE.suff\fP 1.4i
  228. The same as .SOURCE, except that the .SOURCE.suff list is searched first when
  229. trying to locate a file matching the a target whose name ends in the suffix
  230. \&.suff.
  231. .IP \fB.REMOVE\fP 1.4i
  232. The recipe of this target is used whenever \fBdmake\fP needs to remove
  233. intermediate targets that were made but do not need to be kept around.
  234. Such targets result from the application of transitive closure on the
  235. dependency graph.
  236. .PP
  237. In addition to the special targets above,
  238. several other forms of targets are recognized and are considered special,
  239. their exact form and use is defined in the sections that follow.
  240. .SH "SPECIAL MACROS"
  241. .B dmake
  242. defines a number of special macros.  They are divided into three classes:
  243. control macros, run-time macros, and function macros.
  244. The control macros are used by
  245. .B dmake
  246. to configure its actions, and are the preferred method of doing so.
  247. In the case when a control macro has the same function as a special 
  248. target or attribute they share the same name as the special target or
  249. attribute.
  250. The run-time macros are defined when
  251. .B dmake
  252. makes targets and may be used by the user inside recipes.
  253. The function macros provide higher level functions dealing with macro
  254. expansion and diversion file processing.
  255. .SH "CONTROL MACROS"
  256. To use the control macros simply assign them a value just like any other
  257. macro.  The control macros are divided into three groups:
  258. string valued macros, character valued macros, and boolean valued macros.
  259. .PP
  260. The following are all of the string valued macros.
  261. This list is divided into two groups.  The first group gives the string
  262. valued macros that are defined internally and cannot be directly set by the
  263. user.
  264. .IP \fBDIRBRKSTR\fP 1.4i
  265. Contains the string of chars used to terminate
  266. the name of a directory in a pathname.
  267. Under UNIX its value is "/", under MSDOS its value is "/\e:".
  268. .IP \fBINCDEPTH\fP 1.4i
  269. This macro's value is a string of digits representing
  270. the current depth of makefile inclusion.
  271. In the first makefile level this value is zero.
  272. .IP \fBMFLAGS\fP 1.4i
  273. Is the list of flags
  274. that were given on the command line including a leading switch character.
  275. The \-f flag is not included in this list.
  276. .IP \fBMAKECMD\fP 1.4i
  277. Is the name with which \fBdmake\fP was invoked.
  278. .IP \fBMAKEDIR\fP 1.4i
  279. Is the full path to the initial directory in which
  280. .B dmake
  281. was invoked.
  282. .IP \fBMAKEFILE\fP 1.4i
  283. Contains the string "\-f \fImakefile\fP" where, \fImakefile\fP is the name
  284. of initial user makefile that was first read.
  285. .IP \fBMAKEFLAGS\fP 1.4i
  286. Is the same as $(MFLAGS) but has no leading switch
  287. character. (ie. MFLAGS = \-$(MAKEFLAGS))
  288. .IP \fBMAKEMACROS\fP 1.4i
  289. Contains the complete list of macro expressions that were specified on the
  290. command line.
  291. .IP \fBMAKETARGETS\fP 1.4i
  292. Contains the name(s) of the target(s), if any, that were
  293. specified on the command line.
  294. .IP \fBMAXPROCESSLIMIT\fP 1.4i
  295. Is a numeric string representing the maximum number of processes that 
  296. \fBdmake\fP can use when making targets using parallel mode.
  297. .IP \fBNULL\fP 1.4i
  298. Is permanently defined to be the NULL string.
  299. This is useful when comparing a conditional expression to an NULL value.
  300. .IP \fBPWD\fP 1.4i
  301. Is the full path to the
  302. current directory in which make is executing.
  303. .IP \fBTMPFILE\fP 1.4i
  304. Is set to the name of the most recent temporary file opened by \fBdmake\fP.
  305. Temporary files are used for text diversions and for group recipe processing.
  306. .IP \fBTMD\fP 1.4i
  307. Stands for "To Make Dir", and
  308. is the path from the present directory (value of $(PWD)) to the directory
  309. that \fBdmake\fP was started up in (value of $(MAKEDIR)).
  310. This macro is modified when .SETDIR attributes are processed.
  311. .IP \fBUSESHELL\fP 1.4i
  312. The value of this macro is set to "yes" if the current recipe is forced to
  313. use a shell for its execution via the .USESHELL or '+' directives, its value
  314. is "no" otherwise.
  315. .sp
  316. .PP
  317. The second group of string valued macros control
  318. .B dmake
  319. behavior and may be set by the user.
  320. .IP \fB.NOTABS\fP 1.6i
  321. When set to non-NULL enables the use of spaces as well as <tabs> to begin
  322. recipe lines.
  323. By default a non\-group recipe is terminated by a line without any leading
  324. white\-space or by a line not beggining with a <tab> character.
  325. Enabling this mode modifies the first condition of
  326. the above termination rule to terminate a
  327. non\-group recipe with a line that contains only white\-space.
  328. This mode does not effect the parsing of group recipes bracketed by [].
  329. .IP \fB.SETDIR\fP 1.6i
  330. If this macro is assigned a value then \fBdmake\fP will
  331. change to the directory given by that value before making any targets.
  332. .IP \fBAUGMAKE\fP 1.6i
  333. If set to a non NULL value will enable the transformation of special
  334. meta targets to support special AUGMAKE inferences (See the COMPATIBILITY
  335. section).
  336. .IP \fBDIRSEPSTR\fP 1.6i
  337. Contains the string that is used to separate directory components when
  338. path names are constructed.  It is defined with a default value at startup.
  339. .IP \fBDIVFILE\fP 1.6i
  340. Is defined in the startup file and gives the name that should be returned for
  341. the diversion file name when used in
  342. $(mktmp ...) expansions, see the TEXT DIVERSION section for details.
  343. .IP \fB.KEEP_STATE\fP 1.6i
  344. Assigning this macro a value tells
  345. .B dmake
  346. the name of the state file to use and turns on the keeping of state
  347. information for any targets that are brought up to date by the make.
  348. .IP \fBGROUPFLAGS\fP 1.6i
  349. This macro gives the set of flags to pass to the shell when
  350. invoking it to execute a group recipe.  The value of the macro is the
  351. list of flags with a leading switch indicator.  (ie. `\-' under UNIX)
  352. .IP \fBGROUPSHELL\fP 1.6i
  353. This macro defines the full
  354. path to the executable image to be used as the shell when
  355. processing group recipes.  This macro must be defined if group recipes are
  356. used.  It is assigned a default value in the startup makefile.  Under UNIX
  357. this value is /bin/sh.
  358. .IP \fBGROUPSUFFIX\fP 1.6i
  359. If defined, this macro gives the string to use as a suffix
  360. when creating group recipe files to be handed to the command interpreter.
  361. For example, if it is defined as .sh, then all
  362. temporary files created by \fBdmake\fP will end in the suffix .sh.
  363. Under MSDOS if you are using command.com as your GROUPSHELL, then this suffix
  364. must be set to .bat in order for group recipes to function correctly.
  365. The setting of GROUPSUFFIX and GROUPSHELL is done automatically for
  366. command.com in the startup.mk files.
  367. .IP \fBMAKE\fP 1.6i
  368. Is defined in the startup file by default.
  369. The string $(MAKE) is recognized when
  370. using the \-n option for single line recipes.  Initially this macro is defined
  371. to have the value "$(MAKECMD) $(MFLAGS)".
  372. .IP \fBMAKESTARTUP\fP 1.6i
  373. This macro defines the full path to the initial startup
  374. makefile.  Use the \fB\-V\fP command line option to discover its initial
  375. value.
  376. .IP \fBMAXLINELENGTH\fP 1.6i
  377. This macro defines the maximum size of a single line of
  378. makefile input text.  The size is specified as a number, the default value
  379. is defined internally and is shown via the \fB\-V\fP option.
  380. A buffer of this size plus 2 is allocated for reading makefile text.  The
  381. buffer is freed before any targets are made, thereby allowing files containing
  382. long input lines to be processed without consuming memory during the actual
  383. make.
  384. This macro can only be used to extend the line length beyond it's default
  385. minimum value.
  386. .IP \fBMAXPROCESS\fP 1.6i
  387. Specify the maximum number of child processes to use when making targets.
  388. The default value of this macro is "1" and its value cannot exceed the value
  389. of the macro MAXPROCESSLIMIT.  Setting the value of MAXPROCESS on the command
  390. line or in the makefile is equivalent to supplying a corresponding value to
  391. the -P flag on the command line.
  392. .IP \fBPREP\fP 1.6i
  393. This macro defines the number of iterations to be expanded
  394. automatically when processing % rule definitions of the form:
  395. .sp
  396. % : %.suff
  397. .sp
  398. See the sections on PERCENT(%) RULES for details on how PREP is used.
  399. .IP \fBSHELL\fP 1.6i
  400. This macro defines the full path to the executable
  401. image to be used as the shell when
  402. processing single line recipes.  This macro must be defined if recipes
  403. requiring the shell for execution are to be used.
  404. It is assigned a default value in the startup makefile.
  405. Under UNIX this value is /bin/sh.
  406. .IP \fBSHELLFLAGS\fP 1.6i
  407. This macro gives the set of flags to pass to the shell when
  408. invoking it to execute a single line recipe.  The value of the macro is the
  409. list of flags with a leading switch indicator.  (ie. `\-' under UNIX)
  410. .IP \fBSHELLMETAS\fP 1.6i
  411. Each time
  412. .B dmake
  413. executes a single recipe line (not a group recipe) the line is
  414. searched for any occurrence of a character defined in the value of SHELLMETAS.
  415. If such a character is found the recipe line is defined to require a shell
  416. to ensure its correct execution.  In such instances
  417. a shell is used to invoke the recipe line.
  418. If no match is found the recipe line is executed without the use of a shell.
  419. .sp
  420. .PP
  421. There is only one character valued macro defined by \fBdmake\fP:
  422. \fBSWITCHAR\fP contains the switch character used
  423. to introduce options on command lines.  For UNIX its value is `\-', and for
  424. MSDOS its value may be `/' or `\-'.
  425. The macro is internally defined and is not user setable.
  426. The MSDOS version of \fBdmake\fP attempts to first extract SWITCHAR from an
  427. environment variable of the same name.  If that fails it then attempts to
  428. use the undocumented getswitchar system call, and returns the result of
  429. that.  Under MSDOS version 4.0 you must set the value of the environment
  430. macro SWITCHAR to '/' to obtain predictable behavior.
  431. .PP
  432. All boolean macros currently understood by 
  433. .B dmake
  434. correspond directly to the previously defined attributes.
  435. These macros provide
  436. a second way to apply global attributes, and represent the
  437. preferred method of doing so.  They are used by assigning them a
  438. value.  If the value is not a NULL string then the boolean condition
  439. is set to on.
  440. If the value is a NULL string then the condition is set to off.
  441. There are five conditions defined and they correspond directly to the
  442. attributes of the same name.  Their meanings are defined in the ATTRIBUTES
  443. section above.
  444. The macros are:
  445. \&\fB.EPILOG\fP,
  446. \&\fB.IGNORE\fP,
  447. \&\fB.MKSARGS\fP,
  448. \&\fB.NOINFER\fP,
  449. \&\fB.PRECIOUS\fP,
  450. \&\fB.PROLOG\fP,
  451. \&\fB.SEQUENTIAL\fP,
  452. \&\fB.SILENT\fP,
  453. \&\fB.SWAP\fP, and
  454. \&\fB.USESHELL\fP.
  455. Assigning any of these a non NULL value will globally set
  456. the corresponding attribute to on.
  457. .SH "RUN_TIME MACROS"
  458. These macros are defined
  459. when \fBdmake\fP is making targets, and may take on different values for each
  460. target.  \fB$@\fP is defined to be the full target name, \fB$?\fP is the
  461. list of all out of date prerequisites, \fB$&\fP is the list of all
  462. prerequisites, \fB$>\fP is the name of the library if the current target is a
  463. library member, and
  464. \fB$<\fP is the list of prerequisites specified in the current rule.
  465. If the current target had a recipe inferred then \fB$<\fP is the name of the
  466. inferred prerequisite even if the target had a list of prerequisites supplied
  467. using an explicit rule that did not provide a recipe.  In such situations
  468. \fB$&\fP gives the full list of prerequisites.
  469. .PP
  470. \fB$*\fP is defined as
  471. \fB$(@:db)\fP when making targets with explicit recipes and is defined as the
  472. value of % when making targets whose recipe is the result of an inference.
  473. In the first case \fB$*\fP is the target name with no suffix,
  474. and in the second case, is the value of the matched % pattern from
  475. the associated %-rule.
  476. \fB$^\fP expands to the set of out of date prerequisites taken from the
  477. current value of \fB$<\fP.
  478. In addition to these,
  479. \fB$$\fP expands to $, \fB{{\fP expands to {, \fB}}\fP expands to }, and the
  480. strings \fB<+\fP and \fB+>\fP are recognized
  481. as respectively starting and terminating a text diversion when they appear
  482. literally together in the same input line.
  483. .PP
  484. The difference between $? and $^ can best be illustrated by an example,
  485. consider:
  486. .RS
  487. .sp
  488. .nf
  489. fred.out : joe amy hello
  490. \trules for making fred
  491. X
  492. fred.out : my.c your.h his.h her.h      # more prerequisites
  493. .fi
  494. .sp
  495. .RE
  496. Assume joe, amy, and my.c are newer then fred.out.  When
  497. .B dmake
  498. executes the recipe for making fred.out the values of the following macros
  499. will be:
  500. .RS
  501. .sp
  502. .nf
  503. .Is "$@ "
  504. .Ii "$@"
  505. --> fred.out
  506. .Ii "$*"
  507. --> fred
  508. .Ii "$?"
  509. --> joe amy my.c  # note the difference between $? and $^
  510. .Ii "$^"
  511. --> joe amy
  512. .Ii "$<"
  513. --> joe amy hello
  514. .Ii "$&"
  515. --> joe amy hello my.c your.h his.h her.h
  516. .fi
  517. .sp
  518. .RE
  519. .SH "FUNCTION MACROS"
  520. .B dmake
  521. supports a full set of functional macros.  One of these, the $(mktmp ...)
  522. macro, is discussed in detail in the TEXT DIVERSION section and is not
  523. covered here.
  524. .RS
  525. .sp
  526. .IP "$(\fBnull\fP,\fItext\fP \fBtrue\fP \fBfalse\fP)"
  527. expands the value of
  528. .I text.
  529. If it is NULL then the macro returns the value of the expansion of \fBtrue\fP
  530. and the expansion of \fBfalse\fP otherwise.  The terms \fBtrue\fP, and
  531. \fBfalse\fP must be strings containing no white\-space.
  532. .IP "$(\fB!null\fP,\fItext\fP \fBtrue\fP \fBfalse\fP)"
  533. Behaves identically to the previous macro except that the 
  534. .B true
  535. string is chosen if the expansion of
  536. .I text
  537. is not NULL.
  538. .IP "$(\fBeq\fP,\fItext_a\fP,\fItext_b\fP \fBtrue\fP \fBfalse\fP)"
  539. expands
  540. .I text_a
  541. and
  542. .I text_b
  543. and compares their results.  If equal it returns the result of the expansion
  544. of the 
  545. .B true
  546. term, otherwise it returns the expansion of the
  547. .B false
  548. term.
  549. .IP "$(\fB!eq\fP,\fItext_a\fP,\fItext_b\fP \fBtrue\fP \fBfalse\fP)"
  550. Behaves identically to the previous macro except that the 
  551. .B true
  552. string is chosen if the expansions of the two strings are not equal
  553. .IP "$(\fBshell\fP \fBcommand\fP)"
  554. Runs \fIcommand\fP as if it were part of a recipe and returns,
  555. separated by a single space, all the non-white
  556. space terms written to stdout by the command.
  557. For example:
  558. .RS
  559. .RS
  560. .sp
  561. $(shell ls *.c)
  562. .sp
  563. .RE
  564. will return \fI"a.c b.c c.c d.c"\fP if the files exist in the current
  565. directory.  The recipe modification flags \fB[+@%\-]\fP are honored if they
  566. appear as the first characters in the command.  For example:
  567. .RS
  568. .sp
  569. $(shell +ls *.c)
  570. .sp
  571. .RE
  572. will run the command using the current shell.
  573. .RE
  574. .IP "$(\fBsort\fP \fBlist\fP)"
  575. Will take all white\-space separated tokens in \fIlist\fP and will
  576. return their sorted equivalent list.
  577. .IP "$(\fBstrip\fP \fBdata\fP)"
  578. Will replace all strings of white\-space in data by a single space.
  579. .IP "$(\fBsubst\fP,\fIpat\fP,\fIreplacement\fP \fBdata\fP)"
  580. Will search for \fIpat\fP in
  581. .B data
  582. and will replace any occurrence of
  583. .I pat
  584. with the
  585. .I replacement
  586. string.
  587. .RS
  588. The expansion
  589. .RS
  590. .sp
  591. $(subst,.o,.c $(OBJECTS))
  592. .sp
  593. .RE
  594. is equivalent to:
  595. .RS
  596. .sp
  597. $(OBJECTS:s/.o/.c/)
  598. .sp
  599. .RE
  600. .RE
  601. .SH "DYNAMIC PREREQUISITES"
  602. .B dmake
  603. looks for prerequisites whose names contain macro expansions during target
  604. processing.  Any such prerequisites are expanded and the result of the
  605. expansion is used as the prerequisite name.  As an example the line:
  606. .sp
  607. \tfred : $$@.c
  608. .sp
  609. causes the $$@ to be expanded when \fBdmake\fP is making fred, and it resolves
  610. to the target \fIfred\fP.
  611. This enables dynamic prerequisites to be generated.  The value
  612. of @ may be modified by any of the valid macro modifiers.  So you can say for
  613. example:
  614. .sp
  615. \tfred.out : $$(@:b).c
  616. .sp
  617. where the $$(@:b) expands to \fIfred\fP.
  618. Note the use of $$ instead of $ to indicate the dynamic expansion, this
  619. is due to the fact that the rule line is expanded when it is initially parsed,
  620. and $$ then returns $ which later triggers the dynamic prerequisite expansion.
  621. If you really want a $ to be part of a prerequisite name you must use $$$$.
  622. Dynamic macro expansion is performed in all user defined rules,
  623. and the special targets .SOURCE*, and .INCLUDEDIRS.
  624. .SH "BINDING TARGETS"
  625. This operation takes a target name and binds it to an existing file, if
  626. possible.
  627. .B dmake
  628. makes a distinction between the internal target name of a target and its
  629. associated external file name.
  630. Thus it is possible for a target's internal name and its external
  631. file name to differ.
  632. To perform the binding, the following set of rules is used.
  633. Assume that we are
  634. trying to bind a target whose name is of the form \fIX.suff\fP,
  635. where \fI.suff\fP is the suffix and \fIX\fP is the stem portion
  636. (ie. that part which contains the directory and the basename).
  637. .B dmake
  638. takes this target name and performs a series of search operations that try to
  639. find a suitably named file in the external file system.
  640. The search operation is user controlled
  641. via the settings of the various .SOURCE targets.
  642. .RS
  643. .IP 1.
  644. If target has the .SYMBOL attribute set then look for it in the library.
  645. If found, replace the target name with the library member name and continue
  646. with step 2.  If the name is not found then return.
  647. .IP 2.
  648. Extract the suffix portion (that following the `.') of the target name.
  649. If the suffix is not null, look up the special target .SOURCE.<suff>
  650. (<suff> is the suffix).  
  651. If the special target exists then search each directory given in
  652. the .SOURCE.<suff> prerequisite list for the target.
  653. If the target's suffix was null (ie. \fI.suff\fP was empty) then 
  654. perform the above search but use the special target .SOURCE.NULL instead.
  655. If at any point a match is found then terminate the search.
  656. If a directory in the prerequisite list is the special name `.NULL ' perform
  657. a search for the full target name without prepending any directory portion
  658. (ie. prepend the NULL directory).
  659. (a default target of '.SOURCE : .NULL' is defined by \fBdmake\fP at startup,
  660. and is user redefinable)
  661. .IP 3.
  662. The search in step 2. failed.  Repeat the same search but this time
  663. use the special target .SOURCE.
  664. .IP 4.
  665. The search in step 3. failed.
  666. If the target has the library member attribute (.LIBMEMBER)
  667. set then try to find the target in the library which was passed along
  668. with the .LIBMEMBER attribute (see the MAKING LIBRARIES section).
  669. The bound file name assigned to a target which is successfully
  670. located in a library is the same name that would be assigned had the search
  671. failed (see 5.).
  672. .IP 5.
  673. The search failed.  Either the target was not found in any of the search
  674. directories or no applicable .SOURCE special targets exist.
  675. If applicable .SOURCE special targets exist, but the target was not found,
  676. then \fBdmake\fP assigns the first name searched as the bound file name.
  677. If no applicable .SOURCE special targets exist,
  678. then the full original target name becomes the bound file name.
  679. .RE
  680. .PP
  681. There is potential here for a lot of search operations.  The trick is to
  682. define .SOURCE.x special targets with short search lists and leave .SOURCE
  683. as short as possible.
  684. The search algorithm has the following useful side effect.
  685. When a target having the .LIBMEMBER (library member) attribute is searched for,
  686. it is first searched for as an ordinary file.
  687. When a number of library members require updating it is desirable to compile
  688. all of them first and to update the library at the end in a single operation.
  689. If one of the members does not compile and \fBdmake\fP stops, then
  690. the user may fix the error and make again.  \fBdmake\fP will not remake any
  691. of the targets whose object files have already been generated as long as
  692. none of their prerequisite files have been modified as a result of the fix.
  693. .PP
  694. When defining .SOURCE and .SOURCE.x targets the construct
  695. .sp
  696. \t.SOURCE :
  697. .br
  698. \t.SOURCE : fred gery
  699. .sp
  700. is equivalent to
  701. .sp
  702. \t.SOURCE :\- fred gery
  703. .PP
  704. \fBdmake\fP correctly handles the UNIX Make variable VPATH.  By definition VPATH
  705. contains a list of ':' separated directories to search when looking for a
  706. target.  \fBdmake\fP maps VPATH to the following special rule:
  707. .sp
  708. \t.SOURCE :^ $(VPATH:s/:/ /)
  709. .sp
  710. Which takes the value of VPATH and sets .SOURCE to the same set of directories
  711. as specified in VPATH.
  712. .SH "PERCENT(%) RULES AND MAKING INFERENCES"
  713. When \fBdmake\fP makes a target, the target's set of prerequisites (if any)
  714. must exist and the target must have a recipe which \fBdmake\fP
  715. can use to make it.
  716. If the makefile does not specify an explicit recipe for the target then
  717. .B dmake
  718. uses special rules to try to infer a recipe which it can use
  719. to make the target.  Previous versions of Make perform this task by using
  720. rules that are defined by targets of the form .<suffix>.<suffix> and by
  721. using the .SUFFIXES list of suffixes.  The exact workings of this mechanism
  722. were sometimes difficult to understand and often limiting in their usefulness.
  723. Instead, \fBdmake\fP supports the concept of \fI%-meta\fP rules.  
  724. The syntax and semantics of these rules differ from standard rule lines as
  725. follows:
  726. .sp
  727. .nf
  728. .RS
  729. \fI<%-target>\fP [\fI<attributes>\fP] \fI<ruleop>\fP [\fI<%-prerequisites>\fP] [;\fI<recipe>\fP]
  730. .RE
  731. .fi
  732. .sp
  733. where \fI%-target\fP is a target containing exactly a single `%' sign,
  734. .I attributes
  735. is a list (possibly empty) of attributes,
  736. .I ruleop
  737. is the standard set of rule operators,
  738. .I "%-prerequisites"
  739. \&, if present, is a list of prerequisites containing zero or more `%' signs,
  740. and
  741. .I recipe,
  742. if present, is the first line of the recipe.
  743. .PP
  744. The
  745. .I %-target
  746. defines a pattern against which a target whose recipe is
  747. being inferred gets matched.  The pattern match goes as follows:  all chars are
  748. matched exactly from left to right up to but not including the % sign in the
  749. pattern, % then matches the longest string from the actual target name
  750. not ending in
  751. the suffix given after the % sign in the pattern.
  752. Consider the following examples:
  753. .RS
  754. .sp
  755. .nf
  756. .Is "dir/%.c   "
  757. .Ii "%.c"
  758. matches fred.c but not joe.c.Z
  759. .Ii "dir/%.c"
  760. matches dir/fred.c but not dd/fred.c
  761. .Ii "fred/%"
  762. matches fred/joe.c but not f/joe.c
  763. .Ii "%"
  764. matches anything
  765. .fi
  766. .sp
  767. .RE
  768. In each case the part of the target name that matched the % sign is retained
  769. and is substituted for any % signs in the prerequisite list of the %-meta rule
  770. when the rule is selected during inference and
  771. .B dmake
  772. constructs the new dependency.
  773. As an example the following %-meta rules describe the following:
  774. .RS
  775. .sp
  776. %.c : %.y ; recipe...
  777. .sp
  778. .RE
  779. describes how to make any file ending in .c if a corresponding file ending
  780. in .y can be found.
  781. .RS
  782. .sp
  783. foo%.o : fee%.k ; recipe...
  784. .sp
  785. .RE
  786. is used to describe how to make fooxxxx.o from feexxxx.k.
  787. .RS
  788. .sp
  789. %.a :; recipe...
  790. .sp
  791. .RE
  792. describes how to make a file whose suffix is .a without inferring any
  793. prerequisites.
  794. .RS
  795. .sp
  796. %.c : %.y yaccsrc/%.y ; recipe...
  797. .sp
  798. .RE
  799. is a short form for the construct:
  800. .RS
  801. .sp
  802. %.c : %.y ; recipe...
  803. .br
  804. %.c : yaccsrc/%.y ; recipe...
  805. .sp
  806. .RE
  807. ie. It is possible to specify the same recipe for two %-rules by giving
  808. more than one prerequisite in the prerequisite list.
  809. A more interesting example is:
  810. .RS
  811. .sp
  812. % : RCS/%,v ; co $<
  813. .sp
  814. .RE
  815. which describes how to take any target and check it out of
  816. the RCS directory if the corresponding file exists in the RCS directory.
  817. The equivalent SCCS rule would be:
  818. .RS
  819. .sp
  820. % : s.% ; get $<
  821. .sp
  822. .RE
  823. .PP
  824. The previous RCS example defines an infinite rule, because it says how to make
  825. .I anything
  826. from RCS/%,v, and
  827. .I anything
  828. also includes RCS/fred.c,v.
  829. To limit the size of the graph that results from such rules
  830. .B dmake
  831. uses the macro variable PREP (stands for % repetition).  By default the value
  832. of this variable is 0, which says that no repetitions of a %-rule are to be
  833. generated.  If it is set to something greater than 0, then that many
  834. repetitions of any infinite %-rule are allowed.  If in the above
  835. example PREP was set to 1, then \fBdmake\fP would generate the dependency
  836. graph:
  837. .RS
  838. .sp
  839. % --> RCS/%,v --> RCS/RCS/%,v,v
  840. .sp
  841. .RE
  842. Where each link is assigned the same recipe as the first link.
  843. PREP should be used only in special cases, since it may result in
  844. a large increase in the number of possible prerequisites tested.
  845. .B dmake
  846. further assumes that any target that has no suffix can be made from
  847. a prerequisite that has at least one suffix.
  848. .PP
  849. .B dmake
  850. supports dynamic prerequisite generation for prerequisites of %-meta rules.
  851. This is best illustrated by an example.  The RCS rule shown above can infer
  852. how to check out a file from a corresponding RCS file only if the target
  853. is a simple file name with no directory information.  That is, the above rule
  854. can infer how to find \fIRCS/fred.c,v\fP from the target \fIfred.c\fP,
  855. but cannot infer how to find \fIsrcdir/RCS/fred.c,v\fP from \fIsrcdir/fred.c\fP
  856. because the above rule will cause \fBdmake\fP to look for RCS/srcdir/fred.c,v;
  857. which does not exist (assume that srcdir has its own RCS directory as is the
  858. common case).
  859. .PP
  860. A more versatile formulation of the above RCS check out rule is the following:
  861. .RS
  862. .sp
  863. % :  $$(@:d)RCS/$$(@:f),v : co $@
  864. .sp
  865. .RE
  866. This rule uses the dynamic macro $@ to specify the prerequisite to try to
  867. infer.  During inference of this rule the macro $@ is set to the value of
  868. the target of the %-meta rule and the appropriate prerequisite is generated by
  869. extracting the directory portion of the target name (if any), appending the
  870. string \fIRCS/\fP to it, and appending the target file name with a trailing
  871. \fI,v\fP attached to the previous result.
  872. .PP
  873. .B dmake
  874. can also infer indirect prerequisites.
  875. An inferred target can have a list of prerequisites added that will not
  876. show up in the value of $< but will show up in the value of $? and $&.
  877. Indirect prerequisites are specified in an inference rule by quoting the
  878. prerequisite with single quotes.  For example, if you had the explicit
  879. dependency:
  880. .RS
  881. .sp
  882. .nf
  883. fred.o : fred.c ; rule to make fred.o
  884. fred.o : local.h
  885. .fi
  886. .sp
  887. .RE
  888. then this can be inferred for fred.o from the following inference rule:
  889. .RS
  890. .sp
  891. %.o : %.c 'local.h' ; rule to make a .o from a .c
  892. .sp
  893. .RE
  894. You may infer indirect prerequisites that are a function of the value of '%'
  895. in the current rule.  The meta-rule:
  896. .RS
  897. .sp
  898. %.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
  899. .sp
  900. .RE
  901. infers an indirect prerequisite found in the INC directory whose name is the
  902. same as the expansion of $(INC), and the prerequisite name depends on the
  903. base name of the current target.
  904. The set of indirect prerequisites is attached to the meta rule in which they
  905. are specified and are inferred only if the rule is used to infer a recipe
  906. for a target.  They do not play an active role in driving the inference
  907. algorithm.
  908. The construct:
  909. .RS
  910. .sp
  911. %.o : %.c %.f 'local.h'; recipe
  912. .sp
  913. .RE
  914. is equivalent to:
  915. .RS
  916. .sp
  917. .nf
  918. %.o : %.c 'local.h' : recipe
  919. %.o : %.f 'local.h' : recipe
  920. .fi
  921. .sp
  922. .RE
  923. .PP
  924. If any of the attributes .SETDIR, .EPILOG, .PROLOG, .SILENT,
  925. \&.USESHELL, .SWAP, .PRECIOUS, .LIBRARY, .NOSTATE and .IGNORE
  926. are given for a %-rule then when that rule is bound to a target
  927. as the result of an inference, the target's set of attributes is augmented by
  928. the attributes from the above set that are specified in the bound %-rule.
  929. Other attributes specified for %-meta rules are not inherited by the target.
  930. The .SETDIR attribute is treated in a special way.
  931. If the target already had a .SETDIR attribute set then
  932. .B dmake
  933. changes to that directory prior to performing the inference.
  934. During inference any .SETDIR attributes for the inferred prerequisite
  935. are honored.
  936. The directories must exist for a %-meta rule to be selected as a possible
  937. inference path.  If the directories do not exist no error message is issued,
  938. instead the corresponding path in the inference graph is rejected.
  939. .PP
  940. .B dmake
  941. also supports the old format special target .<suffix>.<suffix>
  942. by identifying any rules
  943. of this form and mapping them to the appropriate %-rule.  So for example if
  944. an old makefile contains the construct:
  945. .RS
  946. .sp
  947. \&.c.o :; cc \-c $< \-o $@
  948. .sp
  949. .RE
  950. .B dmake
  951. maps this into the following %-rule:
  952. .RS
  953. .sp
  954. %.o : %.c; cc \-c $< \-o $@
  955. .sp
  956. .RE
  957. Furthermore,
  958. .B dmake
  959. understands several SYSV AUGMAKE special targets and maps them into
  960. corresponding %-meta rules.  These transformation must be enabled by providing
  961. the \-A flag on the command line or by setting the value of AUGMAKE to
  962. non\-NULL.
  963. The construct
  964. .RS
  965. .sp
  966. \&.suff :; recipe
  967. .sp
  968. .RE
  969. gets mapped into:
  970. .RS
  971. .sp
  972. % : %.suff; recipe
  973. .sp
  974. .RE
  975. and the construct
  976. .RS
  977. .sp
  978. \&.c~.o :; recipe
  979. .sp
  980. .RE
  981. gets mapped into:
  982. .RS
  983. .sp
  984. %.o : s.%.c ; recipe
  985. .sp
  986. .RE
  987. In general, a special target of the form .<str>~ is replaced by the %-rule
  988. construct s.%.<str>, thereby providing support for the syntax used by SYSV
  989. AUGMAKE for providing SCCS support.
  990. When enabled, these mappings allow processing of existing SYSV
  991. makefiles without modifications.
  992. .PP
  993. .B dmake
  994. bases all of its inferences on the inference graph constructed from the
  995. %-rules defined in the makefile.
  996. It knows exactly which targets can be made from which prerequisites by
  997. making queries on the inference graph.  For this reason .SUFFIXES is not
  998. needed and is completely ignored.
  999. .PP
  1000. For a %-meta rule to be inferred as the
  1001. rule whose recipe will be used to make a target, the target's name must match
  1002. the %-target pattern, and any inferred %-prerequisite must already exist or
  1003. have an explicit recipe so that the prerequisite can be made.
  1004. Without \fItransitive closure\fP on the inference graph the above rule
  1005. describes precisely when an inference match terminates the search.
  1006. If transitive closure is enabled (the usual case), and a prerequisite does
  1007. not exist or cannot be made, then
  1008. .B dmake
  1009. invokes the inference algorithm recursively on the prerequisite to see if
  1010. there is some way the prerequisite can be manufactured.  For, if the
  1011. prerequisite can be made then the current target can also be made using the
  1012. current %-meta rule.
  1013. This means that there is no longer a need to give a rule
  1014. for making a .o from a .y if you have already given a rule for making a .o
  1015. from a .c and a .c from a .y.  In such cases
  1016. .B dmake
  1017. can infer how to make the
  1018. \&.o from the .y via the intermediary .c and will remove the .c when the .o is
  1019. made.  Transitive closure can be disabled by giving the \-T switch on the
  1020. command line.
  1021. .PP
  1022. A word of caution.
  1023. .B dmake
  1024. bases its transitive closure on the %-meta rule targets.
  1025. When it performs transitive closure it infers how to make a target from a
  1026. prerequisite by performing a pattern match as if the potential prerequisite
  1027. were a new target.
  1028. The set of rules:
  1029. .RS
  1030. .nf
  1031. .sp
  1032. %.o : %.c :; rule for making .o from .c
  1033. %.c : %.y :; rule for making .c from .y
  1034. % : RCS/%,v :; check out of RCS file
  1035. .fi
  1036. .sp
  1037. .RE
  1038. will, by performing transitive closure, allow \fBdmake\fP to infer how to make
  1039. a .o from a .y using a .c as an intermediate temporary file.  Additionally
  1040. it will be able to infer how to make a .y from an RCS file, as long as that
  1041. RCS file is in the RCS directory and has a name which ends in .y,v.
  1042. The transitivity computation is performed dynamically for each target that
  1043. does not have a recipe.  This has potential to be costly if the %-meta
  1044. rules are not carefully specified.  The .NOINFER attribute is used to mark
  1045. a %-meta node as being a final target during inference.  Any node with this
  1046. attribute set will not be used for subsequent inferences.  As an example
  1047. the node RCS/%,v is marked as a final node since we know that if the RCS file
  1048. does not exist there likely is no other way to make it.  Thus the standard
  1049. startup makefile contains an entry similar to:
  1050. .RS
  1051. .nf
  1052. \&.NOINFER : RCS/%,v
  1053. .fi
  1054. .RE
  1055. Thereby indicating that the RCS file is the end of the inference chain.
  1056. X
  1057. Whenever the inference algorithm determines that a target can be made from
  1058. more than one prerequisite and the inference chains for the two methods
  1059. are the same length the algorithm reports an ambiguity and prints the
  1060. ambiguous inference chains.
  1061. .PP
  1062. .B dmake
  1063. tries to
  1064. remove intermediate files resulting from transitive closure if the file
  1065. is not marked as being PRECIOUS, or the \fB\-u\fP flag was not given on the
  1066. command line, and if the inferred intermediate did not previously exist.
  1067. Intermediate targets that existed prior to being made are never removed.
  1068. This is in keeping with the philosophy that
  1069. .B dmake
  1070. should never remove things from the file system that it did not add.
  1071. If the special target .REMOVE is defined and has a recipe then
  1072. .B dmake
  1073. constructs a list of the intermediate files to be removed and makes them
  1074. prerequisites of .REMOVE.  It then makes .REMOVE thereby removing the
  1075. prerequisites if the recipe of .REMOVE says to.  Typically .REMOVE is defined
  1076. in the startup file as:
  1077. .sp
  1078. \t.REMOVE :; $(RM) $<
  1079. .SH "MAKING TARGETS"
  1080. In order to update a target \fBdmake\fP must execute a recipe.
  1081. When a recipe needs to be executed it is first expanded so that any macros
  1082. in the recipe text are expanded, and it is then either executed directly or
  1083. passed to a shell.
  1084. .B dmake
  1085. supports two types of recipes.  The regular recipes and group recipes.
  1086. .PP
  1087. When a regular recipe is invoked \fBdmake\fP executes each line of the recipe
  1088. separately using a new copy of a shell if a shell is required.
  1089. SHAR_EOF
  1090. true || echo 'restore of dmake/man/dmake.tf failed'
  1091. fi
  1092. echo 'End of part 18, continue with part 19'
  1093. echo 19 > _shar_seq_.tmp
  1094. exit 0
  1095. exit 0 # Just in case...
  1096.