From: Michael Jeanson Date: Mon, 28 Sep 2015 15:42:50 +0000 (-0400) Subject: Port: Add AX_LIB_SOCKET_NSL macro to configure.ac X-Git-Tag: v1.3.0~26 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=9e8a1e08843af420b89e6154ecaf61fde61d5ee6 Port: Add AX_LIB_SOCKET_NSL macro to configure.ac This is required on platforms that need extra libraries to link socket programs. Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/configure.ac b/configure.ac index 375de6ba..507efe6c 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,9 @@ esac AM_CONDITIONAL([BABELTRACE_BUILD_WITH_MINGW], [test "x$MINGW32" = "xyes"]) +# Check what libraries are required on this platform to link sockets programs. +AX_LIB_SOCKET_NSL + # Check for libuuid AC_CHECK_LIB([uuid], [uuid_generate], [ diff --git a/m4/ax_lib_socket_nsl.m4 b/m4/ax_lib_socket_nsl.m4 new file mode 100644 index 00000000..058e9751 --- /dev/null +++ b/m4/ax_lib_socket_nsl.m4 @@ -0,0 +1,40 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_lib_socket_nsl.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIB_SOCKET_NSL +# +# DESCRIPTION +# +# This macro figures out what libraries are required on this platform to +# link sockets programs. +# +# The common cases are not to need any extra libraries, or to need +# -lsocket and -lnsl. We need to avoid linking with libnsl unless we need +# it, though, since on some OSes where it isn't necessary it will totally +# break networking. Unisys also includes gethostbyname() in libsocket but +# needs libnsl for socket(). +# +# LICENSE +# +# Copyright (c) 2008 Russ Allbery +# Copyright (c) 2008 Stepan Kasal +# Copyright (c) 2008 Warren Young +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL]) +AC_DEFUN([AX_LIB_SOCKET_NSL], +[ + AC_SEARCH_LIBS([gethostbyname], [nsl]) + AC_SEARCH_LIBS([socket], [socket], [], [ + AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"], + [], [-lnsl])]) +])