From ace3f2e9138ed31e961cf842b3d25f3a5d297789 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 26 Mar 2022 00:59:27 +0100 Subject: initial draft --- Makefile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a101059 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +markdown-snippets := topbar.md footer.md +hypertext-snippets = $(markdown-snippets:%.md=%.html) +markdown := $(filter-out $(markdown-snippets),$(wildcard *.md */*.md */*/*.md)) +hypertext = $(subst index/index,index,$(markdown:%.md=%/index.html)) +graph := $(wildcard *.dot */*.dot */*/*.dot) +vectorimage-graph := $(graph:%.dot=%.svg) + +sitetitle := $(shell head --lines=1 index.md | grep --perl-regexp --only-matching '^\#\s*\K(\S+(\s\S+)*)+') + +all: $(hypertext) $(vectorimage-graph) style.css + +update: .git + git pull + $(MAKE) all + +$(hypertext-snippets): %.html: %.md Makefile + pandoc -f markdown -t html -o $@ $< + sed -i -e '1i
' -e '$$ a
' $@ + +$(vectorimage-graph): %.svg: %.dot Makefile + dot -Tsvg -o$@ $< + +%.html %/index.html: %.md $(hypertext-snippets) Makefile + $(eval title = $(shell head --lines=1 $< | grep --perl-regexp --only-matching '^\#\s*\K(\S+(\s\S+)*)+')) + $(if $(filter-out ./,$(dir $@)),mkdir -p $(dir $@)) + pandoc -s $(if $(title),--metadata pagetitle='$(if $(filter-out $(sitetitle),$(title)),$(sitetitle) -- )$(title)') -c $(shell realpath --relative-to=$(dir $@) style.css) -B topbar.html -A footer.html -f markdown -t html -o $@ $< + +%.css : %.scss Makefile + sassc --load-path /usr/share/sass --style compressed $< $@ + +clean: + rm -f $(vectorimage-graph) + find * -type f -name '*.html' -delete + find * -type d -empty -delete + rm -f style.css style.css.map + rm -rf .sass-cache + +MAKEFLAGS += --jobs +.NOTPARALLEL: source +.PHONY: all update clean -- cgit v1.2.3