chapters := note 01 02 03 04 05 06 07 08 09 10 11 12 appendix edited_chapters := $(foreach chapter,$(chapters),edited/$(chapter).markdown) tex_chapters := $(foreach chapter,$(chapters),tex/$(chapter).tex) book.pdf: $(tex_chapters) book.tex Makefile pdflatex book.tex edited/%.markdown: original/%.markdown edit-chapter.go Makefile go run edit-chapter.go $< $@ tex/%.tex: edited/%.markdown Makefile pandoc -o $@ $< --top-level-division=chapter tex: $(tex_chapters)