Thread (40 messages) 40 messages, 7 authors, 2021-08-04

Re: [PATCH v2 3/5] Makefile: fix "cscope" target to refer to cscope.out

From: Jeff King <hidden>
Date: 2021-07-01 22:25:07

On Thu, Jul 01, 2021 at 06:23:52PM -0400, Jeff King wrote:
On Tue, Jun 29, 2021 at 01:12:57PM +0200, Ævar Arnfjörð Bjarmason wrote:
quoted
diff --git a/Makefile b/Makefile
index faa8900097..2e3b257164 100644
--- a/Makefile
+++ b/Makefile
@@ -2737,10 +2737,12 @@ tags: FORCE
 	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
 	mv tags+ tags
 
+cscope.out:
+	$(QUIET_GEN)$(RM) cscope.out && \
+	$(FIND_SOURCE_FILES) | xargs cscope -f$@ -b
+
 .PHONY: cscope
-cscope:
-	$(QUIET_GEN)$(RM) cscope* && \
-	$(FIND_SOURCE_FILES) | xargs cscope -b
+cscope: cscope.out
Doesn't this break subsequent runs after the first generation? With a
phony "cscope" target, "make cscope" will always run the command, even
if it's not necessary. But with a real "cscope.out" target but not
dependencies, it will _never_ run it, even if one of the files changed.

E.g., with your patch:

  $ make cscope.out
    GEN cscope.out

  $ make cscope.out
  make: 'cscope.out' is up to date.

  $ echo 'void foo(void) { }' >>git.c
  $ make cscope.out
  GIT_VERSION = 2.32.0.96.g5daee1b7bb.dirty
  make: 'cscope.out' is up to date.
Ah, I see it is un-broken in the next commit, which adds actual
dependencies. I think it is OK to have a temporarily-broken state in the
history for something so trivial, but it might be worth mentioning it in
the commit message.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help