Re: [PATCH] Makefile: don't include git version file on 'make clean'

9 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Makefile: don't include git version file on 'make clean'

From: Andreas Schwab <hidden>
Date: 2016-06-15 22:49:11

Ævar Arnfjörð Bjarmason [off-list ref] writes:
Makefile targets aren't triggered by the include directive.
Umm, yes they are, see (make) Remaking Makefiles.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Re: [PATCH] Makefile: don't include git version file on 'make clean'

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:11

On Sun, Jul 25, 2010 at 12:05, Andreas Schwab [off-list ref] wrote:
Ævar Arnfjörð Bjarmason [off-list ref] writes:
quoted
Makefile targets aren't triggered by the include directive.
Umm, yes they are, see (make) Remaking Makefiles.
Ah, yes. But it was being included in more places than just that
-include directive, so I didn't spot the difference:

Without that directive, still generated on make clean:

    $ git diff -U0 | cat
    diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
    index e88f50c..f29406b 100755
    --- a/GIT-VERSION-GEN
    +++ b/GIT-VERSION-GEN
    @@ -2,0 +3,2 @@
    +echo MOO > /tmp/moo
    +
    diff --git a/Makefile b/Makefile
    index b6975aa..5edfeca 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -241 +240,0 @@ GIT-VERSION-FILE: FORCE
    --include GIT-VERSION-FILE
    $ rm -v /tmp/moo; make clean > /dev/null; cat /tmp/moo
    removed `/tmp/moo'
    GIT_VERSION = 1.7.2.6.g65a0d3.dirty
    GITGUI_VERSION = 0.12.0.64.g89d61-dirty
    MOO

Deleted the rule, not generated, but other things are still calling
the rule:

    $ git diff -U0 | cat
    diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
    index e88f50c..f29406b 100755
    --- a/GIT-VERSION-GEN
    +++ b/GIT-VERSION-GEN
    @@ -2,0 +3,2 @@
    +echo MOO > /tmp/moo
    +
    diff --git a/Makefile b/Makefile
    index b6975aa..1a189da 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -239,4 +238,0 @@ all::
    -GIT-VERSION-FILE: FORCE
    -       @$(SHELL_PATH) ./GIT-VERSION-GEN
    --include GIT-VERSION-FILE
    -
    $ rm -v /tmp/moo; make clean > /dev/null; cat /tmp/moo
    removed `/tmp/moo'
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    GITGUI_VERSION = 0.12.0.64.g89d61-dirty
    cat: /tmp/moo: No such file or directory

RE: [PATCH] Makefile: don't include git version file on 'make clean'

From: <hidden>
Date: 2016-06-15 22:49:11


-----Original Message-----
From: Ævar Arnfjörð Bjarmason [mailto:avarab@gmail.com] 
Sent: 2010年7月25日 20:16
To: Andreas Schwab
Cc: Lin, Lynn; kpfleming@digium.com; git@vger.kernel.org
Subject: Re: [PATCH] Makefile: don't include git version file on 'make clean'

On Sun, Jul 25, 2010 at 12:05, Andreas Schwab [off-list ref] wrote:
Ævar Arnfjörð Bjarmason [off-list ref] writes:
quoted
Makefile targets aren't triggered by the include directive.
Umm, yes they are, see (make) Remaking Makefiles.
Ah, yes. But it was being included in more places than just that
-include directive, so I didn't spot the difference:

