From 4d61ade1a317606dc899e38b516410a0c2fdae0e Mon Sep 17 00:00:00 2001 From: Arvind Sankar Date: Tue, 30 Jun 2020 13:10:41 -0400 Subject: 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 Signed-off-by: Arvind Sankar Closes #10538 --- lib/Makefile.am | 8 ++++---- lib/libefi/Makefile.am | 4 +++- lib/libicp/Makefile.am | 2 -- lib/libnvpair/Makefile.am | 9 +++++++-- lib/libspl/Makefile.am | 4 +--- lib/libtpool/Makefile.am | 5 ----- lib/libuutil/Makefile.am | 6 ++++-- lib/libzfs/.gitignore | 1 - lib/libzfs/Makefile.am | 25 ++++++++++++++----------- lib/libzfs/libzfs.pc.in | 2 ++ lib/libzfs/libzfs_core.pc.in | 11 ----------- lib/libzfs_core/.gitignore | 1 + lib/libzfs_core/Makefile.am | 13 ++++++++----- lib/libzfs_core/libzfs_core.pc.in | 13 +++++++++++++ lib/libzpool/Makefile.am | 17 +++++++++++------ lib/libzutil/Makefile.am | 6 ++++-- 16 files changed, 72 insertions(+), 55 deletions(-) delete mode 100644 lib/libzfs/libzfs_core.pc.in create mode 100644 lib/libzfs_core/.gitignore create mode 100644 lib/libzfs_core/libzfs_core.pc.in (limited to 'lib') diff --git a/lib/Makefile.am b/lib/Makefile.am index 4f59aa359..02e7f7b5f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,5 +1,5 @@ # NB: GNU Automake Manual, Chapter 8.3.5: Libtool Convenience Libraries -# These six libraries are intermediary build components. +# These eight libraries are intermediary build components. SUBDIRS = libavl libicp libshare libspl libtpool if BUILD_LINUX @@ -9,6 +9,6 @@ endif # libzutil depends on libefi if present SUBDIRS += libzutil libunicode -# These four libraries, which are installed as the final build product, -# incorporate the six convenience libraries given above. -SUBDIRS += libuutil libnvpair libzpool libzfs_core libzfs +# These five libraries, which are installed as the final build product, +# incorporate the eight convenience libraries given above. +SUBDIRS += libuutil libnvpair libzfs_core libzfs libzpool diff --git a/lib/libefi/Makefile.am b/lib/libefi/Makefile.am index 0ca04df46..fab6c8d47 100644 --- a/lib/libefi/Makefile.am +++ b/lib/libefi/Makefile.am @@ -1,5 +1,7 @@ include $(top_srcdir)/config/Rules.am +AM_CFLAGS += $(LIBUUID_CFLAGS) $(ZLIB_CFLAGS) + noinst_LTLIBRARIES = libefi.la USER_C = \ @@ -7,4 +9,4 @@ USER_C = \ libefi_la_SOURCES = $(USER_C) -libefi_la_LIBADD = $(LIBUUID) +libefi_la_LIBADD = $(LIBUUID_LIBS) $(ZLIB_LIBS) diff --git a/lib/libicp/Makefile.am b/lib/libicp/Makefile.am index fad91e13c..6d3c65ea3 100644 --- a/lib/libicp/Makefile.am +++ b/lib/libicp/Makefile.am @@ -71,5 +71,3 @@ KERNEL_ASM = $(ASM_SOURCES_AS) nodist_libicp_la_SOURCES = \ $(KERNEL_C) \ $(KERNEL_ASM) - -libicp_la_LIBADD = -lrt diff --git a/lib/libnvpair/Makefile.am b/lib/libnvpair/Makefile.am index af99c84b7..c29714342 100644 --- a/lib/libnvpair/Makefile.am +++ b/lib/libnvpair/Makefile.am @@ -26,10 +26,15 @@ dist_libnvpair_la_SOURCES = \ nodist_libnvpair_la_SOURCES = \ $(KERNEL_C) +libnvpair_la_LIBADD = \ + $(top_builddir)/lib/libspl/libspl_assert.la + +libnvpair_la_LIBADD += \ + $(LIBTIRPC_LIBS) + if BUILD_FREEBSD -libnvpair_la_LIBADD = $(LIBTIRPC_LIBS) -L/usr/local/lib -lintl +libnvpair_la_LIBADD += -L/usr/local/lib -lintl libnvpair_la_LDFLAGS = -version-info 3:0:0 else -libnvpair_la_LIBADD = $(LIBTIRPC_LIBS) libnvpair_la_LDFLAGS = -version-info 1:1:0 endif diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am index ad34c3588..f576d6924 100644 --- a/lib/libspl/Makefile.am +++ b/lib/libspl/Makefile.am @@ -12,8 +12,6 @@ endif SUBDIRS = include -AM_CFLAGS += $(LIBTIRPC_CFLAGS) - AM_CCASFLAGS = \ $(CFLAGS) @@ -55,4 +53,4 @@ libspl_la_SOURCES = \ libspl_la_LIBADD = \ libspl_assert.la -libspl_la_LIBADD += -lrt $(LIBTIRPC_LIBS) +libspl_la_LIBADD += $(LIBCLOCK_GETTIME) diff --git a/lib/libtpool/Makefile.am b/lib/libtpool/Makefile.am index 818f49ce4..22bfa4b23 100644 --- a/lib/libtpool/Makefile.am +++ b/lib/libtpool/Makefile.am @@ -7,8 +7,3 @@ USER_C = \ thread_pool_impl.h libtpool_la_SOURCES = $(USER_C) - -libtpool_la_LIBADD = \ - $(top_builddir)/lib/libspl/libspl.la - -libtpool_la_LDFLAGS = -pthread diff --git a/lib/libuutil/Makefile.am b/lib/libuutil/Makefile.am index 37f2eb65b..2d8eab681 100644 --- a/lib/libuutil/Makefile.am +++ b/lib/libuutil/Makefile.am @@ -19,8 +19,10 @@ libuutil_la_LIBADD = \ $(top_builddir)/lib/libavl/libavl.la \ $(top_builddir)/lib/libspl/libspl.la +libuutil_la_LDFLAGS = -pthread + if BUILD_FREEBSD -libuutil_la_LDFLAGS = -pthread -version-info 3:0:0 +libuutil_la_LDFLAGS += -version-info 3:0:0 else -libuutil_la_LDFLAGS = -pthread -version-info 1:1:0 +libuutil_la_LDFLAGS += -version-info 1:1:0 endif diff --git a/lib/libzfs/.gitignore b/lib/libzfs/.gitignore index d719bc1ad..9336a5c00 100644 --- a/lib/libzfs/.gitignore +++ b/lib/libzfs/.gitignore @@ -1,2 +1 @@ /libzfs.pc -/libzfs_core.pc diff --git a/lib/libzfs/Makefile.am b/lib/libzfs/Makefile.am index efdac5ea1..836669e2a 100644 --- a/lib/libzfs/Makefile.am +++ b/lib/libzfs/Makefile.am @@ -7,9 +7,9 @@ VPATH = \ # Suppress unused but set variable warnings often due to ASSERTs AM_CFLAGS += $(NO_UNUSED_BUT_SET_VARIABLE) +AM_CFLAGS += $(LIBCRYPTO_CFLAGS) $(ZLIB_CFLAGS) -libzfs_pcdir = $(datarootdir)/pkgconfig -libzfs_pc_DATA = libzfs.pc libzfs_core.pc +pkgconfig_DATA = libzfs.pc lib_LTLIBRARIES = libzfs.la @@ -69,25 +69,28 @@ dist_libzfs_la_SOURCES = \ nodist_libzfs_la_SOURCES = \ $(KERNEL_C) -libzfs_la_LIBADD = \ - $(top_builddir)/lib/libnvpair/libnvpair.la \ - $(top_builddir)/lib/libuutil/libuutil.la \ - $(top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(top_builddir)/lib/libzutil/libzutil.la +libzfs_la_LIBADD = if BUILD_LINUX libzfs_la_LIBADD += \ $(top_builddir)/lib/libshare/libshare.la endif +libzfs_la_LIBADD += \ + $(top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(top_builddir)/lib/libnvpair/libnvpair.la \ + $(top_builddir)/lib/libuutil/libuutil.la + +libzfs_la_LIBADD += -lm $(LIBCRYPTO_LIBS) $(ZLIB_LIBS) + +libzfs_la_LDFLAGS = -pthread + if BUILD_FREEBSD libzfs_la_LIBADD += -lutil -lgeom -libzfs_la_LDFLAGS = -version-info 4:0:0 +libzfs_la_LDFLAGS += -version-info 4:0:0 else -libzfs_la_LDFLAGS = -version-info 2:0:0 +libzfs_la_LDFLAGS += -version-info 2:0:0 endif -libzfs_la_LIBADD += -lm $(LIBSSL) - # Licensing data EXTRA_DIST = THIRDPARTYLICENSE.openssl THIRDPARTYLICENSE.openssl.descrip diff --git a/lib/libzfs/libzfs.pc.in b/lib/libzfs/libzfs.pc.in index d09e19fb0..6caf49d22 100644 --- a/lib/libzfs/libzfs.pc.in +++ b/lib/libzfs/libzfs.pc.in @@ -8,5 +8,7 @@ Description: LibZFS library Version: @VERSION@ URL: https://zfsonlinux.org Requires: libzfs_core +Requires.private: libcrypto zlib Cflags: -I${includedir}/libzfs -I${includedir}/libspl Libs: -L${libdir} -lzfs -lnvpair +Libs.private: -luutil -lm -pthread diff --git a/lib/libzfs/libzfs_core.pc.in b/lib/libzfs/libzfs_core.pc.in deleted file mode 100644 index 9f5c6462d..000000000 --- a/lib/libzfs/libzfs_core.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libzfs_core -Description: LibZFS core library -Version: @VERSION@ -URL: https://zfsonlinux.org -Cflags: -I${includedir}/libzfs -I${includedir}/libspl -Libs: -L${libdir} -lzfs_core diff --git a/lib/libzfs_core/.gitignore b/lib/libzfs_core/.gitignore new file mode 100644 index 000000000..c428d6369 --- /dev/null +++ b/lib/libzfs_core/.gitignore @@ -0,0 +1 @@ +/libzfs_core.pc diff --git a/lib/libzfs_core/Makefile.am b/lib/libzfs_core/Makefile.am index 69ddabd88..44940e915 100644 --- a/lib/libzfs_core/Makefile.am +++ b/lib/libzfs_core/Makefile.am @@ -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 diff --git a/lib/libzfs_core/libzfs_core.pc.in b/lib/libzfs_core/libzfs_core.pc.in new file mode 100644 index 000000000..e14d42d11 --- /dev/null +++ b/lib/libzfs_core/libzfs_core.pc.in @@ -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 diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 06b89fe0a..bce45acc2 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -13,6 +13,8 @@ AM_CFLAGS += $(NO_UNUSED_BUT_SET_VARIABLE) # Includes kernel code generate warnings for large stack frames AM_CFLAGS += $(FRAME_LARGER_THAN) +AM_CFLAGS += $(ZLIB_CFLAGS) + AM_CFLAGS += -DLIB_ZPOOL_BUILD lib_LTLIBRARIES = libzpool.la @@ -199,16 +201,19 @@ nodist_libzpool_la_SOURCES = \ libzpool_la_LIBADD = \ $(top_builddir)/lib/libicp/libicp.la \ - $(top_builddir)/lib/libnvpair/libnvpair.la \ $(top_builddir)/lib/libunicode/libunicode.la \ - $(top_builddir)/lib/libzutil/libzutil.la + $(top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(top_builddir)/lib/libnvpair/libnvpair.la + +libzpool_la_LIBADD += $(LIBCLOCK_GETTIME) $(ZLIB_LIBS) -ldl + +libzpool_la_LDFLAGS = -pthread if BUILD_FREEBSD -libzpool_la_LIBADD += $(ZLIB) -ldl -lgeom -libzpool_la_LDFLAGS = -pthread -version-info 4:0:0 +libzpool_la_LIBADD += -lgeom +libzpool_la_LDFLAGS += -version-info 4:0:0 else -libzpool_la_LIBADD += $(ZLIB) -ldl -libzpool_la_LDFLAGS = -pthread -version-info 2:0:0 +libzpool_la_LDFLAGS += -version-info 2:0:0 endif if TARGET_CPU_POWERPC diff --git a/lib/libzutil/Makefile.am b/lib/libzutil/Makefile.am index c11da9e9d..af1911760 100644 --- a/lib/libzutil/Makefile.am +++ b/lib/libzutil/Makefile.am @@ -2,6 +2,7 @@ include $(top_srcdir)/config/Rules.am # Suppress unused but set variable warnings often due to ASSERTs AM_CFLAGS += $(NO_UNUSED_BUT_SET_VARIABLE) +AM_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUDEV_CFLAGS) DEFAULT_INCLUDES += -I$(srcdir) @@ -32,11 +33,12 @@ libzutil_la_SOURCES = $(USER_C) libzutil_la_LIBADD = \ $(top_builddir)/lib/libavl/libavl.la \ - $(top_builddir)/lib/libtpool/libtpool.la + $(top_builddir)/lib/libtpool/libtpool.la \ + $(top_builddir)/lib/libspl/libspl.la if BUILD_LINUX libzutil_la_LIBADD += \ $(top_builddir)/lib/libefi/libefi.la endif -libzutil_la_LIBADD += -lm $(LIBBLKID) $(LIBUDEV) +libzutil_la_LIBADD += -lm $(LIBBLKID_LIBS) $(LIBUDEV_LIBS) -- cgit v1.2.3