Target Attributes

Target Attributes
Target Attributes assign certain properties to targets. There are two forms: target [...] [attribute ...] : [sources ...] attribute [...] : [target ...] Both forms assign attributes to the targets on the dependency line. If no targets are listed, the attribute is inherited by all targets subsequently defined. The negation of .ATTRIBUTE is .NOATTRIBUTE.


Always rebuild named target. Chain inference rules. Named targets are dependent sources. Ignore non-zero return status. Force inference rule check. Named targets are object libraries. Override "-n", "-q", and "-t" command-line options. Use memory miser for named target (MS-DOS only.) Target(s) named are not timestamp-compared when appearing as a source. Target(s) named are not the default target. Same as .ALWAYS and .NOCOMPARE. Do not delete non-zero return status targets. Reread target timestamp and location from disk. Indicates dependency line is an inference rule. Indicates shell lines may be queued. Do not display executing shell lines. Set extracted source file timestamp to VCS version timestamp.

Special Targets
Special targets execute shell lines at specific times during the Make process.

.AFTER : [source...] .DEFAULT[.ext ]

Build sources and execute shell lines after Make has built its last target. Supplies shell lines which can be used to update targets of extension .ext.

.BEFORE : [source...] Build sources and execute shell lines before Make builds the first target.

.DEFAULT[.ext] is converted to an equivalent "%[.ext] : " rule. .XXX_GET Where XXX is one of "PVCS", "RCS", "SS", "TLIB". These special targets supply shell lines and attributes for rules that "get" files from the named version control system.

"Percent" Directives
The following directives can be used at read time, run time, or at both times. Conditional Type Action %if condition %ifdef macro %ifndef macro %elif/elseif condition %else %endif read/run read/run read/run read/run read/run read/run Start a conditional block Start a conditional block Start a conditional block Continue the conditional block Start default conditional block End the conditional block

Looping %foreach name [in] list %while condition %end %break %continue

Type read/run run read/run read/run read/run

Action Loop for each name in list Loop while condition is true End the loop Interrupt and quit loop Interrupt and restart loop

Other %abort [status] [msg] %chdir directory %do target [macros] %echo [-n] message %error [status] [msg] %exec command line %getenv envar [macro]

Type read/run read/run run read/run read/run read read/run

Action Display msg then abort with exit status. Change current working directory. Make a subroutine call. macros are set temporarily. Display message. Newline after unless "-n". Display msg then use status as directive status. Execute the command line Define macro from environment variable envar.

%include [<"] file [>"] %restart [ flags ] %set name [+]= value %setenv name [=] value %undef name

read run read/run read/run read/run

Include contents of makefile file. Start make again. Set macro name to value. Set environment variable name to value. 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
The %if, %elif, and %while directives can use all of the following conditional expressions. Simple Expressions Value value 'value' "value" Operators value1 == value2 value1 != value2 value1 < value2 value1 <= value2 value1 > value2 value1 >= value2 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.

Value 1 if value1 is equal to value2, else 0. 1 if value1 is not equal to value2, else 0. 1 if value1 is less than value2, else 0. 1 if value1 is less than or equal to value2, else 0. 1 if value1 is greater than value2, else 0. 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 %defined(name) %dir(name) %empty(name) %exists(name) %file(name) %length(name) %make(name) Value 1 if macro name is defined. 1 if file name is a directory. 1 if file name is empty (zero length). 1 if name is a file or directory. 1 if name is a file. The number of characters in $(name). 1 if name is a command-line target.

%member(name, list) %null(name) %readable(name) %time(name) %writable(name) Cmd-Execution Value Operator [ command ]

1 if name appears as an element of list. 1 if macro name is undefined or if its expansion is null. 1 if file name is readable. The on-disk timestamp of file name. If name doesn't exist this returns 0. 1 if file name is writable.

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 exp1 && exp2 exp1 || exp2 ! exp ( exp )

Value 1 if both exp1 and exp2 are not 0. 1 if either exp1 and exp2 is not 0. 1 if exp is 0. 0 if exp is not 0. 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

Selects automatic dependencies. Names autodependency options. Keywords are: Depsrc, Ignore1Hr, Ignore2Sec, NotEqual, Search, WholeObj. Makes macro names case sensitive. Makes target names case sensitive. Selects debugging options. Make uses line drawing characters when run-time debugging. Prints a makefile summary to screen. Causes display of run-time trace. Long file names are truncated internally to 8.3. Environment variables take precedence over makefile macros.


