I'm using a private script that routinely converts multiple (~100) text files to HTML. I wrote a makefile to only convert text files with changes:
TEXT_DIR = /path/to/app/data/
OUTPUT_DIR = /path/to/app/reports/
.PHONY : html
html : $(wildcard $(OUTPUT_DIR)/*.html)
$(OUTPUT_DIR)/%.html : $(TEXT_DIR)/%.txt
generate_html --html $< $@
When I run make, it calls the script once per each changed file:
generate_html --html /path/to/app/data/file1.txt /path/to/app/reports/file1.html
generate_html --html /path/to/app/data/file2.txt /path/to/app/reports/file2.html
generate_html --html /path/to/app/data/file3.txt /path/to/app/reports/file3.html
This is quite slow, because the script takes a bit of time on initial load as it reads config and does setup. Processing all files in a single run is much faster:
generate_html --html /path/to/app/data/file1.txt /path/to/app/reports/file1.html --html /path/to/app/data/file2.txt /path/to/app/reports/file2.html --html /path/to/app/data/file3.txt /path/to/app/reports/file3.html
How do I make GNU Make run the script like this?