[network-manager-applet] build: cleanup build against libnm/libnm-glib



commit 4683a4e60d5a7cc19ad6feff3694fc738f0d2f26
Author: Thomas Haller <thaller redhat com>
Date:   Tue Oct 4 14:18:53 2016 +0200

    build: cleanup build against libnm/libnm-glib
    
    We already define NETWORKMANAGER_COMPILATION for "nm-default.h".
    Let "nm-default.h" set LIBNM_BUILD to 1 or 0 based on
    NETWORKMANAGER_COMPILATION define.
    
    Also, drop LIBNM_GLIB_BUILD as it really is just !LIBNM_BUILD.

 shared/nm-default.h                       |   21 ++++++++++++++++-----
 src/Makefile.am                           |    1 -
 src/connection-editor/Makefile.am         |    1 -
 src/libnm-gtk/Makefile.am                 |    3 +--
 src/libnma/Makefile.am                    |    1 -
 src/utils/Makefile.am                     |    3 +--
 src/utils/tests/Makefile.am               |    8 +++-----
 src/utils/utils.c                         |    8 ++++----
 src/utils/utils.h                         |   15 +--------------
 src/wireless-security/Makefile.am         |    3 +--
 src/wireless-security/eap-method.c        |   22 +++++++---------------
 src/wireless-security/eap-method.h        |   13 -------------
 src/wireless-security/helpers.h           |   12 ------------
 src/wireless-security/wireless-security.h |   11 -----------
 src/wireless-security/ws-dynamic-wep.h    |    9 ---------
 src/wireless-security/ws-leap.h           |    9 ---------
 src/wireless-security/ws-wep-key.h        |    9 ---------
 src/wireless-security/ws-wpa-eap.h        |    9 ---------
 src/wireless-security/ws-wpa-psk.h        |    9 ---------
 19 files changed, 34 insertions(+), 133 deletions(-)
---
diff --git a/shared/nm-default.h b/shared/nm-default.h
index 7c6f7fd..5b3a8d3 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -45,24 +45,35 @@
 #endif
 
 #include <stdlib.h>
+#include <glib.h>
 
 #include "nm-utils/nm-macros-internal.h"
 