Keep directory in memory. Keep working in spite of errors. Sets the macro reference character. Make each makefile before reading it. Memory miser is used for programs named in list. Names memory miser method. Keywords are: Disk, Xms. Selects Microsoft NMAKE emulation. Undefines all macros defined from environment variables. Names miscellaneous options. Keywords are: MacroRecursiveDef, MacroQuoted, TargetKeepCase, TargetQuoted, TargetMergeDotSlash, TargetSlashEq. Selects Opus Make v5.2x emulation. Selects Opus Make emulation. Selects PolyMake emulation. Sets the regular expression escape character. Sets the regular expression wild-card character. Rejects inference rules. See response files. Sets inference rule character. Names the shell program and selects it. Selects the order suffix rules are tried. Names version control options. Keyword are: CheckinTime, ErrorIfAbsent, FastRecent, IgnoreIfAbsent, RCSGmt

Command Line
mkmf [option |macro |file |@response ] ...
For option, macro and @response are the same as the Opus Make command line section. File: Each file is a source file or object file. If a source file, the object file is inferred from rules. If an object file, the source file is inferred from rules or dependencies. Each source file is scanned for included files which are added as dependencies to the corresponding object file. Each file may be a wild-card specification or may appear as ^file to exclude file from the list of files. If no command-line files are specified, the value of the SRCS or MKMF_SRCS macro is the list of source files.
Command-Line Options



-b file -c -d L -d N -d S -e -f file -h -i -l -nologo -oH[+] -oS[+] -pA -pP -pR -pS -r -s -t file -v -V -z -# 1,2,4

Names file as the built-ins initialization file (the default is make.ini). C-mode. Interpret C-preprocessor directives. Generate local dependency information. No dependency information is generated. Generate local and system dependency information. Environment macros prevail over the makefile macros. Specify file as the makefile to be updated. When more than one "-f" appears each file is read in order but only the last makefile is updated. Display a help screen. Interactive mode. Use makefile.lib as template makefile. Inhibit display of Opus MKMF banner. Dependencies are output hierarchically. Optional "+" outputs source name in dependency list. Dependencies are output sorted (Default). Optional "+" outputs source name in dependency list. Generated dependencies have absolute path names. Generated dependencies are parameterized on the dynamic value of .HDRPATH. Generated dependencies have relative path names. Generated dependencies have path names based on the static value of .HDRPATH. (Default) Reject inference rules. Slow mode. Skip file scanning optimization. Specify file as the template file. Normally MKMF reads and writes the same makefile. Verbose mode. Display the actions of MKMF. Print out the MKMF banner and version, then quit. The MKMF_FLAGS macro is not examined for options. Debugging options. Same as Make's command-line.

Configuration Macros

Preprocessor symbol definitions for files of extension .ext. The regular expression used to find a header file in a source file of extension .ext. The directory list used for locating header files for source files of extension .ext. The list of source file extensions. The list of object file extensions. The list of C-language file extensions. The list of file extensions for resource compiler scripts. The list of file extensions for header files.


The list of file extensions for binary files. The value is the name with which MKMF was invoked from the command line. The version number of MKMF. Additional list of command-line flags. Defines the path separator used when MKMF outputs generated dependencies. The list of project source files. Used if no source files are given on the command line and if the SRCS macro isn't defined. The length of generated dependency lines. The length of dependency line tab stops.

Automatically Updated Macros
Each time MKMF is run it updates the following makefile macros.


List of included header files outside of the current and all search directories. List of included header files found in the current or any search directories. List of all current object files. List of project object files with extension .ext. List of all project source files. List of project source files with extension .ext.

• • • •

Predefined General Macros: Predefined macros that cannot be redefined. Predefined State Macros: Predefined macros that contain the state of Make's command-line flags and directives. Built-In Macros: Macros that are defined by Make, but can be changed by you. Macro Modifiers: When a macro is expanded, the expanded value can be modified with macro modifiers.

Predefined General Macros
Make predefines several macros. Of those macros the following ones cannot be redefined:


the list of target sources newer than the target. the inferred source or, if none, the first explicit source. the complete list of sources for a target.


the name of the target being made. the root name of the target being made. the VCS version from the .XXX_STORAGE directive. name of the built-ins file used. the directory in which Make started. the first command-line target or the first makefile target. the current makefile being processed. all command-line arguments. same as the macro CWD. all command-line macros. the process id of this Make process. the status with which Make is exiting. all command-line targets. the version of this Make executable. the exit status of the last shell line executed.

Predefined State Macros
The following predefined macros contain the state of Make's command-line flags and directives. The "Flag" column is the equivalent command-line flag for that directive (if any).


-a -A

0 or 1 0 or 1 the list of autodependency options. 0 or 1 0 or 1

-# -p -d

