Blame m4/inet_pton.m4

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