Install systemd services with autotools
Change-Id: Ic4875b74bcf2b6232d915070b77fc202a03ef997
diff --git a/configure.ac b/configure.ac
index 734ac99..ba44f98 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,6 +120,23 @@
CPPFLAGS="$CPPFLAGS -pg"
fi
+# https://www.freedesktop.org/software/systemd/man/daemon.html
+PKG_PROG_PKG_CONFIG
+AC_ARG_WITH([systemdsystemunitdir],
+ [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
+ [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"],
+ [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
+ with_systemdsystemunitdir=no],
+ [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
+AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
+ [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
+AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
+
AC_MSG_RESULT([CFLAGS="$CFLAGS"])
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
@@ -127,6 +144,8 @@
AM_CONFIG_HEADER(config.h)
AC_OUTPUT(
+ contrib/Makefile
+ contrib/systemd/Makefile
doc/Makefile
doc/examples/Makefile
src/Makefile