1 .\" Copyright (c) 1990,...,1995 Dennis Vadura, All rights reserved.
3 .\" You must use groff to format this man page!!!
5 .ds TB "0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.2i +0.5i +0.5i +2.0i
9 .nr dmake-indent \w@\\$1 @u
10 .IP "\\$1" \\n[dmake-indent]u
14 .nr dmake-indent \w@\\$1@u
19 .IP "\\$1" \\n[dmake-indent]u
22 .TH DMAKE 1 "2008-02-26" "Dmake Version 4.12"
24 \fBdmake\fR \- maintain program groups, or interdependent files
28 [\-P#] [\-{f|C|K} file] [\-{w|W} target ...]
29 [macro[[!][*][+][:]]=\fIvalue\fP ...]
30 [\-ABcdeEghiknpqrsStTuVxX] [\-v[cdfimrtw]] [\-m[trae]] [target ...]
35 is a re-implementation of the UNIX Make utility with significant enhancements.
37 executes commands found in an external file called a
39 to update one or more target names.
40 Each target may depend on zero or more prerequisite targets.
41 If any of the target's prerequisites is newer than the target or if the target
42 itself does not exist, then
44 will attempt to make the target.
48 command line option is present then
50 searches for an existing
52 from the list of prerequisites specified for the special target \fI.MAKEFILES\fR
53 (see the STARTUP section for more details).
54 If "\-" is the name of the file specified to the
56 flag then \fBdmake\fR uses standard input as the source of the makefile text.
58 Any macro definitions (arguments with embedded "="
59 signs) that appear on the command line are processed first
60 and supercede definitions for macros of the same name found
61 within the makefile. In general it is impossible for definitions found
62 inside the makefile to redefine a macro defined on the command line, see the
63 MACROS section for exceptions.
67 names are specified on the command line, then \fBdmake\fR uses the first
68 non-special target found in the makefile as the default target.
71 section for the list of special targets and their function.
72 Makefiles written for most previous
75 will be handled correctly by
77 Known differences between \fBdmake\fR and other versions of make
80 section found at the end of this document.
82 returns 0 if no errors were detected and a non-zero result if an error
86 Enable AUGMAKE special inference rule transformations
87 (see the "PERCENT(%) RULES" and "AUGMAKE META RULES" sections), these are
88 set to off by default.
90 Enable the use of spaces instead of <tabs> to begin recipe lines.
91 This flag equivalent to the .NOTABS special macro and is further described
94 Use non-standard comment stripping. If you specify \fB\-c\fP then
96 will treat any \fB#\fP character as a start of comment character wherever it
97 may appear unless it is escaped by a \e.
98 .IP "\fB\-C [+]file\fR"
99 This option writes to \fIfile\fP a copy of standard output and
100 standard error from any child processes and from the
102 process itself. If you specify a \fB+\fP prior to the file name then
103 the text is appended to the previous contents of \fIfile\fP.
104 This option is active in the MSDOS implementation only and is ignored
105 by non-MSDOS versions of
108 Disable the use of the directory cache. Normally \fBdmake\fP caches directories
109 as it checks file timestamps. Giving this flag is equivalent to the
110 \&.DIRCACHE attribute or macro being set to \fIno\fP.
112 Read the environment and define all strings of the
113 form '\fBENV\-VAR\fP=\fIevalue\fP'
114 defined within as macros whose name is \fBENV\-VAR\fP,
115 and whose value is '\fIevalue\fP'.
116 The environment is processed prior to processing the user
117 specified makefile thereby allowing definitions in the makefile to override
118 definitions in the environment.
120 Same as \-E, except that the environment is processed after the
121 user specified makefile has been processed
122 (thus definitions in the environment override definitions in the makefile).
123 The \-e and \-E options are mutually exclusive.
124 If both are given the latter takes effect.
126 Use \fBfile\fR as the source for the makefile text.
127 Only one \fB\-f\fR option is allowed.
129 Globally disable group recipe parsing, equivalent to the .IGNOREGROUP
130 attribute or macro being set to \fIyes\fP at the start of the makefile.
132 Print the command summary for \fBdmake\fR.
134 Tells \fBdmake\fR to ignore errors, and continue making other targets.
135 This is equivalent to the .IGNORE attribute or macro.
137 Turns on \fB.KEEP_STATE\fP state tracking and tells \fBdmake\fP to use
138 \fIfile\fP as the state file.
140 Causes \fBdmake\fR to ignore errors caused by command execution and to make
141 all targets not depending on targets that could not be made.
142 Ordinarily \fBdmake\fR stops after a command returns a non-zero status,
143 specifying \fB\-k\fR causes \fBdmake\fR to ignore the error
144 and continue to make as much as possible.
145 .IP "\fB\-m[trae]\fR"
146 Measure timing information. Print the time when targets and/or recipes
147 are started and finished to stdout. The following format is used:
149 \fB{s|e} {target|recipe} time maketarget\fP
151 \fBs\fP or \fBe\fP stands for started or ended, \fBtarget\fP or
152 \fBrecipe\fP denotes if this line refers to the whole target or a
153 recipe. \fBtime\fP is displayed in Unix time format, i.e. the number
154 of seconds since an epoch. (Since 1970-01-01T00:00:00Z). \fBmaketarget\fP
155 obviously represents the target the timing information is given for.
156 The optional flags \fB[trae]\fP can be used to change the information that
157 is displayed. If no optional flags are given only the \fBt\fP flag
158 is assumed to be selected, ie. \fB\-mt\fP. The optional flags stand for:
161 Display the start and end time of each target.
163 Display the start and end time of each recipe.
165 Display the target as an absolute path, i.e. prepend the current working
168 Also display the start and end time of the \fB$(shell command)\fP function
169 (aka. shell escape) macros.
172 Causes \fBdmake\fR to print out what it would have executed,
173 but does not actually execute the commands. A special check is made for
174 the string "$(MAKE)" inside a recipe line, if it is found,
175 the line is expanded and invoked, thereby enabling recursive makes to give a
176 full description of all that they will do.
177 This check is disabled inside group recipes.
179 Print out a version of the digested makefile in human readable form.
180 (useful for debugging, but cannot be re-read by \fBdmake\fP)
182 On systems that support multi-processing cause \fBdmake\fP to use \fI#\fP
183 concurrent child processes to make targets.
184 See the "MULTI PROCESSING" section for more information.
186 Check and see if the target is up to date. Exits with code 0 if up to date,
189 Tells \fBdmake\fR not to read the initial startup makefile, see STARTUP
190 section for more details.
192 Tells \fBdmake\fR to do all its work silently and not echo the commands it is
193 executing to stdout (also suppresses warnings).
194 This is equivalent to the .SILENT attribute or macro.
196 Force sequential execution of recipes on architectures which support
197 concurrent makes. For backward compatibility with old makefiles that have
198 nasty side-effect prerequisite dependencies. (Implies -P1)
200 Causes \fBdmake\fR to touch the targets and bring them up to date
201 without executing any commands.
202 Note that targets will not be created if they do not already exist.
204 Tells \fBdmake\fP to not perform transitive closure on the inference graph.
206 Force an unconditional update. (ie. do everything that would
207 be done if everything that a target depended on was out of date)
208 .IP "\fB\-v[cdfimrtw]\fR"
209 Verbose flag, when making targets print to stdout what we are going to make
210 and what we think its time stamp is. The optional flags \fB[cdfimrtw]\fP can be
211 used to restrict the information that is displayed. In the absence of any
212 optional flags all are assumed to be given (ie. \fB\-v\fP is equivalent to
213 \fB\-vcdfimrtw\fP). The meanings of the optional flags are:
216 Notify of directory cache operations only.
218 Notify of change directory operations only.
220 Notify of file I/O operations only.
222 Notify of inference algorithm operation only.
224 Notify of target update operations only.
226 Force output of recipe lines, warnings and executed commands. This switch
227 is usefull when debugging makefiles that disable the output using the @
228 or @@ property for recipe lines or the .SILENT target/attribute.
229 It also overrides the -s flag.
231 Keep any temporary files created; normally they are automatically deleted.
233 Notify of non-essential warnings (these are historical).
236 Print the version of \fBdmake\fR, and values of builtin macros.
237 .IP "\fB\-W target\fR"
238 Run \fBdmake\fP pretending that \fItarget\fP is out of date.
239 .IP "\fB\-w target\fR"
240 \fIWhat if?\fP Show what would be made if \fItarget\fP were out of date.
242 Upon processing the user makefile export all non-internally defined macros
243 to the user's environment. This option together with the \-e option
244 allows SYSV AUGMAKE recursive makes to function as expected.
246 Inhibit the execution of \fB#!\fP lines found at the beginning of a makefile.
247 The use of this flag prevents non-termination of recursive make invocations.
249 Here is a list of the sections that follow and a short description of each.
250 Perhaps you won't have to read the entire man page to find
252 .IP \fBSTARTUP\fP 1.9i
253 Describes \fBdmake\fP initialization.
254 .IP \fBSYNTAX\fP 1.9i
255 Describes the syntax of makefile expressions.
256 .IP \fBATTRIBUTES\fP 1.9i
257 Describes the notion of attributes and how they are used when
259 .IP \fBMACROS\fP 1.9i
260 Defining and expanding macros.
261 .IP "\fBRULES AND TARGETS" 1.9i
262 How to define targets and their prerequisites.
263 .IP \fBRECIPES\fP 1.9i
264 How to tell \fBdmake\fP how to make a target.
265 .IP "\fBBUILTIN COMMANDS\fP" 1.9i
266 Internal dmake commands.
267 .IP "\fBTEXT DIVERSIONS\fP" 1.9i
268 How to use text diversions in recipes and macro expansions.
269 .IP "\fBVIRTUAL TARGETS\fP" 1.9i
270 Targets that only enforce dependencies, but which can not create a target file.
271 .IP "\fBSPECIAL TARGETS\fP" 1.9i
272 Some targets are special.
273 .IP "\fBSPECIAL MACROS\fP" 1.9i
274 Macros used by \fBdmake\fP to alter the processing of the makefile,
275 and those defined by \fBdmake\fP for the user.
276 .IP "\fBCONTROL MACROS\fP" 1.9i
277 Itemized list of special control macros.
278 .IP "\fBRUNTIME MACROS\fP" 1.9i
279 Discussion of special run-time macros such as $@ and $<.
280 .IP "\fBFUNCTION MACROS\fP" 1.9i
281 Description of functional macros.
282 .IP "\fBCONDITIONAL MACROS\fP" 1.9i
283 Target specific conditional macros.
284 .IP "\fBDYNAMIC PREREQUISITES\fP" 1.9i
285 Processing of prerequisites which contain macro expansions in their name.
286 .IP "\fBBINDING TARGETS\fP" 1.9i
287 The rules that \fBdmake\fP uses to bind
288 a target to an existing file in the file system.
289 .IP "\fBPERCENT(%) RULES\fP" 1.9i
290 Specification of recipes to be used by the inference algorithm.
291 .IP "\fBMAKING INFERENCES\fP" 1.9i
292 The rules that \fBdmake\fP uses when inferring how to make a target which
293 has no explicit recipe. This and the previous section are really a single
295 .IP "\fBAUGMAKE META RULES\fP" 1.9i
296 A subclass of the \fBPERCENT(%) RULES\fP.
297 .IP "\fBMAKING TARGETS\fP" 1.9i
298 How \fBdmake\fP makes targets other than libraries.
299 .IP "\fBMAKING LIBRARIES\fP" 1.9i
300 How \fBdmake\fP makes libraries.
301 .IP "\fBKEEP STATE\fP" 1.9i
302 A discussion of how .KEEP_STATE works.
303 .IP "\fBMULTI PROCESSING\fP" 1.9i
304 Discussion of \fBdmake's\fP parallel make facilities for architectures that
306 .IP "\fBCONDITIONALS\fP" 1.9i
307 Conditional expressions which control the processing of the makefile.
308 .IP "\fBEXAMPLES\fP" 1.9i
309 Some hopefully useful examples.
310 .IP "\fBCOMPATIBILITY\fP" 1.9i
311 How \fBdmake\fP compares with previous versions of make.
312 .IP "\fBLIMITS\fP" 1.9i
313 Limitations of \fBdmake\fP.
314 .IP \fBPORTABILITY\fP 1.9i
315 Comments on writing portable makefiles.
317 Files used by \fBdmake\fP.
318 .IP "\fBSEE ALSO\fP" 1.9i
319 Other related programs, and man pages.
320 .IP "\fBAUTHOR\fP" 1.9i
321 The guy responsible for this thing.
327 begins execution it first processes the command line and then processes
328 an initial startup-makefile.
329 This is followed by an attempt to locate and process a user supplied makefile.
330 The startup file defines the default values of all required control macros
331 and the set of default rules for making targets and inferences.
332 When searching for the startup makefile,
334 searches the following locations, in the order specified,
335 until a startup file is located:
339 The location given as the value of the macro
340 MAKESTARTUP defined on the command line.
342 The location given as the value of the environment variable MAKESTARTUP
343 defined in the current environment.
345 The location given as the value of the macro
346 MAKESTARTUP defined internally within \fBdmake\fP. In this version, the
347 internal definition of MAKESTARTUP is "$(DMAKEROOT)/startup.mk", so you
348 can set the environment variable DMAKEROOT to the location of your startup
351 If DMAKEROOT is not changed, for native Windows dmake versions its value
352 defaults to "$(ABSMAKECMD:d)startup" (see definition of ABSMAKECMD for
354 For unix like versions build with the autotools build system it defaults
355 to the value of "${prefix}/share/startup" at build time. The actual value,
356 usually something like /usr/local/share/startup can be checked with the \-V
360 The above search is disabled by specifying the \-r option on the command line.
361 An error is issued if a startup makefile cannot be found and the \-r
362 option was not specified.
363 A user may substitute a custom startup file by defining
364 the MAKESTARTUP environment variable or by redefining the
365 MAKESTARTUP macro on the command line.
368 looks for the default startup file, check your environment or issue the command
371 A similar search is performed to locate a default user makefile when no
372 \fB\-f\fP command line option is specified.
373 By default, the prerequisite list of the special target .MAKEFILES
374 specifies the names of possible makefiles and the search order that
375 \fBdmake\fP should use to determine if one exists.
376 A typical definition for this target is:
379 \&.MAKEFILES : makefile.mk Makefile makefile
382 \fBdmake\fP will first look for makefile.mk and then the others.
384 cannot be found \fBdmake\fP will try to make it before going on to the next
385 prerequisite. For example, makefile.mk can be checked out of an RCS file
386 if the proper rules for doing so are defined in the startup file.
388 If the first line of the user makefile is of the form:
391 #!command command_args
394 then \fBdmake\fP will expand and run the command prior to reading any
395 additional input. If the return code of the command is zero then \fBdmake\fP
396 will continue on to process the remainder of the user makefile, if the return
397 code is non-zero then dmake will exit.
399 \fBdmake\fP builds the internal dependency graph as it parses a user specified
400 makefile. The graph is rooted at the special target \fB.ROOT\fP. .ROOT is the
401 top level target that dmake builds when it starts to build targets. All user
402 specified targets (those from the command line or taken as defaults from
403 the makefile) are made prerequisites of the special target \fB.TARGETS\fP.
404 \fBdmake\fP by default creates the relationship that .ROOT depends on .TARGETS
405 and as a result everything is made. This approach allows the user to customize, within
406 their makefile, the order and which, target, is built first. For example the
407 default makefiles come with settings for .ROOT that specify:
410 \&.ROOT .PHONY .NOSTATE .SEQUENTIAL : .INIT .TARGETS .DONE
413 with .INIT and .DONE defined as:
416 \&.INIT .DONE .PHONY:;
419 which nicely emulates the behaviour of Sun's make extensions. The building of
420 \&.ROOT's prerequisites is always forced to be sequential. However, this
421 definition is trivially changed by supplying the definition:
427 which skips the preamble and postamble phases of building .TARGETS.
430 that even though .INIT and .DONE are special exceptions, see section SPECIAL
431 TARGETS, the use of self defined targets starting with `.' should be avoided
432 as they would be handled as .<suffix> meta targets. The target names _INIT
433 and _DONE for example would work equally well without the .<suffix>
436 This section is a summary of the syntax of makefile statements.
437 The description is given in a style similar to BNF, where { } enclose
438 items that may appear zero or more times, and [ ] enclose items that
439 are optional. Alternative productions for a left hand side are indicated
440 by '\(->', and newlines are significant. All symbols in \fBbold\fP type
441 are text or names representing text supplied by the user.
444 .Ip "Makefile" "\(-> { Statement }"
445 .Ip "Statement" "\(-> Macro-Definition"
446 \(-> Conditional-Macro-Definition
449 \(-> Attribute-Definition
450 .Ip "Macro-Definition" "\(-> \fBMACRO = LINE\fP"
451 \(-> \fBMACRO [\fB!\fR]*= LINE\fP
452 \(-> \fBMACRO [\fB!\fR]:= LINE\fP
453 \(-> \fBMACRO [\fB!\fR]*:= LINE\fP
454 \(-> \fBMACRO [\fB!\fR]+= LINE\fP
455 \(-> \fBMACRO [\fB!\fR]+:= LINE\fP
456 .Ip "Conditional-Macro-Definition \(-> " "\fBTARGET\fP ?= Macro-Definition"
457 .Ip "Conditional \(-> " "\fB\&.IF\fR expression"
459 [ \fB.ELIF\fR expression
464 .Ip "expression" "\(-> \fBLINE\fR"
466 \(-> expression \fB==\fR expression
467 \(-> expression \fB!=\fR expression
468 \(-> expression \fB<=\fR expression
469 \(-> expression \fB>=\fR expression
470 \(-> \fB(\fR expression \fB)\fR
471 \(-> expression \fB||\fR expression
472 \(-> expression \fB&&\fR expression
473 .Ip "Rule-Definition \(-> " "target-definition"
476 target-definition \(-> targets [attrs] op { \fBPREREQUISITE\fP } [\fB;\fR rcp-line]
477 .Ip "targets" "\(-> target { targets }"
478 \(-> \fB"\fRtarget\fB"\fR { targets }
479 .Ip "target" "\(-> special-target"
481 .Ip "attrs" "\(-> attribute { attrs }"
482 \(-> \fB"\fRattribute\fB"\fR { attrs }
483 .Ip "op" "\(-> \fB:\fR { modifier }"
484 .Ip "modifier" "\(-> \fB:\fR"
489 .Ip "recipe" "\(-> { \fBTAB\fR rcp-line }"
490 \(-> [\fB@\fR[\fB@\fR]][\fB%\fR][\fB\-\fR] \fB[
496 .Ip "rcp-line" "\(-> [\fB@\fR[\fB@\fR]][\fB%\fR][\fB\-\fR][\fB+\fR] \fBLINE\fR"
497 .Ip Attribute-Definition "\(-> attrs \fB:\fR targets"
498 .Ip attribute "\(-> \fB.EPILOG\fR"
499 \(-> \fB.ERRREMOVE\fR
503 \(-> \fB.IGNOREGROUP\fR
511 \(-> \fB.SETDIR=\fIpath\fP\fR
513 \(-> \fB.SEQUENTIAL\fR
517 \(-> \fB.UPDATEALL\fR
519 .Ip "special-target" "\(-> \fB.ERROR\fR"
522 \(-> \fB.GROUPEPILOG\fR
523 \(-> \fB.GROUPPROLOG\fR
526 \(-> \fB.INCLUDEDIRS\fR
527 \(-> \fB.MAKEFILES\fR
531 \(-> \fB.SOURCE.\fIsuffix\fR
532 \(-> \fB.SUFFIXES (deprecated)\fR
537 \(-> .\fIsuffix1\fR.\fIsuffix2\fR
542 Where, \fBTAB\fP represents a <tab> character, \fBSTRING\fP represents an
543 arbitrary sequence of characters, and
544 \fBLINE\fP represents a
545 possibly empty sequence of characters terminated by a non-escaped
546 (not immediately preceded by a backslash '\e') new-line character.
547 \fBMACRO\fP, \fBPREREQUISITE\fP,
548 and \fBTARGET\fP each represent a string of characters not
549 including space or tab which respectively form the name of a macro,
550 prerequisite or target.
551 The name may itself be a macro expansion expression.
552 A \fBLINE\fP can be continued over several physical lines by terminating it with
553 a single backslash character. Comments are initiated by the
554 pound \fB#\fR character and extend to the end of line.
555 All comment text is discarded, a '#' may be placed into the makefile text
556 by escaping it with '\e' (ie. \e# translates to # when it is parsed).
557 An exception to this occurs when a # is seen inside
558 a recipe line that begins with a <tab> or is inside a group recipe.
559 If you specify the \fB\-c\fP command line switch then this behavior is
562 will treat all # characters as start of comment indicators unless they
564 A set of continued lines may be commented out by placing a single # at the
565 start of the first line.
566 A continued line cannot span more than one makefile.
568 \fBwhite space\fP is defined to be any combination of
569 <space>, <tab>, and the sequence \e<nl> when \e<nl> is used to terminate a
570 LINE. \fBNote\fP the special treatment of \e<nl> in macro definion and recipe
572 When processing \fBmacro definition\fP lines,
573 any amount of white space is allowed on either side of the macro operator
574 and white space is stripped from both before and after the macro
575 value string. A \e<nl> sequence in a macro definition is deleted from the
576 macro value before assigning this value.
577 During \fBrecipe expansion\fP the sequence \e<nl> is treated as white space
578 but is deleted from the final recipe string.
579 You must escape the \e<nl> with another \e in order to get a \e at the end
580 of a recipe or macro definition line.
582 When processing \fBtarget\fP definition lines,
583 the recipe for a target must, in general, follow the first definition
584 of the target (See the RULES AND TARGETS section for an exception), and
585 the recipe may not span across multiple makefiles.
586 Any targets and prerequisites found on a target definition line are taken
587 to be white space separated tokens.
588 The rule operator (\fIop\fP in SYNTAX section) is also considered
589 to be a token but does not require
590 white space to precede or follow it. Since the rule operator begins with a `:',
591 traditional versions of make do not allow the `:' character to
592 form a valid target name. \fBdmake\fP allows `:' to be present in
593 target/prerequisite names as long as the entire target/prerequisite name is
598 would be parsed as TARGET = a, PREREQUISITES={fred, :, test}, which
599 is not what was intended. To fix this you must write:
603 Which will be parsed as expected. Quoted target and prerequisite
604 specifications may also contain white space thereby allowing the use of
605 complex function macro expressions..
606 See the EXAMPLES section for how to apply \fB"\fP quoting
607 to a list of targets.
610 defines several target attributes. Attributes may be
611 assigned to a single target, a group of targets, or to all targets in the
612 makefile. Attributes are used to modify
613 \fBdmake\fP actions during target update.
614 The recognized attributes are:
616 .IP \fB.EPILOG\fP 1.2i
617 Insert shell epilog code when executing a group recipe associated with
618 any target having this attribute set.
619 .IP \fB.ERRREMOVE\fP 1.2i
620 Always remove any target having this attribute if an error is encountered
621 while making them. Setting this attribute overrides the .PRECIOUS attribute.
622 .IP \fB.EXECUTE\fP 1.2i
623 If the \-n flag was given then execute the recipe associated with any
624 target having this attribute set.
625 .IP \fB.FIRST\fP 1.2i
626 Used in conjunction with .INCLUDE. Terminates the inclusion with the first
627 successfully included prerequisite.
628 .IP \fB.GROUP\fP 1.2i
629 Force execution of a target's recipe as a group recipe.
630 .IP \fB.IGNORE\fP 1.2i
631 Ignore an error when trying to make any target with this attribute set.
632 .IP \fB.IGNOREGROUP\fP 1.2i
633 Disable the special meaning of '[' to initiate a group recipe.
634 .IP \fB.LIBRARY\fP 1.2i
636 .IP \fB.MKSARGS\fP 1.2i
637 If running in an MSDOS environment then use MKS extended argument passing
638 conventions to pass arguments to commands. Non-MSDOS
639 environments ignore this attribute.
640 .IP \fB.NOINFER\fP 1.2i
641 Any target with this attribute set will not be subjected
642 to transitive closure if it is inferred as a prerequisite
643 of a target whose recipe and prerequisites are being inferred.
644 (i.e. the inference algorithm will not use any prerequisite with this attribute
646 If specified as '.NOINFER:' (ie. with no prerequisites or targets) then the
647 effect is equivalent to specifying \fB\-T\fP on the command line.
648 .IP \fB.NOSTATE\fP 1.2i
649 Any target with this attribute set will not have command line flag
650 information stored in the state file if .KEEP_STATE has been enabled.
651 .IP \fB.PHONY\fP 1.2i
652 Any target with this attribute set will have its recipe executed
653 each time the target is made even if a file matching the target name can
654 be located. Any targets that have a .PHONY attributed target as a
655 prerequisite will be made each time the .PHONY attributed prerequisite is
657 .IP \fB.PRECIOUS\fP 1.2i
658 Do not remove associated target under any circumstances.
659 Set by default for any targets whose corresponding files exist in the file
660 system prior to the execution of \fBdmake\fP.
661 .IP \fB.PROLOG\fP 1.2i
662 Insert shell prolog code when executing a group recipe associated with
663 any target having this attribute set.
664 .IP \fB.SEQUENTIAL\fP 1.2i
665 Force a sequential make of the associated target's prerequisites. If set
666 as a global attribute this implies setting MAXPROCESS=1.
667 .IP \fB.SETDIR\fP 1.2i
668 Change current working directory to specified directory when making the
669 associated target. You must
670 specify the directory at the time the attribute is specified. To do this
671 simply give \fI.SETDIR=path\fP as the attribute. \fIpath\fP is expanded and
672 the result is used as the value of the directory to change to.
673 If \fIpath\fP contains \fB$$@\fP then the name of the target to be built is
674 used in computing the path to change directory to.
675 If path is surrounded by single quotes then path is not expanded, and is used
676 literally as the directory name.
677 If the \fIpath\fP contains any `:' characters then the entire attribute string
678 must be quoted using ".
679 If a target having this attribute set also has the .IGNORE
680 attribute set then if the change to the specified directory fails it will be
681 ignored, and no error message will be issued.
682 .IP \fB.SILENT\fP 1.2i
683 Do not echo the recipe lines when making any target with this attribute set,
684 and do not issue any warnings.
687 when making a target with this attribute set swap the \fBdmake\fP executable
688 to disk prior to executing the recipe line. Also see the '%' recipe line
689 flag defined in the RECIPES section.
690 .IP \fB.SYMBOL\fP 1.2i
691 Target is a library member and is an entry point into a module in the
692 library. This attribute is used only when searching a library for a target.
693 Targets of the form lib((entry)) have this attribute set automatically.
694 .IP \fB.USESHELL\fP 1.2i
695 Force each recipe line of a target to be executed using a shell.
696 Specifying this attribute is equivalent to specifying the '+' character at the
697 start of each line of a non-group recipe.
698 .IP \fB.UPDATEALL\fP 1.2i
699 Indicates that all the targets listed in this rule are updated by the
700 execution of the accompanying recipe.
701 A common example is the production of the
707 when it is run on a grammar. Specifying .UPDATEALL in such a rule
708 prevents the running of yacc twice, once for the y.tab.c file and once
709 for the y.tab.h file. .UPDATEALL targets that are specified in a single rule
710 are treated as a single target and all timestamps are updated whenever any
711 target in the set is made. As a side-effect, \fBdmake\fP internally sorts
712 such targets in ascending alphabetical order and the value of $@ is always
713 the first target in the sorted set.
714 .IP \fB.WINPATH\fP 1.2i
715 Switch between default (POSIX) and Windows style path representation.
716 (This attribute is specific for cygwin dmake executables and non-cygwin
717 environments ignore this attribute.)
719 Under Cygwin it can be useful to generate Windows style paths (with
720 regular slashes) instead of the default cygwin style (POSIX) paths
721 for dmake's dynamic macros.
722 The affected macros are $@, $*, $>, $?, $<, $&, $^ and $(MAKEDIR), $(PWD),
723 $(TMD), $(TMPFILE) and the $(mktmp ...) function macro.
724 This feature can be used to create DOS style path parameters
725 for native W32 programs from dynamic macros.
727 \fBNote\fP that the Windows style paths use regular slashes ('/') instead
728 of the usual Windows backslash ('\\') as directory separator to avoid quoting
729 problems (after all it is still a cygwin \fBdmake\fP!) and cygwin, as well
730 as native Windows, programs should have no problems using this (c:/foo/bar)
733 Example: Assuming the current target to be /tmp/mytarget the $@ macro
734 without .WINPATH active expands to:
741 With .WINPATH set it expands to:
744 C:/cygwin/tmp/mytarget
748 All attributes are user setable and except for .UPDATEALL and .MKSARGS
749 may be used in one of two forms.
750 The .MKSARGS attribute is restricted to use as a global attribute, and
751 the use of the .UPDATEALL attribute is restricted to rules
752 of the second form only.
754 \tATTRIBUTE_LIST : \fItargets\fP
756 assigns the attributes specified by ATTRIBUTE_LIST to each target in
760 \t\fItargets\fP ATTRIBUTE_LIST : ...
762 assigns the attributes specified by ATTRIBUTE_LIST to each target in
766 is empty (ie. a NULL list), then the
767 list of attributes will apply to all targets in the makefile
768 (this is equivalent to the common Make construct of \fI".IGNORE :"\fP
769 but has been modified to the notion of an attribute instead of
771 Not all of the attributes have global meaning.
772 In particular, .LIBRARY, .NOSTATE, .PHONY, .SETDIR, .SYMBOL and .UPDATEALL
773 have no assigned global meaning.
775 Any attribute may be used with any target, even with the special targets.
776 Some combinations are useless (e.g. .INCLUDE .PRECIOUS: ... ),
777 while others are useful (e.g. .INCLUDE .IGNORE : "file.mk" will not complain
778 if file.mk cannot be found using the include file search rules,
779 see the section on SPECIAL TARGETS for a description of .INCLUDE).
780 If a specified attribute will not be used with the special target a warning
781 is issued and the attribute is ignored.
784 supports six forms of macro assignment.
786 .IP "\fBMACRO = LINE\fP" 1.55i
787 This is the most common and familiar form of macro assignment. It assigns
788 LINE literally as the value of MACRO.
789 Future expansions of MACRO recursively expand its value.
790 .IP "\fBMACRO *= LINE\fP" 1.55i
791 This form behaves exactly as the simple '=' form with the exception that if
792 MACRO already has a value then the assignment is not performed.
793 .IP "\fBMACRO := LINE\fP" 1.55i
794 This form differs from the simple '=' form in that it expands LINE
795 prior to assigning it as the value of MACRO.
796 Future expansions of MACRO do not recursively expand its value.
797 .IP "\fBMACRO *:= LINE\fP" 1.55i
798 This form behaves exactly as the ':=' form with the exception that if
799 MACRO already has a value then the assignment and expansion are not performed.
800 .IP "\fBMACRO += LINE\fP" 1.55i
801 This form of macro assignment allows macro values to grow. It takes the
802 literal value of LINE and appends it to the previous value of MACRO separating
803 the two by a single space.
804 Future expansions of MACRO recursively expand its value.
805 .IP "\fBMACRO +:= LINE\fP" 1.55i
806 This form is similar to the '+=' form except that the value of LINE is expanded
807 prior to being added to the value of MACRO.
809 Macro expressions specified on the command line allow the macro value
810 to be redefined within the makefile only if the macro is defined using
811 the '+=' and '+:=' operators. Other operators will define a macro that cannot
814 Each of the preceeding macro assignment operators may be prefixed by \fB!\fP
815 to indicate that the assignment should be forced and that no warnings should
816 be issued. Thus, specifying \fB!\fP has the effect of silently forcing the
817 specified macro assignment.
819 When \fBdmake\fP defines a non-environment macro it strips leading and
820 trailing white space from the macro value.
821 Macros imported from the environment via either the .IMPORT special
822 target (see the SPECIAL TARGETS section), or the \fB\-e\fP, or \fB\-E\fP flags
823 are an exception to this rule. Their values are
824 always taken literally and white space is never stripped.
825 In addition, named macros defined using the .IMPORT special target do
826 not have their values expanded when they are used within a makefile.
827 In contrast, environment macros that are imported
828 due to the specification of the \fB\-e\fP or \fB\-E\fP flags
829 are subject to expansion when used.
831 To specify a macro expansion
832 enclose the name in () or {} and precede it with a dollar sign $.
833 Thus $(TEST) represents an expansion of the macro variable named TEST.
835 defined then $(TEST) is replaced by its expanded value. If TEST is not
836 defined then $(TEST) expands to the NULL string (this is equivalent to
837 defining a macro as 'TEST=' ). A short form may be used for single character
838 named macros. In this case the parentheses are optional, and $(I) is
840 Macro expansion is recursive, hence, if the value string contains an expression
841 representing a macro expansion, the expansion is performed. Circular macro
842 expansions are detected and cause an error to be issued.
844 When defining a macro the given macro name is first expanded before being used
845 to define the macro. Thus it is possible to define macros whose names
846 depend on values of other macros. For example, suppose CWD is defined as
850 then the value of $(CWD) is the name of the current directory.
851 This can be used to define macros specific to this directory, for
854 \t_$(CWD).prt = list of files to print...
856 The actual name of the defined macro is a function of the current directory.
857 A construct such as this is useful when processing a hierarchy of directories
858 using .SETDIR attributed targets and a collection of small distributed
861 Macro variables may be defined within the makefile, on the command
862 line, or imported from the environment.
865 supports several non-standard macro expansions:
866 The first is of the form:
868 .IP \fI$(macro_name:modifier_list:modifier_list:...)\fR
873 may be a combination of:
878 \- file (not including suffix) portion of path names
880 \- directory portion of all path names
882 \- suffix portion of path names
884 \- file (including suffix) portion of path names
886 \- inferred names of targets
888 \- normalized path names
890 \- macro value in lower case
892 \- macro value in upper case
894 \- return the first white space separated token from value
901 \- map escape codes found in macro to their ASCII value
903 \- simple pattern substitution
907 \- prepend a prefix to each token
909 \- append a suffix to each token
913 Thus if we have the example:
915 test = d1/d2/d3/a.out f.out d1/k.out
917 The following macro expansions produce the values on the right of '\(->' after
921 .Is "$(test:s/out/in/:f) "
927 \(-> a.out f.out k.out
929 \(-> d1/d2/d3/a f d1/k
930 .Ii "${test:s/out/in/:f}"
933 \(-> a.out+f.out+k.out
937 \(-> D1/D2/D3/A.OUT F.OUT D1/K.OUT
945 test = d1/d2/../a.out "d1/file name.ext"
947 the following results are returned:
950 .Is "$(test:s/out/in/:f) "
952 \(-> d1/a.out "d1/file name.ext"
956 If a token ends in a string composed from the value of the macro DIRBRKSTR
957 (ie. ends in a directory separator string, e.g. '/' in UNIX) and you use the
958 \fB:d\fP modifier then the expansion returns the directory name less the
959 final directory separator string. Thus successive pairs of :d modifiers
960 each remove a level of directory in the token string.
962 The infered names of targets \fB:i\fP modifier returnes the actual filename
963 associated to the target, see BINDING TARGETS. If the value is not a target or
964 prerequisite the value is returned unchanged. For the following example:
968 If aprog and bprog are targets or prerequisits and they are bound
969 to /tmp/aprog and bprog (see .SOURCE special target) the macro expansion
970 has the following effect:
973 .Is "$(test:s/out/in/:f) "
975 \(-> /tmp/aprog bprog
979 The normalized path names \fB:n\fP modifier honors the setting of .WINPATH to
980 determine the output format of the result.
982 The map escape codes modifier changes the following escape codes \ea => <bel>,
983 \&\eb => <backspace>, \ef => <formfeed>, \en => <nl>, \er => <cr>,
984 \&\et => <tab>, \ev => <vertical tab>, \e" => ", and \exxx => <xxx> where
985 xxx is the octal representation of a character into the corresponding ASCII
988 The tokenization, prepend and append modifier may use the same escape codes
989 that are supported by the map escape codes modifier in the string that is
990 inserted, prepended or added by the respective macro modifier.
991 These modifiers may quote this string to include otherwise problematic
992 characters. E.g. spaces, colons and parentheses.
994 The tokenization modifier takes all white space separated tokens from the
995 macro value and separates them by the separator string. Thus the
1010 The prefix operator \fB^\fP takes all white space separated tokens from the
1011 macro value and prepends \fIstring\fP to each.
1019 mydir/a.out mydir/f.out mydir/k.out
1023 The suffix operator \fB+\fP takes all white space separated tokens from the
1024 macro value and appends \fIstring\fP to each.
1036 The next non-standard form of macro expansion allows for recursive macros.
1037 It is possible to specify a $(\fImacro_name\fR) or ${\fImacro_name\fR} expansion
1038 where \fImacro_name\fR contains more $( ... ) or ${ ... } macro expansions
1041 For example $(CC$(_HOST)$(_COMPILER)) will first expand CC$(_HOST)$(_COMPILER)
1042 to get a result and use that result as the name of the macro to expand.
1043 This is useful for writing a makefile for more than one target
1044 environment. As an example consider the following hypothetical case.
1045 Suppose that _HOST and _COMPILER are imported from the environment
1046 and are set to represent the host machine type and the host compiler
1051 CFLAGS_VAX_CC = \-c \-O # _HOST == "_VAX", _COMPILER == "_CC"
1052 CFLAGS_PC_MSC = \-c \-ML # _HOST == "_PC", _COMPILER == "_MSC"
1054 # redefine CFLAGS macro as:
1056 CFLAGS := $(CFLAGS$(_HOST)$(_COMPILER))
1060 This causes CFLAGS to take on a value that corresponds to the
1061 environment in which the make is being invoked.
1063 The final non-standard macro expansion is of the form:
1066 string1{token_list}string2
1069 where string1, string2 and token_list are expanded. After expansion,
1070 string1 is prepended to each token found in token_list and
1071 string2 is appended to each resulting token from the previous prepend.
1072 string1 and string2 are not delimited by white space
1073 whereas the tokens in token_list are.
1074 A null token in the token list
1075 is specified using "".
1076 Thus using another example we have:
1079 .Is "test/{f1 f2}.o "
1080 .Ii "test/{f1 f2}.o"
1081 --> test/f1.o test/f2.o
1082 .Ii "test/ {f1 f2}.o"
1084 .Ii "test/{f1 f2} .o"
1085 --> test/f1 test/f2 .o
1086 .Ii "test/{""f1"" """"}.o"
1087 --> test/f1.o test/.o
1091 .Is "test/{d1 d2}/{f1 f2}.o --> "
1092 .Ii "test/{d1 d2}/{f1 f2}.o --> "
1093 test/d1/f1.o test/d1/f2.o
1094 test/d2/f1.o test/d2/f2.o
1098 This last expansion is activated only when the first characters of
1100 appear immediately after the opening '{' with no intervening white space.
1101 The reason for this restriction is the following incompatibility with
1102 Bourne Shell recipes. The line
1108 is valid /bin/sh syntax; while
1115 is not. Hence the latter triggers the enhanced macro expansion while the former
1116 causes it to be suppressed.
1117 See the SPECIAL MACROS section for a description of the special macros that
1118 \fBdmake\fP defines and understands.
1119 .SH "RULES AND TARGETS"
1120 A makefile contains a series of entries that specify dependencies.
1121 Such entries are called \fItarget/prerequisite\fP or \fIrule\fP definitions.
1122 Each rule definition
1123 is optionally followed by a set of lines that provide a recipe for updating
1124 any targets defined by the rule.
1127 attempts to bring a target up to date and an explicit recipe is provided with
1128 a rule defining the target, that recipe is used to update the
1129 target. A rule definition begins with a line having the following syntax:
1133 \fI<targets>\fP [\fI<attributes>\fP] \fI<ruleop>\fP [\fI<prerequisites>\fP] [;\fI<recipe>\fP]
1138 is a non-empty list of targets. If the target is a
1139 special target (see SPECIAL TARGETS section below) then it must appear alone
1140 on the rule line. For example:
1143 \&.IMPORT .ERROR : ...
1146 is not allowed since both .IMPORT and .ERROR are special targets.
1147 Special targets are not used in the construction of the dependency graph and
1151 is a possibly empty list of attributes. Any attribute defined in the
1152 ATTRIBUTES section above may be specified. All attributes will be applied to
1153 the list of named targets in the rule definition. No other targets will
1158 if both the target list and prerequisite list are empty but the attributes
1159 list is not, then the specified attributes affect all targets in the makefile.
1163 is a separator which is used to identify the targets from the prerequisites.
1164 Optionally it also provides a facility for modifying the way in which
1166 handles the making of the associated targets.
1167 In its simplest form the operator is a single ':', and need not be separated
1168 by white space from its neighboring tokens. It may additionally be followed
1169 by any of the modifiers { !, ^, \-, :, | }, where:
1172 says execute the recipe for the associated targets once for each out of date
1173 prerequisite. (The meaning of the runtime macro \fB$?\fP is changed, see
1176 section.) Ordinarily the recipe is executed
1177 once for all out of date prerequisites at the same time.
1179 says to insert the specified prerequisites, if any, before any
1180 other prerequisites already associated with the specified targets.
1181 In general, it is not useful to specify ^ with an empty
1182 list of prerequisites.
1184 says to clear the previous list of prerequisites before adding
1185 the new prerequisites. Thus,
1195 however the old form still works as expected.
1197 When the rule operator is not modified by a second ':'
1198 only one set of rules may be specified for making a target.
1199 Multiple definitions may be used to add to the
1200 list of prerequisites that a target depends on.
1201 However, if a target is multiply defined
1202 only one definition may specify a recipe
1203 for making the target.
1205 When a target's rule operator is modified by a second ':'
1206 (:: for example) then this definition may not be the only
1207 definition with a recipe for the target. There may be other :: target
1208 definition lines that specify a different set of prerequisites with a
1209 different recipe for updating the target.
1210 Any such target is made if any of the definitions
1211 find it to be out of date
1212 with respect to the related prerequisites
1213 and the corresponding recipe is used to update the
1214 target. By definition all '::' recipes that are found to be out of date for
1217 In the following simple example, each rule has a `::' \fIruleop\fP. In such an
1218 operator we call the first `:' the operator, and the second `:' the modifier.
1222 first recipe for making a.o
1225 second recipe for making a.o
1228 If a.o is found to be out of date with respect to a.c then the first recipe
1229 is used to make a.o. If it is found out of date with respect to a.y then
1230 the second recipe is used. If a.o is out of date with respect to
1231 b.h then both recipes are invoked to make a.o.
1232 In the last case the order of invocation corresponds to the order in which the
1233 rule definitions appear in the makefile.
1235 Is defined only for PERCENT rule target definitions. When specified it
1236 indicates that the following construct should be parsed using the old
1240 %.o :| %.c %.r %.f ; some rule
1244 %.o : %.c ; some rule
1245 %.o : %.r ; some rule
1246 %.o : %.f ; some rule
1249 Targets defined using a single `:' operator
1250 with a recipe may be redefined again with a new recipe by using a
1251 `:' operator with a `:' modifier.
1252 This is equivalent to a target having been
1253 initially defined with a rule using a `:' modifier.
1254 Once a target is defined using a `:'
1255 modifier it may not be defined again with a recipe using only the `:' operator
1256 with no `:' modifier. In both cases the use of a `:' modifier creates a new
1257 list of prerequisites and makes it the current prerequisite list for the target.
1258 The `:' operator with no recipe always modifies the current list
1260 Thus assuming each of the following definitions has a recipe attached, then:
1274 are legal and mean: add the recipe associated with (2), or (4) to the set
1275 of recipes for joe, placing them after existing recipes for
1291 are errors since we have two sets of perfectly good recipes for
1295 is a possibly empty list of targets that must be brought up to date before
1296 making the current target.
1299 is a short form and allows the user to specify short rule definitions
1301 It is taken to be the first recipe line in a larger recipe
1302 if additional lines follow the rule definition.
1303 If the semi-colon is present but the recipe line is empty (ie. null string)
1305 to be an empty rule. Any target so defined causes target to be treated
1306 as a virtual target, see VIRTUAL TARGETS below.
1308 The traditional format used by most versions of Make defines the recipe
1309 lines as arbitrary strings that may contain macro expansions. They
1310 follow a rule definition line and may be spaced
1311 apart by comment or blank lines.
1312 The list of recipe lines defining the recipe is terminated by a new target
1313 definition, a macro definition, or end-of-file.
1316 begin with a \fB<TAB>\fP character (or \fBspaces\fP, see \fB.NOTABS\fP)
1317 which may optionally be followed with one or all the following
1321 which affect the recipe execution:
1323 indicates that non-zero exit values (ie. errors)
1324 are to be ignored when this recipe line is executed.
1326 indicates that the current recipe line is to be executed using the shell. Group recipes implicitely ignore this property.
1330 should swap itself out to secondary storage (MSDOS only) before running the
1333 indicates that the recipe line should NOT be echoed to the terminal prior to
1336 is a stronger version of the previous property. The recipe line and the
1337 output (stdout and stderr) of the executed recipe are NOT shown on the
1340 Each property is off by default
1341 (ie. by default, errors are significant, commands are echoed, no swapping is
1343 used only if the recipe line contains a character found in the value of the
1345 Global settings activated via command line options or special attribute or
1346 target names may also affect these settings.
1354 second recipe line, executed independent of first.
1355 @a recipe line that is not echoed
1356 -and one that has errors ignored
1357 %and one that causes dmake to swap out
1358 +and one that is executed using a shell.
1363 The second and new format of the recipe block begins the block with the
1364 character '[' (the open group character) in the last non-white space
1365 position of a line, and terminates the
1366 block with the character ']' (the close group character)
1367 in the first non-white space position of a line.
1368 In this form each recipe line need not have a leading TAB. This is
1369 called a recipe group. Groups so defined are fed intact as a single
1370 unit to a shell for execution whenever the corresponding target needs to
1371 be updated. If the open group character '[' is preceded
1372 by one or all of the
1373 .I recipe properties
1375 then they apply to the entire group in the same way that they
1376 apply to single recipe lines. You may also specify '+' but it is
1377 redundant as a shell is already being used to run the recipe.
1378 See the MAKING TARGETS section for a description of how
1381 Here is an example of a group recipe:
1389 tall of these recipe lines are fed to a
1390 single copy of a shell for execution.
1395 .SH "BUILTIN COMMANDS"
1397 supports some builtin commands. An optional leading '+' describes that
1398 the builtin can be used also when being executed in a shell otherwise it
1399 is only implemented when used directly. Remember that if a character of the
1400 recipe is found in the SHELLMETAS macro the execution of the recipe in a
1402 .IP "[\fB+\fP]\fBnoop\fP [\fBsomething\fP]"
1403 The \fBnoop\fP internal command always returns success if used but it is
1404 not executed even though the rest of the commandline is evaluated.
1405 This command can be used to evaluate macro expansions at the runtime of the
1406 recipe without starting a real commmand.
1407 .IP "[\fB+\fP]<empty recipe>
1408 If an empty recipe line is encountered it is not executed. This sounds
1409 more trivial than it really is because the recipe could consist of
1410 macros that evaluated to empty or whitespace only strings.
1411 .IP "\fBecho\fP [\fB-n\fP] \fBdata\fP"
1412 This internal command prints data (with all leading whitespace removed, but
1413 otherwise literally) to stdout. If the '-n' switch is given no trailing
1414 newline is printed. Note that no quoting is removed nor that escape sequences
1417 No special treatment of buildin commands for group recipes is implemented
1418 even though the <empty recipe> will most propably also not be evaluated by
1419 most shells that can be used to handle the recipe groups.
1420 .SH "TEXT DIVERSIONS"
1422 supports the notion of text diversions.
1423 If a recipe line contains the macro expression
1426 $(mktmp[,[\fIfile\fP][,\fItext\fP]] \fIdata\fP)
1429 then all text contained in the \fIdata\fP expression is expanded and
1430 is written to a temporary file. The \fIdata\fP in the file will always
1431 be terminated from a new line character. The \fIfile\fP parameter can
1432 be used to override the name of the temporary file. If its expanded value
1433 is not empty it will be used instead of the unique and thread safe file
1434 name that otherwise would be generated internally. The return
1435 value of the macro is the name of the temporary file unless the \fItext\fP
1436 parameter is defined. In this case the return value is the expanded value
1440 can be any text and must be separated from the 'mktmp' portion of the
1441 macro name by white-space. The only restriction on the data text is that
1442 it must contain a balanced number of parentheses of the same kind as are
1443 used to initiate the $(mktmp ...) expression. For example:
1449 is legal and works as expected, but:
1452 $(mktmp text (to dump to file)
1455 is not legal. You can achieve what you wish by either defining a macro that
1456 expands to '(' or by using {} in the macro expression; like this:
1459 ${mktmp text (to dump to file}
1462 Since the temporary file is opened when the
1463 macro containing the text diversion expression is expanded, diversions may
1464 be nested and any diversions that are created as part of ':=' macro
1465 expansions persist for the duration of the
1468 If the \fIdata\fP text is to contain new lines the map escape codes macro
1469 expasion can be used. For example the expression:
1473 mytext:=this is a\entest of the text diversion
1475 cat $(mktmp $(mytext:m))
1485 where the temporary file contains two lines both of which are terminated
1487 A second more illustrative example generates a response file to an MSDOS
1492 OBJ = fred.obj mary.obj joe.obj
1494 link @$(mktmp $(^:t"+\en"))
1498 The result of making `all' in the second example is the command:
1501 link @/tmp/mk02394AA
1504 where the temporary file contains:
1514 The last line of the file is terminated by a new-line which is always
1515 inserted at the end of the \fIdata\fP string.
1517 If the optional \fIfile\fP specifier is present it can be used to specify
1518 the name of the temporary file to create. An example that would be useful
1519 for MSDOS users with a Turbo-C compiler
1522 $(mktmp,turboc.cfg $(CFLAGS))
1525 will place the contents of CFLAGS into a local \fIturboc.cfg\fP file.
1526 The second optional argument, \fItext\fP, if present alters the name
1527 of the value returned by the $(mktmp ...) macro.
1529 Under MS-DOS text diversions may be a problem. Many DOS tools require
1530 that path names which contain directories use the \e character to delimit
1531 the directories. Some users however wish to use the '/' to delimit pathnames
1532 and use environments that allow them to do so.
1533 The macro USESHELL is set to "yes" if the
1534 current recipe is forced to use a shell via the .USESHELL or '+' directives,
1535 otherwise its value is "no".
1538 startup files define the macro DIVFILE whose value is either the
1539 value of TMPFILE or the value of TMPFILE edited to replace any '/' characters
1540 to the appropriate value based on the current shell and whether it will be
1541 used to execute the recipe.
1543 Previous versions of
1545 defined text diversions using <+, +> strings,
1546 where <+ started a text diversion and +> terminated one.
1548 is backward compatible with this construct only
1549 if the <+ and +> appear literally
1550 on the same recipe line or in the same macro value string. In such instances
1559 which is fully output compatible with the earlier construct. <+, +>
1560 constructs whose text spans multiple lines must be converted by hand to use
1563 If the environment variable TMPDIR is defined then the
1564 temporary file is placed into the directory specified by that variable.
1565 A makefile can modify the location of temporary files by
1566 defining a macro named TMPDIR and exporting it using the .EXPORT special
1568 .SH "VIRTUAL TARGETS"
1570 allows to define targets with the sole purpose to enforce a dependency
1571 chain that are unable to create the target, hence virtual targets.
1572 When \fBdmake\fP tries to make a target, but only finds a target definition
1573 without recipe lines, it would normally issues
1574 a \fB"Don't know how to make ..."\fP error message, but if a target rule is
1575 terminated by a semicolon and has no following recipe lines,
1576 or if it has no recipe lines, but defines prerequisites,
1577 or if the AUGMAKE mode is enabled (see the COMPATIBILITY section for details),
1578 the target is treated as a virtual target and the error is suppressed. In
1579 addition to this, if the default target does not have recipe lines it is also
1580 treated as a virtual target.
1582 Virtual targets should not have a corresponding file therefore
1583 they inherit the time of their newest prerequisite if they have prerequisites,
1584 otherwise they get the current time assigned when being made.
1585 If the virtual target has a corresponding file a warning is issued, but the
1586 time stamp of that file is taken into account. The virtual target uses the
1587 time stamp of the corresponding file if it is newer than the one determined
1588 by the previous rule.
1589 .SH "SPECIAL TARGETS"
1590 This section describes the special targets that are recognized by \fBdmake\fP.
1591 Some are affected by attributes and others are not.
1592 .IP \fB.ERROR\fP 1.4i
1593 If defined then the recipe associated with this target is executed
1594 whenever an error condition is detected by \fBdmake\fP. All attributes that
1595 can be used with any other target may be used with this target. Any
1596 prerequisites of this target will be brought up to date during its processing.
1597 NOTE: errors will be ignored while making this target, in extreme cases this
1598 may cause some problems.
1599 .IP \fB.EXIT\fP 1.4i
1600 If this target is encountered while parsing a makefile then the parsing of the
1601 makefile is immediately terminated at that point.
1602 .IP \fB.EXPORT\fP 1.4i
1603 All prerequisites associated with this target are assumed to
1604 correspond to macro names and they and their values
1605 are exported to the environment as environment strings at the point in
1606 the makefile at which this target appears.
1607 Any attributes specified with this target are ignored.
1608 Only macros which have been assigned a value in the makefile prior to the
1609 export directive are exported, macros as yet undefined
1610 or macros whose value contains any of the characters "+=:*"
1613 Note that macros that are not expanded during the macro assignment and contain
1614 other macros will be written into the environment containing these other
1615 macros in the form of $(macroname).
1616 .IP \fB.IMPORT\fP 1.4i
1617 Prerequisite names specified for this target are searched for in the
1618 environment and defined as macros with their value taken from the environment.
1619 If the special name \fB.EVERYTHING\fP is used as a prerequisite name then
1620 all environment variables defined in the environment are imported.
1621 The functionality of the \fB\-E\fP flag can be forced by placing the construct
1622 \&\fI.IMPORT : .EVERYTHING\fP at the start of a makefile. Similarly, by
1623 placing the construct at the end, one can emulate the effect of the \fB\-e\fP
1625 If a prerequisite name cannot be found in the environment
1626 an error message is issued.
1627 \&.IMPORT accepts the .IGNORE attribute. When given, it causes \fBdmake\fP
1628 to ignore the above error.
1629 See the MACROS section for a description of the processing of imported macro
1631 .IP \fB.INCLUDE\fP 1.4i
1632 Parse another makefile just as if it had been located at the point of the
1633 \&.INCLUDE in the current makefile.
1634 The list of prerequisites gives the list of
1635 makefiles to try to read. If the list contains multiple makefiles then they
1636 are read in order from left to right. The following search rules are used
1637 when trying to locate the file. If the filename is surrounded by " or just
1638 by itself then it is searched for in the current directory. If it is not
1639 found it is then searched for in each of the directories specified
1640 as prerequisites of the \&.INCLUDEDIRS special target.
1641 If the file name is surrounded by < and >, (ie.
1642 <my_spiffy_new_makefile>) then it is searched for only in the directories
1643 given by the .INCLUDEDIRS special target. In both cases if the file name is a
1644 fully qualified name starting at the root of the file system then it is only
1645 searched for once, and the .INCLUDEDIRS list is ignored.
1646 If .INCLUDE fails to find the file it invokes the inference engine to
1647 try to infer and hence make the file to be included. In this way the
1648 file can be checked out of an RCS repository for example.
1650 the .IGNORE, .SETDIR, and .NOINFER attributes.
1651 If the .IGNORE attribute is given and the file
1652 cannot be found then \fBdmake\fP continues processing,
1653 otherwise an error message is generated.
1654 If the .NOINFER attribute is given and the file
1655 cannot be found then \fBdmake\fP will not attempt to
1656 \fIinfer and make\fP the file.
1657 The .SETDIR attribute causes
1659 to change directories to the specified directory prior to attempting the
1660 include operation. If all fails \fBdmake\fP attempts to \fImake\fP the file
1661 to be included. If making the file fails then \fBdmake\fP terminates unless
1662 the .INCLUDE directive also specified the .IGNORE attribute.
1663 If .FIRST is specified along with .INCLUDE then \fBdmake\fP attempts to
1664 include each named prerequisite and will terminate the inclusion with the
1665 first prerequisite that results in a successful inclusion.
1666 .IP \fB.INCLUDEDIRS\fP 1.4i
1667 The list of prerequisites specified for this target defines the set of
1668 directories to search when trying to include a makefile.
1669 .IP \fB.KEEP_STATE\fP 1.4i
1670 This special target is a synonym for the macro definition
1672 \&\t.KEEP_STATE := _state.mk
1674 It's effect is to turn on STATE keeping and to define \fI_state.mk\fP
1676 .IP \fB.MAKEFILES\fP 1.4i
1677 The list of prerequisites is the set of files to try to read as the default
1678 makefile. By default this target is defined as:
1680 \t\&.MAKEFILES : makefile.mk Makefile makefile
1682 .IP \fB.REMOVE\fP 1.4i
1683 The recipe of this target is used whenever \fBdmake\fP needs to remove
1684 intermediate targets that were made but do not need to be kept around.
1685 Such targets result from the application of transitive closure on the
1687 .IP \fB.ROOT\fP 1.4i
1688 The internal root of the dependency graph, see section STARTUP for details.
1689 .IP \fB.SOURCE\fP 1.4i
1690 The prerequisite list of this target defines a set of directories to check
1691 when trying to locate a target file name. See the section on BINDING of
1692 targets for more information.
1693 .IP \fB.SOURCE.suff\fP 1.4i
1694 The same as .SOURCE, except that the .SOURCE.suff list is searched first when
1695 trying to locate a file matching the a target whose name ends in the suffix
1697 .IP \fB.SUFFIXES\fP 1.4i
1698 This deprecated special target has no special meaning. Avoid its use.
1699 .IP \fB.TARGETS\fP 1.4i
1700 The internal targets that all user defined targets are prerequisites of,
1701 see section STARTUP for details.
1703 There are a few targets that are "slightly" special:
1712 These targets exist because of historical reasons, see the usage of .INIT
1713 and .DONE in section "STARTUP", they can be used and defined as ordinary
1714 targets but are special in the sense that even though they start with a `.'
1715 they are not treated as a .<suffix> meta target (See the AUGMAKE META RULES
1716 section for details).
1719 that self defined targets shouldn't use the prefix `.' as they would be
1720 handled as .<suffix> meta targets and dmake most propably would complain
1723 In addition to the special targets above,
1724 several other forms of targets are recognized and are considered special,
1725 their exact form and use is defined in the sections that follow.
1726 .SH "SPECIAL MACROS"
1728 defines a number of special macros. They are divided into three classes:
1729 control macros, run-time macros, and function macros.
1730 The control macros are used by
1732 to configure its actions, and are the preferred method of doing so.
1733 In the case when a control macro has the same function as a special
1734 target or attribute they share the same name as the special target or
1736 The run-time macros are defined when
1738 makes targets and may be used by the user inside recipes.
1739 The function macros provide higher level functions dealing with macro
1740 expansion and diversion file processing.
1741 .SH "CONTROL MACROS"
1742 To use the control macros simply assign them a value just like any other
1743 macro. The control macros are divided into three groups:
1744 string valued macros, character valued macros, and boolean valued macros.
1746 The following are all of the string valued macros.
1747 This list is divided into two groups. The first group gives the string
1748 valued macros that are defined internally and cannot be directly set by the
1750 .IP \fBABSMAKECMD\fP 1.6i
1751 \fBWarning!\fP This macro's value is differently defined for a native Windows
1752 dmake executable (compiled with MS Visual C++ or MinGW) and dmake for other
1753 operating systems or build with other compilers.
1755 In the first case its value is the absolute filename of the executable of
1756 the current dmake process, otherwise it is defined as the NULL string.
1757 .IP \fBINCDEPTH\fP 1.6i
1758 This macro's value is a string of digits representing
1759 the current depth of makefile inclusion.
1760 In the first makefile level this value is zero.
1761 .IP \fBMFLAGS\fP 1.6i
1762 Is the list of flags
1763 that were given on the command line including a leading switch character.
1764 The \-f flag is not included in this list.
1765 .IP \fBMAKECMD\fP 1.6i
1766 Is the name with which \fBdmake\fP was invoked.
1767 .IP \fBMAKEDIR\fP 1.6i
1768 Is the full path to the initial directory in which
1771 .IP \fBMAKEFILE\fP 1.6i
1772 Contains the string "\-f \fImakefile\fP" where, \fImakefile\fP is the name
1773 of initial user makefile that was first read.
1774 .IP \fBMAKEFLAGS\fP 1.6i
1775 Is the same as $(MFLAGS) but has no leading switch
1776 character. (ie. MFLAGS = \-$(MAKEFLAGS))
1777 .IP \fBMAKEMACROS\fP 1.6i
1778 Contains the complete list of macro expressions that were specified on the
1780 .IP \fBMAKETARGETS\fP 1.6i
1781 Contains the name(s) of the target(s), if any, that were
1782 specified on the command line.
1783 .IP \fBMAKEVERSION\fP 1.6i
1784 Contains a string indicating the current \fBdmake\fP version number.
1785 .IP \fBMAXPROCESSLIMIT\fP 1.6i
1786 Is a numeric string representing the maximum number of processes that
1787 \fBdmake\fP can use when making targets using parallel mode.
1789 Is permanently defined to be the NULL string.
1790 This is useful when comparing a conditional expression to an NULL value.
1792 Is the full path to the
1793 current directory in which make is executing.
1794 .IP \fBSPACECHAR\fP 1.6i
1795 Is permanently defined to contain one space character. This is useful
1796 when using space characters in function macros, e.g. subst, that
1797 otherwise would get deleted (leading/trailing spaces) or for using
1798 spaces in function macro parameters.
1799 .IP \fBTMPFILE\fP 1.6i
1800 Is set to the name of the most recent temporary file opened by \fBdmake\fP.
1801 Temporary files are used for text diversions and for group recipe processing.
1803 Stands for "To Make Dir", and
1804 is the path from the present directory (value of $(PWD)) to the directory
1805 that \fBdmake\fP was started up in (value of $(MAKEDIR)). If the present
1806 directory is the directory that \fBdmake\fP was started up in TMD will be
1807 set to the relative path ".". This allows to create valid paths by prepending
1808 $(TMD)$(DIRSEPSTR) to a relative path.
1809 This macro is modified when .SETDIR attributes are processed.
1810 TMD will usually be a relative path with the following two exceptions. If the
1811 relative path would go up until the root directory or if different drive
1812 letters (DOS file system) make a relative path impossible the absolute path
1813 from MAKEDIR is used.
1814 .IP \fBUSESHELL\fP 1.6i
1815 The value of this macro is set to "yes" if the current recipe is forced to
1816 use a shell for its execution via the .USESHELL or '+' directives, its value
1820 The second group of string valued macros control
1822 behavior and may be set by the user.
1823 .IP \fB.DIRCACHE\fP 1.6i
1824 If set to "yes" enables the directory cache (this is the default). If set to
1825 "no" disables the directory cache (equivalent to -d command-line flag).
1826 .IP \fB.DIRCACHERESPCASE\fP 1.6i
1827 If set to "yes" causes the directory cache, if enabled, to respect
1828 file case, if set to "no" files are cached case insensitive.
1829 By default it is set to "no" on Windows as the filesystems on
1830 this operating system are case insensitive and set to "yes" for all
1831 other operating systems. The default can be overriden, if desired.
1833 \fBNote:\fP Using case insensitive directory caching on case sensitive
1834 file systems is a \fBBAD\fP idea. If in doubt use case sensitive
1835 directory caching even on case insensitive file systems as the
1836 worst case in this scenario is that /foo/bar/ and /foo/BAR/ are
1837 cached separately (with the same content) even though they are
1838 the same directory. This would only happen if different targets
1839 use different upper/lower case spellings for the same directory
1840 and that is \fBnever\fP a good idea.
1841 .IP \fBNAMEMAX\fP 1.6i
1842 Defines the maximum length of a filename component. The value of the variable
1843 is initialized at startup to the value of the compiled macro NAME_MAX. On
1844 some systems the value of NAME_MAX is too short by default. Setting a new
1845 value for NAMEMAX will override the compiled value.
1846 .IP \fB.NOTABS\fP 1.6i
1847 When set to "yes" enables the use of spaces as well as <tabs> to begin
1849 By default a non\-group recipe is terminated by a line without any leading
1850 white\-space or by a line not beggining with a <tab> character.
1851 Enabling this mode modifies the first condition of
1852 the above termination rule to terminate a
1853 non\-group recipe with a line that contains only white\-space.
1854 This mode does not effect the parsing of group recipes bracketed by [].
1855 .IP \fBAUGMAKE\fP 1.6i
1856 If set to "yes" value will enable the transformation of special
1857 meta targets to support special AUGMAKE inferences (See the "AUGMAKE
1858 META RULES" and "COMPATIBILITY" sections).
1859 .IP \fBDIRBRKSTR\fP 1.6i
1860 Contains the string of chars used to terminate
1861 the name of a directory in a pathname.
1862 Under UNIX its value is "/", under MSDOS its value is "/\e:".
1863 .IP \fBDIRSEPSTR\fP 1.6i
1864 Contains the string that is used to separate directory components when
1865 path names are constructed. It is defined with a default value at startup.
1866 .IP \fBDIVFILE\fP 1.6i
1867 Is defined in the startup file and gives the name that should be returned for
1868 the diversion file name when used in
1869 $(mktmp ...) expansions, see the TEXT DIVERSION section for details.
1870 .IP \fB.KEEP_STATE\fP 1.6i
1871 Assigning this macro a value tells
1873 the name of the state file to use and turns on the keeping of state
1874 information for any targets that are brought up to date by the make.
1875 .IP \fBGROUPFLAGS\fP 1.6i
1876 This macro gives the set of flags to pass to the shell when
1877 invoking it to execute a group recipe. The value of the macro is the
1878 list of flags with a leading switch indicator. (ie. `\-' under UNIX)
1879 .IP \fBGROUPSHELL\fP 1.6i
1880 This macro defines the full
1881 path to the executable image to be used as the shell when
1882 processing group recipes. This macro must be defined if group recipes are
1883 used. It is assigned a default value in the startup makefile. Under UNIX
1884 this value is /bin/sh.
1885 .IP \fBGROUPSUFFIX\fP 1.6i
1886 If defined, this macro gives the string to use as a suffix
1887 when creating group recipe files to be handed to the command interpreter.
1888 For example, if it is defined as .sh, then all
1889 temporary files created by \fBdmake\fP will end in the suffix .sh.
1890 Under MSDOS if you are using command.com as your GROUPSHELL, then this suffix
1891 must be set to .bat in order for group recipes to function correctly.
1892 The setting of GROUPSUFFIX and GROUPSHELL is done automatically for
1893 command.com in the startup.mk files.
1895 Is defined in the startup file by default.
1896 Initially this macro is defined to have the value "$(MAKECMD) $(MFLAGS)".
1897 The string $(MAKE) is recognized when using the \-n switch.
1898 .IP \fBMAKESTARTUP\fP 1.6i
1899 This macro defines the full path to the initial startup
1900 makefile. Use the \fB\-V\fP command line option to discover its initial
1902 .IP \fBMAXLINELENGTH\fP 1.6i
1903 This macro defines the maximum size of a single line of
1904 makefile input text. The size is specified as a number, the default value
1905 is defined internally and is shown via the \fB\-V\fP option.
1906 A buffer of this size plus 2 is allocated for reading makefile text. The
1907 buffer is freed before any targets are made, thereby allowing files containing
1908 long input lines to be processed without consuming memory during the actual
1910 This macro can only be used to extend the line length beyond it's default
1912 .IP \fBMAXPROCESS\fP 1.6i
1913 Specify the maximum number of child processes to use when making targets.
1914 The default value of this macro is "1" and its value cannot exceed the value
1915 of the macro MAXPROCESSLIMIT. Setting the value of MAXPROCESS on the command
1916 line or in the makefile is equivalent to supplying a corresponding value to
1917 the -P flag on the command line. If the global .SEQUENTIAL attribute is set
1918 (or the -S command line switch is used) the value of MAXPROCESS is fixed
1919 to "1" and cannot be changed.
1920 .IP \fBOOODMAKEMODE\fP 1.6i
1921 This macro enables a special compatibility mode needed by the OpenOffice.org
1922 build system. If set, the switch disables the removal of leading './' path
1923 elements during target filename normalization (See BINDING TARGETS). If './'
1924 appear in the pathname, but not at the beginning of it, they are still
1925 removed by the normalization. Please note that targets that are given on the
1926 command line are going to be registered as default targets \fBafter\fP the
1927 startup file is read.
1929 This macro defines the number of iterations to be expanded
1930 automatically when processing % rule definitions of the form:
1934 See the sections on PERCENT(%) RULES for details on how PREP is used.
1935 .IP \fBSHELL\fP 1.6i
1936 This macro defines the full path to the executable
1937 image to be used as the shell when
1938 processing single line recipes. This macro must be defined if recipes
1939 requiring the shell for execution are to be used.
1940 It is assigned a default value in the startup makefile.
1941 Under UNIX this value is /bin/sh.
1942 .IP \fBSHELLCMDQUOTE\fP 1.6i
1943 This macro can be used to add additional characters before and after the
1944 command string that is passed to the shell defined by the SHELL macro.
1945 If needed, like for \fIcmd.exe\fP and \fIcommand.com\fP, it is assigned
1946 a value in the startup file.
1947 .IP \fBSHELLFLAGS\fP 1.6i
1948 This macro gives the set of flags to pass to the shell when
1949 invoking it to execute a single line recipe. The value of the macro is the
1950 list of flags with a leading switch indicator. (ie. `\-' under UNIX)
1951 .IP \fBSHELLMETAS\fP 1.6i
1954 executes a single recipe line (not a group recipe) the line is
1955 searched for any occurrence of a character defined in the value of SHELLMETAS.
1956 If such a character is found the recipe line is defined to require a shell
1957 to ensure its correct execution. In such instances
1958 a shell is used to invoke the recipe line.
1959 If no match is found the recipe line is executed without the use of a shell.
1962 There is only one character valued macro defined by \fBdmake\fP:
1963 \fBSWITCHAR\fP contains the switch character used
1964 to introduce options on command lines. For UNIX its value is `\-', and for
1965 MSDOS its value may be `/' or `\-'.
1966 The macro is internally defined and is not user setable.
1967 The MSDOS version of \fBdmake\fP attempts to first extract SWITCHAR from an
1968 environment variable of the same name. If that fails it then attempts to
1969 use the undocumented getswitchar system call, and returns the result of
1970 that. Under MSDOS version 4.0 you must set the value of the environment
1971 macro SWITCHAR to '/' to obtain predictable behavior.
1973 All boolean macros currently understood by
1975 correspond directly to the previously defined attributes.
1976 These macros provide
1977 a second way to apply global attributes, and represent the
1978 preferred method of doing so. They are used by assigning them a
1979 value. If the value is not a NULL string then the boolean condition
1981 If the value is a NULL string then the condition is set to off.
1982 There are five conditions defined and they correspond directly to the
1983 attributes of the same name. Their meanings are defined in the ATTRIBUTES
1992 \&\fB.SEQUENTIAL\fP,
1996 Assigning any of these a non NULL value will globally set
1997 the corresponding attribute to on.
1998 .SH "RUNTIME MACROS"
1999 These macros are defined
2000 when \fBdmake\fP is making targets, and may take on different values for each
2001 target. \fB$@\fP is defined to be the full target name, \fB$?\fP is the
2002 list of all out of date prerequisites, except for the \fB!\fP ruleop, in
2003 which case it is set to the current build
2004 prerequisite instead. \fB$&\fP is the list of all
2005 prerequisites, \fB$>\fP is the name of the library if the current target is a
2007 \fB$<\fP is the list of prerequisites specified in the current rule.
2008 If the current target had a recipe inferred then \fB$<\fP is the name of the
2009 inferred prerequisite even if the target had a list of prerequisites supplied
2010 using an explicit rule that did not provide a recipe. In such situations
2011 \fB$&\fP gives the full list of prerequisites.
2013 \fB$*\fP is defined as
2014 \fB$(@:db)\fP when making targets with explicit recipes and is defined as the
2015 value of % when making targets whose recipe is the result of an inference.
2016 In the first case \fB$*\fP is the target name with no suffix,
2017 and in the second case, is the value of the matched % pattern from
2018 the associated %-rule.
2019 \fB$^\fP expands to the set of out of date prerequisites taken from the
2020 current value of \fB$<\fP.
2021 In addition to these,
2022 \fB$$\fP expands to $, \fB{{\fP expands to {, \fB}}\fP expands to }, and the
2023 strings \fB<+\fP and \fB+>\fP are recognized
2024 as respectively starting and terminating a text diversion when they appear
2025 literally together in the same input line.
2027 The difference between $? and $^ can best be illustrated by an example,
2032 fred.out : joe amy hello
2033 \trules for making fred
2035 fred.out : my.c your.h his.h her.h # more prerequisites
2039 Assume joe, amy, and my.c are newer then fred.out. When
2041 executes the recipe for making fred.out the values of the following macros
2052 --> joe amy my.c # note output of $? vs $^
2058 --> joe amy hello my.c your.h his.h her.h
2062 .SH "FUNCTION MACROS"
2064 supports a full set of functional macros. One of these, the $(mktmp ...)
2065 macro, is discussed in detail in the TEXT DIVERSION section and is not
2067 The names of function macros must appear literally after the opening $(
2068 or ${. They are \fBnot\fP recognized if they are the result of a recursive
2071 Note that some of these macros take comma separated parameters
2072 but that these parameters must not contain literal whitespaces. Whitespaces
2073 in macros used in these parameters are allowed.
2076 .IP "$(\fBand\fP \fBmacroterm ...\fP)"
2077 expands each \fBmacroterm\fP in turn until there are no more or one of
2078 them returns an empty string. If all expand to non-empty strings the
2079 macro returs the string "t" otherwise it returns an empty string.
2081 .IP "$(\fBassign\fP \fBexpression\fP)"
2082 Causes \fIexpression\fP to be parsed as a macro assignment expression and results
2083 in the specified assignment being made. An error is issued if the assignment
2084 is not syntatically correct. \fIexpression\fP may contain white space. This is
2085 in effect a dynamic macro assignment facility and may appear anywhere any
2086 other macro may appear. The result of the expanding a dynamic macro
2087 assignment expression is the name of the macro that was assigned and $(NULL)
2088 if the \fIexpression\fP is not a valid macro assignment expression.
2093 $(assign foo := fred)
2094 $(assign $(ind_macro_name) +:= $(morejunk))
2097 .IP "$(\fBecho\fP \fBlist\fP)"
2098 Echo's the value of \fIlist\fP. \fIlist\fP is not expanded.
2099 .IP "$(\fBeq\fP,\fItext_a\fP,\fItext_b\fP \fBtrue\fP \fBfalse\fP)"
2104 and compares their results. If equal it returns the result of the expansion
2107 term, otherwise it returns the expansion of the
2110 .IP "$(\fB!eq\fP,\fItext_a\fP,\fItext_b\fP \fBtrue\fP \fBfalse\fP)"
2111 Behaves identically to the previous macro except that the
2113 string is chosen if the expansions of the two strings are not equal
2114 .IP "$(\fBforeach\fP,\fIvar\fP,\fIlist\fP \fBdata\fP)"
2115 Implements iterative macro expansion over \fIdata\fP using \fBvar\fP as the
2116 iterator taking on values from \fIlist\fP. \fIvar\fP and \fIlist\fP are
2117 expanded and the result is the concatenation of expanding \fIdata\fP with
2118 \fIvar\fP being set to each whitespace separated token from \fIlist\fP.
2125 all :; echo [$(foreach,i,$(list) [$i])]
2137 The iterator variable is defined as a local variable to this foreach
2138 instance. The following expression illustrates this:
2142 $(foreach,i,$(foreach,i,$(sort c a b) root/$i) [$i/f.h])
2146 when evaluated the result is:
2150 [root/a/f.h] [root/b/f.h] [root/c/f.h]
2154 The specification of list must be a valid macro expression, such as:
2158 $($(assign list=a b c))
2164 and cannot just be the list itself. That is, the following foreach
2169 $(foreach,i,a b c [$i])
2183 .IP "$(\fBnil\fP \fBexpression\fP)"
2184 Always returns the value of $(NULL) regardless of what \fIexpression\fP is.
2185 This function macro can be used to discard results of expanding
2187 .IP "$(\fBnormpath\fP \fBlist\fP)"
2188 Will return the normalized path names of all white-space separated tokens
2189 in \fBlist\fP. Quotes can be used to normalize path names that contain
2190 white-space characters. On cygwin the result honors the setting of .WINPATH
2191 to determine the output format of the returned path names.
2192 .IP "$(\fBnormpath,para\fP \fBlist\fP)"
2193 Same as above except that the expanded value of \fBpara\fP is used to
2194 override the .WINPATH setting.
2195 .IP "$(\fBnot\fP \fBmacroterm\fP)"
2196 expands \fBmacroterm\fP and returs the string "t" if the result of the
2197 expansion is the empty string; otherwise, it returns the empty string.
2198 .IP "$(\fBnull\fP,\fItext\fP \fBtrue\fP \fBfalse\fP)"
2199 expands the value of
2201 If it is NULL then the macro returns the value of the expansion of \fBtrue\fP
2202 and the expansion of \fBfalse\fP otherwise. The terms \fBtrue\fP, and
2203 \fBfalse\fP must be strings containing no white\-space.
2204 .IP "$(\fB!null\fP,\fItext\fP \fBtrue\fP \fBfalse\fP)"
2205 Behaves identically to the previous macro except that the
2207 string is chosen if the expansion of
2210 .IP "$(\fBor\fP \fBmacroterm ...\fP)"
2211 expands each \fBmacroterm\fP in turn and returs the empty string if
2212 each term expands to the empty string; otherwise, it returs the string
2214 .IP "$(\fBshell\fP \fBcommand\fP)"
2215 is a shell escape macro. It runs \fIcommand\fP as if it were part of a
2216 recipe and returns, separated by a single space, all the non-white
2217 space terms written to stdout by the command.
2225 will return \fI"a.c b.c c.c d.c"\fP if the files exist in the current
2226 directory. The recipe modification flags \fB[+@%\-]\fP are honored if they
2227 appear as the first characters in the command. For example:
2233 will run the command using the current shell.
2235 \fBNote\fP that if the macro is part of a recipe it will be evaluated after
2236 all previous recipe lines have been executed. For obvious reasons it will be
2237 evaluated before the current recipe line or group recipe is executed.
2239 .IP "$(\fBshell,expand\fP \fBcommand\fP)"
2240 Is an extension to the \fB$(shell command)\fP function macro that expands the
2241 result of running \fBcommand\fP.
2242 .IP "$(\fBsort\fP \fBlist\fP)"
2243 Will take all white\-space separated tokens in \fIlist\fP and will
2244 return their sorted equivalent list.
2245 .IP "$(\fBstrip\fP \fBdata\fP)"
2246 Will replace all strings of white\-space in data by a single space.
2247 .IP "$(\fBsubst\fP,\fIpat\fP,\fIreplacement\fP \fBdata\fP)"
2248 Will search for \fIpat\fP in
2250 and will replace any occurrence of
2254 string. The expansion
2257 $(subst,.o,.c $(OBJECTS))
2266 .IP "$(\fBuniq\fP \fBlist\fP)"
2267 Will take all white\-space separated tokens in \fIlist\fP and will
2268 return their sorted equivalent list containing no duplicates.
2271 For historic reasons \fBdmake\fP treats the following case slightly special:
2274 $(\fBname\fP \fBsomething\fP)
2277 If it encounters a macro with a whitespace after \fBname\fP and \fBname\fP
2278 is not literally one of the above mentioned function macro identifiers then
2279 \fBdmake\fP will return the recursively expanded value of \fB$(name)\fP.
2280 The remaining \fBsomething\fP part will be expanded but the result will be
2281 discarded. The use of this special feature is deprecated and should not be
2284 .SH "CONDITIONAL MACROS"
2286 supports conditional macros. These allow the definition of target specific
2287 macro values. You can now say the following:
2290 \fBtarget\fP ?= \fIMacroName MacroOp Value\fP
2293 This creates a definition for \fIMacroName\fP whose value is \fIValue\fP
2294 only when \fBtarget\fP is being made. You may use a conditional macro
2295 assignment anywhere that a regular macro assignment may appear, including
2296 as the value of a $(assign ...) macro.
2298 The new definition is associated with the most recent cell definition
2299 for \fBtarget\fP. If no prior definition exists then one is created. The
2300 implications of this are immediately evident in the following example:
2306 all : cond;@echo "all done, foo=[$(foo)] bar=[$(bar)]"
2308 cond ?= bar := global decl
2310 cond .SETDIR=unix::;@echo $(foo) $(bar)
2313 cond .SETDIR=msdos::;@echo $(foo) $(bar)
2318 The first conditional assignment creates a binding for 'bar' that is
2319 activated when 'cond' is made. The bindings following the :: definitions are
2320 activated when their respective recipe rules are used. Thus the
2321 first binding serves to provide a global value for 'bar' while any of the
2322 cond :: rules are processed, and the local bindings for 'foo' come into
2323 effect when their associated :: rule is processed.
2325 Conditionals for targets of .UPDATEALL are all activated before the
2326 target group is made. Assignments are processed in order. Note that
2327 the value of a conditional macro assignment is NOT AVAILABLE until the
2328 associated target is made, thus the construct
2332 mytarget ?= bar := hello
2333 mytarget ?= foo := $(bar)
2337 results in $(foo) expanding to "", if you want the result to be "hello"
2342 mytarget ?= bar := hello
2343 mytarget ?= foo = $(bar)
2347 Once a target is made any associated conditional macros are deactivated
2348 and their values are no longer available. Activation occurrs after all
2349 inference, and .SETDIR directives have been processed and after $@ is
2350 assigned, but before prerequisites are processed; thereby making the values of
2351 conditional macro definitions available during construction of prerequisites.
2353 If a %-meta rule target has associated conditional macro assignments,
2354 and the rule is chosen by the inference algorithm then the conditional
2355 macro assignments are inferred together with the associated recipe.
2356 .SH "DYNAMIC PREREQUISITES"
2358 looks for prerequisites whose names contain macro expansions during target
2359 processing. Any such prerequisites are expanded and the result of the
2360 expansion is used as the prerequisite name. As an example the line:
2364 causes the $$@ to be expanded when \fBdmake\fP is making fred, and it resolves
2365 to the target \fIfred\fP.
2366 This enables dynamic prerequisites to be generated. The value
2367 of @ may be modified by any of the valid macro modifiers. So you can say for
2370 \tfred.out : $$(@:b).c
2372 where the $$(@:b) expands to \fIfred\fP.
2373 Note the use of $$ instead of $ to indicate the dynamic expansion, this
2374 is due to the fact that the rule line is expanded when it is initially parsed,
2375 and $$ then returns $ which later triggers the dynamic prerequisite expansion.
2376 Dynamic macro expansion is performed in all user defined rules, and the special
2377 targets .SOURCE*, and .INCLUDEDIRS.
2379 \fBNOTE:\fP The use of a \fB$\fP as part of a prerequisite or target name is
2380 \fBstrongly discouraged\fP as the runtime macros (like $@) are expanded when
2381 used in a recipe line so that the $ is interpreted as a macro identifier and
2382 not as a character of the filename leading to invalid runtime macros.
2383 In addition to this no filename normalization is done for prerequisites and
2384 targets that contain $ characters.
2385 Nevertheless it is possible to use $ in prerequisites by using $$$$ but this
2386 is \fBnot recommended\fP and can lead to surprising results.
2388 If dynamic macro expansion results in multiple white space separated tokens
2389 then these are inserted into the prerequisite list inplace of the dynamic
2390 prerequisite. Due to the recursive nature of macro expansion the prerequisite
2391 list is fully expanded even if the dynamic prerequisite contained other
2393 .SH "BINDING TARGETS"
2394 This operation takes a target name and binds it to an existing file, if
2397 makes a distinction between the internal target name of a target and its
2398 associated external file name.
2399 Thus it is possible for a target's internal name and its external
2400 file name to differ.
2401 To perform the binding, the following set of rules is used.
2403 trying to bind a target whose name is of the form \fIX.suff\fP,
2404 where \fI.suff\fP is the suffix and \fIX\fP is the stem portion
2405 (ie. that part which contains the directory and the basename).
2407 takes this target name and performs a series of search operations that try to
2408 find a suitably named file in the external file system.
2409 The search operation is user controlled
2410 via the settings of the various .SOURCE targets.
2413 If target has the .SYMBOL attribute set then look for it in the library.
2414 If found, replace the target name with the library member name and continue
2415 with step 2. If the name is not found then return.
2417 Extract the suffix portion (that following the `.') of the target name.
2418 If the suffix is not null, look up the special target .SOURCE.<suff>
2419 (<suff> is the suffix).
2420 If the special target exists then search each directory given in
2421 the .SOURCE.<suff> prerequisite list for the target.
2422 If the target's suffix was null (ie. \fI.suff\fP was empty) then
2423 perform the above search but use the special target .SOURCE.NULL instead.
2424 If at any point a match is found then terminate the search.
2425 If a directory in the prerequisite list is the special name `.NULL ' perform
2426 a search for the full target name without prepending any directory portion
2427 (ie. prepend the NULL directory).
2429 The search in step 2. failed. Repeat the same search but this time
2430 use the special target .SOURCE.
2431 (a default target of '.SOURCE : .NULL' is defined by \fBdmake\fP at startup,
2432 and is user redefinable)
2434 The search in step 3. failed.
2435 If the target has the library member attribute (.LIBMEMBER)
2436 set then try to find the target in the library which was passed along
2437 with the .LIBMEMBER attribute (see the MAKING LIBRARIES section).
2438 The bound file name assigned to a target which is successfully
2439 located in a library is the same name that would be assigned had the search
2442 The search failed. Either the target was not found in any of the search
2443 directories or no applicable .SOURCE special targets exist.
2444 If applicable .SOURCE special targets exist, but the target was not found,
2445 then \fBdmake\fP assigns the first name searched as the bound file name.
2446 If no applicable .SOURCE special targets exist,
2447 then the full original target name becomes the bound file name.
2450 There is potential here for a lot of search operations. The trick is to
2451 define .SOURCE.x special targets with short search lists and leave .SOURCE
2452 as short as possible.
2453 The search algorithm has the following useful side effect.
2454 When a target having the .LIBMEMBER (library member) attribute is searched for,
2455 it is first searched for as an ordinary file.
2456 When a number of library members require updating it is desirable to compile
2457 all of them first and to update the library at the end in a single operation.
2458 If one of the members does not compile and \fBdmake\fP stops, then
2459 the user may fix the error and make again. \fBdmake\fP will not remake any
2460 of the targets whose object files have already been generated as long as
2461 none of their prerequisite files have been modified as a result of the fix.
2463 When \fBdmake\fP constructs target (and prerequisite) pathnames they are
2464 normalized to the shortest (or most natural, see below for the cygwin case)
2465 representation. Substrings like './' or of the form 'baz/..' are removed
2466 and multiple slashes are collapsed to one unless they are at the beginning
2467 of the pathname. Leading slashes are normalized according to POSIX rules,
2468 i.e. more than two leading slashes are reduced to one slash and a
2469 leading '//' is kept as it might have a special meaning.
2470 For example "./foo", "bar/../foo" and foo are recognized as the same file.
2471 This may result in somewhat unexpected values of the macro expansion
2472 of runtime macros like \fB$@\fP, but is infact the corect result.
2474 \fBNOTE:\fP A cygwin \fBdmake\fP executable will accept DOS like pathnames
2475 with drive letters and cygwin POSIX pathnames and normalize them into its
2476 natural POSIX representation. This might result in even more surprising
2477 values of runtime macros.
2479 When defining .SOURCE and .SOURCE.x targets the construct
2484 \&.SOURCE : fred gery
2490 \&.SOURCE :\- fred gery
2493 \fBdmake\fP correctly handles the UNIX Make variable VPATH. By definition VPATH
2494 contains a list of ':' separated directories to search when looking for a
2495 target. \fBdmake\fP maps VPATH to the following special rule:
2498 \&.SOURCE :^ $(VPATH:s/:/ /)
2501 Which takes the value of VPATH and sets .SOURCE to the same set of directories
2502 as specified in VPATH.
2503 .SH "PERCENT(%) RULES AND MAKING INFERENCES"
2504 When \fBdmake\fP makes a target, the target's set of prerequisites (if any)
2505 must exist and the target must have a recipe which \fBdmake\fP
2507 If the makefile does not specify an explicit recipe for the target then
2509 uses special rules to try to infer a recipe which it can use
2510 to make the target. Previous versions of Make perform this task by using
2511 rules that are defined by targets of the form .<suffix>.<suffix> (this is still
2512 supported, see "AUGMAKE META RULES") or by using the \fBnot supported\fP by
2513 dmake .SUFFIXES list of suffixes (see "SPECIAL TARGETS" for more details
2514 about .SUFFIXES). The exact workings of this mechanism
2515 were sometimes difficult to understand and often limiting in their usefulness.
2516 Instead, \fBdmake\fP supports the concept of \fI%-meta\fP rules.
2517 The syntax and semantics of these rules differ from standard rule lines as
2522 \fI<%-targets>\fP [\fI<attributes>\fP] \fI<ruleop>\fP [\fI<%-prereqs>\fP] [;\fI<recipe>\fP]
2526 where \fI%-targets\fP are one or more targets containing exactly a single `%'
2529 is a list (possibly empty) of attributes,
2531 is the standard set of rule operators,
2533 \&, if present, is a list of prerequisites containing zero or more `%' signs,
2536 if present, is the first line of the recipe.
2538 If more than one %-target is present this line is equivalent to a repetition
2539 of the whole [<attributes>] <ruleop> [<%-prereqs>] [;<recipe>] sequence
2540 for each %-target, i.e. it is possible to specify the same rule for multiple
2541 %-targets. Because of this following only speaks about \fI<%-target>\fP as
2542 \fI%-targets\fP are divided into multiple definitions with a single %-target.
2544 \fBNOTE:\fP As multiple %-targets didn't work reliably with dmake versions prior
2545 to 4.5 unless the rule operator `|:' was used we currently issue a warning
2546 stating that it \fBnow\fP works.
2550 defines a pattern against which a target whose recipe is
2551 being inferred gets matched. The pattern match goes as follows: all chars are
2552 matched exactly from left to right up to but not including the % sign in the
2553 pattern, % then matches the longest string from the actual target name
2555 the suffix given after the % sign in the pattern.
2556 Consider the following examples:
2562 matches fred.c but not joe.c.Z
2564 matches dir/fred.c but not dd/fred.c
2566 matches fred/joe.c but not f/joe.c
2572 In each case the part of the target name that matched the % sign is retained
2573 and is substituted for any % signs in the prerequisite list of the %-meta rule
2574 when the rule is selected during inference and
2576 constructs the new dependency.
2579 that only the first, non-indirect, prerequisite of the list is used for the
2580 inference mechanism. If more than one non-indirect prerequisite is given
2581 a warning is issued and all but the first non-indirect prerequisites are
2582 ignored. See below for a description of indirect prerequisites.
2584 As an example the following %-meta rules describe the following:
2587 %.c : %.y ; recipe...
2590 describes how to make any file ending in .c if a corresponding file ending
2594 foo%.o : fee%.k ; recipe...
2597 is used to describe how to make fooxxxx.o from feexxxx.k.
2603 describes how to make a file whose suffix is .a without inferring any
2607 %.c : %.y 'yaccsrc/%.y' ; recipe...
2610 matches the corresponding .y file as prerequisite and additionally another .y
2611 file in the yaccsrc subdirectory as indirect prerequisite.
2612 Another interesting example is:
2618 which describes how to take any target and check it out of
2619 the RCS directory if the corresponding file exists in the RCS directory.
2620 The equivalent SCCS rule would be:
2627 The previous RCS example defines an infinite rule, because it says how to make
2631 also includes RCS/fred.c,v.
2632 To limit the size of the graph that results from such rules
2634 uses the macro variable PREP (stands for % repetition). By default the value
2635 of this variable is 0, which says that no repetitions of a %-rule are to be
2636 generated. If it is set to something greater than 0, then that many
2637 repetitions of any infinite %-rule are allowed. If in the above
2638 example PREP was set to 1, then \fBdmake\fP would generate the dependency
2642 % --> RCS/%,v --> RCS/RCS/%,v,v
2645 Where each link is assigned the same recipe as the first link.
2646 PREP should be used only in special cases, since it may result in
2647 a large increase in the number of possible prerequisites tested.
2649 further assumes that any target that has no suffix can be made from
2650 a prerequisite that has at least one suffix.
2653 supports dynamic prerequisite generation for prerequisites of %-meta rules.
2654 This is best illustrated by an example. The RCS rule shown above can infer
2655 how to check out a file from a corresponding RCS file only if the target
2656 is a simple file name with no directory information. That is, the above rule
2657 can infer how to find \fIRCS/fred.c,v\fP from the target \fIfred.c\fP,
2658 but cannot infer how to find \fIsrcdir/RCS/fred.c,v\fP from \fIsrcdir/fred.c\fP
2659 because the above rule will cause \fBdmake\fP to look for RCS/srcdir/fred.c,v;
2660 which does not exist (assume that srcdir has its own RCS directory as is the
2663 A more versatile formulation of the above RCS check out rule is the following:
2666 % : $$(@:d)RCS/$$(@:f),v : co $@
2669 This rule uses the dynamic macro $@ to specify the prerequisite to try to
2670 infer. During inference of this rule the macro $@ is set to the value of
2671 the target of the %-meta rule and the appropriate prerequisite is generated by
2672 extracting the directory portion of the target name (if any), appending the
2673 string \fIRCS/\fP to it, and appending the target file name with a trailing
2674 \fI,v\fP attached to the previous result.
2677 can also infer indirect prerequisites.
2678 An inferred target can have a list of prerequisites added that will not
2679 show up in the value of $< but will show up in the value of $? and $&.
2680 Indirect prerequisites are specified in an inference rule by quoting the
2681 prerequisite with single quotes. For example, if you had the explicit
2686 fred.o : fred.c ; rule to make fred.o
2691 then this can be inferred for fred.o from the following inference rule:
2694 %.o : %.c 'local.h' ; makes a .o from a .c
2697 You may infer indirect prerequisites that are a function of the value of '%'
2698 in the current rule. The meta-rule:
2701 %.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
2704 infers an indirect prerequisite found in the INC directory whose name is the
2705 same as the expansion of $(INC), and the prerequisite name depends on the
2706 base name of the current target.
2707 The set of indirect prerequisites is attached to the meta rule in which they
2708 are specified and are inferred only if the rule is used to infer a recipe
2709 for a target. They do not play an active role in driving the inference
2714 %.o :| %.c %.f 'local.h'; recipe
2721 %.o : %.c 'local.h' ; recipe
2722 %.o : %.f 'local.h' ; recipe
2727 If any of the attributes .EPILOG, .IGNORE, .LIBRARY, .NOSTATE, .PHONY, .PRECIOUS,
2728 \&.PROLOG, .SETDIR, .SILENT, .SWAP, .USESHELL and .WINPATH
2729 are given for a %-rule then when that rule is bound to a target
2730 as the result of an inference, the target's set of attributes is augmented by
2731 the attributes from the above set that are specified in the bound %-rule.
2732 Other attributes specified for %-meta rules are not inherited by the target.
2733 The .SETDIR attribute is treated in a special way.
2734 If the target already had a .SETDIR attribute set then
2736 changes to that directory prior to performing the inference.
2737 During inference any .SETDIR attributes for the inferred prerequisite
2739 The directories must exist for a %-meta rule to be selected as a possible
2740 inference path. If the directories do not exist no error message is issued,
2741 instead the corresponding path in the inference graph is rejected.
2744 bases all of its inferences on the inference graph constructed from the
2745 %-rules defined in the makefile.
2746 It knows exactly which targets can be made from which prerequisites by
2747 making queries on the inference graph.
2749 For a %-meta rule to be inferred as the
2750 rule whose recipe will be used to make a target, the target's name must match
2751 the %-target pattern, and any inferred %-prerequisite must already exist or
2752 have an explicit recipe so that the prerequisite can be made.
2753 Without \fItransitive closure\fP on the inference graph the above rule
2754 describes precisely when an inference match terminates the search.
2755 If transitive closure is enabled (the usual case), and a prerequisite does
2756 not exist or cannot be made, then
2758 invokes the inference algorithm recursively on the prerequisite to see if
2759 there is some way the prerequisite can be manufactured. For, if the
2760 prerequisite can be made then the current target can also be made using the
2761 current %-meta rule.
2762 This means that there is no longer a need to give a rule
2763 for making a .o from a .y if you have already given a rule for making a .o
2764 from a .c and a .c from a .y. In such cases
2766 can infer how to make the
2767 \&.o from the .y via the intermediary .c and will remove the .c when the .o is
2768 made. Transitive closure can be disabled by giving the \-T switch on the
2773 bases its transitive closure on the %-meta rule targets.
2774 When it performs transitive closure it infers how to make a target from a
2775 prerequisite by performing a pattern match as if the potential prerequisite
2781 %.o : %.c ; rule for making .o from .c
2782 %.c : %.y ; rule for making .c from .y
2783 % : RCS/%,v ; check out of RCS file
2787 will, by performing transitive closure, allow \fBdmake\fP to infer how to make
2788 a .o from a .y using a .c as an intermediate temporary file. Additionally
2789 it will be able to infer how to make a .y from an RCS file, as long as that
2790 RCS file is in the RCS directory and has a name which ends in .y,v.
2791 The transitivity computation is performed dynamically for each target that
2792 does not have a recipe. This has potential to be costly if the %-meta
2793 rules are not carefully specified. The .NOINFER attribute is used to mark
2794 a %-meta node as being a final target during inference. Any node with this
2795 attribute set will not be used for subsequent inferences. As an example
2796 the node RCS/%,v is marked as a final node since we know that if the RCS file
2797 does not exist there likely is no other way to make it. Thus the standard
2798 startup makefile contains an entry similar to:
2801 \&.NOINFER : RCS/%,v
2804 Thereby indicating that the RCS file is the end of the inference chain.
2805 Whenever the inference algorithm determines that a target can be made from
2806 more than one prerequisite and the inference chains for the two methods
2807 are the same length the algorithm reports an ambiguity and prints the
2808 ambiguous inference chains.
2812 remove intermediate files resulting from transitive closure if the file
2813 is not marked as being PRECIOUS, or the \fB\-u\fP flag was not given on the
2814 command line, and if the inferred intermediate did not previously exist.
2815 Intermediate targets that existed prior to being made are never removed.
2816 This is in keeping with the philosophy that
2818 should never remove things from the file system that it did not add.
2819 If the special target .REMOVE is defined and has a recipe then
2821 constructs a list of the intermediate files to be removed and makes them
2822 prerequisites of .REMOVE. It then makes .REMOVE thereby removing the
2823 prerequisites if the recipe of .REMOVE says to. Typically .REMOVE is defined
2824 in the startup file as:
2827 \&.REMOVE :; $(RM) $<
2829 .SH "AUGMAKE META RULES"
2830 As a subclass of the meta targets that is actually mapped to %-meta rules
2832 understands several SYSV AUGMAKE targets transformations. This .<suffix>
2833 special target construct transforms into the following %-meta rules:
2847 also supports the old format special target .<suffix>.<suffix>
2848 by identifying any rules
2849 of this form and mapping them to the appropriate %-rule. So for example if
2850 an old makefile contains the construct:
2853 \&.c.o :; cc \-c $< \-o $@
2857 maps this into the following %-rule:
2860 %.o : %.c; cc \-c $< \-o $@
2863 The following SYSV AUGMAKE special targets transformation must be
2864 enabled by providing the \-A flag
2865 on the command line or by setting the value of AUGMAKE to non\-NULL.
2875 %.o : s.%.c ; recipe
2878 In general, a special target of the form .<str>~ is replaced by the %-rule
2879 construct s.%.<str>, thereby providing support for the syntax used by SYSV
2880 AUGMAKE for providing SCCS support.
2881 When enabled, these mappings allow processing of existing SYSV
2882 makefiles without modifications.
2884 .SH "MAKING TARGETS"
2885 In order to update a target \fBdmake\fP must execute a recipe.
2886 When a recipe needs to be executed it is first expanded so that any macros
2887 in the recipe text are expanded, and it is then either executed directly or
2890 supports two types of recipes. The regular recipes and group recipes.
2892 When a regular recipe is invoked \fBdmake\fP executes each line of the recipe
2893 separately using a new copy of a shell if a shell is required.
2894 Thus effects of commands do not generally persist across recipe lines
2895 (e.g. cd requests in a recipe line do not carry over to the next recipe line).
2896 This is true even in environments such as \fBMSDOS\fP, where dmake internally
2897 sets the current working director to match the directory it was in before
2898 the command was executed.
2900 The decision on whether a shell is required to execute a command is based on
2901 the value of the macro SHELLMETAS or on the specification of '+' or .USESHELL
2902 for the current recipe or target respectively.
2903 If any character in the value of
2904 SHELLMETAS is found in the expanded recipe text-line or the use of a shell
2905 is requested explicitly via '+' or .USESHELL then the command is
2906 executed using a shell, otherwise the command is executed directly.
2907 The shell that is used for execution is given by the value of the macro SHELL.
2908 The flags that are passed to the shell are given by the value of SHELLFLAGS.
2909 Thus \fBdmake\fP constructs the command line:
2911 \t$(SHELL) $(SHELLFLAGS) $(expanded_recipe_command)
2913 If the $(SHELLCMDQUOTE) macro is set its value is inserted before and after
2914 the $(expanded_recipe_command) string.
2918 writes the command line that it is about to invoke to standard output.
2919 If the .SILENT attribute is set for the target or for
2920 the recipe line (via @), then the recipe line is not echoed.
2922 Group recipe processing is similar to that of regular recipes, except that
2923 a shell is always invoked. The shell that is invoked is given by the value of
2924 the macro GROUPSHELL, and its flags are taken from the value of the macro
2925 GROUPFLAGS. If a target has the .PROLOG attribute set then
2927 prepends to the shell script the recipe associated with the special target
2928 \&.GROUPPROLOG, and if the attribute .EPILOG is set as well, then the recipe
2929 associated with the special target .GROUPEPILOG is appended to the script
2931 This facility can be used to always prepend a common header and common trailer
2933 Group recipes are echoed to standard output just like standard recipes, but
2934 are enclosed by lines beginning with [ and ].
2936 The recipe flags [+,\-,%,@] are recognized at the start of a recipe line
2937 even if they appear in a macro. For example:
2947 is completely equivalent to writing
2958 The last step performed by
2960 prior to running a recipe is to set the macro CMNDNAME to the name of the
2961 command to execute (determined by finding the first white\-space ending token
2962 in the command line). It then sets the macro CMNDARGS to be the remainder
2965 then expands the macro COMMAND which by default is set to
2968 COMMAND = $(CMNDNAME) $(CMNDARGS)
2971 The result of this final expansion is the command that will be executed.
2972 The reason for this expansion is to allow for a different interface to
2973 the argument passing facilities (esp. under DOS) than that provided by
2975 You can for example define COMMAND to be
2978 COMMAND = $(CMNDNAME) @$(mktmp $(CMNDARGS))
2981 which dumps the arguments into a temporary file and runs the command
2984 $(CMNDNAME) @/tmp/ASAD23043
2987 which has a much shorter argument list. It is now up to the command to
2988 use the supplied argument as the source for all other arguments.
2989 As an optimization, if COMMAND is not defined
2991 does not perform the above expansion. On systems, such as UNIX, that
2992 handle long command lines this provides a slight saving in processing the
2994 .SH "MAKING LIBRARIES"
2995 Libraries are easy to maintain using \fBdmake\fP. A library is a file
2996 containing a collection of object files.
2997 Thus to make a library you simply specify it as a target with the .LIBRARY
2998 attribute set and specify its list of prerequisites. The prerequisites should
2999 be the object members that are to go into the library. When
3001 makes the library target it uses the .LIBRARY attribute to pass to the
3002 prerequisites the .LIBMEMBER attribute and the name of the library. This
3003 enables the file binding mechanism to look for the member in the library if an
3004 appropriate object file cannot be found.
3006 now supports \fBElf\fP libraries on systems that support \fBElf\fP and
3007 hence supports, on those systems, long member file names.
3008 A small example best illustrates this.
3012 mylib.a .LIBRARY : mem1.o mem2.o mem3.o
3013 \trules for making library...
3014 \t# remember to remove .o's when lib is made
3016 # equivalent to: '%.o : %.c ; ...'
3017 \&.c.o :; rules for making .o from .c say
3022 will use the .c.o rule for making the library members if appropriate .c files
3023 can be found using the search rules. NOTE: this is not specific in any way
3024 to C programs, they are simply used as an example.
3027 tries to handle the old library construct format in a sensible way.
3030 is separated and the \fIlib\fP portion is declared
3031 as a library target.
3032 The new target is defined
3033 with the .LIBRARY attribute set and the \fImember.o\fP portion of the
3035 declared as a prerequisite of the lib target.
3036 If the construct \fIlib(member.o)\fP
3037 appears as a prerequisite of a target in the
3038 makefile, that target has the new name of the lib assigned as its
3039 prerequisite. Thus the following example:
3043 a.out : ml.a(a.o) ml.a(b.o); $(CC) \-o $@ $<
3045 \&.c.o :; $(CC) \-c $(CFLAGS) \-o $@ $<
3055 constructs the following dependency
3060 a.out : ml.a; $(CC) \-o $@ $<
3061 ml.a .LIBRARY : a.o b.o
3063 %.o : %.c ; $(CC) -c $(CFLAGS) \-o $@ $<
3073 and making a.out then works as expected.
3075 The same thing happens for any target of the form \fIlib((entry))\fP.
3076 These targets have an
3077 additional feature in that the \fIentry\fP target has the .SYMBOL attribute
3080 NOTE: If the notion of entry points is supported by the archive and by
3081 \fBdmake\fP (currently not the case) then
3083 will search the archive for the entry point and return not only the
3084 modification time of the member which defines the entry but also the name of
3085 the member file. This name will then replace \fIentry\fP and will be used for
3086 making the member file. Once bound to an archive member the .SYMBOL
3087 attribute is removed from the target.
3088 This feature is presently disabled as there is little standardization
3089 among archive formats, and we have yet to find a makefile utilizing this
3090 feature (possibly due to the fact that it is unimplemented in most versions
3095 looks for a library member it must first locate the library file.
3096 It does so by first looking for the library relative to the current directory
3097 and if it is not found it then looks relative to the current value of
3098 $(TMD). This allows commonly used libraries to be kept near the root of
3099 a source tree and to be easily found by
3103 supports the keeping of state information for targets that it makes whenever
3104 the macro .KEEP_STATE is assigned a value. The value of the macro should be
3105 the name of a state file that will contain the state information. If state
3106 keeping is enabled then each target that does not poses the .NOSTATE
3107 attribute will have a record written into the state file indicating the
3108 target's name, the current directory, the command used to update the target,
3109 and which, if any, :: rule is being used. When you make this target again
3110 if any of this information does not match the previous settings and the
3111 target is not out dated it will still be re\-made. The assumption is that one
3112 of the conditions above has changed and that we wish to remake the target.
3114 state keeping is used in the maintenance of
3116 to test compile different versions of the source using different compilers.
3117 Changing the compiler causes the compilation flags to be modified and hence
3118 all sources to be recompiled.
3120 The state file is an ascii file and is portable, however it is
3121 not in human readable form as the entries represent hash keys of the above
3124 The Sun Microsystem's Make construct
3130 is recognized and is mapped to \fB.KEEP_STATE:=_state.mk\fP.
3133 version of state keeping does not include scanning C source files for
3134 dependencies like Sun Make. This is specific to C programs and it was
3135 felt that it does not belong in make.
3137 instead provides the tool, \fBcdepend\fP, to scan C source files and to produce
3138 depedency information. Users are free to modify cdepend to produce other
3139 dependency files. (NOTE:
3141 does not come with the distribution at this time, but will be available in
3142 a patch in the near future)
3143 .SH "MULTI PROCESSING"
3144 If the architecture supports it then \fBdmake\fP is capable of making a target's
3145 prerequisites in parallel. \fBdmake\fP will make as much in parallel as it
3146 can and use a number of child processes up to the maximum specified by
3147 MAXPROCESS or by the value supplied to the \-P command line flag.
3148 A parallel make is enabled by setting the value of MAXPROCESS (either directly
3149 or via \-P option) to a value which is > 1.
3150 \fBdmake\fP guarantees that all dependencies as specified in the makefile are
3151 honored. A target will not be made until all of its prerequisites have been
3152 made. Note that when you specify \fB-P 4\fP then four child processes are
3153 run concurrently but \fBdmake\fP actually displays the fifth command it will
3154 run immediately upon a child process becomming free. This is an artifact of
3155 the method used to traverse the dependency graph and cannot be removed.
3156 If a parallel make is being performed then the following restrictions on
3157 parallelism are enforced.
3160 Individual recipe lines in a non-group recipe are performed sequentially in
3161 the order in which they are specified within the makefile and in parallel with
3162 the recipes of other targets.
3164 If a target contains multiple recipe definitions (cf. :: rules) then these are
3165 performed sequentially in the order in which the :: rules are specified within
3166 the makefile and in parallel with the recipes of other targets.
3168 If a target rule contains the `!' modifier, then the recipe is performed
3169 sequentially for the list of outdated prerequisites and in parallel with the recipes of other targets.
3171 If a target has the .SEQUENTIAL attribute set then all of its prerequisites
3172 are made sequentially relative to one another (as if MAXPROCESS=1), but in
3173 parallel with other targets in the makefile.
3176 Note: If you specify a parallel make then
3177 the order of target update and the order in which the associated recipes are
3178 invoked will not correspond to that displayed by the \-n flag.
3181 supports a makefile construct called a \fIconditional\fR. It allows
3183 to conditionally select portions of makefile text for input processing
3184 and to discard other portions. This becomes useful for
3185 writing makefiles that are intended to function for more than one target
3186 host and environment. The conditional expression is specified as follows:
3190 \&.IF \fIexpression\fR
3192 \&.ELIF \fIexpression\fR
3200 The .ELSE and .ELIF portions are optional, and the conditionals may be
3201 nested (ie. the text may contain another conditional).
3202 \&.IF, .ELSE, and .END
3203 may appear anywhere in the makefile, but a single conditional expression
3204 may not span multiple makefiles.
3206 \fIexpression\fR can be one of the following forms:
3210 \t<text> | <text> == <text> | <text> != <text>
3214 \t<text> <= <text> | <text> >= <text>
3218 \t( <text> ) | <text> || <text> | <text> && <text>
3220 where \fItext\fR is either text or a macro expression. In any case,
3221 before the comparison is made, the expression is expanded. The text
3222 portions are then selected and compared. In the case of the numeric
3223 comparisons enclosing quotes are removed after expanding the expressions
3224 and the leading numerical parts are converted to an integer number. If no
3225 numerical part is found this results to 0 (zero). The
3226 string "12ab" for example evaluates to the number 12.
3227 Expressions can be nested with () and the use of || or &&.
3228 White space at the start and
3229 end of the text portion is discarded before the comparison. This means
3230 that a macro that evaluates to nothing but white space is considered a
3231 NULL value for the purpose of the comparison.
3232 In the first case the expression evaluates TRUE if the text is not NULL
3233 otherwise it evaluates FALSE. The remaining two cases both evaluate the
3234 expression on the basis of a string comparison.
3235 If a macro expression needs to be equated to a NULL string then compare it to
3236 the value of the macro $(NULL).
3237 You can use the $(shell ...) macro to construct more complex test expressions.
3242 # A simple example showing how to use make
3254 example prgm is remade only if a.o and/or b.o is out of date with
3256 These dependencies can be stated more concisely
3257 by using the inference rules defined in the standard startup file.
3258 The default rule for making .o's from .c's looks something like this:
3260 \&\t%.o : %.c; cc \-c $(CFLAGS) \-o $@ $<
3262 Since there exists a rule (defined in the startup file)
3263 for making .o's from .c's
3264 \fBdmake\fR will use that rule
3265 for manufacturing a .o from a .c and we can specify our dependencies
3276 A more general way to say the above using the new macro expansions
3291 If we want to keep the objects in a separate directory, called
3292 objdir, then we would write
3293 something like this.
3305 $(CC) \-c $(CFLAGS) \-o $(@:f) $<
3308 \&.SOURCE.o : objdir # tell dmake to look here for .o's
3312 An example of building library members would go something like this:
3313 (NOTE: The same rules as above will be used to produce .o's from .c's)
3319 LIBm\t= { $(SRC) }.o
3324 $(LIB) .LIBRARY : $(LIBm)
3330 Finally, suppose that each of the source files in the previous example had
3331 the `:' character in their target name. Then we would write the above example
3338 LIBm\t= "{ $(SRC) }.o" # put quotes around each token
3343 $(LIB) .LIBRARY : $(LIBm)
3349 There are two notable differences between
3351 and the standard version of BSD UNIX 4.2/4.3 Make.
3354 BSD UNIX 4.2/4.3 Make supports wild card filename expansion for
3355 prerequisite names. Thus if a directory contains a.h, b.h and c.h, then a
3360 will cause UNIX make to expand the *.h into "a.h b.h c.h". \fBdmake\fR
3361 does not support this type of filename expansion.
3363 Unlike UNIX make, touching a library member causes \fBdmake\fR
3364 to search the library for the member name and to update the library time stamp.
3365 This is only implemented in the UNIX version.
3366 MSDOS and other versions may not have librarians that keep file time stamps,
3367 as a result \fBdmake\fR touches the library file itself, and prints a warning.
3370 \fBdmake\fP is not compatible with GNU Make. In particular it does not
3371 understand GNU Make's macro expansions that query the file system.
3374 is fully compatible with SYSV AUGMAKE, and supports the following AUGMAKE
3378 GNU Make style \fBinclude\fP, and \fBif/else/endif\fP directives are allowed
3379 in non-group recipes.
3380 Thus, the word \fBinclude\fP appearing at
3381 the start of a line that is not part of a gruop recipe will be mapped
3382 to the ".INCLUDE" directive that \fBdamke\fP uses.
3383 Similarly, the words \fBifeq\fP,\fBifneq\fP,\fBelif\fP,\fBelse\fP,
3384 and \fBendif\fP are mapped to their corresponding \fBdmake\fP equivalents.
3386 The macro modifier expression $(macro:str=sub) is understood and is equivalent
3387 to the expression $(macro:s/str/sub), with the restriction that str must match
3388 the following regular expression:
3390 \tstr[ |\et][ |\et]*
3392 (ie. str only matches at the end of a token where str is a suffix and is
3393 terminated by a space, a tab, or end of line)
3394 Normally \fIsub\fP is expanded before the substitution is made, if you specify
3395 \-A on the command line then sub is not expanded.
3397 The macro % is defined to be $@ (ie. $% expands to the same value as $@).
3399 The AUGMAKE notion of libraries is handled correctly.
3401 Directories are always made if you specify \fB\-A\fP. This is consistent
3402 with other UNIX versions of Make.
3404 Makefiles that utilize virtual targets to force making of other targets work
3405 as expected if AUGMAKE special target handling is enabled. For example:
3409 \tmyprog.o : myprog.c $(FRC) ; ...
3412 Works as expected if you issue the command
3414 \t'\fBdmake\fP \-A FRC=FRC'
3416 but fails with a 'don't know how to make FRC'
3417 error message if you do not specify AUGMAKE special target handling via
3418 the \-A flag (or by setting AUGMAKE:=yes internally).
3421 In some environments the length of an argument string is restricted.
3422 (e.g. MSDOS command line arguments cannot be longer than 128 bytes if you are
3423 using the standard command.com command interpreter as your shell,
3425 text diversions may help in these situations.)
3427 To write makefiles that can be moved from one environment to another requires
3428 some forethought. In particular you must define as macros all those things
3429 that may be different in the new environment.
3431 has two facilities that help to support writing portable makefiles, recursive
3432 macros and conditional expressions. The recursive macros, allow one to define
3433 environment configurations that allow different environments for similar types
3434 of operating systems. For example the same make script can be used for SYSV and
3435 BSD but with different macro definitions.
3437 To write a makefile that is portable between UNIX and MSDOS requires both
3438 features since in almost all cases you will need to define new recipes for
3439 making targets. The recipes will probably be quite different since the
3440 capabilities of the tools on each machine are different. Different
3441 macros will be needed to help handle the smaller differences in the two
3444 Makefile, makefile, startup.mk (use dmake \-V to tell you where the startup
3447 sh(1), csh(1), touch(1), f77(1), pc(1), cc(1)
3449 S.I. Feldman \fIMake - A Program for Maintaining Computer Programs\fP
3451 Dennis Vadura, dvadura@wticorp.com
3453 Many thanks to Carl Seger for his helpful suggestions,
3454 and to Trevor John Thompson for his many excellent ideas and
3455 informative bug reports. Many thanks also go to those on the
3456 NET that have helped in making \fBdmake\fP one of the best Make tools
3459 Some system commands return non-zero status inappropriately.
3462 (`\-' within the makefile) to overcome the difficulty.
3464 Some systems do not have easily accessible
3465 time stamps for library members (MSDOS, AMIGA, etc)
3466 for these \fBdmake\fR uses the time stamp of the library instead and prints
3467 a warning the first time it does so. This is almost always ok, except when
3468 multiple makefiles update a single library file. In these instances it is
3469 possible to miss an update if one is not careful.
3471 This man page is way too long.
3473 Rules supported by make(1) may not work if transitive closure is turned off
3476 PWD from csh/ksh will cause problems if a cd operation is performed and
3477 -e or -E option is used.
3479 Using internal macros such as COMMAND, may wreak havoc if you don't understand
3480 their functionality.