inet_pton.m4 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # inet_pton.m4 serial 17
  2. dnl Copyright (C) 2006, 2008-2017 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_PTON],
  7. [
  8. AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
  9. dnl Persuade Solaris <arpa/inet.h> to declare inet_pton.
  10. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  11. AC_REQUIRE([AC_C_RESTRICT])
  12. dnl Most platforms that provide inet_pton define it in libc.
  13. dnl Solaris 8..10 provide inet_pton in libnsl instead.
  14. dnl Solaris 2.6..7 provide inet_pton 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_PTON=1
  19. INET_PTON_LIB=
  20. gl_PREREQ_SYS_H_WINSOCK2
  21. if test $HAVE_WINSOCK2_H = 1; then
  22. AC_CHECK_DECLS([inet_pton],,, [[#include <ws2tcpip.h>]])
  23. if test $ac_cv_have_decl_inet_pton = yes; then
  24. dnl It needs to be overridden, because the stdcall calling convention
  25. dnl is not compliant with POSIX.
  26. REPLACE_INET_PTON=1
  27. INET_PTON_LIB="-lws2_32"
  28. else
  29. HAVE_DECL_INET_PTON=0
  30. HAVE_INET_PTON=0
  31. fi
  32. else
  33. gl_save_LIBS=$LIBS
  34. AC_SEARCH_LIBS([inet_pton], [nsl resolv], [],
  35. [AC_CHECK_FUNCS([inet_pton])
  36. if test $ac_cv_func_inet_pton = no; then
  37. HAVE_INET_PTON=0
  38. fi
  39. ])
  40. LIBS=$gl_save_LIBS
  41. if test "$ac_cv_search_inet_pton" != "no" \
  42. && test "$ac_cv_search_inet_pton" != "none required"; then
  43. INET_PTON_LIB="$ac_cv_search_inet_pton"
  44. fi
  45. AC_CHECK_HEADERS_ONCE([netdb.h])
  46. AC_CHECK_DECLS([inet_pton],,,
  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_pton = no; then
  53. HAVE_DECL_INET_PTON=0
  54. fi
  55. fi
  56. AC_SUBST([INET_PTON_LIB])
  57. ])
  58. # Prerequisites of lib/inet_pton.c.
  59. AC_DEFUN([gl_PREREQ_INET_PTON], [
  60. AC_REQUIRE([gl_SOCKET_FAMILIES])
  61. ])