From 922f8bbbf1097206969e423dd7af1bf33443765b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 29 Jun 2021 13:12:55 +0200 Subject: Makefile: move ".PHONY: cscope" near its target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the ".PHONY: cscope" rule to live alongside the "cscope" target itself, not to be all the way near the bottom where we define the "FORCE" rule. That line was last modified in 2f76919517e (MinGW: avoid collisions between "tags" and "TAGS", 2010-09-28). Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c3565fc0f8..4dd9711a65 100644 --- a/Makefile +++ b/Makefile @@ -2737,6 +2737,7 @@ tags: FORCE $(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \ mv tags+ tags +.PHONY: cscope cscope: $(RM) cscope* $(FIND_SOURCE_FILES) | xargs cscope -b @@ -3245,7 +3246,7 @@ endif .PHONY: all install profile-clean cocciclean clean strip .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell -.PHONY: FORCE cscope +.PHONY: FORCE ### Check documentation # -- cgit v1.2.3 From 033395be3287170658f0a36fa406dea9def7b657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 29 Jun 2021 13:12:56 +0200 Subject: Makefile: add QUIET_GEN to "cscope" target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't show the very verbose $(FIND_SOURCE_FILES) command on every "make cscope" invocation. See my recent 3c80fcb591 (Makefile: add QUIET_GEN to "tags" and "TAGS" targets, 2021-03-28) for the same fix for the other adjacent targets. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4dd9711a65..faa8900097 100644 --- a/Makefile +++ b/Makefile @@ -2739,7 +2739,7 @@ tags: FORCE .PHONY: cscope cscope: - $(RM) cscope* + $(QUIET_GEN)$(RM) cscope* && \ $(FIND_SOURCE_FILES) | xargs cscope -b ### Detect prefix changes -- cgit v1.2.3 From 7171221d82249cb8ce4b73a40852a487d1cebde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 22 Jul 2021 01:23:04 +0200 Subject: Makefile: don't use "FORCE" for tags targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the "FORCE" dependency from the "tags", "TAGS" and "cscope" targets, instead make them depend on whether or not the relevant source files have changed. For the cscope target we need to change it to depend on the actual generated file while we generate while we're at it, as the next commit will discuss we always generate a cscope.out file. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index faa8900097..55d0a98dc6 100644 --- a/Makefile +++ b/Makefile @@ -2727,20 +2727,24 @@ FIND_SOURCE_FILES = ( \ | sed -e 's|^\./||' \ ) -$(ETAGS_TARGET): FORCE +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)+" && \ + echo $(FOUND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \ mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)" -tags: FORCE +tags: $(FOUND_SOURCE_FILES) $(QUIET_GEN)$(RM) tags+ && \ - $(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \ + echo $(FOUND_SOURCE_FILES) | xargs ctags -a -o tags+ && \ mv tags+ tags -.PHONY: cscope -cscope: +cscope.out: $(FOUND_SOURCE_FILES) $(QUIET_GEN)$(RM) cscope* && \ - $(FIND_SOURCE_FILES) | xargs cscope -b + echo $(FOUND_SOURCE_FILES) | xargs cscope -b + +.PHONY: cscope +cscope: cscope.out ### Detect prefix changes TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\ @@ -2921,7 +2925,7 @@ check: config-list.h command-list.h exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c,$(FOUND_SOURCE_FILES)) COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES) -- cgit v1.2.3 From 530a446d4ac81c722a81d8d08883be27a17ad8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 5 Aug 2021 00:54:39 +0200 Subject: Makefile: remove "cscope.out", not "cscope*" in cscope.out target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before we generate a "cscope.out" file, remove that file explicitly, and not everything matching "cscope*". This doesn't change any behavior of the Makefile in practice, but makes this rule less confusing, and consistent with other similar rules. The cscope target was added in a2a9150bf06 (makefile: Add a cscope target, 2007-10-06). It has always referred to cscope* instead of to cscope.out in .gitignore and the "clean" target, even though we only ever generated a cscope.out file. This was seemingly done to aid use-cases where someone invoked cscope with the "-q" flag, which would make it create a "cscope.in.out" and "cscope.po.out" files in addition to "cscope.out". But us removing those files we never generated is confusing, so let's only remove the file we need to, furthermore let's use the "-f" flag to explicitly name the cscope.out file, even though it's the default if not "-f" argument is supplied. It is somewhat inconsistent to change from the glob here but not in the "clean" rule and .gitignore, an earlier version of this change updated those as well, but see [1][2] for why they were kept. 1. https://lore.kernel.org/git/87k0lit57x.fsf@evledraar.gmail.com/ 2. https://lore.kernel.org/git/87im0kn983.fsf@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 55d0a98dc6..b3e2c7dc7a 100644 --- a/Makefile +++ b/Makefile @@ -2740,8 +2740,8 @@ tags: $(FOUND_SOURCE_FILES) mv tags+ tags cscope.out: $(FOUND_SOURCE_FILES) - $(QUIET_GEN)$(RM) cscope* && \ - echo $(FOUND_SOURCE_FILES) | xargs cscope -b + $(QUIET_GEN)$(RM) $@ && \ + echo $(FOUND_SOURCE_FILES) | xargs cscope -f$@ -b .PHONY: cscope cscope: cscope.out -- cgit v1.2.3 From 899062438f47189cdcc3f5d3b3185eb4cfd798a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 5 Aug 2021 00:54:40 +0200 Subject: Makefile: normalize clobbering & xargs for tags targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the "tags", "TAGS" and "cscope.out" targets rely on piping into xargs with an "echo | xargs" pattern, we need to make sure we're in an append mode. Unlike my recent change to make use of ".DELETE_ON_ERROR" in 7b76d6bf221 (Makefile: add and use the ".DELETE_ON_ERROR" flag, 2021-06-29), we really do need the "rm $@+" at the beginning (note, not "rm $@"). This is because the xargs command may decide to invoke the program multiple times. We need to make sure we've got a union of its results at the end. For "ctags" and "etags" we used the "-a" flag for this, for cscope that behavior is the default. Its "-u" flag disables its equivalent of an implicit "-a" flag. Let's also consistently use the $@ and $@+ names instead of needlessly hardcoding or referring to more verbose names in the "tags" and "TAGS" rules. These targets could perhaps be improved in the future by factoring this "echo | xargs" pattern so that we make intermediate tags files for each source file, and then assemble them into one "tags" file at the end. The etags manual page suggests that doing that (or perhaps just --update) might be counter-productive, in any case, the tag building is fast enough for me, so I'm leaving that for now. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b3e2c7dc7a..471765b09f 100644 --- a/Makefile +++ b/Makefile @@ -2730,18 +2730,19 @@ FIND_SOURCE_FILES = ( \ FOUND_SOURCE_FILES = $(shell $(FIND_SOURCE_FILES)) $(ETAGS_TARGET): $(FOUND_SOURCE_FILES) - $(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \ - echo $(FOUND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \ - mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)" + $(QUIET_GEN)$(RM) $@+ && \ + echo $(FOUND_SOURCE_FILES) | xargs etags -a -o $@+ && \ + mv $@+ $@ tags: $(FOUND_SOURCE_FILES) - $(QUIET_GEN)$(RM) tags+ && \ - echo $(FOUND_SOURCE_FILES) | xargs ctags -a -o tags+ && \ - mv tags+ tags + $(QUIET_GEN)$(RM) $@+ && \ + echo $(FOUND_SOURCE_FILES) | xargs ctags -a -o $@+ && \ + mv $@+ $@ cscope.out: $(FOUND_SOURCE_FILES) - $(QUIET_GEN)$(RM) $@ && \ - echo $(FOUND_SOURCE_FILES) | xargs cscope -f$@ -b + $(QUIET_GEN)$(RM) $@+ && \ + echo $(FOUND_SOURCE_FILES) | xargs cscope -f$@+ -b && \ + mv $@+ $@ .PHONY: cscope cscope: cscope.out -- cgit v1.2.3