Directives

 "Percent" Directives    Conditional Expressions    Dot Directives

 

"Percent" Directives [Top]

The following directives can be used at read time, run time, or at both times.

Conditional Type Action
%if condition read/run Start a conditional block
%ifdef macro read/run Start a conditional block
%ifndef macro read/run Start a conditional block
%elif/elseif condition read/run Continue the conditional block
%else read/run Start default conditional block
%endif read/run End the conditional block

 

Looping Type Action
%foreach name [in] list read/run Loop for each name in list
%while condition run Loop while condition is true
%end read/run End the loop
%break read/run Interrupt and quit loop
%continue read/run Interrupt and restart loop

 

Other Type Action
%abort [status] [msg] read/run Display msg then abort with exit status.
%chdir directory read/run Change current working directory.
%do target [macros] run Make a subroutine call. macros are set temporarily.
%echo [-n] message read/run Display message. Newline after unless "-n".
%error [status] [msg] read/run Display msg then use status as directive status.
%exec command line read Execute the command line
%getenv envar [macro] read/run Define macro from environment variable envar.
%include [<"] file [>"] read Include contents of makefile file.
%restart [ flags ] run Start make again.
%set name [+]= value read/run Set macro name to value.
%setenv name [=] value read/run Set environment variable name to value.
%undef name read/run Undefine a macro.

Either % or ! may be used as the directive character. Placing the directive character in the first column of the makefile makes that directive read-time. Otherwise the directive is run-time. Whitespace is allowed between the directive character and the directive name.

 

Conditional Expressions [Top]

The %if, %elif, and %while directives can use all of the following conditional expressions.

Simple Expressions Value
value
'value'
"value"
If value is the number zero the expression is 0, else it is 1. Single or double quotes must be placed around value if it contains spaces or if it is null.

 

Operators Value
value1 == value2 1 if value1 is equal to value2, else 0.
value1 != value2 1 if value1 is not equal to value2, else 0.
value1 < value2 1 if value1 is less than value2, else 0.
value1 <= value2 1 if value1 is less than or equal to value2, else 0.
value1 > value2 1 if value1 is greater than value2, else 0.
value1 >= value2 1 if value1 is greater than or equal to value2, else 0.

If both values are numbers, the comparison is numerical, else alphabetical. If either value contains spaces or is null, it must be enclosed in single or double quotes. The case sensitivity of the string comparison is the same as for target names and is set with the .CASE_TARGET and .NOCASE_TARGET directives.

 

Built-in Functions Value
%defined(name) 1 if macro name is defined.
%dir(name) 1 if file name is a directory.
%empty(name) 1 if file name is empty (zero length).
%exists(name) 1 if name is a file or directory.
%file(name) 1 if name is a file.
%length(name) The number of characters in $(name).
%make(name) 1 if name is a command-line target.
%member(name, list) 1 if name appears as an element of list.
%null(name) 1 if macro name is undefined or if its expansion is null.
%readable(name) 1 if file name is readable.
%time(name) The on-disk timestamp of file name. If name doesn't exist this returns 0.
%writable(name) 1 if file name is writable.

 

Cmd-Execution
Operator
Value
command ] The exit status of the command, conventionally "0" if it succeeds.

Notes:

  • MS-DOS internal commands return "0" whether they succeed or fail!
  • The brackets are literal.

 

Logical Operators Value
exp1 && exp2 1 if both exp1 and exp2 are not 0.
exp1 || exp2 1 if either exp1 and exp2 is not 0.
! exp 1 if exp is 0. 0 if exp is not 0.
( exp ) The same state as exp.

Logical operators combine other expressions. Each expression is evaluated from left to right but parentheses can order the evaluation. Unlike the C programming language the logical expressions do not "short-circuit". That is, both exp1 and exp2 are evaluated.

 

Dot Directives [Top]

Name Action
.AUTODEPEND Selects automatic dependencies.
.AUTODEPEND_MODE Names autodependency options. Keywords are: Depsrc, Ignore1Hr, Ignore2Sec, NotEqual, Search, WholeObj.
.CASE_MACRO Makes macro names case sensitive.
.CASE_TARGET Makes target names case sensitive.
.DEBUG Selects debugging options.
.DEBUG_GRAPHICS Make uses line drawing characters when run-time debugging.
.DEBUG_PRINT Prints a makefile summary to screen.
.DEBUG_RUN Causes display of run-time trace.
.EIGHT_DOT_THREE Long file names are truncated internally to 8.3.
.ENV_OVERRIDE Environment variables take precedence over makefile macros.
.KEEPDIR Keep directory in memory.
.KEEPWORKING Keep working in spite of errors.
.MACRO_CHAR Sets the macro reference character.
.MAKE_MAKEFILE Make each makefile before reading it.
.MEMSWAP [list] Memory miser is used for programs named in list.
.MISER_MODE Names memory miser method. Keywords are: Disk, Xms.
.MS_NMAKE Selects Microsoft NMAKE emulation.
.NOENVMACROS Undefines all macros defined from environment variables.
.OPTIONS Names miscellaneous options. Keywords are: MacroRecursiveDef, MacroQuoted, TargetKeepCase, TargetQuoted, TargetMergeDotSlash, TargetSlashEq.
.OPUS_52X Selects Opus Make v5.2x emulation.
.OPUS_MAKE Selects Opus Make emulation.
.POLY_MAKE Selects PolyMake emulation.
.REGEX_CHAR Sets the regular expression escape character.
.REGEX_WILD Sets the regular expression wild-card character.
.REJECT_RULES Rejects inference rules.
.RESPONSE.XXX See response files.
.RULE_CHAR Sets inference rule character.
.SHELL Names the shell program and selects it.
.SUFFIXES Selects the order suffix rules are tried.
.VCS_MODE Names version control options. Keyword are: CheckinTime, ErrorIfAbsent, FastRecent, IgnoreIfAbsent, RCSGmt