From 573ea1de20c12db0d04705a95431418ae8d6271a Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 21 Dec 2017 20:09:38 +0100 Subject: [PATCH] Use systemd as a soft dependency Dunst does not neccessarily need systemd. Dunst gets started primarily via DBus. The systemd service is useful on systemd init based systems, but won't have any impact on non-systemd systems. To make systemd a soft dependency is neccessary, as pkg-config now also queries the systemd.pc file, which won't exist on non systemd systems. --- Makefile | 48 +++++++++++++++++++++++++++++++++++++++++------- config.mk | 4 ++++ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 9567d47..f4ff0ac 100644 --- a/Makefile +++ b/Makefile @@ -8,17 +8,30 @@ ifneq ($(wildcard ./.git/.),) VERSION := $(shell git describe --tags) endif +ifeq (,${SYSTEMD}) +# Check for systemctl to avoid discrepancies on systems, where +# systemd is installed, but systemd.pc is in another package +systemctl := $(shell command -v systemctl >/dev/null && echo systemctl) +ifeq (systemctl,${systemctl}) +SYSTEMD := 1 +else +SYSTEMD := 0 +endif +endif + SERVICEDIR_DBUS ?= $(shell pkg-config dbus-1 --variable=session_bus_services_dir) SERVICEDIR_DBUS := ${SERVICEDIR_DBUS} ifeq (,${SERVICEDIR_DBUS}) $(error "Failed to query pkg-config for package 'dbus-1'!") endif +ifneq (0,${SYSTEMD}) SERVICEDIR_SYSTEMD ?= $(shell pkg-config systemd --variable=systemduserunitdir) SERVICEDIR_SYSTEMD := ${SERVICEDIR_SYSTEMD} ifeq (,${SERVICEDIR_SYSTEMD}) $(error "Failed to query pkg-config for package 'systemd'!") endif +endif LIBS := $(shell pkg-config --libs ${pkg_config_packs}) INCS := $(shell pkg-config --cflags ${pkg_config_packs}) @@ -78,10 +91,15 @@ doc: docs/dunst.1 docs/dunst.1: docs/dunst.pod pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ -.PHONY: service -service: +.PHONY: service service-dbus service-systemd +service: service-dbus +service-dbus: @sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service +ifneq (0,${SYSTEMD}) +service: service-systemd +service-systemd: @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service +endif .PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests clean: clean-dunst clean-dunstify clean-doc clean-tests @@ -101,7 +119,10 @@ clean-doc: clean-tests: rm -f test/test test/*.o -.PHONY: install install-dunst install-doc install-service uninstall +.PHONY: install install-dunst install-doc \ + install-service install-service-dbus install-service-systemd \ + uninstall \ + uninstall-service uninstall-service-dbus uninstall-service-systemd install: install-dunst install-doc install-service install-dunst: dunst doc @@ -114,13 +135,26 @@ install-doc: mkdir -p ${DESTDIR}${PREFIX}/share/dunst install -m644 dunstrc ${DESTDIR}${PREFIX}/share/dunst -install-service: service +install-service: service install-service-dbus +install-service-dbus: install -Dm644 org.knopwob.dunst.service ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service +ifneq (0,${SYSTEMD}) +install-service: install-service-systemd +install-service-systemd: install -Dm644 dunst.systemd.service ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service +endif -uninstall: +uninstall: uninstall-service rm -f ${DESTDIR}${PREFIX}/bin/dunst rm -f ${DESTDIR}${MANPREFIX}/man1/dunst.1 - rm -f ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service - rm -f ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service rm -rf ${DESTDIR}${PREFIX}/share/dunst + +uninstall-service: uninstall-service-dbus +uninstall-service-dbus: + rm -f ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service + +ifneq (0,${SYSTEMD}) +uninstall-service: uninstall-service-systemd +uninstall-service-systemd: + rm -f ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service +endif diff --git a/config.mk b/config.mk index 7b26a48..47811ac 100644 --- a/config.mk +++ b/config.mk @@ -2,6 +2,10 @@ PREFIX ?= /usr/local MANPREFIX = ${PREFIX}/share/man +# Disable systemd service file installation, +# if you don't want to use systemd albeit installed +#SYSTEMD ?= 0 + # uncomment to disable parsing of dunstrc # or use "CFLAGS=-DSTATIC_CONFIG make" to build #STATIC= -DSTATIC_CONFIG # Warning: This is deprecated behavior