build - Multiple wildcards in GNU Makefile Pattern -


my filetree looks this:

makefile src/foo/foo.c src/bar/bar.c build/bin/ build/libs/ 

each sub-directory contains other files related source, want structure. since have many foos , more bars, thought of pattern rule:

progs=foo bar  : $(progs)  % :: src/%/%.c     @echo $@ $< 

unfortunately make not recognize valid pattern:

make: *** no rule make target `foo', needed `all'.  stop. 

however, if keep files in src/ directory, single % works expected:

% :: src/%.c     @echo $@ $<  output: foo src/foo bar src/bar 

is there way without giving structure?

use vpath:

progs=foo bar  : $(progs)  % : %.c     @echo $@ $<  vpath %.c src/foo src/bar 

and if want put binaries in build/bin/,

progs = build/bin/foo build/bin/bar  : $(progs)  build/bin/% : %.c     @echo $@ $<  vpath %.c src/foo src/bar 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -