[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AM_SUBST_IGNORE = AC_SUBST without Makefile variable definition
From: |
Alexandre Duret-Lutz |
Subject: |
Re: AM_SUBST_IGNORE = AC_SUBST without Makefile variable definition |
Date: |
Sat, 18 Mar 2006 10:31:08 +0100 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) |
>>> "adl" == Alexandre Duret-Lutz <address@hidden> writes:
[...]
adl> Originally, I wanted AM_SUBST_IGNORE to cause Automake to ignore
adl> a previously defined AC_SUBST, so you could have
adl> AC_SUBST([foo])
adl> and later, perhaps outside the macro that defines 'foo' if it's
adl> not yours, you would do
adl> AM_SUBST_IGNORE([foo])
adl> to tell Automake to ignore it. I'm sure the name of _IGNORE
adl> makes more sense in this usage. But then I realized the two
adl> lines would be often close to each other, and it was harmless to
adl> call AC_SUBST from AM_SUBST_IGNORE, even if AC_SUBST is not
adl> called.
I changed my mind about this. In this updated patch
AM_SUBST_NOTMAKE does not call AC_SUBST, I think this has some
minor advantages over the previous approach
- it makes it possible to ignore a variable that may be not always
defined
- no need to distinguish AM_SUBST_NOTMAKE/AM_SUBST_NOTMAKE_TRACE
- it makes future extensions easier (be it wildcard on macros,
specification of the set of Makefiles where this should apply, or
whatever else we might invent)
I still haven't completely understood the reaction to the earlier version of
this patch. Do you still think there is some ongoing Autoconf works (about
multi-line substitution or anything else) that should influence this patch?
To me it certainly looks completely independent of Autoconf.
distcheck is still running.
2006-03-18 Alexandre Duret-Lutz <address@hidden>
* automake.in (%ignored_configure_vars): New variable.
(scan_autoconf_traces): Trace for AM_SUBST_NOTMAKE and fill
%ignored_configure_vars.
(define_configure_variable): Declare ignored configure variables
as VAR_SILENT. Do not special-case AMDEPBACKSLASH and ANSI2KNR
w.r.t. VAR_SILENT.
* doc/automake.texi (Optional): Document AM_SUBST_NOTMAKE.
* m4/substign.m4: New file.
* m4/Makefile.am (dist_m4data_DATA): Add substign.m4.
* m4/cond.m4: AM_SUBST_IGNORE $1_TRUE and $1_FALSE (PR automake/477).
* m4/depend.m4: AM_SUBST_IGNORE AMDEPBACKSLASH.
* m4/protos.m4: AM_SUBST_IGNORE ANSI2KNR.
* tests/cond.test: Make sure TEST_FALSE and TEST_TRUE are not defined.
* tests/amsubst.test: New file.
* tests/Makefile.am (TESTS): Add it.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.302
diff -u -r1.302 NEWS
--- NEWS 10 Mar 2006 10:52:00 -0000 1.302
+++ NEWS 18 Mar 2006 09:27:41 -0000
@@ -89,6 +89,12 @@
$(LIBOBJS), $(LTLIBOBJS), $(ALLOCA), and $(LTALLOCA) can be used
in different directories.
+ - A new macro, AM_SUBST_NOTMAKE, can be used to declare variables
+ for which Automake should not produce a `VAR = @VAR@' definition
+ in Makefile.in. This comes handy when @VAR@ ends with a backslash,
+ for instance, or if it's a huge definition that would bloat the
+ the Makefile.in.
+
- $(EXEEXT) is automatically appended to filenames of TESTS and
that have been declared as programs in the same Makefile.
This is mostly useful when some check_PROGRAMS are listed in TESTS.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1618
diff -u -r1.1618 automake.in
--- automake.in 10 Mar 2006 12:02:26 -0000 1.1618
+++ automake.in 18 Mar 2006 09:27:41 -0000
@@ -390,6 +390,10 @@
# generation.
my %configure_vars = ();
+# Ignored configure substitutions (i.e., variables not to be output in
+# Makefile.in)
+my %ignored_configure_vars = ();
+
# Files included by $configure_ac.
my @configure_deps = ();
@@ -4807,6 +4811,7 @@
AM_INIT_AUTOMAKE => 0,
AM_MAINTAINER_MODE => 0,
AM_PROG_CC_C_O => 0,
+ AM_SUBST_NOTMAKE => 1,
LT_SUPPORTED_TAG => 1,
_LT_AC_TAGCONFIG => 0,
m4_include => 1,
@@ -4918,6 +4923,12 @@
{
$libsources{$args[1]} = $here;
}
+ elsif ($macro eq 'AC_REQUIRE_AUX_FILE')
+ {
+ # Only remember the first time a file is required.
+ $required_aux_file{$args[1]} = $where
+ unless exists $required_aux_file{$args[1]};
+ }
elsif ($macro eq 'AC_SUBST_TRACE')
{
# Just check for alphanumeric in AC_SUBST_TRACE. If you do
@@ -4975,11 +4986,9 @@
{
$seen_cc_c_o = $where;
}
- elsif ($macro eq 'AC_REQUIRE_AUX_FILE')
+ elsif ($macro eq 'AM_SUBST_NOTMAKE')
{
- # Only remember the first time a file is required.
- $required_aux_file{$args[1]} = $where
- unless exists $required_aux_file{$args[1]};
+ $ignored_configure_vars{$args[1]} = $where;
}
elsif ($macro eq 'm4_include'
|| $macro eq 'm4_sinclude'
@@ -5873,16 +5882,16 @@
my $pretty = VAR_ASIS;
my $owner = VAR_CONFIGURE;
- # Do not output the ANSI2KNR configure variable -- we AC_SUBST
- # it in protos.m4, but later redefine it elsewhere. This is
- # pretty hacky. We also don't output AMDEPBACKSLASH: it might
- # be subst'd by `\', which certainly would not be appreciated by
- # Make.
- if ($var eq 'ANSI2KNR' || $var eq 'AMDEPBACKSLASH')
- {
- $pretty = VAR_SILENT;
- $owner = VAR_AUTOMAKE;
- }
+ # Some variables we do not want to output. For instance it
+ # would be a bad idea to output `U = @address@hidden when address@hidden@`
can be
+ # substituted as `\`.
+ $pretty = VAR_SILENT if exists $ignored_configure_vars{$var};
+
+ # ANSI2KNR is a variable that Automake wants to redefine, so
+ # it must be owned by Automake. (It is also used as a proof
+ # that AM_C_PROTOTYPES has been run, that's why we do not simply
+ # omit the AC_SUBST.)
+ $owner = VAR_AUTOMAKE if $var eq 'ANSI2KNR';
Automake::Variable::define ($var, $owner, '', TRUE, subst $var,
'', $configure_vars{$var}, $pretty);
Index: doc/automake.texi
===================================================================
RCS file: /cvs/automake/automake/doc/automake.texi,v
retrieving revision 1.131
diff -u -r1.131 automake.texi
--- doc/automake.texi 10 Mar 2006 10:51:37 -0000 1.131
+++ doc/automake.texi 18 Mar 2006 09:27:43 -0000
@@ -1584,6 +1584,9 @@
you can use these variables in any @file{Makefile.am} if
@code{AC_PATH_XTRA} is called.
address@hidden (see below) can be used to declare
+substitutions that should not be defined as @file{Makefile} variables.
+
@item AM_C_PROTOTYPES
This is required when using automatic de-ANSI-fication; see @ref{ANSI}.
@@ -1602,6 +1605,30 @@
@code{MAINTAINER_MODE} conditional, which you can use in your own
@file{Makefile.am}. @xref{maintainer-mode}.
address@hidden AM_SUBST_NOTMAKE
+This macro declares an @code{AC_SUBST} variable that automake should not
+define in the @file{Makefile.in}s it outputs.
+
+It is occasionally necessary to let Automake ignore some substitutions
+that are not meant to be used as @file{Makefile} variables. For
+instance values that are terminated by a backslash would cause syntax
+error if they were defined as @file{Makefile} variables.
+
+As an example the following @file{configure.ac} fragment will cause
+Automake not to output a @code{directory_separator =
+@@directory_separator@@} definition in @file{Makefile.in}s, while
address@hidden@@directory_separator@@} can still be used anywhere it makes
+sense.
address@hidden
+if some test; then
+ directory_separator=/
+else
+ directory_separator=\\
+fi
+AC_SUBST([directory_separator])
+AM_SUBST_NOTMAKE([directory_separator])
address@hidden example
+
@item m4_include
Files included by @file{configure.ac} using this macro will be
detected by Automake and automatically distributed. They will also
Index: m4/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/m4/Makefile.am,v
retrieving revision 1.54
diff -u -r1.54 Makefile.am
--- m4/Makefile.am 14 May 2005 20:28:53 -0000 1.54
+++ m4/Makefile.am 18 Mar 2006 09:27:43 -0000
@@ -2,7 +2,7 @@
## Makefile for Automake m4.
-## Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004
+## Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2006
## Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
@@ -54,6 +54,7 @@
runlog.m4 \
sanity.m4 \
strip.m4 \
+substign.m4 \
tar.m4
EXTRA_DIST = dirlist amversion.in
Index: m4/cond.m4
===================================================================
RCS file: /cvs/automake/automake/m4/cond.m4,v
retrieving revision 1.13
diff -u -r1.13 cond.m4
--- m4/cond.m4 9 Jan 2005 14:46:21 -0000 1.13
+++ m4/cond.m4 18 Mar 2006 09:27:43 -0000
@@ -1,13 +1,13 @@
# AM_CONDITIONAL -*- Autoconf -*-
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
# 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 7
+# serial 8
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
@@ -16,8 +16,10 @@
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
-AC_SUBST([$1_TRUE])
-AC_SUBST([$1_FALSE])
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+AM_SUBST_NOTMAKE([$1_TRUE])dnl
+AM_SUBST_NOTMAKE([$1_FALSE])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
Index: m4/depend.m4
===================================================================
RCS file: /cvs/automake/automake/m4/depend.m4,v
retrieving revision 1.35
diff -u -r1.35 depend.m4
--- m4/depend.m4 9 Jan 2005 14:46:21 -0000 1.35
+++ m4/depend.m4 18 Mar 2006 09:27:43 -0000
@@ -1,13 +1,12 @@
## -*- Autoconf -*-
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
# 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 8
+# serial 9
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
@@ -152,5 +151,6 @@
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
-AC_SUBST([AMDEPBACKSLASH])
+AC_SUBST([AMDEPBACKSLASH])dnl
+AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
])
Index: m4/protos.m4
===================================================================
RCS file: /cvs/automake/automake/m4/protos.m4,v
retrieving revision 1.11
diff -u -r1.11 protos.m4
--- m4/protos.m4 9 Jan 2005 14:46:21 -0000 1.11
+++ m4/protos.m4 18 Mar 2006 09:27:43 -0000
@@ -2,14 +2,14 @@
## Check for function prototypes. ##
## From Franc,ois Pinard ##
## ------------------------------- ##
-# Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005
+# Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2006
# 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 4
+# serial 5
AC_DEFUN([AM_C_PROTOTYPES],
[AC_REQUIRE([AC_C_PROTOTYPES])
@@ -20,9 +20,10 @@
fi
# Ensure some checks needed by ansi2knr itself.
AC_REQUIRE([AC_HEADER_STDC])
-AC_CHECK_HEADERS(string.h)
-AC_SUBST(U)dnl
-AC_SUBST(ANSI2KNR)dnl
+AC_CHECK_HEADERS([string.h])
+AC_SUBST([U])dnl
+AC_SUBST([ANSI2KNR])dnl
+AM_SUBST_NOTMAKE([ANSI2KNR])dnl
])
AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
Index: m4/substign.m4
===================================================================
RCS file: m4/substign.m4
diff -N m4/substign.m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ m4/substign.m4 18 Mar 2006 09:27:43 -0000
@@ -0,0 +1,12 @@
+## -*- Autoconf -*-
+# Copyright (C) 2006 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.
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([AM_SUBST_NOTMAKE])
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.593
diff -u -r1.593 Makefile.am
--- tests/Makefile.am 10 Mar 2006 12:02:26 -0000 1.593
+++ tests/Makefile.am 18 Mar 2006 09:27:43 -0000
@@ -37,6 +37,7 @@
alpha2.test \
amassign.test \
ammissing.test \
+amsubst.test \
ansi.test \
ansi2.test \
ansi3.test \
Index: tests/amsubst.test
===================================================================
RCS file: tests/amsubst.test
diff -N tests/amsubst.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/amsubst.test 18 Mar 2006 09:27:43 -0000
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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 2, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Check for AM_SUBST_NOTMAKE.
+
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_SUBST([backslash], "\\")
+AM_SUBST_NOTMAKE([backslash])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+test:
+ @echo $(backslash) @address@hidden
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+# If AM_SUBST_NOTMAKE is not honored, the backslash
+# variable will not be empty.
+$MAKE test | grep '^[$]$'
Index: tests/cond.test
===================================================================
RCS file: /cvs/automake/automake/tests/cond.test,v
retrieving revision 1.8
diff -u -r1.8 cond.test
--- tests/cond.test 14 May 2005 20:28:54 -0000 1.8
+++ tests/cond.test 18 Mar 2006 09:27:43 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1997, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2001, 2002, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -22,11 +22,11 @@
. ./defs || exit 1
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+set -e
+
+cat >> configure.in << 'END'
AM_CONDITIONAL(TEST, true)
-AC_OUTPUT(Makefile)
+AC_OUTPUT
END
cat > Makefile.am << 'END'
@@ -37,11 +37,10 @@
endif
END
-set -e
-$ACLOCAL || exit 1
+$ACLOCAL
$AUTOMAKE
+grep '^TEST_FALSE' Makefile.in && exit 1
+grep '^TEST_TRUE' Makefile.in && exit 1
grep 'address@hidden@VAR = true$' Makefile.in
grep 'address@hidden@VAR = false$' Makefile.in
-
-exit 0
--
Alexandre Duret-Lutz
Shared books are happy books. http://www.bookcrossing.com/friend/gadl
- Re: AM_SUBST_IGNORE = AC_SUBST without Makefile variable definition,
Alexandre Duret-Lutz <=