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.
10 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(),
11 dnl gethostbyaddr() defined?
12 dnl - On Solaris < 11.4, they are in libnsl. Ignore libxnet.
13 dnl - On Haiku, they are in libnetwork.
14 dnl - On BeOS, they are in libnet.
15 dnl - On native Windows, they are in ws2_32.dll.
16 dnl - Otherwise they are in libc.
17 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
20 AC_SEARCH_LIBS([gethostbyname], [nsl network net],
21 [if test "$ac_cv_search_gethostbyname" != "none required"; then
22 HOSTENT_LIB="$ac_cv_search_gethostbyname"
25 if test -z "$HOSTENT_LIB"; then
26 AC_CHECK_FUNCS([gethostbyname], , [
27 AC_CACHE_CHECK([for gethostbyname in winsock2.h and -lws2_32],
28 [gl_cv_w32_gethostbyname],
29 [gl_cv_w32_gethostbyname=no
35 #ifdef HAVE_WINSOCK2_H
40 [[gethostbyname(NULL);]])],
41 [gl_cv_w32_gethostbyname=yes])
44 if test "$gl_cv_w32_gethostbyname" = "yes"; then
45 HOSTENT_LIB="-lws2_32"
49 AC_SUBST([HOSTENT_LIB])