diff mbox series

[v4l-utils,1/2] configure.ac: autodetect availability of systemd

Message ID 20210303223234.26567-1-u.oelmann@pengutronix.de
State New
Headers show
Series [v4l-utils,1/2] configure.ac: autodetect availability of systemd | expand

Commit Message

Ulrich Ölmann March 3, 2021, 10:32 p.m. UTC
Import systemd's official suggestion [1] how this should be handled in packages
using autoconf.

[1] https://www.freedesktop.org/software/systemd/man/daemon.html#Installing%20systemd%20Service%20Files

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 configure.ac | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index 727730c5ccf4..f62ad7cb25ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -388,7 +388,15 @@  AC_ARG_WITH(udevdir,
 AC_ARG_WITH(systemdsystemunitdir,
 	AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [set systemd system unit directory]),
 	[],
-	[with_systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd || echo /lib/systemd/system`])
+	[with_systemdsystemunitdir=auto])
+AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
+      [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
+       AS_IF([test "x$def_systemdsystemunitdir" = "x"],
+             [AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
+                    [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
+              with_systemdsystemunitdir=no],
+             [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
+AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
 
 # Generic check: works with most distributions
 def_gconv_dir=`for i in /lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib; do if @<:@ -d \$i/gconv @:>@; then echo \$i/gconv; break; fi; done`