BULLETINS := $(wildcard bulletins/*.lytex) all: $(foreach bulletin,$(BULLETINS),output/$(notdir $(basename $(bulletin))).pdf) # Declare dependencies dynamically $(foreach bulletin,$(BULLETINS), \ $(eval output/$(notdir $(basename $(bulletin))).pdf: $(bulletin)) \ ) output/%.pdf: mkdir -p output cache; \ date=$(basename $(notdir $@)); \ lilypond-book --output=cache --pdf bulletins/$$date.lytex && \ (cd cache && lualatex $$date.tex) && \ mv cache/$$date.pdf output/ clean: rm -rf output cache .PHONY: all clean