table of contents
- NAME
 - SYNOPSIS
 - DESCRIPTION
 - OPTIONS
 - INDEX
 - STARTUP
 - SYNTAX
 - ATTRIBUTES
 - MACROS
 - RULES AND TARGETS
 - RECIPES
 - BUILTIN COMMANDS
 - TEXT DIVERSIONS
 - VIRTUAL TARGETS
 - SPECIAL TARGETS
 - SPECIAL MACROS
 - CONTROL MACROS
 - RUNTIME MACROS
 - FUNCTION MACROS
 - CONDITIONAL MACROS
 - DYNAMIC PREREQUISITES
 - BINDING TARGETS
 - PERCENT(%) RULES AND MAKING INFERENCES
 - AUGMAKE META RULES
 - MAKING TARGETS
 - MAKING LIBRARIES
 - KEEP STATE
 - MULTI PROCESSING
 - CONDITIONALS
 - EXAMPLES
 - COMPATIBILITY
 - LIMITS
 - PORTABILITY
 - FILES
 - SEE ALSO
 - AUTHOR
 - BUGS
 - WARNINGS
 
other versions
- wheezy 1:4.12-2
 
| DMAKE(1) | General Commands Manual | DMAKE(1) | 
NAME¶
dmake - maintain program groups, or interdependent filesSYNOPSIS¶
dmake [-P#] [-{f|C|K} file] [-{w|W} target ...] [macro[[!][*][+][:]]= value ...] [-ABcdeEghiknpqrsStTuVxX] [-v[cdfimrtw]] [-m[trae]] [target ...]DESCRIPTION¶
dmake is a re-implementation of the UNIX Make utility with significant enhancements. dmake executes commands found in an external file called a makefile to update one or more target names. Each target may depend on zero or more prerequisite targets. If any of the target's prerequisites is newer than the target or if the target itself does not exist, then dmake will attempt to make the target. If no -f command line option is present then dmake searches for an existing makefile from the list of prerequisites specified for the special target .MAKEFILES (see the STARTUP section for more details). If "-" is the name of the file specified to the -f flag then dmake uses standard input as the source of the makefile text. Any macro definitions (arguments with embedded "=" signs) that appear on the command line are processed first and supercede definitions for macros of the same name found within the makefile. In general it is impossible for definitions found inside the makefile to redefine a macro defined on the command line, see the MACROS section for exceptions. If no target names are specified on the command line, then dmake uses the first non-special target found in the makefile as the default target. See the SPECIAL TARGETS section for the list of special targets and their function. Makefiles written for most previous versions of Make will be handled correctly by dmake. Known differences between dmake and other versions of make are discussed in the COMPATIBILITY section found at the end of this document. dmake returns 0 if no errors were detected and a non-zero result if an error occurred.OPTIONS¶
- -A
 - Enable AUGMAKE special inference rule transformations (see the "PERCENT(%) RULES" and "AUGMAKE META RULES" sections), these are set to off by default.
 
- -B
 - Enable the use of spaces instead of <tabs> to begin recipe lines. This flag equivalent to the .NOTABS special macro and is further described below.
 
- -c
 - Use non-standard comment stripping. If you specify -c then dmake will treat any # character as a start of comment character wherever it may appear unless it is escaped by a \.
 
- -C [+]file
 - This option writes to file a copy of standard output and standard error from any child processes and from the dmake process itself. If you specify a + prior to the file name then the text is appended to the previous contents of file. This option is active in the MSDOS implementation only and is ignored by non-MSDOS versions of dmake.
 
- -d
 - Disable the use of the directory cache. Normally dmake caches directories as it checks file timestamps. Giving this flag is equivalent to the .DIRCACHE attribute or macro being set to no.
 
- -E
 - Read the environment and define all strings of the form ' ENV-VAR=evalue' defined within as macros whose name is ENV-VAR, and whose value is ' evalue'. The environment is processed prior to processing the user specified makefile thereby allowing definitions in the makefile to override definitions in the environment.
 
- -e
 - Same as -E, except that the environment is processed after the user specified makefile has been processed (thus definitions in the environment override definitions in the makefile). The -e and -E options are mutually exclusive. If both are given the latter takes effect.
 
- -f file
 - Use file as the source for the makefile text. Only one -f option is allowed.
 
- -g
 - Globally disable group recipe parsing, equivalent to the .IGNOREGROUP attribute or macro being set to yes at the start of the makefile.
 
- -h
 - Print the command summary for dmake.
 
- -i
 - Tells dmake to ignore errors, and continue making other targets. This is equivalent to the .IGNORE attribute or macro.
 
- -K file
 - Turns on .KEEP_STATE state tracking and tells dmake to use file as the state file.
 
- -k
 - Causes dmake to ignore errors caused by command execution and to make all targets not depending on targets that could not be made. Ordinarily dmake stops after a command returns a non-zero status, specifying -k causes dmake to ignore the error and continue to make as much as possible.
 
- -m[trae]
 - Measure timing information. Print the time when targets and/or recipes are started and finished to stdout. The following format is used:
 
- {s|e} {target|recipe} time maketarget
 
- s or e stands for started or ended, target or recipe denotes if this line refers to the whole target or a recipe. time is displayed in Unix time format, i.e. the number of seconds since an epoch. (Since 1970-01-01T00:00:00Z). maketarget obviously represents the target the timing information is given for. The optional flags [trae] can be used to change the information that is displayed. If no optional flags are given only the t flag is assumed to be selected, ie. -mt. The optional flags stand for:
 
- t
 - Display the start and end time of each target.
 
- r
 - Display the start and end time of each recipe.
 
- a
 - Display the target as an absolute path, i.e. prepend the current working directory.
 
- e
 - Also display the start and end time of the $(shell command) function (aka. shell escape) macros.
 
- -n
 - Causes dmake to print out what it would have executed, but does not actually execute the commands. A special check is made for the string "$(MAKE)" inside a recipe line, if it is found, the line is expanded and invoked, thereby enabling recursive makes to give a full description of all that they will do. This check is disabled inside group recipes.
 
- -p
 - Print out a version of the digested makefile in human readable form. (useful for debugging, but cannot be re-read by dmake)
 
- -P#
 - On systems that support multi-processing cause dmake to use # concurrent child processes to make targets. See the "MULTI PROCESSING" section for more information.
 
- -q
 - Check and see if the target is up to date. Exits with code 0 if up to date, 1 otherwise.
 
- -r
 - Tells dmake not to read the initial startup makefile, see STARTUP section for more details.
 
- -s
 - Tells dmake to do all its work silently and not echo the commands it is executing to stdout (also suppresses warnings). This is equivalent to the .SILENT attribute or macro.
 
- -S
 - Force sequential execution of recipes on architectures which support concurrent makes. For backward compatibility with old makefiles that have nasty side-effect prerequisite dependencies. (Implies -P1)
 
- -t
 - Causes dmake to touch the targets and bring them up to date without executing any commands. Note that targets will not be created if they do not already exist.
 
- -T
 - Tells dmake to not perform transitive closure on the inference graph.
 
- -u
 - Force an unconditional update. (ie. do everything that would be done if everything that a target depended on was out of date)
 
- -v[cdfimrtw]
 - Verbose flag, when making targets print to stdout what we are going to make and what we think its time stamp is. The optional flags [cdfimrtw] can be used to restrict the information that is displayed. In the absence of any optional flags all are assumed to be given (ie. -v is equivalent to -vcdfimrtw). The meanings of the optional flags are:
 
- c
 - Notify of directory cache operations only.
 
- d
 - Notify of change directory operations only.
 
- f
 - Notify of file I/O operations only.
 
- i
 - Notify of inference algorithm operation only.
 
- m
 - Notify of target update operations only.
 
- r
 - Force output of recipe lines, warnings and executed commands. This switch is usefull when debugging makefiles that disable the output using the @ or @@ property for recipe lines or the .SILENT target/attribute. It also overrides the -s flag.
 
- t
 - Keep any temporary files created; normally they are automatically deleted.
 
- w
 - Notify of non-essential warnings (these are historical).
 
- -V
 - Print the version of dmake, and values of builtin macros.
 
- -W target
 - Run dmake pretending that target is out of date.
 
- -w target
 - What if? Show what would be made if target were out of date.
 
- -x
 - Upon processing the user makefile export all non-internally defined macros to the user's environment. This option together with the -e option allows SYSV AUGMAKE recursive makes to function as expected.
 
- -X
 - Inhibit the execution of #! lines found at the beginning of a makefile. The use of this flag prevents non-termination of recursive make invocations.
 
INDEX¶
Here is a list of the sections that follow and a short description of each. Perhaps you won't have to read the entire man page to find what you need.- STARTUP
 - Describes dmake initialization.
 
- SYNTAX
 - Describes the syntax of makefile expressions.
 
- ATTRIBUTES
 - Describes the notion of attributes and how they are used when making targets.
 
- MACROS
 - Defining and expanding macros.
 
- RULES AND TARGETS
 - How to define targets and their prerequisites.
 
- RECIPES
 - How to tell dmake how to make a target.
 
- BUILTIN COMMANDS
 - Internal dmake commands.
 
- TEXT DIVERSIONS
 - How to use text diversions in recipes and macro expansions.
 
- VIRTUAL TARGETS
 - Targets that only enforce dependencies, but which can not create a target file.
 
- SPECIAL TARGETS
 - Some targets are special.
 
- SPECIAL MACROS
 - Macros used by dmake to alter the processing of the makefile, and those defined by dmake for the user.
 
- CONTROL MACROS
 - Itemized list of special control macros.
 
- RUNTIME MACROS
 - Discussion of special run-time macros such as $@ and $<.
 
- FUNCTION MACROS
 - Description of functional macros.
 
- CONDITIONAL MACROS
 - Target specific conditional macros.
 
- DYNAMIC PREREQUISITES
 - Processing of prerequisites which contain macro expansions in their name.
 
- BINDING TARGETS
 - The rules that dmake uses to bind a target to an existing file in the file system.
 
- PERCENT(%) RULES
 - Specification of recipes to be used by the inference algorithm.
 
- MAKING INFERENCES
 - The rules that dmake uses when inferring how to make a target which has no explicit recipe. This and the previous section are really a single section in the text.
 
- AUGMAKE META RULES
 - A subclass of the PERCENT(%) RULES.
 
- MAKING TARGETS
 - How dmake makes targets other than libraries.
 
- MAKING LIBRARIES
 - How dmake makes libraries.
 
- KEEP STATE
 - A discussion of how .KEEP_STATE works.
 
- MULTI PROCESSING
 - Discussion of dmake's parallel make facilities for architectures that support them.
 
- CONDITIONALS
 - Conditional expressions which control the processing of the makefile.
 
- EXAMPLES
 - Some hopefully useful examples.
 
- COMPATIBILITY
 - How dmake compares with previous versions of make.
 
- LIMITS
 - Limitations of dmake.
 
- PORTABILITY
 - Comments on writing portable makefiles.
 
- FILES
 - Files used by dmake.
 
- SEE ALSO
 - Other related programs, and man pages.
 
- AUTHOR
 - The guy responsible for this thing.
 
- BUGS
 - Hope not.
 
STARTUP¶
When dmake begins execution it first processes the command line and then processes an initial startup-makefile. This is followed by an attempt to locate and process a user supplied makefile. The startup file defines the default values of all required control macros and the set of default rules for making targets and inferences. When searching for the startup makefile, dmake searches the following locations, in the order specified, until a startup file is located:- 1.
 - The location given as the value of the macro MAKESTARTUP defined on the command line.
 
- 2.
 - The location given as the value of the environment variable MAKESTARTUP defined in the current environment.
 
- 3.
 - The location given as the value of the macro MAKESTARTUP
      defined internally within dmake. In this version, the internal
      definition of MAKESTARTUP is "$(DMAKEROOT)/startup.mk", so you
      can set the environment variable DMAKEROOT to the location of your startup
      directory.
    If DMAKEROOT is not changed, for native Windows dmake versions its value defaults to "$(ABSMAKECMD:d)startup" (see definition of ABSMAKECMD for details). For unix like versions build with the autotools build system it defaults to the value of "${prefix}/share/startup" at build time. The actual value, usually something like /usr/local/share/startup can be checked with the -V command line switch.
 
.ROOT .PHONY .NOSTATE .SEQUENTIAL : .INIT
  .TARGETS .DONE
.INIT .DONE .PHONY:;
.ROOT : .TARGETS
SYNTAX¶
This section is a summary of the syntax of makefile statements. The description is given in a style similar to BNF, where { } enclose items that may appear zero or more times, and [ ] enclose items that are optional. Alternative productions for a left hand side are indicated by '→', and newlines are significant. All symbols in bold type are text or names representing text supplied by the user.- Makefile
 - 
    
→ { Statement } 
- Statement
 - 
    
→ Macro-Definition → Conditional-Macro-Definition → Conditional → Rule-Definition → Attribute-Definition
 
- Macro-Definition
 - 
    
→ MACRO = LINE → MACRO [!]*= LINE → MACRO [!]:= LINE → MACRO [!]*:= LINE → MACRO [!]+= LINE → MACRO [!]+:= LINE
 
- Conditional-Macro-Definition →
 - 
    
TARGET ?= Macro-Definition
 
- Conditional →
 - 
    
.IF expression Makefile [ .ELIF expression Makefile ] [ .ELSE Makefile ] .END
 
- expression
 - 
    
→ LINE → STRING → expression == expression → expression != expression → expression <= expression → expression >= expression → ( expression ) → expression || expression → expression && expression
 
- Rule-Definition →
 - 
    
target-definition [ recipe ] 
target-definition → targets [attrs] op {  PREREQUISITE } [; rcp-line]
 
- targets
 - 
    
→ target { targets } → "target" { targets } 
- target
 - 
    
→ special-target → TARGET
 
- attrs
 - 
    
→ attribute { attrs } → "attribute" { attrs } 
- op
 - 
    
→ : { modifier } 
- modifier
 - 
    
→ : → ^ → ! → - → |
 
- recipe
 - 
    
→ { TAB rcp-line } → [ @[@]][%][-] [ 
- 
    
{ LINE } 
- 
    
]
 
- rcp-line
 - 
    
→ [ @[@]][%][-][+] LINE
 
- Attribute-Definition
 - 
    
→ attrs : targets
 
- attribute
 - 
    
→ .EPILOG → .ERRREMOVE → .EXECUTE → .GROUP → .IGNORE → .IGNOREGROUP → .LIBRARY → .MKSARGS → .NOINFER → .NOSTATE → .PHONY → .PRECIOUS → .PROLOG → .SETDIR=path → .SILENT → .SEQUENTIAL → .SWAP → .USESHELL → .SYMBOL → .UPDATEALL → .WINPATH
 
- special-target
 - 
    
→ .ERROR → .EXIT → .EXPORT → .GROUPEPILOG → .GROUPPROLOG → .IMPORT → .INCLUDE → .INCLUDEDIRS → .MAKEFILES → .REMOVE → .ROOT → .SOURCE → .SOURCE.suffix → .SUFFIXES (deprecated) → .TARGETS → .INIT → .DONE → . suffix → . suffix1.suffix2 
ATTRIBUTES¶
dmake defines several target attributes. Attributes may be assigned to a single target, a group of targets, or to all targets in the makefile. Attributes are used to modify dmake actions during target update. The recognized attributes are:- .EPILOG
 - Insert shell epilog code when executing a group recipe associated with any target having this attribute set.
 
- .ERRREMOVE
 - Always remove any target having this attribute if an error is encountered while making them. Setting this attribute overrides the .PRECIOUS attribute.
 
- .EXECUTE
 - If the -n flag was given then execute the recipe associated with any target having this attribute set.
 
- .FIRST
 - Used in conjunction with .INCLUDE. Terminates the inclusion with the first successfully included prerequisite.
 
- .GROUP
 - Force execution of a target's recipe as a group recipe.
 
- .IGNORE
 - Ignore an error when trying to make any target with this attribute set.
 
- .IGNOREGROUP
 - Disable the special meaning of '[' to initiate a group recipe.
 
- .LIBRARY
 - Target is a library.
 
- .MKSARGS
 - If running in an MSDOS environment then use MKS extended argument passing conventions to pass arguments to commands. Non-MSDOS environments ignore this attribute.
 
- .NOINFER
 - Any target with this attribute set will not be subjected to transitive closure if it is inferred as a prerequisite of a target whose recipe and prerequisites are being inferred. (i.e. the inference algorithm will not use any prerequisite with this attribute set, as a target) If specified as '.NOINFER:' (ie. with no prerequisites or targets) then the effect is equivalent to specifying -T on the command line.
 
- .NOSTATE
 - Any target with this attribute set will not have command line flag information stored in the state file if .KEEP_STATE has been enabled.
 
- .PHONY
 - Any target with this attribute set will have its recipe executed each time the target is made even if a file matching the target name can be located. Any targets that have a .PHONY attributed target as a prerequisite will be made each time the .PHONY attributed prerequisite is made.
 
- .PRECIOUS
 - Do not remove associated target under any circumstances. Set by default for any targets whose corresponding files exist in the file system prior to the execution of dmake.
 
- .PROLOG
 - Insert shell prolog code when executing a group recipe associated with any target having this attribute set.
 
- .SEQUENTIAL
 - Force a sequential make of the associated target's prerequisites. If set as a global attribute this implies setting MAXPROCESS=1.
 
- .SETDIR
 - Change current working directory to specified directory when making the associated target. You must specify the directory at the time the attribute is specified. To do this simply give .SETDIR=path as the attribute. path is expanded and the result is used as the value of the directory to change to. If path contains $$@ then the name of the target to be built is used in computing the path to change directory to. If path is surrounded by single quotes then path is not expanded, and is used literally as the directory name. If the path contains any `:' characters then the entire attribute string must be quoted using ". If a target having this attribute set also has the .IGNORE attribute set then if the change to the specified directory fails it will be ignored, and no error message will be issued.
 
- .SILENT
 - Do not echo the recipe lines when making any target with this attribute set, and do not issue any warnings.
 
- .SWAP
 - Under MSDOS when making a target with this attribute set swap the dmake executable to disk prior to executing the recipe line. Also see the '%' recipe line flag defined in the RECIPES section.
 
- .SYMBOL
 - Target is a library member and is an entry point into a module in the library. This attribute is used only when searching a library for a target. Targets of the form lib((entry)) have this attribute set automatically.
 
- .USESHELL
 - Force each recipe line of a target to be executed using a shell. Specifying this attribute is equivalent to specifying the '+' character at the start of each line of a non-group recipe.
 
- .UPDATEALL
 - Indicates that all the targets listed in this rule are updated by the execution of the accompanying recipe. A common example is the production of the y.tab.c and y.tab.h files by yacc when it is run on a grammar. Specifying .UPDATEALL in such a rule prevents the running of yacc twice, once for the y.tab.c file and once for the y.tab.h file. .UPDATEALL targets that are specified in a single rule are treated as a single target and all timestamps are updated whenever any target in the set is made. As a side-effect, dmake internally sorts such targets in ascending alphabetical order and the value of $@ is always the first target in the sorted set.
 
- .WINPATH
 - Switch between default (POSIX) and Windows style path
      representation. (This attribute is specific for cygwin dmake executables
      and non-cygwin environments ignore this attribute.)
    Under Cygwin it can be useful to generate Windows style paths (with regular slashes) instead of the default cygwin style (POSIX) paths for dmake's dynamic macros. The affected macros are $@, $*, $>, $?, $<, $&, $^ and $(MAKEDIR), $(PWD), $(TMD), $(TMPFILE) and the $(mktmp ...) function macro. This feature can be used to create DOS style path parameters for native W32 programs from dynamic macros.Note that the Windows style paths use regular slashes ('/') instead of the usual Windows backslash ('\') as directory separator to avoid quoting problems (after all it is still a cygwin dmake!) and cygwin, as well as native Windows, programs should have no problems using this (c:/foo/bar) path representation.Example: Assuming the current target to be /tmp/mytarget the $@ macro without .WINPATH active expands to:
 
/tmp/mytarget
 
With .WINPATH set it expands to:
C:/cygwin/tmp/mytarget
MACROS¶
dmake supports six forms of macro assignment.- MACRO = LINE
 - This is the most common and familiar form of macro assignment. It assigns LINE literally as the value of MACRO. Future expansions of MACRO recursively expand its value.
 
- MACRO *= LINE
 - This form behaves exactly as the simple '=' form with the exception that if MACRO already has a value then the assignment is not performed.
 
- MACRO := LINE
 - This form differs from the simple '=' form in that it expands LINE prior to assigning it as the value of MACRO. Future expansions of MACRO do not recursively expand its value.
 
- MACRO *:= LINE
 - This form behaves exactly as the ':=' form with the exception that if MACRO already has a value then the assignment and expansion are not performed.
 
- MACRO += LINE
 - This form of macro assignment allows macro values to grow. It takes the literal value of LINE and appends it to the previous value of MACRO separating the two by a single space. Future expansions of MACRO recursively expand its value.
 
- MACRO +:= LINE
 - This form is similar to the '+=' form except that the value of LINE is expanded prior to being added to the value of MACRO.
 
- $(macro_name:modifier_list:modifier_list:...)
 
- b or B
 - 
    
- file (not including suffix) portion of path names 
- d or D
 - 
    
- directory portion of all path names 
- e or E
 - 
    
- suffix portion of path names 
- f or F
 - 
    
- file (including suffix) portion of path names 
- i or I
 - 
    
- inferred names of targets 
- n or N
 - 
    
- normalized path names 
- l or L
 - 
    
- macro value in lower case 
- u or U
 - 
    
- macro value in upper case 
- 1
 - 
    
- return the first white space separated token from value 
or a single one of:
- m or M
 - 
    
- map escape codes found in macro to their ASCII value 
- s or S
 - 
    
- simple pattern substitution 
- t or T
 - 
    
- tokenization. 
- ^
 - 
    
- prepend a prefix to each token 
- +
 - 
    
- append a suffix to each token
 
Thus if we have the example:
test = d1/d2/d3/a.out f.out d1/k.out
The following macro expansions produce the values on the right of '→'
  after expansion.
- $(test:d)
 - 
    
→ d1/d2/d3/ d1/ 
- $(test:b)
 - 
    
→ a f k 
- $(test:f)
 - 
    
→ a.out f.out k.out 
- ${test:db}
 - 
    
→ d1/d2/d3/a f d1/k 
- ${test:s/out/in/:f}
 - 
    
→ a.in f.in k.in 
- $(test:f:t"+")
 - 
    
→ a.out+f.out+k.out 
- $(test:e)
 - 
    
→ .out .out .out 
- $(test:u)
 - 
    
→ D1/D2/D3/A.OUT F.OUT D1/K.OUT 
- $(test:1)
 - 
    
→ d1/d2/d3/a.out 
For this macro
test = d1/d2/../a.out "d1/file
  name.ext"
the following results are returned:
- $(test:n)
 - 
    
→ d1/a.out "d1/file name.ext" 
If a token ends in a string composed from the value of the macro DIRBRKSTR (ie. ends in a directory separator string, e.g. '/' in UNIX) and you use the :d modifier then the expansion returns the directory name less the final directory separator string. Thus successive pairs of :d modifiers each remove a level of directory in the token string. The infered names of targets :i modifier returnes the actual filename associated to the target, see BINDING TARGETS. If the value is not a target or prerequisite the value is returned unchanged. For the following example:
test = aprog bprog
If aprog and bprog are targets or prerequisits and they are bound to /tmp/aprog
  and bprog (see .SOURCE special target) the macro expansion has the following
  effect:
- $(test:i)
 - 
    
→ /tmp/aprog bprog 
The normalized path names :n modifier honors the setting of .WINPATH to determine the output format of the result. The map escape codes modifier changes the following escape codes \a => <bel>, \b => <backspace>, \f => <formfeed>, \n => <nl>, \r => <cr>, \t => <tab>, \v => <vertical tab>, \" => ", and \xxx => <xxx> where xxx is the octal representation of a character into the corresponding ASCII value. The tokenization, prepend and append modifier may use the same escape codes that are supported by the map escape codes modifier in the string that is inserted, prepended or added by the respective macro modifier. These modifiers may quote this string to include otherwise problematic characters. E.g. spaces, colons and parentheses. The tokenization modifier takes all white space separated tokens from the macro value and separates them by the separator string. Thus the expansion:
$(test:f:t"+\n")
produces:
a.out+ f.out+ k.out
$(test:f:^mydir/)
produces:
mydir/a.out mydir/f.out mydir/k.out
$(test:b:+.c)
produces:
a.c f.c k.c
CFLAGS_VAX_CC = -c -O # _HOST == "_VAX", _COMPILER == "_CC" CFLAGS_PC_MSC = -c -ML # _HOST == "_PC", _COMPILER == "_MSC"# redefine CFLAGS macro as:CFLAGS := $(CFLAGS$(_HOST)$(_COMPILER))
- test/{f1 f2}.o
 - 
    
--> test/f1.o test/f2.o 
- test/ {f1 f2}.o
 - 
    
--> test/ f1.o f2.o 
- test/{f1 f2} .o
 - 
    
--> test/f1 test/f2 .o 
- test/{"f1" ""}.o
 - 
    
--> test/f1.o test/.o
 
- and
 - 
    
 
- test/{d1 d2}/{f1 f2}.o -->
 - 
    
test/d1/f1.o test/d1/f2.o test/d2/f1.o test/d2/f2.o
 
This last expansion is activated only when the first characters of token_list appear immediately after the opening '{' with no intervening white space. The reason for this restriction is the following incompatibility with Bourne Shell recipes. The line
is not. Hence the latter triggers the enhanced macro expansion while the former causes it to be suppressed. See the SPECIAL MACROS section for a description of the special macros that dmake defines and understands.
RULES AND TARGETS¶
A makefile contains a series of entries that specify dependencies. Such entries are called target/prerequisite or rule definitions. Each rule definition is optionally followed by a set of lines that provide a recipe for updating any targets defined by the rule. Whenever dmake attempts to bring a target up to date and an explicit recipe is provided with a rule defining the target, that recipe is used to update the target. A rule definition begins with a line having the following syntax:<targets> [<attributes>] <ruleop> [<prerequisites>] [;<recipe>]
.IMPORT .ERROR : ...
- NOTE:
 - As stated earlier, if both the target list and prerequisite
      list are empty but the attributes list is not, then the specified
      attributes affect all targets in the makefile.
    
 
- !
 - says execute the recipe for the associated targets once for each out of date prerequisite. (The meaning of the runtime macro $? is changed, see below in the RUNTIME MACROS section.) Ordinarily the recipe is executed once for all out of date prerequisites at the same time.
 
- ^
 - says to insert the specified prerequisites, if any, before any other prerequisites already associated with the specified targets. In general, it is not useful to specify ^ with an empty list of prerequisites.
 
- -
 - says to clear the previous list of prerequisites before
      adding the new prerequisites. Thus,
    foo :foo : bar bazcan be replaced byfoo :- bar bazhowever the old form still works as expected.
 
- :
 - When the rule operator is not modified by a second ':' only
      one set of rules may be specified for making a target. Multiple
      definitions may be used to add to the list of prerequisites that a target
      depends on. However, if a target is multiply defined only one definition
      may specify a recipe for making the target.
    When a target's rule operator is modified by a second ':' (:: for example) then this definition may not be the only definition with a recipe for the target. There may be other :: target definition lines that specify a different set of prerequisites with a different recipe for updating the target. Any such target is made if any of the definitions find it to be out of date with respect to the related prerequisites and the corresponding recipe is used to update the target. By definition all '::' recipes that are found to be out of date for are executed.In the following simple example, each rule has a `::' ruleop. In such an operator we call the first `:' the operator, and the second `:' the modifier.
a.o :: a.c b.h first recipe for making a.o a.o :: a.y b.h second recipe for making a.oIf a.o is found to be out of date with respect to a.c then the first recipe is used to make a.o. If it is found out of date with respect to a.y then the second recipe is used. If a.o is out of date with respect to b.h then both recipes are invoked to make a.o. In the last case the order of invocation corresponds to the order in which the rule definitions appear in the makefile. 
- |
 - Is defined only for PERCENT rule target definitions. When
      specified it indicates that the following construct should be parsed using
      the old semantinc meaning:
    
%.o :| %.c %.r %.f ; some rule
is equivalent to:%.o : %.c ; some rule %.o : %.r ; some rule %.o : %.f ; some rule 
joe : fred ... (1) joe :: more ... (2)andjoe :: fred ... (3) joe :: more ... (4)
joe :: fred ... (5) joe : more ... (6)andjoe : fred ... (7) joe : more ... (8)
RECIPES¶
The traditional format used by most versions of Make defines the recipe lines as arbitrary strings that may contain macro expansions. They follow a rule definition line and may be spaced apart by comment or blank lines. The list of recipe lines defining the recipe is terminated by a new target definition, a macro definition, or end-of-file. Each recipe line MUST begin with a <TAB> character (or spaces, see .NOTABS) which may optionally be followed with one or all the following recipe property characters '@%+-' which affect the recipe execution:- '-'
 - indicates that non-zero exit values (ie. errors) are to be ignored when this recipe line is executed.
 
- '+'
 - indicates that the current recipe line is to be executed using the shell. Group recipes implicitely ignore this property.
 
- '%'
 - indicates that dmake should swap itself out to secondary storage (MSDOS only) before running the recipe.
 
- '@'
 - indicates that the recipe line should NOT be echoed to the terminal prior to being executed.
 
- '@@'
 - is a stronger version of the previous property. The recipe line and the output (stdout and stderr) of the executed recipe are NOT shown on the terminal.
 
target :
first recipe line second recipe line, executed independent of first. @a recipe line that is not echoed -and one that has errors ignored %and one that causes dmake to swap out +and one that is executed using a shell.
target : [ first recipe line second recipe line tall of these recipe lines are fed to a single copy of a shell for execution. ]
BUILTIN COMMANDS¶
dmake supports some builtin commands. An optional leading '+' describes that the builtin can be used also when being executed in a shell otherwise it is only implemented when used directly. Remember that if a character of the recipe is found in the SHELLMETAS macro the execution of the recipe in a shell is forced.- [+]noop [something]
 - The noop internal command always returns success if used but it is not executed even though the rest of the commandline is evaluated. This command can be used to evaluate macro expansions at the runtime of the recipe without starting a real commmand.
 
- [+]<empty recipe>
 - If an empty recipe line is encountered it is not executed. This sounds more trivial than it really is because the recipe could consist of macros that evaluated to empty or whitespace only strings.
 
- echo [-n] data
 - This internal command prints data (with all leading whitespace removed, but otherwise literally) to stdout. If the '-n' switch is given no trailing newline is printed. Note that no quoting is removed nor that escape sequences are handled.
 
TEXT DIVERSIONS¶
dmake supports the notion of text diversions. If a recipe line contains the macro expressionmytext:=this is a\ntest of the text diversion all: cat $(mktmp $(mytext:m))
OBJ = fred.obj mary.obj joe.obj all : $(OBJ) link @$(mktmp $(^:t"+\n"))
fred.obj+ mary.obj+ joe.obj
VIRTUAL TARGETS¶
Dmake allows to define targets with the sole purpose to enforce a dependency chain that are unable to create the target, hence virtual targets. When dmake tries to make a target, but only finds a target definition without recipe lines, it would normally issues a "Don't know how to make ..." error message, but if a target rule is terminated by a semicolon and has no following recipe lines, or if it has no recipe lines, but defines prerequisites, or if the AUGMAKE mode is enabled (see the COMPATIBILITY section for details), the target is treated as a virtual target and the error is suppressed. In addition to this, if the default target does not have recipe lines it is also treated as a virtual target. Virtual targets should not have a corresponding file therefore they inherit the time of their newest prerequisite if they have prerequisites, otherwise they get the current time assigned when being made. If the virtual target has a corresponding file a warning is issued, but the time stamp of that file is taken into account. The virtual target uses the time stamp of the corresponding file if it is newer than the one determined by the previous rule.SPECIAL TARGETS¶
This section describes the special targets that are recognized by dmake. Some are affected by attributes and others are not.- .ERROR
 - If defined then the recipe associated with this target is executed whenever an error condition is detected by dmake. All attributes that can be used with any other target may be used with this target. Any prerequisites of this target will be brought up to date during its processing. NOTE: errors will be ignored while making this target, in extreme cases this may cause some problems.
 
- .EXIT
 - If this target is encountered while parsing a makefile then the parsing of the makefile is immediately terminated at that point.
 
- .EXPORT
 - All prerequisites associated with this target are assumed
      to correspond to macro names and they and their values are exported to the
      environment as environment strings at the point in the makefile at which
      this target appears. Any attributes specified with this target are
      ignored. Only macros which have been assigned a value in the makefile
      prior to the export directive are exported, macros as yet undefined or
      macros whose value contains any of the characters "+=:*" are not
      exported.
    Note that macros that are not expanded during the macro assignment and contain other macros will be written into the environment containing these other macros in the form of $(macroname).
 
- .IMPORT
 - Prerequisite names specified for this target are searched for in the environment and defined as macros with their value taken from the environment. If the special name .EVERYTHING is used as a prerequisite name then all environment variables defined in the environment are imported. The functionality of the -E flag can be forced by placing the construct .IMPORT : .EVERYTHING at the start of a makefile. Similarly, by placing the construct at the end, one can emulate the effect of the -e command line flag. If a prerequisite name cannot be found in the environment an error message is issued. .IMPORT accepts the .IGNORE attribute. When given, it causes dmake to ignore the above error. See the MACROS section for a description of the processing of imported macro values.
 
- .INCLUDE
 - Parse another makefile just as if it had been located at the point of the .INCLUDE in the current makefile. The list of prerequisites gives the list of makefiles to try to read. If the list contains multiple makefiles then they are read in order from left to right. The following search rules are used when trying to locate the file. If the filename is surrounded by " or just by itself then it is searched for in the current directory. If it is not found it is then searched for in each of the directories specified as prerequisites of the .INCLUDEDIRS special target. If the file name is surrounded by < and >, (ie. <my_spiffy_new_makefile>) then it is searched for only in the directories given by the .INCLUDEDIRS special target. In both cases if the file name is a fully qualified name starting at the root of the file system then it is only searched for once, and the .INCLUDEDIRS list is ignored. If .INCLUDE fails to find the file it invokes the inference engine to try to infer and hence make the file to be included. In this way the file can be checked out of an RCS repository for example. .INCLUDE accepts the .IGNORE, .SETDIR, and .NOINFER attributes. If the .IGNORE attribute is given and the file cannot be found then dmake continues processing, otherwise an error message is generated. If the .NOINFER attribute is given and the file cannot be found then dmake will not attempt to infer and make the file. The .SETDIR attribute causes dmake to change directories to the specified directory prior to attempting the include operation. If all fails dmake attempts to make the file to be included. If making the file fails then dmake terminates unless the .INCLUDE directive also specified the .IGNORE attribute. If .FIRST is specified along with .INCLUDE then dmake attempts to include each named prerequisite and will terminate the inclusion with the first prerequisite that results in a successful inclusion.
 
- .INCLUDEDIRS
 - The list of prerequisites specified for this target defines the set of directories to search when trying to include a makefile.
 
- .KEEP_STATE
 - This special target is a synonym for the macro definition
    .KEEP_STATE := _state.mkIt's effect is to turn on STATE keeping and to define _state.mk as the state file.
 
- .MAKEFILES
 - The list of prerequisites is the set of files to try to
      read as the default makefile. By default this target is defined as:
    .MAKEFILES : makefile.mk Makefile makefile
 
- .REMOVE
 - The recipe of this target is used whenever dmake needs to remove intermediate targets that were made but do not need to be kept around. Such targets result from the application of transitive closure on the dependency graph.
 
- .ROOT
 - The internal root of the dependency graph, see section STARTUP for details.
 
- .SOURCE
 - The prerequisite list of this target defines a set of directories to check when trying to locate a target file name. See the section on BINDING of targets for more information.
 
- .SOURCE.suff
 - The same as .SOURCE, except that the .SOURCE.suff list is searched first when trying to locate a file matching the a target whose name ends in the suffix .suff.
 
- .SUFFIXES
 - This deprecated special target has no special meaning. Avoid its use.
 
- .TARGETS
 - The internal targets that all user defined targets are prerequisites of, see section STARTUP for details.
 
.INIT .DONE
SPECIAL MACROS¶
dmake defines a number of special macros. They are divided into three classes: control macros, run-time macros, and function macros. The control macros are used by dmake to configure its actions, and are the preferred method of doing so. In the case when a control macro has the same function as a special target or attribute they share the same name as the special target or attribute. The run-time macros are defined when dmake makes targets and may be used by the user inside recipes. The function macros provide higher level functions dealing with macro expansion and diversion file processing.CONTROL MACROS¶
To use the control macros simply assign them a value just like any other macro. The control macros are divided into three groups: string valued macros, character valued macros, and boolean valued macros. The following are all of the string valued macros. This list is divided into two groups. The first group gives the string valued macros that are defined internally and cannot be directly set by the user.- ABSMAKECMD
 - Warning! This macro's value is differently defined
      for a native Windows dmake executable (compiled with MS Visual C++ or
      MinGW) and dmake for other operating systems or build with other
      compilers.
    In the first case its value is the absolute filename of the executable of the current dmake process, otherwise it is defined as the NULL string.
 
- INCDEPTH
 - This macro's value is a string of digits representing the current depth of makefile inclusion. In the first makefile level this value is zero.
 
- MFLAGS
 - Is the list of flags that were given on the command line including a leading switch character. The -f flag is not included in this list.
 
- MAKECMD
 - Is the name with which dmake was invoked.
 
- MAKEDIR
 - Is the full path to the initial directory in which dmake was invoked.
 
- MAKEFILE
 - Contains the string "-f makefile" where, makefile is the name of initial user makefile that was first read.
 
- MAKEFLAGS
 - Is the same as $(MFLAGS) but has no leading switch character. (ie. MFLAGS = -$(MAKEFLAGS))
 
- MAKEMACROS
 - Contains the complete list of macro expressions that were specified on the command line.
 
- MAKETARGETS
 - Contains the name(s) of the target(s), if any, that were specified on the command line.
 
- MAKEVERSION
 - Contains a string indicating the current dmake version number.
 
- MAXPROCESSLIMIT
 - Is a numeric string representing the maximum number of processes that dmake can use when making targets using parallel mode.
 
- NULL
 - Is permanently defined to be the NULL string. This is useful when comparing a conditional expression to an NULL value.
 
- PWD
 - Is the full path to the current directory in which make is executing.
 
- SPACECHAR
 - Is permanently defined to contain one space character. This is useful when using space characters in function macros, e.g. subst, that otherwise would get deleted (leading/trailing spaces) or for using spaces in function macro parameters.
 
- TMPFILE
 - Is set to the name of the most recent temporary file opened by dmake. Temporary files are used for text diversions and for group recipe processing.
 
- TMD
 - Stands for "To Make Dir", and is the path from the present directory (value of $(PWD)) to the directory that dmake was started up in (value of $(MAKEDIR)). If the present directory is the directory that dmake was started up in TMD will be set to the relative path ".". This allows to create valid paths by prepending $(TMD)$(DIRSEPSTR) to a relative path. This macro is modified when .SETDIR attributes are processed. TMD will usually be a relative path with the following two exceptions. If the relative path would go up until the root directory or if different drive letters (DOS file system) make a relative path impossible the absolute path from MAKEDIR is used.
 
- USESHELL
 - The value of this macro is set to "yes" if the
      current recipe is forced to use a shell for its execution via the
      .USESHELL or '+' directives, its value is "no" otherwise.
    
 
- .DIRCACHE
 - If set to "yes" enables the directory cache (this is the default). If set to "no" disables the directory cache (equivalent to -d command-line flag).
 
- .DIRCACHERESPCASE
 - If set to "yes" causes the directory cache, if
      enabled, to respect file case, if set to "no" files are cached
      case insensitive. By default it is set to "no" on Windows as the
      filesystems on this operating system are case insensitive and set to
      "yes" for all other operating systems. The default can be
      overriden, if desired.
    Note: Using case insensitive directory caching on case sensitive file systems is a BAD idea. If in doubt use case sensitive directory caching even on case insensitive file systems as the worst case in this scenario is that /foo/bar/ and /foo/BAR/ are cached separately (with the same content) even though they are the same directory. This would only happen if different targets use different upper/lower case spellings for the same directory and that is never a good idea.
 
- NAMEMAX
 - Defines the maximum length of a filename component. The value of the variable is initialized at startup to the value of the compiled macro NAME_MAX. On some systems the value of NAME_MAX is too short by default. Setting a new value for NAMEMAX will override the compiled value.
 
- .NOTABS
 - When set to "yes" enables the use of spaces as well as <tabs> to begin recipe lines. By default a non-group recipe is terminated by a line without any leading white-space or by a line not beggining with a <tab> character. Enabling this mode modifies the first condition of the above termination rule to terminate a non-group recipe with a line that contains only white-space. This mode does not effect the parsing of group recipes bracketed by [].
 
- AUGMAKE
 - If set to "yes" value will enable the transformation of special meta targets to support special AUGMAKE inferences (See the "AUGMAKE META RULES" and "COMPATIBILITY" sections).
 
- DIRBRKSTR
 - Contains the string of chars used to terminate the name of a directory in a pathname. Under UNIX its value is "/", under MSDOS its value is "/\:".
 
- DIRSEPSTR
 - Contains the string that is used to separate directory components when path names are constructed. It is defined with a default value at startup.
 
- DIVFILE
 - Is defined in the startup file and gives the name that should be returned for the diversion file name when used in $(mktmp ...) expansions, see the TEXT DIVERSION section for details.
 
- .KEEP_STATE
 - Assigning this macro a value tells dmake the name of the state file to use and turns on the keeping of state information for any targets that are brought up to date by the make.
 
- GROUPFLAGS
 - This macro gives the set of flags to pass to the shell when invoking it to execute a group recipe. The value of the macro is the list of flags with a leading switch indicator. (ie. `-' under UNIX)
 
- GROUPSHELL
 - This macro defines the full path to the executable image to be used as the shell when processing group recipes. This macro must be defined if group recipes are used. It is assigned a default value in the startup makefile. Under UNIX this value is /bin/sh.
 
- GROUPSUFFIX
 - If defined, this macro gives the string to use as a suffix when creating group recipe files to be handed to the command interpreter. For example, if it is defined as .sh, then all temporary files created by dmake will end in the suffix .sh. Under MSDOS if you are using command.com as your GROUPSHELL, then this suffix must be set to .bat in order for group recipes to function correctly. The setting of GROUPSUFFIX and GROUPSHELL is done automatically for command.com in the startup.mk files.
 
- MAKE
 - Is defined in the startup file by default. Initially this macro is defined to have the value "$(MAKECMD) $(MFLAGS)". The string $(MAKE) is recognized when using the -n switch.
 
- MAKESTARTUP
 - This macro defines the full path to the initial startup makefile. Use the -V command line option to discover its initial value.
 
- MAXLINELENGTH
 - This macro defines the maximum size of a single line of makefile input text. The size is specified as a number, the default value is defined internally and is shown via the -V option. A buffer of this size plus 2 is allocated for reading makefile text. The buffer is freed before any targets are made, thereby allowing files containing long input lines to be processed without consuming memory during the actual make. This macro can only be used to extend the line length beyond it's default minimum value.
 
- MAXPROCESS
 - Specify the maximum number of child processes to use when making targets. The default value of this macro is "1" and its value cannot exceed the value of the macro MAXPROCESSLIMIT. Setting the value of MAXPROCESS on the command line or in the makefile is equivalent to supplying a corresponding value to the -P flag on the command line. If the global .SEQUENTIAL attribute is set (or the -S command line switch is used) the value of MAXPROCESS is fixed to "1" and cannot be changed.
 
- OOODMAKEMODE
 - This macro enables a special compatibility mode needed by the OpenOffice.org build system. If set, the switch disables the removal of leading './' path elements during target filename normalization (See BINDING TARGETS). If './' appear in the pathname, but not at the beginning of it, they are still removed by the normalization. Please note that targets that are given on the command line are going to be registered as default targets after the startup file is read.
 
- PREP
 - This macro defines the number of iterations to be expanded
      automatically when processing % rule definitions of the form:
    % : %.suffSee the sections on PERCENT(%) RULES for details on how PREP is used.
 
- SHELL
 - This macro defines the full path to the executable image to be used as the shell when processing single line recipes. This macro must be defined if recipes requiring the shell for execution are to be used. It is assigned a default value in the startup makefile. Under UNIX this value is /bin/sh.
 
- SHELLCMDQUOTE
 - This macro can be used to add additional characters before and after the command string that is passed to the shell defined by the SHELL macro. If needed, like for cmd.exe and command.com, it is assigned a value in the startup file.
 
- SHELLFLAGS
 - This macro gives the set of flags to pass to the shell when invoking it to execute a single line recipe. The value of the macro is the list of flags with a leading switch indicator. (ie. `-' under UNIX)
 
- SHELLMETAS
 - Each time dmake executes a single recipe line (not a
      group recipe) the line is searched for any occurrence of a character
      defined in the value of SHELLMETAS. If such a character is found the
      recipe line is defined to require a shell to ensure its correct execution.
      In such instances a shell is used to invoke the recipe line. If no match
      is found the recipe line is executed without the use of a shell.
    
 
RUNTIME MACROS¶
These macros are defined when dmake is making targets, and may take on different values for each target. $@ is defined to be the full target name, $? is the list of all out of date prerequisites, except for the ! ruleop, in which case it is set to the current build prerequisite instead. $& is the list of all prerequisites, $> is the name of the library if the current target is a library member, and $< is the list of prerequisites specified in the current rule. If the current target had a recipe inferred then $< is the name of the inferred prerequisite even if the target had a list of prerequisites supplied using an explicit rule that did not provide a recipe. In such situations $& gives the full list of prerequisites. $* is defined as $(@:db) when making targets with explicit recipes and is defined as the value of % when making targets whose recipe is the result of an inference. In the first case $* is the target name with no suffix, and in the second case, is the value of the matched % pattern from the associated %-rule. $^ expands to the set of out of date prerequisites taken from the current value of $<. In addition to these, $$ expands to $, {{ expands to {, }} expands to }, and the strings <+ and +> are recognized as respectively starting and terminating a text diversion when they appear literally together in the same input line. The difference between $? and $^ can best be illustrated by an example, consider:fred.out : joe amy hello rules for making fred fred.out : my.c your.h his.h her.h # more prerequisites
- $@
 - 
    
--> fred.out 
- $*
 - 
    
--> fred 
- $?
 - 
    
--> joe amy my.c # note output of $? vs $^ 
- $^
 - 
    
--> joe amy 
- $<
 - 
    
--> joe amy hello 
- $&
 - 
    
--> joe amy hello my.c your.h his.h her.h 
FUNCTION MACROS¶
dmake supports a full set of functional macros. One of these, the $(mktmp ...) macro, is discussed in detail in the TEXT DIVERSION section and is not covered here. The names of function macros must appear literally after the opening $( or ${. They are not recognized if they are the result of a recursive expansion. Note that some of these macros take comma separated parameters but that these parameters must not contain literal whitespaces. Whitespaces in macros used in these parameters are allowed.- $(and macroterm ...)
 - expands each macroterm in turn until there are no
      more or one of them returns an empty string. If all expand to non-empty
      strings the macro returs the string "t" otherwise it returns an
      empty string.
    
 
- $(assign expression)
 - Causes expression to be parsed as a macro assignment expression and results in the specified assignment being made. An error is issued if the assignment is not syntatically correct. expression may contain white space. This is in effect a dynamic macro assignment facility and may appear anywhere any other macro may appear. The result of the expanding a dynamic macro assignment expression is the name of the macro that was assigned and $(NULL) if the expression is not a valid macro assignment expression. Some examples are:
 
$(assign foo := fred) $(assign $(ind_macro_name) +:= $(morejunk))
- $(echo list)
 - Echo's the value of list. list is not expanded.
 
- $(eq,text_a,text_b true false)
 - expands text_a and text_b and compares their results. If equal it returns the result of the expansion of the true term, otherwise it returns the expansion of the false term.
 
- $(!eq,text_a,text_b true false)
 - Behaves identically to the previous macro except that the true string is chosen if the expansions of the two strings are not equal
 
- $(foreach,var,list data)
 - Implements iterative macro expansion over data using var as the iterator taking on values from list. var and list are expanded and the result is the concatenation of expanding data with var being set to each whitespace separated token from list. For example:
 
list = a b c all :; echo [$(foreach,i,$(list) [$i])]
[[a] [b] [c]]
$(foreach,i,$(foreach,i,$(sort c a b) root/$i) [$i/f.h])
[root/a/f.h] [root/b/f.h] [root/c/f.h]
$($(assign list=a b c)) $(sort d a b c) $(echo a b c)
$(foreach,i,a b c [$i])
"b c [a]"
- $(nil expression)
 - Always returns the value of $(NULL) regardless of what expression is. This function macro can be used to discard results of expanding macro expressions.
 
- $(normpath list)
 - Will return the normalized path names of all white-space separated tokens in list. Quotes can be used to normalize path names that contain white-space characters. On cygwin the result honors the setting of .WINPATH to determine the output format of the returned path names.
 
- $(normpath,para list)
 - Same as above except that the expanded value of para is used to override the .WINPATH setting.
 
- $(not macroterm)
 - expands macroterm and returs the string "t" if the result of the expansion is the empty string; otherwise, it returns the empty string.
 
- $(null,text true false)
 - expands the value of text. If it is NULL then the macro returns the value of the expansion of true and the expansion of false otherwise. The terms true, and false must be strings containing no white-space.
 
- $(!null,text true false)
 - Behaves identically to the previous macro except that the true string is chosen if the expansion of text is not NULL.
 
- $(or macroterm ...)
 - expands each macroterm in turn and returs the empty string if each term expands to the empty string; otherwise, it returs the string "t".
 
- $(shell command)
 - is a shell escape macro. It runs command as if it were part of a recipe and returns, separated by a single space, all the non-white space terms written to stdout by the command. For example:
 
- $(shell,expand command)
 - Is an extension to the $(shell command) function macro that expands the result of running command.
 
- $(sort list)
 - Will take all white-space separated tokens in list and will return their sorted equivalent list.
 
- $(strip data)
 - Will replace all strings of white-space in data by a single space.
 
- $(subst,pat,replacement data)
 - Will search for pat in data and will replace any occurrence of pat with the replacement string. The expansion
 
- $(uniq list)
 - Will take all white-space separated tokens in list
      and will return their sorted equivalent list containing no duplicates.
    
 
CONDITIONAL MACROS¶
dmake supports conditional macros. These allow the definition of target specific macro values. You can now say the following:foo := helloall : cond;@echo "all done, foo=[$(foo)] bar=[$(bar)]"cond ?= bar := global declcond .SETDIR=unix::;@echo $(foo) $(bar) cond ?= foo := hicond .SETDIR=msdos::;@echo $(foo) $(bar) cond ?= foo := hihi
mytarget ?= bar := hello mytarget ?= foo := $(bar)
mytarget ?= bar := hello mytarget ?= foo = $(bar)
DYNAMIC PREREQUISITES¶
dmake looks for prerequisites whose names contain macro expansions during target processing. Any such prerequisites are expanded and the result of the expansion is used as the prerequisite name. As an example the line:BINDING TARGETS¶
This operation takes a target name and binds it to an existing file, if possible. dmake makes a distinction between the internal target name of a target and its associated external file name. Thus it is possible for a target's internal name and its external file name to differ. To perform the binding, the following set of rules is used. Assume that we are trying to bind a target whose name is of the form X.suff, where .suff is the suffix and X is the stem portion (ie. that part which contains the directory and the basename). dmake takes this target name and performs a series of search operations that try to find a suitably named file in the external file system. The search operation is user controlled via the settings of the various .SOURCE targets.- 1.
 - If target has the .SYMBOL attribute set then look for it in the library. If found, replace the target name with the library member name and continue with step 2. If the name is not found then return.
 
- 2.
 - Extract the suffix portion (that following the `.') of the target name. If the suffix is not null, look up the special target .SOURCE.<suff> (<suff> is the suffix). If the special target exists then search each directory given in the .SOURCE.<suff> prerequisite list for the target. If the target's suffix was null (ie. .suff was empty) then perform the above search but use the special target .SOURCE.NULL instead. If at any point a match is found then terminate the search. If a directory in the prerequisite list is the special name `.NULL ' perform a search for the full target name without prepending any directory portion (ie. prepend the NULL directory).
 
- 3.
 - The search in step 2. failed. Repeat the same search but this time use the special target .SOURCE. (a default target of '.SOURCE : .NULL' is defined by dmake at startup, and is user redefinable)
 
- 4.
 - The search in step 3. failed. If the target has the library member attribute (.LIBMEMBER) set then try to find the target in the library which was passed along with the .LIBMEMBER attribute (see the MAKING LIBRARIES section). The bound file name assigned to a target which is successfully located in a library is the same name that would be assigned had the search failed (see 5.).
 
- 5.
 - The search failed. Either the target was not found in any of the search directories or no applicable .SOURCE special targets exist. If applicable .SOURCE special targets exist, but the target was not found, then dmake assigns the first name searched as the bound file name. If no applicable .SOURCE special targets exist, then the full original target name becomes the bound file name.
 
PERCENT(%) RULES AND MAKING INFERENCES¶
When dmake makes a target, the target's set of prerequisites (if any) must exist and the target must have a recipe which dmake can use to make it. If the makefile does not specify an explicit recipe for the target then dmake uses special rules to try to infer a recipe which it can use to make the target. Previous versions of Make perform this task by using rules that are defined by targets of the form .<suffix>.<suffix> (this is still supported, see "AUGMAKE META RULES") or by using the not supported by dmake .SUFFIXES list of suffixes (see "SPECIAL TARGETS" for more details about .SUFFIXES). The exact workings of this mechanism were sometimes difficult to understand and often limiting in their usefulness. Instead, dmake supports the concept of %-meta rules. The syntax and semantics of these rules differ from standard rule lines as follows:<%-targets> [<attributes>] <ruleop> [<%-prereqs>] [;<recipe>]
- %.c
 - 
    
matches fred.c but not joe.c.Z 
- dir/%.c
 - 
    
matches dir/fred.c but not dd/fred.c 
- fred/%
 - 
    
matches fred/joe.c but not f/joe.c 
- %
 - 
    
matches anything 
fred.o : fred.c ; rule to make fred.o fred.o : local.h
%.o : %.c 'local.h' ; recipe %.o : %.f 'local.h' ; recipe
%.o : %.c ; rule for making .o from .c %.c : %.y ; rule for making .c from .y % : RCS/%,v ; check out of RCS file
.NOINFER : RCS/%,v
AUGMAKE META RULES¶
As a subclass of the meta targets that is actually mapped to %-meta rules dmake understands several SYSV AUGMAKE targets transformations. This .<suffix> special target construct transforms into the following %-meta rules:MAKING TARGETS¶
In order to update a target dmake must execute a recipe. When a recipe needs to be executed it is first expanded so that any macros in the recipe text are expanded, and it is then either executed directly or passed to a shell. dmake supports two types of recipes. The regular recipes and group recipes. When a regular recipe is invoked dmake executes each line of the recipe separately using a new copy of a shell if a shell is required. Thus effects of commands do not generally persist across recipe lines (e.g. cd requests in a recipe line do not carry over to the next recipe line). This is true even in environments such as MSDOS, where dmake internally sets the current working director to match the directory it was in before the command was executed. The decision on whether a shell is required to execute a command is based on the value of the macro SHELLMETAS or on the specification of '+' or .USESHELL for the current recipe or target respectively. If any character in the value of SHELLMETAS is found in the expanded recipe text-line or the use of a shell is requested explicitly via '+' or .USESHELL then the command is executed using a shell, otherwise the command is executed directly. The shell that is used for execution is given by the value of the macro SHELL. The flags that are passed to the shell are given by the value of SHELLFLAGS. Thus dmake constructs the command line:SH = + all: $(SH)echo hi
SH = + all: +echo hi
MAKING LIBRARIES¶
Libraries are easy to maintain using dmake. A library is a file containing a collection of object files. Thus to make a library you simply specify it as a target with the .LIBRARY attribute set and specify its list of prerequisites. The prerequisites should be the object members that are to go into the library. When dmake makes the library target it uses the .LIBRARY attribute to pass to the prerequisites the .LIBMEMBER attribute and the name of the library. This enables the file binding mechanism to look for the member in the library if an appropriate object file cannot be found. dmake now supports Elf libraries on systems that support Elf and hence supports, on those systems, long member file names. A small example best illustrates this.mylib.a .LIBRARY : mem1.o mem2.o mem3.o rules for making library... # remember to remove .o's when lib is made# equivalent to: '%.o : %.c ; ...' .c.o :; rules for making .o from .c say
a.out : ml.a(a.o) ml.a(b.o); $(CC) -o $@ $< .c.o :; $(CC) -c $(CFLAGS) -o $@ $< %.a:
ar rv $@ $? ranlib $@ rm -rf $?
a.out : ml.a; $(CC) -o $@ $< ml.a .LIBRARY : a.o b.o %.o : %.c ; $(CC) -c $(CFLAGS) -o $@ $< %.a :
ar rv $@ $? ranlib $@ rm -rf $?
KEEP STATE¶
dmake supports the keeping of state information for targets that it makes whenever the macro .KEEP_STATE is assigned a value. The value of the macro should be the name of a state file that will contain the state information. If state keeping is enabled then each target that does not poses the .NOSTATE attribute will have a record written into the state file indicating the target's name, the current directory, the command used to update the target, and which, if any, :: rule is being used. When you make this target again if any of this information does not match the previous settings and the target is not out dated it will still be re-made. The assumption is that one of the conditions above has changed and that we wish to remake the target. For example, state keeping is used in the maintenance of dmake to test compile different versions of the source using different compilers. Changing the compiler causes the compilation flags to be modified and hence all sources to be recompiled. The state file is an ascii file and is portable, however it is not in human readable form as the entries represent hash keys of the above information. The Sun Microsystem's Make constructMULTI PROCESSING¶
If the architecture supports it then dmake is capable of making a target's prerequisites in parallel. dmake will make as much in parallel as it can and use a number of child processes up to the maximum specified by MAXPROCESS or by the value supplied to the -P command line flag. A parallel make is enabled by setting the value of MAXPROCESS (either directly or via -P option) to a value which is > 1. dmake guarantees that all dependencies as specified in the makefile are honored. A target will not be made until all of its prerequisites have been made. Note that when you specify -P 4 then four child processes are run concurrently but dmake actually displays the fifth command it will run immediately upon a child process becomming free. This is an artifact of the method used to traverse the dependency graph and cannot be removed. If a parallel make is being performed then the following restrictions on parallelism are enforced.- 1.
 - Individual recipe lines in a non-group recipe are performed sequentially in the order in which they are specified within the makefile and in parallel with the recipes of other targets.
 
- 2.
 - If a target contains multiple recipe definitions (cf. :: rules) then these are performed sequentially in the order in which the :: rules are specified within the makefile and in parallel with the recipes of other targets.
 
- 3.
 - If a target rule contains the `!' modifier, then the recipe is performed sequentially for the list of outdated prerequisites and in parallel with the recipes of other targets.
 
- 4.
 - If a target has the .SEQUENTIAL attribute set then all of its prerequisites are made sequentially relative to one another (as if MAXPROCESS=1), but in parallel with other targets in the makefile.
 
CONDITIONALS¶
dmake supports a makefile construct called a conditional. It allows the user to conditionally select portions of makefile text for input processing and to discard other portions. This becomes useful for writing makefiles that are intended to function for more than one target host and environment. The conditional expression is specified as follows:.IF expression ... if text ... .ELIF expression ... if text ... .ELSE ... else text ... .END
EXAMPLES¶
# A simple example showing how to use make # prgm : a.o b.o cc a.o b.o -o prgm a.o : a.c g.h cc a.c -o $@ b.o : b.c g.h cc b.c -o $@
prgm : a.o b.o cc -o prgm $< a.o b.o : g.h
SRC = a b
OBJ = {$(SRC)}.o
 
prgm : $(OBJ)
	cc -o $@ $<
 
$(OBJ) : g.h
SRC = a b
OBJ = {$(SRC)}.o
 
prgm : $(OBJ)
	cc $< -o $@
 
$(OBJ) : g.h
%.o : %.c
	$(CC) -c $(CFLAGS) -o $(@:f) $<
	mv $(@:f) objdir
.SOURCE.o : objdir   # tell dmake to look here for .o's
SRC= a b
LIB= lib
LIBm= { $(SRC) }.o
 
prgm: $(LIB)
	cc -o $@ $(LIB)
 
$(LIB) .LIBRARY : $(LIBm)
	ar rv $@ $<
	rm $<
SRC= f:a f:b
LIB= lib
LIBm= "{ $(SRC) }.o"	 # put quotes around each token
 
prgm: $(LIB)
	cc -o $@ $(LIB)
 
$(LIB) .LIBRARY : $(LIBm)
	ar rv $@ $<
	rm $<
COMPATIBILITY¶
There are two notable differences between dmake and the standard version of BSD UNIX 4.2/4.3 Make.- 1.
 - BSD UNIX 4.2/4.3 Make supports wild card filename expansion
      for prerequisite names. Thus if a directory contains a.h, b.h and c.h,
      then a line like
    target: *.hwill cause UNIX make to expand the *.h into "a.h b.h c.h". dmake does not support this type of filename expansion.
 
- 2.
 - Unlike UNIX make, touching a library member causes dmake to search the library for the member name and to update the library time stamp. This is only implemented in the UNIX version. MSDOS and other versions may not have librarians that keep file time stamps, as a result dmake touches the library file itself, and prints a warning.
 
- 1.
 - GNU Make style include, and if/else/endif directives are allowed in non-group recipes. Thus, the word include appearing at the start of a line that is not part of a gruop recipe will be mapped to the ".INCLUDE" directive that damke uses. Similarly, the words ifeq,ifneq,elif,else, and endif are mapped to their corresponding dmake equivalents.
 
- 2.
 - The macro modifier expression $(macro:str=sub) is
      understood and is equivalent to the expression $(macro:s/str/sub), with
      the restriction that str must match the following regular expression:
    str[ |\t][ |\t]*(ie. str only matches at the end of a token where str is a suffix and is terminated by a space, a tab, or end of line) Normally sub is expanded before the substitution is made, if you specify -A on the command line then sub is not expanded.
 
- 3.
 - The macro % is defined to be $@ (ie. $% expands to the same value as $@).
 
- 4.
 - The AUGMAKE notion of libraries is handled correctly.
 
- 5.
 - Directories are always made if you specify -A. This is consistent with other UNIX versions of Make.
 
- 6.
 - Makefiles that utilize virtual targets to force making of
      other targets work as expected if AUGMAKE special target handling is
      enabled. For example:
    
FRC: myprog.o : myprog.c $(FRC) ; ...Works as expected if you issue the command' dmake -A FRC=FRC'but fails with a 'don't know how to make FRC' error message if you do not specify AUGMAKE special target handling via the -A flag (or by setting AUGMAKE:=yes internally). 
LIMITS¶
In some environments the length of an argument string is restricted. (e.g. MSDOS command line arguments cannot be longer than 128 bytes if you are using the standard command.com command interpreter as your shell, dmake text diversions may help in these situations.)PORTABILITY¶
To write makefiles that can be moved from one environment to another requires some forethought. In particular you must define as macros all those things that may be different in the new environment. dmake has two facilities that help to support writing portable makefiles, recursive macros and conditional expressions. The recursive macros, allow one to define environment configurations that allow different environments for similar types of operating systems. For example the same make script can be used for SYSV and BSD but with different macro definitions. To write a makefile that is portable between UNIX and MSDOS requires both features since in almost all cases you will need to define new recipes for making targets. The recipes will probably be quite different since the capabilities of the tools on each machine are different. Different macros will be needed to help handle the smaller differences in the two environments.FILES¶
Makefile, makefile, startup.mk (use dmake -V to tell you where the startup file is)SEE ALSO¶
sh(1), csh(1), touch(1), f77(1), pc(1), cc(1)AUTHOR¶
Dennis Vadura, dvadura@wticorp.comBUGS¶
Some system commands return non-zero status inappropriately. Use -i (`-' within the makefile) to overcome the difficulty. Some systems do not have easily accessible time stamps for library members (MSDOS, AMIGA, etc) for these dmake uses the time stamp of the library instead and prints a warning the first time it does so. This is almost always ok, except when multiple makefiles update a single library file. In these instances it is possible to miss an update if one is not careful. This man page is way too long.WARNINGS¶
Rules supported by make(1) may not work if transitive closure is turned off (-T, .NOINFER). PWD from csh/ksh will cause problems if a cd operation is performed and -e or -E option is used. Using internal macros such as COMMAND, may wreak havoc if you don't understand their functionality.| 2008-02-26 | Dmake Version 4.12 |