blob: 80aaf2b8a9c0462465409b4d790f3da595ac6812 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(GIT_COMMIT)' -s -w"
GO_SRC := $(shell find . -name '*.go')
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: $(BIN)
$(BIN): $(GO_SRC) $(OUTPUT_CSS) $(GO_TEMPLATES_FILES)
go build -ldflags=$(LDFLAGS) -o $(BIN)
install:
install -Dm755 $(BIN) $(BINDIR)/$(BIN)
run: sass tmpl
go run -ldflags=$(LDFLAGS) .
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 $(OUTPUT_CSS)
-rm $(BIN)
.PHONY: sass tmpl
|