>From 78c52d586b8498508f4784ab6facf20a5859e6bc Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 21 Feb 2021 17:01:29 +0100 Subject: [PATCH 5/5] Don't use gcc-ar and gcc-ranlib if they are not functional. * configure.ac (AR, RANLIB): Don't use gcc-ar and gcc-ranlib if they always fail. --- configure.ac | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 2d62107..8c3e27a 100644 --- a/configure.ac +++ b/configure.ac @@ -252,17 +252,63 @@ fi # Indeed, we rely on a C compiler. AC_PROG_CC +# We do support cross-compiling. +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + # This package contains libraries. When enabling LTO with static libraries (for # which setting CFLAGS/LDFLAGS is enough) we need to use the specialized library # tools which come with GCC. Autoconf doesn't check for them by default, but # it's easy to do. If the specialized tools aren't available we fall back on the # traditional ones. # +# On the other hand, some versions of 'gcc-ar' and 'gcc-ranlib' always fail with +# "sorry - this program has been built without plugin support". Don't pick them +# in this case. +# # I noticed that moving the check for RANLIB to this early point prevents the # default (HOSTTRIPLET-ranlib) from being chosen despite the order of the tools # chosen here. Some default might come from gl_EARLY. -AC_CHECK_TOOLS([RANLIB], [gcc-ranlib ranlib]) -AC_CHECK_TOOLS([AR], [gcc-ar ar]) + +AC_MSG_CHECKING([for ar]) +if test -z "$AR"; then + for prog in ${host}-gcc-ar gcc-ar; do + if test -z "$AR" \ + && (type $prog) >/dev/null 2>&1 \ + && $prog --help >/dev/null 2>&1; then + AR="$prog" + fi + done + for prog in ${host}-ar ar; do + if test -z "$AR" \ + && (type $prog) >/dev/null 2>&1; then + AR="$prog" + fi + done + test -n "$AR" || AR=: +fi +AC_MSG_RESULT([$AR]) +AC_SUBST([AR]) + +AC_MSG_CHECKING([for ranlib]) +if test -z "$RANLIB"; then + for prog in ${host}-gcc-ranlib gcc-ranlib; do + if test -z "$RANLIB" \ + && (type $prog) >/dev/null 2>&1 \ + && $prog --help >/dev/null 2>&1; then + RANLIB="$prog" + fi + done + for prog in ${host}-ranlib ranlib; do + if test -z "$RANLIB" \ + && (type $prog) >/dev/null 2>&1; then + RANLIB="$prog" + fi + done + test -n "$RANLIB" || RANLIB=: +fi +AC_MSG_RESULT([$RANLIB]) +AC_SUBST([RANLIB]) # Run the early part of the Gnulib initialization. This is recommended # right after AC_PROG_CC . @@ -283,10 +329,6 @@ if test "x$NO_MINUS_C_MINUS_O" != "x"; then AC_MSG_ERROR([please write to $PACKAGE_BUGREPORT if you want to help]) fi -# We do support cross-compiling. -AC_CANONICAL_BUILD -AC_CANONICAL_HOST - # Define a feature CPP macro if we are cross-compiling; also set a shell # variable holding "yes" or "no" to use in this script. AC_MSG_CHECKING([if we are cross-compiling]) -- 2.7.4