makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. GEN_HTMLS := $(SRC_HTMLS:%.src.html=%.gen.html)
  7. GEN_MDS := $(SRC_MDS:%.src.md=%.gen.html)
  8. GEN_FILES := $(GEN_HTMLS) $(GEN_MDS)
  9. INCLUDED_FILES := $(shell find src/include -type f)
  10. DOWNLOAD_FILES := $(shell find src/download -type f)
  11. DIST_GEN_FILES := $(GEN_FILES:src/%.gen.html=$(DIST_DIR)/%.html)
  12. DIST_INC_FILES := $(INCLUDED_FILES:src/%=$(DIST_DIR)/%)
  13. DIST_DWN_FILES := $(DOWNLOAD_FILES:src/%=$(DIST_DIR)/%)
  14. DIST_FILES := $(DIST_GEN_FILES) $(DIST_INC_FILES) $(DIST_DWN_FILES)
  15. PANDOC_GEN := pandoc --standalone --wrap=none --template src/templates/main.html --metadata-file src/meta.yml
  16. .PHONY: build dist
  17. build: $(GEN_FILES)
  18. $(info HTML generated)
  19. %.gen.html: %.src.html
  20. $(PANDOC_GEN) --output $@ $<
  21. %.gen.html: %.src.md
  22. $(PANDOC_GEN) --output $@ $<
  23. dist: $(DIST_DIR)
  24. $(info Distributed folder generated)
  25. $(DIST_DIR): $(DIST_FILES)
  26. $(DIST_DIR)/include/%: src/include/%
  27. mkdir --parents $(dir $@)
  28. cp $< $@
  29. $(DIST_DIR)/download/%: src/download/%
  30. mkdir --parents $(dir $@)
  31. cp $< $@
  32. $(DIST_DIR)/%.html: src/%.gen.html
  33. mkdir --parents $(dir $@)
  34. cp $< $@
  35. .PHONY: clean
  36. clean:
  37. rm -f $(GEN_FILES)
  38. clean-dist:
  39. rm -f $(DIST_FILES)
  40. .PHONY: debug
  41. debug:
  42. $(info SRC_HTMLS $(SRC_HTMLS))
  43. $(info SRC_MDS $(SRC_MDS))
  44. $(info GEN_HTMLS $(GEN_HTMLS))
  45. $(info GEN_MDS $(GEN_MDS))
  46. $(info GEN_FILES $(GEN_FILES))
  47. $(info DIST_FILES $(DIST_FILES))