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
SYSCTL=$(shell which systemctl)
SYSCTL=${shell which systemctl}
DESTDIR=/
CONFDIR=/etc/$(TARGET)
SYSDSERVICEDIR=/etc/systemd/system
INSTALL_BINDIR=${DESTDIR}usr/bin
INSTALL_CONFIGDIR=${DESTDIR}etc/${TARGET}
INSTALL_SYSDSERVICEDIR=${DESTDIR}usr/lib/systemd/system
LDFLAGS=-ldflags "-s -w"
all: $(TARGET)
all: ${TARGET}
$(TARGET): main.go
go build $(LDFLAGS)
${TARGET}: main.go
go build ${LDFLAGS}
install:
install -m 0755 $(TARGET) /usr/bin/$(TARGET)
mkdir -p -m 0755 $(CONFDIR)
install -m 0644 config.example.json $(CONFDIR)/config.example.json
install -Dm 0755 ${TARGET} ${INSTALL_BINDIR}/${TARGET}
install -Dm 0644 config.example.json ${INSTALL_CONFIGDIR}/config.json
install-service:
install -m 0644 $(TARGET).service $(SYSDSERVICEDIR)/$(TARGET).service
$(SYSCTL) daemon-reload
install -Dm 0644 ${TARGET}.service ${INSTALL_SYSDSERVICEDIR}/${TARGET}.service
${SYSCTL} daemon-reload
uninstall:
rm /usr/bin/$(TARGET)
rm ${INSTALL_BINDIR}/${TARGET}
uninstall-service:
$(SYSCTL) stop $(TARGET).service
$(SYSCTL) disable $(TARGET).service
rm $(SYSDSERVICEDIR)/$(TARGET).service
$(SYSCTL) daemon-reload
${SYSCTL} stop ${TARGET}.service
${SYSCTL} disable ${TARGET}.service
rm ${INSTALL_SYSDSERVICEDIR}/${TARGET}.service
${SYSCTL} daemon-reload
clean:
go clean