diff options
Diffstat (limited to 'gl/m4/inet_ntop.m4')
| -rw-r--r-- | gl/m4/inet_ntop.m4 | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4 index a6d219c2..476f063f 100644 --- a/gl/m4/inet_ntop.m4 +++ b/gl/m4/inet_ntop.m4 | |||
| @@ -1,38 +1,68 @@ | |||
| 1 | # inet_ntop.m4 serial 12 | 1 | # inet_ntop.m4 serial 19 |
| 2 | dnl Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
| 6 | 6 | ||
| 7 | AC_DEFUN([gl_FUNC_INET_NTOP], | 7 | AC_DEFUN([gl_FUNC_INET_NTOP], |
| 8 | [ | 8 | [ |
| 9 | AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) | ||
| 10 | |||
| 9 | dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop. | 11 | dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop. |
| 10 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | 12 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 11 | 13 | ||
| 12 | gl_REPLACE_ARPA_INET_H | 14 | AC_REQUIRE([AC_C_RESTRICT]) |
| 13 | 15 | ||
| 14 | dnl Most platforms that provide inet_ntop define it in libc. | 16 | dnl Most platforms that provide inet_ntop define it in libc. |
| 15 | dnl Solaris 8..10 provide inet_ntop in libnsl instead. | 17 | dnl Solaris 8..10 provide inet_ntop in libnsl instead. |
| 16 | gl_save_LIBS=$LIBS | 18 | dnl Solaris 2.6..7 provide inet_ntop in libresolv instead. |
| 17 | AC_SEARCH_LIBS([inet_ntop], [nsl], [], | 19 | dnl Native Windows provides it in -lws2_32 instead, with a declaration in |
| 18 | [AC_REPLACE_FUNCS([inet_ntop])]) | 20 | dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl |
| 19 | LIBS=$gl_save_LIBS | 21 | dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). |
| 22 | HAVE_INET_NTOP=1 | ||
| 20 | INET_NTOP_LIB= | 23 | INET_NTOP_LIB= |
| 21 | if test "$ac_cv_search_inet_ntop" != "no" && | 24 | gl_PREREQ_SYS_H_WINSOCK2 |
| 22 | test "$ac_cv_search_inet_ntop" != "none required"; then | 25 | if test $HAVE_WINSOCK2_H = 1; then |
| 23 | INET_NTOP_LIB="$ac_cv_search_inet_ntop" | 26 | AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]]) |
| 27 | if test $ac_cv_have_decl_inet_ntop = yes; then | ||
| 28 | dnl It needs to be overridden, because the stdcall calling convention | ||
| 29 | dnl is not compliant with POSIX. | ||
| 30 | REPLACE_INET_NTOP=1 | ||
| 31 | INET_NTOP_LIB="-lws2_32" | ||
| 32 | else | ||
| 33 | HAVE_DECL_INET_NTOP=0 | ||
| 34 | HAVE_INET_NTOP=0 | ||
| 35 | fi | ||
| 36 | else | ||
| 37 | gl_save_LIBS=$LIBS | ||
| 38 | AC_SEARCH_LIBS([inet_ntop], [nsl resolv], [], | ||
| 39 | [AC_CHECK_FUNCS([inet_ntop]) | ||
| 40 | if test $ac_cv_func_inet_ntop = no; then | ||
| 41 | HAVE_INET_NTOP=0 | ||
| 42 | fi | ||
| 43 | ]) | ||
| 44 | LIBS=$gl_save_LIBS | ||
| 45 | |||
| 46 | if test "$ac_cv_search_inet_ntop" != "no" \ | ||
| 47 | && test "$ac_cv_search_inet_ntop" != "none required"; then | ||
| 48 | INET_NTOP_LIB="$ac_cv_search_inet_ntop" | ||
| 49 | fi | ||
| 50 | |||
| 51 | AC_CHECK_HEADERS_ONCE([netdb.h]) | ||
| 52 | AC_CHECK_DECLS([inet_ntop],,, | ||
| 53 | [[#include <arpa/inet.h> | ||
| 54 | #if HAVE_NETDB_H | ||
| 55 | # include <netdb.h> | ||
| 56 | #endif | ||
| 57 | ]]) | ||
| 58 | if test $ac_cv_have_decl_inet_ntop = no; then | ||
| 59 | HAVE_DECL_INET_NTOP=0 | ||
| 60 | fi | ||
| 24 | fi | 61 | fi |
| 25 | AC_SUBST([INET_NTOP_LIB]) | 62 | AC_SUBST([INET_NTOP_LIB]) |
| 26 | |||
| 27 | gl_PREREQ_INET_NTOP | ||
| 28 | ]) | 63 | ]) |
| 29 | 64 | ||
| 30 | # Prerequisites of lib/inet_ntop.c. | 65 | # Prerequisites of lib/inet_ntop.c. |
| 31 | AC_DEFUN([gl_PREREQ_INET_NTOP], [ | 66 | AC_DEFUN([gl_PREREQ_INET_NTOP], [ |
| 32 | AC_CHECK_DECLS([inet_ntop],,,[#include <arpa/inet.h>]) | ||
| 33 | if test $ac_cv_have_decl_inet_ntop = no; then | ||
| 34 | HAVE_DECL_INET_NTOP=0 | ||
| 35 | fi | ||
| 36 | AC_REQUIRE([gl_SOCKET_FAMILIES]) | 67 | AC_REQUIRE([gl_SOCKET_FAMILIES]) |
| 37 | AC_REQUIRE([AC_C_RESTRICT]) | ||
| 38 | ]) | 68 | ]) |
