From: Vincent Bernat Date: Fri, 5 Sep 2014 18:19:34 +0000 (+0200) Subject: build: check if pkg-config is correctly installed in ./autogen.sh X-Git-Tag: 0.7.11~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79790b96b5eb02843071bb6689dfb6e1b62c3432;p=thirdparty%2Flldpd.git build: check if pkg-config is correctly installed in ./autogen.sh Absence of pkg-config leads to some odd messages: configure.ac:27: error: possibly undefined macro: AC_SUBST If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. configure.ac:163: error: possibly undefined macro: AC_MSG_FAILURE configure:21413: error: possibly undefined macro: AC_MSG_CHECKING configure:21418: error: possibly undefined macro: AC_TRY_LINK configure:21423: error: possibly undefined macro: AC_MSG_RESULT configure:21432: error: possibly undefined macro: AC_MSG_NOTICE configure:21894: error: possibly undefined macro: AC_PATH_TOOL configure:21896: error: possibly undefined macro: AC_MSG_ERROR configure:21975: error: possibly undefined macro: AC_DEFINE_UNQUOTED We try to detect this situation by looking for `PKG_CHECK_MODULES` macro in `aclocal.m4`. If not present, we issue some useful tips, like installing the package or telling aclocal the location of `pkg.m4` (mostly for OSX users). --- diff --git a/autogen.sh b/autogen.sh index 78e5d82b..bc63a810 100755 --- a/autogen.sh +++ b/autogen.sh @@ -36,6 +36,32 @@ check_command "$AUTOCONF" check_command "$AUTOHEADER" check_command "$AUTOMAKE" +# Absence of pkg-config or misconfiguration can make some odd error +# messages, we check if it is installed correctly. See: +# https://blogs.oracle.com/mandy/entry/autoconf_weirdness +# +# We cannot just check for pkg-config command, we need to check for +# PKG_* macros. The pkg-config command can be defined in ./configure, +# we cannot tell anything when not present. +check_pkg_config() { + grep -q '^AC_DEFUN.*PKG_CHECK_MODULES' aclocal.m4 || { + cat <&2 +autogen.sh: could not find PKG_CHECK_MODULES macro. + + Either pkg-config is not installed on your system or + \`pkg.m4' is missing or not found by aclocal. + + If \`pkg.m4' is installed at an unusual location, re-run + \`autogen.sh' by setting \`ACLOCAL_FLAGS': + + ACLOCAL_FLAGS="-I /share/aclocal" ./autogen.sh + +EOF + exit 1 + } +} + + echo "autogen.sh: start libtoolize to get ltmain.sh" ${LIBTOOLIZE} --copy --force echo "autogen.sh: reconfigure with autoreconf" @@ -45,9 +71,10 @@ ${AUTORECONF} -vif -I m4 || { [ -d "$dir" ] || continue [ -f "$dir"/configure.ac ] || [ -f "$dir"/configure.in ] || continue echo "autogen.sh: configure `basename $dir`" - (cd "$dir" && ${ACLOCAL} -I m4) + (cd "$dir" && ${ACLOCAL} -I m4 ${ACLOCAL_FLAGS}) + (cd "$dir" && check_pkg_config) (cd "$dir" && ${LIBTOOLIZE} --automake --copy --force) - (cd "$dir" && ${ACLOCAL} -I m4) + (cd "$dir" && ${ACLOCAL} -I m4 ${ACLOCAL_FLAGS}) (cd "$dir" && ${AUTOCONF} --force) (cd "$dir" && ${AUTOHEADER}) (cd "$dir" && ${AUTOMAKE} --add-missing --copy --force-missing)