makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. SRC_LIST_YML := $(shell echo src/projets/*/*.meta.yml)
  8. GEN_HTMLS := $(SRC_HTMLS:%.src.html=%.gen.html)
  9. GEN_MDS := $(SRC_MDS:%.src.md=%.gen.html)
  10. GEN_LIST_YML := src/projets/list.gen.yml
  11. GEN_CONTENT_FILES := $(GEN_HTMLS) $(GEN_MDS)
  12. GEN_FILES := $(GEN_CONTENT_FILES) $(GEN_LIST_YML)
  13. INCLUDED_FILES := $(shell find src/include -type f)
  14. EMBEDDED_FILES := $(shell find src -name '*.png' -or -name '*.svg' -or -name '*.pdf')
  15. DIST_GEN_FILES := $(GEN_CONTENT_FILES:src/%.gen.html=$(DIST_DIR)/%.html)
  16. DIST_INC_FILES := $(INCLUDED_FILES:src/%=$(DIST_DIR)/%)
  17. DIST_EMB_FILES := $(EMBEDDED_FILES:src/%=$(DIST_DIR)/%)
  18. DIST_FILES := $(DIST_GEN_FILES) $(DIST_INC_FILES) $(DIST_DWN_FILES) $(DIST_EMB_FILES) $(DIST_DIR)/favicon.ico
  19. PANDOC_GEN := pandoc --standalone --wrap=none --template src/templates/main.html --metadata-file src/meta.yml
  20. LIST_GEN := yq eval-all '{"data": ., "link": filename | sub("meta.yml", "html") | sub("src", "")} as $$item ireduce ([]; . + $$item) | {"list": .}'
  21. # Build
  22. .PHONY: build
  23. build: $(GEN_CONTENT_FILES)
  24. $(info HTML generated)
  25. %.gen.html: %.src.html %.meta.yml $(SRC_TEMPLATES)
  26. $(PANDOC_GEN) --metadata-file $*.meta.yml --output $@ $<
  27. %.gen.html: %.src.md %.meta.yml $(SRC_TEMPLATES)
  28. $(PANDOC_GEN) --metadata-file $*.meta.yml --output $@ $<
  29. # Build lists
  30. $(GEN_LIST_YML): $(SRC_LIST_YML)
  31. $(LIST_GEN) $(SRC_LIST_YML) > $@
  32. src/projets/content.gen.html: src/projets/content.src.html src/projets/content.meta.yml $(GEN_LIST_YML) $(SRC_TEMPLATES)
  33. $(PANDOC_GEN) --metadata-file src/projets/content.meta.yml --metadata-file $(GEN_LIST_YML) --output $@ $<
  34. # Distribution
  35. .PHONY: dist
  36. dist: $(DIST_DIR)
  37. $(info Distributed folder generated)
  38. $(DIST_DIR): $(DIST_FILES)
  39. $(DIST_DIR)/%.html: src/%.gen.html
  40. mkdir --parents $(dir $@)
  41. cp $< $@
  42. $(DIST_DIR)/%: src/%
  43. mkdir --parents $(dir $@)
  44. cp $< $@
  45. # Cleaning
  46. .PHONY: clean
  47. clean:
  48. rm -f $(GEN_FILES)
  49. .PHONY: clean-dist
  50. clean-dist:
  51. rm -rf $(DIST_DIR)/*
  52. .PHONY: clean-all
  53. clean-all: clean clean-dist
  54. .PHONY: debug
  55. debug:
  56. $(info SRC_HTMLS $(SRC_HTMLS))
  57. $(info SRC_MDS $(SRC_MDS))
  58. $(info SRC_TEMPLATES $(SRC_TEMPLATES))
  59. $(info GEN_HTMLS $(GEN_HTMLS))
  60. $(info GEN_MDS $(GEN_MDS))
  61. $(info GEN_FILES $(GEN_FILES))
  62. $(info GEN_CONTENT_FILES $(GEN_CONTENT_FILES))
  63. $(info INCLUDED_FILES $(INCLUDED_FILES))
  64. $(info EMBEDDED_FILES $(EMBEDDED_FILES))
  65. $(info DIST_FILES $(DIST_FILES))