From 96cda9c82224e6609b7ddbde89b43a91eddf2fed Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Mon, 3 Nov 2008 22:56:22 +0100 Subject: [PATCH] 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/Makefile.am: Update. Suggestion by Bruno Haible. Signed-off-by: Ralf Wildenhues --- ChangeLog | 9 +++++++++ NEWS | 3 +++ doc/automake.texi | 14 +++++++++++++- m4/substnot.m4 | 9 ++++++++- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/subst4.test | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 81 insertions(+), 2 deletions(-) create mode 100755 tests/subst4.test diff --git a/ChangeLog b/ChangeLog index ef3b8f397..a6c63a2a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2008-11-03 Ralf Wildenhues + 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/Makefile.am: Update. + Suggestion by Bruno Haible. + Fix regression introduced by AM_DEFAULT_SOURCE_EXT. * automake.in (handle_source_transform): Use the right variable when determining whether to apply the old rule for the libtool diff --git a/NEWS b/NEWS index 5c7d295a3..483416593 100644 --- a/NEWS +++ b/NEWS @@ -114,6 +114,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 acb97cdcc..40b5b5d21 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -2896,7 +2896,8 @@ The Autoconf Manual}. @item AC_SUBST The first argument is automatically defined as a variable in each -generated @file{Makefile.in}. @xref{Setting Output Variables, , Setting +generated @file{Makefile.in}, 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 @@ -2941,6 +2942,17 @@ generated @file{Makefile.in}s, unless @var{default-mode} is conditional, which you can use in your own @file{Makefile.am}. @xref{maintainer-mode}. +@item AM_SUBST_NOTMAKE(@var{var}) +Prevent Automake from defining a variable @var{var}, even if it is +substituted by @command{config.status}. Normally, Automake defines a +@command{make} variable for each @command{configure} substitution, +i.e., for each @code{AC_SUBST([@var{var}])}. 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 @code{@var{var} = @@@var{value}@@} might yield +unintended results. + @item m4_include Files included by @file{configure.ac} 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 5958962bb..811d28685 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 + # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) diff --git a/tests/Makefile.am b/tests/Makefile.am index fa2b9a866..52c37c546 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -574,6 +574,7 @@ subpkg3.test \ subst.test \ subst2.test \ subst3.test \ +subst4.test \ substref.test \ substre2.test \ substtarg.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index f06377066..04d205c31 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -727,6 +727,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 000000000..02e46bdee --- /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 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + +# Test AM_SUBST_NOTMAKE. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'EOF' +myrule="\ +foo: bar + echo making \$@ from bar + echo \$@ > \$@ +" +AC_SUBST([myrule]) +AM_SUBST_NOTMAKE([myrule]) +AC_OUTPUT +EOF + +cat > Makefile.am <<'EOF' +@myrule@ +EOF +: > bar + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure +$MAKE foo +test -f foo +: -- 2.47.2