# Environment vars DIST_DIR := dist # Computed vars SRC_HTMLS := $(shell find src -name '*.src.html') SRC_MDS := $(shell find src -name '*.src.md') SRC_TEMPLATES := $(shell find src/templates -name '*.html') GEN_HTMLS := $(SRC_HTMLS:%.src.html=%.gen.html) GEN_MDS := $(SRC_MDS:%.src.md=%.gen.html) GEN_FILES := $(GEN_HTMLS) $(GEN_MDS) INCLUDED_FILES := $(shell find src/include -type f) EMBEDDED_FILES := $(shell find src -name '*.png' -or -name '*.svg') DIST_GEN_FILES := $(GEN_FILES:src/%.gen.html=$(DIST_DIR)/%.html) DIST_INC_FILES := $(INCLUDED_FILES:src/%=$(DIST_DIR)/%) DIST_EMB_FILES := $(EMBEDDED_FILES:src/%=$(DIST_DIR)/%) DIST_FILES := $(DIST_GEN_FILES) $(DIST_INC_FILES) $(DIST_DWN_FILES) $(DIST_EMB_FILES) $(DIST_DIR)/favicon.ico PANDOC_GEN := pandoc --standalone --wrap=none --template src/templates/main.html --metadata-file src/meta.yml .PHONY: build build: $(GEN_FILES) $(info HTML generated) %.gen.html: %.src.html %.meta.yml $(SRC_TEMPLATES) $(PANDOC_GEN) --metadata-file $*.meta.yml --output $@ $< %.gen.html: %.src.md %.meta.yml $(SRC_TEMPLATES) $(PANDOC_GEN) --metadata-file $*.meta.yml --output $@ $< .PHONY: dist dist: $(DIST_DIR) $(info Distributed folder generated) $(DIST_DIR): $(DIST_FILES) $(DIST_DIR)/%.html: src/%.gen.html mkdir --parents $(dir $@) cp $< $@ $(DIST_DIR)/%: src/% mkdir --parents $(dir $@) cp $< $@ .PHONY: clean clean: rm -f $(GEN_FILES) .PHONY: clean-dist clean-dist: rm -rf $(DIST_DIR)/* .PHONY: clean-all clean-all: clean clean-dist .PHONY: debug debug: $(info SRC_HTMLS $(SRC_HTMLS)) $(info SRC_MDS $(SRC_MDS)) $(info SRC_TEMPLATES $(SRC_TEMPLATES)) $(info GEN_HTMLS $(GEN_HTMLS)) $(info GEN_MDS $(GEN_MDS)) $(info GEN_FILES $(GEN_FILES)) $(info INCLUDED_FILES $(INCLUDED_FILES)) $(info EMBEDDED_FILES $(EMBEDDED_FILES)) $(info DIST_FILES $(DIST_FILES))