From a7a17f3725b4824b06887dfdaf5bb6ffe96e5a43 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Wed, 20 Feb 2019 11:06:21 +0000 Subject: [PATCH] Fix builds in mingw32. On mingw64, configure does not find declarations for inet_ntop() and inet_pton(), but does find implementations, and so does not try to compile the compat versions. On mingw32, configure find neither declarations or implementations, and so tries to compile the compat versions. However, there are declarations in ws2tcpip.h, and these do not have the same prototype as compat. The build fails, complaining about conflicting types for inet_ntop(). The declarations in ws2tcpip.h are #defines to Windows functions InetNtopA() and InetPtonA(). Which is not good, but we're stuck with it. Try to work around this by including ws2tcpip.h in the headers while checking for declarations. Unfortunately it looks like you can't do that when checking for implementations and substituting compat versions when not found. So only do that if we don't find declarations; we're already making sure that ws2tcpip.h is included via config.h in source modules. --- configure.ac | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index f927ef6c..0412f538 100644 --- a/configure.ac +++ b/configure.ac @@ -1514,9 +1514,20 @@ CFLAGS="$CFLAGS $LIBBSD_CFLAGS" ],[ AC_MSG_WARN([libbsd not found or usable; using embedded code instead]) ]) -AC_CHECK_DECLS([inet_pton,inet_ntop,strlcpy,arc4random,arc4random_uniform]) -AC_REPLACE_FUNCS(inet_pton) -AC_REPLACE_FUNCS(inet_ntop) +AC_CHECK_DECLS([inet_pton,inet_ntop,strlcpy,arc4random,arc4random_uniform], [], [], [ +AC_INCLUDES_DEFAULT +#ifdef HAVE_WS2TCPIP_H +#include +#endif +]) +AS_IF([test "x$ac_cv_have_decl_inet_pton" = xyes], + [], + [AC_REPLACE_FUNCS(inet_pton)] +) +AS_IF([test "x$ac_cv_have_decl_inet_ntop" = xyes], + [], + [AC_REPLACE_FUNCS(inet_ntop)] +) AC_REPLACE_FUNCS(strlcpy) AC_REPLACE_FUNCS(arc4random) AC_REPLACE_FUNCS(arc4random_uniform)