f78
Automatic Variables
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 an explicit rule, there is no stem; so
If the target name in an explicit rule does not end with a recognized suffix,
The variant variables names are formed by appending
The following is a list of the variants.
We use a special stylistic convention when we discuss these automatic
variables; we write the value of
The file name of the target of the rule. If the target is an archive member,
then $@ is the name of the archive file. In a pattern rule that has multiple targets
(see Introduction to Pattern Rules), $@ is the name of whichever target caused the rules commands to be run.
The target member name, when the target is an archive member. See Using make to Update Archive Files. For example, if the target is foo.a(bar.o) then $% isbar.o and $@ is foo.a. $% is empty when the target is not an archive member.
The name of the first dependency. If the target got its commands from an
implicit rule, this will be the first dependency added by the implicit rule (see Using Implicit Rules).
The names of all the dependencies that are newer than the target, with spaces
between them. For dependencies which are archive members, only the member named
is used (see Using make to Update Archive Files).
The names of all the dependencies, with spaces between them. For dependencies
which are archive members, only the member named is used (Using make to Update Archive Files). A target has only one dependency on each other file it depends on, no
matter how many times each file is listed as a dependency. So if you list a
dependency more than once for a target, the value of $ contains just one copy of the name.
This is like $, but dependencies listed more than once are duplicated in the order they
were listed in the makefile. This is primarily useful for use in linking commands
where it is meaningful to repeat library file names in a particular order.
The stem with which an implicit rule matches (see How Patterns Match). If the target is dir/a.foo.b and the target pattern is a.%.b then the stem is dir/foo. The stem is useful for constructing names of related files.
ar r lib $?
The directory part of the file name of the target, with the trailing slash
removed. If the value of $@ is dir/foo.o then $(@D) isdir. This value is . if $@ does not contain a slash.
The file-within-directory part of the file name of the target. If the value of
$@ isdir/foo.o then $(@F) isfoo.o. $(@F) is equivalent to $(notdir $@).
$(*F)
The directory part and the file-within-directory part of the stem; dir and foo in this instance.
$(%F)
The directory part and the file-within-directory part of the target archive
member name. This makes sense only for archive member targets of the form archive(member) and is useful only when member may contain a directory name. (See Archive Members as Targets.)
$(<F)
The directory part and the file-within-directory part of the first dependency.
$(F)
Lists of the directory parts and the file-within-directory parts of all
dependencies.
$(?F)
Lists of the directory parts and the file-within-directory parts of all
dependencies that are newer than the target.