]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Make it more explicit and visible when pkg-config is not found
authorArne Schwabe <arne@rfc2549.org>
Fri, 5 Jan 2024 14:05:40 +0000 (15:05 +0100)
committerGert Doering <gert@greenie.muc.de>
Fri, 5 Jan 2024 14:12:35 +0000 (15:12 +0100)
Users seem to struggle to read the full error message. This adds an
indication if pkg-config is actually found to the warning/error message
that use pkg-config.

On platforms that do not require pkg-config and for optional libraries,
the existence of pkg-config is mentioned as part of the error/warning message.

When found:

    configure: error: libnl-genl-3.0 package not found or too old. Is the development package and pkg-config (/usr/bin/pkg-config) installed? Must be version 3.4.0 or newer for DCO

not found:

    configure: error: libnl-genl-3.0 package not found or too old. Is the development package and pkg-config (not found) installed? Must be version 3.4.0 or newer for DCO

On platforms where pkg-config is required (only Linux at the moment),
configure will abort when not detecting pkg-config:

checking for pkg-config... no
configure: error: pkg-config is required

Change-Id: Iebaa35a23e217a4cd7739af229cbfc08a3d8854a
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20240105140540.14757-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27939.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
configure.ac

index f4206120fa0f2388a7e6b6a1b79d36f832ffa328..3ad9f14be3958e78c439919d32d1e83be83c130c 100644 (file)
@@ -323,6 +323,7 @@ case "$host" in
                AM_CONDITIONAL([TARGET_LINUX], [true])
                AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["L"], [Target prefix])
                have_sitnl="yes"
+               pkg_config_required="yes"
                ;;
        *-*-solaris*)
                AC_DEFINE([TARGET_SOLARIS], [1], [Are we running on Solaris?])
@@ -376,6 +377,16 @@ esac
 AM_CONDITIONAL([CROSS_COMPILING], test "${cross_compiling}" = "yes")
 
 PKG_PROG_PKG_CONFIG
+# Add variable to print if pkg-config is found or not. Users often miss that
+if test "${PKG_CONFIG}" = ""; then
+       if test "${pkg_config_required}" = "yes"; then
+               AC_MSG_ERROR([pkg-config is required])
+       fi
+       pkg_config_found="(not found)"
+else
+       pkg_config_found="(${PKG_CONFIG})"
+fi
+
 AC_PROG_CPP
 AC_PROG_INSTALL
 AC_PROG_LN_S
@@ -810,7 +821,7 @@ if test "$enable_dco" != "no"; then
                                          [libnl-genl-3.0 >= 3.4.0],
                                          [have_libnl="yes"],
                                          [
-                                          AC_MSG_ERROR([libnl-genl-3.0 package not found or too old. Is the development package and pkg-config installed? Must be version 3.4.0 or newer for DCO])
+                                          AC_MSG_ERROR([libnl-genl-3.0 package not found or too old. Is the development package and pkg-config ${pkg_config_found} installed? Must be version 3.4.0 or newer for DCO])
                                          ]
                                )
                                CFLAGS="${CFLAGS} ${LIBNL_GENL_CFLAGS}"
@@ -854,10 +865,11 @@ dnl Depend on libcap-ng on Linux
 dnl
 case "$host" in
        *-*-linux*)
+               # We require pkg-config
                PKG_CHECK_MODULES([LIBCAPNG],
                                  [libcap-ng],
                                  [],
-                                 [AC_MSG_ERROR([libcap-ng package not found. Is the development package and pkg-config installed?])]
+                                 [AC_MSG_ERROR([libcap-ng package not found. Is the development package and pkg-config ${pkg_config_found} installed?])]
                )
                AC_CHECK_HEADER([sys/prctl.h],,[AC_MSG_ERROR([sys/prctl.h not found!])])
 
@@ -878,7 +890,7 @@ if test "${with_crypto_library}" = "openssl"; then
                        [OPENSSL],
                        [openssl >= 1.0.2],
                        [have_openssl="yes"],
-                       [] # If this fails, we will do another test next
+                       [AC_MSG_WARN([OpenSSL not found by pkg-config ${pkg_config_found}])] # If this fails, we will do another test next
                )
                OPENSSL_LIBS=${OPENSSL_LIBS:--lssl -lcrypto}
        fi
@@ -1083,7 +1095,7 @@ elif test "${with_crypto_library}" = "wolfssl"; then
                        [WOLFSSL],
                        [wolfssl],
                        [],
-                       [AC_MSG_ERROR([Could not find wolfSSL.])]
+                       [AC_MSG_ERROR([Could not find wolfSSL using pkg-config ${pkg_config_found}])]
                )
                PKG_CHECK_VAR(
                        [WOLFSSL_INCLUDEDIR],
@@ -1508,7 +1520,7 @@ AC_ARG_ENABLE(
 PKG_CHECK_MODULES(
        [CMOCKA], [cmocka],
        [have_cmocka="yes"],
-       [AC_MSG_WARN([cmocka.pc not found on the system.  Unit tests disabled])]
+       [AC_MSG_WARN([cmocka.pc not found on the system using pkg-config ${pkg_config_found}.  Unit tests disabled])]
 )
 AM_CONDITIONAL([ENABLE_UNITTESTS], [test "${enable_unit_tests}" = "yes" -a "${have_cmocka}" = "yes" ])
 AC_SUBST([ENABLE_UNITTESTS])