summaryrefslogtreecommitdiff
path: root/Makefile
blob: a101059057cf64b4a4c01587b817f06b07c6eaae (plain)
  1. markdown-snippets := topbar.md footer.md
  2. hypertext-snippets = $(markdown-snippets:%.md=%.html)
  3. markdown := $(filter-out $(markdown-snippets),$(wildcard *.md */*.md */*/*.md))
  4. hypertext = $(subst index/index,index,$(markdown:%.md=%/index.html))
  5. graph := $(wildcard *.dot */*.dot */*/*.dot)
  6. vectorimage-graph := $(graph:%.dot=%.svg)
  7. sitetitle := $(shell head --lines=1 index.md | grep --perl-regexp --only-matching '^\#\s*\K(\S+(\s\S+)*)+')
  8. all: $(hypertext) $(vectorimage-graph) style.css
  9. update: .git
  10. git pull
  11. $(MAKE) all
  12. $(hypertext-snippets): %.html: %.md Makefile
  13. pandoc -f markdown -t html -o $@ $<
  14. sed -i -e '1i <div class=\"$*\">' -e '$$ a </div>' $@
  15. $(vectorimage-graph): %.svg: %.dot Makefile
  16. dot -Tsvg -o$@ $<
  17. %.html %/index.html: %.md $(hypertext-snippets) Makefile
  18. $(eval title = $(shell head --lines=1 $< | grep --perl-regexp --only-matching '^\#\s*\K(\S+(\s\S+)*)+'))
  19. $(if $(filter-out ./,$(dir $@)),mkdir -p $(dir $@))
  20. 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 $@ $<
  21. %.css : %.scss Makefile
  22. sassc --load-path /usr/share/sass --style compressed $< $@
  23. clean:
  24. rm -f $(vectorimage-graph)
  25. find * -type f -name '*.html' -delete
  26. find * -type d -empty -delete
  27. rm -f style.css style.css.map
  28. rm -rf .sass-cache
  29. MAKEFLAGS += --jobs
  30. .NOTPARALLEL: source
  31. .PHONY: all update clean