Suppose, I have 2 files, dependent upon each other:
./pictures/1_data.tex
|
V
./data/1.pl
So, 1_data.tex is generated from the Perl file. To do it I have the following rule in the makefile:
./pictures/1_data.tex: ./data/1.pl
perl given.pl 1 > $@
If I have multiple files with this pattern:
./data/1.pl
./data/2.pl
...
./data/n.pl
I'd like to use wildcards to process them. I tried this:
./pictures/*_data.tex: ./data/*.pl
perl given.pl $* > $@
But it generates incorrect command:
perl given.pl pictures/1_data > pictures/1_data.tex
Is it possible to have a backreference only to 1
, and not to the whole target? As $*
does.
Use pattern rules:
all: $(patsubst ./data/%.pl,./pictures/%_data.tex,$(wildcard ./data/*.pl))
./pictures/%_data.tex : ./data/%.pl
perl given.pl $* > $@