I'm trying to figure out a Makefile problem I've got. I start with a lot of files in a telemetry/
directory, and for each one I need to create a corresponding file in a features/
directory.
The list of filenames in the telemetry/
directory is cached in a filelist
file, and I define an allfeats
target to encompass all the file-level targets. Except the allfeats
target doesn't actually work.
My Makefile (heavily trimmed to just show this issue) looks like this:
MYSAMP:=$(shell cat filelist)
allfeats: $(patsubst %,features/%-feat.rds,$(MYSAMP))
@echo done
features/%-feat.rds: telemetry/%
Rscript -e 'saveRDS(process("$<"), "$@")'
print-%:
@echo $* = $($*)
But something about the timing of variable propagation, I think, isn't letting me chain rules the way I intend:
% make -n allfeats
make: *** No rule to make target `features/709731-feat.rds', needed by `allfeats'. Stop.
It does actually know how to create that target if I specify it explicitly:
% make -n features/709731-feat.rds
Rscript -e 'saveRDS(process("telemetry/709731"), "features/709731-feat.rds")'
Is there a different way to define my rules (or variables) that will work as intended?