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