bug-automake
[Top][All Lists]
Advanced

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

Re: even `if FALSE' *_SOURCES should be used for TAGS


From: Stefano Lattarini
Subject: Re: even `if FALSE' *_SOURCES should be used for TAGS
Date: Thu, 14 Oct 2010 14:31:54 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

On Wednesday 13 October 2010, Ralf Wildenhues wrote:
> Hi Stefano,
Hi Ralf.  Attached is an amended patch (still basically only defining
new tests, but with some tweaks to `automake.in' too).
 
> * Stefano Lattarini wrote on Wed, Oct 13, 2010 at 03:54:31PM CEST:
> > On Tuesday 12 October 2010, Ralf Wildenhues wrote:
> > > * Stefano Lattarini wrote on Tue, Oct 12, 2010 at 05:51:58PM CEST:
> > > > > OTOH AM_CONDITIONAL can be used for example if an optional sources 
> > > > > part is
> > > > > / is not bundled, in such case the current automake behavior is 
> > > > > better.
> > > 
> > > > Ralf, do you agree we should implement the behaviour requested by Jan?
> > > 
> > > Well, I see the following caveat:
> > > 
> > > 'make tags' shouldn't cause files to be built (or accessed) that 'make
> > > dist' wouldn't build; that probably means conditional nodist_ files
> > > shouldn't be tagged.
> 
> > I disagree; non-distributed but unconditonally-defined sources should be
> > tagged IMHO (even if they are Makefile-generated), as should distributed
> > but conditionally-defined sources.
> 
> Your statement doesn't conflict with my statement, as far as I can see.
> Is there a typo somewhere, or are we misreading each other?
It's probably me who's misreading you; thanks for your clarifications below.

> Maybe it helps to clarify my statement by reformulating as follows:
> 
>   'make tags' shouldn't cause files to be built (or accessed) that 'make
>   dist' wouldn't build (apart from files created by 'make all' already);
>   that probably means conditional nodist_ files shouldn't be tagged.
Exactly what I meant (but explained in a clearer and more concise way).
BTW, this might make a nice addition for the automake manual.
 
> The thing that needs to be avoided is that `make tags' tries to run
> the generator in the setting below if the generator is not present:
> 
> if HAVE_GENERATOR
> nodist_foo_SOURCES += file.c
> file.c:
>         generator > $@
> endif
> 
> However, the other question to consider is that with generators, users
> might not want the generated files to be tagged, rather than the source:
> Good examples are yacc or lex files, where the .y and .l files should be
> tagged but the generated .c files shouldn't.
Hmpf, I didn't think of that.

> I'm not sure how to solve that easily except by some new structure
> information in the Language struct.
BTW, would a new couple of prefixes `tag'/`notag' help here?  Or a new
variable `EXCLUDE_TAGS_FILES'?
 
> > This is also more consistent with the current automake documentation:
> >   ``If any C, C++ or Fortran 77 source code or headers are present, then
> >     tags and TAGS rules will be generated for the directory.  All files
> >     listed using the _SOURCES, _HEADERS, and _LISP primaries will be used
> >     to generate tags.  Note that generated source files that are not
> >     distributed must be declared in variables like nodist_noinst_HEADERS
> >     or nodist_prog_SOURCES or they will be ignored.''
> 
> I'm hoping this is also moot if above is cleared up.  :-)
Yes, definitely.
 
> > Only non-distributed conditionally-defined sources should not be tagged
> > by default (but should be when listed in some EXTRA_*_SOURCES, or when
> > the condition they are defined into happens to be true).
> 
> I agree to this with:  s/when listed in some EXTRA_*_SOURCES, or //
> Otherwise again the above caveat applies.
True; and after all, the variable TAGS_FILE can always come to the rescue...
but I see it's still undocumented; should we document it?  And since we are
at it, could we give it a better name, like `EXTRA_TAGS_FILES'?
 
> FYI, the EXTRA_foo_SOURCES listing is necessary so automake can add a
> dependency file for these; it doesn't state whether the source can be
> generated or not.
Tanks for the explanations; let's drop the `EXTRA_*_SOURCES' then.

> > > OTOH, automake.in:handle_source_transform is the only place where
> > > @sources and @dist_sources get possibly different values, and I don't
> > > understand why that was done; IOW, why the implementation didn't just
> > > have $(SOURCES) = $(DIST_SOURCES)  (except for the possibility of the
> > > no-dist option, of course).
> 
> > Maybe to take into account the possibility of having non-distributed,
> > Makefile-generated and unconditonally-defined sources -- for which tags
> > should be enabled, even if they are not distributed.  This is just a
> > guess of mine, though, as I've done no history digging.
> 
> Good point.
Thanks.
 
> > As an aside, I see that the testsuite coverage on tags functionality
> > is *extremely* lacking and inadequate, and I'd really like to extend
> > it; so I seize this opportunity to repropose my idea of a new
> > "tests-extend" topic branch dedicated to testsuite enhancement
> > and extension.
> 
> I haven't dismissed the idea of such a topic branch.  I do think that
> testsuite additions for 'tags' functionality would better fit on a
> branch that deals with 'tags' functionality: topics related to
> features seem more fitting than topics related to source code subdirs.
I agree on this; and maybe a new "tags" branch could also absorb the
oldish obsolescent "dr-cscope" branch...
 
> > Subject: [PATCH] New tests; add TODO comment to automake.in
> 
> > --- a/automake.in
> > +++ b/automake.in
> > @@ -2208,6 +2208,10 @@ sub handle_source_transform ($$$$%)
> >     $used_pfx{$xpfx} = 1
> >       unless $prefix =~ /EXTRA_/;
> >  
> > +   # FIXME: $varname should be added to @sources iff:
> > +        #   1. it is unconditionally defined, or
> > +        #   2. it is in EXTRA_DIST, or
> > +        #   3. it is distributed
> 
> (2) is redundant with (3), no?
Sorry, I meant `EXTRA_*_SOURCES' here; but this is moot now, and (2)
should become "is in $(EXTRA_TAGS_FILES)" (fixed in the attached
patch).
 
> Ah, interesting tangent here: Ben reported a while ago that conditional
> EXTRA_DIST distributes conditionally.  I had very much grown accustomed
> to this behavior, but it is at odds with the way conditionals work
> otherwise.  OTOH, user setups will break if we change the current
> functionality.
> 
> Anyway, rather than committing the FIXME patch let's fix it.  ;-)
Well, the previous patch (like the current one BTW) was not meant to
be applied, just to be discussed ;-)

> 
> >     push @sources, "\$($varname)";
> >     push @dist_sources, shadow_unconditionally ($varname, $where)
> >       unless (option ('no-dist') || $prefix =~ /^nodist_/);
> 
> > --- /dev/null
> > +++ b/tests/tagscond.test
> > @@ -0,0 +1,117 @@
> 
> > +# Check that tags for conditionally defined (but distributed)
> > +# sources work.
> 
> This test looks sensible to me (with nits below).
> 
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +cat >> configure.in <<'END'
> > +AC_PROG_CC
> > +AM_PATH_LISPDIR
> > +AM_CONDITIONAL([COND], [test x"$cond" = x"yes"])
> > +AC_OUTPUT
> > +END
> > +
> > +cat > Makefile.am <<'END'
> > +bin_PROGRAMS = foo bar
> > +foo_SOURCES = main.c
> > +if COND
> > +  foo_SOURCES += foo1.c
> > +  bar_SOURCES = main.c bar.h
> > +  include_HEADERS = quux.h
> > +  lisp_LISP = joe.el
> > +else
> > +  foo_SOURCES += foo2.c
> > +  bar_SOURCES = main.c baz.h
> > +  include_HEADERS = zardoz.h
> > +  lisp_LISP = moe.el
> 
> I always cringe if the text in conditionals is indented: makefile
> parsing is fragile, automake isn't perfect, and it misreads
> space-indented rules.
I indentend it because there are no rules here, only variable
definitions; but since you think they could cause problems too,
I'll remove the indentation -- better err on the side of caution.
> For that reason I tend to avoid it fully (we might want to fix it
> but that's a different issue entirely and also one that breaks
> real-world setups and should be kept orthogonal to this).
Agreed.
 
> (automake also misparses non-TAB-indented continuations of rule recipes;
> this is another limitation over Posix, but I think it might be shared by
> some older makes also.)
> 
> > +endif
> > +
> > +quux.h zardoz.h:
> > +   : > $@
> 
> Unfortunately, automake also doesn't correctly analyze
> 
>   target1 target2:
> 
> which is something we should probably fix but which some users might
> also have come to rely on.
Ouch.  But this should not be an issue here I think, since automake
should not be interested *at all* in the fact that `quux.h' and
`zardoz.h' are automatically generated at make time.  Right?
In fact, I've amended the test to *make sure* that automake doesn't
analyze `quux.h' and `zardoz.h' targets.  Everyhing should still work
nonetheless.

> > +CLEANFILES = quux.h zardoz.h
> > +
> > +exp.list:
> > +   (case $(srcdir) in .) d=;; *) d=$(srcdir)/;; esac \
> > +     && echo $${d}bar.h \
> > +     && echo $${d}baz.h \
> > +          && echo $${d}foo1.c \
> > +          && echo $${d}foo2.c \
> > +          && echo $${d}main.c \
> > +     && echo $${d}quux.h \
> > +     && echo $${d}zardoz.h \
> > +     && echo $${d}joe.el \
> > +     && echo $${d}moe.el \
> > +        ) > $@
> 
> Let's use { ...; } > $@ for the outer redirection so the unbalanced
> parentheses don't hurt the eye (and editor syntax highlighting) so much.
OK.

