MAKE(1S) | illumos Specific Commands | MAKE(1S) |
/usr/xpg4/bin/make [-d] [-dd] [-D] [-DD] [-e] [-i] [-k]
[-n] [-p] [-P] [-q] [-r] [-s] [-S] [-t] [-V]
[-f makefile]... [target]... [macro = value...]
The make utility recursively checks each target against its dependencies, beginning with the first target entry in makefile if no target argument is supplied on the command line. If, after processing all of its dependencies, a target file is found either to be missing, or to be older than any of its dependencies, make rebuilds it. Optionally with this version of make, a target can be treated as out-of-date when the commands used to generate it have changed since the last time the target was built.
To build a given target, make executes the list of commands, called a rule. This rule can be listed explicitly in the target's makefile entry, or it can be supplied implicitly by make.
If no target is specified on the command line, make uses the first target defined in makefile.
If a target has no makefile entry, or if its entry has no rule, make attempts to derive a rule by each of the following methods, in turn, until a suitable rule is found. Each method is described under Usage below.
If there is no makefile entry for a target, if no rule can be derived for building it, and if no file by that name is present, make issues an error message and halts.
Next, make reads in a default makefile that typically contains predefined macro definitions, target entries for implicit rules, and additional rules, such as the rule for retrieving SCCS files. If present, make uses the file make.rules in the current directory; otherwise it reads the file /usr/share/lib/make/make.rules, which contains the standard definitions and rules. Use the directive:
in your local make.rules file to include them.
Next, make imports variables from the environment (unless the -e option is in effect), and treats them as defined macros. Because make uses the most recent definition it encounters, a macro definition in the makefile normally overrides an environment variable of the same name. When -e is in effect, however, environment variables are read in after all makefiles have been read. In that case, the environment variables take precedence over definitions in the makefile.
Next, make reads any makefiles you specify with -f, or one of makefile or Makefile as described above and then the state file, in the local directory if it exists. If the makefile contains a .KEEP_STATE_FILE target, then it reads the state file that follows the target. Refer to special target .KEEP_STATE_FILE for details.
Next (after reading the environment if -e is in effect), make reads in any macro definitions supplied as command line arguments. These override macro definitions in the makefile and the environment both, but only for the make command itself.
make exports environment variables, using the most recently defined value. Macro definitions supplied on the command line are not normally exported, unless the macro is also an environment variable.
make does not export macros defined in the makefile. If an environment variable is set, and a macro with the same name is defined on the command line, make exports its value as defined on the command line. Unless -e is in effect, macro definitions within the makefile take precedence over those imported from the environment.
The macros MAKEFLAGS, MAKE, SHELL, HOST_ARCH, HOST_MACH, and TARGET_MACH are special cases. See Special-Purpose Macros below for details.
The first line contains the name of a target, or a space-separated list of target names, terminated with a colon or double colon. If a list of targets is given, this is equivalent to having a separate entry of the same form for each target. The colon(s) can be followed by a dependency, or a dependency list. make checks this list before building the target. The dependency list can be terminated with a semicolon ( ;), which in turn can be followed by a single Bourne shell command. Subsequent lines in the target entry begin with a TAB and contain Bourne shell commands. These commands comprise the rule for building the target.
Shell commands can be continued across input lines by escaping the NEWLINE with a backslash (\). The continuing line must also start with a TAB.
To rebuild a target, make expands macros, strips off initial TAB characters and either executes the command directly (if it contains no shell metacharacters), or passes each command line to a Bourne shell for execution.
The first non-empty line that does not begin with a TAB or # begins another target or macro definition.
.DEFAULT, .SCCS_GET, and .SUFFIXES
define macros. macro is the name of the macro, and value, which consists of all characters up to a comment character or unescaped NEWLINE, is the value. make strips both leading and trailing white space in accepting the value.
Subsequent references to the macro, of the forms: $(name) or ${name} are replaced by value. The parentheses or brackets can be omitted in a reference to a macro with a single-character name.
Macro references can contain references to other macros, in which case nested references are expanded first.
where string1 is either a suffix, or a word to be replaced in the macro definition, and string2 is the replacement suffix or word. Words in a macro value are separated by SPACE, TAB, and escaped NEWLINE characters.
where op is the existing (old) prefix and os is the existing (old) suffix, np and ns are the new prefix and new suffix, respectively, and the pattern matched by % (a string of zero or more characters), is carried forward from the value being replaced. For example:
sets the value of DEBUG to tmp/fabricate−g.
Notice that pattern replacement macro references cannot be used in the dependency list of a pattern matching rule; the % characters are not evaluated independently. Also, any number of % metacharacters can appear after the equal-sign.
Notice that flags passed by way of MAKEFLAGS are only displayed when the -d, or -dd options are in effect.
The MAKE macro is another special case. It has the value make by default, and temporarily overrides the -n option for any line in which it is referred to. This allows nested invocations of make written as:
to run recursively, with the -n flag in effect for all commands but make. This lets you use make -n to test an entire hierarchy of makefiles.
For compatibility with the 4.2 BSD make, the MFLAGS macro is set from the MAKEFLAGS variable by prepending a -. MFLAGS is not exported automatically.
The SHELL macro, when set to a single-word value such as /usr/bin/csh, indicates the name of an alternate shell to use. The default is /bin/sh. Notice that make executes commands that contain no shell metacharacters itself. Built-in commands, such as dirs in the C shell, are not recognized unless the command line includes a metacharacter (for instance, a semicolon). This macro is neither imported from, nor exported to the environment, regardless of -e. To be sure it is set properly, you must define this macro within every makefile that requires it.
The syntax of the VPATH macro is:
VPATH specifies a list of directories to search for the files, which are targets or dependencies, when make is executed. VPATH is also used in order to search for the include files mentioned in the particular makefile.
When processing a target or a dependency or an include directive, make checks the existence of the file with the same name in the current directory. If the file is found to be missing, make searches for this file in the list of directories presented in VPATH (like the PATH variable in the shell). Unlike the PATH variable, VPATH is used in order to search for the files with relative pathnames. When make attempts to apply implicit rules to the target, it also searches for the dependency files using VPATH.
When the file is found using VPATH, internal macros $@, @<, $?, $*, and their alternative forms (with D or F appended) are set in accordance with the name derived from VPATH. For instance, if the target subdir/foo.o is found in the directory /aaa/bbb using VPATH, then the value of the internal macro $@ for this target is /aaa/bbb/subdir/foo.o.
If a target or a dependency file is found using VPATH, then any occurrences of the word that is the same as the target name in the subsequent rules are replaced with the actual name of the target derived from VPATH.
For example:
If file.c is found in ./subdir, then the command
are executed.
The following macros are provided for use with cross-compilation:
To refer to the $@ dynamic macro within a dependency list, precede the reference with an additional $ character (as in, $$@). Because make assigns $< and $* as it would for implicit rules (according to the suffixes list and the directory contents), they can be unreliable when used within explicit target entries.
These macros can be modified to apply either to the filename part, or the directory part of the strings they stand for, by adding an upper case F or D, respectively (and enclosing the resulting name in parentheses or braces). Thus, $(@D) refers to the directory part of the string $@; if there is no directory part, . is assigned. $(@F) refers to the filename part.
indicates that when processing any of the targets listed and their dependencies, macro is to be set to the value supplied. Notice that if a conditional macro is referred to in a dependency list, the $ must be delayed (use $$ instead). Also, target-list can contain a % pattern, in which case the macro is conditionally defined for all targets encountered that match the pattern. A pattern replacement reference can be used within the value.
You can temporarily append to a macros value with a conditional definition of the form:
Table of Predefined Macros | ||
Use | Macro | Default Value |
Library | AR | ar |
Archives | ARFLAGS | rv |
Assembler | AS | as |
Commands | ASFLAGS | |
COMPILE.s | $(AS) $(ASFLAGS) | |
COMPILE.S | $(CC) $(ASFLAGS) $(CPPFLAGS) -c | |
C | CC | cc |
Compiler | CFLAGS | |
Commands | CPPFLAGS | |
COMPILE.c | $(CC) $(CFLAGS) $(CPPFLAGS) -c | |
LINK.c | $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) | |
C++ | CCC | CC |
Compiler | CCFLAGS | CFLAGS |
Commands | CPPFLAGS | |
COMPILE.cc | $(CCC) $(CCFLAGS) $(CPPFLAGS) -c | |
LINK.cc | $(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) | |
COMPILE.C | $(CCC) $(CCFLAGS) $(CPPFLAGS) -c | |
LINK.C | $(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) | |
FORTRAN 77 | FC | f77 |
Compiler | FFLAGS | |
Commands | COMPILE.f | $(FC) $(FFLAGS) -c |
LINK.f | $(FC) $(FFLAGS) $(LDFLAGS) | |
COMPILE.F | $(FC) $(FFLAGS) $(CPPFLAGS) -c | |
LINK.F | $(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) | |
FORTRAN 90 | FC | f90 |
Compiler | F90FLAGS | |
Commands | COMPILE.f90 | $(F90C) $(F90FLAGS) -c |
LINK.f90 | $(F90C) $(F90FLAGS) $(LDFLAGS) | |
COMPILE.ftn | $(F90C) $(F90FLAGS) $(CPPFLAGS) -c | |
LINK.ftn | $(F90C) $(F90FLAGS) $(CPPFLAGS) $(LDFLAGS) | |
Link Editor | LD | ld |
Command | LDFLAGS | |
lex | LEX | lex |
Command | LFLAGS | |
LEX.l | $(LEX) $(LFLAGS) -t | |
lint | LINT | lint |
Command | LINTFLAGS | |
LINT.c | $(LINT) $(LINTFLAGS) $(CPPFLAGS) | |
Modula 2 | M2C | m2c |
Commands | M2FLAGS | |
MODFLAGS | ||
DEFFLAGS | ||
COMPILE.def | $(M2C) $(M2FLAGS) $(DEFFLAGS) | |
COMPILE.mod | $(M2C) $(M2FLAGS) $(MODFLAGS) | |
Pascal | PC | pc |
Compiler | PFLAGS | |
Commands | COMPILE.p | $(PC) $(PFLAGS) $(CPPFLAGS) -c |
LINK.p | $(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) | |
Ratfor | RFLAGS | |
Compilation | COMPILE.r | $(FC) $(FFLAGS) $(RFLAGS) -c |
Commands | LINK.r | $(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) |
rm Command | RM | rm -f |
sccs | SCCSFLAGS | |
Command | SCCSGETFLAGS | -s |
yacc | YACC | yacc |
Command | YFLAGS | |
YACC.y | $(YACC) $(YFLAGS) | |
Suffixes List | SUFFIXES | .o .c .c~ .cc .cc~ .y .y~ .l .l~ .s .s~ .sh .sh~ .S .S~ .ln .h .h~ .f .f~ .F .F~ .mod .mod~ .sym .def .def~ .p .p~ .r .r~ .cps .cps~ .C .C~ .Y .Y~ .L .L .f90 .f90~ .ftn .ftn~ |
is a pattern matching rule, in which tp is a target prefix, ts is a target suffix, dp is a dependency prefix, and ds is a dependency suffix (any of which can be null). The % stands for a basename of zero or more characters that is matched in the target, and is used to construct the name of a dependency. When make encounters a match in its search for an implicit rule, it uses the rule in that target entry to build the target from the dependency file. Pattern-matching implicit rules typically make use of the $@ and $< dynamic macros as placeholders for the target and dependency names. Other, regular dependencies can occur in the dependency list; however, none of the regular dependencies can contain %. An entry of the form:
is a valid pattern matching rule.
The target entry for a suffix rule takes the form:
where Ts is the suffix of the target, Ds is the suffix of the dependency file, and rule is the rule for building a target in the class. Both Ds and Ts must appear in the suffixes list. (A suffix need not begin with a . to be recognized.)
A suffix rule with only one suffix describes how to build a target having a null (or no) suffix from a dependency file with the indicated suffix. For instance, the .c rule could be used to build an executable program named file from a C source file named file.c. If a target with a null suffix has an explicit dependency, make omits the search for a suffix rule.
Table of Standard Implicit (Suffix) Rules for Assembly Files | |
Implicit Rule Name | Command Line |
.s.o | $(COMPILE.s) -o $@ $< |
.s.a | $(COMPILE.s) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.s~.o | $(GET) $(GFLAGS) -p $< > $*.s |
$(COMPILE.s) -o $@ $*.s | |
.S.o | $(COMPILE.S) -o $@ $< |
.S.a | $(COMPILE.S) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.S~.o | $(GET) $(GFLAGS) -p $< > $*.S |
$(COMPILE.S) -o $@ $*.S | |
.S~.a | $(GET) $(GFLAGS) -p $< > $*.S |
$(COMPILE.S) -o $% $*.S | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% |
Table of Standard Implicit (Suffix) Rules for C Files | |
Implicit Rule Name | Command Line |
.c | $(LINK.c) -o $@ $< $(LDLIBS) |
.c.ln | $(LINT.c) $(OUTPUT_OPTION) -i $< |
.c.o | $(COMPILE.c) $(OUTPUT_OPTION) $< |
.c.a | $(COMPILE.c) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.c~ | $(GET) $(GFLAGS) -p $< > $*.c |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $*.c | |
.c~.o | $(GET) $(GFLAGS) -p $< > $*.c |
$(CC) $(CFLAGS) -c $*.c | |
.c~.ln | $(GET) $(GFLAGS) -p $< > $*.c |
$(LINT.c) $(OUTPUT_OPTION) -c $*.c | |
.c~.a | $(GET) $(GFLAGS) -p $< > $*.c |
$(COMPILE.c) -o $% $*.c | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% |
Table of Standard Implicit (Suffix) Rules for C++ Files | |
Implicit Rule Name | Command Line |
.cc | $(LINK.cc) -o $@ $< $(LDLIBS) |
.cc.o | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
.cc.a | $(COMPILE.cc) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.cc~ | $(GET) $(GFLAGS) -p $< > $*.cc |
$(LINK.cc) -o $@ $*.cc $(LDLIBS) | |
.cc.o | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
.cc~.o | $(GET) $(GFLAGS) -p $< > $*.cc |
$(COMPILE.cc) $(OUTPUT_OPTION) $*.cc | |
.cc.a | $(COMPILE.cc) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.cc~.a | $(GET) $(GFLAGS) -p $< > $*.cc |
$(COMPILE.cc) -o $% $*.cc | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.C | $(LINK.C) -o $@ $< $(LDLIBS) |
.C~ | $(GET) $(GFLAGS) -p $< > $*.C |
$(LINK.C) -o $@ $*.C $(LDLIBS) | |
.C.o | $(COMPILE.C) $(OUTPUT_OPTION) $< |
.C~.o | $(GET) $(GFLAGS) -p $< > $*.C |
$(COMPILE.C) $(OUTPUT_OPTION) $*.C | |
.C.a | $(COMPILE.C) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.C~.a | $(GET) $(GFLAGS) -p $< > $*.C |
$(COMPILE.C) -o $% $*.C | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% |
Table of Standard Implicit (Suffix) Rules for FORTRAN 77 Files | |
Implicit Rule Name | Command Line |
.f | $(LINK.f) -o $@ $< $(LDLIBS) |
.f.o | $(COMPILE.f) $(OUTPUT_OPTION) $< |
.f.a | $(COMPILE.f) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.f | $(LINK.f) -o $@ $< $(LDLIBS) |
.f~ | $(GET) $(GFLAGS) -p $< > $*.f |
$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.f | |
.f~.o | $(GET) $(GFLAGS) -p $< > $*.f |
$(FC) $(FFLAGS) -c $*.f | |
.f~.a | $(GET) $(GFLAGS) -p $< > $*.f |
$(COMPILE.f) -o $% $*.f | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.F | $(LINK.F) -o $@ $< $(LDLIBS) |
.F.o | $(COMPILE.F) $(OUTPUT_OPTION) $< |
.F.a | $(COMPILE.F) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.F~ | $(GET) $(GFLAGS) -p $< > $*.F |
$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.F | |
.F~.o | $(GET) $(GFLAGS) -p $< > $*.F |
$(FC) $(FFLAGS) -c $*.F | |
.F~.a | $(GET) $(GFLAGS) -p $< > $*.F |
$(COMPILE.F) -o $% $*.F | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% |
Table of Standard Implicit (Suffix) Rules for FORTRAN 90 Files | |
Implicit Rule Name | Command Line |
.f90 | $(LINK.f90) -o $@ $< $(LDLIBS) |
.f90~ | $(GET) $(GFLAGS) -p $< > $*.f90 |
$(LINK.f90) -o $@ $*.f90 $(LDLIBS) | |
.f90.o | $(COMPILE.f90) $(OUTPUT_OPTION) $< |
.f90~.o | $(GET) $(GFLAGS) -p $< > $*.f90 |
$(COMPILE.f90) $(OUTPUT_OPTION) $*.f90 | |
.f90.a | $(COMPILE.f90) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.f90~.a | $(GET) $(GFLAGS) -p $< > $*.f90 |
$(COMPILE.f90) -o $% $*.f90 | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.ftn | $(LINK.ftn) -o $@ $< $(LDLIBS) |
.ftn~ | $(GET) $(GFLAGS) -p $< > $*.ftn |
$(LINK.ftn) -o $@ $*.ftn $(LDLIBS) | |
.ftn.o | $(COMPILE.ftn) $(OUTPUT_OPTION) $< |
.ftn~.o | $(GET) $(GFLAGS) -p $< > $*.ftn |
$(COMPILE.ftn) $(OUTPUT_OPTION) $*.ftn | |
.ftn.a | $(COMPILE.ftn) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.ftn~.a | $(GET) $(GFLAGS) -p $< > $*.ftn |
$(COMPILE.ftn) -o $% $*.ftn | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% |
Table of Standard Implicit (Suffix) Rules for lex Files | |
Implicit Rule Name | Command Line |
.l | $(RM) $*.c |
$(LEX.l) $< > $*.c | |
$(LINK.c) -o $@ $*.c $(LDLIBS) | |
$(RM) $*.c | |
.l.c | $(RM) $@ |
$(LEX.l) $< > $@ | |
.l.ln | $(RM) $*.c |
$(LEX.l) $< > $*.c | |
$(LINT.c) -o $@ -i $*.c | |
$(RM) $*.c | |
.l.o | $(RM) $*.c |
$(LEX.l) $< > $*.c | |
$(COMPILE.c) -o $@ $*.c | |
$(RM) $*.c | |
.l~ | $(GET) $(GFLAGS) -p $< > $*.l |
$(LEX) $(LFLAGS) $*.l | |
$(CC) $(CFLAGS) -c lex.yy.c | |
rm -f lex.yy.c | |
mv lex.yy.c $@ | |
.l~.c | $(GET) $(GFLAGS) -p $< > $*.l |
$(LEX) $(LFLAGS) $*.l | |
mv lex.yy.c $@ | |
.l~.ln | $(GET) $(GFLAGS) -p $< > $*.l |
$(RM) $*.c | |
$(LEX.l) $*.l > $*.c | |
$(LINT.c) -o $@ -i $*.c | |
$(RM) $*.c | |
.l~.o | $(GET) $(GFLAGS) -p $< > $*.l |
$(LEX) $(LFLAGS) $*.l | |
$(CC) $(CFLAGS) -c lex.yy.c | |
rm -f lex.yy.c | |
mv lex.yy.c $@ |
Table of Standard Implicit (Suffix) Rules for Modula 2 Files | |
Implicit Rule Name | Command Line |
.mod | $(COMPILE.mod) -o $@ -e $@ $< |
.mod.o | $(COMPILE.mod) -o $@ $< |
.def.sym | $(COMPILE.def) -o $@ $< |
.def~.sym | $(GET) $(GFLAGS) -p $< > $*.def |
$(COMPILE.def) -o$@ $*.def | |
.mod~ | $(GET) $(GFLAGS) -p $< > $*.mod |
$(COMPILE.mod) -o $@ -e $@ $*.mod | |
.mod~.o | $(GET) $(GFLAGS) -p $< > $*.mod |
$(COMPILE.mod) -o $@ $*.mod | |
.mod~.a | $(GET) $(GFLAGS) -p $< > $*.mod |
$(COMPILE.mod) -o $% $*.mod | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% |
Table of Standard Implicit (Suffix) Rules for NeWS Files | |
Implicit Rule Name | Command Line |
.cps.h | cps $*.cps |
.cps~.h | $(GET) $(GFLAGS) -p $< > $*.cps |
$(CPS) $(CPSFLAGS) $*.cps |
Table of Standard Implicit (Suffix) Rules for Pascal Files | |
Implicit Rule Name | Command Line |
.p | $(LINK.p) -o $@ $< $(LDLIBS) |
.p.o | $(COMPILE.p) $(OUTPUT_OPTION) $< |
.p~ | $(GET) $(GFLAGS) -p $< > $*.p |
$(LINK.p) -o $@ $*.p $(LDLIBS) | |
.p~.o | $(GET) $(GFLAGS) -p $< > $*.p |
$(COMPILE.p) $(OUTPUT_OPTION) $*.p | |
.p~.a | $(GET) $(GFLAGS) -p $< > $*.p |
$(COMPILE.p) -o $% $*.p | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% |
Table of Standard Implicit (Suffix) Rules for Ratfor Files | |
Implicit Rule Name | Command Line |
.r | $(LINK.r) -o $@ $< $(LDLIBS) |
.r.o | $(COMPILE.r) $(OUTPUT_OPTION) $< |
.r.a | $(COMPILE.r) -o $% $< |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% | |
.r~ | $(GET) $(GFLAGS) -p $< > $*.r |
$(LINK.r) -o $@ $*.r $(LDLIBS) | |
.r~.o | $(GET) $(GFLAGS) -p $< > $*.r |
$(COMPILE.r) $(OUTPUT_OPTION) $*.r | |
.r~.a | $(GET) $(GFLAGS) -p $< > $*.r |
$(COMPILE.r) -o $% $*.r | |
$(AR) $(ARFLAGS) $@ $% | |
$(RM) $% |
Table of Standard Implicit (Suffix) Rules for SCCS Files | |
Implicit Rule Name | Command Line |
.SCCS_GET | sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@ -G$@ |
.SCCS_GET_POSIX | sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@ |
.GET_POSIX | $(GET) $(GFLAGS) s.$@ |
Table of Standard Implicit (Suffix) Rules for Shell Scripts | |
Implicit Rule Name | Command Line |
.sh | cat $< >$@ |
chmod +x $@ | |
.sh~ | $(GET) $(GFLAGS) -p $< > $*.sh |
cp $*.sh $@ | |
chmod a+x $@ |
Table of Standard Implicit (Suffix) Rules for yacc Files | |
Implicit Rule Name | Command Line |
.y | $(YACC.y) $< |
$(LINK.c) -o $@ y.tab.c $(LDLIBS) | |
$(RM) y.tab.c | |
.y.c | $(YACC.y) $< |
mv y.tab.c $@ | |
.y.ln | $(YACC.y) $< |
$(LINT.c) -o $@ -i y.tab.c | |
$(RM) y.tab.c | |
.y.o | $(YACC.y) $< |
$(COMPILE.c) -o $@ y.tab.c | |
$(RM) y.tab.c | |
.y~ | $(GET) $(GFLAGS) -p $< > $*.y |
$(YACC) $(YFLAGS) $*.y | |
$(COMPILE.c) -o $@ y.tab.c | |
$(RM) y.tab.c | |
.y~.c | $(GET) $(GFLAGS) -p $< > $*.y |
$(YACC) $(YFLAGS) $*.y | |
mv y.tab.c $@ | |
.y~.ln | $(GET) $(GFLAGS) -p $< > $*.y |
$(YACC.y) $*.y | |
$(LINT.c) -o $@ -i y.tab.c | |
$(RM) y.tab.c | |
.y~.o | $(GET) $(GFLAGS) -p $< > $*.y |
$(YACC) $(YFLAGS) $*.y | |
$(CC) $(CFLAGS) -c y.tab.c | |
rm -f y.tab.c | |
mv y.tab.o $@ |
make reads in the standard set of implicit rules from the file /usr/share/lib/make/make.rules, unless -r is in effect, or there is a make.rules file in the local directory that does not include that file.
A tilde (~) indicates that if a dependency file with the indicated suffix (minus the ~) is under SCCS its most recent version should be retrieved, if necessary, before the target is processed.
refers to a member, or a space-separated list of members, in an ar(1) library.
The dependency of the library member on the corresponding file must be given as an explicit entry in the makefile. This can be handled by a pattern matching rule of the form:
where .s is the suffix of the member; this suffix is typically .o for object libraries.
A target name of the form:
refers to the member of a randomized object library that defines the entry point named symbol.
make invokes the shell with the -e (exit-on-errors) argument. Thus, with semicolon-separated command sequences, execution of the later commands depends on the success of the former. This behavior can be overridden by starting the command line with a -, or by writing a shell script that returns a non-zero status only as it finds appropriate.
Although composed of several input lines, the escaped NEWLINE characters insure that make treats them all as one (shell) command line.
To use the Bourne shell for control structure for loops, use a command line of the form:
To refer to a shell variable, use a double-dollar-sign ($$). This prevents expansion of the dollar-sign by make.
The command is executed only once, standard error output is discarded, and NEWLINE characters are replaced with SPACEs. If the command has a non-zero exit status, make halts with an error.
To capture the output of a shell command in a macro reference, use a reference of the form:
where MACRO is the name of a macro containing a valid Bourne shell command line. In this case, the command is executed whenever the reference is evaluated. As with shell command substitutions, the reference is replaced with the standard output of the command. If the command has a non-zero exit status, make halts with an error.
In contrast to commands in rules, the command is not subject for macro substitution; therefore, a dollar sign ( $) need not be replaced with a double dollar sign ( $$).
This makefile says that pgm depends on two files a.o and b.o, and that they in turn depend on their corresponding source files ( a.c and b.c) along with a common file incl.h:
Example 2 Using implicit rules
The following makefile uses implicit rules to express the same dependencies:
When the -q option is not specified, the make utility exits with one of the following values:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Committed |
Standard | See standards(5). |
Solaris Advanced User's Guide
Filenames with the characters =, :, or @, do not work.
You cannot build file.o from lib(file.o).
Options supplied by MAKEFLAGS should be reported for nested make commands. Use the -d option to find out what options the nested command picks up from MAKEFLAGS.
This version of make is incompatible in certain respects with previous versions:
There is no guarantee that makefiles created for this version of make work with earlier versions.
If there is no make.rules file in the current directory, and the file /usr/share/lib/make/make.rules is missing, make stops before processing any targets. To force make to run anyway, create an empty make.rules file in the current directory.
Once a dependency is made, make assumes the dependency file is present for the remainder of the run. If a rule subsequently removes that file and future targets depend on its existence, unexpected errors can result.
When hidden dependency checking is in effect, the $? macro's value includes the names of hidden dependencies. This can lead to improper filename arguments to commands when $? is used in a rule.
Pattern replacement macro references cannot be used in the dependency list of a pattern matching rule.
Unlike previous versions, this version of make strips a leading ./ from the value of the $@ dynamic macro.
With automatic SCCS retrieval, this version of make does not support tilde suffix rules.
The only dynamic macro whose value is strictly determined when used in a dependency list is $@ (takes the form $$@).
make invokes the shell with the -e argument. This cannot be inferred from the syntax of the rule alone.
April 23, 2008 |