Opus Make Quick Reference
Opus Make Quick Reference
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.
Attribute Description
.ALWAYS Always rebuild named target.
.CHAIN Chain inference rules.
.DEPSRC Named targets are dependent sources.
.IGNORE Ignore non-zero return status.
.INFER Force inference rule check.
.LIBRARY Named targets are object libraries.
.MAKE Override "-n", "-q", and "-t" command-line options.
.MISER Use memory miser for named target (MS-DOS only.)
.NOCOMPARE Target(s) named are not timestamp-compared when appearing as a source.
.NODEFAULT Target(s) named are not the default target.
.PHONY Same as .ALWAYS and .NOCOMPARE.
.PRECIOUS Do not delete non-zero return status targets.
.REREAD Reread target timestamp and location from disk.
.RULE Indicates dependency line is an inference rule.
.QUEUE Indicates shell lines may be queued.
.SILENT Do not display executing shell lines.
.VCSTOUCH Set extracted source file timestamp to VCS version timestamp.
Special Targets
Special targets execute shell lines at specific times during the Make process.
Target Usage
.AFTER : [source...] Build sources and execute shell lines after Make has built its last target.
.BEFORE : [source...] Build sources and execute shell lines before Make builds the first target.
.DEFAULT[.ext ] Supplies shell lines which can be used to update targets of extension .ext.
.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.
Directives
"Percent" Directives
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
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 If value is the number zero the expression is 0, else it is 1. Single or double quotes
'value' must be placed around value if it contains spaces or if it is null.
"value"
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.
Cmd-Execution Value
Operator
[ 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 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
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
Opus MKMF
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
Option Action
-b file Names file as the built-ins initialization file (the default is make.ini).
-c C-mode. Interpret C-preprocessor directives.
-d L Generate local dependency information.
-d N No dependency information is generated.
-d S Generate local and system dependency information.
-e Environment macros prevail over the makefile macros.
-f file 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.
-h Display a help screen.
-i Interactive mode.
-l Use makefile.lib as template makefile.
-nologo Inhibit display of Opus MKMF banner.
-oH[+] Dependencies are output hierarchically. Optional "+" outputs source name in dependency list.
-oS[+] Dependencies are output sorted (Default). Optional "+" outputs source name in dependency list.
-pA Generated dependencies have absolute path names.
-pP Generated dependencies are parameterized on the dynamic value of .HDRPATH.
-pR Generated dependencies have relative path names.
-pS Generated dependencies have path names based on the static value of .HDRPATH. (Default)
-r Reject inference rules.
-s Slow mode. Skip file scanning optimization.
-t file Specify file as the template file. Normally MKMF reads and writes the same makefile.
-v Verbose mode. Display the actions of MKMF.
-V Print out the MKMF banner and version, then quit.
-z The MKMF_FLAGS macro is not examined for options.
-# 1,2,4 Debugging options. Same as Make's command-line.
Configuration Macros
Name Value
.CDEFINES.ext Preprocessor symbol definitions for files of extension .ext.
.HDR.ext The regular expression used to find a header file in a source file of extension .ext.
.HDRPATH.ext The directory list used for locating header files for source files of extension .ext.
.TYPE.SRC The list of source file extensions.
.TYPE.OBJ The list of object file extensions.
.TYPE.C The list of C-language file extensions.
.TYPE.RC The list of file extensions for resource compiler scripts.
.TYPE.HDR The list of file extensions for header files.
.TYPE.BIN The list of file extensions for binary files.
MKMF The value is the name with which MKMF was invoked from the command line.
MKMFVERSION The version number of MKMF.
MKMF_FLAGS Additional list of command-line flags.
MKMF_PATHSEP Defines the path separator used when MKMF outputs generated dependencies.
MKMF_SRCS 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.
MKMF_LINELEN The length of generated dependency lines.
MKMF_TABLEN The length of dependency line tab stops.
Macros
• 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.
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.
Name Value
AS assembler: "masm"
CC C compiler: "cl" or "cc"
FC FORTRAN compiler: "f77l"
LIBEXE object librarian program: "lib"
LINK object linker: "link "
MAKE path name to the Make executable.
MAKEFILE first makefile read.
OS the current operating system: "MSDOS", "OS2", "unix", "NT" or "Win95").
OSRELEASE the minor operating system number.
OSVERSION the major operating system number.
PVCSGET program that gets files from PVCS storage: "get "
PVCSGETFLAGS flags to $(PVCSGET): "-q -r "
RC resource compiler program: "rc"
RCSGET program that gets files from RCS storage:"co "
RCSGETFLAGS flags to $(RCSGET): ""
SHELLSUFFIX MS-DOS file extension for batch files: ".bat"
SSGET program that gets files from SourceSafe storage: "ss"
SSGETFLAGS flags to $(SSGET): "get"
STAMPOBJ program that timestamps object files: "stampobj"
TLIBGET program that gets files from TLIB storage: "tlib"
TLIBGETFLAGS 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.
Modifier Action
number Select the "number"th element of the value.
>string Append string to each element.
<string Prepend string to each element.
from=to Substitute all occurrences of from with to.
*F, *D Wild-card match for files or directories.
@ Include file contents or project file list from SourceSafe, Source Integrity or TLIB.
@F[R], @P[R] 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.
A/, A\, A Convert to absolute name using "/", "\" or the default path separator.
B Select the base part of the element.
D Select the directory part of the element.
E Select the extension part of the element.
F Select the file part of the element.
LC Convert the element to lower case.
Mregex Choose elements that match regular expression regex.
M"spec" Choose elements that match file specification spec.
Nregex Choose elements that do not match regular expression regex.
N"spec" Choose elements that do not match file specification spec.
P Select the path part of the element.
R Select the root part of the element.
S/from/to/[g] Substitutes from (a regular expression) to to. If "g" is given, all from matches are substituted.
Otherwise, only the first from match is substituted.
UC Convert the element to upper case.
Wstr Replace whitespace between macro elements with str, where str can contain the following
special sequences:
Sequence Value
\n a newline character
\r a return character
\t a tab character
\\ a literal backslash
\ddd an octal character ddd (1 to 3 digits)
\xdd a hexadecimal character dd (1 or 2 digits)
X Target names are expanded into path names.
Z Select the drive part of the element.
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.
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]
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 Do not delete the response file.
NOKEEP Delete the response file (Default.)
ECHO 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.