rework etags makefile design

Chris Shoemaker c.shoemaker at cox.net
Thu Oct 13 23:39:56 EDT 2005


[ FYI, this time I'm sending to -devel *on*purpose* to discuss patch. :) ]

I don't know why, but for whatever reason I got really hung-up on
figuring out why the 'make etags' was always triggering the remake of
the etags.files rule, and why it was always re-running etags.  It
seemed like I might as well have just run a script with 'etags' in it
every time.

When I got to the bottom of the rabbit-hole, this patch is what I
ended up with.  It's quite small but contains 3 significant changes:

1) don't trigger on modified ./ when rule itself modifies ./
2) etags.files rule execution always results in updated (touched) etags.files
3) tags file rule won't trigger if tags file is newer than every source file.

It all WorksForMe(tm), but since this process is a bit odd, I was
wondering if I've missed anything here.

-chris

*************************************************
Subject: [etags.diff] fixup tags dependencies

 * Makefile.TAGS |   11 +++++------
 * Makefile.am   |    4 ++--
   - exclude CVS and hidden directories and files from consideration
by [ec]tags
   - allow 'make' to consider age of tags file when determining
whether or not to rerun [ec]tags.
   - fix perpetual remake trigger by excluding toplevel directory
dependency from etags.files rule which touches said directory.

 Makefile.TAGS |   24 ++++++++----------------
 Makefile.am   |    4 ++--
 2 files changed, 10 insertions(+), 18 deletions(-)

Index: gnucash/Makefile.TAGS
===================================================================
--- gnucash.orig/Makefile.TAGS
+++ gnucash/Makefile.TAGS
@@ -7,25 +7,17 @@
 # i.e. TAGS: etags.files $(shell cat etags.files) doesn't work right
 # because etags.files contents are expanded before it's re-generated.
 
-# The $(shell find . -type d) dependency seems to be pointless -- it
-# always fires.  It appears that someone's always touching something.
-etags.files: $(shell find . -type d)
-	find . -path './debian' -prune -o -path './.pc' -prune -o \
-		-path '*.#*' -prune -o -name '*.[ch]' -print -o \
-		-name '*.scm' -print | sort > etags.files.tmp
-	@if cmp --quiet etags.files etags.files.tmp; \
-        then \
-          echo "TAGS file list hasn't changed."; \
-          rm -f etags.files.tmp; \
-        else \
-          echo "TAGS file list has changed."; \
-          mv etags.files.tmp etags.files; \
-        fi
+etags.files: $(shell find . -mindepth 1 -type d ! -name CVS ! -path "*/.*")
+	find . -path '*/.*' -prune -o \( -name '*.[ch]' -o -name '*.scm' \) \
+		-print | sort > etags.files.tmp
+	cmp -s etags.files etags.files.tmp || cp etags.files.tmp etags.files
+	rm -f etags.files.tmp
+	touch etags.files
 
 # we don't need an etags.files dep here b/c you always call this after
 # re-generating etags.files if needed from the top-level Makefile.am.
-etags: $(shell cat etags.files)
+TAGS: $(shell cat etags.files)
 	etags `cat etags.files`
 
-ctags: $(shell cat etags.files)
+tags: $(shell cat etags.files)
 	ctags `cat etags.files`
Index: gnucash/Makefile.am
===================================================================
--- gnucash.orig/Makefile.am
+++ gnucash/Makefile.am
@@ -97,7 +97,7 @@ etags:
         # make sure etags.files is up to date.
 	${MAKE} -f Makefile.TAGS etags.files
         # now use the contents of etags.files to re-make TAGS if needed.
-	${MAKE} -f Makefile.TAGS etags
+	${MAKE} -f Makefile.TAGS TAGS
 
 else
 
@@ -112,7 +112,7 @@ ctags:
         # make sure etags.files is up to date.
 	${MAKE} -f Makefile.TAGS etags.files
         # now use the contents of etags.files to re-make TAGS if needed.
-	${MAKE} -f Makefile.TAGS ctags
+	${MAKE} -f Makefile.TAGS tags
 
 else
 


More information about the gnucash-devel mailing list