summaryrefslogtreecommitdiff
path: root/Makefile
blob: 407e2f7250198ab79ce82792a7f837e954f61a67 (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
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