From 07d5c86e780ed2155da491b408718b2e01f25ec4 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 13 Nov 2017 16:16:39 +0100 Subject: [PATCH] build: fix wrong jansson prerequisites Currently there are multiple features that require Jansson support, but WITH_JANSSON=1 is set only when configuring with --enable-json-validation. Therefore a build with "--disable-json-validation --enable-ovs" fails. The availability of Jansson (WITH_JANSSON) should only be used: - to check if dependent features can be enabled - to determine compiler and linker flags in the Makefile - in nm-jansson.h to define compatibility functions if needed Everything else must be controlled by a configure switch. https://bugzilla.gnome.org/show_bug.cgi?id=790233 --- configure.ac | 13 ++++++++++--- libnm-core/nm-utils.c | 4 ++-- libnm-core/tests/test-general.c | 4 ++-- libnm-core/tests/test-keyfile.c | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 14227e1aac..c358d48821 100644 --- a/configure.ac +++ b/configure.ac @@ -642,6 +642,14 @@ PKG_CHECK_MODULES(UUID, uuid) # Teamd control checks PKG_CHECK_MODULES(JANSSON, [jansson], [have_jansson=yes], [have_jansson=no]) +if test "$have_jansson" = "yes"; then + AC_DEFINE(WITH_JANSSON, 1, [Define if JANSSON is enabled]) +else + AC_DEFINE(WITH_JANSSON, 0, [Define if JANSSON is enabled]) +fi +AM_CONDITIONAL(WITH_JANSSON, test "${have_jansson}" = "yes") + + PKG_CHECK_MODULES(LIBTEAMDCTL, [libteamdctl >= 1.9], [have_teamdctl=yes],[have_teamdctl=no]) if test "$have_jansson" = "yes" -a "$have_teamdctl" = "yes"; then have_team_prereq=yes @@ -673,14 +681,13 @@ AC_ARG_ENABLE(json-validation, [enable_json_validation=${enableval}], [enable_json_validation=${have_jansson}]) if (test "${enable_json_validation}" == "no"); then - AC_DEFINE(WITH_JANSSON, 0, [Define if JANSSON is enabled]) + AC_DEFINE(WITH_JSON_VALIDATION, 0, [Define if JSON validation in libnm is enabled]) else if test "$have_jansson" = "no"; then AC_MSG_ERROR([jansson is needed for team configuration validation. Use --disable-json-validation to build without it.]) fi - AC_DEFINE(WITH_JANSSON, 1, [Define if JANSSON is enabled]) + AC_DEFINE(WITH_JSON_VALIDATION, 1, [Define if JSON validation in libnm is enabled]) fi -AM_CONDITIONAL(WITH_JANSSON, test "${enable_json_validation}" != "no") # we usually compile with polkit support. --enable-polkit=yes|no only sets the # default configuration for main.auth-polkit. User can always enable/disable polkit diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 6c8436cc5d..a3c363c52a 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -4304,7 +4304,7 @@ const char **nm_utils_enum_get_values (GType type, gint from, gint to) /*****************************************************************************/ -#if WITH_JANSSON +#if WITH_JSON_VALIDATION /** * nm_utils_is_json_object: * @str: the JSON string to test @@ -4715,7 +4715,7 @@ done: return updated; } -#else /* WITH_JANSSON */ +#else /* !WITH_JSON_VALIDATION */ gboolean nm_utils_is_json_object (const char *str, GError **error) diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 188cb28e63..9f134583b3 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -5848,7 +5848,7 @@ test_nm_utils_check_valid_json (void) { _json_config_check_valid (NULL, FALSE); _json_config_check_valid ("", FALSE); -#if WITH_JANSSON +#if WITH_JSON_VALIDATION _json_config_check_valid ("{ }", TRUE); _json_config_check_valid ("{ \"a\" : 1 }", TRUE); _json_config_check_valid ("{ \"a\" : }", FALSE); @@ -5873,7 +5873,7 @@ _team_config_equal_check (const char *conf1, static void test_nm_utils_team_config_equal (void) { -#if WITH_JANSSON +#if WITH_JSON_VALIDATION _team_config_equal_check ("", "", TRUE, TRUE); _team_config_equal_check ("{}", "{ }", diff --git a/libnm-core/tests/test-keyfile.c b/libnm-core/tests/test-keyfile.c index 2dc929afd8..6f3b0e3276 100644 --- a/libnm-core/tests/test-keyfile.c +++ b/libnm-core/tests/test-keyfile.c @@ -623,7 +623,7 @@ test_team_conf_read_valid (void) static void test_team_conf_read_invalid (void) { -#if WITH_JANSSON +#if WITH_JSON_VALIDATION GKeyFile *keyfile = NULL; gs_unref_object NMConnection *con = NULL; NMSettingTeam *s_team;