Runtime macros
Runtime macros receive values as make is making
targets. They take on different values for each target. These are
the recognized runtime macros:
- $@
- Evaluates to the full name of the target, when building a normal target. When building a library, it expands to the name of the archive library. For example, if the target is mylib(member), $@ expands to mylib.
- $%
- Also evaluates to the full name of the target, when building a normal target. When building a library, it expands to the name of the archive member. In the previous example, $% expands to member.
- $&
- Evaluates to the list of all prerequisites, in all rules that apply to the target.
- $?
- Evaluates to the list of all prerequisites that are newer than the target. In inference rules, however, this macro evaluates to the same value as the $^ macro.
- $>
- Evaluates to the name of the library if the current target is a library member. For example, if the target is mylib(member), $> expands to mylib.
- $^
- Evaluates to the list of prerequisites given in the rule that contains the recipe make is executing.
- $<
- In normal rules, it evaluates the same as $?. In inference rules it evaluates to the single prerequisite that causes the execution of the rule.
- $*
- Is equivalent to $(%:db). This expands to the target name with no suffix.
- $$
- Expands to $.
The following example illustrates the difference between these:
a.o : a.c
a.o : b.h c.h
recipe for making a.oAssume a.c and c.h are newer than a.o, whereas b.h is not. When make executes
the recipe for a.o, the macros expand to the
following values:
$@ → a.o
$* → a
$& → a.c b.h c.h
$? → a.c c.h
$^ → b.h c.h
$< → b.h c.hConsider this example of a library target:
mylib(mem1.o):
recipe…For this target, the internal macros then expand to:
$@ → mylib
$* → mem1
$> → mylib