2021-04-23 14:02:15 +00:00
|
|
|
# VERSION
|
|
|
|
VERSION ?= $(shell git describe --abbrev=0)+hash.$(shell git rev-parse --short HEAD)
|
|
|
|
|
2022-03-11 09:28:30 +00:00
|
|
|
DESTDIR ?=
|
|
|
|
PREFIX ?= /usr/local
|
2021-04-23 14:02:15 +00:00
|
|
|
EXECUTABLE := dyndns-client
|
|
|
|
|
|
|
|
# BINARIES
|
|
|
|
# ==============================================================================
|
2022-03-11 09:28:30 +00:00
|
|
|
all: ${EXECUTABLE}
|
2021-04-23 14:02:15 +00:00
|
|
|
|
2022-03-11 09:28:30 +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
|
2022-03-11 09:28:30 +00:00
|
|
|
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
|
2022-03-11 09:28:30 +00:00
|
|
|
install: ${EXECUTABLE}
|
2021-04-23 14:02:15 +00:00
|
|
|
install --directory ${DESTDIR}${PREFIX}/bin
|
2022-03-11 09:28:30 +00:00
|
|
|
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}
|