Sample Header Ad - 728x90

Can I use a flexible (either or) prerequisite in GNU make?

1 vote
2 answers
61 views
Is it possible to have a flexible extension for a prerequisite? For example, let's say I want to apply a rule to a list of targets that all have the same prerequisite pattern, except that some of them have a .xls extension, while the others have .xlsx. I'd like to allow for "%data.xlsx" OR "%data.xls" in the code below.
-make
target := */*report.html

$(target): %report.html: %report.qmd %data.xlsx
		quarto render $<
If it helps, I'm trying to re-compile all .qmd files in their respective directory; they result in .html files, and need data files that are either .xls, or .xlsx - job1/ - job1_report.html - job1_report.qmd - job1_data.xls - job2/ - job1_report.html - job2_report.qmd - job2_data.xlsx - ...
Asked by user2165907 (111 rep)
Apr 19, 2025, 12:12 AM
Last activity: Apr 21, 2025, 06:26 PM