aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-10-05 16:04:22 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-10-05 16:09:40 +0200
commit058274fcc304279b1f4fe5effb683bee1a67f494 (patch)
treeed63e0f4667d97afd9a8df82600a629905ae7db2
parent39f2578e79b6db426ad3dd5db4898bcc7820e44a (diff)
downloadcerrado-058274fcc304279b1f4fe5effb683bee1a67f494.tar.gz
cerrado-058274fcc304279b1f4fe5effb683bee1a67f494.tar.bz2
cerrado-058274fcc304279b1f4fe5effb683bee1a67f494.zip
ref: Makefile takes all go files into account
It leverages the fact that make checks file modification timestamps so it does not compile again if there is no change. Now the all the files generated take that into account when using makefile (scss, qtpl and go).
-rw-r--r--.gitignore5
-rw-r--r--Makefile17
2 files changed, 13 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 776d7a2..541ad56 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
-bin/
+# css output
static/*.css
+
+# bin output
+cerrado
diff --git a/Makefile b/Makefile
index c235179..da2f091 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,13 @@
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)
+TEMPLATES := $(wildcard $(TEMPLATES_DIR)/*.qtpl)
GO_TEMPLATES_FILES := $(TEMPLATES:.qtpl=.qtpl.go)
SASS_DIR := scss
@@ -14,13 +15,13 @@ 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)
+build: $(BIN)
+
+$(BIN): $(GO_SRC) $(OUTPUT_CSS) $(GO_TEMPLATES_FILES)
+ go build -ldflags=$(LDFLAGS) -o $(BIN)
install:
- install -Dm755 bin/$(BIN) $(BINDIR)/$(BIN)
+ install -Dm755 $(BIN) $(BINDIR)/$(BIN)
run: sass tmpl
go run .
@@ -40,7 +41,7 @@ $(TEMPLATES_DIR)/%.qtpl.go: $(TEMPLATES_DIR)/%.qtpl
qtc $(TEMPLATES_DIR)/$*.qtpl
clean:
- rm -f $(OUTPUT_CSS)
- rm bin/$(BIN)
+ -rm $(OUTPUT_CSS)
+ -rm $(BIN)
.PHONY: sass tmpl