autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: config files substitution with awk


From: Ralf Wildenhues
Subject: Re: config files substitution with awk
Date: Mon, 4 Dec 2006 20:48:58 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Paul,

* Paul Eggert wrote on Mon, Nov 27, 2006 at 11:50:54PM CET:
> Ralf Wildenhues <address@hidden> writes:
> 
> > I don't think we can assume that $AWK is more powerful than awk, so
> > we'd have to have the getline test anyway.  After all, the user may
> > have used ./configure AWK=awk
> 
> For that invocation we should just use the Awk that the user told us,
> and not second-guess the choice; that is the Autoconf tradition.
> 
> Perhaps it'd be simpler if Autoconf always invoked AC_PROG_AWK,
> in all cases where Awk is used by Autoconf?
> 
> The idea here is that the installer shouldn't have to worry about
> 'configure' invoking two Awk implementations to do real work.  There
> should be only one Awk implementation to worry about.  That will
> simplify the installer's job.

Yes, good idea.  How about this patch?
OK to use $AWK in config.status, or would a parameter $ac_cs_awk be
needed?

Cheers,
Ralf

2006-12-04  Ralf Wildenhues  <address@hidden>

        * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Use `$AWK'
        instead of `awk' consistently.
        (_AC_OUTPUT_CONFIG_STATUS): Initialize $AWK.
        * tests/torture.at (Torturing config.status): Test both the
        result of AC_PROG_AWK and plain awk.
        (Substitute a 2000-byte string): Likewise.
        (Substitute and define special characters): Likewise.
        (Substitute a newline): Likewise.

Index: lib/autoconf/status.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.121
diff -u -r1.121 status.m4
--- lib/autoconf/status.m4      27 Nov 2006 18:59:43 -0000      1.121
+++ lib/autoconf/status.m4      4 Dec 2006 19:47:14 -0000
@@ -346,7 +346,7 @@
 dnl Without any AC_SUBST_FILE, omit all related code.
 dnl Note the expansion is double-quoted for readability.
 m4_ifdef([_AC_SUBST_FILES],
-[[if awk 'BEGIN { getline <"/dev/null" }' </dev/null 2>/dev/null; then
+[[if $AWK 'BEGIN { getline <"/dev/null" }' </dev/null 2>/dev/null; then
   ac_cs_awk_getline=:
   ac_cs_awk_pipe_init=
   ac_cs_awk_read_file='
@@ -368,12 +368,12 @@
 m4_ifdef([_AC_SUBST_FILES],
 [m4_define([_AC_SUBST_CMDS], [|
 if $ac_cs_awk_getline; then
-  awk -f "$tmp/subs.awk"
+  $AWK -f "$tmp/subs.awk"
 else
-  awk -f "$tmp/subs.awk" | $SHELL
+  $AWK -f "$tmp/subs.awk" | $SHELL
 fi])],
 [m4_define([_AC_SUBST_CMDS],
-[| awk -f "$tmp/subs.awk"])])dnl
+[| $AWK -f "$tmp/subs.awk"])])dnl
 
 echo 'BEGIN {' >"$tmp/subs.awk"
 _ACEOF
@@ -1302,6 +1302,10 @@
 AC_PROVIDE_IFELSE([AC_PROG_MKDIR_P],
 [MKDIR_P='$MKDIR_P'
 ])dnl
+AC_PROVIDE_IFELSE([AC_PROG_AWK],
+[AWK='$AWK'
+])dnl
+test -n "\$AWK" || AWK=awk
 _ACEOF
 
 cat >>$CONFIG_STATUS <<\_ACEOF
Index: tests/torture.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/torture.at,v
retrieving revision 1.74
diff -u -r1.74 torture.at
--- tests/torture.at    27 Nov 2006 18:59:43 -0000      1.74
+++ tests/torture.at    4 Dec 2006 19:47:14 -0000
@@ -490,15 +490,18 @@
 AC_CONFIG_FILES(dummy)
 m4_for(AC_Count, 1, 100, 1,
        [AC_DEFUBST(AC_Count)])
+AC_PROG_AWK
 AC_OUTPUT
 ]])# configure.ac
 
 AT_CHECK_AUTOCONF
 AT_CHECK_AUTOHEADER
-AT_CHECK_CONFIGURE
+# Check both awk and the result of AC_PROG_AWK
+for awk_arg in FOO= AWK=awk; do
+  AT_CHECK_CONFIGURE([$awk_arg])
 
-# Checking that AC_DEFINE worked properly.
-AT_DATA([expout],
+  # Checking that AC_DEFINE worked properly.
+  AT_DATA([expout],
 [/* Define to the address where bug reports for this package should be sent. */
 #define PACKAGE_BUGREPORT ""
 
@@ -518,16 +521,18 @@
 /* AT_DESCRIPTION */
 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE"
 ])])
-AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
 
-# Checking that AC_SUBST worked properly.
-AT_DATA([expout],
+  AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
+
+  # Checking that AC_SUBST worked properly.
+  AT_DATA([expout],
 [m4_for(AT_Count, 1, 100, 1,
 [AT_BIG_VALUE
 content of file AT_Count
 ])])
 
-AT_CHECK([cat dummy], 0, expout)
+  AT_CHECK([cat dummy], 0, expout)
+done
 
 AT_CLEANUP
 
@@ -563,14 +568,17 @@
 ]])
 
 AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE
-AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
+# Check both awk and the result of AC_PROG_AWK
+for awk_arg in Foo= AWK=awk; do
+  AT_CHECK_CONFIGURE([$awk_arg])
+  AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
 )
-AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
+  AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
 )
-AT_CHECK([cat Baz], 0, m4_for([n], 1, 4,, m4_for([m], 1, 25,, ... ... ... ... 
....)
+  AT_CHECK([cat Baz], 0, m4_for([n], 1, 4,, m4_for([m], 1, 25,, ... ... ... 
... ....)
 )
 )
+done
 AT_CLEANUP
 
 
@@ -633,8 +641,10 @@
 
 AT_CHECK_AUTOCONF
 AT_CHECK_AUTOHEADER
-AT_CHECK_CONFIGURE
-AT_CHECK([cat Foo], 0, [[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
+# Check both awk and the result of AC_PROG_AWK
+for awk_arg in FOO= AWK=awk; do
+  AT_CHECK_CONFIGURE([$awk_arg])
+  AT_CHECK([cat Foo], 0, [[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
 @foo@ @baz@@address@hidden stray @ and more@@bla
 address@hidden@ @address@hidden@baz
 address@hidden@ @address@hidden
@@ -647,8 +657,9 @@
 address@hidden@
 @address@hidden
 ]])
-AT_CHECK_DEFINES([[#define foo X*'[]+ ",& &`\($foo !
+  AT_CHECK_DEFINES([[#define foo X*'[]+ ",& &`\($foo !
 ]])
+done
 AT_CLEANUP
 
 
@@ -673,10 +684,13 @@
 ]])
 
 AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE
-AT_CHECK([cat Foo], 0, [one
+# Check both awk and the result of AC_PROG_AWK
+for awk_arg in FOO= AWK=awk; do
+  AT_CHECK_CONFIGURE([$awk_arg])
+  AT_CHECK([cat Foo], 0, [one
 two
 ])
+done
 AT_CLEANUP
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]