the current debug options 0 or 1 0 or 1 0 or 1 Inverted state of the .NOENVMACROS directive.

-e -i -z

0 or 1 0 or 1 0 or 1 0 or 1


-D -k -M -m -EN -n -E2 -EO -EP -q

0 or 1 0 or 1 0 or 1 the list of .MEMSWAP names 0 or 1 the list of miser modes 0 or 1 0 or 1 list of optional features list of compatibility features 0 or 1 0 or 1 0 or 1 the regex literal backslash the regex escape character the regex literal dot the regex "match any character"


0 or 1 0 or 1 the rule character the shell program and shell flags

-s -t or -T

0 or 1 the list of suffixes 0 (neither flag), 1 (-t), 2 (-T) 0 or 1 The list of version control modes.

Built-In Macros
The following macros are also defined by Make, but can be changed by you. The value in quotes is Make's default value.


assembler: "masm" C compiler: "cl" or "cc"


FORTRAN compiler: "f77l" object librarian program: "lib" object linker: "link " path name to the Make executable. first makefile read. the current operating system: "MSDOS", "OS2", "unix", "NT" or "Win95"). the minor operating system number. the major operating system number. program that gets files from PVCS storage: "get " flags to $(PVCSGET): "-q -r " resource compiler program: "rc" program that gets files from RCS storage:"co " flags to $(RCSGET): "" MS-DOS file extension for batch files: ".bat" program that gets files from SourceSafe storage: "ss" flags to $(SSGET): "get" program that timestamps object files: "stampobj" program that gets files from TLIB storage: "tlib" flags to $(TLIBGET): "EBS"

Macro Modifiers
When a macro is expanded, the expanded value can be modified with macro modifiers. To modify a macro, expand it with: $(name,modifier[,modifier]...) name is macro expanded, then each modifier is applied in succession to the elements of the expanded value.

number >string <string from=to *F, *D @ @F[R], @P[R]

Select the "number"th element of the value. Append string to each element. Prepend string to each element. Substitute all occurrences of from with to. Wild-card match for files or directories. Include file contents or project file list from SourceSafe, Source Integrity or TLIB. For SourceSafe, @F include project files only, @P includes project subprojects only. Optional

"R" recurses through subprojects. @/from/to/[g] File lines matched by regex from are included, with from replaced by to. If "g" is given, all from matches are substituted on the matched lines. Otherwise, only the first from match is substituted. Convert to absolute name using "/", "\" or the default path separator. Select the base part of the element. Select the directory part of the element. Select the extension part of the element. Select the file part of the element. Convert the element to lower case. Choose elements that match regular expression regex. Choose elements that match file specification spec. Choose elements that do not match regular expression regex. Choose elements that do not match file specification spec. Select the path part of the element. Select the root part of the element. Substitutes from (a regular expression) to to. If "g" is given, all from matches are substituted. Otherwise, only the first from match is substituted. Convert the element to upper case. Replace whitespace between macro elements with str, where str can contain the following special sequences: Sequence \n \r \t \\ \ddd \xdd X Z Value a newline character a return character a tab character a literal backslash an octal character ddd (1 to 3 digits) a hexadecimal character dd (1 or 2 digits)

A/, A\, A B D E F LC Mregex M"spec" Nregex N"spec" P R S/from/to/[g] UC Wstr

Target names are expanded into path names. Select the drive part of the element.

Make Command Line
make [target | option | macro | @response] ...
Options are indicated by a "-" or "/" followed by a single letter, which is the option name.

Macros are macro definitions of the form name=[value]. Macros defined on the command line take precedence over macros defined in the makefile. Targets are named targets to be built. If no command-line targets are listed the first target in the first makefile is made. @response directs Make to read response file for additional options, macros, targets and response files. Initial Options: Before parsing the command line Make looks for the OPUSMAKEOPTS environment variable and, if it is found, its value is parsed as an initial command line. Current Options: After reading its initialization file, Make places the command-line options in a macro called MFLAGS. The state of each command-line option is also kept in a State Macro.

Command Line Options
-a -A -b file -d -D -e -E N -E O -E P -E 2 -f file -h -i -k -m -M -n -nologo -p -q -r -s -t

