Update Gnulib to the latest git version
[deliverable/binutils-gdb.git] / gnulib / import / m4 / inet_ntop.m4
1 # inet_ntop.m4 serial 21
2 dnl Copyright (C) 2005-2006, 2008-2019 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_INET_NTOP],
8 [
9 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
10
11 dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13
14 AC_REQUIRE([AC_C_RESTRICT])
15
16 dnl Most platforms that provide inet_ntop define it in libc.
17 dnl Solaris 8..10 provide inet_ntop in libnsl instead.
18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
19 dnl Haiku provides it in -lnetwork.
20 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
21 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
22 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
23 HAVE_INET_NTOP=1
24 INET_NTOP_LIB=
25 gl_PREREQ_SYS_H_WINSOCK2
26 if test $HAVE_WINSOCK2_H = 1; then
27 dnl It needs to be overridden, because the stdcall calling convention
28 dnl is not compliant with POSIX. Set REPLACE_INET_NTOP in order to avoid
29 dnl a name conflict at the linker level, even though the header file
30 dnl <ws2tcpip.h> declares inet_ntop only if _WIN32_WINNT >= 0x0600.
31 REPLACE_INET_NTOP=1
32 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
33 if test $ac_cv_have_decl_inet_ntop = yes; then
34 INET_NTOP_LIB="-lws2_32"
35 else
36 HAVE_DECL_INET_NTOP=0
37 fi
38 else
39 gl_save_LIBS=$LIBS
40 AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [],
41 [AC_CHECK_FUNCS([inet_ntop])
42 if test $ac_cv_func_inet_ntop = no; then
43 HAVE_INET_NTOP=0
44 fi
45 ])
46 LIBS=$gl_save_LIBS
47
48 if test "$ac_cv_search_inet_ntop" != "no" \
49 && test "$ac_cv_search_inet_ntop" != "none required"; then
50 INET_NTOP_LIB="$ac_cv_search_inet_ntop"
51 fi
52
53 AC_CHECK_HEADERS_ONCE([netdb.h])
54 AC_CHECK_DECLS([inet_ntop],,,
55 [[#include <arpa/inet.h>
56 #if HAVE_NETDB_H
57 # include <netdb.h>
58 #endif
59 ]])
60 if test $ac_cv_have_decl_inet_ntop = no; then
61 HAVE_DECL_INET_NTOP=0
62 fi
63 fi
64 AC_SUBST([INET_NTOP_LIB])
65 ])
66
67 # Prerequisites of lib/inet_ntop.c.
68 AC_DEFUN([gl_PREREQ_INET_NTOP], [
69 AC_REQUIRE([gl_SOCKET_FAMILIES])
70 ])
This page took 0.032545 seconds and 4 git commands to generate.