summaryrefslogtreecommitdiff
path: root/t/tags-pr12372.sh
blob: 6a2088bce5e11a6f9718fa5280832a102953cad0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /bin/sh
# Copyright (C) 2012-2018 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 <https://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'
. test-init.sh

cat >> configure.ac <<'END'
AC_PROG_CC
AC_CONFIG_FILES([sub/Makefile])
# Fake linking.  Help avoid possible spurious errors from make
# or from the linker; errors that are irrelevant to this test.
AC_SUBST([LINK], ['echo $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@'])
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

noinst_PROGRAMS = foo
foo_SOURCES = foo-main.pc barbar.c
SUBDIRS = sub
END

mkdir sub
cat > sub/Makefile.am <<'END'
all-local: tags
.pc.o:
	sed -e 's/@/a/g' $(srcdir)/$*.pc >$*.c
	$(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $*.c
	rm -f $*.c

noinst_PROGRAMS = zap
zap_SOURCES = zardoz.pc
END

echo 'int main(void) [ return bar(1); ]' > foo-main.pc
echo 'int bar(int x) { return !x; }' > barbar.c
echo 'int m@in(void) { return 0; }' > sub/zardoz.pc

$ACLOCAL
$AUTOCONF
$AUTOMAKE

./configure

# Exuberant Ctags (at least version 5.8) doesn't generate any tags
# for file extensions it doesn't recognize.  This can be fixed by
# using the '--langmap' option.  But we must be careful, because
# etags from Emacs (at least version 23.4) doesn't recognize that
# option.
if etags --help | grep '.*--langmap'; then
  run_make ETAGSFLAGS="--langmap=c:+.pc"
else
  $MAKE
fi

cat TAGS
cat sub/TAGS
$FGREP foo-main.pc TAGS
$FGREP barbar.c TAGS
$FGREP zardoz.pc sub/TAGS

$MAKE distcheck

: