Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/make
  2. #
  3. # Prerequisites:
  4. #
  5. # Mandatory:
  6. #
  7. # kramdown: http://kramdown.rubyforge.org/
  8. # $ sudo gem install kramdown
  9. #
  10. # Optional:
  11. #
  12. # graphviz: http://www.graphviz.org/
  13. # http://www.graphviz.org/Download_macos.php
  14. # or $ sudo port install graphviz +no_x11
  15. # pdflatex: https://www.tug.org/texlive/
  16. # follow https://code.google.com/p/mactlmgr/
  17. # some commands:
  18. RM=rm
  19. DOT=dot
  20. KRAMDOWN=kramdown
  21. PDFLATEX=pdflatex
  22. BUILD_DST := build
  23. # graphviz
  24. $(BUILD_DST)/%.png: %.dot
  25. $(DOT) -Tpng -o $@ $<
  26. $(BUILD_DST)/%.pdf: %.dot
  27. $(DOT) -Tpdf -o $@ $<
  28. $(BUILD_DST)/%.svg: %.dot
  29. $(DOT) -Tsvg -o $@ $<
  30. $(BUILD_DST)/%.svg: %.svg
  31. cp $< $@
  32. # markdown / kramdown
  33. $(BUILD_DST)/%.html: %.md
  34. -$(KRAMDOWN) --template templates/document-mathjax $< > $@
  35. $(BUILD_DST)/%.tex: %.md
  36. -$(KRAMDOWN) --template templates/document-toc --output latex $< > $@
  37. %.pdf: %.tex
  38. # needs texlive package ucs
  39. # call 2x to get toc right
  40. -$(PDFLATEX) -output-directory=$(BUILD_DST) $< ; $(PDFLATEX) -output-directory=$(BUILD_DST) $<
  41. .PHONY: clean
  42. SPECS_DOT := $(patsubst %.dot,$(BUILD_DST)/%.pdf,$(wildcard **.dot))
  43. SPECS_HTML := $(patsubst %.md,$(BUILD_DST)/%.html,$(wildcard **.md))
  44. SPECS_SVG := $(patsubst %.svg,$(BUILD_DST)/%.svg,$(wildcard **.svg))
  45. SPECS_TEX := $(patsubst %.md,$(BUILD_DST)/%.pdf,$(wildcard **.md))
  46. TARGETS := $(SPECS_HTML) $(SPECS_DOT) $(SPECS_SVG)
  47. all: $(TARGETS)
  48. pdf: $(SPECS_TEX) $(SPECS_DOT)
  49. clean:
  50. -$(RM) $(TARGETS) $(SPECS_TEX) *.aux *.log *.out *.toc