[gnome-disk-utility] build: add elogind support for seat retrieval



commit af74d38043903a936a0a9c6907c6ae06c547bacc
Author: Mart Raudsepp <leio gentoo org>
Date:   Tue Apr 9 13:16:46 2019 +0300

    build: add elogind support for seat retrieval

 meson.build            | 21 ++++++++++++---------
 meson_options.txt      |  3 ++-
 src/libgdu/gduutils.c  |  4 ++--
 src/libgdu/meson.build |  5 +----
 4 files changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/meson.build b/meson.build
index a5149c8e..ac641928 100644
--- a/meson.build
+++ b/meson.build
@@ -3,7 +3,7 @@ project(
   version: '3.32.0',
   license: 'GPL2.0',
   default_options: 'buildtype=debugoptimized',
-  meson_version: '>= 0.43.0'
+  meson_version: '>= 0.47.0'
 )
 
 gdu_name = 'gnome-disk-utility'
@@ -75,13 +75,16 @@ libnotify_dep = dependency('libnotify', version: '>= 0.7')
 liblzma_dep = dependency('liblzma', version: '>= 5.0.5')
 m_dep = cc.find_library('m')
 
-# *** Check for libsystemd ***
-enable_libsystemd = get_option('libsystemd')
-if enable_libsystemd
-  libsystemd_dep = dependency('libsystemd', version: '>= 209', required: false)
-  config_h.set('HAVE_LIBSYSTEMD', libsystemd_dep.found(),
-               description: 'Define to 1 if libsystemd is available')
+# *** Check for logind ***
+assert(not (get_option('libsystemd').enabled() and get_option('libelogind').enabled()), 'Can not support 
systemd and elogind at once')
+if not get_option('libelogind').enabled()
+  logind_dep = dependency('libsystemd', version: '>= 209', required: get_option('libsystemd'))
 endif
+if get_option('libelogind').enabled() or not logind_dep.found()
+  logind_dep = dependency('libelogind', version: '>= 209', required: get_option('libelogind'))
+endif
+config_h.set('HAVE_LOGIND', logind_dep.found(),
+             description: 'Define to 1 if logind API is available')
 
 gnome = import('gnome')
 i18n = import('i18n')
@@ -123,9 +126,9 @@ output += '        libexecdir:                 ' + gdu_libexecdir + '\n'
 output += '        localedir:                  ' + gdu_localedir + '\n'
 output += '        mandir:                     ' + gdu_mandir + '\n'
 output += '        sysconfdir:                 ' + gdu_sysconfdir + '\n\n'
-output += '        Use libsystemd:             ' + enable_libsystemd.to_string() + '\n'
+output += '        Use logind:                 ' + logind_dep.found().to_string() + '\n'
 output += '        Build g-s-d plug-in:        ' + enable_gsd_plugin.to_string() + '\n\n'
 output += '        compiler:                   ' + cc.get_id() + '\n'
 output += '        cflags:                     ' + ' '.join(compiler_flags) + '\n\n'
-output += '        (Change with: meson configure BUILDDIR -D libsystemd=true|false -D 
gsd_plugin=true|false)\n\n'
+output += '        (Change with: meson configure BUILDDIR -D libelogind=auto|enabled|disabled -D 
libsystemd=auto|enabled|disabled -D gsd_plugin=true|false)\n\n'
 message(output)
diff --git a/meson_options.txt b/meson_options.txt
index 952f5d24..895fc115 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,2 +1,3 @@
-option('libsystemd', type: 'boolean', value: true, description: 'build with libsystemd')
+option('libelogind', type: 'feature', value: 'auto', description: 'build with libelogind')
+option('libsystemd', type: 'feature', value: 'auto', description: 'build with libsystemd')
 option('gsd_plugin', type: 'boolean', value: true, description: 'build gnome-settings-daemon plug-in')
diff --git a/src/libgdu/gduutils.c b/src/libgdu/gduutils.c
index 59a26f3a..bff70304 100644
--- a/src/libgdu/gduutils.c
+++ b/src/libgdu/gduutils.c
@@ -19,7 +19,7 @@
 # include <features.h>
 #endif
 
-#if defined(HAVE_LIBSYSTEMD)
+#if defined(HAVE_LOGIND)
 #include <systemd/sd-login.h>
 #endif
 
@@ -405,7 +405,7 @@ gdu_options_update_entry_option (GtkWidget       *options_entry,
   g_free (opts);
 }
 
-#if defined(HAVE_LIBSYSTEMD)
+#if defined(HAVE_LOGIND)
 
 const gchar *
 gdu_utils_get_seat (void)
diff --git a/src/libgdu/meson.build b/src/libgdu/meson.build
index 00f7edd7..0693b229 100644
--- a/src/libgdu/meson.build
+++ b/src/libgdu/meson.build
@@ -17,14 +17,11 @@ deps = [
   udisk_dep,
   gtk_dep,
   libsecret_dep,
+  logind_dep,
   pwquality_dep,
   m_dep
 ]
 
-if enable_libsystemd
-  deps += libsystemd_dep
-endif
-
 cflags = [
   '-DPACKAGE_DATA_DIR="@0@"'.format(gdu_datadir),
   '-DG_LOG_DOMAIN="libgdu"',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]