diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..407e2f7 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev) +LDFLAGS := -s -w -X main.version=$(VERSION) +HOST ?= yttrium.mfamily.org + +.PHONY: build arm64 run deploy clean + +build: ## native build + CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o build/gps-clock-dash . + +arm64: ## Raspberry Pi (64-bit) build + GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o build/gps-clock-dash-arm64 . + +run: build + ./build/gps-clock-dash + +deploy: arm64 ## copy binary + unit to $(HOST) and (re)start the service + scp build/gps-clock-dash-arm64 deploy/gps-clock-dash.service $(HOST):/tmp/ + ssh -t $(HOST) 'sudo install -m 0755 /tmp/gps-clock-dash-arm64 /usr/local/bin/gps-clock-dash && \ + sudo install -m 0644 /tmp/gps-clock-dash.service /etc/systemd/system/gps-clock-dash.service && \ + sudo systemctl daemon-reload && sudo systemctl enable --now gps-clock-dash && \ + sudo systemctl restart gps-clock-dash && systemctl --no-pager status gps-clock-dash | head -5' + +clean: + rm -rf build |
