I have the following file tree (for example):
foo/1213.csv foo/7789.csv far/8471.csv far/7811.csv boo/8109.csv bar/2778.csv bar/3334.csv bar/1337.csv
Now, I want for each
foo far boo bar directory to create a
qux.json inside of it, which is dependant on all of
*.csv files in that directory.
So far, it shouldn't be to difficult - I believe something like this would work (correct me if I'm wrong):
%/qux.json: %/*.csv my-script.py -o $@ $^
The point where I get stuck is when there are few "classes" of rules and for each class have a different recipe, for example something like:
CLASS1=foo far CLASS2=boo bar $(patsubst %,%/qux.json,$(CLASS1)): $(patsubst %,%/*.csv,$(CLASS1)) my-script1.py -o $@ $^ $(patsubst %,%/qux.json,$(CLASS2)): $(patsubst %,%/*.csv,$(CLASS2)) my-script2.py -o $@ $^
make foo/qux.json fails with
make: *** No rule to make target 'far/*.csv', needed by 'foo/qux.json'. Stop..
I tried many different things, like:
$(patsubst %,%/qux.json,$(CLASS1)): $(wildcard $(patsubst %/qux.json,%/*.csv,$@)) my-script1.py -o $@ $
Essentially, I have several types of subdirectories. I can enumerate each member to a makefile variable. Each subdirectory contains random number of input csv files. I want to create a json file inside each directory from all its csv files. But each class of directories needs to run a different script.
I tried reading through
man files, I've tries searching on the internet and SO, but this s too specific for any search result and too difficult for me to figure out through manual.