]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Add custom check for inet_pton()/inet_ntop() on MinGW/WIN32
authorGert Doering <gert@greenie.muc.de>
Tue, 22 Sep 2015 20:31:24 +0000 (22:31 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 6 Oct 2015 07:34:50 +0000 (09:34 +0200)
More recent MinGW versions have these functions (if compiling at
_VISTA level or higher), but the normal AC_CHECK_FUNCS() check does
not find them because the necessary header file is not #include'd and
the libws2_32 not linked - and our compat functions are incompatible
with the definitions in <ws2tcpip.h>, so compilation fails.

Fix with a custom AC_LINK_IFELSE()/AC_LANG_PROGRAM() construct.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Tested-by: Heiko Hund <heiko.hund@sophos.com>
Tested-by: Samuli Seppänen <samuli@openvpn.net>
Lazy-ACK-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1442953884-54602-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10165

configure.ac

index 51ef93b0b628fd26be0894025714fb22af890b45..31cff257af78eb1d6ba1f62c5efedef7af88cab7 100644 (file)
@@ -632,7 +632,7 @@ AC_SUBST([SOCKETS_LIBS])
 
 old_LIBS="${LIBS}"
 LIBS="${LIBS} ${SOCKETS_LIBS}"
-AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton])
+AC_CHECK_FUNCS([sendmsg recvmsg])
 # Windows use stdcall for winsock so we cannot auto detect these
 m4_define(
        [SOCKET_FUNCS],
@@ -644,6 +644,27 @@ m4_define(
        [setsockopt getsockopt getsockname poll]dnl
 )
 if test "${WIN32}" = "yes"; then
+# normal autoconf function checking does not find inet_ntop/inet_pton
+# because they need to include the actual header file and link ws2_32.dll
+       LIBS="${LIBS} -lws2_32"
+       AC_MSG_CHECKING([for MinGW inet_ntop()/inet_pton()])
+       AC_LINK_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [[
+#include <ws2tcpip.h>
+                       ]],
+                       [[
+int r = (int) inet_ntop (0, NULL, NULL, 0);
+    r += inet_pton(AF_INET, NULL, NULL);
+return r;
+                       ]]
+               )],
+               [AC_MSG_RESULT([OK])
+                AC_DEFINE([HAVE_INET_NTOP],[1],[MinGW inet_ntop])
+                AC_DEFINE([HAVE_INET_PTON],[1],[MinGW inet_pton])
+               ],
+               [AC_MSG_RESULT([not found])]
+       )
        m4_foreach(
                [F],
                m4_split(SOCKET_FUNCS SOCKET_OPT_FUNCS),
@@ -651,6 +672,7 @@ if test "${WIN32}" = "yes"; then
                        AC_DEFINE([UF], [1], [Win32 builtin])
        )
 else
+       AC_CHECK_FUNCS([inet_ntop inet_pton])
        AC_CHECK_FUNCS(
                SOCKET_FUNCS,
                ,