3 dnl Copyright (C) 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_PTON],
10 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
12 dnl Persuade Solaris <arpa/inet.h> to declare inet_pton.
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 AC_REQUIRE([AC_C_RESTRICT])
17 dnl Most platforms that provide inet_pton define it in libc.
18 dnl Solaris 8..10 provide inet_pton in libnsl instead.
19 dnl Solaris 2.6..7 provide inet_pton 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_PTON in order to avoid
30 dnl a name conflict at the linker level, even though the header file
31 dnl <ws2tcpip.h> declares inet_pton only if _WIN32_WINNT >= 0x0600.
33 AC_CHECK_DECLS([inet_pton],,, [[#include <ws2tcpip.h>]])
34 if test $ac_cv_have_decl_inet_pton = yes; then
35 INET_PTON_LIB="-lws2_32"
41 AC_SEARCH_LIBS([inet_pton], [nsl resolv network], [],
42 [AC_CHECK_FUNCS([inet_pton])
43 if test $ac_cv_func_inet_pton = no; then
49 if test "$ac_cv_search_inet_pton" != "no" \
50 && test "$ac_cv_search_inet_pton" != "none required"; then
51 INET_PTON_LIB="$ac_cv_search_inet_pton"
54 AC_CHECK_HEADERS_ONCE([netdb.h])
55 AC_CHECK_DECLS([inet_pton],,,
56 [[#include <arpa/inet.h>
61 if test $ac_cv_have_decl_inet_pton = no; then
65 AC_SUBST([INET_PTON_LIB])
68 # Prerequisites of lib/inet_pton.c.
69 AC_DEFUN([gl_PREREQ_INET_PTON], [
70 AC_REQUIRE([gl_SOCKET_FAMILIES])