Clean up lib dependencies

libzutil is currently statically linked into libzfs, libzfs_core and
libzpool. Avoid the unnecessary duplication by removing it from libzfs
and libzpool, and adding libzfs_core to libzpool.

Remove a few unnecessary dependencies:
- libuutil from libzfs_core
- libtirpc from libspl
- keep only libcrypto in libzfs, as we don't use any functions from
  libssl
- librt is only used for clock_gettime, however on modern systems that's
  in libc rather than librt. Add a configure check to see if we actually
  need librt
- libdl from raidz_test

Add a few missing dependencies:
- zlib to libefi and libzfs
- libuuid to zpool, and libuuid and libudev to zed
- libnvpair uses assertions, so add assert.c to provide aok and
  libspl_assertf

Sort the LDADD for programs so that libraries that satisfy dependencies
come at the end rather than the beginning of the linker command line.

Revamp the configure tests for libaries to use FIND_SYSTEM_LIBRARY
instead. This can take advantage of pkg-config, and it also avoids
polluting LIBS.

List all the required dependencies in the pkgconfig files, and move the
one for libzfs_core into the latter's directory. Install pkgconfig files
in $(libdir)/pkgconfig on linux and $(prefix)/libdata/pkgconfig on
FreeBSD, instead of /usr/share/pkgconfig, as the more correct location
for library .pc files.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10538
This commit is contained in:
Arvind Sankar
2020-06-30 13:10:41 -04:00
committed by Brian Behlendorf
parent b6437ea41c
commit 4d61ade1a3
45 changed files with 171 additions and 168 deletions
+1
View File
@@ -0,0 +1 @@
/libzfs_core.pc
+8 -5
View File
@@ -1,5 +1,7 @@
include $(top_srcdir)/config/Rules.am
pkgconfig_DATA = libzfs_core.pc
lib_LTLIBRARIES = libzfs_core.la
USER_C = \
@@ -8,13 +10,14 @@ USER_C = \
libzfs_core_la_SOURCES = $(USER_C)
libzfs_core_la_LIBADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libuutil/libuutil.la \
$(top_builddir)/lib/libzutil/libzutil.la
$(top_builddir)/lib/libzutil/libzutil.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
libzfs_core_la_LDFLAGS = -pthread
if BUILD_FREEBSD
libzfs_core_la_LDFLAGS = -version-info 3:0:0
libzfs_core_la_LIBADD += -lutil -lgeom
libzfs_core_la_LDFLAGS += -version-info 3:0:0
else
libzfs_core_la_LDFLAGS = -version-info 1:0:0
libzfs_core_la_LDFLAGS += -version-info 1:0:0
endif
+13
View File
@@ -0,0 +1,13 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libzfs_core
Description: LibZFS core library
Version: @VERSION@
URL: https://zfsonlinux.org
Requires.private: blkid uuid libtirpc zlib
Cflags: -I${includedir}/libzfs -I${includedir}/libspl
Libs: -L${libdir} -lzfs_core -lnvpair
Libs.private: @LIBCLOCK_GETTIME@ @LIBUDEV_LIBS@ -lm -pthread