empserver/m4/my_windows_api.m4
Markus Armbruster a164390d1f w32: Modernize for MinGW 6.0.0, and clean up
We provide gettimeofday() only #ifdef _MSC_VER, but declare it
unconditionally in our own sys/time.h.  This is asking for trouble.
Declare it only #ifdef _MSC_VER, else pull in MinGW's sys/time.h with
#include_next.

Likewise, define macros ftruncate(), S_IRUSR & friends in our own
unistd.h only #ifdef _MSC_VER, else pull in MinGW's unistd.h with
#include_next.  The #include <getopt.h> is now useless, drop.

src/lib/commands/info.c relies on sys/time.h including windows.h.
Unclean, and no longer the case with MinGW.  Include it directly.

MinGW provides EWOULDBLOCK.  Drop our replacement.

MinGW provides inet_ntop() in ws2tcpip.h, but only if feature test
macro _WIN32_WINNT >= 0x600, i.e. Windows Vista or later.  It defaults
to 0x0502 (Windows Server 2003).  Make configure #define _WIN32_WINNT
0x0601 in config.h.  This requests Windows 7.  Trying to support Vista
feels unwise.  Include ws2tcpip.h, and drop our replacement.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-02-13 19:25:18 +01:00

22 lines
584 B
Text

AC_DEFUN([MY_WINDOWS_API],
[
AC_MSG_CHECKING([whether compiling for Windows API])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([[#ifdef _WIN32
{ /* Here's a nickel, kid */
#endif]])],
[Windows_API=no],
[Windows_API=yes])
AC_MSG_RESULT([$Windows_API])
if test $Windows_API = yes; then
AC_DEFINE([WINDOWS], 1, [Define if compiling for Windows API])
AC_DEFINE([WIN32_LEAN_AND_MEAN], 1,
[Define to make Windows includes pull in less junk])
AC_DEFINE([_WIN32_WINNT], 0x0601,
[Request Windows 7])
LIBS_SOCKETS="-lws2_32"
else
LIBS_SOCKETS=
fi
AC_SUBST([LIBS_SOCKETS])
])