MAKE Directives
Go Up to MAKE.EXE
MAKE directives resemble directives in languages such as C and Pascal. In MAKE, directives perform various control functions, such as displaying commands onscreen before executing them. MAKE directives begin either with an exclamation point or a period, and they override any options given on the command line. Directives that begin with an exclamation point must appear at the start of a new line.
Contents
MAKE Directives and Their Command-Line Options
The following table lists the MAKE directives and their corresponding command-line options:
Directive | Option (if available) | Description/Example |
---|---|---|
|
|
Turns on autodependency checking.
Autodependencies are the files that are automatically included in the targets you build, such as the header files included in your C++ source code. With |
|
|
Turns on autodependency caching. |
|
Uses | |
|
Acts like a C else if. | |
|
Acts like a C else. | |
|
Ends an | |
|
Stops MAKE and prints an error message. The syntax of the !error directive is:
MAKE stops processing and prints the following string when it encounters this directive: Embed !if !$d(MYMACRO) #if MYMACRO isn't defined !error MYMACRO isn't defined ! endif If
Error-Checking Controls MAKE offers four different error-checking controls:
| |
|
Begins a conditional statement. | |
|
Acts like a C | |
|
Acts like a C | |
|
|
MAKE ignores the return value of a command. |
|
This directive is like the
You can enclose the file name in quotation marks However, writing duplicate Rules, commands, or directives must be complete within a single source file; you cannot start a command in an | |
|
|
Keeps temporary files that MAKE creates (MAKE usually deletes them.) |
|
Prints a message to stdout while MAKE runs the makefile. The !message The macro is defined here as: $(MacroName) When MAKE interprets this line, it will print onscreen (assuming the macro expands to .CPP):
| |
|
|
Turns off autodependency checking. |
|
|
Turns off autodependency caching. |
|
|
Turns off .Ignore. |
|
|
Does not keep temporary files that MAKE creates. |
|
|
Displays commands before MAKE executes them. |
|
|
Tells MAKE not to swap iteself out of memory before executing a command. |
|
Tells MAKE to search for files with the extension To tell MAKE to look for files with the
| |
|
Saves the targets even if the build fails. If a MAKE build fails, MAKE deletes the target file. The
| |
|
|
MAKE executes commands without printing them first. |
|
Determines the implicit rule for ambiguous dependencies.
The
where For example, you could include the line
The following .suffixes: .asm .c .cpp myprog.exe: myprog.obj bcc32 myprog.obj .cpp.obj: bcc32 -P -c $< .asm.obj: tasm /mx $ .c.obj: bcc32 -P- -c $< | |
|
|
Tells MAKE to swap itself out of memory before executing a command. |
|
Clears the definition of a macro. After this, the macro is undefined.
The The syntax of the |
Using Macros in Directives
You can use the $d macro with the !if conditional directive to perform some processing if a specific macro is defined. Follow $d with a macro name enclosed in parentheses or braces, as shown in the following example:
!if $d(DEBUG) #If DEBUG is defined, bcc32 -v f1.cpp f2.cpp #compile with debug information; !else #otherwise bcc32 -v- f1.cpp f2.cpp #don't include debug information. !endif
Null Macros
While an undefined macro name causes an
!ifdef MacroName
test to return false
, MacroName
defined as null will return true
. You define a null macro by following the equal sign =
in the macro definition with either spaces or a return character. For example, the following line defines a null macro in a makefile:
NULLMACRO =
Either of the following lines can define a null macro on the MAKE command line:
NULLMACRO ="" -DNULLMACRO
!if and Other Conditional Directives
The !if
directive works like C if
statements. As shown here, the syntax of !if
and the other conditional directives resembles compiler conditionals:
|
|
|
|
|
|
|
|
|
|
The following expressions are equivalent:
!ifdef macro /* is equivalent to */ !if $d(macro) ifndef macro /* is equivalent to */ !if !$d(macro)
These rules apply to conditional directives:
- One
!else
directive is allowed between!if
,!ifdef
, or!ifndef
and!endif
. - Multiple
!elif
directives are allowed between!if
,!ifdef
, or!ifndef
,!else
and!endif
. - You cannot split rules across conditional directives.
- You can nest conditional directives.
!if
,!ifdef
, and!ifndef
must have matching!endif
directives within the same file.
The following information can be included between the !if
and !endif
directives:
- Macro definition
- Explicit rule
- Implicit rule
- Include directive
- !error directive
- !undef directive
In an if
statement, a conditional expression consists of decimal, octal, or hexadecimal constants and the operators shown in the following table:
Operator | Description | Operator | Description |
---|---|---|---|
|
Negation |
|
Conditional expression |
|
Bit complement |
|
Logical NOT |
|
Addition |
|
Right shift |
|
Subtraction |
|
Left shift |
|
Multiplication |
|
Bitwise AND |
|
Division |
|
Bitwise OR |
|
Remainder |
|
Bitwise XOR |
|
Logical AND |
|
Greater than or equal to * |
|
Logical OR |
|
Less than or equal to * |
|
Greater than |
|
Equality * |
|
Less than |
|
Inequality * |
The operators marked with the * sign also work with string expressions.
MAKE evaluates a conditional expression as either a 32-bit signed integer or a character string.