1diff --git a/.gitignore b/.gitignore
2index 776d7a2c9749474ff5daa02e3b6842d4c1d8a36d..541ad56b75c1ce20a60f2d1405ce069afb74e0e2 100644
3--- a/.gitignore
4+++ b/.gitignore
5@@ -1,2 +1,5 @@
6-bin/
7+# css output
8 static/*.css
9+
10+# bin output
11+cerrado
12diff --git a/Makefile b/Makefile
13index c235179e4f8088760a7a6fc842a3c5a2814fa6d6..da2f09103e43dd1aef25f2f284ea1f806a3f0598 100644
14--- a/Makefile
15+++ b/Makefile
16@@ -1,12 +1,13 @@
17 GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
18 LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(GIT_COMMIT)' -s -w"
19+GO_SRC := $(shell find . -name '*.go')
20
21 BIN ?= cerrado
22 PREFIX ?= /usr/local
23 BINDIR ?= $(PREFIX)/bin
24
25 TEMPLATES_DIR := templates
26-TEMPLATES := $(wildcard $(TEMPLATES_DIR)/*.qtpl)
27+TEMPLATES := $(wildcard $(TEMPLATES_DIR)/*.qtpl)
28 GO_TEMPLATES_FILES := $(TEMPLATES:.qtpl=.qtpl.go)
29
30 SASS_DIR := scss
31@@ -14,13 +15,13 @@ CSS_DIR := static
32 OUTPUT_CSS := $(CSS_DIR)/main.$(GIT_COMMIT).css
33 SASS_FILES := $(wildcard $(SASS_DIR)/*.scss)
34
35-build: sass tmpl
36- go build \
37- -ldflags=$(LDFLAGS) \
38- -o bin/$(BIN)
39+build: $(BIN)
40+
41+$(BIN): $(GO_SRC) $(OUTPUT_CSS) $(GO_TEMPLATES_FILES)
42+ go build -ldflags=$(LDFLAGS) -o $(BIN)
43
44 install:
45- install -Dm755 bin/$(BIN) $(BINDIR)/$(BIN)
46+ install -Dm755 $(BIN) $(BINDIR)/$(BIN)
47
48 run: sass tmpl
49 go run .
50@@ -40,7 +41,7 @@ $(TEMPLATES_DIR)/%.qtpl.go: $(TEMPLATES_DIR)/%.qtpl
51 qtc $(TEMPLATES_DIR)/$*.qtpl
52
53 clean:
54- rm -f $(OUTPUT_CSS)
55- rm bin/$(BIN)
56+ -rm $(OUTPUT_CSS)
57+ -rm $(BIN)
58
59 .PHONY: sass tmpl