Subject: bug#12372: arbitrary suffix sources are not added to the tags

From: Stefano Lattarini <[email-masked]>
Date: Fri, 07 Sep 2012 11:16:03 +0200

severity 12372 minor
close 12372
thanks

On 09/06/2012 05:11 PM, Юрий Пухальский wrote:
> So the .am file is like this:
> 
> .POSIX:
> 
> SUFFIXES = .pc
> 
> .pc.lo:
> 	cp $*.pc $*.c
> 	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile
> $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
> $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o $@ $*.c
> 	rm -f $*.c
> 
> CCLD = $(CC)
> LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
> 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
> 	$(LDFLAGS) -o $@
> 
> noinst_LTLIBRARIES=libfoo.la
> 
> libfoo_la_SOURCES=foo.pc bar.c
> 
> The libfoo_la_SOURCES are not added to the tags list and the tags
> goals are not generated:
>
I'm not able to reproduce this failure with the latest version of Automake
(1.12.4).  In fact ...

> excerpt from the Makefile.in
> ---------
> tags: TAGS
> TAGS:
> 
> ctags: CTAGS
> CTAGS:
> ---------
>
... in my case, the generated makefile reads:

  ctags: CTAGS
  CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
		$(TAGS_FILES) $(LISP)
	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
	unique=`for i in $$list; do \
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
	  done | \
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
	test -z "$(CTAGS_ARGS)$$unique" \
	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
	     $$unique

(and similarly for TAGS/tags), which is correct.

Anyway, I've added a new test case (see patch below) to check against this
bug, to ensure it won't surreptitiously represent itself.

In case the problem persists for you also with Autoamke 1.12.4, feel free
to re-open this ticket.

Thanks,
  Stefano

> Adding them to the TAGS_FILES explicitly (as Stefano had advised)
> doesn't help. It seems that it's being overridden.
> 
> ---------- Forwarded message ----------
> From: Юрий Пухальский <[email-masked]>
> Date: Mon, Jul 23, 2012 at 4:49 PM
> Subject: bug#7824: Automatic chaining of make suffix rules (was: Re:
> bug#7824: won't fix)
> To: Stefano Lattarini <[email-masked]>
> Cc: [email-masked], Automake List <[email-masked]>
> 
> 
> On Mon, Jul 23, 2012 at 4:42 PM, Stefano Lattarini
> <[email-masked]> wrote:
>> [Re-adding the list, as this discussion is worth being registered in
>> the archives IMHO]
>>
> Ok.
> 
>>>>> The situation is that both of the approaches (.pc.c rule and .pc.lo
>>>>> rule) have problems entailed.
>>>>
>>>>>  * .pc.lo rule doesn't create tags for *.pc sources.
>>>>>
>>>> Try to add the relevant '.pc' files to $(TAGS_FILES) explicitly.  It should
>>>> solve your issue.  If it doesn't, you've found a new Automake bug, which I
>>>> will gladly fix :-)
>>>
>>> Ah, ok! I knew there must be something like that.
>>> But why in the first place it doesn't do it automatically? I have it
>>> in the _SOURCES… Is it afraid of the .pc extension?
>>>
>> I'm not sure actually.  Might be a tiny bug in automake.  Care to open a
>> new report about the issue, so I won't forget?  I'll get to it eventually,
>> but not right now.
> 

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

>From 94b7b8ecd4bae85782b45a9bb36f42c4d2b93805 Mon Sep 17 00:00:00 2001
Message-Id: <94b7b8ecd[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Fri, 7 Sep 2012 10:42:42 +0200
Subject: [PATCH] coverage: expose automake bug#12372 (tags-related)

That bug is somehow already been fixed in the latest automake
version (1.12.4); but exercise it anyway in the testsuite, to
ensure we won't regress.

* t/tags-pr12372.sh: New test.
* t/list-of-tests.mk: Add it.

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 t/list-of-tests.mk |  1 +
 t/tags-pr12372.sh  | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100755 t/tags-pr12372.sh

diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 8e1093a..c20fead 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -1154,6 +1154,7 @@ t/tap-summary-color.sh \
 t/tags.sh \
 t/tags2.sh \
 t/tagsub.sh \
+t/tags-pr12372.sh \
 t/tar.sh \
 t/tar2.sh \
 t/tar3.sh \
diff --git a/t/tags-pr12372.sh b/t/tags-pr12372.sh
new file mode 100755
index 0000000..d46927e
--- /dev/null
+++ b/t/tags-pr12372.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Test to make sure tags are processed also for files with non-standard
+# extensions.  See automake bug#12372.
+
+required='cc etags'
+. ./defs || exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+all-local: tags
+.pc.o:
+	sed -e 's/\[/{/' -e 's/\]/}/' $(srcdir)/$*.pc >$*.c
+	$(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $*.c
+	rm -f $*.c
+
+LINK = $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@
+noinst_PROGRAMS = foo
+foo_SOURCES = foo-main.pc barbar.c
+END
+
+echo 'int main(void) [ return bar(1); ]' > foo-main.pc
+echo 'int bar(int x) { return !x; }' > barbar.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE
+cat TAGS
+$FGREP foo-main.pc TAGS
+$FGREP barbar.c TAGS
+
+$MAKE distcheck
+
+:
-- 
1.7.12