git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/5] Makefile: "make tags" fixes & cleanup

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 29, 2021, 11:12 UTC
Message-ID
<cover-0.5-0000000000-20210629T110837Z-avarab@gmail.com>
In-Reply-To
<cover-0.3-00000000000-20210622T141844Z-avarab@gmail.com>

A v2 of my fixes to the tags targets. This no longer depends on my .DELETE_ON_ERROR change, and goes directly on top of "master". See [2] for the just-submitted v2 of that other series.

The big win here is that none of the tags targets depend on "FORCE" anymore, so we'll only re-generate them if our sources change.

I missed the interaction of the "-a" flag and xargs splitting the arguments into am implicit -n, so in v1 of this we could end up with incomplete tag files. In this v2 we more incrementally reach similar ends, but in the end result retain our rm/gen/mv dance, since it's needed in this case.

1. http://lore.kernel.org/git/cover-0.3-00000000000-20210622T141844Z-avarab@gmail.com
2. https://lore.kernel.org/git/patch-1.1-2557117855-20210629T084356Z-avarab@gmail.com/
Ævar Arnfjörð Bjarmason (5):
  Makefile: move ".PHONY: cscope" near its target
  Makefile: add QUIET_GEN to "cscope" target
  Makefile: fix "cscope" target to refer to cscope.out
  Makefile: don't use "FORCE" for tags targets
  Makefile: normalize clobbering & xargs for tags targets
 .gitignore |  2 +-
 Makefile   | 34 ++++++++++++++++++++--------------
 2 files changed, 21 insertions(+), 15 deletions(-)
Range-diff against v1:
1:  383a90c8ac = 1:  dd6cfd6022 Makefile: move ".PHONY: cscope" near its target
-:  ---------- > 2:  56daa09738 Makefile: add QUIET_GEN to "cscope" target
2:  ea39f1f5cd ! 3:  35c8b83904 Makefile: fix "cscope" target to refer to cscope.out
    @@ Commit message
     
         The cscope target added in a2a9150bf06 (makefile: Add a cscope target,
         2007-10-06) has for some reason been referring to cscope* instead of
    -    cscope.out. Let's generate the cscope.out file directly so we don't
    -    need to speculate.
    +    cscope.out.
     
    -    The "-fcscope.out" (note, no whitespace) argument is enabled by
    -    default on my system's cscope 15.9, but let's provide it explicitly
    -    for good measure.
    +    Let's generate the cscope.out file directly so we don't need to
    +    speculate. The "-fcscope.out" (note, no whitespace) argument is
    +    enabled by default on my system's cscope 15.9, but let's provide it
    +    explicitly for good measure.
     
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
    @@ Makefile: tags: FORCE
      	mv tags+ tags
      
     +cscope.out:
    ++	$(QUIET_GEN)$(RM) cscope.out && \
     +	$(FIND_SOURCE_FILES) | xargs cscope -f$@ -b
     +
      .PHONY: cscope
     -cscope:
    --	$(RM) cscope*
    +-	$(QUIET_GEN)$(RM) cscope* && \
     -	$(FIND_SOURCE_FILES) | xargs cscope -b
     +cscope: cscope.out
      
