summaryrefslogtreecommitdiff
path: root/Makefile
blob: 995868a32e8da2f32d81b8d04f9ab1564681a66e (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. --metadata lang=da \
  24. $(if $(title),\
  25. $(if $(filter-out $(sitetitle),$(title)),$(strip \
  26. --metadata pagetitle='$(sitetitle) -- $(title)'),$(strip \
  27. --metadata pagetitle='$(title)'))) \
  28. -c $(shell realpath --relative-to=$(dir $@) style.css) \
  29. -B topbar.html \
  30. -A footer.html \
  31. -o $@ $<
  32. %.css : %.scss Makefile
  33. sassc --load-path /usr/share/sass --style compressed $< $@
  34. clean:
  35. rm -f $(vectorimage-graph)
  36. find * -type f -name '*.html' -delete
  37. find * -type d -empty -delete
  38. rm -f style.css style.css.map
  39. rm -rf .sass-cache
  40. MAKEFLAGS += --jobs
  41. .NOTPARALLEL: source
  42. .PHONY: all update clean