Re: fedora 42 doesn't have awk: how to deal with autoconf subst?
Paul Eggert <[email protected]> Fri, 18 Apr 2025 16:16:31 -0700
| Newsgroups | gmane.comp.lib.gnulib.bugs,gmane.comp.sysutils.autoconf.bugs |
|---|---|
| Organization | UCLA Computer Science Department |
| Message-ID | <[email protected]> |
On 2025-04-18 10:32, Zack Weinberg wrote: > this hypothetical 'shawk' would be > a *harder* task than converting all the existing unconditional uses of > awk to use sed instead. In 2007 we starting using awk in config.status because sed didn't always handle backslash-newline correctly, and because our sed approach ran into POSIX length limits that our awk approach doesn't have. I also vaguely recall awk ran faster. So I'd be cautious about switching back to sed. It's been mentioned a couple of times that 'configure' should diagnose and fail if awk is missing rather than bulldozing ahead with nonsense, so I installed the first attached patch to try to do that. The check is actually in config.status, which 'configure' calls but which can be called separately. Also, I saw that a minimal 'configure' uses grep only for "grep -c ^", so I installed the second attached patch to use "sed -n '$='" instead, since sed is used lots of other places in the script. I think most 'configure' scripts use grep for other stuff anyway, so this second minor tweak is not that much of a change in practice.
0001-config.status-now-checks-for-missing-awk.patch
(text/x-patch, 1.4 KB)
From b73f28c5196de7f79d62f793cfc247d2d6910393 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 18 Apr 2025 13:32:03 -0700 Subject: [PATCH 1/2] config.status now checks for missing awk * lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Diagnose missing awk and fail, rather than blundering on. --- NEWS | 3 +++ lib/autoconf/status.m4 | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 0b57386c..0899de5f 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,9 @@ GNU Autoconf NEWS - User visible changes. *** Autoconf no longer generates ${1+"$@"} in scripts, working around a bug in AIX 7.2 ksh93. +*** config.status now fails with a diagnostic if awk is missing, + rather than misbehaving. + * Noteworthy changes in release 2.72 (2023-12-22) [release] ** Backward incompatibilities diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4 index 4fd8f39b..8bbf4b38 100644 --- a/lib/autoconf/status.m4 +++ b/lib/autoconf/status.m4 @@ -1470,7 +1470,13 @@ AC_PROVIDE_IFELSE([AC_PROG_MKDIR_P], AC_PROVIDE_IFELSE([AC_PROG_AWK], [AWK='$AWK' ])dnl -test -n "\$AWK" || AWK=awk +test -n "\$AWK" || { + awk '' </dev/null || + AS_ESCAPE( + m4_dquote(m4_expand([AC_MSG_ERROR([try installing gawk])])), + [\$`]) + AWK=awk +} _ACEOF cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1 -- 2.48.1
0002-Avoid-grep-in-minimal-configure.patch
(text/x-patch, 2.3 KB)
From 3d79cd9ff455d85e788398bfe4fdc4544fabceb5 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 18 Apr 2025 14:01:38 -0700 Subject: [PATCH 2/2] Avoid grep in minimal configure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Use ‘sed -n '$='’ instead of ‘grep -c’, since these are the only uses of grep in a minimal ‘configure’ and we are already using sed elsewhere. --- doc/install.texi | 12 ++++++------ lib/autoconf/status.m4 | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/doc/install.texi b/doc/install.texi index f9e5e7fa..98eebe3d 100644 --- a/doc/install.texi +++ b/doc/install.texi @@ -138,15 +138,15 @@ you can type @samp{make uninstall} to remove the installed files. Installation requires a POSIX-like environment with a shell and at least the following standard utilities: -@example -awk cat cp diff echo expr false -grep ls mkdir mv printf pwd -rm rmdir sed sort test tr -@end example +@quotation +@t{awk cat cp diff echo expr false +ls mkdir mv printf pwd +rm rmdir sed sort test tr} +@end quotation @noindent This package's installation may need other standard utilities such as -@command{cmp}, @command{make}, @command{sleep} and @command{touch}, +@command{grep}, @command{make}, @command{sleep} and @command{touch}, along with compilers like @command{gcc}. @node Compilers and Options diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4 index 8bbf4b38..0ac451dc 100644 --- a/lib/autoconf/status.m4 +++ b/lib/autoconf/status.m4 @@ -403,14 +403,13 @@ rm -f conf$$files.sh echo "_ACEOF" } >conf$$subs.sh || AC_MSG_ERROR([could not make $CONFIG_STATUS]) -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim_num=`echo "$ac_subst_vars" | sed -n '$='` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || AC_MSG_ERROR([could not make $CONFIG_STATUS]) -dnl Do not use grep on conf$$subs.awk, since AIX grep has a line length limit. - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | sed -n '$='` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then -- 2.48.1