Date post: | 12-Nov-2014 |
Category: |
Documents |
Upload: | nomaddarcy |
View: | 143 times |
Download: | 4 times |
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.
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_GETWhere 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
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 ExpressionsThe %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
OperatorValue
[ 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
Name Action
.AUTODEPEND Selects automatic dependencies.
.AUTODEPEND_MODENames 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.
.OPTIONSNames 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_MODENames 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_SRCSThe 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.
Automatically Updated Macros
Each time MKMF is run it updates the following makefile macros.
Name Value
EXTHDRS List of included header files outside of the current and all search directories.
HDRS List of included header files found in the current or any search directories.
OBJS List of all current object files.
OBJS.ext List of project object files with extension .ext.
SRCS List of all project source files.
SRCS.ext List of project source files with extension .ext.
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.
Predefined General Macros Make predefines several macros. Of those macros the following ones cannot be redefined:
Name Value
.NEWSOURCES the list of target sources newer than the target.
.SOURCE the inferred source or, if none, the first explicit source.
.SOURCES the complete list of sources for a target.
.TARGET the name of the target being made.
.TARGETROOT the root name of the target being made.
.VERSION the VCS version from the .XXX_STORAGE directive.
BUILTINS name of the built-ins file used.
CWD the directory in which Make started.
FIRSTTARGET the first command-line target or the first makefile target.
INPUTFILE the current makefile being processed.
MAKEARGS all command-line arguments.
MAKEDIR same as the macro CWD.
MAKEMACROS all command-line macros.
MAKEPID the process id of this Make process.
MAKESTATUS the status with which Make is exiting.
MAKETARGETS all command-line targets.
MAKEVERSION the version of this Make executable.
status 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).
Name Flag Value
.ALWAYS -a 0 or 1
.AUTODEPEND -A 0 or 1
.AUTODEPEND_MODE the list of autodependency options.
.CASE_MACRO 0 or 1
.CASE_TARGET 0 or 1
.DEBUG -# the current debug options
.DEBUG_PRINT -p 0 or 1
.DEBUG_RUN -d 0 or 1
.EIGHT_DOT_THREE 0 or 1
.ENVMACRO Inverted state of the .NOENVMACROS directive.
.ENV_OVERRIDE -e 0 or 1
.GLOBAL_PATH 0 or 1
.IGNORE -i 0 or 1
.IGNORE_MFLAGS -z 0 or 1
.KEEPDIR -D 0 or 1
.KEEPWORKING -k 0 or 1
.MAKE_MAKEFILE -M 0 or 1
.MEMSWAP the list of .MEMSWAP names
.MISER -m 0 or 1
.MISER_MODE the list of miser modes
.MS_NMAKE -EN 0 or 1
.NOEXECUTE -n 0 or 1
.OPTIONS list of optional features
.OPUS_52X -E2 list of compatibility features
.OPUS_MAKE -EO 0 or 1
.POLY_MAKE -EP 0 or 1
.QUERY -q 0 or 1
.REGEX_BACK the regex literal backslash
.REGEX_CHAR the regex escape character
.REGEX_DOT the regex literal dot
.REGEX_WILD the regex "match any character"
.REJECT_RULES -r 0 or 1
.REREAD 0 or 1
.RULE_CHAR the rule character
.SHELL the shell program and shell flags
.SILENT -s 0 or 1
.SUFFIXES the list of suffixes
.TOUCH -t or -T 0 (neither flag), 1 (-t), 2 (-T)
.UNIXPATHS 0 or 1
.VCS_MODE 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.
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.
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
Option Action
-a The command-line targets (or default target) are updated whether or not they need updating.
-A Automatic dependencies are enabled.
-b file Names file as the built-ins initialization file (the default is make.ini).
-d Run-time debugging of Make operation displays targets being made.
-DKeep-directory mode. The first access of a directory to look for a file results in the directory
being read into memory and kept.
-e Environment macros prevail over the makefile definition
-E N Emulate NMAKE.
-E O Emulate Opus Make (the default).
-E P Emulate PolyMake / PVCS Configuration Builder.
-E 2 Emulate Opus Make v5.2x
-f file Specify file as the makefile. May be repeated. If file is "-" the console is read.
-h Display the list of command-line options.
-i Ignore errors. The non-zero exit status from any shell lines is ignored.
-k Keep working. Any errors when updating a target cause work on that target only to be stopped.
-m Use the memory miser. (MSDOS only)
-M Make the makefile before reading it.
-n No execute. Display but do not execute the shell lines.
-nologo Inhibit display of Opus Make banner.
-p Print debugging information to screen.
-q Query mode. Make returns exit status 0 if there is nothing to update.
-r Reject inference rules that are built into Make and that are defined in the initialization file.
-s Silent mode. Shell lines are not displayed before execution.
-t Touch out-of-date targets, setting their timestamp to the current time.
-T Like "-t", but creates target files of zero length if they do not exist yet.
-V Print out the Make banner and version then quit.
-x file Redirect error messages into file. If file is "-" the error messages are redirected to the screen.
-z The MFLAGS macro is not examined for options.
-# 1 Debugging option. Read-time debugging mode.
-# 2 Debugging option. Warn about undefined macros.
-# 4 Debugging option. Warn about unrecognized makefile lines.
-# 8 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 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.
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
| Demark the end of the prefixes.
@ (Silent) Don't display shell line before execution but display for "make -n"
@@ Don't display shell line before execution even for "make -n"
-[num] (Ignore)[num]
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.
--[num] As "-[num]", but don't print "ignored" message.
~[num] (TrackErrors)[num] As "-[num]", but don't set status macro.
~~[num] As "--[num]", but don't set status macro.
* (MemSwap)Swap Opus Make out of memory before executing shell line. When emulating
PM/CB the prefix is ":".
& (Always) Override "-n" command-line flag for this shell line.
= Reread target's on-disk timestamp after all its shell lines have been executed.
: (NoShell)Execute shell line, without using shell program. When emulating PM/CB the
prefix is "*".
+ (Shell) Execute shell line using shell program.
! (Iterate)Iterate this shell line for each element of *? or $**, according to which appears
first on the shell line.
> (ExtraLine) Echo CR/LF after the shell line is executed.