Secondary Makefile Extension

The gnu 3.8 manual section says:

β€œDuring the secondary extension of explicit rules $$@and $$%respectively evaluate the target file name and, when the target is an archive member, the name of the target member. The variable $$<evaluates the first precondition in the first rule for this purpose. $$^And $$+evaluate the list of all prerequisites of the rules that have already appeared for one and the same goal ( $$+with and $$^without repetition ). The following example will help illustrate this behavior:

.SECONDEXPANSION:
foo: foo.1 bar.1 $$< $$^ $$+ # line #1
foo: foo.2 bar.2 $$< $$^ $$+ # line #2
foo: foo.3 bar.3 $$< $$^ $$+ # line #3

In the first list of prerequisites, all three variables ($$ <, $$ ^ and $$ +) expand to an empty string. "

My question is: Why $$<does it expand to an empty string? The paragraph above says that he must evaluate the first requirement of the first rule for this purpose. Wouldn't that be foo.1?

+4
source share
1 answer

The manual is misleading, possibly due to a typo. The first of two sentences:

The $$ <variable evaluates the first precondition in the first rule for this purpose. $$ ^ and $$ + evaluate a list of all the prerequisites of rules that have already appeared for the same purpose ($$ + with repetitions and $$ ^ without).

must be qualified, like the second, adding the words: "it has already appeared."

You can verify that this correctly describes the behavior by running two makefiles:

Do 1

.SECONDEXPANSION:
foo: foo.1 $$<
    @echo $+

Conclusion:

foo.1

, $$< . :

2

.SECONDEXPANSION:
foo: foo.1
foo: foo.2 $$<
    @echo $+

:

foo.2 foo.1 foo.1

foo.1 foo.2 foo , foo.2 foo.1 . , $$< foo.1 , foo.1 .

+5

Source: https://habr.com/ru/post/1537473/


All Articles