fix Makefile

This commit is contained in:
Alexey Avramov 2019-07-23 22:58:13 +09:00
parent af36cb2ed7
commit cfe68fcca5
2 changed files with 20 additions and 14 deletions

View File

@ -1,43 +1,48 @@
DESTDIR ?=
BINDIR ?= /usr/local/bin
SYSTEMDUNITDIR ?= /etc/systemd/system
CONFDIR ?= /etc
MANDIR ?= /usr/share/man/man1
LOGDIR ?= /var/log
SYSTEMDUNITDIR ?= /etc/systemd/system
all:
@ echo "Use: make install, make systemd, make uninstall"
install:
install -d $(DESTDIR)$(BINDIR)
install -m0755 ./nohang $(DESTDIR)$(BINDIR)/nohang
install -m0755 ./nohang_notify_helper $(DESTDIR)$(BINDIR)/nohang_notify_helper
install -m0755 ./oom-sort $(DESTDIR)$(BINDIR)/oom-sort
install -m0755 ./psi-top $(DESTDIR)$(BINDIR)/psi-top
install -m0755 ./psi-monitor $(DESTDIR)$(BINDIR)/psi-monitor
install -m0755 nohang $(DESTDIR)$(BINDIR)/nohang
install -m0755 nohang_notify_helper $(DESTDIR)$(BINDIR)/nohang_notify_helper
install -m0755 oom-sort $(DESTDIR)$(BINDIR)/oom-sort
install -m0755 psi-top $(DESTDIR)$(BINDIR)/psi-top
install -m0755 psi-monitor $(DESTDIR)$(BINDIR)/psi-monitor
install -d $(DESTDIR)$(CONFDIR)/nohang
-git describe --tags --long --dirty > ./version
-install -m0644 ./version $(DESTDIR)$(CONFDIR)/nohang/version
-rm -fvr ./version
-git describe --tags --long --dirty > version
-install -m0644 version $(DESTDIR)$(CONFDIR)/nohang/version
-rm -fv version
install -m0644 ./nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf
install -m0644 ./nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf.default
install -m0644 nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf
install -m0644 nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf.default
install -d $(DESTDIR)$(CONFDIR)/logrotate.d
install -m0644 ./nohang.logrotate $(DESTDIR)$(CONFDIR)/logrotate.d/nohang
install -m0644 nohang.logrotate $(DESTDIR)$(CONFDIR)/logrotate.d/nohang
install -d $(DESTDIR)$(MANDIR)
gzip -c nohang.1 > $(DESTDIR)$(MANDIR)/nohang.1.gz
gzip -c oom-sort.1 > $(DESTDIR)$(MANDIR)/oom-sort.1.gz
-install -d $(DESTDIR)$(SYSTEMDUNITDIR)
-install -m0644 ./nohang.service $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service
-sed "s|:TARGET_BIN:|$(DESTDIR)$(BINDIR)|g;s|:TARGET_CONF:|$(DESTDIR)$(CONFDIR)|g" nohang.service.in > nohang.service
-install -m0644 nohang.service $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service
-rm -fv nohang.service
-chcon -t systemd_unit_file_t $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service
uninstall:
# 'make uninstall' must not fail with error if systemctl is unavailable or returns error
-systemctl stop nohang.service || true
-systemctl disable nohang.service || true
-systemctl daemon-reload
rm -fv $(DESTDIR)$(BINDIR)/nohang
rm -fv $(DESTDIR)$(BINDIR)/nohang_notify_helper
rm -fv $(DESTDIR)$(BINDIR)/oom-sort
@ -54,3 +59,4 @@ systemd:
-systemctl daemon-reload
-systemctl enable nohang.service
-systemctl restart nohang
-systemctl status nohang

View File

@ -3,7 +3,7 @@ Description=Highly configurable OOM prevention daemon
Documentation=man:nohang(1) https://github.com/hakavlad/nohang
[Service]
ExecStart=/usr/local/bin/nohang --config /etc/nohang/nohang.conf
ExecStart=:TARGET_BIN:/nohang --config :TARGET_CONF:/nohang/nohang.conf
Slice=nohang.slice
Restart=always
KillMode=mixed