services: add fallback systemd unitdir if systemd is not available

Allows building the service files without a systemd dependency by
defining a default systemd user unit directory.

Relevant in Alpine, where we can package the service files in a
subpackage without having systemd in Alpine.

Addresses feedback of https://github.com/linux-speakup/espeakup/pull/64,
therefore superseeds it.
This commit is contained in:
Achill Gilgenast 2026-06-29 15:56:42 +02:00 committed by Samuel Thibault
commit c3c7c6a007
2 changed files with 7 additions and 3 deletions

View file

@ -1,4 +1,4 @@
systemd = dependency('systemd', required: get_option('systemd')) systemd = dependency('systemd')
if systemd.found() if (systemd.found() and get_option('systemd').allowed()) or get_option('systemd').enabled()
subdir('systemd') subdir('systemd')
endif endif

View file

@ -1,4 +1,8 @@
if systemd.found()
unitdir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir') unitdir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir')
else
unitdir = join_paths(prefixdir, get_option('libdir'), 'systemd', 'system')
endif
prefixdir = get_option('prefix') prefixdir = get_option('prefix')
bindir = join_paths(prefixdir, get_option('bindir')) bindir = join_paths(prefixdir, get_option('bindir'))