maint: Update HACKING
[automake.git] / t / tags-pr12372.sh
blob14ae78c5bb5bf454541f60f643f21c169af0ef3e
1 #! /bin/sh
2 # Copyright (C) 2012-2017 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Test to make sure tags are processed also for files with non-standard
18 # extensions. See automake bug#12372.
20 required='cc etags'
21 . test-init.sh
23 cat >> configure.ac <<'END'
24 AC_PROG_CC
25 AC_CONFIG_FILES([sub/Makefile])
26 # Fake linking. Help avoid possible spurious errors from make
27 # or from the linker; errors that are irrelevant to this test.
28 AC_SUBST([LINK], ['echo $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@'])
29 AC_OUTPUT
30 END
32 cat > Makefile.am <<'END'
33 all-local: tags
34 .pc.o:
35 sed -e 's/\[/{/' -e 's/\]/}/' $(srcdir)/$*.pc >$*.c
36 $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $*.c
37 rm -f $*.c
39 noinst_PROGRAMS = foo
40 foo_SOURCES = foo-main.pc barbar.c
41 SUBDIRS = sub
42 END
44 mkdir sub
45 cat > sub/Makefile.am <<'END'
46 all-local: tags
47 .pc.o:
48 sed -e 's/@/a/g' $(srcdir)/$*.pc >$*.c
49 $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $*.c
50 rm -f $*.c
52 noinst_PROGRAMS = zap
53 zap_SOURCES = zardoz.pc
54 END
56 echo 'int main(void) [ return bar(1); ]' > foo-main.pc
57 echo 'int bar(int x) { return !x; }' > barbar.c
58 echo 'int m@in(void) { return 0; }' > sub/zardoz.pc
60 $ACLOCAL
61 $AUTOCONF
62 $AUTOMAKE
64 ./configure
66 # Exuberant Ctags (at least version 5.8) doesn't generate any tags
67 # for file extensions it doesn't recognize. This can be fixed by
68 # using the '--langmap' option. But we must be careful, because
69 # etags from Emacs (at least version 23.4) doesn't recognize that
70 # option.
71 if etags --help | grep '.*--langmap'; then
72 run_make ETAGSFLAGS="--langmap=c:+.pc"
73 else
74 $MAKE
77 cat TAGS
78 cat sub/TAGS
79 $FGREP foo-main.pc TAGS
80 $FGREP barbar.c TAGS
81 $FGREP zardoz.pc sub/TAGS
83 $MAKE distcheck