[PATCH 1/3] configure: use AC_PROG_GREP to detect a suitable grep

Bill Roberts bill.roberts at arm.com
Thu Oct 16 19:01:39 CEST 2025


Invoke AC_PROG_GREP to ensure a portable, working sed is available
instead of assuming one is present and risking obscure configure-time
failures. Replace direct grep invocations with the detected $(GREP)
variable so the build consistently uses the correct version.

Signed-off-by: Bill Roberts <bill.roberts at arm.com>
---
 configure.ac | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index edee25fae..d91d740d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,8 @@ AM_INIT_AUTOMAKE([1.8 gnu no-dependencies subdir-objects])
 AC_CONFIG_HEADERS(config.h:config.in)
 AM_MAINTAINER_MODE
 
+# Check for extra tools needed by configure
+AC_PROG_GREP
 
 AC_ARG_ENABLE(assert,
 AS_HELP_STRING([--enable-assert],[enable ASSERT checking [default=no]]),
@@ -3353,7 +3355,7 @@ DECL_$tmp_fbase (__MPN(${tmp_fbase}_init));" >>fat.h
 	    #
 	    if test -n "$GMP_NONSTD_ABI" && test $tmp_ext != "c"; then
 	      abi=[`sed -n 's/^[ 	]*ABI_SUPPORT(\(.*\))/\1/p' $tmp_file `]
-	      if echo "$abi" | grep -q "\\b${GMP_NONSTD_ABI}\\b"; then
+	      if echo "$abi" | $GREP -q "\\b${GMP_NONSTD_ABI}\\b"; then
 		true
 	      else
 		continue
@@ -3421,14 +3423,14 @@ include][($mpn_relative_top_srcdir/mpn/$tmp_dir/$tmp_base.asm)
             CPUVEC_SETUP="$CPUVEC_SETUP    decided_cpuvec.$tmp_fbase = __gmpn_${tmp_fbase}_${tmp_suffix}; \\
 "
             # Ditto for any preinv variant (preinv_divrem_1, preinv_mod_1).
-            if grep "^PROLOGUE(mpn_preinv_$tmp_fn)" $tmp_file >/dev/null; then
+            if $GREP "^PROLOGUE(mpn_preinv_$tmp_fn)" $tmp_file >/dev/null; then
               echo "DECL_preinv_$tmp_fbase (__gmpn_preinv_${tmp_fbase}_$tmp_suffix);" >>fat.h
               CPUVEC_SETUP="$CPUVEC_SETUP    decided_cpuvec.preinv_$tmp_fbase = __gmpn_preinv_${tmp_fbase}_${tmp_suffix}; \\
 "
             fi
 
             # Ditto for any mod_1...cps variant
-            if grep "^PROLOGUE(mpn_${tmp_fbase}_cps)" $tmp_file >/dev/null; then
+            if $GREP "^PROLOGUE(mpn_${tmp_fbase}_cps)" $tmp_file >/dev/null; then
               echo "DECL_${tmp_fbase}_cps (__gmpn_${tmp_fbase}_cps_$tmp_suffix);" >>fat.h
               CPUVEC_SETUP="$CPUVEC_SETUP    decided_cpuvec.${tmp_fbase}_cps = __gmpn_${tmp_fbase}_cps_${tmp_suffix}; \\
 "
@@ -3534,7 +3536,7 @@ for tmp_fn in $gmp_mpn_functions; do
 	  #
 	  if test -n "$GMP_NONSTD_ABI" && test $tmp_ext != "c"; then
 	    abi=[`sed -n 's/^[ 	]*ABI_SUPPORT(\(.*\))/\1/p' $tmp_file `]
-	    if echo "$abi" | grep -q "\\b${GMP_NONSTD_ABI}\\b"; then
+	    if echo "$abi" | $GREP -q "\\b${GMP_NONSTD_ABI}\\b"; then
 	      true
 	    else
 	      continue
-- 
2.51.0



More information about the gmp-devel mailing list