Let's say I have this GNU makefile:
SOURCE = source1/a source2/b source3/c
BUILD = build/a build/b build/c
BASE = build/
$(BUILD): $(BASE)%: %
install $< $@
So basically I have files in the directories source1, source2 and source3, which I want to regardlessly put into the build directory.
I want to accomplish this with a single static pattern rule. My naïve approach would be this:
$(BUILD): $(BASE)%: $(filter *%, $(SOURCE))
install $< $@
This doesn't work. I know that filters are also denoted with percentage signs.
$(BUILD): $(BASE)%: $(wildcard */$(notdir %))
install $< $@
This doesn't work either. But even if, this would still be non-satisfactory, as I might want to touch
a new file source1/b, which would mess everything up.
How can I use the $(filter)
function in GNU makefile static pattern rules? Or is there another approach to do accomplish this?
The hierarchy now looks like this:
source1/
a
source2/
b
source3/
c
build/
I want it to look like this:
source1/
a
source2/
b
source3/
c
build/
a
b
c
source1/b
andsource2/b
, then what do you want to put intobuild/
? – Betaa
,b
andc
intobuild
. – hgieselb
do you want to put intobuild/
? You say that you might wish to introducesource/b
in addition tosource2/b
, but you don't say what you want Make to do in that case. – Betasource2/b
into build, because it is in the$(SOURCE)
variable. I think this problem can't be appropriately solved in make, so I would do that outside of make. – hgiesel