dyndns-client/Makefile

54 lines
1.6 KiB
Makefile
Raw Normal View History

2021-04-23 14:02:15 +00:00
# VERSION
VERSION ?= $(shell git describe --abbrev=0)+hash.$(shell git rev-parse --short HEAD)
DESTDIR ?=
PREFIX ?= /usr/local
2021-04-23 14:02:15 +00:00
EXECUTABLE := dyndns-client
# BINARIES
# ==============================================================================
all: ${EXECUTABLE}
2021-04-23 14:02:15 +00:00
${EXECUTABLE}:
2021-04-23 14:02:15 +00:00
CGO_ENABLED=0 \
GOPRIVATE=$(shell go env GOPRIVATE) \
GOPROXY=$(shell go env GOPROXY) \
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
# TEST
# ==============================================================================
PHONY+=test
test: clean ${EXECUTABLE}
2021-04-23 14:02:15 +00:00
go test -v ./pkg/...
# CLEAN
# ==============================================================================
PHONY+=clean
clean:
rm --force ${EXECUTABLE} || true
rm --force --recursive bin || true
# UN/INSTALL
# ==============================================================================
PHONY+=install
install: ${EXECUTABLE}
2021-04-23 14:02:15 +00:00
install --directory ${DESTDIR}${PREFIX}/bin
install --mode 755 ${EXECUTABLE} ${DESTDIR}${PREFIX}/bin/${EXECUTABLE}
2021-04-23 14:02:15 +00:00
install --directory ${DESTDIR}/usr/lib/systemd/system
install --mode 644 systemd/${EXECUTABLE}.service ${DESTDIR}/usr/lib/systemd/system
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}/usr/lib/systemd/system/${EXECUTABLE}.service \
${DESTDIR}/usr/share/licenses/${EXECUTABLE}/LICENSE
# PHONY
# ==============================================================================
.PHONY: ${PHONY}