Raspberry Pi alarm clock server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB

SHELL := /bin/bash
VERSION=$(shell grep -e 'Version' sonar.go | head -n 1 | cut -d '"' -f 2)
BUILD=$(shell git describe --always)
CURDIR=$(shell curdir)
# Inject the build version (commit hash) into the executable.
LDFLAGS := -ldflags "-X main.Build=$(BUILD)"
# `make setup` to set up a new environment, pull dependencies, etc.
.PHONY: setup
setup: clean
go get -u ./...
# `make build` to build the binary.
.PHONY: build
gofmt -w .
go build $(LDFLAGS) -i -o bin/sonar cmd/sonar/main.go
# `make dist` makes a distribution bundle.
.PHONY: dist
rm -rf dist
mkdir dist
cp -r crontab.in www dist/
go build $(LDFLAGS) -i -o dist/sonar cmd/sonar/main.go
cd dist
tar -czvf sonar-$(VERSION).tar.gz *
mv *.tar.gz ../
# `make pi` makes a distribution for the Raspberry Pi.
.PHONY: pi
rm -rf sonar.pi
mkdir sonar.pi
cp -r crontab.in www sonar.pi/
GOOS=linux GOARCH=arm go build $(LDFLAGS) -i -o sonar.pi/sonar cmd/sonar/main.go
zip -r sonar-pi.zip sonar.pi
# `make run` to run it in debug mode.
.PHONY: run
go run cmd/sonar/main.go -debug
# `make watch` to run it in debug mode.
.PHONY: watch
./go-reload cmd/sonar/main.go -debug
# `make test` to run unit tests.
.PHONY: test
go test ./...
# `make clean` cleans everything up.
.PHONY: clean
rm -rf bin dist