build: easier selection of session tracking

Using --with-session-tracking=xxx you can select the backend
you want from among CK, systemd, or none.
This commit is contained in:
Dan Williams 2012-02-01 16:49:46 -06:00
parent 20035ad443
commit f900522308
3 changed files with 24 additions and 61 deletions

View file

@ -312,7 +312,7 @@ else
fi
AC_SUBST(UDEV_BASE_DIR)
# systemd
# systemd unit support
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[],
@ -322,37 +322,27 @@ if test "x$with_systemdsystemunitdir" != xno; then
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
SESSION_TRACKING=none
dnl
dnl Disable ConsoleKit support
dnl
AC_ARG_WITH(ck, AS_HELP_STRING([--without-ck], [Build NetworkManager without ConsoleKit session tracking support]))
AM_CONDITIONAL(WITH_CONSOLEKIT, test x"$with_ck" != xno)
no_ck=0
if test x"$with_ck" = x"no"; then
no_ck="1"
else
with_ck="yes"
SESSION_TRACKING=ConsoleKit
fi
AC_DEFINE_UNQUOTED(NO_CONSOLEKIT, $no_ck, [Define to disable use of ConsoleKit])
# systemd session tracking
AC_ARG_ENABLE([systemd],
AS_HELP_STRING([--enable-systemd], [Use systemd for session tracking]),
[with_systemd=$enableval],
[with_systemd=no])
if test "$with_systemd" = "yes" ; then
PKG_CHECK_MODULES(SYSTEMD, [libsystemd-login])
SESSION_TRACKING=systemd
AC_ARG_WITH(session-tracking, AS_HELP_STRING([--with-session-tracking=systemd], [Build NetworkManager with specific session tracking support]))
if test "z$with_session_tracking" = "z"; then
# Default to ConsoleKit session tracking like we used before
with_session_tracking=ck
fi
case $with_session_tracking in
ck|none) ;;
systemd)
PKG_CHECK_MODULES(SYSTEMD, [libsystemd-login])
;;
*)
AC_MSG_ERROR(--with-session-tracking must be one of [none, ck, systemd])
;;
esac
AC_SUBST(SYSTEMD_CFLAGS)
AC_SUBST(SYSTEMD_LIBS)
AM_CONDITIONAL(SESSION_TRACKING_CK, test "x$with_session_tracking" = "xck")
AM_CONDITIONAL(SESSION_TRACKING_SYSTEMD, test "x$with_session_tracking" = "xsystemd")
AM_CONDITIONAL(WITH_SYSTEMD, [test "$with_systemd" = "yes"], [Using systemd])
have_libnl="no"
PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [have_libnl3=yes], [have_libnl3=no])
PKG_CHECK_MODULES(LIBNL_ROUTE3, libnl-route-3.0, [have_libnl_route3=yes], [have_libnl_route3=no])
@ -806,7 +796,7 @@ else
echo PolicyKit support: no
fi
echo Session tracking: ${SESSION_TRACKING}
echo Session tracking: ${with_session_tracking}
if test "${enable_wimax}" = "yes"; then
echo WiMAX support: yes

View file

@ -187,13 +187,14 @@ NetworkManager_SOURCES = \
nm-session-utils.c \
nm-session-utils.h
if WITH_SYSTEMD
NetworkManager_SOURCES += \
nm-session-monitor-systemd.c
if SESSION_TRACKING_SYSTEMD
NetworkManager_SOURCES += nm-session-monitor-systemd.c
else
NetworkManager_SOURCES += \
nm-session-monitor.c
if SESSION_TRACKING_CK
NetworkManager_SOURCES += nm-session-monitor-ck.c
else
NetworkManager_SOURCES += nm-session-monitor-null.c
endif
endif
nm-access-point-glue.h: $(top_srcdir)/introspection/nm-access-point.xml

View file

@ -234,10 +234,6 @@ ensure_database (NMSessionMonitor *self, GError **error)
{
gboolean ret = FALSE;
#if NO_CONSOLEKIT
return TRUE;
#endif
if (self->database != NULL) {
struct stat statbuf;
@ -284,10 +280,6 @@ nm_session_monitor_init (NMSessionMonitor *self)
GError *error = NULL;
GFile *file;
#if NO_CONSOLEKIT
return;
#endif
/* Sessions-by-user is responsible for destroying the Session objects */
self->sessions_by_user = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, (GDestroyNotify) session_free);
@ -392,12 +384,6 @@ nm_session_monitor_user_has_session (NMSessionMonitor *monitor,
{
Session *s;
#if NO_CONSOLEKIT
if (!user_to_uid (username, out_uid, error))
return FALSE;
return TRUE;
#endif
if (!ensure_database (monitor, error))
return FALSE;
@ -435,12 +421,6 @@ nm_session_monitor_uid_has_session (NMSessionMonitor *monitor,
{
Session *s;
#if NO_CONSOLEKIT
if (!uid_to_user (uid, out_user, error))
return FALSE;
return TRUE;
#endif
if (!ensure_database (monitor, error))
return FALSE;
@ -477,10 +457,6 @@ nm_session_monitor_user_active (NMSessionMonitor *monitor,
{
Session *s;
#if NO_CONSOLEKIT
return TRUE;
#endif
if (!ensure_database (monitor, error))
return FALSE;
@ -515,10 +491,6 @@ nm_session_monitor_uid_active (NMSessionMonitor *monitor,
{
Session *s;
#if NO_CONSOLEKIT
return TRUE;
#endif
if (!ensure_database (monitor, error))
return FALSE;