diff options
author | Arvind Sankar <[email protected]> | 2020-06-30 13:10:41 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-07-10 14:26:00 -0700 |
commit | 4d61ade1a317606dc899e38b516410a0c2fdae0e (patch) | |
tree | d6c2003638fe28b2fe341515aaded236d6c1320f /config | |
parent | b6437ea41c7611481925d72d294677434639b847 (diff) |
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 <[email protected]>
Signed-off-by: Arvind Sankar <[email protected]>
Closes #10538
Diffstat (limited to 'config')
-rw-r--r-- | config/find_system_library.m4 | 10 | ||||
-rw-r--r-- | config/user-clock_gettime.m4 | 12 | ||||
-rw-r--r-- | config/user-libaio.m4 | 10 | ||||
-rw-r--r-- | config/user-libblkid.m4 | 10 | ||||
-rw-r--r-- | config/user-libcrypto.m4 | 8 | ||||
-rw-r--r-- | config/user-libssl.m4 | 12 | ||||
-rw-r--r-- | config/user-libudev.m4 | 22 | ||||
-rw-r--r-- | config/user-libuuid.m4 | 16 | ||||
-rw-r--r-- | config/user-zlib.m4 | 19 | ||||
-rw-r--r-- | config/user.m4 | 7 |
10 files changed, 54 insertions, 72 deletions
diff --git a/config/find_system_library.m4 b/config/find_system_library.m4 index 9d22bcfab..3f2f7b709 100644 --- a/config/find_system_library.m4 +++ b/config/find_system_library.m4 @@ -11,7 +11,9 @@ AC_DEFUN([FIND_SYSTEM_LIBRARY], [ _library_found= - PKG_CHECK_MODULES([$1], [$2], [_library_found=1], [ + AS_IF([test -n "$2"], [PKG_CHECK_MODULES([$1], [$2], [_library_found=1], [:])]) + + AS_IF([test -z "$_library_found"], [ AS_IF([test -f /usr/include/[$3]], [ AC_SUBST([$1][_CFLAGS], []) AC_SUBST([$1][_LIBS], ["-l[$5]]") @@ -21,6 +23,7 @@ AC_DEFUN([FIND_SYSTEM_LIBRARY], [ AC_SUBST([$1][_LIBS], ["-L/usr/local -l[$5]]") _library_found=1 ],[dnl ELSE + : m4_foreach([prefix], [$4], [ AS_IF([test "x$_library_found" != "x1"], [ AS_IF([test -f [/usr/include/]prefix[/][$3]], [ @@ -37,7 +40,7 @@ AC_DEFUN([FIND_SYSTEM_LIBRARY], [ ])]) AS_IF([test -z "$_library_found"], [ - AC_MSG_WARN([cannot find [$2] via pkg-config or in the standard locations]) + AC_MSG_WARN([cannot find [$5] via pkg-config or in the standard locations]) ]) ]) @@ -51,7 +54,7 @@ AC_DEFUN([FIND_SYSTEM_LIBRARY], [ LDFLAGS="$LDFLAGS $[$1][_LIBS]" AC_CHECK_HEADER([$3], [], [ - AC_MSG_WARN([header [$3] for library [$2] is not usable]) + AC_MSG_WARN([header [$3] for library [$5] is not usable]) _library_found= ]) @@ -66,6 +69,7 @@ AC_DEFUN([FIND_SYSTEM_LIBRARY], [ ]) AS_IF([test -n "$_library_found"], [ + AC_DEFINE([HAVE_][$1], [1], [Define if you have [$5]]) :;$7 ],[dnl ELSE :;$8 diff --git a/config/user-clock_gettime.m4 b/config/user-clock_gettime.m4 new file mode 100644 index 000000000..c96024da7 --- /dev/null +++ b/config/user-clock_gettime.m4 @@ -0,0 +1,12 @@ +dnl # +dnl # Check if librt is required for clock_gettime. +dnl # clock_gettime is generally available in libc on modern systems. +dnl # +AC_DEFUN([ZFS_AC_CONFIG_USER_CLOCK_GETTIME], [ + AC_CHECK_FUNC([clock_gettime], [], [ + AC_CHECK_LIB([rt], [clock_gettime], [ + AC_SUBST([LIBCLOCK_GETTIME], [-lrt])], [ + AC_MSG_FAILURE([*** clock_gettime is missing in libc and librt]) + ]) + ]) +]) diff --git a/config/user-libaio.m4 b/config/user-libaio.m4 index d7a7cb508..0a58876fe 100644 --- a/config/user-libaio.m4 +++ b/config/user-libaio.m4 @@ -2,13 +2,5 @@ dnl # dnl # Check for libaio - only used for libaiot test cases. dnl # AC_DEFUN([ZFS_AC_CONFIG_USER_LIBAIO], [ - LIBAIO= - - AC_CHECK_HEADER([libaio.h], [ - user_libaio=yes - AC_SUBST([LIBAIO], ["-laio"]) - AC_DEFINE([HAVE_LIBAIO], 1, [Define if you have libaio]) - ], [ - user_libaio=no - ]) + FIND_SYSTEM_LIBRARY(LIBAIO, [], [libaio.h], [], [aio], [], [user_libaio=yes], [user_libaio=no]) ]) diff --git a/config/user-libblkid.m4 b/config/user-libblkid.m4 index 88e6f990b..427c4f172 100644 --- a/config/user-libblkid.m4 +++ b/config/user-libblkid.m4 @@ -3,11 +3,7 @@ dnl # Check for libblkid. Basic support for detecting ZFS pools dnl # has existing in blkid since 2008. dnl # AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [ - LIBBLKID= - - AC_CHECK_HEADER([blkid/blkid.h], [], [AC_MSG_FAILURE([ - *** blkid.h missing, libblkid-devel package required])]) - - AC_SUBST([LIBBLKID], ["-lblkid"]) - AC_DEFINE([HAVE_LIBBLKID], 1, [Define if you have libblkid]) + FIND_SYSTEM_LIBRARY(LIBBLKID, [blkid], [blkid/blkid.h], [], [blkid], [], [], [ + AC_MSG_FAILURE([ + *** blkid.h missing, libblkid-devel package required])]) ]) diff --git a/config/user-libcrypto.m4 b/config/user-libcrypto.m4 new file mode 100644 index 000000000..432b84838 --- /dev/null +++ b/config/user-libcrypto.m4 @@ -0,0 +1,8 @@ +dnl # +dnl # Check for libcrypto. Used for userspace password derivation via PBKDF2. +dnl # +AC_DEFUN([ZFS_AC_CONFIG_USER_LIBCRYPTO], [ + FIND_SYSTEM_LIBRARY(LIBCRYPTO, [libcrypto], [openssl/evp.h], [], [crypto], [PKCS5_PBKDF2_HMAC_SHA1], [], [ + AC_MSG_FAILURE([ + *** evp.h missing, libssl-devel package required])]) +]) diff --git a/config/user-libssl.m4 b/config/user-libssl.m4 deleted file mode 100644 index f6824510f..000000000 --- a/config/user-libssl.m4 +++ /dev/null @@ -1,12 +0,0 @@ -dnl # -dnl # Check for libssl. Used for userspace password derivation via PBKDF2. -dnl # -AC_DEFUN([ZFS_AC_CONFIG_USER_LIBSSL], [ - LIBSSL= - - AC_CHECK_HEADER([openssl/evp.h], [], [AC_MSG_FAILURE([ - *** evp.h missing, libssl-devel package required])]) - - AC_SUBST([LIBSSL], ["-lssl -lcrypto"]) - AC_DEFINE([HAVE_LIBSSL], 1, [Define if you have libssl]) -]) diff --git a/config/user-libudev.m4 b/config/user-libudev.m4 index 9b7454927..5164d17cd 100644 --- a/config/user-libudev.m4 +++ b/config/user-libudev.m4 @@ -2,18 +2,18 @@ dnl # dnl # Check for libudev - needed for vdev auto-online and auto-replace dnl # AC_DEFUN([ZFS_AC_CONFIG_USER_LIBUDEV], [ - LIBUDEV= + FIND_SYSTEM_LIBRARY(LIBUDEV, [libudev], [libudev.h], [], [udev], [], [user_libudev=yes], [user_libudev=no]) - AC_CHECK_HEADER([libudev.h], [ - user_libudev=yes - AC_SUBST([LIBUDEV], ["-ludev"]) - AC_DEFINE([HAVE_LIBUDEV], 1, [Define if you have libudev]) - ], [ - user_libudev=no - ]) + AS_IF([test "x$user_libudev" = xyes], [ + AX_SAVE_FLAGS + + CFLAGS="$CFLAGS $LIBUDEV_CFLAGS" + LDFLAGS="$LDFLAGS $LIBUDEV_LIBS" - AC_SEARCH_LIBS([udev_device_get_is_initialized], [udev], [ - AC_DEFINE([HAVE_LIBUDEV_UDEV_DEVICE_GET_IS_INITIALIZED], 1, [ - Define if udev_device_get_is_initialized is available])], []) + AC_CHECK_LIB([udev], [udev_device_get_is_initialized], [ + AC_DEFINE([HAVE_LIBUDEV_UDEV_DEVICE_GET_IS_INITIALIZED], 1, [ + Define if udev_device_get_is_initialized is available])], []) + AX_RESTORE_FLAGS + ]) ]) diff --git a/config/user-libuuid.m4 b/config/user-libuuid.m4 index f0da671a3..c4012f30a 100644 --- a/config/user-libuuid.m4 +++ b/config/user-libuuid.m4 @@ -2,17 +2,7 @@ dnl # dnl # Check for libuuid dnl # AC_DEFUN([ZFS_AC_CONFIG_USER_LIBUUID], [ - LIBUUID= - - AC_CHECK_HEADER([uuid/uuid.h], [], [AC_MSG_FAILURE([ - *** uuid/uuid.h missing, libuuid-devel package required])]) - - AC_SEARCH_LIBS([uuid_generate], [uuid], [], [AC_MSG_FAILURE([ - *** uuid_generate() missing, libuuid-devel package required])]) - - AC_SEARCH_LIBS([uuid_is_null], [uuid], [], [AC_MSG_FAILURE([ - *** uuid_is_null() missing, libuuid-devel package required])]) - - AC_SUBST([LIBUUID], ["-luuid"]) - AC_DEFINE([HAVE_LIBUUID], 1, [Define if you have libuuid]) + FIND_SYSTEM_LIBRARY(LIBUUID, [uuid], [uuid/uuid.h], [], [uuid], [uuid_generate, uuid_is_null], [], [ + AC_MSG_FAILURE([*** libuuid-devel package required]) + ]) ]) diff --git a/config/user-zlib.m4 b/config/user-zlib.m4 index 82c0962e4..d30fde288 100644 --- a/config/user-zlib.m4 +++ b/config/user-zlib.m4 @@ -2,20 +2,7 @@ dnl # dnl # Check for zlib dnl # AC_DEFUN([ZFS_AC_CONFIG_USER_ZLIB], [ - ZLIB= - - AC_CHECK_HEADER([zlib.h], [], [AC_MSG_FAILURE([ - *** zlib.h missing, zlib-devel package required])]) - - AC_SEARCH_LIBS([compress2], [z], [], [AC_MSG_FAILURE([ - *** compress2() missing, zlib-devel package required])]) - - AC_SEARCH_LIBS([uncompress], [z], [], [AC_MSG_FAILURE([ - *** uncompress() missing, zlib-devel package required])]) - - AC_SEARCH_LIBS([crc32], [z], [], [AC_MSG_FAILURE([ - *** crc32() missing, zlib-devel package required])]) - - AC_SUBST([ZLIB], ["-lz"]) - AC_DEFINE([HAVE_ZLIB], 1, [Define if you have zlib]) + FIND_SYSTEM_LIBRARY(ZLIB, [zlib], [zlib.h], [], [z], [compress2, uncompress, crc32], [], [ + AC_MSG_FAILURE([*** zlib-devel package required]) + ]) ]) diff --git a/config/user.m4 b/config/user.m4 index c09705bde..c22067551 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -6,6 +6,10 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_MOUNT_HELPER ZFS_AC_CONFIG_USER_SYSVINIT ZFS_AC_CONFIG_USER_DRACUT + AM_COND_IF([BUILD_FREEBSD], [ + PKG_INSTALLDIR(['${prefix}/libdata/pkgconfig'])], [ + PKG_INSTALLDIR + ]) ZFS_AC_CONFIG_USER_ZLIB AM_COND_IF([BUILD_LINUX], [ ZFS_AC_CONFIG_USER_UDEV @@ -15,8 +19,9 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ]) ZFS_AC_CONFIG_USER_LIBTIRPC ZFS_AC_CONFIG_USER_LIBUDEV - ZFS_AC_CONFIG_USER_LIBSSL + ZFS_AC_CONFIG_USER_LIBCRYPTO ZFS_AC_CONFIG_USER_LIBAIO + ZFS_AC_CONFIG_USER_CLOCK_GETTIME ZFS_AC_CONFIG_USER_PAM ZFS_AC_CONFIG_USER_RUNSTATEDIR ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS |