* automake.texi (Tags): Document ctags.
* automake.in (handle_tags): Handle ctags.
* lib/am/tags.am (CTAGS): New macro.
(CTAGSFLAGS): Likewise.
(ctags): New target.
(distclean-tags): Remove `tags'.
2002-07-09 Tom Tromey <tromey@redhat.com>
+ For PR automake/286:
+ * automake.texi (Tags): Document ctags.
+ * automake.in (handle_tags): Handle ctags.
+ * lib/am/tags.am (CTAGS): New macro.
+ (CTAGSFLAGS): Likewise.
+ (ctags): New target.
+ (distclean-tags): Remove `tags'.
+
* lib/am/depend2.am: Reworked syntax to avoid parsing problem.
* lib/am/depend2.am: Search in srcdir and builddir for %SOURCE%
sub handle_tags
{
my @tag_deps = ();
+ my @ctag_deps = ();
if (variable_defined ('SUBDIRS'))
{
$output_rules .= ("tags-recursive:\n"
. "\tdone\n");
push (@tag_deps, 'tags-recursive');
&depend ('.PHONY', 'tags-recursive');
+
+ $output_rules .= ("ctags-recursive:\n"
+ . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
+ # Never fail here if a subdir fails; it
+ # isn't important.
+ . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
+ . " && \$(MAKE) \$(AM_MAKEFLAGS) ctags); \\\n"
+ . "\tdone\n");
+ push (@ctag_deps, 'ctags-recursive');
+ &depend ('.PHONY', 'ctags-recursive');
}
if (&saw_sources_p (1)
}
$output_rules .= &file_contents ('tags',
('CONFIG' => "@config",
- 'DIRS' => "@tag_deps"));
+ 'TAGSDIRS' => "@tag_deps",
+ 'CTAGSDIRS' => "@ctag_deps"));
&examine_variable ('TAGS_DEPENDENCIES');
}
elsif (reject_var ('TAGS_DEPENDENCIES',
# Otherwise, it would be possible for a top-level "make TAGS"
# to fail because some subdirectory failed.
$output_rules .= "tags: TAGS\nTAGS:\n\n";
+ # Ditto ctags.
+ $output_rules .= "ctags: CTAGS\nCTAGS:\n\n";
}
}
are added directly to the dependencies for the @code{tags} target.
@vindex TAGS_DEPENDENCIES
+Automake also generates a @code{ctags} target which can be used to
+build @command{vi}-style @file{tags} files. The variable @code{CTAGS}
+is the name of the program to invoke (by default @samp{ctags});
+@code{CTAGSFLAGS} can be used by the user to pass additional flags,
+and @code{AM_CTAGSFLAGS} can be used by the @file{Makefile.am}.
+
Automake will also generate an @code{ID} target which will run
@code{mkid} on the source. This is only supported on a
directory-by-directory basis.
ETAGS = etags
ETAGSFLAGS =
-TAGS: %DIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
+TAGS: %TAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
$$tags $$unique
+## ------------- ##
+## vi-style tags ##
+## ------------- ##
+
+CTAGS = ctags
+CTAGSFLAGS =
+
+.PHONY: CTAGS ctags
+ctags: CTAGS
+
+## We have a dummy name here because `tags' has already been in use
+## for a long time to mean Emacs-style tags. Oops. This means the
+## dependencies here are useless.
+CTAGS: %CTAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+## Make sure the list of sources is unique.
+ list='$(SOURCES) $(HEADERS) %CONFIG% $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+## Handle VPATH correctly.
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+## Make sure we have something to run ctags on.
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+
## --------------- ##
## `Global' tags. ##
## --------------- ##
.PHONY distclean-am: distclean-tags
distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags