annotate m4/inet_ntop.m4 @ 15633:c2c292001fc0

inet_ntop: Support for MSVC on Windows Vista or newer. * lib/arpa_inet.in.h (inet_ntop): Also consider REPLACE_INET_NTOP. * lib/inet_ntop.c (rpl_inet_ntop): Use a simple wrapper if HAVE_DECL_INET_NTOP is defined. * m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): Invoke gl_PREREQ_SYS_H_WINSOCK2. On platforms with <winsock2.h>, test whether inet_ntop is declared in <ws2tcpip.h>. If so, arrange to replace it. * m4/arpa_inet_h.m4 (gl_ARPA_INET_H_DEFAULTS): Initialize REPLACE_INET_NTOP. * modules/arpa_inet (Makefile.am): Substitute REPLACE_INET_NTOP. * modules/inet_ntop (Files): Add m4/sys_socket_h.m4. (Depends-on, configure.ac): Update condition. * doc/posix-functions/inet_ntop.texi: Mention the MSVC problem.
author Bruno Haible <bruno@clisp.org>
date Sat, 17 Sep 2011 14:56:11 +0200
parents 9d4b273deacd
children 54ccb1d64384
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15633
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
1 # inet_ntop.m4 serial 17
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 14037
diff changeset
2 dnl Copyright (C) 2005-2006, 2008-2011 Free Software Foundation, Inc.
5825
96441be32be1 New module 'inet_ntop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
96441be32be1 New module 'inet_ntop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
96441be32be1 New module 'inet_ntop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
96441be32be1 New module 'inet_ntop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
13062
fcd6c0f53dc8 Rename gl_INET_NTOP.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
7 AC_DEFUN([gl_FUNC_INET_NTOP],
5825
96441be32be1 New module 'inet_ntop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
10018
8406478f0d13 Ensure the system declares inet_ntop, inet_pton when possible.
Bruno Haible <bruno@clisp.org>
parents: 10010
diff changeset
9 dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
8406478f0d13 Ensure the system declares inet_ntop, inet_pton when possible.
Bruno Haible <bruno@clisp.org>
parents: 10010
diff changeset
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
8406478f0d13 Ensure the system declares inet_ntop, inet_pton when possible.
Bruno Haible <bruno@clisp.org>
parents: 10010
diff changeset
11
15633
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
12 AC_REQUIRE([AC_C_RESTRICT])
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
13
12225
e06ba2ed6c0f Avoid link error for inet_ntop on Solaris.
Simon Josefsson <simon@josefsson.org>
parents: 11450
diff changeset
14 dnl Most platforms that provide inet_ntop define it in libc.
e06ba2ed6c0f Avoid link error for inet_ntop on Solaris.
Simon Josefsson <simon@josefsson.org>
parents: 11450
diff changeset
15 dnl Solaris 8..10 provide inet_ntop in libnsl instead.
15633
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
16 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
17 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
18 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
14982
734141d3f8bf inet_ntop. getaddrinfo: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14685
diff changeset
19 HAVE_INET_NTOP=1
15633
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
20 INET_NTOP_LIB=
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
21 gl_PREREQ_SYS_H_WINSOCK2
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
22 if test $HAVE_WINSOCK2_H = 1; then
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
23 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
24 if test $ac_cv_have_decl_inet_ntop = yes; then
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
25 dnl It needs to be overridden, because the stdcall calling convention
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
26 dnl is not compliant with POSIX.
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
27 REPLACE_INET_NTOP=1
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
28 INET_NTOP_LIB="-lws2_32"
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
29 else
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
30 HAVE_DECL_INET_NTOP=0
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
31 HAVE_INET_NTOP=0
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
32 fi
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
33 else
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
34 gl_save_LIBS=$LIBS
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
35 AC_SEARCH_LIBS([inet_ntop], [nsl], [],
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
36 [AC_CHECK_FUNCS([inet_ntop])
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
37 if test $ac_cv_func_inet_ntop = no; then
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
38 HAVE_INET_NTOP=0
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
39 fi
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
40 ])
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
41 LIBS=$gl_save_LIBS
14982
734141d3f8bf inet_ntop. getaddrinfo: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14685
diff changeset
42
15633
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
43 if test "$ac_cv_search_inet_ntop" != "no" \
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
44 && test "$ac_cv_search_inet_ntop" != "none required"; then
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
45 INET_NTOP_LIB="$ac_cv_search_inet_ntop"
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
46 fi
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
47
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
48 AC_CHECK_HEADERS_ONCE([netdb.h])
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
49 AC_CHECK_DECLS([inet_ntop],,,
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
50 [[#include <arpa/inet.h>
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
51 #if HAVE_NETDB_H
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
52 # include <netdb.h>
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
53 #endif
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
54 ]])
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
55 if test $ac_cv_have_decl_inet_ntop = no; then
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
56 HAVE_DECL_INET_NTOP=0
c2c292001fc0 inet_ntop: Support for MSVC on Windows Vista or newer.
Bruno Haible <bruno@clisp.org>
parents: 15618
diff changeset
57 fi
12225
e06ba2ed6c0f Avoid link error for inet_ntop on Solaris.
Simon Josefsson <simon@josefsson.org>
parents: 11450
diff changeset
58 fi
e06ba2ed6c0f Avoid link error for inet_ntop on Solaris.
Simon Josefsson <simon@josefsson.org>
parents: 11450
diff changeset
59 AC_SUBST([INET_NTOP_LIB])
14982
734141d3f8bf inet_ntop. getaddrinfo: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14685
diff changeset
60 ])
734141d3f8bf inet_ntop. getaddrinfo: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14685
diff changeset
61
734141d3f8bf inet_ntop. getaddrinfo: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14685
diff changeset
62 # Prerequisites of lib/inet_ntop.c.
734141d3f8bf inet_ntop. getaddrinfo: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14685
diff changeset
63 AC_DEFUN([gl_PREREQ_INET_NTOP], [
5825
96441be32be1 New module 'inet_ntop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 AC_REQUIRE([gl_SOCKET_FAMILIES])
96441be32be1 New module 'inet_ntop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 ])