Port: Add AX_LIB_SOCKET_NSL macro to configure.ac
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 28 Sep 2015 15:42:50 +0000 (11:42 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 13 Oct 2015 20:58:15 +0000 (16:58 -0400)
This is required on platforms that need extra libraries to
link socket programs.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
m4/ax_lib_socket_nsl.m4 [new file with mode: 0644]

index ec7afa06cd72d1f7f557ceb66550a31fd2b1b7ec..d38eea013a2a2f2994d6fdfa63eb2c536bc2ff0a 100644 (file)
@@ -91,6 +91,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 (file)
index 0000000..058e975
--- /dev/null
@@ -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 <rra@stanford.edu>
+#   Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz>
+#   Copyright (c) 2008 Warren Young <warren@etr-usa.com>
+#
+#   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])])
+])
This page took 0.027216 seconds and 4 git commands to generate.