[vlc-commits] configure: Fix if_nametoindex detection

Hugo Beauzée-Luyssen git at videolan.org
Tue Dec 5 10:24:25 CET 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Dec  4 17:43:44 2017 +0100| [34d979557edd3f5ce8ef1e3dc1b4bbbf7d386327] | committer: Hugo Beauzée-Luyssen

configure: Fix if_nametoindex detection

This fixes win32 builds

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=34d979557edd3f5ce8ef1e3dc1b4bbbf7d386327
---

 configure.ac         | 10 +++++++++-
 include/vlc_fixups.h |  7 ++++---
 src/network/udp.c    |  1 +
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index f9bde2aa4c..4fb0e25f55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -680,7 +680,15 @@ AC_LINK_IFELSE([
         char dst[[sizeof(struct in_addr)]];
         inet_pton(AF_INET, "127.0.0.1", dst);
     ])],[AC_DEFINE([HAVE_INET_PTON],[1],[Define to 1 if you have inet_pton function])],[AC_LIBOBJ([inet_pton])])
-AC_CHECK_FUNCS([if_nameindex if_nametoindex])
+
+AC_SEARCH_LIBS([if_nametoindex], [iphlpapi], [
+  AS_IF([test "$ac_cv_search_if_nametoindex" != "none required"], [
+    SOCKET_LIBS="$ac_cv_search_if_nametoindex $SOCKET_LIBS"
+  ])
+  AC_DEFINE([HAVE_IF_NAMETOINDEX], [1], [Define to 1 if you have if_nametoindex function])
+])
+
+AC_CHECK_FUNCS([if_nameindex])
 VLC_RESTORE_FLAGS
 AC_SUBST(SOCKET_LIBS)
 
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 4888b782be..54efe8a7d3 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -411,13 +411,14 @@ struct if_nameindex
     unsigned if_index;
     char    *if_name;
 };
-# ifndef HAVE_IF_NAMETOINDEX
-#  define if_nametoindex(name)   atoi(name)
-# endif
 # define if_nameindex()         (errno = ENOBUFS, NULL)
 # define if_freenameindex(list) (void)0
 #endif
 
+#ifndef HAVE_IF_NAMETOINDEX
+# define if_nametoindex(name)   atoi(name)
+#endif
+
 #ifndef HAVE_STRUCT_TIMESPEC
 struct timespec {
     time_t  tv_sec;   /* Seconds */
diff --git a/src/network/udp.c b/src/network/udp.c
index d098fb1425..adc4376db9 100644
--- a/src/network/udp.c
+++ b/src/network/udp.c
@@ -41,6 +41,7 @@
 #ifdef _WIN32
 #   undef EAFNOSUPPORT
 #   define EAFNOSUPPORT WSAEAFNOSUPPORT
+#   include <iphlpapi.h>
 #else
 #   include <unistd.h>
 #   ifdef HAVE_NET_IF_H



More information about the vlc-commits mailing list