makefile - Why GNU Make's secondary expansion does not work with pattern rules for dependencies? -


consider makefile:

%: %.c     @echo making $@     @touch $@  .secondexpansion: %.pid: $$(basename $$@)     $(<d)/$(<f) --pidfile=$<.pid 

here, first rule builds program , second rule starts it, producing pid-file. note: know secondary expansion unnecessary in example; real makefile more complex , need secondary expansion there.

so, typing make foo.pid, expect make build foo foo.c first rule , run ./foo --pidfile=foo.pid second one.

however, not seem work:

$ make -f makefile.test foo.pid make: *** no rule make target 'foo.pid'.  stop. 

this somehow relates secondary-expanded dependencies provided pattern rules. if write either

  • %.pid: % in second rule (i. e. rid of secondary-expansion), or
  • foo: %: %.c in first rule (i. e. write explicit static pattern rule),

it works. why? limitation of gnu make? in case, i'd avoid pre-listing possible programs in first rule.

i think situation described in section 10.5.5 match-anything pattern rules. whay have here non-terminal match-anything rule, not allowed match file name indicates specific type of data.

if had let's say

%:: %.c     @echo making $@     @touch $@ 

it work.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -