89 lines
3.0 KiB
Makefile
89 lines
3.0 KiB
Makefile
VERSION?=$(shell git describe --abbrev=0)+$(shell date +'%Y%m%d%H%I%S')
|
|
|
|
EXECUTABLE:=flucky
|
|
|
|
DESTDIR?=
|
|
PREFIX?=/usr/local
|
|
|
|
# BINARIES
|
|
# ==============================================================================
|
|
all: ${EXECUTABLE}
|
|
|
|
${EXECUTABLE}:
|
|
CGO_ENABLED=1 \
|
|
GOPROXY=$(shell go env GOPROXY) \
|
|
GOPRIVATE=$(shell go env GOPRIVATE) \
|
|
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
|
|
|
# COMPLETIONS
|
|
# ==============================================================================
|
|
${EXECUTABLE}.sh: ${EXECUTABLE}
|
|
${EXECUTABLE} completion bash > ${@}
|
|
|
|
${EXECUTABLE}.fish: ${EXECUTABLE}
|
|
${EXECUTABLE} completion fish > ${@}
|
|
|
|
${EXECUTABLE}.zsh: ${EXECUTABLE}
|
|
${EXECUTABLE} completion zsh > ${@}
|
|
|
|
# UN/INSTALL
|
|
# ==============================================================================
|
|
PHONY+=install
|
|
install: ${EXECUTABLE} ${EXECUTABLE}.sh ${EXECUTABLE}.fish ${EXECUTABLE}.zsh
|
|
install --directory ${DESTDIR}${PREFIX}/bin
|
|
install --mode 755 ${EXECUTABLE} ${DESTDIR}${PREFIX}/bin/${EXECUTABLE}
|
|
|
|
install --directory ${DESTDIR}/usr/lib/systemd/system
|
|
install --mode 644 systemd/${EXECUTABLE}.service ${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service
|
|
|
|
install --directory ${DESTDIR}${PREFIX}/share/bash-completion/completions/
|
|
install --mode 644 ${EXECUTABLE}.sh ${DESTDIR}${PREFIX}/share/bash-completion/completions/${EXECUTABLE}.sh
|
|
|
|
install --directory ${DESTDIR}${PREFIX}/fish/vendor_completions.d
|
|
install --mode 644 ${EXECUTABLE}.fish ${DESTDIR}${PREFIX}/fish/vendor_completions.d/${EXECUTABLE}.fish
|
|
|
|
install --directory ${DESTDIR}${PREFIX}/licenses/${EXECUTABLE}
|
|
install --mode 644 LICENSE ${DESTDIR}${PREFIX}/licenses/${EXECUTABLE}/LICENSE
|
|
|
|
PHONY+=uninstall
|
|
uninstall:
|
|
-rm --recursive --force \
|
|
${DESTDIR}${PREFIX}/bin/${EXECUTABLE} \
|
|
${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service \
|
|
${DESTDIR}${PREFIX}/share/bash-completion/completions/${EXECUTABLE}.sh \
|
|
${DESTDIR}${PREFIX}/fish/vendor_completions.d/${EXECUTABLE}.fish \
|
|
${DESTDIR}${PREFIX}/licenses/${EXECUTABLE}/LICENSE
|
|
|
|
# CLEAN
|
|
# ==============================================================================
|
|
PHONY+=clean
|
|
clean:
|
|
rm --force --recursive ${EXECUTABLE}* || true
|
|
|
|
# TEST
|
|
# ==============================================================================
|
|
PHONY+=test/unit
|
|
test/unit:
|
|
go test -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 600s -count=1 ./pkg/...
|
|
|
|
PHONY+=test/coverage
|
|
test/coverage: test/unit
|
|
go tool cover -html=coverage.txt
|
|
|
|
# GOLANGCI-LINT
|
|
# ==============================================================================
|
|
PHONY+=golangci-lint
|
|
golangci-lint:
|
|
golangci-lint run --concurrency=$(shell nproc)
|
|
|
|
# GOSEC
|
|
# ==============================================================================
|
|
PHONY+=gosec
|
|
gosec:
|
|
gosec $(shell pwd)/...
|
|
|
|
# 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} |