Without that directive, still generated on make clean:

    $ git diff -U0 | cat
    diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
    index e88f50c..f29406b 100755
    --- a/GIT-VERSION-GEN
    +++ b/GIT-VERSION-GEN
    @@ -2,0 +3,2 @@
    +echo MOO > /tmp/moo
    +
    diff --git a/Makefile b/Makefile
    index b6975aa..5edfeca 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -241 +240,0 @@ GIT-VERSION-FILE: FORCE
    --include GIT-VERSION-FILE
    $ rm -v /tmp/moo; make clean > /dev/null; cat /tmp/moo
    removed `/tmp/moo'
    GIT_VERSION = 1.7.2.6.g65a0d3.dirty
    GITGUI_VERSION = 0.12.0.64.g89d61-dirty
    MOO

Deleted the rule, not generated, but other things are still calling
the rule:


Why not delete the rule? We only handle this on 'make clean' command ('make distclean') target



    $ git diff -U0 | cat
    diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
    index e88f50c..f29406b 100755
    --- a/GIT-VERSION-GEN
    +++ b/GIT-VERSION-GEN
    @@ -2,0 +3,2 @@
    +echo MOO > /tmp/moo
    +
    diff --git a/Makefile b/Makefile
    index b6975aa..1a189da 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -239,4 +238,0 @@ all::
    -GIT-VERSION-FILE: FORCE
    -       @$(SHELL_PATH) ./GIT-VERSION-GEN
    --include GIT-VERSION-FILE
    -
    $ rm -v /tmp/moo; make clean > /dev/null; cat /tmp/moo
    removed `/tmp/moo'
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    GITGUI_VERSION = 0.12.0.64.g89d61-dirty
    cat: /tmp/moo: No such file or directory

RE: [PATCH] Makefile: don't include git version file on 'make clean'

From: <hidden>
Date: 2016-06-15 22:49:11


-----Original Message-----
From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On Behalf Of lynn.lin@emc.com
Sent: 2010年7月25日 20:19
To: avarab@gmail.com; schwab@linux-m68k.org
Cc: kpfleming@digium.com; git@vger.kernel.org
Subject: RE: [PATCH] Makefile: don't include git version file on 'make clean'



-----Original Message-----
From: Ævar Arnfjörð Bjarmason [mailto:avarab@gmail.com] 
Sent: 2010年7月25日 20:16
To: Andreas Schwab
Cc: Lin, Lynn; kpfleming@digium.com; git@vger.kernel.org
Subject: Re: [PATCH] Makefile: don't include git version file on 'make clean'

On Sun, Jul 25, 2010 at 12:05, Andreas Schwab [off-list ref] wrote:
Ævar Arnfjörð Bjarmason [off-list ref] writes:
quoted
Makefile targets aren't triggered by the include directive.
Umm, yes they are, see (make) Remaking Makefiles.
Ah, yes. But it was being included in more places than just that
-include directive, so I didn't spot the difference:

Without that directive, still generated on make clean:

    $ git diff -U0 | cat
    diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
    index e88f50c..f29406b 100755
    --- a/GIT-VERSION-GEN
    +++ b/GIT-VERSION-GEN
    @@ -2,0 +3,2 @@
    +echo MOO > /tmp/moo
    +
    diff --git a/Makefile b/Makefile
    index b6975aa..5edfeca 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -241 +240,0 @@ GIT-VERSION-FILE: FORCE
    --include GIT-VERSION-FILE
    $ rm -v /tmp/moo; make clean > /dev/null; cat /tmp/moo
    removed `/tmp/moo'
    GIT_VERSION = 1.7.2.6.g65a0d3.dirty
    GITGUI_VERSION = 0.12.0.64.g89d61-dirty
    MOO

Deleted the rule, not generated, but other things are still calling
the rule:


Why not delete the rule? We only handle this on 'make clean' command ('make distclean') target


Sorry.it's typo .Why delete the rule



    $ git diff -U0 | cat
    diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
    index e88f50c..f29406b 100755
    --- a/GIT-VERSION-GEN
    +++ b/GIT-VERSION-GEN
    @@ -2,0 +3,2 @@
    +echo MOO > /tmp/moo
    +
    diff --git a/Makefile b/Makefile
    index b6975aa..1a189da 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -239,4 +238,0 @@ all::
    -GIT-VERSION-FILE: FORCE
    -       @$(SHELL_PATH) ./GIT-VERSION-GEN
    --include GIT-VERSION-FILE
    -
    $ rm -v /tmp/moo; make clean > /dev/null; cat /tmp/moo
    removed `/tmp/moo'
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    GITGUI_VERSION = 0.12.0.64.g89d61-dirty
    cat: /tmp/moo: No such file or directory

