On Wednesday, July 14, 2004 4:56 pm, Jesse Barnes wrote:
> On Wednesday, July 14, 2004 4:40 pm, Bob Friesenhahn wrote:
> > It should be no different than other recursive Automake rules (e.g.
> > 'dist').  Each Makefile.am would concatenate its own source file list
> > to a 'cscope.files' in the top level of the build directory. Once the
> > rule in all the Makefile.am's has been executed, cscope would be
> > executed.  In fact, I think that the existing 'make dist' is the best
> > example of this because it is pretty similar.
>
> Ooh, distdirs is a complex target.  I'll see what I can come up with, but
> if you beat me to it that's perfectly ok :)

Here's what I've got so far.  It's broken and I have a few questions:

  - what's if %?SUBDIRS% ... endif for?  I've seen it used elsewhere, and 
comments that say it's not allowed.

  - is there a better way to do what I'm doing with
      $(MAKE) ... reldir=$$subdir cscopedirs
    ?  the cscope.files file in $(top_builddir) needs to have paths relative 
to $(top_srcdir) (and, come to think of it, my current approach doesn't deal 
with that at all)

  - when I run automake to recreate my makefiles, some directories are missing 
'cscopedir' rules, how can I check for that?

Thanks,
Jesse
diff -Naurp -X /home/jbarnes/dontdiff automake-1.8.5.orig/doc/automake.texi automake-1.8.5/doc/automake.texi
--- automake-1.8.5.orig/doc/automake.texi	2004-05-13 16:41:35.000000000 -0400
+++ automake-1.8.5/doc/automake.texi	2004-07-14 17:53:22.289314464 -0400
@@ -228,7 +228,7 @@ Building documentation
 
 Miscellaneous Rules
 
-* Tags::                        Interfacing to etags and mkid
+* Tags::                        Interfacing to etags, mkid and cscope
 * Suffixes::                    Handling new file extensions
 * Multilibs::                   Support for multilibs.
 
@@ -5903,7 +5903,7 @@ the @code{AM_INIT_AUTOMAKE} macro in @fi
 There are a few rules and variables that didn't fit anywhere else.
 
 @menu
-* Tags::                        Interfacing to etags and mkid
+* Tags::                        Interfacing to etags, mkid, and cscope
 * Suffixes::                    Handling new file extensions
 * Multilibs::                   Support for multilibs.
 @end menu
@@ -5964,6 +5964,11 @@ GNU Global Tags program}.  The @code{GTA
 automatically and puts the result in the top build directory.  The
 variable @code{GTAGS_ARGS} holds arguments which are passed to
 @code{gtags}.
+
+Automake also supports @uref{http://cscope.sourceforge.net/,cscope}.
+The @code{cscope} rule runs cscope on the list of available source
+files.  Use @code{CSCOPE_ARGS} to pass additional flags to the
[EMAIL PROTECTED] program.
 @vindex GTAGS_ARGS
 
 
diff -Naurp -X /home/jbarnes/dontdiff automake-1.8.5.orig/lib/am/tags.am automake-1.8.5/lib/am/tags.am
--- automake-1.8.5.orig/lib/am/tags.am	2004-05-13 16:41:23.000000000 -0400
+++ automake-1.8.5/lib/am/tags.am	2004-07-14 17:50:41.768717304 -0400
@@ -123,6 +123,27 @@ GTAGS:
 	  && gtags -i $(GTAGS_ARGS) $$here
 
 
+## ------- ##
+## cscope  ##
+## ------- ##
+.PHONY: cscopedir
+cscopedir:
+	list='$(SOURCES)'; for source in $$list; do \
+	  echo $(reldir)/$$source >> $(top_builddir)/cscope.files ; \
+	done
+if %?SUBDIRS%
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  (cd $$subdir && \
+	    $(MAKE) $(AM_MAKEFLAGS) reldir=$$subdir cscopedir) \
+	    || exit 1; \
+	done
+endif %?SUBDIRS%
+
+.PHONY: cscope
+cscope: cscopedir
+	cd $(top_builddir) && cscope -b -R -q -i cscope.files $(CSCOPE_ARGS)
+
+
 ## ---------- ##
 ## Cleaning.  ##
 ## ---------- ##
@@ -130,4 +151,5 @@ GTAGS:
 .PHONY distclean-am: distclean-tags
 
 distclean-tags:
-	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags cscope.out cscope.in.out \
+	cscope.po.out cscope.files

Reply via email to