inet_ntop.m4 2.3 KB

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