inet_ntop.m4 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # inet_ntop.m4 serial 19
  2. dnl Copyright (C) 2005-2006, 2008-2014 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 Native Windows provides it in -lws2_32 instead, with a declaration in
  16. dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
  17. dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
  18. HAVE_INET_NTOP=1
  19. INET_NTOP_LIB=
  20. gl_PREREQ_SYS_H_WINSOCK2
  21. if test $HAVE_WINSOCK2_H = 1; then
  22. AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
  23. if test $ac_cv_have_decl_inet_ntop = yes; then
  24. dnl It needs to be overridden, because the stdcall calling convention
  25. dnl is not compliant with POSIX.
  26. REPLACE_INET_NTOP=1
  27. INET_NTOP_LIB="-lws2_32"
  28. else
  29. HAVE_DECL_INET_NTOP=0
  30. HAVE_INET_NTOP=0
  31. fi
  32. else
  33. gl_save_LIBS=$LIBS
  34. AC_SEARCH_LIBS([inet_ntop], [nsl resolv], [],
  35. [AC_CHECK_FUNCS([inet_ntop])
  36. if test $ac_cv_func_inet_ntop = no; then
  37. HAVE_INET_NTOP=0
  38. fi
  39. ])
  40. LIBS=$gl_save_LIBS
  41. if test "$ac_cv_search_inet_ntop" != "no" \
  42. && test "$ac_cv_search_inet_ntop" != "none required"; then
  43. INET_NTOP_LIB="$ac_cv_search_inet_ntop"
  44. fi
  45. AC_CHECK_HEADERS_ONCE([netdb.h])
  46. AC_CHECK_DECLS([inet_ntop],,,
  47. [[#include <arpa/inet.h>
  48. #if HAVE_NETDB_H
  49. # include <netdb.h>
  50. #endif
  51. ]])
  52. if test $ac_cv_have_decl_inet_ntop = no; then
  53. HAVE_DECL_INET_NTOP=0
  54. fi
  55. fi
  56. AC_SUBST([INET_NTOP_LIB])
  57. ])
  58. # Prerequisites of lib/inet_ntop.c.
  59. AC_DEFUN([gl_PREREQ_INET_NTOP], [
  60. AC_REQUIRE([gl_SOCKET_FAMILIES])
  61. ])