From 26310da15dd46776faf1c8e892896f443aa9c419 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 30 Jan 2022 03:25:54 -0500 Subject: autoconf-wrapper: handle autodetection better If WANT_AUTOCONF isn't set, don't just default to the latest version. If the current directory has configure or aclocal.m4 files previously generated with a specific autoconf version, then use that if available. This matches how the automake wrapper behaves. Signed-off-by: Mike Frysinger --- ac-wrapper.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ac-wrapper.sh b/ac-wrapper.sh index e37f5f3..d85b71b 100755 --- a/ac-wrapper.sh +++ b/ac-wrapper.sh @@ -146,10 +146,32 @@ generated_version() { sed -n -E "/${re}/{s:${re}:\3:;p;q}" "$@" } +recorded_aclocal_version() { + local re='.*m4_warning.*this file was generated for autoconf ([0-9].+)\..*' + sed -n -E "/${re}/{s:${re}:\1:;p;q}" "$@" +} + # # autodetect routine # -if [ "${WANT_AUTOCONF}" = "2.1" ] && [ -f "configure.ac" ] ; then +if [ -z "${WANT_AUTOCONF}" ] ; then + auto_vers= + if [ -r "configure" ] ; then + auto_vers="${auto_vers} $(generated_version configure)" + fi + if [ -r "aclocal.m4" ] ; then + auto_vers="${auto_vers} $(recorded_aclocal_version aclocal.m4)" + fi + # We don't need to set $binary here as it has already been setup for us + # earlier to the latest available version. + if [ -n "${auto_vers}" ] ; then + if ! find_binary ${auto_vers} ; then + warn "auto-detected versions not found (${auto_vers}); falling back to latest available" + fi + fi +fi + +if [ "${WANT_AUTOCONF}" = "2.1" -o "${WANT_AUTOCONF}" = "2.13" ] && [ -f "configure.ac" ] ; then err \ "Since configure.ac is present, aclocal will always use autoconf 2.59+\n" \ "\twhich conflicts with your choice and causes errors. You have two options:\n" \ -- cgit v1.2.3-65-gdbad