PKGBUILD/Makefile

89 lines
3.0 KiB
Makefile
Raw Permalink Normal View History

VERSION?=$(shell git describe --abbrev=0)+$(shell date +'%Y%m%d%H%I%S')
2021-04-10 14:06:47 +00:00
EXECUTABLE:=flucky
2021-04-10 14:06:47 +00:00
DESTDIR?=
PREFIX?=/usr/local
# BINARIES
# ==============================================================================
2021-05-26 17:57:47 +00:00
all: ${EXECUTABLE}
2021-05-26 17:57:47 +00:00
${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) \
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
# ==============================================================================
2021-05-26 17:57:47 +00:00
${EXECUTABLE}.sh: ${EXECUTABLE}
${EXECUTABLE} completion bash > ${@}
2021-04-10 14:06:47 +00:00
2021-05-26 17:57:47 +00:00
${EXECUTABLE}.fish: ${EXECUTABLE}
${EXECUTABLE} completion fish > ${@}
2021-04-10 14:06:47 +00:00
2021-05-26 17:57:47 +00:00
${EXECUTABLE}.zsh: ${EXECUTABLE}
${EXECUTABLE} completion zsh > ${@}
2021-04-10 14:06:47 +00:00
2021-04-10 14:52:29 +00:00
# UN/INSTALL
2021-04-10 14:06:47 +00:00
# ==============================================================================
PHONY+=install
2021-05-26 17:57:47 +00:00
install: ${EXECUTABLE} ${EXECUTABLE}.sh ${EXECUTABLE}.fish ${EXECUTABLE}.zsh
2021-04-10 14:06:47 +00:00
install --directory ${DESTDIR}${PREFIX}/bin
2021-05-26 17:57:47 +00:00
install --mode 755 ${EXECUTABLE} ${DESTDIR}${PREFIX}/bin/${EXECUTABLE}
2021-04-10 14:52:29 +00:00
install --directory ${DESTDIR}/usr/lib/systemd/system
install --mode 644 systemd/${EXECUTABLE}.service ${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service
2021-05-26 17:57:47 +00:00
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
2021-04-10 14:52:29 +00:00
PHONY+=uninstall
uninstall:
-rm --recursive --force \
${DESTDIR}${PREFIX}/bin/${EXECUTABLE} \
${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service \
2021-05-26 17:57:47 +00:00
${DESTDIR}${PREFIX}/share/bash-completion/completions/${EXECUTABLE}.sh \
${DESTDIR}${PREFIX}/fish/vendor_completions.d/${EXECUTABLE}.fish \
${DESTDIR}${PREFIX}/licenses/${EXECUTABLE}/LICENSE
2021-04-10 14:06:47 +00:00
# CLEAN
# ==============================================================================
PHONY+=clean
clean:
2021-05-26 17:57:47 +00:00
rm --force --recursive ${EXECUTABLE}* || true
2019-08-26 13:12:32 +00:00
# TEST
# ==============================================================================
PHONY+=test/unit
test/unit:
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
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)/...
# 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}