joi, 18 oct. 2018, 18:56 Paul Smith <psm...@gnu.org> a scris:

> On Thu, 2018-10-18 at 17:40 +0200, Gisle Vanem wrote:
> >    bin/%.exe: $($(@F)_OBJ) $(LIBS)
> >            $(call link_EXE, $@, $^)
>
> This cannot work because automatic variables like $@, etc. are only
> valid _inside a recipe_.  They are not set and cannot be used in target
> or prerequisite lists: they expand to the empty string.
>
> You have two choices.  You can either separate the prerequisites from
> the recipe, like this:
>
>   bin/%.exe:
>           $(call link_EXE,$@,$^)
>
>   bin/animation.exe: $(animation_OBJ) $(LIBS)
>   bin/barchart.exe: $(barchart_OBJ) $(LIBS)
>

I have a similar issue, but in my case I used explicit pattern rules, vpath
and added compiler generated .d files to make sure the object files are
regenerated on .h modification, but the end result was that the pattern
rules were no longer called after the initial generation.

My tentative explanation is that the .d dependency rules are considered
more specific (but empty) than the pattern rules and/or vpath is at fault,
also.

Is this explanation correct? Will the issue also appear in the solution
above?

Or, you can enable secondary expansion which will allow you to write:
>
>   .SECONDEXPANSION:
>
>   bin/%.exe: $$($$(@F)_OBJ) $(LIBS)
>             $(call link_EXE, $@, $^)
>
> (note the extra "$" in the variable references.  See:
>
> https://www.gnu.org/software/make/manual/make.html#Secondary-Expansion
>

Eddy
_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to