[vlc-commits] configure: check if if_nametoindex is available on Windows

Steve Lhomme git at videolan.org
Fri Jun 19 08:25:52 CEST 2020


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Apr 30 10:53:27 2020 +0200| [fb59b22084917af874ecdab2a38b65996711699f] | committer: Steve Lhomme

configure: check if if_nametoindex is available on Windows

It may link with iphlpapi but be forbidden in UWP.

This test relies on the fact that -Werror-implicit-function-declaration works
in the compiler. And that's why it's done after it's enabled.

It's only used for the --miface option to set the preferred multicast interface.

(cherry picked from commit 424e8991d357e948627bd8ce8872ce7e8a5de6a7) (edited)

edited:
- if_nametoindex was already detected, so just moved the code after the
 -Werror-implicit-function-declaration test

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

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

 configure.ac | 101 ++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 51 insertions(+), 50 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1eb7d02631..1a084aadb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -690,56 +690,6 @@ dnl Check for max_align_t
 AC_CHECK_TYPES([max_align_t],,,
 [#include <stddef.h>])
 
-dnl Checks for socket stuff
-VLC_SAVE_FLAGS
-SOCKET_LIBS=""
-AC_SEARCH_LIBS(connect, [socket], [
-  AS_IF([test "$ac_cv_search_connect" != "none required"], [
-    SOCKET_LIBS="$ac_cv_search_connect"
-  ])
-], [
-  AS_IF([test "${SYS}" = "mingw32"], [
-    SOCKET_LIBS="-lws2_32 -liphlpapi"
-  ])
-])
-
-AC_SEARCH_LIBS([inet_pton], [nsl], [
- AS_IF([test "$ac_cv_search_inet_pton" != "none required"], [
-    SOCKET_LIBS="$ac_cv_search_inet_pton $SOCKET_LIBS"
-  ])
-],, [${SOCKET_LIBS}])
-
-LIBS="${LIBS} ${SOCKET_LIBS}"
-CFLAGS="${CFLAGS} -Werror-implicit-function-declaration"
-AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([#ifdef _WIN32
-        #include <ws2tcpip.h>
-        #include <windows.h>
-        # if _WIN32_WINNT < 0x600
-        #  error Needs vista+
-        # endif
-        #else
-        #include <sys/socket.h>
-        #include <arpa/inet.h>
-        #endif], [
-        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_LINK_IFELSE([
-    AC_LANG_PROGRAM([#ifdef _WIN32
-        #include <iphlpapi.h>
-        #else
-        #include <sys/types.h>
-        #include <sys/socket.h>
-        #include <net/if.h>
-        #endif], [
-        if_nametoindex("");
-    ])],[AC_DEFINE([HAVE_IF_NAMETOINDEX],[1],[Define to 1 if you have if_nametoindex function])])
-AC_CHECK_TYPES([struct if_nameindex],,,[#include <net/if.h>])
-AC_CHECK_FUNCS([if_nameindex])
-VLC_RESTORE_FLAGS
-AC_SUBST(SOCKET_LIBS)
-
 dnl Check for socklen_t
 AH_TEMPLATE(socklen_t, [Define to `int' if <sys/socket.h> does not define.])
 AC_CACHE_CHECK([for socklen_t in sys/socket.h], dnl ` (fix VIM syntax highlight
@@ -1007,9 +957,60 @@ dnl
 AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security], [CFLAGS])
 AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security], [CXXFLAGS])
 
+dnl -Werror-implicit-function-declaration is used for the if_nametoindex detection with winstore
 AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local], [CFLAGS])
 AX_APPEND_COMPILE_FLAGS([-pipe], [CFLAGS])
 
+dnl Checks for socket stuff
+VLC_SAVE_FLAGS
+SOCKET_LIBS=""
+AC_SEARCH_LIBS(connect, [socket], [
+  AS_IF([test "$ac_cv_search_connect" != "none required"], [
+    SOCKET_LIBS="$ac_cv_search_connect"
+  ])
+], [
+  AS_IF([test "${SYS}" = "mingw32"], [
+    SOCKET_LIBS="-lws2_32 -liphlpapi"
+  ])
+])
+
+AC_SEARCH_LIBS([inet_pton], [nsl], [
+ AS_IF([test "$ac_cv_search_inet_pton" != "none required"], [
+    SOCKET_LIBS="$ac_cv_search_inet_pton $SOCKET_LIBS"
+  ])
+],, [${SOCKET_LIBS}])
+
+LIBS="${LIBS} ${SOCKET_LIBS}"
+CFLAGS="${CFLAGS} -Werror-implicit-function-declaration"
+AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([#ifdef _WIN32
+        #include <ws2tcpip.h>
+        #include <windows.h>
+        # if _WIN32_WINNT < 0x600
+        #  error Needs vista+
+        # endif
+        #else
+        #include <sys/socket.h>
+        #include <arpa/inet.h>
+        #endif], [
+        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_LINK_IFELSE([
+    AC_LANG_PROGRAM([#ifdef _WIN32
+        #include <iphlpapi.h>
+        #else
+        #include <sys/types.h>
+        #include <sys/socket.h>
+        #include <net/if.h>
+        #endif], [
+        if_nametoindex("");
+    ])],[AC_DEFINE([HAVE_IF_NAMETOINDEX],[1],[Define to 1 if you have if_nametoindex function])])
+AC_CHECK_TYPES([struct if_nameindex],,,[#include <net/if.h>])
+AC_CHECK_FUNCS([if_nameindex])
+VLC_RESTORE_FLAGS
+AC_SUBST(SOCKET_LIBS)
+
 dnl
 dnl  Debugging mode
 dnl



More information about the vlc-commits mailing list