3:  67fc87665d ! 4:  b924cc3f56 Makefile: don't use "FORCE" for tags targets
    @@ Commit message
         targets, instead make them depend on whether or not the relevant
         source files have changed.
     
    -    I'm also removing the "-o" option from them, that seems to have been
    -    cargo-culted when they were initially added in f81e7c626f3 (Makefile:
    -    Add TAGS and tags targets, 2006-03-18). It would make sense to use
    -    that option if we had been appending to tag files, it doesn't make any
    -    sense that it was used after we'd just removed the files file being
    -    appended to.
    -
    -    This will potentially cause a partial file to be left behind if the
    -    command dies, but my in-flight series to use the ".DELETE_ON_ERROR"
    -    flag in the Makefile[1] will make that problem go away. I think even
    -    without that it's not problem we need to worry about in these cases.
    -
    -    1. https://lore.kernel.org/git/patch-1.1-9420448e74f-20210622T141100Z-avarab@gmail.com/
    -
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## Makefile ##
    @@ Makefile: FIND_SOURCE_FILES = ( \
      	)
      
     -$(ETAGS_TARGET): FORCE
    --	$(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \
    --	$(FIND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \
    --	mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)"
     +FOUND_SOURCE_FILES = $(shell $(FIND_SOURCE_FILES))
    ++
    ++$(ETAGS_TARGET): $(FOUND_SOURCE_FILES)
    + 	$(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \
    + 	$(FIND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \
    + 	mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)"
      
     -tags: FORCE
    --	$(QUIET_GEN)$(RM) tags+ && \
    --	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
    --	mv tags+ tags
    -+$(ETAGS_TARGET): $(FOUND_SOURCE_FILES)
    -+	$(QUIET_GEN)echo $(FOUND_SOURCE_FILES) | \
    -+	xargs etags -o $@
    -+
     +tags: $(FOUND_SOURCE_FILES)
    -+	$(QUIET_GEN)echo $(FOUND_SOURCE_FILES) | \
    -+	xargs ctags -o $@
    + 	$(QUIET_GEN)$(RM) tags+ && \
    + 	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
    + 	mv tags+ tags
      
    - cscope.out:
    +-cscope.out:
    ++cscope.out: $(FOUND_SOURCE_FILES)
    + 	$(QUIET_GEN)$(RM) cscope.out && \
     -	$(FIND_SOURCE_FILES) | xargs cscope -f$@ -b
    -+	$(QUIET_GEN)echo $(FOUND_SOURCE_FILES) | \
    -+	xargs cscope -f$@ -b
    ++	echo $(FOUND_SOURCE_FILES) | xargs cscope -f$@ -b
      
      .PHONY: cscope
      cscope: cscope.out
-:  ---------- > 5:  5195d99e25 Makefile: normalize clobbering & xargs for tags targets
-- 
2.32.0.613.g20d5ce26552
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 15 of 45 in “Makefile: "make tags" fixes & cleanup”
  1. 0/3 Makefile: "make tags" fixes & cleanupÆvar Arnfjörð Bjarmason, Jun 22, 2021
  2. 1/3 Makefile: move ".PHONY: cscope" near its targetÆvar Arnfjörð Bjarmason, Jun 22, 2021
  3. 2/3 Makefile: fix "cscope" target to refer to cscope.outÆvar Arnfjörð Bjarmason, Jun 22, 2021
  4. Jeff KingJun 22, 2021
  5. Chris TorekJun 22, 2021
  6. Felipe ContrerasJun 23, 2021
  7. Felipe ContrerasJun 23, 2021
  8. Felipe ContrerasJun 23, 2021
  9. 3/3 Makefile: don't use "FORCE" for tags targetsÆvar Arnfjörð Bjarmason, Jun 22, 2021
  10. Jeff KingJun 22, 2021
  11. Felipe ContrerasJun 23, 2021
  12. Taylor BlauJun 22, 2021
  13. Junio C HamanoJun 29, 2021
  14. Ævar Arnfjörð BjarmasonJun 29, 2021
  15. 0/5 Makefile: "make tags" fixes & cleanupÆvar Arnfjörð Bjarmason, Jun 29, 2021
  16. 1/5 Makefile: move ".PHONY: cscope" near its targetÆvar Arnfjörð Bjarmason, Jun 29, 2021
  17. 2/5 Makefile: add QUIET_GEN to "cscope" targetÆvar Arnfjörð Bjarmason, Jun 29, 2021
  18. 3/5 Makefile: fix "cscope" target to refer to cscope.outÆvar Arnfjörð Bjarmason, Jun 29, 2021
  19. Jeff KingJul 1, 2021
  20. Jeff KingJul 1, 2021
  21. 4/5 Makefile: don't use "FORCE" for tags targetsÆvar Arnfjörð Bjarmason, Jun 29, 2021
  22. Ramsay JonesJun 30, 2021
  23. 5/5 Makefile: normalize clobbering & xargs for tags targetsÆvar Arnfjörð Bjarmason, Jun 29, 2021
  24. 0/5 Makefile: "make tags" fixes & cleanupÆvar Arnfjörð Bjarmason, Jul 21, 2021
  25. 1/5 Makefile: move ".PHONY: cscope" near its targetÆvar Arnfjörð Bjarmason, Jul 21, 2021
  26. 2/5 Makefile: add QUIET_GEN to "cscope" targetÆvar Arnfjörð Bjarmason, Jul 21, 2021
  27. 3/5 Makefile: don't use "FORCE" for tags targetsÆvar Arnfjörð Bjarmason, Jul 21, 2021
  28. 4/5 Makefile: the "cscope" target always creates a "cscope.out"Ævar Arnfjörð Bjarmason, Jul 21, 2021
  29. Junio C HamanoJul 22, 2021
  30. Taylor BlauJul 22, 2021
  31. Junio C HamanoJul 22, 2021
  32. Ævar Arnfjörð BjarmasonJul 22, 2021
  33. 5/5 Makefile: normalize clobbering & xargs for tags targetsÆvar Arnfjörð Bjarmason, Jul 21, 2021
  34. Jeff KingJul 23, 2021
  35. Jeff KingJul 23, 2021
  36. Jeff KingJul 23, 2021
  37. Junio C HamanoJul 23, 2021
  38. Felipe ContrerasJul 23, 2021
  39. Felipe ContrerasJul 23, 2021
  40. 0/5 Makefile: "make tags" fixes & cleanupÆvar Arnfjörð Bjarmason, Aug 4, 2021
  41. 1/5 Makefile: move ".PHONY: cscope" near its targetÆvar Arnfjörð Bjarmason, Aug 4, 2021
  42. 2/5 Makefile: add QUIET_GEN to "cscope" targetÆvar Arnfjörð Bjarmason, Aug 4, 2021
  43. 3/5 Makefile: don't use "FORCE" for tags targetsÆvar Arnfjörð Bjarmason, Aug 4, 2021
  44. 4/5 Makefile: remove "cscope.out", not "cscope*" in cscope.out targetÆvar Arnfjörð Bjarmason, Aug 4, 2021
  45. 5/5 Makefile: normalize clobbering & xargs for tags targetsÆvar Arnfjörð Bjarmason, Aug 4, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.