2020-01-09 20:50:27 +00:00
|
|
|
VERSION?=$(shell git describe --abbrev=0)+$(shell date +'%Y%m%d%H%I%S')
|
2019-09-04 11:37:50 +00:00
|
|
|
|
2021-04-10 14:06:47 +00:00
|
|
|
EXECUTABLE:=flucky
|
2020-01-09 20:50:27 +00:00
|
|
|
|
2021-04-10 14:06:47 +00:00
|
|
|
DESTDIR?=
|
|
|
|
PREFIX?=/usr/local
|
2020-01-09 20:50:27 +00:00
|
|
|
|
2019-09-04 11:37:50 +00:00
|
|
|
# BINARIES
|
|
|
|
# ==============================================================================
|
2020-05-31 22:52:54 +00:00
|
|
|
EXECUTABLE_TARGETS:= \
|
|
|
|
bin/linux/amd64/${EXECUTABLE} \
|
|
|
|
bin/linux/arm/5/${EXECUTABLE} \
|
|
|
|
bin/linux/arm/7/${EXECUTABLE} \
|
|
|
|
bin/tmp/${EXECUTABLE}
|
2019-08-26 06:26:37 +00:00
|
|
|
|
2020-05-31 22:52:54 +00:00
|
|
|
${EXECUTABLE}: bin/tmp/${EXECUTABLE}
|
2019-06-14 19:35:13 +00:00
|
|
|
|
2021-03-21 17:47:14 +00:00
|
|
|
bin/linux/amd64/${EXECUTABLE}:
|
2020-05-21 15:40:24 +00:00
|
|
|
CGO_ENABLED=1 \
|
2020-01-09 20:50:27 +00:00
|
|
|
GOOS=linux \
|
|
|
|
GOARCH=amd64 \
|
2021-04-09 15:11:51 +00:00
|
|
|
GOPROXY=$(shell go env GOPROXY) \
|
|
|
|
GOPRIVATE=$(shell go env GOPRIVATE) \
|
2020-01-09 20:50:27 +00:00
|
|
|
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
2019-08-26 06:26:37 +00:00
|
|
|
|
2021-03-21 17:47:14 +00:00
|
|
|
bin/linux/arm/5/${EXECUTABLE}:
|
2020-05-21 15:40:24 +00:00
|
|
|
CGO_ENABLED=1 \
|
2020-01-09 20:50:27 +00:00
|
|
|
GOOS=linux \
|
|
|
|
GOARCH=arm \
|
|
|
|
GOARM=5 \
|
2021-04-09 15:11:51 +00:00
|
|
|
GOPROXY=$(shell go env GOPROXY) \
|
|
|
|
GOPRIVATE=$(shell go env GOPRIVATE) \
|
2020-01-09 20:50:27 +00:00
|
|
|
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
2019-08-26 13:12:32 +00:00
|
|
|
|
2021-03-21 17:47:14 +00:00
|
|
|
bin/linux/arm/7/${EXECUTABLE}:
|
2020-06-27 19:12:00 +00:00
|
|
|
CC=arm-linux-gnueabihf-gcc \
|
2020-05-21 15:40:24 +00:00
|
|
|
CGO_ENABLED=1 \
|
2020-01-09 20:50:27 +00:00
|
|
|
GOOS=linux \
|
|
|
|
GOARCH=arm \
|
|
|
|
GOARM=7 \
|
2021-04-09 15:11:51 +00:00
|
|
|
GOPROXY=$(shell go env GOPROXY) \
|
|
|
|
GOPRIVATE=$(shell go env GOPRIVATE) \
|
2020-01-09 20:50:27 +00:00
|
|
|
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
|
|
|
|
2021-03-21 17:47:14 +00:00
|
|
|
bin/tmp/${EXECUTABLE}:
|
2020-05-21 15:40:24 +00:00
|
|
|
CGO_ENABLED=1 \
|
2021-04-09 15:11:51 +00:00
|
|
|
GOPROXY=$(shell go env GOPROXY) \
|
|
|
|
GOPRIVATE=$(shell go env GOPRIVATE) \
|
2020-01-09 20:50:27 +00:00
|
|
|
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
2019-08-26 13:12:32 +00:00
|
|
|
|
2021-04-10 14:06:47 +00:00
|
|
|
# COMPLETIONS
|
|
|
|
# ==============================================================================
|
|
|
|
bin/tmp/${EXECUTABLE}.sh: bin/tmp/${EXECUTABLE}
|
|
|
|
bin/tmp/${EXECUTABLE} completion bash > ${@}
|
|
|
|
|
|
|
|
bin/tmp/${EXECUTABLE}.fish: bin/tmp/${EXECUTABLE}
|
|
|
|
bin/tmp/${EXECUTABLE} completion fish > ${@}
|
|
|
|
|
|
|
|
bin/tmp/${EXECUTABLE}.zsh: bin/tmp/${EXECUTABLE}
|
|
|
|
bin/tmp/${EXECUTABLE} completion zsh > ${@}
|
|
|
|
|
2021-04-10 14:52:29 +00:00
|
|
|
# UN/INSTALL
|
2021-04-10 14:06:47 +00:00
|
|
|
# ==============================================================================
|
|
|
|
PHONY+=install
|
|
|
|
install: bin/tmp/${EXECUTABLE} bin/tmp/${EXECUTABLE}.sh bin/tmp/${EXECUTABLE}.fish bin/tmp/${EXECUTABLE}.zsh
|
|
|
|
install --directory ${DESTDIR}${PREFIX}/bin
|
|
|
|
install --mode 755 bin/tmp/${EXECUTABLE} ${DESTDIR}${PREFIX}/bin/${EXECUTABLE}
|
2021-04-10 14:52:29 +00:00
|
|
|
|
|
|
|
install --directory ${DESTDIR}/etc/bash_completion.d
|
2021-04-10 14:06:47 +00:00
|
|
|
install --mode 755 bin/tmp/${EXECUTABLE}.sh ${DESTDIR}/etc/bash_completion.d/${EXECUTABLE}.sh
|
2021-04-10 14:52:29 +00:00
|
|
|
|
|
|
|
install --directory ${DESTDIR}/usr/share/fish/vendor_completions.d
|
|
|
|
install --mode 644 bin/tmp/${EXECUTABLE}.fish ${DESTDIR}/usr/share/fish/vendor_completions.d/${EXECUTABLE}.fish
|
|
|
|
|
|
|
|
install --directory ${DESTDIR}/usr/lib/systemd/system
|
|
|
|
install --mode 644 systemd/${EXECUTABLE}.service ${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service
|
|
|
|
|
|
|
|
install --directory ${DESTDIR}/usr/share/licenses/${EXECUTABLE}
|
|
|
|
install --mode 644 LICENSE ${DESTDIR}/usr/share/licenses/${EXECUTABLE}/LICENSE
|
|
|
|
|
|
|
|
PHONY+=uninstall
|
|
|
|
uninstall:
|
|
|
|
-rm --recursive --force \
|
|
|
|
${DESTDIR}${PREFIX}/bin/${EXECUTABLE} \
|
|
|
|
${DESTDIR}/etc/bash_completion.d/${EXECUTABLE}.sh \
|
|
|
|
${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service \
|
|
|
|
${DESTDIR}/usr/share/fish/vendor_completions.d/${EXECUTABLE}.fish \
|
|
|
|
${DESTDIR}/usr/share/licenses/${EXECUTABLE}/LICENSE
|
2021-04-10 14:06:47 +00:00
|
|
|
|
2020-05-31 22:52:54 +00:00
|
|
|
# CLEAN
|
2019-09-04 11:37:50 +00:00
|
|
|
# ==============================================================================
|
|
|
|
PHONY+=clean
|
|
|
|
clean:
|
2020-01-09 20:50:27 +00:00
|
|
|
rm --force --recursive bin/ || true
|
2019-08-26 13:12:32 +00:00
|
|
|
|
2020-05-31 22:52:54 +00:00
|
|
|
# TEST
|
|
|
|
# ==============================================================================
|
|
|
|
PHONY+=test/unit
|
2021-03-21 17:47:14 +00:00
|
|
|
test/unit:
|
2020-05-31 22:52:54 +00:00
|
|
|
go test -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 600s -count=1 ./pkg/...
|
|
|
|
|
2021-04-10 14:06:47 +00:00
|
|
|
PHONY+=test/coverage
|
2020-05-31 22:52:54 +00:00
|
|
|
test/coverage: test/unit
|
|
|
|
go tool cover -html=coverage.txt
|
|
|
|
|
2021-05-16 21:02:46 +00:00
|
|
|
# GOLANGCI-LINT
|
|
|
|
# ==============================================================================
|
|
|
|
PHONY+=golangci-lint
|
|
|
|
golangci-lint:
|
|
|
|
golangci-lint run --concurrency=$(shell nproc)
|
|
|
|
|
|
|
|
# GOSEC
|
|
|
|
# ==============================================================================
|
|
|
|
PHONY+=gosec
|
|
|
|
gosec:
|
|
|
|
gosec $(shell pwd)/...
|
|
|
|
|
2019-09-04 11:37:50 +00:00
|
|
|
# PHONY
|
|
|
|
# ==============================================================================
|
|
|
|
# Declare the contents of the PHONY variable as phony. We keep that information
|
|
|
|
# in a variable so we can use it in if_changed.
|
|
|
|
.PHONY: ${PHONY}
|