Blame m4/inet_ntop.m4

Packit Service 4684c1
# inet_ntop.m4 serial 21
Packit Service 4684c1
dnl Copyright (C) 2005-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_NTOP],
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_ntop.
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_ntop define it in libc.
Packit Service 4684c1
  dnl Solaris 8..10 provide inet_ntop in libnsl instead.
Packit Service 4684c1
  dnl Solaris 2.6..7 provide inet_ntop 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_NTOP=1
Packit Service 4684c1
  INET_NTOP_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_NTOP 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_ntop only if _WIN32_WINNT >= 0x0600.
Packit Service 4684c1
    REPLACE_INET_NTOP=1
Packit Service 4684c1
    AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
Packit Service 4684c1
    if test $ac_cv_have_decl_inet_ntop = yes; then
Packit Service 4684c1
      INET_NTOP_LIB="-lws2_32"
Packit Service 4684c1
    else
Packit Service 4684c1
      HAVE_DECL_INET_NTOP=0
Packit Service 4684c1
    fi
Packit Service 4684c1
  else
Packit Service 4684c1
    gl_save_LIBS=$LIBS
Packit Service 4684c1
    AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [],
Packit Service 4684c1
      [AC_CHECK_FUNCS([inet_ntop])
Packit Service 4684c1
       if test $ac_cv_func_inet_ntop = no; then
Packit Service 4684c1
         HAVE_INET_NTOP=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_ntop" != "no" \
Packit Service 4684c1
       && test "$ac_cv_search_inet_ntop" != "none required"; then
Packit Service 4684c1
      INET_NTOP_LIB="$ac_cv_search_inet_ntop"
Packit Service 4684c1
    fi
Packit Service 4684c1
Packit Service 4684c1
    AC_CHECK_HEADERS_ONCE([netdb.h])
Packit Service 4684c1
    AC_CHECK_DECLS([inet_ntop],,,
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_ntop = no; then
Packit Service 4684c1
      HAVE_DECL_INET_NTOP=0
Packit Service 4684c1
    fi
Packit Service 4684c1
  fi
Packit Service 4684c1
  AC_SUBST([INET_NTOP_LIB])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# Prerequisites of lib/inet_ntop.c.
Packit Service 4684c1
AC_DEFUN([gl_PREREQ_INET_NTOP], [
Packit Service 4684c1
  AC_REQUIRE([gl_SOCKET_FAMILIES])
Packit Service 4684c1
])