> > +MOSTLYCLEANFILES = exp.list
> > +
> > +.PHONY: test
> > +test: exp.list ID TAGS CTAGS
> > +   diff exp.list TAGS
> > +   diff exp.list tags
> > +   diff exp.list ID
> > +
> > +check-local: test
> > +END
> > +
> > +echo 'int main(void) { return 0; }' > main.c
> > +echo 'extern int i;' > foo1.c
> > +echo 'extern int j;' > foo2.c
> > +: > bar.h
> > +: > baz.h
> > +
> > +: > elisp-comp
> > +
> > +mkdir bin
> > +cat > bin/etags <<'END'
> > +#!/bin/sh
> > +for i in ${1+"$@"}; do echo "$i"; done | sort > TAGS
> 
> Using the ${1+"$@"} idiom requires sanitization for zsh.
Even when zsh is called as /bin/sh?
> OTOH, if you
> can rely on the set of positional parameters to be nonempty you can just
> use "$@" which requires no sanitization.  With a for loop, things are
> easier even: you can just use
>   for i
>   do
>     ...
>   done
> 
> (the newline before 'do' is intentional; see autoconf.info).
> Also below in ctags.
Will fix following your suggestion.
 
> You need to sanitize the locale to C when sorting, if only to stabilize
> sorting in case-ignoring collation.  Several instances.
Good catch.  Will do.

