1
0
mirror of https://github.com/cmur2/miflorad.git synced 2024-12-22 12:54:25 +01:00
miflorad/Makefile

80 lines
2.7 KiB
Makefile
Raw Normal View History

2020-08-30 20:42:58 +02:00
# https://tech.davis-hansson.com/p/make/
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eux -o pipefail -c
.DELETE_ON_ERROR:
.SILENT:
.DEFAULT_GOAL := all
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
2018-12-13 16:33:37 +01:00
MIFLORA_ADDR?=00:00:00:00:00:00
2018-12-23 12:35:33 +01:00
MIFLORAD_VERSION?=master
RUN_COMMAND=miflorad
RUN_OPTIONS=$(MIFLORA_ADDR)
2018-12-13 16:33:37 +01:00
.PHONY: all
2020-08-30 20:42:58 +02:00
all: clean build test ## Run clean, build and test (default goal)
2018-12-13 16:33:37 +01:00
.PHONY: run
2020-08-30 20:42:58 +02:00
run: clean build test ## Run clean, build, test and finally launch the $RUN_COMMAND as root
sudo cmd/$(RUN_COMMAND)/$(RUN_COMMAND) $(RUN_OPTIONS)
2018-12-13 16:33:37 +01:00
.PHONY: clean
2020-08-30 20:42:58 +02:00
clean: ## Remove all produced executables
2018-12-25 22:16:46 +01:00
rm -f cmd/miflorad/miflorad
2018-12-13 16:33:37 +01:00
rm -f cmd/munin-miflora/munin-miflora
2018-12-25 22:16:46 +01:00
rm -f cmd/munin-miflora-gatt/munin-miflora-gatt
2018-12-13 16:33:37 +01:00
.PHONY: build
2020-08-30 20:42:58 +02:00
build: cmd/miflorad/miflorad cmd/munin-miflora/munin-miflora cmd/munin-miflora-gatt/munin-miflora-gatt ## Build all produced executables
2018-12-13 16:33:37 +01:00
.PHONY: test
2020-08-30 20:42:58 +02:00
test: build ## Run all tests
pushd cmd/miflorad
go test -v -race
popd
pushd common
go test -v -race
popd
2018-12-13 16:33:37 +01:00
.PHONY: remote-run
2020-08-30 20:42:58 +02:00
remote-run: clean ## Run clean, build $RUN_COMMAND for Linux on ARM and launch it via SSH on extzero
pushd cmd/$(RUN_COMMAND)
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w"
popd
file cmd/$(RUN_COMMAND)/$(RUN_COMMAND)
scp cmd/$(RUN_COMMAND)/$(RUN_COMMAND) extzero:$(RUN_COMMAND)
ssh extzero "./$(RUN_COMMAND) $(RUN_OPTIONS)"
.PHONY: release
2020-08-30 20:42:58 +02:00
release: ## Build and upload release version of miflorad to Github
mkdir -p pkg
2020-08-30 20:42:58 +02:00
pushd cmd/miflorad
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-amd64" -ldflags="-s -w -X main.version=$(MIFLORAD_VERSION)"
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-arm" -ldflags="-s -w -X main.version=$(MIFLORAD_VERSION)"
popd
# github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --prerelease --github-repository "cmur2/miflorad"
github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --github-repository "cmur2/miflorad"
2018-12-25 22:16:46 +01:00
.PHONY: cmd/miflorad/miflorad
cmd/miflorad/miflorad:
2020-08-30 20:42:58 +02:00
pushd cmd/miflorad
CGO_ENABLED=0 go build -buildmode=pie -ldflags "-X main.version=$(MIFLORAD_VERSION)"
.PHONY: cmd/munin-miflora/munin-miflora
2018-12-13 16:33:37 +01:00
cmd/munin-miflora/munin-miflora:
2020-08-30 20:42:58 +02:00
pushd cmd/munin-miflora
CGO_ENABLED=0 go build -buildmode=pie
2018-12-25 22:16:46 +01:00
.PHONY: cmd/munin-miflora-gatt/munin-miflora-gatt
cmd/munin-miflora-gatt/munin-miflora-gatt:
2020-08-30 20:42:58 +02:00
pushd cmd/munin-miflora-gatt
CGO_ENABLED=0 go build -buildmode=pie
.PHONY: help
help: ## Print this help text
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'