Debian Codegraph @

m4/hostent.m4

raw
1 # hostent.m4
2 # serial 5
3 dnl Copyright (C) 2008, 2010-2024 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_HOSTENT],
10 [
11 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(),
12 dnl gethostbyaddr() defined?
13 dnl - On Solaris < 11.4, they are in libnsl. Ignore libxnet.
14 dnl - On Haiku, they are in libnetwork.
15 dnl - On BeOS, they are in libnet.
16 dnl - On native Windows, they are in ws2_32.dll.
17 dnl - Otherwise they are in libc.
18 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
19 HOSTENT_LIB=
20 gl_saved_libs="$LIBS"
21 AC_SEARCH_LIBS([gethostbyname], [nsl network net],
22 [if test "$ac_cv_search_gethostbyname" != "none required"; then
23 HOSTENT_LIB="$ac_cv_search_gethostbyname"
24 fi])
25 LIBS="$gl_saved_libs"
26 if test -z "$HOSTENT_LIB"; then
27 AC_CHECK_FUNCS([gethostbyname], , [
28 AC_CACHE_CHECK([for gethostbyname in winsock2.h and -lws2_32],
29 [gl_cv_w32_gethostbyname],
30 [gl_cv_w32_gethostbyname=no
31 gl_saved_LIBS="$LIBS"
32 LIBS="$LIBS -lws2_32"
33 AC_LINK_IFELSE(
34 [AC_LANG_PROGRAM(
35 [[
36 #ifdef HAVE_WINSOCK2_H
37 #include <winsock2.h>
38 #endif
39 #include <stddef.h>
40 ]],
41 [[gethostbyname(NULL);]])],
42 [gl_cv_w32_gethostbyname=yes])
43 LIBS="$gl_saved_LIBS"
44 ])
45 if test "$gl_cv_w32_gethostbyname" = "yes"; then
46 HOSTENT_LIB="-lws2_32"
47 fi
48 ])
49 fi
50 AC_SUBST([HOSTENT_LIB])
51 ])