> > +END
> > +cat > bin/ctags <<'END'
> > +#!/bin/sh
> > +for i in ${1+"$@"}; do echo "$i"; done | sort > tags
> > +END
> > +cat > bin/mkid <<'END'
> > +#!/bin/sh
> > +case $1 in
> > +  -f*) out=`expr "x$1" : 'x-f\(.*\)'`; shift;;
> > +    *) out=ID;;
> > +esac
> > +for i in ${1+"$@"}; do echo "$i"; done | sort > "$out"
> > +END
> > +chmod a+x bin/etags bin/ctags bin/mkid
> > +PATH=`pwd`/bin$PATH_SEPARATOR$PATH
> > +
> > +$ACLOCAL
> > +$AUTOCONF
> > +$AUTOMAKE
> > +
> > +for cond in yes no; do
> > +  case $cond in
> > +    yes) anticond=no;;
> > +     no) anticond=yes;;
> > +  esac
> > +  ./configure cond="$cond" EMACS=no
> > +  $MAKE test
> > +  $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="cond='$cond' EMACS=no"
> > +  $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="cond='$anticond' EMACS=no"
> > +  $MAKE distclean
> > +done
> > +
> > +:
> 
> > --- /dev/null
> > +++ b/tests/tagsextra.test
> > @@ -0,0 +1,70 @@
> 
> > +# Check interaction of EXTRA_SOURCES with tags.
> 
> Please reevaluate this test given the reasoning above.
Maybe this should be converted in a test for TAGS_FILES or EXTRA_TAGS_FILES.
I've gone for the latter in the attached patch.

