I have a data file that is processed by a script to produce multiple output files. Each of these output files is then processed further. Which files are created depends on the contents of the input file, so I can't list them explicitly. I can't quite figure out how to refer to the various files that are generated in a makefile.
Currently, I have something like this:
final.out: *.out2
merge_files final.out $(sort $^)
%.out2: %.out1
convert_files $?
%.out1: data.in
extract_data data.in
This fails with No rule to make target '*.out2', needed by 'final.out'
. I assume this is because the .out2 files don't exist yet and therefore the wildcard expression isn't replaced the way I would like it to. I have tried to use the wildcard function but that fails because the list of prerequisites ends up being empty.
Any pointers would be much appreciated.
EDIT: fixed the list of prerequisites in second pass.
You apparently cannot compute the list of intermediate files before running the
extract_data
command. In this case a solution consists in running make twice. One first time to generate the*.out1
files and a second time to finish the job. You can use an empty dummy file to mark whether theextract_data
command shall be run again or not:Unfortunately your question is missing some details I would ask immediately if some SW developer would present this makefile for review:
extract_files
provide the list of files?convert_files
convert one file or multiple? The example seems to imply that it converts multiple.The following is the approach I would choose. I'm going to use a tar file as an example for an input file that results in multiple output files
tar
optionv
to print files while they are extracted$(DATA_FILES)
UPDATE if
extract_data
doesn't provide the list of files, you could modify my example like this. But of course that depends on that there are no other files that match*.out1
in your directory.