Files
smartbar/Makefile

48 lines
1.2 KiB
Makefile
Raw Permalink Normal View History

2025-08-10 17:17:01 -07:00
GO := $(shell which go)
ifeq (, $(GO))
$(error "Required Go toolchain (go) not in $(PATH).")
endif
PAGES := $(sort $(wildcard pages/*.html)) pages.yaml
2025-08-10 17:36:57 -07:00
TEMPLATES := $(sort $(wildcard templates/*.gohtml))
2025-08-10 17:47:57 -07:00
ASSETS_DIR := assets
ASSETS_FILES := $(shell find $(ASSETS_DIR) -type f 2>/dev/null)
2025-08-10 17:36:57 -07:00
OUT_DIR := _dist
PAGES_DIR := pages
TEMPLATES_DIR := templates
2025-08-10 17:17:01 -07:00
.PHONY: serve build clean
2025-08-10 17:36:57 -07:00
build: $(OUT_DIR)/index.stamp
2025-08-10 17:17:01 -07:00
2025-08-10 17:47:57 -07:00
$(OUT_DIR)/index.stamp: $(PAGES) $(TEMPLATES) $(ASSETS_FILES) cmd/build/main.go
2025-08-10 17:36:57 -07:00
@$(GO) run ./cmd/build --pages $(PAGES_DIR) --out $(OUT_DIR) --templates $(TEMPLATES_DIR) --order pages.yaml
@mkdir -p $(OUT_DIR)
2025-08-10 17:47:57 -07:00
@if [ -d $(ASSETS_DIR) ]; then rm -rf $(OUT_DIR)/$(ASSETS_DIR); cp -r $(ASSETS_DIR) $(OUT_DIR)/; fi
2025-08-10 17:36:57 -07:00
@date +%s > $(OUT_DIR)/index.stamp
2025-08-10 17:17:01 -07:00
serve: deps
@$(GO) run ./cmd/serve --port 8000 $(PWD)
2025-08-10 17:17:01 -07:00
2025-08-10 17:36:57 -07:00
PDF := $(OUT_DIR)/output.pdf
PDF_2UP := $(OUT_DIR)/output-2up.pdf
2025-08-10 17:17:01 -07:00
.PHONY: deps
deps:
@$(GO) mod tidy
.PHONY: pdf
pdf: build deps
@echo "Generating PDF with headless Chrome..."
2025-08-10 17:36:57 -07:00
@$(GO) run ./cmd/pdf --in $(OUT_DIR)/print.html --out $(PDF)
2025-08-10 17:17:01 -07:00
.PHONY: pdf-2up
pdf-2up: build deps
@echo "Generating 2-up PDF with headless Chrome..."
2025-08-10 17:36:57 -07:00
@$(GO) run ./cmd/pdf --in $(OUT_DIR)/print_2up.html --out $(PDF_2UP) --w 11 --h 8.5
2025-08-10 17:17:01 -07:00
clean:
2025-08-10 17:36:57 -07:00
rm -rf $(OUT_DIR) index.html
2025-08-10 17:17:01 -07:00