NryزXvؖ){nljض}zj:v
zZzf~zwڢ)

RE: [PATCH] Makefile: don't include git version file on 'make clean'

From: <hidden>
Date: 2016-06-15 22:49:11


-----Original Message-----
From: Lin, Lynn 
Sent: 2010年7月25日 20:22
To: Lin, Lynn; avarab@gmail.com; schwab@linux-m68k.org
Cc: kpfleming@digium.com; git@vger.kernel.org
Subject: RE: [PATCH] Makefile: don't include git version file on 'make clean'



-----Original Message-----
From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On Behalf Of lynn.lin@emc.com
Sent: 2010年7月25日 20:19
To: avarab@gmail.com; schwab@linux-m68k.org
Cc: kpfleming@digium.com; git@vger.kernel.org
Subject: RE: [PATCH] Makefile: don't include git version file on 'make clean'



-----Original Message-----
From: Ævar Arnfjörð Bjarmason [mailto:avarab@gmail.com] 
Sent: 2010年7月25日 20:16
To: Andreas Schwab
Cc: Lin, Lynn; kpfleming@digium.com; git@vger.kernel.org
Subject: Re: [PATCH] Makefile: don't include git version file on 'make clean'

On Sun, Jul 25, 2010 at 12:05, Andreas Schwab [off-list ref] wrote:
Ævar Arnfjörð Bjarmason [off-list ref] writes:
quoted
Makefile targets aren't triggered by the include directive.
Umm, yes they are, see (make) Remaking Makefiles.
Ah, yes. But it was being included in more places than just that
-include directive, so I didn't spot the difference:

