The following is a list of
automatic variables.
$%
$<
$?
$
$+
$*
In a static pattern rule, the stem is part of the file name that matched the % in the target pattern.
In an explicit rule, there is no stem; so $* cannot be deter-mined in that way. Instead, if the target name ends with a recognized suffix (see Old-fashioned suffix rules), $* is set to the target name minus the suffix. For example, if the target name is foo.c, then $* is set to foo, since .c is a suffix. gnu make does this bizarre thing only for compatibility with other implementations of make. You should generally avoid using $* except in implicit rules or static pattern rules.
If the target name in an explicit rule does not end with a recognized suffix, $* is set to the empty string for that rule.
$?
is useful even in explicit rules when you wish to operate on only the dependencies
that have changed. For example, suppose that an archive named lib
is supposed to contain copies of several object files. This rule copies
just the changed object files into the archive:
Of the variables previously listed, four have values that are single file names, and two have values that are lists of file names. These six have variants that get just the files directory name or just the file name within the directory.
The variant variables names are formed by appending D or F, respectively. These variants are semi-obsolete in GNU make since the functions dir and notdir can be used to get a similar effect (see Functions for file names). Note, however, that the F variants all omit the trailing slash which always appears in the output of the dir function.
$(@D)
$(@F)
$(*D)
$(*F)
$(%D)
$(%F)
$(<D)
$(<F)
$(D)
$(F)
$(?D)
$(?F)
We use a special stylistic convention when we discuss these automatic variables; we write the value of $<, rather than the variable, < as we would write for ordinary variables such as objects and CFLAGS. We think this convention looks more natural in this special case. Do not assume it has a deep significance; $< refers to the variable named < just as $(CFLAGS) refers to the variable named CFLAGS. You could just as well use $(<) in place of $<.