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
... | ... |
@@ -632,7 +632,7 @@ AC_SUBST([SOCKETS_LIBS]) |
632 | 632 |
|
633 | 633 |
old_LIBS="${LIBS}" |
634 | 634 |
LIBS="${LIBS} ${SOCKETS_LIBS}" |
635 |
-AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton]) |
|
635 |
+AC_CHECK_FUNCS([sendmsg recvmsg]) |
|
636 | 636 |
# Windows use stdcall for winsock so we cannot auto detect these |
637 | 637 |
m4_define( |
638 | 638 |
[SOCKET_FUNCS], |
... | ... |
@@ -644,6 +644,27 @@ m4_define( |
644 | 644 |
[setsockopt getsockopt getsockname poll]dnl |
645 | 645 |
) |
646 | 646 |
if test "${WIN32}" = "yes"; then |
647 |
+# normal autoconf function checking does not find inet_ntop/inet_pton |
|
648 |
+# because they need to include the actual header file and link ws2_32.dll |
|
649 |
+ LIBS="${LIBS} -lws2_32" |
|
650 |
+ AC_MSG_CHECKING([for MinGW inet_ntop()/inet_pton()]) |
|
651 |
+ AC_LINK_IFELSE( |
|
652 |
+ [AC_LANG_PROGRAM( |
|
653 |
+ [[ |
|
654 |
+#include <ws2tcpip.h> |
|
655 |
+ ]], |
|
656 |
+ [[ |
|
657 |
+int r = (int) inet_ntop (0, NULL, NULL, 0); |
|
658 |
+ r += inet_pton(AF_INET, NULL, NULL); |
|
659 |
+return r; |
|
660 |
+ ]] |
|
661 |
+ )], |
|
662 |
+ [AC_MSG_RESULT([OK]) |
|
663 |
+ AC_DEFINE([HAVE_INET_NTOP],[1],[MinGW inet_ntop]) |
|
664 |
+ AC_DEFINE([HAVE_INET_PTON],[1],[MinGW inet_pton]) |
|
665 |
+ ], |
|
666 |
+ [AC_MSG_RESULT([not found])] |
|
667 |
+ ) |
|
647 | 668 |
m4_foreach( |
648 | 669 |
[F], |
649 | 670 |
m4_split(SOCKET_FUNCS SOCKET_OPT_FUNCS), |
... | ... |
@@ -651,6 +672,7 @@ if test "${WIN32}" = "yes"; then |
651 | 651 |
AC_DEFINE([UF], [1], [Win32 builtin]) |
652 | 652 |
) |
653 | 653 |
else |
654 |
+ AC_CHECK_FUNCS([inet_ntop inet_pton]) |
|
654 | 655 |
AC_CHECK_FUNCS( |
655 | 656 |
SOCKET_FUNCS, |
656 | 657 |
, |