diff options
author | Dan Winship <danw@redhat.com> | 2014-11-25 10:00:33 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2015-02-24 12:10:57 -0600 |
commit | a0d4d15ed22fff2ed856ca6291812e96374afc94 (patch) | |
tree | 5936c5e399c80a342ba1de4e93ae4ef1d289ebe4 | |
parent | 1c161c841f01ec4fb3c6648c04f5c113105ef41d (diff) | |
download | network-manager-applet-a0d4d15ed22fff2ed856ca6291812e96374afc94.tar.gz |
utils: build separate libnm-based and libnm-glib-based versions
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/connection-editor/Makefile.am | 3 | ||||
-rw-r--r-- | src/libnm-gtk/Makefile.am | 1 | ||||
-rw-r--r-- | src/utils/Makefile.am | 31 | ||||
-rw-r--r-- | src/utils/tests/Makefile.am | 7 | ||||
-rw-r--r-- | src/utils/tests/test-utils.c | 13 | ||||
-rw-r--r-- | src/utils/utils.c | 19 | ||||
-rw-r--r-- | src/utils/utils.h | 52 | ||||
-rw-r--r-- | src/wireless-security/Makefile.am | 3 |
10 files changed, 71 insertions, 65 deletions
diff --git a/configure.ac b/configure.ac index 09a4fb69..7dffcfef 100644 --- a/configure.ac +++ b/configure.ac @@ -77,9 +77,11 @@ PKG_CHECK_MODULES(NMA, libnm-util >= 1.0 libnm-glib-vpn >= 1.0 gmodule-export-2.0]) - NMA_CFLAGS="$NMA_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32" +PKG_CHECK_MODULES(LIBNM, [libnm gio-2.0 >= 2.32]) +LIBNM_CFLAGS="$LIBNM_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32" + PKG_CHECK_MODULES(LIBSECRET, [libsecret-unstable]) # Check for libnotify >= 0.7 diff --git a/src/Makefile.am b/src/Makefile.am index 9379a516..4b1afbb2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,6 +9,7 @@ nm_applet_CPPFLAGS = \ $(NOTIFY_CFLAGS) \ $(MM_GLIB_CFLAGS) \ $(APPINDICATOR_CFLAGS) \ + -DLIBNM_GLIB_BUILD \ -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_10 \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_0_9_10 \ -DICONDIR=\""$(datadir)/icons"\" \ @@ -82,7 +83,7 @@ nm_applet_LDADD = \ $(NOTIFY_LIBS) \ $(MM_GLIB_LIBS) \ $(APPINDICATOR_LIBS) \ - ${top_builddir}/src/utils/libutils.la \ + ${top_builddir}/src/utils/libutils-libnm-glib.la \ ${top_builddir}/src/wireless-security/libwireless-security.la \ ${top_builddir}/src/libnm-gtk/libnm-gtk.la diff --git a/src/connection-editor/Makefile.am b/src/connection-editor/Makefile.am index bc6c14cb..ccff613a 100644 --- a/src/connection-editor/Makefile.am +++ b/src/connection-editor/Makefile.am @@ -3,6 +3,7 @@ bin_PROGRAMS = nm-connection-editor nm_connection_editor_CPPFLAGS = \ $(GTK_CFLAGS) \ $(NMA_CFLAGS) \ + -DLIBNM_GLIB_BUILD \ -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_10 \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_0_9_10 \ -DICONDIR=\""$(datadir)/icons"\" \ @@ -87,7 +88,7 @@ nm-connection-editor-service-glue.h: $(top_srcdir)/src/connection-editor/nm-conn nm_connection_editor_LDADD = \ ${top_builddir}/src/wireless-security/libwireless-security.la \ - ${top_builddir}/src/utils/libutils.la \ + ${top_builddir}/src/utils/libutils-libnm-glib.la \ ${top_builddir}/src/libnm-gtk/libnm-gtk.la \ $(GTK_LIBS) \ $(NMA_LIBS) \ diff --git a/src/libnm-gtk/Makefile.am b/src/libnm-gtk/Makefile.am index c2a75a4a..b63c67c9 100644 --- a/src/libnm-gtk/Makefile.am +++ b/src/libnm-gtk/Makefile.am @@ -29,6 +29,7 @@ libnm_gtk_la_CFLAGS = \ $(NMA_CFLAGS) \ $(DBUS_CFLAGS) \ $(GUDEV_CFLAGS) \ + -DLIBNM_GLIB_BUILD \ -DICONDIR=\""$(datadir)/icons"\" \ -DUIDIR=\""$(uidir)"\" \ -DBINDIR=\""$(bindir)"\" \ diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am index c2cbe9e8..33a1d531 100644 --- a/src/utils/Makefile.am +++ b/src/utils/Makefile.am @@ -1,15 +1,32 @@ -SUBDIRS=. tests +SUBDIRS= . tests -noinst_LTLIBRARIES = libutils.la +noinst_LTLIBRARIES = \ + libutils-libnm-glib.la \ + libutils-libnm.la -libutils_la_SOURCES = \ +libutils_libnm_glib_la_SOURCES = \ nm-glib-compat.h \ utils.c \ utils.h -libutils_la_CPPFLAGS = \ +libutils_libnm_glib_la_CPPFLAGS = \ + -DLIBNM_GLIB_BUILD \ $(GTK_CFLAGS) \ - $(NMA_CFLAGS) \ - -I${top_srcdir}/src + $(NMA_CFLAGS) -libutils_la_LIBADD = $(GTK_LIBS) $(NMA_LIBS) +libutils_libnm_glib_la_LIBADD = \ + $(GTK_LIBS) \ + $(NMA_LIBS) + +libutils_libnm_la_SOURCES = \ + utils.c \ + utils.h + +libutils_libnm_la_CPPFLAGS = \ + -DLIBNM_BUILD \ + $(GTK_CFLAGS) \ + $(LIBNM_CFLAGS) + +libutils_libnm_la_LIBADD = \ + $(GTK_LIBS) \ + $(LIBNM_LIBS) diff --git a/src/utils/tests/Makefile.am b/src/utils/tests/Makefile.am index ba676ce4..61e937ad 100644 --- a/src/utils/tests/Makefile.am +++ b/src/utils/tests/Makefile.am @@ -4,13 +4,14 @@ test_utils_SOURCES = test-utils.c test_utils_CPPFLAGS = \ -I $(top_srcdir)/src/utils \ + -DLIBNM_BUILD \ $(GTK_CFLAGS) \ - $(NMA_CFLAGS) + $(LIBNM_CFLAGS) test_utils_LDADD = \ - ${top_builddir}/src/utils/libutils.la \ + ${top_builddir}/src/utils/libutils-libnm.la \ $(GTK_LIBS) \ - $(NMA_LIBS) + $(LIBNM_LIBS) check-local: test-utils $(abs_builddir)/test-utils diff --git a/src/utils/tests/test-utils.c b/src/utils/tests/test-utils.c index 68d64726..10e11a5e 100644 --- a/src/utils/tests/test-utils.c +++ b/src/utils/tests/test-utils.c @@ -49,17 +49,12 @@ typedef struct { char *asdf11_adhoc_wpa_rsn; } TestData; -static GByteArray * +static GBytes * string_to_ssid (const char *str) { - GByteArray *ssid; - g_assert (str != NULL); - ssid = g_byte_array_sized_new (strlen (str)); - g_assert (ssid != NULL); - g_byte_array_append (ssid, (const guint8 *) str, strlen (str)); - return ssid; + return g_bytes_new (str, strlen (str)); } static char * @@ -69,7 +64,7 @@ make_hash (const char *str, guint32 wpa_flags, guint32 rsn_flags) { - GByteArray *ssid; + GBytes *ssid; char *hash, *hash2; ssid = string_to_ssid (str); @@ -83,7 +78,7 @@ make_hash (const char *str, /* Make sure they are the same each time */ g_assert (!strcmp (hash, hash2)); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); return hash; } diff --git a/src/utils/utils.c b/src/utils/utils.c index 269abe37..42db7468 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -17,7 +17,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 - 2011 Red Hat, Inc. + * Copyright 2007 - 2014 Red Hat, Inc. */ #include <config.h> @@ -27,9 +27,6 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> -#include <nm-setting-connection.h> -#include <nm-utils.h> - #include "utils.h" /* @@ -68,7 +65,12 @@ utils_ether_addr_valid (const struct ether_addr *test_addr) } char * -utils_hash_ap (const GByteArray *ssid, +utils_hash_ap ( +#ifdef LIBNM_BUILD + GBytes *ssid, +#else + const GByteArray *ssid, +#endif NM80211Mode mode, guint32 flags, guint32 wpa_flags, @@ -78,8 +80,13 @@ utils_hash_ap (const GByteArray *ssid, memset (&input[0], 0, sizeof (input)); - if (ssid) + if (ssid) { +#ifdef LIBNM_BUILD + memcpy (input, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); +#else memcpy (input, ssid->data, ssid->len); +#endif + } if (mode == NM_802_11_MODE_INFRA) input[32] |= (1 << 0); diff --git a/src/utils/utils.h b/src/utils/utils.h index a4827de9..5adb20d2 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -17,7 +17,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 - 2012 Red Hat, Inc. + * Copyright 2007 - 2014 Red Hat, Inc. */ #ifndef UTILS_H @@ -25,58 +25,38 @@ #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 <net/ethernet.h> #include <nm-access-point.h> - - -#if defined (__GNUC__) -#define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(GCC diagnostic ignored warning) -#elif defined (__clang__) -#define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(clang diagnostic ignored warning) -#endif - -/* you can only suppress a specific warning that the compiler - * understands. Otherwise you will get another compiler warning - * about invalid pragma option. - * It's not that bad however, because gcc and clang often have the - * same name for the same warning. */ - -#if defined (__GNUC__) -#define NM_PRAGMA_WARNING_DISABLE(warning) \ - _Pragma("GCC diagnostic push"); \ - _Pragma(_NM_PRAGMA_WARNING_DO(warning)) -#elif defined (__clang__) -#define NM_PRAGMA_WARNING_DISABLE(warning) \ - _Pragma("clang diagnostic push"); \ - _Pragma(_NM_PRAGMA_WARNING_DO(warning)) -#else -#define NM_PRAGMA_WARNING_DISABLE(warning) -#endif - -#if defined (__GNUC__) -#define NM_PRAGMA_WARNING_REENABLE \ - _Pragma("GCC diagnostic pop") -#elif defined (__clang__) -#define NM_PRAGMA_WARNING_REENABLE \ - _Pragma("clang diagnostic pop") #else -#define NM_PRAGMA_WARNING_REENABLE +#error neither LIBNM_BUILD nor LIBNM_GLIB_BUILD defined #endif - guint32 utils_freq_to_channel (guint32 freq); guint32 utils_channel_to_freq (guint32 channel, char *band); guint32 utils_find_next_channel (guint32 channel, int direction, char *band); gboolean utils_ether_addr_valid (const struct ether_addr *test_addr); +#ifdef LIBNM_BUILD +char *utils_hash_ap (GBytes *ssid, + NM80211Mode mode, + guint32 flags, + guint32 wpa_flags, + guint32 rsn_flags); +#else char *utils_hash_ap (const GByteArray *ssid, NM80211Mode mode, guint32 flags, guint32 wpa_flags, guint32 rsn_flags); +#endif char *utils_escape_notify_message (const char *src); diff --git a/src/wireless-security/Makefile.am b/src/wireless-security/Makefile.am index 42030509..78d52637 100644 --- a/src/wireless-security/Makefile.am +++ b/src/wireless-security/Makefile.am @@ -33,13 +33,14 @@ libwireless_security_la_SOURCES = \ libwireless_security_la_CPPFLAGS = \ $(GTK_CFLAGS) \ -DUIDIR=\""$(uidir)"\" \ + -DLIBNM_GLIB_BUILD \ $(NMA_CFLAGS) \ -I${top_srcdir}/src/utils libwireless_security_la_LIBADD = \ $(GTK_LIBS) \ $(NMA_LIBS) \ - ${top_builddir}/src/utils/libutils.la + ${top_builddir}/src/utils/libutils-libnm-glib.la uidir = $(datadir)/nm-applet ui_DATA = \ |