3 dnl Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_INET_NTOP],
10 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
12 dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 AC_REQUIRE([AC_C_RESTRICT])
17 dnl Most platforms that provide inet_ntop define it in libc.
18 dnl Solaris 8..10 provide inet_ntop in libnsl instead.
19 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
20 dnl Haiku provides it in -lnetwork.
21 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
22 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
23 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
26 gl_PREREQ_SYS_H_WINSOCK2
27 if test $HAVE_WINSOCK2_H = 1; then
28 dnl It needs to be overridden, because the stdcall calling convention
29 dnl is not compliant with POSIX. Set REPLACE_INET_NTOP in order to avoid
30 dnl a name conflict at the linker level, even though the header file
31 dnl <ws2tcpip.h> declares inet_ntop only if _WIN32_WINNT >= 0x0600.
33 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
34 if test $ac_cv_have_decl_inet_ntop = yes; then
35 INET_NTOP_LIB="-lws2_32"
41 AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [],
42 [AC_CHECK_FUNCS([inet_ntop])
43 if test $ac_cv_func_inet_ntop = no; then
49 if test "$ac_cv_search_inet_ntop" != "no" \
50 && test "$ac_cv_search_inet_ntop" != "none required"; then
51 INET_NTOP_LIB="$ac_cv_search_inet_ntop"
54 AC_CHECK_HEADERS_ONCE([netdb.h])
55 AC_CHECK_DECLS([inet_ntop],,,
56 [[#include <arpa/inet.h>
61 if test $ac_cv_have_decl_inet_ntop = no; then
65 AC_SUBST([INET_NTOP_LIB])
68 # Prerequisites of lib/inet_ntop.c.
69 AC_DEFUN([gl_PREREQ_INET_NTOP], [
70 AC_REQUIRE([gl_SOCKET_FAMILIES])