Blame m4/inet_pton.m4

Packit Service 4684c1
# inet_pton.m4 serial 19
Packit Service 4684c1
dnl Copyright (C) 2006, 2008-2020 Free Software Foundation, Inc.
Packit Service 4684c1
dnl This file is free software; the Free Software Foundation
Packit Service 4684c1
dnl gives unlimited permission to copy and/or distribute it,
Packit Service 4684c1
dnl with or without modifications, as long as this notice is preserved.
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gl_FUNC_INET_PTON],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
Packit Service 4684c1
Packit Service 4684c1
  dnl Persuade Solaris <arpa/inet.h> to declare inet_pton.
Packit Service 4684c1
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit Service 4684c1
Packit Service 4684c1
  AC_REQUIRE([AC_C_RESTRICT])
Packit Service 4684c1
Packit Service 4684c1
  dnl Most platforms that provide inet_pton define it in libc.
Packit Service 4684c1
  dnl Solaris 8..10 provide inet_pton in libnsl instead.
Packit Service 4684c1
  dnl Solaris 2.6..7 provide inet_pton in libresolv instead.
Packit Service 4684c1
  dnl Haiku provides it in -lnetwork.
Packit Service 4684c1
  dnl Native Windows provides it in -lws2_32 instead, with a declaration in
Packit Service 4684c1
  dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
Packit Service 4684c1
  dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
Packit Service 4684c1
  HAVE_INET_PTON=1
Packit Service 4684c1
  INET_PTON_LIB=
Packit Service 4684c1
  gl_PREREQ_SYS_H_WINSOCK2
Packit Service 4684c1
  if test $HAVE_WINSOCK2_H = 1; then
Packit Service 4684c1
    dnl It needs to be overridden, because the stdcall calling convention
Packit Service 4684c1
    dnl is not compliant with POSIX.  Set REPLACE_INET_PTON in order to avoid
Packit Service 4684c1
    dnl a name conflict at the linker level, even though the header file
Packit Service 4684c1
    dnl <ws2tcpip.h> declares inet_pton only if _WIN32_WINNT >= 0x0600.
Packit Service 4684c1
    REPLACE_INET_PTON=1
Packit Service 4684c1
    AC_CHECK_DECLS([inet_pton],,, [[#include <ws2tcpip.h>]])
Packit Service 4684c1
    if test $ac_cv_have_decl_inet_pton = yes; then
Packit Service 4684c1
      INET_PTON_LIB="-lws2_32"
Packit Service 4684c1
    else
Packit Service 4684c1
      HAVE_DECL_INET_PTON=0
Packit Service 4684c1
    fi
Packit Service 4684c1
  else
Packit Service 4684c1
    gl_save_LIBS=$LIBS
Packit Service 4684c1
    AC_SEARCH_LIBS([inet_pton], [nsl resolv network], [],
Packit Service 4684c1
      [AC_CHECK_FUNCS([inet_pton])
Packit Service 4684c1
       if test $ac_cv_func_inet_pton = no; then
Packit Service 4684c1
         HAVE_INET_PTON=0
Packit Service 4684c1
       fi
Packit Service 4684c1
      ])
Packit Service 4684c1
    LIBS=$gl_save_LIBS
Packit Service 4684c1
Packit Service 4684c1
    if test "$ac_cv_search_inet_pton" != "no" \
Packit Service 4684c1
       && test "$ac_cv_search_inet_pton" != "none required"; then
Packit Service 4684c1
      INET_PTON_LIB="$ac_cv_search_inet_pton"
Packit Service 4684c1
    fi
Packit Service 4684c1
Packit Service 4684c1
    AC_CHECK_HEADERS_ONCE([netdb.h])
Packit Service 4684c1
    AC_CHECK_DECLS([inet_pton],,,
Packit Service 4684c1
      [[#include <arpa/inet.h>
Packit Service 4684c1
        #if HAVE_NETDB_H
Packit Service 4684c1
        # include <netdb.h>
Packit Service 4684c1
        #endif
Packit Service 4684c1
      ]])
Packit Service 4684c1
    if test $ac_cv_have_decl_inet_pton = no; then
Packit Service 4684c1
      HAVE_DECL_INET_PTON=0
Packit Service 4684c1
    fi
Packit Service 4684c1
  fi
Packit Service 4684c1
  AC_SUBST([INET_PTON_LIB])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# Prerequisites of lib/inet_pton.c.
Packit Service 4684c1
AC_DEFUN([gl_PREREQ_INET_PTON], [
Packit Service 4684c1
  AC_REQUIRE([gl_SOCKET_FAMILIES])
Packit Service 4684c1
])