-#include "nm-version.h"
+#include <nm-version.h>
 
 #include <gtk/gtk.h>
 
 /*****************************************************************************/
 
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB) || ((NETWORKMANAGER_COMPILATION) == 
NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#define LIBNM_BUILD 1
+#else
+#define LIBNM_BUILD 0
+#endif
 
-#include <glib/gi18n-lib.h>
 
+#if ((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB) || ((NETWORKMANAGER_COMPILATION) & 
NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#include <glib/gi18n-lib.h>
 #else
-
 #include <glib/gi18n.h>
+#endif
 
-#endif /* NM_NETWORKMANAGER_COMPILATION_LIB || NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */
+
+#if ((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#include <nm-connection.h>
+#else
+#include <NetworkManager.h>
+#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */
 
 /*****************************************************************************/
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 913c897..aaad63e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,6 @@ nm_applet_CPPFLAGS = \
        $(NOTIFY_CFLAGS) \
        $(MM_GLIB_CFLAGS) \
        $(APPINDICATOR_CFLAGS) \
-       -DLIBNM_BUILD \
        -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_4 \
        -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_4 \
        -DICONDIR=\""$(datadir)/icons"\"                                                \
diff --git a/src/connection-editor/Makefile.am b/src/connection-editor/Makefile.am
index f4f2176..b6f31a5 100644
--- a/src/connection-editor/Makefile.am
+++ b/src/connection-editor/Makefile.am
@@ -4,7 +4,6 @@ nm_connection_editor_CPPFLAGS = \
        $(GTK_CFLAGS) \
        $(LIBNM_CFLAGS) \
        $(JANSSON_CFLAGS) \
-       -DLIBNM_BUILD \
        -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_4 \
        -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_4 \
        -DICONDIR=\""$(datadir)/icons"\" \
diff --git a/src/libnm-gtk/Makefile.am b/src/libnm-gtk/Makefile.am
index 735de76..e3830f6 100644
--- a/src/libnm-gtk/Makefile.am
+++ b/src/libnm-gtk/Makefile.am
@@ -28,7 +28,7 @@ libnm_gtk_la_CFLAGS = \
        $(GTK_CFLAGS) \
        $(LIBNM_GLIB_CFLAGS) \
        $(GUDEV_CFLAGS) \
-       -DLIBNM_GLIB_BUILD \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \
        -DICONDIR=\""$(datadir)/icons"\" \
        -DUIDIR=\""$(uidir)"\" \
        -DBINDIR=\""$(bindir)"\" \
@@ -37,7 +37,6 @@ libnm_gtk_la_CFLAGS = \
        -DDATADIR=\""$(datadir)"\" \
        -DAUTOSTARTDIR=\""$(sysconfdir)/xdg/autostart"\" \
        -DNMALOCALEDIR=\"$(datadir)/locale\" \
-       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \
        "-I${top_srcdir}/shared/" \
        -I${top_srcdir}/src/utils \
        -I${top_srcdir}/src/wireless-security
diff --git a/src/libnma/Makefile.am b/src/libnma/Makefile.am
index 5a7302e..4dde7d4 100644
--- a/src/libnma/Makefile.am
+++ b/src/libnma/Makefile.am
@@ -24,7 +24,6 @@ libnma_la_CFLAGS = \
        $(GTK_CFLAGS) \
        $(LIBNM_CFLAGS) \
        $(GUDEV_CFLAGS) \
-       -DLIBNM_BUILD \
        -DICONDIR=\""$(datadir)/icons"\" \
        -DUIDIR=\""$(uidir)"\" \
        -DBINDIR=\""$(bindir)"\" \
diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
index 47c360c..aac0155 100644
--- a/src/utils/Makefile.am
+++ b/src/utils/Makefile.am
@@ -9,7 +9,7 @@ libutils_libnm_glib_la_SOURCES = \
        utils.h
 
 libutils_libnm_glib_la_CPPFLAGS = \
-       -DLIBNM_GLIB_BUILD \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \
        $(GTK_CFLAGS) \
        $(LIBNM_GLIB_CFLAGS) \
        "-I${top_srcdir}/shared/"
@@ -23,7 +23,6 @@ libutils_libnm_la_SOURCES = \
        utils.h
 
 libutils_libnm_la_CPPFLAGS = \
-       -DLIBNM_BUILD \
        $(GTK_CFLAGS) \
        $(LIBNM_CFLAGS) \
        "-I${top_srcdir}/shared/"
diff --git a/src/utils/tests/Makefile.am b/src/utils/tests/Makefile.am
index eafaf4a..7987345 100644
--- a/src/utils/tests/Makefile.am
+++ b/src/utils/tests/Makefile.am
@@ -3,11 +3,10 @@ noinst_PROGRAMS = test-utils
 test_utils_SOURCES = test-utils.c
 
 test_utils_CPPFLAGS = \
-       -I $(top_srcdir)/src/utils \
-       -DLIBNM_BUILD \
+       "-I${top_srcdir}/shared/" \
+       -I$(top_srcdir)/src/utils \
        $(GTK_CFLAGS) \
-       $(LIBNM_CFLAGS) \
-       "-I${top_srcdir}/shared/"
+       $(LIBNM_CFLAGS)
 
 test_utils_LDADD = \
        ${top_builddir}/src/utils/libutils-libnm.la \
@@ -15,4 +14,3 @@ test_utils_LDADD = \
        $(LIBNM_LIBS)
 
 TESTS = $(noinst_PROGRAMS)
-
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 000ccd4..23e41c3 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -22,11 +22,11 @@
 
 #include "nm-default.h"
 
+#include "utils.h"
+
 #include <string.h>
 #include <netinet/ether.h>
 
-#include "utils.h"
-
 /*
  * utils_ether_addr_valid
  *
@@ -64,7 +64,7 @@ utils_ether_addr_valid (const struct ether_addr *test_addr)
 
 char *
 utils_hash_ap (
-#ifdef LIBNM_BUILD
+#if LIBNM_BUILD
                GBytes *ssid,
 #else
                const GByteArray *ssid,
@@ -79,7 +79,7 @@ utils_hash_ap (
        memset (&input[0], 0, sizeof (input));
 
        if (ssid) {
-#ifdef LIBNM_BUILD
+#if LIBNM_BUILD
                memcpy (input, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
 #else
                memcpy (input, ssid->data, ssid->len);
diff --git a/src/utils/utils.h b/src/utils/utils.h
index 8202127..ab90366 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -23,24 +23,11 @@
 #ifndef UTILS_H
 #define UTILS_H
 
-#include <glib.h>
-#include <gtk/gtk.h>
-
 #include <net/ethernet.h>
 
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-connection.h>
-#include <nm-device.h>
-#include <nm-access-point.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 gboolean utils_ether_addr_valid (const struct ether_addr *test_addr);
 
-#ifdef LIBNM_BUILD
+#if LIBNM_BUILD
 char *utils_hash_ap (GBytes *ssid,
                      NM80211Mode mode,
                      guint32 flags,
diff --git a/src/wireless-security/Makefile.am b/src/wireless-security/Makefile.am
index 2be7aa7..c66ba1b 100644
--- a/src/wireless-security/Makefile.am
+++ b/src/wireless-security/Makefile.am
@@ -38,7 +38,7 @@ libwireless_security_libnm_glib_la_SOURCES = \
 libwireless_security_libnm_glib_la_CPPFLAGS = \
        $(GTK_CFLAGS) \
        -DUIDIR=\""$(uidir)"\" \
-       -DLIBNM_GLIB_BUILD \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \
        $(LIBNM_GLIB_CFLAGS) \
        "-I${top_srcdir}/shared/" \
        -I${top_srcdir}/src/utils \
@@ -55,7 +55,6 @@ libwireless_security_libnm_la_SOURCES = \
 libwireless_security_libnm_la_CPPFLAGS = \
        $(GTK_CFLAGS) \
        -DUIDIR=\""$(uidir)"\" \
-       -DLIBNM_BUILD \
        $(LIBNM_CFLAGS) \
        "-I${top_srcdir}/shared/" \
        -I${top_srcdir}/src/utils \
diff --git a/src/wireless-security/eap-method.c b/src/wireless-security/eap-method.c
index 42b9d80..c8c2136 100644
--- a/src/wireless-security/eap-method.c
+++ b/src/wireless-security/eap-method.c
@@ -270,7 +270,7 @@ out:
        return success;
 }
 
-#ifdef LIBNM_GLIB_BUILD
+#if !LIBNM_BUILD
 static const char *
 find_tag (const char *tag, const char *buf, gsize len)
 {
@@ -403,16 +403,14 @@ out:
 static gboolean
 default_filter_privkey (const GtkFileFilterInfo *filter_info, gpointer user_data)
 {
-#ifdef LIBNM_GLIB_BUILD
-       const char *extensions[] = { ".der", ".pem", ".p12", ".key", NULL };
-#endif
+       _nm_unused const char *extensions[] = { ".der", ".pem", ".p12", ".key", NULL };
        gboolean require_encrypted = !!user_data;
        gboolean is_encrypted;
 
        if (!filter_info->filename)
                return FALSE;
 
-#if defined (LIBNM_GLIB_BUILD)
+#if !LIBNM_BUILD
        if (!file_has_extension (filter_info->filename, extensions))
                return FALSE;
 
@@ -420,12 +418,10 @@ default_filter_privkey (const GtkFileFilterInfo *filter_info, gpointer user_data
        if (   !file_is_der_or_pem (filter_info->filename, TRUE, &is_encrypted)
            && !nm_utils_file_is_pkcs12 (filter_info->filename))
                return FALSE;
-#elif defined (LIBNM_BUILD)
+#else
        is_encrypted = FALSE;
        if (!nm_utils_file_is_private_key (filter_info->filename, &is_encrypted))
                return FALSE;
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
 #endif
 
        return require_encrypted ? is_encrypted : TRUE;
@@ -434,24 +430,20 @@ default_filter_privkey (const GtkFileFilterInfo *filter_info, gpointer user_data
 static gboolean
 default_filter_cert (const GtkFileFilterInfo *filter_info, gpointer user_data)
 {
-#ifdef LIBNM_GLIB_BUILD
-       const char *extensions[] = { ".der", ".pem", ".crt", ".cer", NULL };
-#endif
+       _nm_unused const char *extensions[] = { ".der", ".pem", ".crt", ".cer", NULL };
 
        if (!filter_info->filename)
                return FALSE;
 
-#if defined (LIBNM_GLIB_BUILD)
+#if !LIBNM_BUILD
        if (!file_has_extension (filter_info->filename, extensions))
                return FALSE;
 
        if (!file_is_der_or_pem (filter_info->filename, FALSE, NULL))
                return FALSE;
-#elif defined (LIBNM_BUILD)
+#else
        if (!nm_utils_file_is_certificate (filter_info->filename))
                return FALSE;
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
 #endif
 
        return TRUE;
diff --git a/src/wireless-security/eap-method.h b/src/wireless-security/eap-method.h
index 84c1c78..171d1ca 100644
--- a/src/wireless-security/eap-method.h
+++ b/src/wireless-security/eap-method.h
@@ -23,18 +23,6 @@
 #ifndef EAP_METHOD_H
 #define EAP_METHOD_H
 
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-connection.h>
-#include <nm-setting-8021x.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 typedef struct _EAPMethod EAPMethod;
 
 typedef void        (*EMAddToSizeGroupFunc) (EAPMethod *method, GtkSizeGroup *group);
@@ -141,4 +129,3 @@ void eap_method_ca_cert_ignore_save (NMConnection *connection);
 void eap_method_ca_cert_ignore_load (NMConnection *connection);
 
 #endif /* EAP_METHOD_H */
-
diff --git a/src/wireless-security/helpers.h b/src/wireless-security/helpers.h
index bdd58b0..f299c69 100644
--- a/src/wireless-security/helpers.h
+++ b/src/wireless-security/helpers.h
@@ -23,18 +23,6 @@
 #ifndef _HELPERS_H_
 #define _HELPERS_H_
 
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-connection.h>
-#include <nm-setting.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 typedef const char * (*HelperSecretFunc)(NMSetting *);
 
 void helper_fill_secret_entry (NMConnection *connection,
diff --git a/src/wireless-security/wireless-security.h b/src/wireless-security/wireless-security.h
index e9bcf63..9fb83de 100644
--- a/src/wireless-security/wireless-security.h
+++ b/src/wireless-security/wireless-security.h
@@ -23,17 +23,6 @@
 #ifndef WIRELESS_SECURITY_H
 #define WIRELESS_SECURITY_H
 
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-connection.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 typedef struct _WirelessSecurity WirelessSecurity;
 
 typedef void (*WSChangedFunc) (WirelessSecurity *sec, gpointer user_data);
diff --git a/src/wireless-security/ws-dynamic-wep.h b/src/wireless-security/ws-dynamic-wep.h
index e25a983..e2e5f6a 100644
--- a/src/wireless-security/ws-dynamic-wep.h
+++ b/src/wireless-security/ws-dynamic-wep.h
@@ -23,14 +23,6 @@
 #ifndef WS_DYNAMIC_WEP_H
 #define WS_DYNAMIC_WEP_H
 
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-connection.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 typedef struct _WirelessSecurityDynamicWEP WirelessSecurityDynamicWEP;
 
 WirelessSecurityDynamicWEP *ws_dynamic_wep_new (NMConnection *connection,
@@ -38,4 +30,3 @@ WirelessSecurityDynamicWEP *ws_dynamic_wep_new (NMConnection *connection,
                                                 gboolean secrets_only);
 
 #endif /* WS_DYNAMIC_WEP_H */
-
diff --git a/src/wireless-security/ws-leap.h b/src/wireless-security/ws-leap.h
index 6b1fe56..fedc06d 100644
--- a/src/wireless-security/ws-leap.h
+++ b/src/wireless-security/ws-leap.h
@@ -23,17 +23,8 @@
 #ifndef WS_LEAP_H
 #define WS_LEAP_H
 
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-connection.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 typedef struct _WirelessSecurityLEAP WirelessSecurityLEAP;
 
 WirelessSecurityLEAP * ws_leap_new (NMConnection *connection, gboolean secrets_only);
 
 #endif /* WS_LEAP_H */
-
diff --git a/src/wireless-security/ws-wep-key.h b/src/wireless-security/ws-wep-key.h
index 7ba5407..604eba6 100644
--- a/src/wireless-security/ws-wep-key.h
+++ b/src/wireless-security/ws-wep-key.h
@@ -23,14 +23,6 @@
 #ifndef WS_WEP_KEY_H
 #define WS_WEP_KEY_H
 
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-setting-wireless-security.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 typedef struct _WirelessSecurityWEPKey WirelessSecurityWEPKey;
 
 WirelessSecurityWEPKey *ws_wep_key_new (NMConnection *connection,
@@ -39,4 +31,3 @@ WirelessSecurityWEPKey *ws_wep_key_new (NMConnection *connection,
                                         gboolean secrets_only);
 
 #endif /* WS_WEP_KEY_H */
-
diff --git a/src/wireless-security/ws-wpa-eap.h b/src/wireless-security/ws-wpa-eap.h
index b8f9ba8..0ebff70 100644
--- a/src/wireless-security/ws-wpa-eap.h
+++ b/src/wireless-security/ws-wpa-eap.h
@@ -23,14 +23,6 @@
 #ifndef WS_WPA_EAP_H
 #define WS_WPA_EAP_H
 
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-connection.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 typedef struct _WirelessSecurityWPAEAP WirelessSecurityWPAEAP;
 
 WirelessSecurityWPAEAP * ws_wpa_eap_new (NMConnection *connection,
@@ -38,4 +30,3 @@ WirelessSecurityWPAEAP * ws_wpa_eap_new (NMConnection *connection,
                                          gboolean secrets_only);
 
 #endif /* WS_WPA_EAP_H */
-
diff --git a/src/wireless-security/ws-wpa-psk.h b/src/wireless-security/ws-wpa-psk.h
index 6bd1768..8b84ed8 100644
--- a/src/wireless-security/ws-wpa-psk.h
+++ b/src/wireless-security/ws-wpa-psk.h
@@ -23,17 +23,8 @@
 #ifndef WS_WPA_PSK_H
 #define WS_WPA_PSK_H
 
-#if defined (LIBNM_BUILD)
-#include <NetworkManager.h>
-#elif defined (LIBNM_GLIB_BUILD)
-#include <nm-connection.h>
-#else
-#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined
-#endif
-
 typedef struct _WirelessSecurityWPAPSK WirelessSecurityWPAPSK;
 
 WirelessSecurityWPAPSK * ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only);
 
 #endif /* WS_WEP_KEY_H */
-


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