Without that directive, still generated on make clean:

    $ git diff -U0 | cat
    diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
    index e88f50c..f29406b 100755
    --- a/GIT-VERSION-GEN
    +++ b/GIT-VERSION-GEN
    @@ -2,0 +3,2 @@
    +echo MOO > /tmp/moo
    +
    diff --git a/Makefile b/Makefile
    index b6975aa..5edfeca 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -241 +240,0 @@ GIT-VERSION-FILE: FORCE
    --include GIT-VERSION-FILE
    $ rm -v /tmp/moo; make clean > /dev/null; cat /tmp/moo
    removed `/tmp/moo'
    GIT_VERSION = 1.7.2.6.g65a0d3.dirty
    GITGUI_VERSION = 0.12.0.64.g89d61-dirty
    MOO

Deleted the rule, not generated, but other things are still calling
the rule:


Why not delete the rule? We only handle this on 'make clean' command ('make distclean') target


Sorry.it's typo .Why delete the rule



    $ git diff -U0 | cat
    diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
    index e88f50c..f29406b 100755
    --- a/GIT-VERSION-GEN
    +++ b/GIT-VERSION-GEN
    @@ -2,0 +3,2 @@
    +echo MOO > /tmp/moo
    +
    diff --git a/Makefile b/Makefile
    index b6975aa..1a189da 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -239,4 +238,0 @@ all::
    -GIT-VERSION-FILE: FORCE
    -       @$(SHELL_PATH) ./GIT-VERSION-GEN
    --include GIT-VERSION-FILE
    -
    $ rm -v /tmp/moo; make clean > /dev/null; cat /tmp/moo
    removed `/tmp/moo'
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    make[2]: *** No rule to make target `GIT-VERSION-FILE'.  Stop.
    GITGUI_VERSION = 0.12.0.64.g89d61-dirty
    cat: /tmp/moo: No such file or directory

NryزXvؖ){nljض}zj:v
zZzf~zwڢ)






We have two place to call GIT-VERSION-FILE target in top Makefile
 
git.o git.spec \
        $(patsubst %.sh,%,$(SCRIPT_SH)) \
        $(patsubst %.perl,%,$(SCRIPT_PERL)) \
        : GIT-VERSION-FILE

clean:
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS


My patch is to don't call GIT-VERSION-FILE target when you run 'make clean'



Thanks
Lynn

Re: [PATCH] Makefile: don't include git version file on 'make clean'

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:11

On Sun, Jul 25, 2010 at 12:29,  [off-list ref] wrote:
My patch is to don't call GIT-VERSION-FILE target when you run 'make clean'
Yes, but as I demonstrated it gets called anyway. Presumably because
of the $(MAKE) -C ... clean rules. But I haven't looked into it.

RE: [PATCH] Makefile: don't include git version file on 'make clean'

From: <hidden>
Date: 2016-06-15 22:49:11


-----Original Message-----
From: Ævar Arnfjörð Bjarmason [mailto:avarab@gmail.com] 
Sent: 2010年7月25日 20:34
To: Lin, Lynn
Cc: schwab@linux-m68k.org; kpfleming@digium.com; git@vger.kernel.org
Subject: Re: [PATCH] Makefile: don't include git version file on 'make clean'

On Sun, Jul 25, 2010 at 12:29,  [off-list ref] wrote:
My patch is to don't call GIT-VERSION-FILE target when you run 'make clean'
Yes, but as I demonstrated it gets called anyway. Presumably because
of the $(MAKE) -C ... clean rules. But I haven't looked into it.


If we don't specify special goals, when we run any target ,it will call GIT-VERSIONF-FILE target as it include this target 

Example from GNU make manual:
http://www.gnu.org/software/autoconf/manual/make/Goals.html


An example of appropriate use is to avoid including .d files during clean rules (see Automatic Prerequisites), so make won't create them only to immediately remove them again:

          sources = foo.c bar.c
     
     ifneq ($(MAKECMDGOALS),clean)
     include $(sources:.c=.d)
     endif



Thanks
Lynn

Re: [PATCH] Makefile: don't include git version file on 'make clean'

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:11

On Sun, Jul 25, 2010 at 12:37,  [off-list ref] wrote:

-----Original Message-----
From: Ævar Arnfjörð Bjarmason [mailto:avarab@gmail.com]
Sent: 2010年7月25日 20:34
To: Lin, Lynn
Cc: schwab@linux-m68k.org; kpfleming@digium.com; git@vger.kernel.org
Subject: Re: [PATCH] Makefile: don't include git version file on 'make clean'

On Sun, Jul 25, 2010 at 12:29,  [off-list ref] wrote:
quoted
My patch is to don't call GIT-VERSION-FILE target when you run 'make clean'
Yes, but as I demonstrated it gets called anyway. Presumably because
of the $(MAKE) -C ... clean rules. But I haven't looked into it.


If we don't specify special goals, when we run any target ,it will call GIT-VERSIONF-FILE target as it include this target

Example from GNU make manual:
http://www.gnu.org/software/autoconf/manual/make/Goals.html


An example of appropriate use is to avoid including .d files during clean rules (see Automatic Prerequisites), so make won't create them only to immediately remove them again:

         sources = foo.c bar.c

    ifneq ($(MAKECMDGOALS),clean)
    include $(sources:.c=.d)
    endif
Yes, I know (now) how include directives work. What I'm saying is that
your patch doesn't work because the main Makefile clean directive
calls *other* makefiles, which in turn include the version file:

    $ rm GIT-VERSION-FILE ; make -C gitweb clean; cat GIT-VERSION-FILE
    make: Entering directory `/home/avar/g/git/gitweb'
    make[1]: Entering directory `/home/avar/g/git'
    GIT_VERSION = 1.7.2.6.g65a0d3
    make[1]: Leaving directory `/home/avar/g/git'
    make[1]: Entering directory `/home/avar/g/git'
    make[1]: `GIT-VERSION-FILE' is up to date.
    make[1]: Leaving directory `/home/avar/g/git'
    make: Leaving directory `/home/avar/g/git/gitweb'
    make: Entering directory `/home/avar/g/git/gitweb'
    make[1]: Entering directory `/home/avar/g/git'
    make[1]: `GIT-VERSION-FILE' is up to date.
    make[1]: Leaving directory `/home/avar/g/git'
    rm -f gitweb.cgi static/gitweb.min.js static/gitweb.min.css
