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