[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compacting link-rules
From: |
Paul Smith |
Subject: |
Re: Compacting link-rules |
Date: |
Thu, 18 Oct 2018 11:56:01 -0400 |
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)
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
Re: Compacting link-rules, Eddy Petrișor, 2018/10/19