[Top][All Lists]

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


From: Ralf Wildenhues
Date: Mon, 3 Nov 2008 06:05:59 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

This came up again recently in gnulib:

I would like to apply the first patch to Autoconf, and the second one to
Automake.  Any reasons against doing so?


    Point at AM_SUBST_NOTMAKE.
    * doc/autoconf.texi (Setting Output Variables): Add cross
    reference to new Automake macro AM_SUBST_NOTMAKE.

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 2a7fc4a..20fd9a0 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -8761,7 +8761,12 @@ Setting Output Variables
 replaces instances of @samp{@@@var{variable}@@} in input files with the
 value that the shell variable @var{variable} has when @code{AC_OUTPUT}
 is called.  The value can contain any address@hidden character, including
+newline.  If you are using Automake 1.11 or newer, for newlines in values
+you might want to consider using @code{AM_SUBST_NOTMAKE} to prevent
address@hidden from adding a line @address@hidden =
+@@@var{variable}@@} to the @file{} files (@pxref{Optional, ,
+Automake, automake, Other things Automake recognizes}).
 Variable occurrences should not overlap: e.g., an input file should
 not contain @samp{@@@var{var1}@@@var{var2}@@} if @var{var1} and @var{var2}
 are variable names.

    New public macro AM_SUBST_NOTMAKE.
    * m4/substnot.m4 (AM_SUBST_NOTMAKE): New public macro; invoke
    _AM_SUBST_NOTMAKE with arguments.
    * doc/automake.texi (Optional): Document it.
    * NEWS: Update.
    * tests/subst4.test: New test.
    * tests/ Update.
    Suggestion by Bruno Haible.
    Signed-off-by: Ralf Wildenhues <address@hidden>

diff --git a/NEWS b/NEWS
index 80fae1a..cc7c41f 100644
--- a/NEWS
+++ b/NEWS
@@ -125,6 +125,9 @@ New in 1.10a:
   - AM_MAINTAINER_MODE now allows for an optional argument specifying
     the default setting.
+  - AM_SUBST_NOTMAKE may prevent substitution of AC_SUBSTed variables,
+    useful especially for multi-line values.
 Bugs fixed in 1.10a:
 * Long standing bugs:
diff --git a/doc/automake.texi b/doc/automake.texi
index 2ac7043..0c6146f 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -2897,7 +2897,8 @@ The Autoconf Manual}.
 @item AC_SUBST
 The first argument is automatically defined as a variable in each
-generated @file{}.  @xref{Setting Output Variables, , Setting
+generated @file{}, unless @code{AM_SUBST_NOTMAKE} is also
+used for this variable.  @xref{Setting Output Variables, , Setting
 Output Variables, autoconf, The Autoconf Manual}.
 If the Autoconf manual says that a macro calls @code{AC_SUBST} for
@@ -2942,6 +2943,17 @@ generated @file{}s, unless @var{default-mode} 
 conditional, which you can use in your own @file{}.
address@hidden AM_SUBST_NOTMAKE(@var{var})
+Prevent that Automake defines a variable @var{var} even if it is
+substituted by @command{config.status}.  Normally, Automake defines a
address@hidden variable for each @command{configure} substitution,
+i.e., for each @code{AC_SUBST(address@hidden)}.  This macro prevents that
+definition from Automake.  If @code{AC_SUBST} has not been called
+for this variable, then @code{AM_SUBST_NOTMAKE} has no effects.
+Preventing variable definitions may be useful for substitution of
+multi-line values, where @address@hidden = @@@var{value}@@} might yield
+unintended results.
 @item m4_include
 Files included by @file{} using this macro will be
 detected by Automake and automatically distributed.  They will also
diff --git a/m4/substnot.m4 b/m4/substnot.m4
index 5958962..811d286 100644
--- a/m4/substnot.m4
+++ b/m4/substnot.m4
@@ -1,12 +1,19 @@
 ##                                                          -*- Autoconf -*-
-# Copyright (C) 2006  Free Software Foundation, Inc.
+# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
+# serial 2
 # ---------------------------
 # Prevent Automake from outputting VARIABLE = @VARIABLE@ in
 # This macro is traced by Automake.
+# ---------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
diff --git a/tests/ b/tests/
index 2e64c25..4b4a780 100644
--- a/tests/
+++ b/tests/
@@ -595,6 +595,7 @@ subpkg3.test \
 subst.test \
 subst2.test \
 subst3.test \
+subst4.test \
 substref.test \
 substre2.test \
 substtarg.test \
diff --git a/tests/subst4.test b/tests/subst4.test
new file mode 100755
index 0000000..02e46bd
--- /dev/null
+++ b/tests/subst4.test
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2008  Free Software
+# Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <>.
+. ./defs || Exit 1
+set -e
+cat >> <<'EOF'
+foo: bar
+       echo making \$@ from bar
+       echo \$@ > \$@
+cat > <<'EOF'
+: > bar
+$MAKE foo
+test -f foo

reply via email to

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