Skip to content

Commit

Permalink
Skip systemd service install if SYSTEMD_SYSTEM_DIR is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
rhansen committed May 17, 2024
1 parent 89d4f3c commit 1c0eff1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ PREFIX?=/usr/local
CONFIG_DIR?=/etc/keyd
SOCKET_PATH=/var/run/keyd.socket

# If this variable is set to the empty string, no systemd unit files will be
# installed.
SYSTEMD_SYSTEM_DIR = /usr/lib/systemd/system

CFLAGS:=-DVERSION=\"v$(VERSION)\ \($(COMMIT)\)\" \
Expand Down Expand Up @@ -51,15 +53,15 @@ man:
scdoc < "$$f" | gzip > "$$target"; \
done
install:
@if [ -e /run/systemd/system ]; then \
@if [ -e /run/systemd/system ] && [ -n '$(SYSTEMD_SYSTEM_DIR)' ]; then \
mkdir -p '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)'; \
install -Dm644 keyd.service '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd.service'; \
else \
elif [ -n '$(SYSTEMD_SYSTEM_DIR)' ]; then \
echo "NOTE: systemd not found, you will need to manually add keyd to your system's init process."; \
fi

@if [ "$(VKBD)" = "usb-gadget" ]; then \
install -Dm644 src/vkbd/usb-gadget.service '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd-usb-gadget.service'; \
{ [ -z '$(SYSTEMD_SYSTEM_DIR)' ] || install -Dm644 src/vkbd/usb-gadget.service '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd-usb-gadget.service'; } && \
install -Dm755 src/vkbd/usb-gadget.sh $(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh; \
fi

Expand All @@ -82,14 +84,15 @@ install:

uninstall:
-groupdel keyd
[ -z '$(SYSTEMD_SYSTEM_DIR)' ] || rm -f \
'$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd.service' \
'$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd-usb-gadget.service'
rm -rf $(DESTDIR)$(PREFIX)/bin/keyd \
$(DESTDIR)$(PREFIX)/bin/keyd-application-mapper \
$(DESTDIR)$(PREFIX)/share/doc/keyd/ \
$(DESTDIR)$(PREFIX)/share/man/man1/keyd*.gz \
$(DESTDIR)$(PREFIX)/share/keyd/ \
'$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd-usb-gadget.service' \
$(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh \
'$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd.service'
$(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh
clean:
-rm -rf bin keyd.service src/vkbd/usb-gadget.service
test:
Expand Down

0 comments on commit 1c0eff1

Please sign in to comment.