1
0

[Makefile] $() -> ${}. Use install the right way. Make it ready for PKGBUILD using DESTDIR. Added clean target.

This commit is contained in:
Alexander Andreev 2021-12-24 21:17:36 +04:00
parent 230034da27
commit e559b11b08
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -1,31 +1,35 @@
TARGET=httpprocwatchd TARGET=httpprocwatchd
SYSCTL=$(shell which systemctl) SYSCTL=${shell which systemctl}
DESTDIR=/
CONFDIR=/etc/$(TARGET) INSTALL_BINDIR=${DESTDIR}usr/bin
SYSDSERVICEDIR=/etc/systemd/system INSTALL_CONFIGDIR=${DESTDIR}etc/${TARGET}
INSTALL_SYSDSERVICEDIR=${DESTDIR}usr/lib/systemd/system
LDFLAGS=-ldflags "-s -w" LDFLAGS=-ldflags "-s -w"
all: $(TARGET) all: ${TARGET}
$(TARGET): main.go ${TARGET}: main.go
go build $(LDFLAGS) go build ${LDFLAGS}
install: install:
install -m 0755 $(TARGET) /usr/bin/$(TARGET) install -Dm 0755 ${TARGET} ${INSTALL_BINDIR}/${TARGET}
mkdir -p -m 0755 $(CONFDIR) install -Dm 0644 config.example.json ${INSTALL_CONFIGDIR}/config.json
install -m 0644 config.example.json $(CONFDIR)/config.example.json
install-service: install-service:
install -m 0644 $(TARGET).service $(SYSDSERVICEDIR)/$(TARGET).service install -Dm 0644 ${TARGET}.service ${INSTALL_SYSDSERVICEDIR}/${TARGET}.service
$(SYSCTL) daemon-reload ${SYSCTL} daemon-reload
uninstall: uninstall:
rm /usr/bin/$(TARGET) rm ${INSTALL_BINDIR}/${TARGET}
uninstall-service: uninstall-service:
$(SYSCTL) stop $(TARGET).service ${SYSCTL} stop ${TARGET}.service
$(SYSCTL) disable $(TARGET).service ${SYSCTL} disable ${TARGET}.service
rm $(SYSDSERVICEDIR)/$(TARGET).service rm ${INSTALL_SYSDSERVICEDIR}/${TARGET}.service
$(SYSCTL) daemon-reload ${SYSCTL} daemon-reload
clean:
go clean