From c1bea7251cfa9a89999a2e0bae58cccc224f3696 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 13 Sep 2002 16:37:01 +0000 Subject: [PATCH] * automake.texi (Building ctags and etags): Rename and adjust as ... (Building true and false): ... this. * tests/targetclash.test: New file. * tests/specflags7.test, tests/specflags8.test: Adjust to build true and false. * tests/Makefile.am (TESTS): Add targetclash.test. (XFAIL_TESTS): Remove specflags7.test and specflags8.test. --- ChangeLog | 8 ++++ automake.texi | 98 +++++++++++++++++++++--------------------- stamp-vti | 2 +- tests/Makefile.am | 1 + tests/Makefile.in | 3 +- tests/specflags7.test | 32 +++++++------- tests/specflags8.test | 26 +++++------ tests/targetclash.test | 40 +++++++++++++++++ version.texi | 2 +- 9 files changed, 132 insertions(+), 80 deletions(-) create mode 100755 tests/targetclash.test diff --git a/ChangeLog b/ChangeLog index 2e60f22f8..e0500254e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2002-09-13 Alexandre Duret-Lutz + * automake.texi (Building ctags and etags): Rename and adjust as ... + (Building true and false): ... this. + * tests/targetclash.test: New file. + * tests/specflags7.test, tests/specflags8.test: Adjust to build + true and false. + * tests/Makefile.am (TESTS): Add targetclash.test. + (XFAIL_TESTS): Remove specflags7.test and specflags8.test. + Diagnose target clashes, for PR automake/344: * automake.in (%targets): Record conditionals for definitions. (%target_conditional): Remove (obsoleted by %targets). diff --git a/automake.texi b/automake.texi index bdeccba3e..2d3db524b 100644 --- a/automake.texi +++ b/automake.texi @@ -611,7 +611,7 @@ directory in parallel. @menu * Complete:: A simple example, start to finish * Hello:: A classic program -* etags:: Building etags and ctags +* true:: Building true and false @end menu @@ -681,7 +681,7 @@ Now you can run @code{automake --add-missing} to generate your you're done! -@node Hello, etags, Complete, Examples +@node Hello, true, Complete, Examples @section A classic program @cindex Example, GNU Hello @@ -794,54 +794,54 @@ INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" @end example -@node etags, , Hello, Examples -@section Building etags and ctags +@node true, , Hello, Examples +@section Building true and false -@cindex Example, ctags and etags -@cindex ctags Example -@cindex etags Example +@cindex Example, false and true +@cindex false Example +@cindex true Example Here is another, trickier example. It shows how to generate two -programs (@code{ctags} and @code{etags}) from the same source file -(@file{etags.c}). The difficult part is that each compilation of -@file{etags.c} requires different @code{cpp} flags. +programs (@code{true} and @code{false}) from the same source file +(@file{true.c}). The difficult part is that each compilation of +@file{true.c} requires different @code{cpp} flags. @example -bin_PROGRAMS = etags ctags -ctags_SOURCES = -ctags_LDADD = ctags.o +bin_PROGRAMS = true false +false_SOURCES = +false_LDADD = false.o -etags.o: etags.c - $(COMPILE) -DETAGS_REGEXPS -c etags.c +true.o: true.c + $(COMPILE) -DEXIT_CODE=0 -c true.c -ctags.o: etags.c - $(COMPILE) -DCTAGS -o ctags.o -c etags.c +false.o: true.c + $(COMPILE) -DEXIT_CODE=1 -o false.o -c true.c @end example -Note that there is no @code{etags_SOURCES} definition. Automake will -implicitly assume that there is a source file named @file{etags.c}, and -define rules to compile @file{etags.o} and link @file{etags}. The -@code{etags.o: etags.c} rule supplied by the above @file{Makefile.am}, -will override the Automake generated rule to build @file{etags.o}. +Note that there is no @code{true_SOURCES} definition. Automake will +implicitly assume that there is a source file named @file{true.c}, and +define rules to compile @file{true.o} and link @file{true}. The +@code{true.o: true.c} rule supplied by the above @file{Makefile.am}, +will override the Automake generated rule to build @file{true.o}. -@code{ctags_SOURCES} is defined to be empty---that way no implicit value +@code{false_SOURCES} is defined to be empty---that way no implicit value is substituted. Because we have not listed the source of -@file{ctags}, we have to tell Automake how to link the program. This is -the purpose of the @code{ctags_LDADD} line. A @code{ctags_DEPENDENCIES} -variable, holding the dependencies of the @file{ctags} target will be +@file{false}, we have to tell Automake how to link the program. This is +the purpose of the @code{false_LDADD} line. A @code{false_DEPENDENCIES} +variable, holding the dependencies of the @file{false} target will be automatically generated by Automake from the contant of -@code{ctags_LDADD}. +@code{false_LDADD}. The above rules won't work if your compiler doesn't accept both @samp{-c} and @samp{-o}. The simplest fix for this is to introduce a bogus dependency (to avoid problems with a parallel @code{make}): @example -etags.o: etags.c ctags.o - $(COMPILE) -DETAGS_REGEXPS -c etags.c +true.o: true.c false.o + $(COMPILE) -DEXIT_CODE=0 -c true.c -ctags.o: etags.c - $(COMPILE) -DCTAGS -c etags.c && mv etags.o ctags.o +false.o: true.c + $(COMPILE) -DEXIT_CODE=1 -c true.c && mv true.o false.o @end example Also, these explicit rules do not work if the de-ANSI-fication feature @@ -849,33 +849,33 @@ is used (@pxref{ANSI}). Supporting de-ANSI-fication requires a little more work: @example -etags._o: etags._c ctags.o - $(COMPILE) -DETAGS_REGEXPS -c etags.c +true._o: true._c false.o + $(COMPILE) -DEXIT_CODE=0 -c true.c -ctags._o: etags._c - $(COMPILE) -DCTAGS -c etags.c && mv etags._o ctags.o +false._o: true._c + $(COMPILE) -DEXIT_CODE=1 -c true.c && mv true._o false.o @end example As it turns out, there is also a much easier way to do this same task. Some of the above techniques are useful enough that we've kept the -example in the manual. However if you were to build @code{etags} and -@code{ctags} in real life, you would probably use per-program +example in the manual. However if you were to build @code{true} and +@code{false} in real life, you would probably use per-program compilation flags, like so: @example -bin_PROGRAMS = ctags etags +bin_PROGRAMS = false true -ctags_SOURCES = etags.c -ctags_CPPFLAGS = -DCTAGS +false_SOURCES = true.c +false_CPPFLAGS = -DEXIT_CODE=1 -etags_SOURCES = etags.c -etags_CPPFLAGS = -DETAGS_REGEXPS +true_SOURCES = true.c +true_CPPFLAGS = -DEXIT_CODE=0 @end example -In this case Automake will cause @file{etags.c} to be compiled twice, +In this case Automake will cause @file{true.c} to be compiled twice, with different flags. De-ANSI-fication will work automatically. In this instance, the names of the object files would be chosen by -automake; they would be @file{ctags-etags.o} and @file{etags-etags.o}. +automake; they would be @file{false-true.o} and @file{true-true.o}. (The name of the object files rarely matters.) @@ -1097,6 +1097,8 @@ easier. These macros can automatically be put into your * Requirements:: Configuration requirements * Optional:: Other things Automake recognizes * Invoking aclocal:: Auto-generating aclocal.m4 +* aclocal options:: aclocal command line arguments +* Macro search path:: Modifying aclocal's search path * Macros:: Autoconf macros supplied with Automake * Extending aclocal:: Writing your own aclocal macros @end menu @@ -1283,7 +1285,7 @@ generated @file{Makefile.in}s. This macro defines the @end table -@node Invoking aclocal, Macros, Optional, configure +@node Invoking aclocal, aclocal options, Optional, configure @section Auto-generating aclocal.m4 @cindex Invoking aclocal @@ -1322,7 +1324,7 @@ comment which will be completely ignored by @code{aclocal}, use * Macro search path:: How aclocal finds .m4 files @end menu -@node aclocal options, Macro search path, Invoking aclocal, Invoking aclocal +@node aclocal options, Macro search path, Invoking aclocal, configure @section aclocal options @cindex aclocal, Options @@ -1365,7 +1367,7 @@ Print the names of the files it examines. Print the version number of Automake and exit. @end table -@node Macro search path, , aclocal options, Invoking aclocal +@node Macro search path, Macros, aclocal options, configure @section Macro search path @cindex Macro search path @@ -1507,7 +1509,7 @@ Similarly, @file{dirlist} can be handy if you have installed a local copy Automake on your account and want @command{aclocal} to look for macros installed at other places on the system. -@node Macros, Extending aclocal, Invoking aclocal, configure +@node Macros, Extending aclocal, Macro search path, configure @section Autoconf macros supplied with Automake Automake ships with several Autoconf macros that you can use from your diff --git a/stamp-vti b/stamp-vti index 5a2ac1ffa..a3d36bbdf 100644 --- a/stamp-vti +++ b/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 9 September 2002 +@set UPDATED 13 September 2002 @set UPDATED-MONTH September 2002 @set EDITION 1.6c @set VERSION 1.6c diff --git a/tests/Makefile.am b/tests/Makefile.am index 869b12b3f..8d0d46708 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -380,6 +380,7 @@ tags.test \ tagsub.test \ target.test \ target-cflags.test \ +targetclash.test \ texinfo.test \ texinfo2.test \ texinfo3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 9d161cb40..7566afee5 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -472,6 +472,7 @@ tags.test \ tagsub.test \ target.test \ target-cflags.test \ +targetclash.test \ texinfo.test \ texinfo2.test \ texinfo3.test \ @@ -523,7 +524,7 @@ subdir = tests mkinstalldirs = $(SHELL) $(top_srcdir)/lib/mkinstalldirs CONFIG_CLEAN_FILES = defs DIST_SOURCES = -DIST_COMMON = Makefile.am Makefile.in configure.in defs.in +DIST_COMMON = Makefile.am Makefile.in defs.in all: all-am .SUFFIXES: diff --git a/tests/specflags7.test b/tests/specflags7.test index 7cd85b2a1..558d65ce2 100755 --- a/tests/specflags7.test +++ b/tests/specflags7.test @@ -18,7 +18,7 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. -# The ctags/etags example from the manual, plus a check for _SHORTNAME. +# The true/false example from the manual, plus a check for _SHORTNAME. required=gcc . ./defs || exit 1 @@ -31,24 +31,24 @@ AC_OUTPUT END cat > Makefile.am << 'END' -bin_PROGRAMS = etags ctags -ctags_SOURCES = etags.c -ctags_CFLAGS = -DCTAGS -ctags_SHORTNAME = c -# No etags_SOURCES definition. Use the default source. -etags_CFLAGS = -DETAGS -etags_SHORTNAME = e +bin_PROGRAMS = false true +true_SOURCES = false.c +true_CFLAGS = -DTRUE +true_SHORTNAME = t +# No false_SOURCES definition. Use the default source. +false_CFLAGS = -DFALSE +false_SHORTNAME = f END -cat > etags.c << 'END' +cat > false.c << 'END' #include int main (int argc, char *argv[]) { -#ifdef CTAGS - puts ("ctags"); +#ifdef TRUE + puts ("true"); #else - puts ("etags"); + puts ("false"); #endif return 0; } @@ -60,7 +60,7 @@ $AUTOMAKE -a ./configure $MAKE -./ctags | grep ctags -./etags | grep etags -test -f ./c-etags.o -test -f ./e-etags.o +./true | grep true +./false | grep false +test -f ./t-false.o +test -f ./f-false.o diff --git a/tests/specflags8.test b/tests/specflags8.test index d2b74bde9..1d90fff31 100755 --- a/tests/specflags8.test +++ b/tests/specflags8.test @@ -18,7 +18,7 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. -# Like the ctags/etags example from the manual, +# Like the true/false example from the manual, # with one extra indirection in the sources (PR/315), and # use of _CPPFLAGS (PR/337). @@ -37,23 +37,23 @@ END # different flags. cat > Makefile.am << 'END' -ETAGSSOURCE = etags.c -bin_PROGRAMS = etags ctags -ctags_SOURCES = $(ETAGSSOURCE) -ctags_CPPFLAGS = -DCTAGS -etags_SOURCES = $(ETAGSSOURCE) -etags_CPPFLAGS = -DETAGS +FALSESOURCE = false.c +bin_PROGRAMS = false true +true_SOURCES = $(FALSESOURCE) +true_CPPFLAGS = -DTRUE +false_SOURCES = $(FALSESOURCE) +false_CPPFLAGS = -DFALSE END -cat > etags.c << 'END' +cat > false.c << 'END' #include int main (int argc, char *argv[]) { -#ifdef CTAGS - puts ("ctags"); +#ifdef TRUE + puts ("true"); #else - puts ("etags"); + puts ("false"); #endif return 0; } @@ -65,5 +65,5 @@ $AUTOMAKE -a ./configure $MAKE -./ctags | grep ctags -./etags | grep etags +./true | grep true +./false | grep false diff --git a/tests/targetclash.test b/tests/targetclash.test new file mode 100755 index 000000000..91ca5ef98 --- /dev/null +++ b/tests/targetclash.test @@ -0,0 +1,40 @@ +#! /bin/sh +# Copyright (C) 2002 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 autoconf; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Check that target clashes are diagnosed. + +required=gcc +. ./defs || exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +END + +cat > Makefile.am << 'END' +bin_PROGRAMS = ctags +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a 2>stderr && exit 1 +cat stderr +grep 'redefinition.*ctags' stderr diff --git a/version.texi b/version.texi index 5a2ac1ffa..a3d36bbdf 100644 --- a/version.texi +++ b/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 9 September 2002 +@set UPDATED 13 September 2002 @set UPDATED-MONTH September 2002 @set EDITION 1.6c @set VERSION 1.6c -- 2.47.2