Blame m4/inet_pton.m4

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