> Also, can we name the thingy EXTRA_*_SOURCES so it is clear that it is
> not literal (several instances)?
Moot now.

> Thanks.
> 
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +cat >> configure.in <<'END'
> > +AM_CONDITIONAL([COND], [false])
> > +AC_PROG_CC
> > +AC_OUTPUT
> > +END
> > +
> > +cat > Makefile.am <<'END'
> > +bin_PROGRAMS = foo
> > +foo_SOURCES = main.c
> > +if COND
> > +nodist_foo_SOURCES = bad.c
> > +endif
> > +EXTRA_foo_SOURCES = bad.c
> > +bad.c:
> > +## this file should never be compiled, so make its content invalid C
> > +   echo '/* %{~GREP~ME~}% */ choke me' > $@
> > +END
> > +
> > +echo 'int main(void) { return 0; }' > main.c
> > +
> > +mkdir bin
> > +for p in etags ctags mkid; do
> > +  (echo '#!/bin/sh' && echo 'exit 0') > bin/$p
> > +  chmod a+x bin/$p
> > +done
> > +PATH=`pwd`/bin$PATH_SEPARATOR$PATH
> > +
> > +$ACLOCAL
> > +$AUTOCONF
> > +$AUTOMAKE
> > +
> > +./configure
> > +
> > +for target in ID ctags CTAGS tags TAGS; do
> > +  rm -f bad.c
> > +  $MAKE $target
> > +  $FGREP '%{~GREP~ME~}%' bad.c
> > +done
> > +
> > +$MAKE
> > +./foo
> > +
> > +$MAKE distdir
> > +test ! -r $me-1.0/bar.c
> > +
> > +$MAKE distcheck
> > +
> > +:
> 
> > --- /dev/null
> > +++ b/tests/tagsnodist.test
> 
> > +# Check that "make TAGS" and similar do not try to create
> > +# non-distributed files used only in "false" conditionals.
> 
> This test looks ok to me, with nits below.
>
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +cat >> configure.in <<'END'
> > +AM_CONDITIONAL([COND_OK], [:])
> > +AM_CONDITIONAL([COND_KO], [false])
> > +AC_PROG_CC
> > +AC_OUTPUT
> > +END
> > +
> > +cat > Makefile.am <<'END'
> > +bin_PROGRAMS = foo
> > +foo_SOURCES = main.c
> > +
> > +if COND_OK
> > +## conditionally defined, but distributed: it will be considered
> > +## for tags, even if it's not listed in EXTRA_SOURCES.
> > +foo_SOURCES += bar.c
> > +## non-distributed and conditionally defined: but it will be considered
> > +## for tags, since the conditional COND_OK heppens to be true.
> 
> happens
Fixed.
 
> > +nodist_foo_SOURCES = baz.c
> > +else
> > +## non-distributed and conditionally defined: it won't be considered
> > +## for tags, since it's not listed in EXTRA_SOURCES and it's in the
> > +## `else' branch of the conditional COND_OK, which happens to be true.
> 
> Please reevaluate this comment and the next one as per above.
Agreed.
 
