Detecting systemduserunitdir with pkg-config
configure.ac contains:
# It is correct for this to be in ${prefix}/lib, even on systems where that
# does not match ${libdir}. This is what systemd uses on such platforms.
AC_ARG_WITH([systemduserunitdir],
AS_HELP_STRING([--with-systemduserunitdir=PATH],
[Set directory for systemd user units, or 'no' to disable]
[[default=${prefix}/lib/systemd/user]]),
[systemd_userdir="$withval"],
[systemd_userdir='${prefix}/lib/systemd/user'])
AC_SUBST([systemd_userdir])
AM_CONDITIONAL([WITH_SYSTEMD_USER_UNITS], [test "x$systemd_userdir" != "xno"])
If my prefix is /usr/local, then sysemduserunitdir gets /usr/local/lib/systemd/user, a path that is not mentioned at https://www.freedesktop.org/software/systemd/man/systemd.unit.html .
Use pkg-config --variable=systemduserunitdir systemd
instead, as pulseaudio does (https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/configure.ac#n1252).