From bda44605617e964c6ef3254d16949ff6dadde76a Mon Sep 17 00:00:00 2001
From: Rasmus Thomsen <cogitri@exherbo.org>
Date: Wed, 27 Jun 2018 13:56:31 +0200
Subject: [PATCH] build: support building with elogind

elogind is a drop-in replacement for systemd's logind and as
such can be used here
---
 configure.ac | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/configure.ac b/configure.ac
index 8890aa1..8f1375d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1235,6 +1235,11 @@ AC_ARG_ENABLE([systemd-login],
 AC_ARG_ENABLE([systemd-journal],
     AS_HELP_STRING([--disable-systemd-journal],[Disable optional systemd journal support]))
 
+#### elogind support (optional) ####
+
+AC_ARG_ENABLE([elogind-login],
+    AS_HELP_STRING([--disable-elogind-login],[Disable optional elogind login support]))
+
 # Newer systemd's combine their subcomponent libraries into one
 # If it exists, we should use it for the further checks
 
@@ -1282,6 +1287,28 @@ AC_SUBST(HAVE_SYSTEMD_LOGIN)
 AM_CONDITIONAL([HAVE_SYSTEMD_LOGIN], [test "x$HAVE_SYSTEMD_LOGIN" = x1])
 AS_IF([test "x$HAVE_SYSTEMD_LOGIN" = "x1"], AC_DEFINE([HAVE_SYSTEMD_LOGIN], 1, [Have SYSTEMDLOGIN?]))
 
+#### elogind login support (optional) ####
+
+AS_IF([test "x$enable_systemd_login" = "xyes" && test "x$enable_elogind_login" != "xno"],
+    [AC_MSG_ERROR([*** Can't enable systemd-logind and elogind at the same time])])
+
+# Because elogind is a drop-in replacement for systemd's logind we just pretend that
+# we have logind here, so that we don't have to modify any source files
+if test "x$enable_elogind_login" != "xno"; then
+    PKG_CHECK_MODULES(LIBELOGIND, [ libelogind ], HAVE_ELOGIND_LOGIN=1, HAVE_ELOGIND_LOGIN=0)
+    SYSTEMDLOGIN_CFLAGS="$LIBELOGIND_CFLAGS"
+    SYSTEMDLOGIN_LIBS="$LIBELOGIND_LIBS"
+    AC_SUBST(HAVE_ELOGIND_LOGIN)
+    AC_SUBST(SYSTEMDLOGIN_CFLAGS)
+    AC_SUBST(SYSTEMDLOGIN_LIBS)
+fi
+
+AS_IF([test "x$enable_elogind_login" = "xyes" && test "x$HAVE_ELOGIND_LOGIN" = "x0"],
+    [AC_MSG_ERROR([*** Needed elogind login support not found])])
+
+AM_CONDITIONAL([HAVE_ELOGIND_LOGIN], [test "x$HAVE_ELOGIND_LOGIN" = x1])
+AS_IF([test "x$HAVE_ELOGIND_LOGIN" = "x1"], AC_DEFINE([HAVE_SYSTEMD_LOGIN], 1, [Have SYSTEMDLOGIN?]))
+
 #### systemd journal support (optional) ####
 
 AS_IF([test "x$enable_systemd_journal" != "xno"],
@@ -1607,6 +1634,7 @@ AS_IF([test "x$HAVE_ESOUND" = "x1" -a "x$USE_PER_USER_ESOUND_SOCKET" = "x1"], EN
 AS_IF([test "x$HAVE_GCOV" = "x1"], ENABLE_GCOV=yes, ENABLE_GCOV=no)
 AS_IF([test "x$HAVE_LIBCHECK" = "x1"], ENABLE_TESTS=yes, ENABLE_TESTS=no)
 AS_IF([test "x$enable_legacy_database_entry_format" != "xno"], ENABLE_LEGACY_DATABASE_ENTRY_FORMAT=yes, ENABLE_LEGACY_DATABASE_ENTRY_FORMAT=no)
+AS_IF([test "x$HAVE_ELOGIND_LOGIN" = "x1"], ENABLE_ELOGIND_LOGIN=yes, ENABLE_ELOGIND_LOGIN=no)
 
 echo "
  ---{ $PACKAGE_NAME $VERSION }---
@@ -1675,6 +1703,7 @@ echo "
     Enable per-user EsounD socket: ${ENABLE_PER_USER_ESOUND_SOCKET}
     Force preopen:                 ${FORCE_PREOPEN}
     Preopened modules:             ${PREOPEN_MODS}
+    Enable elogind:                ${ENABLE_ELOGIND_LOGIN}
 
     Legacy Database Entry Support: ${ENABLE_LEGACY_DATABASE_ENTRY_FORMAT}
 "
-- 
2.18.0