From 4fdb624ab3a91ac814a022c1035460654a2f596c Mon Sep 17 00:00:00 2001 From: urosm Date: Fri, 17 May 2024 15:35:32 +0200 Subject: [PATCH] update `Makefile` --- Makefile | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index d2ffa64..fde449e 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,27 @@ SHELL = /bin/sh .SUFFIXES: +# All notes referenced with internal links, starting from `index.md`. NOTES = $(shell pandoc lua pandoc/collect_notes.lua index.md) -TARGETS = $(patsubst %.md,public_html/%.html,$(NOTES)) -GETDEPS = $(patsubst %.md,public_html/%.html.part,$(shell pandoc lua pandoc/collect_links.lua $(1))) -DEPSMETAFLAGS = $(patsubst %,-M linkparts=%,$(filter-out $<,$^)) +# All pages referenced with internal links, starting from `index.md`. +PAGES := $(patsubst %.md,public_html/%.html,$(NOTES)) +# All parts referenced with internal links in `$(1)`, plus the sitemap. +PARTS = $(patsubst %.md,public_html/%.html.part,$(shell pandoc lua pandoc/collect_links.lua $(1))) public_html/sitemap.html.part + +PANDOCFLAGS = --data-dir pandoc .PHONY: all -all: $(TARGETS) +all: $(PAGES) .SECONDEXPANSION: -public_html/%.html: %.md \ - $$(call GETDEPS,%.md) \ - public_html/sitemap.html.part - pandoc --data-dir pandoc -d bavbavhaus.net.yaml -M slug=$* $(DEPSMETAFLAGS) -o $@ $< +public_html/%.html: flags = $(patsubst %,-M parts=%,$(filter-out $<,$^)) +public_html/%.html: %.md $$(call PARTS,%.md) + @echo $^ + pandoc $(PANDOCFLAGS) -d bavbavhaus.net.yaml -M slug=$* $(flags) -o $@ $< +.SECONDARY: public_html/%.html.part: %.md - pandoc --data-dir pandoc -d bavbavhaus.net.part.yaml --id-prefix $* -M url=$*.html -M slug=$* -o $@ $< + pandoc $(PANDOCFLAGS) -d bavbavhaus.net.part.yaml --id-prefix $* -M url=$*.html -M slug=$* -o $@ $< public_html/sitemap.html.part: $(NOTES) pandoc lua pandoc/sitemap.lua index.md $@