From e85b072ad01b82f540501bab50e66181679d6c21 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 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 4516525a..931b3b91 100644 --- a/configure.ac +++ b/configure.ac @@ -281,15 +281,19 @@ then AC_DEFINE(HAVE_SETUID_ENABLED, 1, [Define if setuid support should be enabled.]) fi -AC_ARG_ENABLE(delayacct, [AS_HELP_STRING([--enable-delayacct], [enable linux delay accounting])],, enable_delayacct="no") +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