makefile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Environment vars
  2. DIST_DIR := dist
  3. # Computed vars
  4. SRC_HTMLS := $(shell find src -name '*.src.html')
  5. SRC_MDS := $(shell find src -name '*.src.md')
  6. SRC_TEMPLATES := $(shell find src/templates -name '*.html')
  7. GEN_HTMLS := $(SRC_HTMLS:%.src.html=%.gen.html)
  8. GEN_MDS := $(SRC_MDS:%.src.md=%.gen.html)
  9. GEN_FILES := $(GEN_HTMLS) $(GEN_MDS)
  10. INCLUDED_FILES := $(shell find src/include -type f)
  11. DOWNLOAD_FILES := $(shell find src/download -type f)
  12. EMBEDDED_FILES := $(shell find src -name '*.png' -type f)
  13. DIST_GEN_FILES := $(GEN_FILES:src/%.gen.html=$(DIST_DIR)/%.html)
  14. DIST_INC_FILES := $(INCLUDED_FILES:src/%=$(DIST_DIR)/%)
  15. DIST_DWN_FILES := $(DOWNLOAD_FILES:src/%=$(DIST_DIR)/%)
  16. DIST_EMB_FILES := $(EMBEDDED_FILES:src/%=$(DIST_DIR)/%)
  17. DIST_FILES := $(DIST_GEN_FILES) $(DIST_INC_FILES) $(DIST_DWN_FILES) $(DIST_EMB_FILES) $(DIST_DIR)/favicon.ico
  18. PANDOC_GEN := pandoc --standalone --wrap=none --template src/templates/main.html --metadata-file src/meta.yml
  19. .PHONY: build
  20. build: $(GEN_FILES)
  21. $(info HTML generated)
  22. %.gen.html: %.src.html $(SRC_TEMPLATES)
  23. $(PANDOC_GEN) --output $@ $<
  24. %.gen.html: %.src.md $(SRC_TEMPLATES)
  25. $(PANDOC_GEN) --output $@ $<
  26. .PHONY: dist
  27. dist: $(DIST_DIR)
  28. $(info Distributed folder generated)
  29. $(DIST_DIR): $(DIST_FILES)
  30. $(DIST_DIR)/include/%: src/include/%
  31. mkdir --parents $(dir $@)
  32. cp $< $@
  33. $(DIST_DIR)/download/%: src/download/%
  34. mkdir --parents $(dir $@)
  35. cp $< $@
  36. $(DIST_DIR)/%.html: src/%.gen.html
  37. mkdir --parents $(dir $@)
  38. cp $< $@
  39. $(DIST_DIR)/%.png: src/%.png
  40. mkdir --parents $(dir $@)
  41. cp $< $@
  42. $(DIST_DIR)/favicon.ico: src/favicon.ico
  43. cp $< $@
  44. .PHONY: clean
  45. clean:
  46. rm -f $(GEN_FILES)
  47. clean-dist:
  48. rm -rf $(DIST_DIR)/*
  49. .PHONY: debug
  50. debug:
  51. $(info SRC_HTMLS $(SRC_HTMLS))
  52. $(info SRC_MDS $(SRC_MDS))
  53. $(info SRC_TEMPLATES $(SRC_TEMPLATES))
  54. $(info GEN_HTMLS $(GEN_HTMLS))
  55. $(info GEN_MDS $(GEN_MDS))
  56. $(info GEN_FILES $(GEN_FILES))
  57. $(info INCLUDED_FILES $(INCLUDED_FILES))
  58. $(info DOWNLOAD_FILES $(DOWNLOAD_FILES))
  59. $(info EMBEDDED_FILES $(EMBEDDED_FILES))
  60. $(info DIST_FILES $(DIST_FILES))