diff options
author | Thomas Haller <thaller@redhat.com> | 2018-08-27 18:18:49 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-08-27 18:18:49 +0200 |
commit | e763a07a6e09499e2fca47859256fe42da8bc651 (patch) | |
tree | 0a052a48f32824ffd4eb7b8e97ded1876b11ecb1 | |
parent | 68691eb0097281972e5fa80088b2804d33e5a232 (diff) | |
parent | 1dd63580df2b6d6c8c08e43bd0ae7c2407611415 (diff) | |
download | NetworkManager-e763a07a6e09499e2fca47859256fe42da8bc651.tar.gz |
build: merge branch 'th/build-ifdef-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/187
-rw-r--r-- | config.h.meson | 3 | ||||
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | meson.build | 93 | ||||
-rw-r--r-- | meson_options.txt | 4 | ||||
-rw-r--r-- | src/devices/ovs/nm-ovsdb.c | 2 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 2 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-helper.c | 2 | ||||
-rw-r--r-- | src/meson.build | 10 | ||||
-rw-r--r-- | src/nm-logging.h | 6 | ||||
-rw-r--r-- | src/nm-session-monitor.c | 34 | ||||
-rw-r--r-- | src/platform/nm-linux-platform.c | 4 |
11 files changed, 89 insertions, 80 deletions
diff --git a/config.h.meson b/config.h.meson index 06190aae11..c5fbf5fab3 100644 --- a/config.h.meson +++ b/config.h.meson @@ -1,9 +1,6 @@ /* Define if building universal (internal helper macro) */ #mesondefine AC_APPLE_UNIVERSAL_BUILD -/* Path to ConsoleKit database */ -#mesondefine CKDB_PATH - /* Define to path of dhclient binary */ #mesondefine DHCLIENT_PATH diff --git a/configure.ac b/configure.ac index 0ed61a13f4..ea1c43f12f 100644 --- a/configure.ac +++ b/configure.ac @@ -444,6 +444,8 @@ fi if test "$have_systemd_logind" = "yes"; then AC_DEFINE([SESSION_TRACKING_SYSTEMD], 1, [Define to 1 if libsystemd-login is available]) session_tracking="$session_tracking, systemd-logind" +else + AC_DEFINE([SESSION_TRACKING_SYSTEMD], 0, [Define to 1 if libsystemd-login is available]) fi if test "$use_elogind" = "yes" -a "$have_systemd_logind" = "yes"; then @@ -460,12 +462,15 @@ fi if test "$have_elogind" = "yes"; then AC_DEFINE([SESSION_TRACKING_ELOGIND], 1, [Define to 1 if libelogin is available]) session_tracking="$session_tracking, elogind" +else + AC_DEFINE([SESSION_TRACKING_ELOGIND], 0, [Define to 1 if libelogin is available]) fi if test "$use_consolekit" = "yes"; then AC_DEFINE([SESSION_TRACKING_CONSOLEKIT], 1, [Define to 1 if ConsoleKit is available]) - AC_DEFINE([CKDB_PATH], "/var/run/ConsoleKit/database", [Path to ConsoleKit database]) session_tracking="$session_tracking, consolekit" +else + AC_DEFINE([SESSION_TRACKING_CONSOLEKIT], 0, [Define to 1 if ConsoleKit is available]) fi session_tracking="$(printf '%s' "${session_tracking}" | sed 's/^, //')" @@ -1111,6 +1116,8 @@ if test "${enable_more_logging}" = ""; then fi if test "${enable_more_logging}" = "yes"; then AC_DEFINE(NM_MORE_LOGGING, [1], [Define if more debug logging is enabled]) +else + AC_DEFINE(NM_MORE_LOGGING, [0], [Define if more debug logging is enabled]) fi NM_LTO diff --git a/meson.build b/meson.build index 44944d3162..4695efb2a2 100644 --- a/meson.build +++ b/meson.build @@ -210,6 +210,8 @@ if jansson_dep.found() endif libsystemd_dep = dependency('libsystemd', version: '>= 209', required: false) +libsystemd_login_dep = dependency('libsystemd-login', version: '>= 183', required: false) + config_h.set10('HAVE_LIBSYSTEMD', libsystemd_dep.found()) systemd_dep = dependency('systemd', required: false) @@ -347,63 +349,70 @@ config_h.set_quoted('NM_CONFIG_DEFAULT_LOGGING_BACKEND', config_logging_backend_ session_tracking = get_option('session_tracking') session_trackers = [] -enable_session_tracking = (session_tracking != 'no') - -enable_consolekit = get_option('consolekit') -if enable_session_tracking - if session_tracking == 'systemd' - logind_dep = libsystemd_dep - if not logind_dep.found() - logind_dep = dependency('libsystemd-login', required: false) - assert(logind_dep.found(), 'You must have libsystemd or libsystemd-login installed to build with systemd-logind support') - endif - session_trackers += 'systemd-logind' - config_h.set('SESSION_TRACKING_SYSTEMD', true) - else - logind_dep = libelogind_dep - assert(logind_dep.found() and libelogind_dep.version().version_compare('>= 229'), 'You must have libelogind installed to build with elogind support.') - session_trackers += 'elogind' - config_h.set('SESSION_TRACKING_ELOGIND', true) +if session_tracking == 'systemd' + logind_dep = libsystemd_dep + if not logind_dep.found() + logind_dep = dependency('libsystemd-login', required: false) + assert(logind_dep.found(), 'You must have libsystemd or libsystemd-login installed to build with systemd-logind support') endif + session_trackers += 'systemd-logind' + config_h.set10('SESSION_TRACKING_SYSTEMD', true) + config_h.set10('SESSION_TRACKING_ELOGIND', false) +elif session_tracking == 'elogind' + logind_dep = libelogind_dep + assert(logind_dep.found() and libelogind_dep.version().version_compare('>= 229'), 'You must have libelogind installed to build with elogind support.') + session_trackers += 'elogind' + config_h.set10('SESSION_TRACKING_SYSTEMD', false) + config_h.set10('SESSION_TRACKING_ELOGIND', true) +else + logind_dep = dependency('', required:false) +endif - if enable_consolekit - session_trackers += 'consolekit' - config_h.set_quoted('CKDB_PATH', '/var/run/ConsoleKit/database') - config_h.set('SESSION_TRACKING_CONSOLEKIT', enable_consolekit) - endif +session_tracking_consolekit = get_option('session_tracking_consolekit') +if session_tracking_consolekit + session_trackers += 'consolekit' endif +config_h.set10('SESSION_TRACKING_CONSOLEKIT', session_tracking_consolekit) hostname_persist = get_option('hostname_persist') config_h.set('HOSTNAME_PERSIST_SUSE', (hostname_persist == 'suse')) config_h.set('HOSTNAME_PERSIST_GENTOO', (hostname_persist == 'gentoo')) config_h.set('HOSTNAME_PERSIST_SLACKWARE', (hostname_persist == 'slackware')) -enable_suspend_resume = get_option('suspend_resume') -suspend_resume = '' +suspend_resume = get_option('suspend_resume') + +if suspend_resume == 'auto' + if libsystemd_dep.found() or libsystemd_login_dep.found() + suspend_resume = 'systemd' + elif libelogind_dep.found() + suspend_resume = 'elogind' + elif session_tracking_consolekit + suspend_resume = 'consolekit' + else + suspend_resume = 'upower' + endif +endif -if enable_suspend_resume +if suspend_resume == 'systemd' if libsystemd_dep.found() system_inhibit_dep = libsystemd_dep - suspend_resume = 'systemd' - config_h.set('SUSPEND_RESUME_SYSTEMD', true) + elif libsystemd_login_dep.found() + system_inhibit_dep = libsystemd_login_dep else - system_inhibit_dep = dependency('libsystemd-login', version: '>= 183', required: false) - if system_inhibit_dep.found() - suspend_resume = 'systemd' - config_h.set('SUSPEND_RESUME_SYSTEMD', true) - elif libelogind_dep.found() - system_inhibit_dep = libelogind_dep - suspend_resume = 'elogind' - config_h.set('SUSPEND_RESUME_ELOGIND', true) - elif enable_consolekit - suspend_resume = 'consolekit' - config_h.set('SUSPEND_RESUME_CONSOLEKIT', true) - else - suspend_resume = 'upower' - config_h.set('SUSPEND_RESUME_UPOWER', true) - endif + error('Need libsystemd for suspend_resume=systemd') endif + config_h.set('SUSPEND_RESUME_SYSTEMD', true) +elif suspend_resume == 'elogind' + assert(libelogind_dep.found(), 'Need libelogind for suspend_resume=elogind') + system_inhibit_dep = libelogind_dep + config_h.set('SUSPEND_RESUME_ELOGIND', true) +elif suspend_resume == 'consolekit' + config_h.set('SUSPEND_RESUME_CONSOLEKIT', true) +elif suspend_resume == 'upower' + config_h.set('SUSPEND_RESUME_UPOWER', true) +else + error('bug') endif # SELinux support diff --git a/meson_options.txt b/meson_options.txt index e97a773ac6..25ec7ae4e9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -13,9 +13,9 @@ option('dnssec_trigger', type: 'array', value: ['dnssec-trigger-script', '/usr/l # platform option('dist_version', type: 'string', value: '', description: 'Define the NM\'s distribution version string') -option('consolekit', type: 'boolean', value: true, description: 'Support consolekit session tracking') +option('session_tracking_consolekit', type: 'boolean', value: true, description: 'Support consolekit session tracking') option('session_tracking', type: 'combo', choices: ['systemd', 'elogind', 'no'], value: 'systemd', description: 'Compatibility option to choose one session tracking module') -option('suspend_resume', type: 'boolean', value: true, description: 'Build NetworkManager with specific suspend/resume support') +option('suspend_resume', type: 'combo', choices: ['upower', 'systemd', 'elogind', 'consolekit', 'auto'], value: 'auto', description: 'Build NetworkManager with specific suspend/resume support') option('polkit', type: 'combo', choices: ['yes', 'no', 'disabled'], value: 'yes', description: 'set default value for auth-polkit configuration option. This value can be overwritten by NM configuration. \'disabled\' compiles NM without any support') option('modify_system', type: 'boolean', value: false, description: 'Allow users to modify system connections') option('polkit_agent', type: 'boolean', value: false, description: 'enable polkit agent for clients') diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index a9cb57034a..b00397cff0 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -139,7 +139,7 @@ typedef struct { static void _call_trace (const char *comment, OvsdbMethodCall *call, json_t *msg) { -#ifdef NM_MORE_LOGGING +#if NM_MORE_LOGGING char *str = NULL; if (msg) diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 6c5a4723fb..5190faf742 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -438,7 +438,7 @@ periodic_update (NMDeviceWifi *self) percent = nm_platform_wifi_get_quality (nm_device_get_platform (NM_DEVICE (self)), ifindex); if (percent >= 0 || ++priv->invalid_strength_counter > 3) { if (nm_wifi_ap_set_strength (priv->current_ap, (gint8) percent)) { -#ifdef NM_MORE_LOGGING +#if NM_MORE_LOGGING _ap_dump (self, LOGL_TRACE, priv->current_ap, "updated", 0); #endif } diff --git a/src/dhcp/nm-dhcp-helper.c b/src/dhcp/nm-dhcp-helper.c index 8ea5506152..2b48d7a5f0 100644 --- a/src/dhcp/nm-dhcp-helper.c +++ b/src/dhcp/nm-dhcp-helper.c @@ -31,7 +31,7 @@ /*****************************************************************************/ -#ifdef NM_MORE_LOGGING +#if NM_MORE_LOGGING #define _NMLOG_ENABLED(level) TRUE #else #define _NMLOG_ENABLED(level) ((level) <= LOG_ERR) diff --git a/src/meson.build b/src/meson.build index b678d77cf5..83fc3eacaf 100644 --- a/src/meson.build +++ b/src/meson.build @@ -146,12 +146,10 @@ sources = files( deps = [ dl_dep, libndp_dep, - # FIXME: Some files use introspection/dbus* headers, so - # this dependency might be needed - #libnmdbus_dep, libudev_dep, nm_core_dep, - shared_n_acd_dep + shared_n_acd_dep, + logind_dep, ] if enable_concheck @@ -170,10 +168,6 @@ if enable_selinux deps += selinux_dep endif -if enable_session_tracking - deps += logind_dep -endif - libnetwork_manager = static_library( nm_name, sources: sources, diff --git a/src/nm-logging.h b/src/nm-logging.h index 70c14a5e04..0737bbd639 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -271,7 +271,7 @@ gboolean nm_logging_syslog_enabled (void); /* _LOGT() and _LOGt() both log with level TRACE, but the latter is disabled by default, * unless building with --with-more-logging. */ -#ifdef NM_MORE_LOGGING +#if NM_MORE_LOGGING #define _LOGt_ENABLED(...) _NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__) #define _LOGt(...) _NMLOG (LOGL_TRACE, __VA_ARGS__) #define _LOGt_err(errsv, ...) _NMLOG_err (errsv, LOGL_TRACE, __VA_ARGS__) @@ -311,7 +311,7 @@ gboolean nm_logging_syslog_enabled (void); #define _LOG2W_err(errsv, ...) _NMLOG2_err (errsv, LOGL_WARN , __VA_ARGS__) #define _LOG2E_err(errsv, ...) _NMLOG2_err (errsv, LOGL_ERR , __VA_ARGS__) -#ifdef NM_MORE_LOGGING +#if NM_MORE_LOGGING #define _LOG2t_ENABLED(...) _NMLOG2_ENABLED (LOGL_TRACE, ##__VA_ARGS__) #define _LOG2t(...) _NMLOG2 (LOGL_TRACE, __VA_ARGS__) #define _LOG2t_err(errsv, ...) _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__) @@ -342,7 +342,7 @@ gboolean nm_logging_syslog_enabled (void); #define _LOG3W_err(errsv, ...) _NMLOG3_err (errsv, LOGL_WARN , __VA_ARGS__) #define _LOG3E_err(errsv, ...) _NMLOG3_err (errsv, LOGL_ERR , __VA_ARGS__) -#ifdef NM_MORE_LOGGING +#if NM_MORE_LOGGING #define _LOG3t_ENABLED(...) _NMLOG3_ENABLED (LOGL_TRACE, ##__VA_ARGS__) #define _LOG3t(...) _NMLOG3 (LOGL_TRACE, __VA_ARGS__) #define _LOG3t_err(errsv, ...) _NMLOG3_err (errsv, LOGL_TRACE, __VA_ARGS__) diff --git a/src/nm-session-monitor.c b/src/nm-session-monitor.c index 23d41d7ee7..7dbe835b8e 100644 --- a/src/nm-session-monitor.c +++ b/src/nm-session-monitor.c @@ -28,24 +28,26 @@ #include <string.h> #include <sys/stat.h> -#if defined (SESSION_TRACKING_SYSTEMD) && defined (SESSION_TRACKING_ELOGIND) +#if SESSION_TRACKING_SYSTEMD && SESSION_TRACKING_ELOGIND #error Cannot build both systemd-logind and elogind support #endif -#ifdef SESSION_TRACKING_SYSTEMD +#if SESSION_TRACKING_SYSTEMD #include <systemd/sd-login.h> #define LOGIND_NAME "systemd-logind" #endif -#ifdef SESSION_TRACKING_ELOGIND +#if SESSION_TRACKING_ELOGIND #include <elogind/sd-login.h> #define LOGIND_NAME "elogind" -/* Re-Use SESSION_TRACKING_SYSTEMD as elogind substitutes systemd-login */ -#define SESSION_TRACKING_SYSTEMD 1 #endif #include "NetworkManagerUtils.h" +#define SESSION_TRACKING_XLOGIND (SESSION_TRACKING_SYSTEMD || SESSION_TRACKING_ELOGIND) + +#define CKDB_PATH "/var/run/ConsoleKit/database" + /*****************************************************************************/ enum { @@ -58,14 +60,14 @@ static guint signals[LAST_SIGNAL] = { 0 }; struct _NMSessionMonitor { GObject parent; -#ifdef SESSION_TRACKING_SYSTEMD +#if SESSION_TRACKING_XLOGIND struct { sd_login_monitor *monitor; guint watch; } sd; #endif -#ifdef SESSION_TRACKING_CONSOLEKIT +#if SESSION_TRACKING_CONSOLEKIT struct { GFileMonitor *monitor; GHashTable *cache; @@ -85,7 +87,7 @@ G_DEFINE_TYPE (NMSessionMonitor, nm_session_monitor, G_TYPE_OBJECT); /*****************************************************************************/ -#ifdef SESSION_TRACKING_SYSTEMD +#if SESSION_TRACKING_XLOGIND static gboolean st_sd_session_exists (NMSessionMonitor *monitor, uid_t uid, gboolean active) { @@ -143,11 +145,11 @@ st_sd_finalize (NMSessionMonitor *monitor) } nm_clear_g_source (&monitor->sd.watch); } -#endif /* SESSION_TRACKING_SYSTEMD */ +#endif /* SESSION_TRACKING_XLOGIND */ /*****************************************************************************/ -#ifdef SESSION_TRACKING_CONSOLEKIT +#if SESSION_TRACKING_CONSOLEKIT typedef struct { gboolean active; } CkSession; @@ -352,12 +354,12 @@ nm_session_monitor_session_exists (NMSessionMonitor *self, { g_return_val_if_fail (NM_IS_SESSION_MONITOR (self), FALSE); -#ifdef SESSION_TRACKING_SYSTEMD +#if SESSION_TRACKING_XLOGIND if (st_sd_session_exists (self, uid, active)) return TRUE; #endif -#ifdef SESSION_TRACKING_CONSOLEKIT +#if SESSION_TRACKING_CONSOLEKIT if (ck_session_exists (self, uid, active)) return TRUE; #endif @@ -370,12 +372,12 @@ nm_session_monitor_session_exists (NMSessionMonitor *self, static void nm_session_monitor_init (NMSessionMonitor *monitor) { -#ifdef SESSION_TRACKING_SYSTEMD +#if SESSION_TRACKING_XLOGIND st_sd_init (monitor); _LOGD ("using "LOGIND_NAME" session tracking"); #endif -#ifdef SESSION_TRACKING_CONSOLEKIT +#if SESSION_TRACKING_CONSOLEKIT ck_init (monitor); _LOGD ("using ConsoleKit session tracking"); #endif @@ -384,11 +386,11 @@ nm_session_monitor_init (NMSessionMonitor *monitor) static void finalize (GObject *object) { -#ifdef SESSION_TRACKING_SYSTEMD +#if SESSION_TRACKING_XLOGIND st_sd_finalize (NM_SESSION_MONITOR (object)); #endif -#ifdef SESSION_TRACKING_CONSOLEKIT +#if SESSION_TRACKING_CONSOLEKIT ck_finalize (NM_SESSION_MONITOR (object)); #endif diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index a960f41ef1..9ff976a259 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -3413,7 +3413,7 @@ typedef struct { struct nl_sock *nlh; guint32 nlh_seq_next; -#ifdef NM_MORE_LOGGING +#if NM_MORE_LOGGING guint32 nlh_seq_last_handled; #endif guint32 nlh_seq_last_seen; @@ -4772,7 +4772,7 @@ event_seq_check (NMPlatform *platform, guint32 seq_number, WaitForNlResponseResu } } -#ifdef NM_MORE_LOGGING +#if NM_MORE_LOGGING if (seq_number != priv->nlh_seq_last_handled) _LOGt ("netlink: recvmsg: unwaited sequence number %u", seq_number); priv->nlh_seq_last_handled = seq_number; |