| 1 |
# inet_ntop.m4 |
| 2 |
# serial 22 |
| 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. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
AC_DEFUN([gl_FUNC_INET_NTOP], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) |
| 12 |
|
| 13 |
dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop. |
| 14 |
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 15 |
|
| 16 |
AC_REQUIRE([AC_C_RESTRICT]) |
| 17 |
|
| 18 |
dnl Most platforms that provide inet_ntop define it in libc. |
| 19 |
dnl Solaris 8..10 provide inet_ntop in libnsl instead. |
| 20 |
dnl Solaris 2.6..7 provide inet_ntop in libresolv instead. |
| 21 |
dnl Haiku provides it in -lnetwork. |
| 22 |
dnl Native Windows provides it in -lws2_32 instead, with a declaration in |
| 23 |
dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl |
| 24 |
dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). |
| 25 |
HAVE_INET_NTOP=1 |
| 26 |
INET_NTOP_LIB= |
| 27 |
gl_PREREQ_SYS_H_WINSOCK2 |
| 28 |
if test $HAVE_WINSOCK2_H = 1; then |
| 29 |
dnl It needs to be overridden, because the stdcall calling convention |
| 30 |
dnl is not compliant with POSIX. Set REPLACE_INET_NTOP in order to avoid |
| 31 |
dnl a name conflict at the linker level, even though the header file |
| 32 |
dnl <ws2tcpip.h> declares inet_ntop only if _WIN32_WINNT >= 0x0600. |
| 33 |
REPLACE_INET_NTOP=1 |
| 34 |
AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]]) |
| 35 |
if test $ac_cv_have_decl_inet_ntop = yes; then |
| 36 |
INET_NTOP_LIB="-lws2_32" |
| 37 |
else |
| 38 |
HAVE_DECL_INET_NTOP=0 |
| 39 |
fi |
| 40 |
else |
| 41 |
gl_saved_LIBS=$LIBS |
| 42 |
AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [], |
| 43 |
[AC_CHECK_FUNCS([inet_ntop]) |
| 44 |
if test $ac_cv_func_inet_ntop = no; then |
| 45 |
HAVE_INET_NTOP=0 |
| 46 |
fi |
| 47 |
]) |
| 48 |
LIBS=$gl_saved_LIBS |
| 49 |
|
| 50 |
if test "$ac_cv_search_inet_ntop" != "no" \ |
| 51 |
&& test "$ac_cv_search_inet_ntop" != "none required"; then |
| 52 |
INET_NTOP_LIB="$ac_cv_search_inet_ntop" |
| 53 |
fi |
| 54 |
|
| 55 |
AC_CHECK_HEADERS_ONCE([netdb.h]) |
| 56 |
AC_CHECK_DECLS([inet_ntop],,, |
| 57 |
[[#include <arpa/inet.h> |
| 58 |
#if HAVE_NETDB_H |
| 59 |
# include <netdb.h> |
| 60 |
#endif |
| 61 |
]]) |
| 62 |
if test $ac_cv_have_decl_inet_ntop = no; then |
| 63 |
HAVE_DECL_INET_NTOP=0 |
| 64 |
fi |
| 65 |
fi |
| 66 |
AC_SUBST([INET_NTOP_LIB]) |
| 67 |
]) |
| 68 |
|
| 69 |
# Prerequisites of lib/inet_ntop.c. |
| 70 |
AC_DEFUN([gl_PREREQ_INET_NTOP], [ |
| 71 |
AC_REQUIRE([gl_SOCKET_FAMILIES]) |
| 72 |
]) |