[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #63125] Automatic variables in Secondary Expansion don't work as do
Paul D. Smith
[bug #63125] Automatic variables in Secondary Expansion don't work as documented
Wed, 28 Sep 2022 16:48:35 -0400 (EDT)
Follow-up Comment #1, bug #63125 (project make):
A result of *foo.1* is definitely not right.
The value of *$<* is always set to the first prerequisite in the rule
definition which provides the recipe, if there is one. Only if there isn't a
prerequisite listed in the rule itself will you get the first found
$ cat Makefile
foo: foo.2 ; : $@ $<
foo.%: ; : $@
bar: ; : $@ $<
$ make foo
: foo foo.2
$ make bar
: bar foo.3
We can see that the behavior in GNU make 3.81 was definitely wrong.
Also, recall that $^ shows a set of prerequisites that does NOT include
duplicates. If you want to see the full set of prerequisites including
duplicates, you need to use $+.
However even if you use $+ you'll get a different answer because indeed $$< is
not set here. There seems to be some dissension between the docs and the
code, which we should investigate.
In general it can be tricky to use automatic variables that contain
prerequisites, in the list of prerequisites, because there's a catch-22 there.
Resolving it would require that each prerequisite be parsed and all automatic
variables be updated before any subsequent secondary expansion is done and I'm
not sure that's how it works.
FYI I checked and the behavior you see in 4.3 was the same as in 3.82.
Reply to this item at:
Message sent via Savannah