From 2dffee8de9c4584726b7d2f9b6c4d910b7d0b861 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 6 Apr 2018 11:03:00 -0300 Subject: [PATCH] Require pkg-config as an optional build dependency on Linux (#775) With this commit: * if pkgconfig is installed, it will expand the code inside the shell if, adding the pkgconfig-based tests for the dependencies of Linux delay accounting. * if pkgconfig is not installed, it will add an error message inside the test of Linux delay accounting, telling the user to install pkgconfig and rebuild the configure script if they want to use Linux delay accounting. The end result is: * people running Linux * will not need pkgconfig when not using delay accounting * will need pkgconfig when using delay accounting * if they don't have it * they are told by configure they need to install it and re-run autogen.sh when running from Git * they are told by configure they need to install it and re-run configure when running from the tarball * people not running Linux * will never need pkgconfig ...and in none of the above scenarios the generated configure script produces unexpanded macros for users checking out the sources from Git. --- configure.ac | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index aab90889..de3d04b1 100644 --- a/configure.ac +++ b/configure.ac @@ -334,12 +334,16 @@ fi AC_ARG_ENABLE(delayacct, [AS_HELP_STRING([--enable-delayacct], [enable linux delay accounting])],, enable_delayacct="no") if test "x$enable_delayacct" = xyes then - PKG_PROG_PKG_CONFIG() - PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"]) - PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"]) - CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS" - LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS" - AC_DEFINE(HAVE_DELAYACCT, 1, [Define if delay accounting support should be enabled.]) + m4_ifdef([PKG_PROG_PKG_CONFIG], [ + PKG_PROG_PKG_CONFIG() + PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"]) + PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"]) + CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS" + LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS" + AC_DEFINE(HAVE_DELAYACCT, 1, [Define if delay accounting support should be enabled.]) + ], [ + 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.]) + ]) fi