makefile 1.8 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. EMBEDDED_FILES := $(shell find src -name '*.png' -or -name '*.svg')
  12. DIST_GEN_FILES := $(GEN_FILES:src/%.gen.html=$(DIST_DIR)/%.html)
  13. DIST_INC_FILES := $(INCLUDED_FILES:src/%=$(DIST_DIR)/%)
  14. DIST_EMB_FILES := $(EMBEDDED_FILES:src/%=$(DIST_DIR)/%)
  15. DIST_FILES := $(DIST_GEN_FILES) $(DIST_INC_FILES) $(DIST_DWN_FILES) $(DIST_EMB_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
  18. build: $(GEN_FILES)
  19. $(info HTML generated)
  20. %.gen.html: %.src.html %.meta.yml $(SRC_TEMPLATES)
  21. $(PANDOC_GEN) --metadata-file $*.meta.yml --output $@ $<
  22. %.gen.html: %.src.md %.meta.yml $(SRC_TEMPLATES)
  23. $(PANDOC_GEN) --metadata-file $*.meta.yml --output $@ $<
  24. .PHONY: dist
  25. dist: $(DIST_DIR)
  26. $(info Distributed folder generated)
  27. $(DIST_DIR): $(DIST_FILES)
  28. $(DIST_DIR)/%.html: src/%.gen.html
  29. mkdir --parents $(dir $@)
  30. cp $< $@
  31. $(DIST_DIR)/%: src/%
  32. mkdir --parents $(dir $@)
  33. cp $< $@
  34. .PHONY: clean
  35. clean:
  36. rm -f $(GEN_FILES)
  37. .PHONY: clean-dist
  38. clean-dist:
  39. rm -rf $(DIST_DIR)/*
  40. .PHONY: clean-all
  41. clean-all: clean clean-dist
  42. .PHONY: debug
  43. debug:
  44. $(info SRC_HTMLS $(SRC_HTMLS))
  45. $(info SRC_MDS $(SRC_MDS))
  46. $(info SRC_TEMPLATES $(SRC_TEMPLATES))
  47. $(info GEN_HTMLS $(GEN_HTMLS))
  48. $(info GEN_MDS $(GEN_MDS))
  49. $(info GEN_FILES $(GEN_FILES))
  50. $(info INCLUDED_FILES $(INCLUDED_FILES))
  51. $(info EMBEDDED_FILES $(EMBEDDED_FILES))
  52. $(info DIST_FILES $(DIST_FILES))