GIT_COMMIT ?= $(shell git rev-parse --short HEAD) LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(GIT_COMMIT)' -s -w" BIN ?= cerrado PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin TEMPLATES_DIR := templates TEMPLATES := $(wildcard $(TEMPLATES_DIR)/*.qtpl) GO_TEMPLATES_FILES := $(TEMPLATES:.qtpl=.qtpl.go) SASS_DIR := scss CSS_DIR := static OUTPUT_CSS := $(CSS_DIR)/main.$(GIT_COMMIT).css SASS_FILES := $(wildcard $(SASS_DIR)/*.scss) build: sass tmpl go build \ -ldflags=$(LDFLAGS) \ -o bin/$(BIN) install: install -Dm755 bin/$(BIN) $(BINDIR)/$(BIN) run: sass tmpl go run . test: go test -v --tags=unit ./... sass: $(OUTPUT_CSS) $(OUTPUT_CSS): $(SASS_FILES) @mkdir -p $(CSS_DIR) sassc $(SASS_DIR)/main.scss $(OUTPUT_CSS) tmpl: $(GO_TEMPLATES_FILES) $(TEMPLATES_DIR)/%.qtpl.go: $(TEMPLATES_DIR)/%.qtpl qtc $(TEMPLATES_DIR)/$*.qtpl clean: rm -f $(OUTPUT_CSS) rm bin/$(BIN) .PHONY: sass tmpl