The command-line targets (or default target) are updated whether or not they need updating. Automatic dependencies are enabled. Names file as the built-ins initialization file (the default is make.ini). Run-time debugging of Make operation displays targets being made. Keep-directory mode. The first access of a directory to look for a file results in the directory being read into memory and kept. Environment macros prevail over the makefile definition Emulate NMAKE. Emulate Opus Make (the default). Emulate PolyMake / PVCS Configuration Builder. Emulate Opus Make v5.2x Specify file as the makefile. May be repeated. If file is "-" the console is read. Display the list of command-line options. Ignore errors. The non-zero exit status from any shell lines is ignored. Keep working. Any errors when updating a target cause work on that target only to be stopped. Use the memory miser. (MSDOS only) Make the makefile before reading it. No execute. Display but do not execute the shell lines. Inhibit display of Opus Make banner. Print debugging information to screen. Query mode. Make returns exit status 0 if there is nothing to update. Reject inference rules that are built into Make and that are defined in the initialization file. Silent mode. Shell lines are not displayed before execution. Touch out-of-date targets, setting their timestamp to the current time.

-T -V -x file -z -# 1 -# 2 -# 4 -# 8

Like "-t", but creates target files of zero length if they do not exist yet. Print out the Make banner and version then quit. Redirect error messages into file. If file is "-" the error messages are redirected to the screen. The MFLAGS macro is not examined for options. Debugging option. Read-time debugging mode. Debugging option. Warn about undefined macros. Debugging option. Warn about unrecognized makefile lines. Debugging option. Leave behind generated response and batch files.

Object Libraries
Object library building
The general form for specifying that target is an object library is: target .LIBRARY : [source]... [shell line for updating library]

Object module dependencies
The general form for object modules dependencies is: target : library(module-1 [module-2]...)

Response Files
Inline Response Files
The syntax for an inline response file is: target : command [prolog] << [ response_file ] [ line copied to response file ] ... << [epilog] where << begin and end the response file, response_file names the file, and epilog and prolog are optional text. The most common prolog is "@". The epilog can be used for redirection or other text. There are three special words that can appear in the epilog:

Epilog Meaning
KEEP NOKEEP ECHO Do not delete the response file. Delete the response file (Default.) Show the contents of the response file.

Automatic Responses
Automatic responses are defined with a directive of the form: .RESPONSE.XXX : [ parameter ... ] [ program ... ] Where XXX is the name of a response class, parameter describes the response class, and program is the name of a program that accepts the response class. This directive both defines response classes (see the manual for details) and adds program names to existing classes. For example, to add automatic response file support for Borland's TLINK use the following: .RESPONSE.LINK : TLINK

Inference Rules
Defining Inference Rules
The general form for an inference rule is: Tp%Ts [attribute ...] : Sp%Ss [shell line] ... Where Tp is the target prefix, Ts is the target suffix, Sp is the source prefix and Ss is the source suffix. All prefixes and suffixes are optional. The attribute are target attributes for this rule. These attributes will be given to the target that matches this rule. The shell lines are the commands that update the target.

The Rule-Matching Process
When Make tries to match a target to an inference rule, each Tp%Ts pattern is matched against the target name, with "%" used to match zero or more characters. Every possible rule is tried and scored, with the best-scoring rule the one that uses "%" to match the smallest number of characters. Make then goes through this ranked list of rules, forming Sp%Ss and seeing if this name corresponds to a source file or source target name. If it does, the rule is matched.

Inference Rules and Target Groups
Multiple targets can be updated with a single rule of the form: Tp1%Ts1 + Tp2%Ts2 [ + Tp3%Ts3]... [attribute ...] : Sp%Ss [shell line] ... If a target matches any of TpN%TsN patterns and Sp%Ss is found, Make knows that this rule builds all targets on the left side of the colon.

Shell-Line Prefixes
Shell-line prefixes appear on a shell line before the program name. They appear as single characters or as (prefix). The first non-prefix character ends the prefixes or the"|" prefix explicitly marks the end. Each shell line is macro expanded before prefixes are detected. Char. (Prefix) Value | @ @@ -[num] (Ignore)[num] (Silent) Demark the end of the prefixes. Don't display shell line before execution but display for "make -n" Don't display shell line before execution even for "make -n" Ignore non-zero shell line exit status, printing an "ignored" message. If num is given, only ignore exit status if less than or equal to num. The status macro holds the exit status value. As "-[num]", but don't print "ignored" message. (TrackErrors)[num] As "-[num]", but don't set status macro. As "--[num]", but don't set status macro. (MemSwap) (Always) (NoShell) (Shell) (Iterate) (ExtraLine) Swap Opus Make out of memory before executing shell line. When emulating PM/CB the prefix is ":". Override "-n" command-line flag for this shell line. Reread target's on-disk timestamp after all its shell lines have been executed. Execute shell line, without using shell program. When emulating PM/CB the prefix is "*". Execute shell line using shell program. Iterate this shell line for each element of *? or $**, according to which appears first on the shell line. Echo CR/LF after the shell line is executed.

--[num] ~[num] ~~[num] * & = : + ! >