bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #63125] Automatic variables in Secondary Expansion don't work as do


From: Paul D. Smith
Subject: [bug #63125] Automatic variables in Secondary Expansion don't work as documented
Date: Thu, 29 Sep 2022 13:45:24 -0400 (EDT)

Follow-up Comment #3, bug #63125 (project make):

> Well, it did work that way on Make 3.81.
It did _something_ in GNU make 3.81, but it wasn't the _right_ thing.  I tried
to show this in my previous answer but I was not very clear about it, sorry
about that.

Consider this output, without .SECONDEXPANSION, which you will get for ALL
versions of GNU make:

$ cat Makefile
foo: foo.1
foo: foo.2 ; : '<=$<' '+=$+'

foo.%: ; : $@

$ make
: foo.2
: foo.1
: '<=foo.2' '+=foo.2 foo.2'

Note carefully here that although *foo: foo.1* appears FIRST in the makefile,
the value of $< is actually *foo.2*, not *foo.1*, and foo.2 is built first
followed by foo.1.  That's because *foo.2* is the first prerequisite in the
rule where the recipe appears, and that's how the first prerequisite is always
chosen (see the docs for this).

Now when we add in .SECONDEXPANSION, we can see that actually, GNU make 3.81
gets this wrong:

$ cat Makefile
.SECONDEXPANSION:

foo: foo.1
foo: foo.2 $$< ; : '<=$<' '+=$+'

foo.%: ; : $@

$ make
: foo.2
: foo.1
: '<=foo.2' '+=foo.2 foo.1 foo.1'

Note here that although the value if $< is *foo.2* as it should be, actually
when we expanded *$$<* in the secondary expansion it resolved to *foo.1*,
because at that time it seemed like *foo.1* was the first prerequisite: we had
not yet parsed the current prerequisite list so we didn't replace it with
*foo.2*.

So although GNU make 3.81 did replace $$< with some value, not an empty value,
it was not actually the _right_ value.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63125>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]