build-sys: Give sensible errors if missing pkg-config

pkg-config is used to find various libraries used by procps.
Unfortunately it, or rather automake, give terrible misleading
error messages if pkg-config is not installed.

At ./configure time you get this:
configure: error: ncurses support missing/incomplete (for partial
build use --without-ncurses)

At automake time you get this:
configure.ac:33: error: possibly undefined macro: AC_MSG_ERROR
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:48: error: possibly undefined macro: AS_IF
configure.ac:113: error: possibly undefined macro: AC_DEFINE

The internet is filled with such wonderful other examples.

This commit does two things:
 At autoconf time, check PKG_PREREQ macro is defined which is found in
pkg.m4 and tells us pkg-config has its macros available.
 At configure time, check the result of the pkg-config test and error
 if it didn't find it.

Now it actually says its missing pkg-config. To be fair, the autoconf
check is "documented" and recommended in pkg.m4 file.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
This commit is contained in:
Craig Small 2022-05-25 21:08:50 +10:00
parent 8128641814
commit 6e661d2724

View File

@ -40,7 +40,14 @@ AM_PROG_CC_C_O
AC_PROG_CPP AC_PROG_CPP
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_LN_S AC_PROG_LN_S
dnl Check pkg-config is there for autoconf and at ./configure
m4_ifndef([PKG_PREREQ],
[m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
AS_IF([test -z "$PKG_CONFIG"],[
AC_MSG_ERROR([Could not find pkg-config])])
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_DEFUN([PROCPS_PROG_PO4A], [ AC_DEFUN([PROCPS_PROG_PO4A], [