#! /bin/sh
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# Copyright (C) 2012-2013 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
# extensions. See automake bug#12372.
required='cc etags'
-. ./defs || exit 1
+. 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
$(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $*.c
rm -f $*.c
-LINK = $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@
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
./configure
-$MAKE
+# 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