> > +nodist_foo_SOURCES = quux.c
> > +endif
> > +
> > +if COND_KO
> > +## non-distributed and conditionally defined: won't be considered
> > +## for tags, since it's not listed in EXTRA_SOURCES and the conditional
> > +## COND_KO happensto be false.
> 
> happens to
Fixed.

> > +nodist_foo_SOURCES += zardoz.c
> > +endif
> > +
> > +bar.c:
> > +   echo 'int bar(void) { return 0; }' > $@
> > +baz.c:
> > +   echo 'int baz(void) { return 1; }' > $@
I've obfuscated these too.
> > +CLEANFILES = bar.c baz.c
> > +
> > +quux.c zardoz.c:
> 
> See above.
Should not be a problem here either.
 
> > +   @echo 'ERROR: $@ should never be crated' >&2; exit 1
> > +END
> > +
> > +cat > main.c <<'END'
> > +int main(void)
> > +{
> > +  int bar(void);
> > +  int baz(void);
> > +  return bar() * baz();
> > +}
> > +END
> > +
> > +mkdir bin
> > +for p in etags ctags mkid; do
> > +  (echo '#!/bin/sh' && echo 'exit 0') > bin/$p
> > +  chmod a+x bin/$p
> > +done
> > +PATH=`pwd`/bin$PATH_SEPARATOR$PATH
> > +
> > +$ACLOCAL
> > +$AUTOCONF
> > +$AUTOMAKE
> > +
> > +./configure
> > +
> > +for target in ID ctags CTAGS tags TAGS; do
> > +  $MAKE $target
> > +  test -f bar.c
> > +  test -f baz.c
> > +  test ! -r quux.c
> > +  test ! -r zardoz.c
> > +  rm -f bar.c baz.c
> > +done
> > +
> > +$MAKE
> > +./foo
> 
> I prefer to avoid executing compiled programs if executability is not
> the primary purpose of the test.  Rationale is that it breaks cross
> compile setups (we don't really support those setups in the testsuite
> yet but I have pending patches to fix that), and it breaks for example
> when you have wine installed on GNU/Linux and the binfmt_misc module in
> place, and need to specify the .exe extension so the file is found.
> 
> Most actual issues can be solved by causing link failures in the
> unwanted cases.  If not, then it's still easier to use TESTS and 'make
> check', or run ./foo$(EXEEXT) from within the Makefile.
All good points; I'll fix it.
> Another instance below.
And that too.

> > +$MAKE distcheck
> > +$MAKE clean
> > +rm -f ID *tags* *TAGS* # just to be sure
> > +
> > +# Try again, with no-dist option.
> > +
> > +echo 'AUTOMAKE_OPTIONS = no-dist' >> Makefile.am
> > +$AUTOMAKE Makefile
> > +
> > +./config.status Makefile
> > +
> > +test ! -r bar.c # sanity check
> > +test ! -r baz.c # likewise
> > +for target in ID ctags CTAGS tags TAGS; do
> > +  $MAKE $target
> > +  test -f bar.c
> > +  test -f baz.c
> > +  test ! -r quux.c
> > +  test ! -r zardoz.c
> > +  rm -f bar.c baz.c
> > +done
> > +
> > +$MAKE
> > +./foo
> > +
> > +$MAKE distdir && Exit 1 # sanity check
> > +
> > +:
> 
> Thanks,
> Ralf
> 

Thanks for the review,
  Stefano
From fb6d965844e037b9149a35f1640da0ad516a26ca Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Wed, 13 Oct 2010 15:46:11 +0200
Subject: [PATCH] New tests & automake.in tweakings

---
 automake.in           |   16 ++++--
 tests/tagscond.test   |  132 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/tagsextra.test  |  127 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/tagsnodist.test |  128 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 398 insertions(+), 5 deletions(-)
 create mode 100755 tests/tagscond.test
 create mode 100755 tests/tagsextra.test
 create mode 100755 tests/tagsnodist.test

