hostent.m4 1.5 KB

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