# [RFC/PATCH] Avoid TAGS/tags warning from GNU Make

4 messages from 2010-09-04 to 2010-09-04. Participants: Jonathan Nieder, Matthieu Moy, Junio C Hamano.
Thread: https://gitlist.dev/t/24969

## Jonathan Nieder, 2010-09-04 09:03

Subject: [RFC/PATCH] Avoid TAGS/tags warning from GNU Make
Message-ID: <20100904090331.GA10903@burratino>
URL: https://gitlist.dev/e/20100904090331.GA10903%40burratino

```
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Thu, 22 Oct 2009 19:04:17 +0200

MinGW make considers the TAGS and tags targets to refer to
the same file:

 Makefile: warning: overriding commands for target `TAGS'
 Makefile: warning: ignoring old commands for target `TAGS'

Suppress both targets on that platform.

Cc: Fredrik Kuivinen <frekui@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
This is kind of ugly; I hope there is a better way.  Maybe mingw
make ought to special-case the TAGS name, since this has come up in
other projects[1], too.

[1] e.g., http://thread.gmane.org/gmane.comp.video.mplayer.devel/51542/focus=51545

 Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index 40fbcae..a1d4550 100644
--- a/Makefile
+++ b/Makefile
@@ -1952,6 +1952,7 @@ info:
 pdf:
 	$(MAKE) -C Documentation pdf
 
+ifeq (,$(findstring MINGW,$(uname_S)))
 TAGS:
 	$(RM) TAGS
 	$(FIND) . -name '*.[hcS]' -print | xargs etags -a
@@ -1959,6 +1960,7 @@ TAGS:
 tags:
 	$(RM) tags
 	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
+endif
 
 cscope:
 	$(RM) cscope*
-- 
1.7.2.3

```

## Matthieu Moy, 2010-09-04 09:41

Subject: Re: [RFC/PATCH] Avoid TAGS/tags warning from GNU Make
Message-ID: <vpqeid97sn6.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqeid97sn6.fsf%40bauges.imag.fr
In-Reply-To: <20100904090331.GA10903@burratino>

```
Jonathan Nieder <jrnieder@gmail.com> writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> Date: Thu, 22 Oct 2009 19:04:17 +0200
>
> MinGW make considers the TAGS and tags targets to refer to
> the same file:
>
>  Makefile: warning: overriding commands for target `TAGS'
>  Makefile: warning: ignoring old commands for target `TAGS'
>
> Suppress both targets on that platform.

Wouldn't it be more sensible to rename them (like ETAGS/CTAGS) on
mingw instead, in case someone wants to use these files on windows?

Well, anyway, it doesn't harm much to remove them, they're just
convenience targets to be used by text editors, not by the build
system itself.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Junio C Hamano, 2010-09-04 16:14

Subject: Re: [RFC/PATCH] Avoid TAGS/tags warning from GNU Make
Message-ID: <7v8w3hxz81.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v8w3hxz81.fsf%40alter.siamese.dyndns.org
In-Reply-To: <vpqeid97sn6.fsf@bauges.imag.fr>

```
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Jonathan Nieder <jrnieder@gmail.com> writes:
>
>> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>> Date: Thu, 22 Oct 2009 19:04:17 +0200
>>
>> MinGW make considers the TAGS and tags targets to refer to
>> the same file:
>>
>>  Makefile: warning: overriding commands for target `TAGS'
>>  Makefile: warning: ignoring old commands for target `TAGS'
>>
>> Suppress both targets on that platform.
>
> Wouldn't it be more sensible to rename them (like ETAGS/CTAGS) on
> mingw instead, in case someone wants to use these files on windows?

I think that makes much more sense.  How about doing it that way, perhaps
something like this?

By the way, doesn't case insensitive HFS+ have the same issue?

-- >8 --
[Subject] MinGW: avoid collisions between "tags" and "TAGS"

On case insensitive filesystems, "tags" and "TAGS" target will try to
overwrite the same file.  Allow MinGW to use "ETAGS" instead.

These two targets do produce real files; do not put them on .PHONY target
list.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 Makefile |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 8b7c243..d87efdd 100644
--- a/Makefile
+++ b/Makefile
@@ -390,6 +390,8 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
 	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
 	  git-instaweb
 
+ETAGS_TARGET = TAGS
+
 # Empty...
 EXTRA_PROGRAMS =
 
@@ -1120,6 +1122,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_REGEX = YesPlease
 	NO_PYTHON = YesPlease
 	BLK_SHA1 = YesPlease
+	ETAGS_TARGET = ETAGS
 	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
 	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 	COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
@@ -1954,9 +1957,9 @@ info:
 pdf:
 	$(MAKE) -C Documentation pdf
 
-TAGS:
-	$(RM) TAGS
-	$(FIND) . -name '*.[hcS]' -print | xargs etags -a
+$(ETAGS_TARGET):
+	$(RM) $(ETAGS_TARGET)
+	$(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
 
 tags:
 	$(RM) tags
@@ -2228,7 +2231,7 @@ clean:
 	$(RM) $(TEST_PROGRAMS)
 	$(RM) -r bin-wrappers
 	$(RM) -r $(dep_dirs)
-	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
+	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
 	$(RM) -r autom4te.cache
 	$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
 	$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
@@ -2252,7 +2255,7 @@ endif
 
 .PHONY: all install clean strip
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
-.PHONY: FORCE TAGS tags cscope
+.PHONY: FORCE cscope
 
 ### Check documentation
 #

```

## Jonathan Nieder, 2010-09-04 16:34

Subject: Re: [RFC/PATCH] Avoid TAGS/tags warning from GNU Make
Message-ID: <20100904163407.GA31513@burratino>
URL: https://gitlist.dev/e/20100904163407.GA31513%40burratino
In-Reply-To: <7v8w3hxz81.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano wrote:

> +++ b/Makefile
> @@ -390,6 +390,8 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
>  	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
>  	  git-instaweb
>  
> +ETAGS_TARGET = TAGS
[...]
> @@ -1954,9 +1957,9 @@ info:
>  pdf:
>  	$(MAKE) -C Documentation pdf
>  
> -TAGS:
> -	$(RM) TAGS
> -	$(FIND) . -name '*.[hcS]' -print | xargs etags -a
> +$(ETAGS_TARGET):
> +	$(RM) $(ETAGS_TARGET)
> +	$(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)

Nice.

> @@ -2252,7 +2255,7 @@ endif
>  
>  .PHONY: all install clean strip
>  .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
> -.PHONY: FORCE TAGS tags cscope
> +.PHONY: FORCE cscope

make: `tags' is up to date.

How about something like this squashed in or on top?

-- 8< --
Subject: Makefile: regenerate editor tag files when asked

tags and TAGS depend on all source files, but it is easier to teach
the Makefile to regenerate them every time the user asks than to
declare that.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 52252d4..205fe58 100644
--- a/Makefile
+++ b/Makefile
@@ -1955,11 +1955,11 @@ info:
 pdf:
 	$(MAKE) -C Documentation pdf
 
-$(ETAGS_TARGET):
+$(ETAGS_TARGET): FORCE
 	$(RM) $(ETAGS_TARGET)
 	$(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
 
-tags:
+tags: FORCE
 	$(RM) tags
 	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
 
-- 
1.7.2.3

```
