[Top][All Lists]

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

Re: Compacting link-rules

From: Eddy Petrișor
Subject: Re: Compacting link-rules
Date: Fri, 19 Oct 2018 09:26:50 +0300

joi, 18 oct. 2018, 18:56 Paul Smith <address@hidden> 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:

          $(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:


  bin/%.exe: $$($$(@F)_OBJ) $(LIBS)
            $(call link_EXE, $@, $^)

(note the extra "$" in the variable references.  See:



reply via email to

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