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.
This commit is contained in:
Benedikt Heine 2017-12-21 20:09:38 +01:00
parent 8f17d6026b
commit 573ea1de20
2 changed files with 45 additions and 7 deletions

View File

@ -8,17 +8,30 @@ ifneq ($(wildcard ./.git/.),)
VERSION := $(shell git describe --tags) VERSION := $(shell git describe --tags)
endif 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 ?= $(shell pkg-config dbus-1 --variable=session_bus_services_dir)
SERVICEDIR_DBUS := ${SERVICEDIR_DBUS} SERVICEDIR_DBUS := ${SERVICEDIR_DBUS}
ifeq (,${SERVICEDIR_DBUS}) ifeq (,${SERVICEDIR_DBUS})
$(error "Failed to query pkg-config for package 'dbus-1'!") $(error "Failed to query pkg-config for package 'dbus-1'!")
endif endif
ifneq (0,${SYSTEMD})
SERVICEDIR_SYSTEMD ?= $(shell pkg-config systemd --variable=systemduserunitdir) SERVICEDIR_SYSTEMD ?= $(shell pkg-config systemd --variable=systemduserunitdir)
SERVICEDIR_SYSTEMD := ${SERVICEDIR_SYSTEMD} SERVICEDIR_SYSTEMD := ${SERVICEDIR_SYSTEMD}
ifeq (,${SERVICEDIR_SYSTEMD}) ifeq (,${SERVICEDIR_SYSTEMD})
$(error "Failed to query pkg-config for package 'systemd'!") $(error "Failed to query pkg-config for package 'systemd'!")
endif endif
endif
LIBS := $(shell pkg-config --libs ${pkg_config_packs}) LIBS := $(shell pkg-config --libs ${pkg_config_packs})
INCS := $(shell pkg-config --cflags ${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 docs/dunst.1: docs/dunst.pod
pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@
.PHONY: service .PHONY: service service-dbus service-systemd
service: service: service-dbus
service-dbus:
@sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service @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 @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service
endif
.PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests .PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests
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: clean-tests:
rm -f test/test test/*.o 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: install-dunst install-doc install-service
install-dunst: dunst doc install-dunst: dunst doc
@ -114,13 +135,26 @@ install-doc:
mkdir -p ${DESTDIR}${PREFIX}/share/dunst mkdir -p ${DESTDIR}${PREFIX}/share/dunst
install -m644 dunstrc ${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 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 install -Dm644 dunst.systemd.service ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service
endif
uninstall: uninstall: uninstall-service
rm -f ${DESTDIR}${PREFIX}/bin/dunst rm -f ${DESTDIR}${PREFIX}/bin/dunst
rm -f ${DESTDIR}${MANPREFIX}/man1/dunst.1 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 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

View File

@ -2,6 +2,10 @@
PREFIX ?= /usr/local PREFIX ?= /usr/local
MANPREFIX = ${PREFIX}/share/man 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 # uncomment to disable parsing of dunstrc
# or use "CFLAGS=-DSTATIC_CONFIG make" to build # or use "CFLAGS=-DSTATIC_CONFIG make" to build
#STATIC= -DSTATIC_CONFIG # Warning: This is deprecated behavior #STATIC= -DSTATIC_CONFIG # Warning: This is deprecated behavior