build: merge branch 'th/build-ifdef-cleanup'

https://github.com/NetworkManager/NetworkManager/pull/187
This commit is contained in:
Thomas Haller 2018-08-27 18:18:49 +02:00
commit e763a07a6e
11 changed files with 90 additions and 81 deletions

View file

@ -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

View file

@ -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

View file

@ -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)
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)
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
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 enable_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 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

View file

@ -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')

View file

@ -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)

View file

@ -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
}

View file

@ -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)

View file

@ -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,

View file

@ -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__)

View file

@ -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

View file

@ -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;