diff --git a/automake.in b/automake.in
index 6b36ae2..902fbac 100755
--- a/automake.in
+++ b/automake.in
@@ -542,7 +542,7 @@ my %compile_clean_files;
 my %libtool_clean_directories;
 
 # Value of `$(SOURCES)', used by tags.am.
-my @sources;
+my @tags_sources;
 # Sources which go in the distribution.
 my @dist_sources;
 
@@ -690,7 +690,7 @@ sub initialize_per_input ()
     # We always include `.'.  This isn't strictly correct.
     %libtool_clean_directories = ('.' => 1);
 
-    @sources = ();
+    @tags_sources = ();
     @dist_sources = ();
 
     %object_map = ();
@@ -2208,7 +2208,13 @@ sub handle_source_transform ($$$$%)
        $used_pfx{$xpfx} = 1
          unless $prefix =~ /EXTRA_/;
 
-       push @sources, "\$($varname)";
+       # FIXME: $varname should be added to @tags_sources iff:
+        #   1. it is unconditionally defined, or
+        #   2. it is in $(EXTRA_TAGS_FILES), or
+        #   3. it is distributed
+        # Since $(EXTRA_TAGS_FILES) is already dealt with in tags.am,
+        # we only need to worry about (1) and (3).
+       push @tags_sources, "\$($varname)";
        push @dist_sources, shadow_unconditionally ($varname, $where)
          unless (option ('no-dist') || $prefix =~ /^nodist_/);
 
@@ -2262,7 +2268,7 @@ sub handle_source_transform ($$$$%)
          }
 
        &define_variable ($one_file . "_SOURCES", $default_source, $where);
-       push (@sources, $default_source);
+       push (@tags_sources, $default_source);
        push (@dist_sources, $default_source);
 
        %linkers_used = ();
@@ -8193,7 +8199,7 @@ sub generate_makefile ($$)
   handle_libtool;
 
   # Variables used by distdir.am and tags.am.
-  define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources);
+  define_pretty_variable ('SOURCES', TRUE, INTERNAL, @tags_sources);
   if (! option 'no-dist')
     {
       define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources);
