diff options
Diffstat (limited to 'gl/m4/inet_pton.m4')
| -rw-r--r-- | gl/m4/inet_pton.m4 | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/gl/m4/inet_pton.m4 b/gl/m4/inet_pton.m4 new file mode 100644 index 00000000..b6e59a25 --- /dev/null +++ b/gl/m4/inet_pton.m4 | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | # inet_pton.m4 | ||
| 2 | # serial 20 | ||
| 3 | dnl Copyright (C) 2006, 2008-2025 Free Software Foundation, Inc. | ||
| 4 | dnl This file is free software; the Free Software Foundation | ||
| 5 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 6 | dnl with or without modifications, as long as this notice is preserved. | ||
| 7 | dnl This file is offered as-is, without any warranty. | ||
| 8 | |||
| 9 | AC_DEFUN([gl_FUNC_INET_PTON], | ||
| 10 | [ | ||
| 11 | AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) | ||
| 12 | |||
| 13 | dnl Persuade Solaris <arpa/inet.h> to declare inet_pton. | ||
| 14 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||
| 15 | |||
| 16 | AC_REQUIRE([AC_C_RESTRICT]) | ||
| 17 | |||
| 18 | dnl Most platforms that provide inet_pton define it in libc. | ||
| 19 | dnl Solaris 8..10 provide inet_pton in libnsl instead. | ||
| 20 | dnl Solaris 2.6..7 provide inet_pton in libresolv instead. | ||
| 21 | dnl Haiku provides it in -lnetwork. | ||
| 22 | dnl Native Windows provides it in -lws2_32 instead, with a declaration in | ||
| 23 | dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl | ||
| 24 | dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). | ||
| 25 | HAVE_INET_PTON=1 | ||
| 26 | INET_PTON_LIB= | ||
| 27 | gl_PREREQ_SYS_H_WINSOCK2 | ||
| 28 | if test $HAVE_WINSOCK2_H = 1; then | ||
| 29 | dnl It needs to be overridden, because the stdcall calling convention | ||
| 30 | dnl is not compliant with POSIX. Set REPLACE_INET_PTON in order to avoid | ||
| 31 | dnl a name conflict at the linker level, even though the header file | ||
| 32 | dnl <ws2tcpip.h> declares inet_pton only if _WIN32_WINNT >= 0x0600. | ||
| 33 | REPLACE_INET_PTON=1 | ||
| 34 | AC_CHECK_DECLS([inet_pton],,, [[#include <ws2tcpip.h>]]) | ||
| 35 | if test $ac_cv_have_decl_inet_pton = yes; then | ||
| 36 | INET_PTON_LIB="-lws2_32" | ||
| 37 | else | ||
| 38 | HAVE_DECL_INET_PTON=0 | ||
| 39 | fi | ||
| 40 | else | ||
| 41 | gl_saved_LIBS=$LIBS | ||
| 42 | AC_SEARCH_LIBS([inet_pton], [nsl resolv network], [], | ||
| 43 | [AC_CHECK_FUNCS([inet_pton]) | ||
| 44 | if test $ac_cv_func_inet_pton = no; then | ||
| 45 | HAVE_INET_PTON=0 | ||
| 46 | fi | ||
| 47 | ]) | ||
| 48 | LIBS=$gl_saved_LIBS | ||
| 49 | |||
| 50 | if test "$ac_cv_search_inet_pton" != "no" \ | ||
| 51 | && test "$ac_cv_search_inet_pton" != "none required"; then | ||
| 52 | INET_PTON_LIB="$ac_cv_search_inet_pton" | ||
| 53 | fi | ||
| 54 | |||
| 55 | AC_CHECK_HEADERS_ONCE([netdb.h]) | ||
| 56 | AC_CHECK_DECLS([inet_pton],,, | ||
| 57 | [[#include <arpa/inet.h> | ||
| 58 | #if HAVE_NETDB_H | ||
| 59 | # include <netdb.h> | ||
| 60 | #endif | ||
| 61 | ]]) | ||
| 62 | if test $ac_cv_have_decl_inet_pton = no; then | ||
| 63 | HAVE_DECL_INET_PTON=0 | ||
| 64 | fi | ||
| 65 | fi | ||
| 66 | AC_SUBST([INET_PTON_LIB]) | ||
| 67 | ]) | ||
| 68 | |||
| 69 | # Prerequisites of lib/inet_pton.c. | ||
| 70 | AC_DEFUN([gl_PREREQ_INET_PTON], [ | ||
| 71 | AC_REQUIRE([gl_SOCKET_FAMILIES]) | ||
| 72 | ]) | ||
