[Top][All Lists]

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

Improve automatic variables during secondary expansion

From: Mike Haboustak
Subject: Improve automatic variables during secondary expansion
Date: Sat, 13 Jul 2019 20:53:39 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

I'm working on a project[1] that would benefit from using $< and $^ during
secondary expansion. Unfortunately, they're not very usable currently.

I have a relatively simple patch that I think improves several issues. It's
a breaking change, but the end behavior seems consistent with user

The underlying issue is that secondary expansion happens once, on the
entire prerequisite string before it is split and then entered. The
dependency list for the current rule is always empty when expansion
occurs, and the values of $< and $^ are correspondingly wrong.

expand > 2nd expand > split_prereqs > enter_prereqs.

The patch adds split_se_prereqs between first and second expansion. The
following expand, split and enter prerequisite functions already support
operating on a dependency list, so don't require any changes.

As an example of how this breaking change matches user expectations,
consider the following makefile. With the current implementation the
value of $$< changes during second expansion if the prereqs are defined
in separate explicit rules. If we split, then expand, the output
will match. $< and $^ contain all prerequisites defined before the
current prerequisite is expanded (in the current rule or prior rules).

.DEFAULT: ; @:

all: foo boo

foo: foo.ex
foo: $$(basename $$<).ex2

boo: boo.ex $$(basename $$<).ex2

        @echo $@ prereqs are $^
foo prereqs are foo.ex foo.ex2
boo prereqs are boo.ex .ex2

Should I just add my patch to the existing bug #28456 (Expansion of $$< is
incorrect)? Or should I create a new bug to track this enhancement,
because it may or may not be acceptable and might need some discussion?

[1] https://lists.gnu.org/archive/html/help-make/2019-02/msg00003.html

reply via email to

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