makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 %.meta.yml $(SRC_TEMPLATES)
  23. $(PANDOC_GEN) --metadata-file $*.meta.yml --output $@ $<
  24. %.gen.html: %.src.md %.meta.yml $(SRC_TEMPLATES)
  25. $(PANDOC_GEN) --metadata-file $*.meta.yml --output $@ $<
  26. .PHONY: dist
  27. dist: $(DIST_DIR)
  28. $(info Distributed folder generated)
  29. $(DIST_DIR): $(DIST_FILES)
  30. $(DIST_DIR)/%.html: src/%.gen.html
  31. mkdir --parents $(dir $@)
  32. cp $< $@
  33. $(DIST_DIR)/%: src/%
  34. mkdir --parents $(dir $@)
  35. cp $< $@
  36. .PHONY: clean
  37. clean:
  38. rm -f $(GEN_FILES)
  39. .PHONY: clean-dist
  40. clean-dist:
  41. rm -rf $(DIST_DIR)/*
  42. .PHONY: clean-all
  43. clean-all: clean clean-dist
  44. .PHONY: debug
  45. debug:
  46. $(info SRC_HTMLS $(SRC_HTMLS))
  47. $(info SRC_MDS $(SRC_MDS))
  48. $(info SRC_TEMPLATES $(SRC_TEMPLATES))
  49. $(info GEN_HTMLS $(GEN_HTMLS))
  50. $(info GEN_MDS $(GEN_MDS))
  51. $(info GEN_FILES $(GEN_FILES))
  52. $(info INCLUDED_FILES $(INCLUDED_FILES))
  53. $(info DOWNLOAD_FILES $(DOWNLOAD_FILES))
  54. $(info EMBEDDED_FILES $(EMBEDDED_FILES))
  55. $(info DIST_FILES $(DIST_FILES))