cerrado @ a47effe083d70cae7f039ff207087447a7a82ee0

ref: Refactor makefile

Now the makefile file takes into account the source folder for
temaplating and scss, which means it will not regeneratem them every
time you run "make" or "make run". This speeds up local development
iterations.
diff --git a/Makefile b/Makefile
index 068f872f4466fcf2cf7cacddb0a6dc17c0e22241..17e424db62b5ef0e9004443ef74860eda86f84ce 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,16 @@
-SLUG ?= $(shell git rev-parse --short HEAD)
-LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(SLUG)' -s -w"
+GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
+LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(GIT_COMMIT)' -s -w"
+
+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-slug tmpl
+build: sass tmpl
 	go build \
 		-ldflags=$(LDFLAGS) \
 		-o bin/cerrado
@@ -12,20 +21,18 @@
 test:
 	go test -v --tags=unit ./...
 
-# this is meant for "prod" build
-sass-slug:
-	mkdir -p static
-	sassc \
-		--style compressed \
-		-I scss scss/main.scss static/main.$(SLUG).css
+sass: $(OUTPUT_CSS)
+
+$(OUTPUT_CSS): $(SASS_FILES)
+	@mkdir -p $(CSS_DIR)
+	sassc $(SASS_DIR)/main.scss $(OUTPUT_CSS)
+
+tmpl: $(GO_TEMPLATES_FILES)
 
-sass:
-	mkdir -p static
-	sassc \
-		-I scss scss/main.scss static/main.css
+$(TEMPLATES_DIR)/%.qtpl.go: $(TEMPLATES_DIR)/%.qtpl
+	qtc $(TEMPLATES_DIR)/$*.qtpl
 
-tmpl:
-	cd ./templates && \
-	qtc *
+clean:
+	rm -f $(OUTPUT_CSS)
 
-.PHONY: sass
+.PHONY: sass tmpl