summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRafael Kitover <rkitover@gmail.com>2019-03-02 16:19:05 -0800
committerBrian Behlendorf <behlendorf1@llnl.gov>2019-03-02 16:19:05 -0800
commit762f9ef3d9d897b5baf7c91d6e8a7bf371a9b02f (patch)
treef7a62c6fc76497d7724aaec5f5b93191fa525a52 /lib
parent0409679d88a8ccd06397ceae1b6d08935198c756 (diff)
config: better libtirpc detection
Improve the autoconf code for finding libtirpc and do not assume the headers are in /usr/include/tirpc. Also remove this assumption from the `rpc/xdr.h` header in libspl and use the same `#include_next` mechanism that is used for other libspl headers. Include pkg.m4 from pkg-config in config/ for PKG_CHECK_MODULES(), the file license allows this. Include ax_save_flags.m4 and ax_restore_flags.m4 from autoconf-archive, the file licenses are compatible. Use the 2012 versions so as not rely on a more recent autoconf feature AS_VAR_COPY(), which breaks some build slaves. Add new macro library `config/find_system_library.m4` which defines the FIND_SYSTEM_LIBRARY() macro which is a convenience wrapper over using PKG_CHECK_MODULES() with a fallback to standard library locations and some sanity checks. The parameters are: ``` FIND_SYSTEM_LIBRARY(VARIABLE-PREFIX, MODULE, HEADER, HEADER-PREFIXES, LIBRARY, FUNCTIONS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) ``` `HEADER-PREFIXES` and `FUNCTIONS` are comma-separated m4 lists. For libtirpc we are using: ``` FIND_SYSTEM_LIBRARY(LIBTIRPC, [libtirpc], [rpc/xdr.h], [tirpc], [tirpc], [xdrmem_create], [], [...]) ``` The headers are first checked for without the prefixes and then with. This system works with pkg-config and falls back on checking standard header/library locations, it can be easily overridden by the user by setting the `PREFIX_CFLAGS` and `PREFIX_LIBS` variables which are automatically added to the `./configure --help` output. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rafael Kitover <rkitover@gmail.com> Closes #7422 Closes #8313
Diffstat (limited to 'lib')
-rw-r--r--lib/libnvpair/Makefile.am8
-rw-r--r--lib/libspl/Makefile.am4
-rw-r--r--lib/libspl/include/rpc/xdr.h13
3 files changed, 8 insertions, 17 deletions
diff --git a/lib/libnvpair/Makefile.am b/lib/libnvpair/Makefile.am
index 8d6519f30..6d59d7bfc 100644
--- a/lib/libnvpair/Makefile.am
+++ b/lib/libnvpair/Makefile.am
@@ -4,11 +4,9 @@ VPATH = \
$(top_srcdir)/module/nvpair \
$(top_srcdir)/lib/libnvpair
-# Required CFLAGS for libtirpc
-AM_CFLAGS += $(LIBTIRPC_CFLAGS)
-
# Includes kernel code, generate warnings for large stack frames
-AM_CFLAGS += $(FRAME_LARGER_THAN)
+# and required CFLAGS for libtirpc
+AM_CFLAGS += $(FRAME_LARGER_THAN) $(LIBTIRPC_CFLAGS)
DEFAULT_INCLUDES += \
-I$(top_srcdir)/include \
@@ -30,7 +28,7 @@ nodist_libnvpair_la_SOURCES = \
$(USER_C) \
$(KERNEL_C)
-libnvpair_la_LIBADD = $(LIBTIRPC)
+libnvpair_la_LIBADD = $(LIBTIRPC_LIBS)
libnvpair_la_LDFLAGS = -version-info 1:1:0
EXTRA_DIST = $(USER_C)
diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am
index 5fceaf6a5..cd74676dd 100644
--- a/lib/libspl/Makefile.am
+++ b/lib/libspl/Makefile.am
@@ -10,6 +10,8 @@ DIST_SUBDIRS = include asm-generic asm-i386 asm-x86_64
DEFAULT_INCLUDES += \
-I$(top_srcdir)/lib/libspl/include
+AM_CFLAGS += $(LIBTIRPC_CFLAGS)
+
AM_CCASFLAGS = \
$(CFLAGS)
@@ -35,6 +37,6 @@ nodist_libspl_la_SOURCES = \
$(USER_C) \
$(USER_ASM)
-libspl_la_LIBADD = -lrt
+libspl_la_LIBADD = -lrt $(LIBTIRPC_LIBS)
EXTRA_DIST = $(USER_C)
diff --git a/lib/libspl/include/rpc/xdr.h b/lib/libspl/include/rpc/xdr.h
index 3c7c53fcc..27e4395c7 100644
--- a/lib/libspl/include/rpc/xdr.h
+++ b/lib/libspl/include/rpc/xdr.h
@@ -32,21 +32,12 @@
#ifndef LIBSPL_RPC_XDR_H
#define LIBSPL_RPC_XDR_H
-/*
- * When available prefer libtirpc for xdr functionality. This library is
- * mandatory when compiling with musl libc because it does not provide xdr.
- */
-#if defined(HAVE_LIBTIRPC)
+#include_next <rpc/xdr.h>
-#include <tirpc/rpc/xdr.h>
-#ifdef xdr_control
+#ifdef xdr_control /* if e.g. using tirpc */
#undef xdr_control
#endif
-#else
-#include_next <rpc/xdr.h>
-#endif /* HAVE_LIBTIRPC */
-
#define XDR_GET_BYTES_AVAIL 1
typedef struct xdr_bytesrec {