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 expectations. 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). --- .SECONDEXPANSION: .DEFAULT: ; @: all: foo boo foo: foo.ex foo: $$(basename $$<).ex2 boo: boo.ex $$(basename $$<).ex2 %oo: @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 _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make