changeset 22867:0bd86dae2734

Use pkg-config to detect NetworkManager. Also, fail if it isn't present, suggesting the use of --disable-nm in that case.
author Richard Laager <rlaager@wiktel.com>
date Sun, 11 May 2008 00:27:18 +0000
parents 40364452eeaa
children 8dadddab10ed
files configure.ac libpurple/Makefile.am libpurple/network.c pidgin/gtkdialogs.c
diffstat 4 files changed, 20 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Sat May 10 23:21:34 2008 +0000
+++ b/configure.ac	Sun May 11 00:27:18 2008 +0000
@@ -1221,7 +1221,15 @@
 
 dnl Check for NetworkManager.h; if we don't have it, oh well
 	if test "x$enable_nm" = "xyes" ; then
-		AC_CHECK_HEADERS(NetworkManager/NetworkManager.h, [], enable_nm=no)
+		PKG_CHECK_MODULES(NETWORKMANAGER, [NetworkManager], [
+			AC_SUBST(NETWORKMANAGER_CFLAGS)
+			AC_SUBST(NETWORKMANAGER_LIBS)
+			AC_DEFINE(HAVE_NETWORKMANAGER, 1, [Define if we have NetworkManager.])
+		], [
+			AC_MSG_ERROR([
+NetworkManager development headers not found.
+Use --disable-nm if you do not need NetworkManager support.
+])])
 	fi
 else
 	enable_nm=no
--- a/libpurple/Makefile.am	Sat May 10 23:21:34 2008 +0000
+++ b/libpurple/Makefile.am	Sun May 11 00:27:18 2008 +0000
@@ -244,7 +244,7 @@
 	$(DBUS_LIBS) \
 	$(GLIB_LIBS) \
 	$(LIBXML_LIBS) \
-	$(LIBNM_LIBS) \
+	$(NETWORKMANAGER_LIBS) \
 	$(INTLLIBS) \
 	-lm
 
@@ -258,4 +258,4 @@
 	$(DEBUG_CFLAGS) \
 	$(DBUS_CFLAGS) \
 	$(LIBXML_CFLAGS) \
-	$(LIBNM_CFLAGS)
+	$(NETWORKMANAGER_CFLAGS)
--- a/libpurple/network.c	Sat May 10 23:21:34 2008 +0000
+++ b/libpurple/network.c	Sun May 11 00:27:18 2008 +0000
@@ -59,9 +59,9 @@
 #  define HX_SIZE_OF_IFREQ(a) sizeof(a)
 #endif
 
-#ifdef HAVE_NETWORKMANAGER_NETWORKMANAGER_H
+#ifdef HAVE_NETWORKMANAGER
 #include <dbus/dbus-glib.h>
-#include <NetworkManager/NetworkManager.h>
+#include <NetworkManager.h>
 
 static DBusGConnection *nm_conn = NULL;
 static DBusGProxy *nm_proxy = NULL;
@@ -81,7 +81,7 @@
 	UPnPMappingAddRemove *mapping_data;
 };
 
-#ifdef HAVE_NETWORKMANAGER_NETWORKMANAGER_H
+#ifdef HAVE_NETWORKMANAGER
 static NMState nm_get_network_state(void);
 #endif
 
@@ -593,7 +593,7 @@
 gboolean
 purple_network_is_available(void)
 {
-#ifdef HAVE_NETWORKMANAGER_NETWORKMANAGER_H
+#ifdef HAVE_NETWORKMANAGER
 	NMState state = nm_get_network_state();
 	if (state == NM_STATE_UNKNOWN)
 	{
@@ -612,7 +612,7 @@
 #endif
 }
 
-#ifdef HAVE_NETWORKMANAGER_NETWORKMANAGER_H
+#ifdef HAVE_NETWORKMANAGER
 static void
 nm_update_state(NMState state)
 {
@@ -700,7 +700,7 @@
 void
 purple_network_init(void)
 {
-#ifdef HAVE_NETWORKMANAGER_NETWORKMANAGER_H
+#ifdef HAVE_NETWORKMANAGER
 	GError *error = NULL;
 #endif
 #ifdef _WIN32
@@ -729,7 +729,7 @@
 	if(purple_prefs_get_bool("/purple/network/map_ports") || purple_prefs_get_bool("/purple/network/auto_ip"))
 		purple_upnp_discover(NULL, NULL);
 
-#ifdef HAVE_NETWORKMANAGER_NETWORKMANAGER_H
+#ifdef HAVE_NETWORKMANAGER
 	nm_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
 	if (!nm_conn) {
 		purple_debug_warning("network", "Error connecting to DBus System service: %s.\n", error->message);
@@ -762,7 +762,7 @@
 void
 purple_network_uninit(void)
 {
-#ifdef HAVE_NETWORKMANAGER_NETWORKMANAGER_H
+#ifdef HAVE_NETWORKMANAGER
 	if (nm_proxy) {
 		dbus_g_proxy_disconnect_signal(nm_proxy, "StateChange", G_CALLBACK(nm_state_change_cb), NULL);
 		g_object_unref(G_OBJECT(nm_proxy));
--- a/pidgin/gtkdialogs.c	Sat May 10 23:21:34 2008 +0000
+++ b/pidgin/gtkdialogs.c	Sun May 11 00:27:18 2008 +0000
@@ -629,7 +629,7 @@
 #endif
 
 #ifndef _WIN32
-#ifdef HAVE_NETWORKMANAGER_NETWORKMANAGER_H
+#ifdef HAVE_NETWORKMANAGER
 	g_string_append(str, "    <b>NetworkManager:</b> Enabled<br/>");
 #else
 	g_string_append(str, "    <b>NetworkManager:</b> Disabled<br/>");