GO := $(shell which go) ifeq (, $(GO)) $(error "Required Go toolchain (go) not in $(PATH).") endif PAGES := $(sort $(wildcard pages/*.html)) pages.yaml TEMPLATES := $(sort $(wildcard templates/*.gohtml)) OUT_DIR := _dist PAGES_DIR := pages TEMPLATES_DIR := templates .PHONY: serve build clean build: $(OUT_DIR)/index.stamp $(OUT_DIR)/index.stamp: $(PAGES) $(TEMPLATES) cmd/build/main.go @$(GO) run ./cmd/build --pages $(PAGES_DIR) --out $(OUT_DIR) --templates $(TEMPLATES_DIR) --order pages.yaml @mkdir -p $(OUT_DIR) @date +%s > $(OUT_DIR)/index.stamp serve: build @echo "Serving $(OUT_DIR) as document root..." @xdg-open "http://localhost:8000/index.html" || true @cd $(OUT_DIR) && python -m http.server PDF := $(OUT_DIR)/output.pdf PDF_2UP := $(OUT_DIR)/output-2up.pdf .PHONY: deps deps: @$(GO) mod tidy .PHONY: pdf pdf: build deps @echo "Generating PDF with headless Chrome..." @$(GO) run ./cmd/pdf --in $(OUT_DIR)/print.html --out $(PDF) .PHONY: pdf-2up pdf-2up: build deps @echo "Generating 2-up PDF with headless Chrome..." @$(GO) run ./cmd/pdf --in $(OUT_DIR)/print_2up.html --out $(PDF_2UP) --w 11 --h 8.5 clean: rm -rf $(OUT_DIR) index.html