GITWEB-BUILD-OPTIONS
    make: Leaving directory `/home/avar/g/git/gitweb'
    GIT_VERSION = 1.7.2.6.g65a0d3

So just removing the inclusion in the main Makefile doesn't do
anything at all.

To get it to work you need to patch the */Makefile files too, and
patch other clean targets like distclean.

But personally I think this whole thing is a bit silly, but others may
disagree. I've said my bit.

Thanks for contributing to Git anyway, your help is appreciated.

RE: [PATCH] Makefile: don't include git version file on 'make clean'

From: <hidden>
Date: 2016-06-15 22:49:11


-----Original Message-----
From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On Behalf Of ?var Arnfj?re Bjarmason
Sent: 2010年7月25日 21:08
To: Lin, Lynn
Cc: schwab@linux-m68k.org; kpfleming@digium.com; git@vger.kernel.org
Subject: Re: [PATCH] Makefile: don't include git version file on 'make clean'

On Sun, Jul 25, 2010 at 12:37,  [off-list ref] wrote:

-----Original Message-----
From: Ævar Arnfjörð Bjarmason [mailto:avarab@gmail.com]
Sent: 2010年7月25日 20:34
To: Lin, Lynn
Cc: schwab@linux-m68k.org; kpfleming@digium.com; git@vger.kernel.org
Subject: Re: [PATCH] Makefile: don't include git version file on 'make clean'

On Sun, Jul 25, 2010 at 12:29,  [off-list ref] wrote:
quoted
My patch is to don't call GIT-VERSION-FILE target when you run 'make clean'
Yes, but as I demonstrated it gets called anyway. Presumably because
of the $(MAKE) -C ... clean rules. But I haven't looked into it.


If we don't specify special goals, when we run any target ,it will call GIT-VERSIONF-FILE target as it include this target

Example from GNU make manual:
http://www.gnu.org/software/autoconf/manual/make/Goals.html


An example of appropriate use is to avoid including .d files during clean rules (see Automatic Prerequisites), so make won't create them only to immediately remove them again:

         sources = foo.c bar.c

    ifneq ($(MAKECMDGOALS),clean)
    include $(sources:.c=.d)
    endif
Yes, I know (now) how include directives work. What I'm saying is that
your patch doesn't work because the main Makefile clean directive
calls *other* makefiles, which in turn include the version file:

    $ rm GIT-VERSION-FILE ; make -C gitweb clean; cat GIT-VERSION-FILE
    make: Entering directory `/home/avar/g/git/gitweb'
    make[1]: Entering directory `/home/avar/g/git'
    GIT_VERSION = 1.7.2.6.g65a0d3
    make[1]: Leaving directory `/home/avar/g/git'
    make[1]: Entering directory `/home/avar/g/git'
    make[1]: `GIT-VERSION-FILE' is up to date.
    make[1]: Leaving directory `/home/avar/g/git'
    make: Leaving directory `/home/avar/g/git/gitweb'
    make: Entering directory `/home/avar/g/git/gitweb'
    make[1]: Entering directory `/home/avar/g/git'
    make[1]: `GIT-VERSION-FILE' is up to date.
    make[1]: Leaving directory `/home/avar/g/git'
    rm -f gitweb.cgi static/gitweb.min.js static/gitweb.min.css
GITWEB-BUILD-OPTIONS
    make: Leaving directory `/home/avar/g/git/gitweb'
    GIT_VERSION = 1.7.2.6.g65a0d3

So just removing the inclusion in the main Makefile doesn't do
anything at all.

To get it to work you need to patch the */Makefile files too, and
patch other clean targets like distclean.

There are Document,gitweb and git-gui module have the same "issues"


But personally I think this whole thing is a bit silly, but others may
disagree. I've said my bit.


I think we can do better when we find redundant code, correct?


Thanks for contributing to Git anyway, your help is appreciated.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help