makefile 1.7 KB

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