aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/glib-2.0/glib-2.0-2.26.1/configure-ipv6.patch
blob: 548e0dc650038d215ce8dda5024b2fd1035e509d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From a619a217e3e5aa5345db631213aec5a3684a3001 Mon Sep 17 00:00:00 2001
Subject: [PATCH] autodetect in6addr_{any,loopback} availability

Fixes linking error on systems which choose not to support ipv6:
./.libs/libgio-2.0.so: undefined reference to `in6addr_loopback'
./.libs/libgio-2.0.so: undefined reference to `in6addr_any'

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 configure.ac       |   31 +++++++++++++++++++++++++++++++
 gio/ginetaddress.c |   16 ++++++++++++++--
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7114014..023db49 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1019,6 +1019,37 @@ if test $glib_native_win32 = no; then
   AC_SUBST(LIBASYNCNS_LIBADD)
 fi
 
+dnl handle --disable-ipv6
+AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]))
+if test "$ipv6" != "no"; then
+  AC_DEFINE(HAVE_IPV6, 1, [Define if IPv6 is available])
+
+  AC_MSG_CHECKING([for struct in6addr_any])
+  AC_TRY_LINK(
+   [#define IN_AUTOCONF
+     #include <sys/types.h>
+     #include <sys/socket.h>
+     #include <netinet/in.h>],
+   [struct in6_addr a = in6addr_any;
+    return a.s6_addr[0];],
+   [AC_MSG_RESULT(yes)
+    AC_DEFINE(HAVE_IN6ADDR_ANY, 1, [Define if in6addr_any is available])],
+   [AC_MSG_RESULT(no)]
+  )
+  AC_MSG_CHECKING([for struct in6addr_loopback])
+  AC_TRY_LINK(
+   [#define IN_AUTOCONF
+     #include <sys/types.h>
+     #include <sys/socket.h>
+     #include <netinet/in.h>],
+   [struct in6_addr a = in6addr_loopback;
+    return a.s6_addr[0];],
+   [AC_MSG_RESULT(yes)
+    AC_DEFINE(HAVE_IN6ADDR_LOOPBACK, 1, [Define if in6addr_loopback is available])],
+   [AC_MSG_RESULT(no)]
+  )
+fi
+
 case $host in
   *-*-solaris* )
      AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Needed to get declarations for msg_control and msg_controllen on Solaris)
diff --git a/gio/ginetaddress.c b/gio/ginetaddress.c
index 0f67e4f..ed29be2 100644
--- a/gio/ginetaddress.c
+++ b/gio/ginetaddress.c
@@ -484,7 +484,13 @@ g_inet_address_new_loopback (GSocketFamily family)
       return g_inet_address_new_from_bytes (addr, family);
     }
   else
-    return g_inet_address_new_from_bytes (in6addr_loopback.s6_addr, family);
+    {
+#ifdef HAVE_IN6ADDR_LOOPBACK
+      return g_inet_address_new_from_bytes (in6addr_loopback.s6_addr, family);
+#else
+      return NULL;
+#endif
+    }
 }
 
 /**
@@ -511,7 +517,13 @@ g_inet_address_new_any (GSocketFamily family)
       return g_inet_address_new_from_bytes (addr, family);
     }
   else
-    return g_inet_address_new_from_bytes (in6addr_any.s6_addr, family);
+    {
+#ifdef HAVE_IN6ADDR_ANY
+      return g_inet_address_new_from_bytes (in6addr_any.s6_addr, family);
+#else
+      return NULL;
+#endif
+    }
 }
 
 
-- 
1.7.2.3