From 9837738d51d691899d563cd2376f1d1138574df1 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Wed, 26 Aug 2020 18:46:51 +0200 Subject: [PATCH 1/6] always require `pkg-config` --- .github/workflows/ci.yml | 6 +++--- Makefile.am | 7 ------- configure.ac | 25 +++++++++++++------------ 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d95d0af91..6e6c84a5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install Dependencies - run: sudo apt-get install libncursesw5-dev + run: sudo apt-get install pkg-config libncursesw5-dev - name: Bootstrap run: ./autogen.sh - name: Configure @@ -30,7 +30,7 @@ jobs: sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' -y sudo apt-get update -q - name: Install Dependencies - run: sudo apt-get install clang-10 libncursesw5-dev + run: sudo apt-get install clang-10 pkg-config libncursesw5-dev - name: Bootstrap run: ./autogen.sh - name: Configure @@ -45,7 +45,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install Dependencies - run: sudo apt-get install libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev + run: sudo apt-get install pkg-config libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev - name: Bootstrap run: ./autogen.sh - name: Configure diff --git a/Makefile.am b/Makefile.am index d455b4d45..4005f5a45 100644 --- a/Makefile.am +++ b/Makefile.am @@ -231,13 +231,6 @@ coverage: cppcheck: cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS -dist-hook: $(top_distdir)/configure - @if grep 'pkg_m4_absent' '$(top_distdir)/configure'; then \ - echo 'configure is generated without pkg.m4. Please supply pkg.m4 and run ./autogen.sh to rebuild the configure script.'>&2; \ - (exit 1); \ - else :; \ - fi - .PHONY: lcov lcov: diff --git a/configure.ac b/configure.ac index b98dacc03..2482ceda6 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,14 @@ AM_PROG_CC_C_O # Required by hwloc scripts AC_USE_SYSTEM_EXTENSIONS +# Setup pkg-config. +# ---------------------------------------------------------------------- +m4_ifndef([PKG_PREREQ], + [m4_fatal([must install pkg-config 0.29 or later before running ./autogen.sh])]) +PKG_PREREQ([0.29]) + +PKG_PROG_PKG_CONFIG + # Checks for platform. # ---------------------------------------------------------------------- case "$target_os" in @@ -273,18 +281,11 @@ fi AC_ARG_ENABLE(delayacct, [AS_HELP_STRING([--enable-delayacct], [enable Linux delay accounting])],, enable_delayacct="no") if test "x$enable_delayacct" = xyes then - 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.]) - ], [ - 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.]) - ]) + 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.]) fi AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [Treat warnings as errors (default: warnings are not errors)])], [enable_werror="$enableval"], [enable_werror=no]) From 5f383ad2277ed552fd9d0931f6bc7951f4f273f4 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Wed, 26 Aug 2020 18:47:15 +0200 Subject: [PATCH 2/6] allow to run `autogen.sh` from non-toplevel directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` mkdir _build cd _build ../autogen.sh ../configure … ``` --- autogen.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autogen.sh b/autogen.sh index c07e08544..2f03647ac 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,3 +1,10 @@ #!/bin/sh + +set -e + +bindir=${0%/*} +: ${bindir:=.} +cd "$bindir" + mkdir -p m4 autoreconf --install --force From d9ceb666649971c742b8ff563d50a12cc1f665f7 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Wed, 26 Aug 2020 21:44:00 +0200 Subject: [PATCH 3/6] require 'modern' autoconf/automake --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2482ceda6..eb615af97 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.65) +AC_PREREQ([2.69]) AC_INIT([htop],[3.0.0],[htop@groups.io]) AC_CONFIG_SRCDIR([htop.c]) @@ -12,7 +12,7 @@ AC_CONFIG_MACRO_DIR([m4]) # Required by hwloc scripts AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE([1.11]) +AM_INIT_AUTOMAKE([1.15 -Wall]) # Checks for programs. # ---------------------------------------------------------------------- From 783d969ab2e19d6af3310535a96fb930d6fbedd7 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Wed, 26 Aug 2020 21:40:37 +0200 Subject: [PATCH 4/6] use libtool to ease linking against libraries --- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index eb615af97..ff21517e2 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,12 @@ AM_PROG_CC_C_O # Required by hwloc scripts AC_USE_SYSTEM_EXTENSIONS +# Setup Libtool. +# ---------------------------------------------------------------------- +LT_PREREQ([2.4.6]) +LT_INIT +AC_SUBST([LIBTOOL_DEPS]) + # Setup pkg-config. # ---------------------------------------------------------------------- m4_ifndef([PKG_PREREQ], From 1780d1cbe24e237c4f2ab6126010771bb2a5d0c0 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Wed, 26 Aug 2020 21:41:01 +0200 Subject: [PATCH 5/6] use silent rules by default --- Makefile.am | 2 +- configure.ac | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 4005f5a45..c6a1255f6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -226,7 +226,7 @@ coverage: $(MAKE) all CFLAGS="" AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" LDFLAGS="-lgcov" .c.h: - ./scripts/MakeHeader.py $< + $(AM_V_GEN)./scripts/MakeHeader.py $< cppcheck: cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS diff --git a/configure.ac b/configure.ac index ff21517e2..f4c4c740f 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([1.15 -Wall]) +AM_SILENT_RULES([yes]) # Checks for programs. # ---------------------------------------------------------------------- From 8ba6a199a98b467256826624aa2acd0a7c4a3c1c Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Wed, 26 Aug 2020 21:41:32 +0200 Subject: [PATCH 6/6] use `pkg-config` to determine HWLOC flags --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index f4c4c740f..a3591e99f 100644 --- a/configure.ac +++ b/configure.ac @@ -275,6 +275,9 @@ fi AC_ARG_ENABLE(hwloc, [AS_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no") if test "x$enable_hwloc" = xyes then + PKG_CHECK_MODULES([LIBHWLOC], [hwloc], [], [missing_libraries="$missing_libraries libhwloc"]) + CFLAGS="$CFLAGS $LIBHWLOC_CFLAGS" + LIBS="$LIBS $LIBHWLOC_LIBS" AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [missing_libraries="$missing_libraries libhwloc"]) AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"]) fi