From 1896ef8419a2d9e222e0467e42b3792a9983fc14 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 10 Jul 2002 05:36:46 +0000 Subject: [PATCH] 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'. --- ChangeLog | 8 ++++++++ automake.in | 16 +++++++++++++++- automake.texi | 6 ++++++ lib/am/tags.am | 35 +++++++++++++++++++++++++++++++++-- 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa0b212..81663d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2002-07-09 Tom Tromey + 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% diff --git a/automake.in b/automake.in index 7a1af9b..753e9a1 100755 --- a/automake.in +++ b/automake.in @@ -3720,6 +3720,7 @@ sub handle_data sub handle_tags { my @tag_deps = (); + my @ctag_deps = (); if (variable_defined ('SUBDIRS')) { $output_rules .= ("tags-recursive:\n" @@ -3731,6 +3732,16 @@ sub handle_tags . "\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) @@ -3751,7 +3762,8 @@ sub handle_tags } $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', @@ -3765,6 +3777,8 @@ sub handle_tags # 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"; } } diff --git a/automake.texi b/automake.texi index 06c355a..9990aad 100644 --- a/automake.texi +++ b/automake.texi @@ -4323,6 +4323,12 @@ want to set @samp{TAGS_DEPENDENCIES}. The contents of this variable 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. diff --git a/lib/am/tags.am b/lib/am/tags.am index f961a18..b34641d 100644 --- a/lib/am/tags.am +++ b/lib/am/tags.am @@ -44,7 +44,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) ETAGS = etags ETAGSFLAGS = -TAGS: %DIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \ +TAGS: %TAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ @@ -70,6 +70,37 @@ TAGS: %DIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \ $$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. ## ## --------------- ## @@ -88,4 +119,4 @@ GTAGS: .PHONY distclean-am: distclean-tags distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -- 2.7.4