diff --git a/tests/tagscond.test b/tests/tagscond.test
new file mode 100755
index 0000000..2083294
--- /dev/null
+++ b/tests/tagscond.test
@@ -0,0 +1,132 @@
+#! /bin/sh
+# Copyright (C) 2010 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 2, 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 <http://www.gnu.org/licenses/>.
+
+# Check that tags for conditionally defined (but distributed)
+# sources work.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AM_PATH_LISPDIR
+AM_CONDITIONAL([COND], [test x"$cond" = x"yes"])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = main.c
+if COND
+foo_SOURCES += foo1.c
+bar_SOURCES = main.c bar.h
+include_HEADERS = quux.h
+lisp_LISP = joe.el
+else !COND
+foo_SOURCES += foo2.c
+bar_SOURCES = main.c baz.h
+include_HEADERS = zardoz.h
+lisp_LISP = moe.el
+endif !COND
+
+## It shouldn't matter if automake does not recognize and parse these
+## targets, so obfuscate them.  Everything should still work correctly.
+empty =
+h_ext = .h
+dummy1 q$(empty)uu$(empty)x.h zardoz$(h_ext) dummy2:
+       : > $@
+CLEANFILES = quux.h zardoz.h
+
+exp.list:
+## the leading `:;' works around a bug in bash <= 3.2
+       :; { \
+         case $(srcdir) in .) d=;; *) d=$(srcdir)/;; esac \
+           && echo $${d}bar.h \
+           && echo $${d}baz.h \
+           && echo $${d}foo1.c \
+           && echo $${d}foo2.c \
+           && echo $${d}main.c \
+           && echo $${d}quux.h \
+           && echo $${d}zardoz.h \
+           && echo $${d}joe.el \
+           && echo $${d}moe.el \
+       :; } > $@
+MOSTLYCLEANFILES = exp.list
+
+.PHONY: test
+test: exp.list ID TAGS CTAGS
+       diff exp.list TAGS
+       diff exp.list tags
+       diff exp.list ID
+
+check-local: test
+END
+
+echo 'int main(void) { return 0; }' > main.c
+echo 'extern int i;' > foo1.c
+echo 'extern int j;' > foo2.c
+: > bar.h
+: > baz.h
+
+: > elisp-comp
+
+mkdir bin
+cat > bin/etags <<'END'
+#!/bin/sh
+for i
+do
+  echo "$i"
+done | LC_ALL=C sort > TAGS
+END
+cat > bin/ctags <<'END'
+#!/bin/sh
+for i
+do
+  echo "$i"
+done | LC_ALL=C sort > tags
+END
+cat > bin/mkid <<'END'
+#!/bin/sh
+case $1 in
+  -f*) out=`expr "x$1" : 'x-f\(.*\)'`; shift;;
+    *) out=ID;;
+esac
+for i
+do
+  echo "$i"
+done | LC_ALL=C sort > "$out"
+END
+chmod a+x bin/etags bin/ctags bin/mkid
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for cond in yes no; do
+  case $cond in
+    yes) anticond=no;;
+     no) anticond=yes;;
+  esac
+  ./configure cond="$cond" EMACS=no
+  $MAKE test
+  $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="cond='$cond' EMACS=no"
+  $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="cond='$anticond' EMACS=no"
+  $MAKE distclean
+done
+
+:
diff --git a/tests/tagsextra.test b/tests/tagsextra.test
new file mode 100755
index 0000000..4bb2c73
--- /dev/null
+++ b/tests/tagsextra.test
@@ -0,0 +1,127 @@
+#! /bin/sh
+# Copyright (C) 2010 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 2, 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 <http://www.gnu.org/licenses/>.
+
+# Check that files listed in EXTRA_TAGS_FILES are considered for tags.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AM_CONDITIONAL([COND], [false])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = maude
+maude_SOURCES = main.c
+if COND
+nodist_maude_SOURCES = bad.c
+endif
+EXTRA_TAGS_FILES = bad.c dummy.foo dummy.bar
+bad.c:
+## this file should never be compiled, so make its content invalid C
+       echo '/* %{~GREP~ME~}% */ choke me' > $@
+dummy.bar:
+       echo '!DUMMY!BAR!' > $@
+END
+
+echo 'int main(void) { return 0; }' > main.c
+: > dummy.foo
+
+mkdir bin
+cat > bin/etags <<'END'
+#!/bin/sh
+for i
+do
+  echo "$i"
+done | LC_ALL=C sort > TAGS
+END
+cat > bin/ctags <<'END'
+#!/bin/sh
+for i
+do
+  echo "$i"
+done | LC_ALL=C sort > tags
+END
+cat > bin/mkid <<'END'
+#!/bin/sh
+case $1 in
+  -f*) out=`expr "x$1" : 'x-f\(.*\)'`; shift;;
+    *) out=ID;;
+esac
+for i
+do
+  echo "$i"
+done | LC_ALL=C sort > "$out"
+END
+chmod a+x bin/etags bin/ctags bin/mkid
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+
+  (sed 's|^\./||' | LC_ALL=C sort > exp.list) <<END
+$srcdir/main.c
+./bad.c
+$srcdir/dummy.foo
+./dummy.bar
+END
+
+  for target in ID ctags CTAGS tags TAGS; do
+    rm -f ID *TAGS* *tags* bad.c dummy.bar
+    $MAKE $target
+    ls -l # for debugging
+    $FGREP '%{~GREP~ME~}%' bad.c
+    $FGREP '!DUMMY!BAR!' dummy.bar
+    if $vpath; then
+      test ! -r main.c || Exit 1     # sanity check
+      test ! -r dummy.foo || Exit 1  # likewise
+    fi
+    case $target in #XXX
+      ID) file=ID;;
+      tags|TAGS) file=TAGS;;
+      ctags|CTAGS) file=tags;;
+      *) Exit 99;; # can't happen
+    esac
+    sed 's|^./||' $file > got.list
+    diff exp.list got.list
+  done
+
+  $MAKE
+  $MAKE distdir
+  test ! -r $me-1.0/bar.c
+  $MAKE distcheck
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/tagsnodist.test b/tests/tagsnodist.test
new file mode 100755
index 0000000..ad87c78
--- /dev/null
+++ b/tests/tagsnodist.test
@@ -0,0 +1,128 @@
+#! /bin/sh
+# Copyright (C) 2010 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 2, 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 <http://www.gnu.org/licenses/>.
+
+# Check that "make TAGS" and similar do not try to create
+# non-distributed files used only in "false" conditionals.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AM_CONDITIONAL([COND_OK], [:])
+AM_CONDITIONAL([COND_KO], [false])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = main.c
+
+if COND_OK
+## conditionally defined, but distributed: it will be considered
+## for tags, even if it's not listed in EXTRA_TAGS_FILES.
+foo_SOURCES += bar.c
+## non-distributed and conditionally defined: but it will be considered
+## for tags, since the conditional COND_OK happens to be true.
+nodist_foo_SOURCES = baz.c
+else
+## non-distributed and conditionally defined: it won't be considered
+## for tags, since it's not listed in EXTRA_TAGS_FILES and it's in the
+## `else' branch of the conditional COND_OK, which happens to be true.
+nodist_foo_SOURCES = quux.c
+endif
+
+if COND_KO
+## non-distributed and conditionally defined: won't be considered
+## for tags, since it's not listed in EXTRA_TAGS_FILES and the
+## conditional COND_KO happens to be false.
+nodist_foo_SOURCES += zardoz.c
+endif
+
+## It shouldn't matter if automake does not recognize and parse these
+## targets, so obfuscate them.  Everything should still work correctly.
+empty =
+c_ext = .c
+dummy1 $(empty)ba$(empty)r.c:
+       echo 'int bar(void) { return 0; }' > $@
+dummy2 baz$(c_ext):
+       echo 'int baz(void) { return 1; }' > $@
+CLEANFILES = bar.c baz.c
+
+quux.c zardoz.c:
+       @echo 'ERROR: $@ should never be crated' >&2; exit 1
+END
+
+cat > main.c <<'END'
+int main(void)
+{
+  int bar(void);
+  int baz(void);
+  return bar() * baz();
+}
+END
+
+mkdir bin
+for p in etags ctags mkid; do
+  (echo '#!/bin/sh' && echo 'exit 0') > bin/$p
+  chmod a+x bin/$p
+done
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+for target in ID ctags CTAGS tags TAGS; do
+  $MAKE $target
+  test -f bar.c
+  test -f baz.c
+  test ! -r quux.c
+  test ! -r zardoz.c
+  rm -f bar.c baz.c
+done
+
+$MAKE
+
+$MAKE distcheck
+$MAKE clean
+rm -f ID *tags* *TAGS* # just to be sure
+
+# Try again, with no-dist option.
+
+echo 'AUTOMAKE_OPTIONS = no-dist' >> Makefile.am
+$AUTOMAKE Makefile
+
+./config.status Makefile
+
+test ! -r bar.c # sanity check
+test ! -r baz.c # likewise
+for target in ID ctags CTAGS tags TAGS; do
+  $MAKE $target
+  test -f bar.c
+  test -f baz.c
+  test ! -r quux.c
+  test ! -r zardoz.c
+  rm -f bar.c baz.c
+done
+
+$MAKE
+$MAKE distdir && Exit 1 # sanity check
+
+:
-- 
1.7.1


reply via email to

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