ax_lib_socket_nsl.m4 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_lib_socket_nsl.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_LIB_SOCKET_NSL
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro figures out what libraries are required on this platform to
  12. # link sockets programs.
  13. #
  14. # The common cases are not to need any extra libraries, or to need
  15. # -lsocket and -lnsl. We need to avoid linking with libnsl unless we need
  16. # it, though, since on some OSes where it isn't necessary it will totally
  17. # break networking. Unisys also includes gethostbyname() in libsocket but
  18. # needs libnsl for socket().
  19. #
  20. # LICENSE
  21. #
  22. # Copyright (c) 2008 Russ Allbery <rra@stanford.edu>
  23. # Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz>
  24. # Copyright (c) 2008 Warren Young <warren@etr-usa.com>
  25. #
  26. # Copying and distribution of this file, with or without modification, are
  27. # permitted in any medium without royalty provided the copyright notice
  28. # and this notice are preserved. This file is offered as-is, without any
  29. # warranty.
  30. #serial 7
  31. AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL])
  32. AC_DEFUN([AX_LIB_SOCKET_NSL],
  33. [
  34. AC_SEARCH_LIBS([gethostbyname], [nsl])
  35. AC_SEARCH_LIBS([socket], [socket], [], [
  36. AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
  37. [], [-lnsl])])
  38. ])