servent.m4 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # servent.m4 serial 2
  2. dnl Copyright (C) 2008, 2010-2014 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_SERVENT],
  7. [
  8. dnl Where are getservent(), setservent(), endservent(), getservbyname(),
  9. dnl getservbyport() defined?
  10. dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
  11. dnl getprotobynumber() defined?
  12. dnl - On Solaris, they are in libsocket. 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_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
  18. SERVENT_LIB=
  19. gl_saved_libs="$LIBS"
  20. AC_SEARCH_LIBS([getservbyname], [socket network net],
  21. [if test "$ac_cv_search_getservbyname" != "none required"; then
  22. SERVENT_LIB="$ac_cv_search_getservbyname"
  23. fi])
  24. LIBS="$gl_saved_libs"
  25. if test -z "$SERVENT_LIB"; then
  26. AC_CHECK_FUNCS([getservbyname], , [
  27. AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32],
  28. [gl_cv_w32_getservbyname],
  29. [gl_cv_w32_getservbyname=no
  30. gl_save_LIBS="$LIBS"
  31. LIBS="$LIBS -lws2_32"
  32. AC_LINK_IFELSE(
  33. [AC_LANG_PROGRAM(
  34. [[
  35. #ifdef HAVE_WINSOCK2_H
  36. #include <winsock2.h>
  37. #endif
  38. #include <stddef.h>
  39. ]],
  40. [[getservbyname(NULL,NULL);]])],
  41. [gl_cv_w32_getservbyname=yes])
  42. LIBS="$gl_save_LIBS"
  43. ])
  44. if test "$gl_cv_w32_getservbyname" = "yes"; then
  45. SERVENT_LIB="-lws2_32"
  46. fi
  47. ])
  48. fi
  49. AC_SUBST([SERVENT_LIB])
  50. ])