diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2024-03-30 13:47:14 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2024-04-05 19:27:07 +0200 |
commit | 24b1513296fd61722166625ad46be1c56a5efc44 (patch) | |
tree | a0137954bfd9252bef84f18c57d90c95696d9dfc /configure.ac | |
parent | a782ef357067962f60580478067f4023facab6a0 (diff) |
linux: use dlopen for libnl3 instead of dynamic linking
Instead of the current behavior of dynamic linking against libnl3 and
libnl-genl-3 when configured with --enable-delayacct, load the shared
libraries on request, if any delay accounting related process field is
active, via dlopen(3), similar to libsensors and libsystemd.
Distribution, who currently build htop with --enable-delayacct, need to
explicitly add libnl3 and libnl-genl-3 as runtime dependencies to
continue supporting delay accounting out-of-the-box.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/configure.ac b/configure.ac index b3137dec..0a90ca48 100644 --- a/configure.ac +++ b/configure.ac @@ -658,40 +658,26 @@ case "$enable_delayacct" in elif test "$enable_static" = yes; then enable_delayacct=no else - m4_ifdef([PKG_PROG_PKG_CONFIG], [ - enable_delayacct=yes - PKG_PROG_PKG_CONFIG() - PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [enable_delayacct=no]) - PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [enable_delayacct=no]) - if test "$enable_delayacct" = yes; then - AM_CFLAGS="$AM_CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS" - LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS" - AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.]) - fi - ], [ - enable_delayacct=no - AC_MSG_NOTICE([Linux delay accounting support can not be enabled, cause pkg-config is required for checking its availability]) - ]) + old_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I/usr/include/libnl3" + AC_CHECK_HEADERS([netlink/attr.h netlink/handlers.h netlink/msg.h], [enable_delayacct=yes], [enable_delayacct=no]) + CFLAGS="$old_CFLAGS" fi ;; yes) - m4_ifdef([PKG_PROG_PKG_CONFIG], [ - PKG_PROG_PKG_CONFIG() - PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [AC_MSG_ERROR([can not find required library libnl3])]) - PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [AC_MSG_ERROR([can not find required library libnl3genl])]) - AM_CFLAGS="$AM_CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS" - LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS" - AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.]) - ], [ - pkg_m4_absent=1 - m4_warning([configure is generated without pkg.m4. 'make dist' target will be disabled.]) - AC_MSG_ERROR([htop on Linux requires pkg-config for checking delayacct requirements. Please install pkg-config and run ./autogen.sh to rebuild the configure script.]) - ]) + old_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I/usr/include/libnl3" + AC_CHECK_HEADERS([netlink/attr.h netlink/handlers.h netlink/msg.h], [], [AC_MSG_ERROR([can not find required header files netlink/attr.h, netlink/handlers.h, netlink/msg.h])]) + CFLAGS="$old_CFLAGS" ;; *) AC_MSG_ERROR([bad value '$enable_delayacct' for --enable-delayacct]) ;; esac +if test "$enable_delayacct" = yes; then + AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.]) + AM_CFLAGS="$AM_CFLAGS -I/usr/include/libnl3" +fi AM_CONDITIONAL([HAVE_DELAYACCT], [test "$enable_delayacct" = yes]) |