threads / discuss / 40973

[PATCHv2] Makefile: add missing phony target

Subject: [PATCHv2] Makefile: add missing phony target

## tl;dr

4 messages between Dec 11, 2015 and Dec 11, 2015.

replies: 3people: 2as markdown or json

Elia Pinto· Dec 11, 2015, 14:22 UTC · lore

Add some missing phony target to Makefile. Also put the .PHONY declaration immediately before the target declaration, where necessary, for a better readability and a uniform style.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Helped-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
---
This is the second version of this patch.
Added the corrections suggested by Matthieu Moy ($gmane/282221)
 Makefile | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 43ceeb9..afd2358 100644
--- a/Makefile
+++ b/Makefile
@@ -534,7 +534,7 @@ install-perl-script: $(SCRIPT_PERL_INS)
 install-python-script: $(SCRIPT_PYTHON_INS)
 	$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 
-.PHONY: clean-perl-script clean-sh-script clean-python-script
+.PHONY: clean-sh-script clean-perl-script clean-python-script
 clean-sh-script:
 	$(RM) $(SCRIPT_SH_GEN)
 clean-perl-script:
@@ -1644,6 +1644,9 @@ shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
 strip: $(PROGRAMS) git$X
 	$(STRIP) $(STRIP_OPTS) $^
 
+.PHONY: all profile profile-fast
+.PHONY: please_set_SHELL_PATH_to_a_more_modern_shell shell_compatibility_test strip
+
 ### Target-specific flags and dependencies
 
 # The generic compilation pattern rule and automatically
@@ -2011,6 +2014,7 @@ $(VCSSVN_LIB): $(VCSSVN_OBJS)
 
 export DEFAULT_EDITOR DEFAULT_PAGER
 
+.PHONY: doc man html info pdf
 doc:
 	$(MAKE) -C Documentation all
 
@@ -2054,6 +2058,7 @@ po/git.pot: $(GENERATED_H) FORCE
 		$(LOCALIZED_PERL)
 	mv $@+ $@
 
+.PHONY: pot
 pot: po/git.pot
 
 POFILES := $(wildcard po/*.po)
@@ -2074,6 +2079,7 @@ $(ETAGS_TARGET): FORCE
 	$(RM) $(ETAGS_TARGET)
 	$(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
 
+.PHONY: FORCE cscope
 tags: FORCE
 	$(RM) tags
 	$(FIND_SOURCE_FILES) | xargs ctags -a
@@ -2189,6 +2195,7 @@ export NO_SVN_TESTS
 export TEST_NO_MALLOC_CHECK
 
 ### Testing rules
+.PHONY: test perf
 
 test: all
 	$(MAKE) -C t/ all
@@ -2196,7 +2203,6 @@ test: all
 perf: all
 	$(MAKE) -C t/perf/ all
 
-.PHONY: test perf
 
 test-ctype$X: ctype.o
 
@@ -2215,6 +2221,7 @@ test-svn-fe$X: vcs-svn/lib.a
 test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
 
+.PHONY: check_sha1 $(SP_OBJ) sparse check check-sha1
 check-sha1:: test-sha1$X
 	./test-sha1.sh
 
@@ -2224,7 +2231,6 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
 	$(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
 		$(SPARSE_FLAGS) $<
 
-.PHONY: sparse $(SP_OBJ)
 sparse: $(SP_OBJ)
 
 check: common-cmds.h
@@ -2237,6 +2243,7 @@ check: common-cmds.h
 		exit 1; \
 	fi
 
+
 ### Installation rules
 
 ifneq ($(filter /%,$(firstword $(template_dir))),)
@@ -2263,6 +2270,7 @@ mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
 
 install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
 
+.PHONY: profile-install profile-fast-install install
 profile-install: profile
 	$(MAKE) install
 
@@ -2329,6 +2337,8 @@ endif
 	done && \
 	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
+.PHONY: install-gitweb install-man install-html install-info install-pdf
+.PHONY: quick-install-doc quick-install-man quick-install-html
 install-gitweb:
 	$(MAKE) -C gitweb install
 
@@ -2365,6 +2375,8 @@ git.spec: git.spec.in GIT-VERSION-FILE
 	mv $@+ $@
 
 GIT_TARNAME = git-$(GIT_VERSION)
+
+.PHONY: dist rpm dist-doc  distclean profile-clean clean
 dist: git.spec git-archive$(X) configure
 	./git-archive --format=tar \
 		--prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
@@ -2445,9 +2457,6 @@ endif
 	$(RM) GIT-USER-AGENT GIT-PREFIX
 	$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS
 
-.PHONY: all install profile-clean clean strip
-.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
-.PHONY: FORCE cscope
 
 ### Check documentation
 #
@@ -2499,9 +2508,9 @@ check-builtins::
 
 ### Test suite coverage testing
 #
-.PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
-.PHONY: coverage-clean-results
 
+.PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
+.PHONY: coverage-clean-results coverage-untested-functions cover_db cover_db_html
 coverage:
 	$(MAKE) coverage-test
 	$(MAKE) coverage-untested-functions
-- 
2.5.0
Matthieu Moy· Dec 11, 2015, 14:40 UTC · re: Elia Pinto · lore

Re: [PATCHv2] Makefile: add missing phony target

Elia Pinto <gitter.spiros@gmail.com> writes:
> This is the second version of this patch.
> Added the corrections suggested by Matthieu Moy ($gmane/282221)

Sorry, but my main concern was that the patch could not be reviewed in good conditions as-is, and I think it still cannot be. It's very hard to spot which .PHONY rules you're adding and which are just code movement. You should really split this into one "code movement" patch and one "actual bugfix" patch. Or someone with better eyes than me should review the patch ;-).

Show 14 quoted lines
> @@ -2215,6 +2221,7 @@ test-svn-fe$X: vcs-svn/lib.a
>  test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
>  	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
>  
> +.PHONY: check_sha1 $(SP_OBJ) sparse check check-sha1
>  check-sha1:: test-sha1$X
>  	./test-sha1.sh
>  
> @@ -2224,7 +2231,6 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
>  	$(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
>  		$(SPARSE_FLAGS) $<
>  
> -.PHONY: sparse $(SP_OBJ)
>  sparse: $(SP_OBJ)

This "sparse" movement looks again contradictory with the goal announced in the commit message.

Show 6 quoted lines
> @@ -2237,6 +2243,7 @@ check: common-cmds.h
>  		exit 1; \
>  	fi
>  
> +
>  ### Installation rules
Useless hunk.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Elia Pinto· Dec 11, 2015, 15:13 UTC · re: Matthieu Moy · lore

Re: [PATCHv2] Makefile: add missing phony target

2015-12-11 15:40 GMT+01:00 Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>:
Show 11 quoted lines
> Elia Pinto <gitter.spiros@gmail.com> writes:
>
>> This is the second version of this patch.
>> Added the corrections suggested by Matthieu Moy ($gmane/282221)
>
> Sorry, but my main concern was that the patch could not be reviewed in
> good conditions as-is, and I think it still cannot be. It's very hard to
> spot which .PHONY rules you're adding and which are just code movement.
> You should really split this into one "code movement" patch and one
> "actual bugfix" patch. Or someone with better eyes than me should review
> the patch ;-).
Ok. No problem. I thought there was no need for a patch so simple. But ok.
Thank you. I will reroll.
Show 18 quoted lines
>
>> @@ -2215,6 +2221,7 @@ test-svn-fe$X: vcs-svn/lib.a
>>  test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
>>       $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
>>
>> +.PHONY: check_sha1 $(SP_OBJ) sparse check check-sha1
>>  check-sha1:: test-sha1$X
>>       ./test-sha1.sh
>>
>> @@ -2224,7 +2231,6 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
>>       $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
>>               $(SPARSE_FLAGS) $<
>>
>> -.PHONY: sparse $(SP_OBJ)
>>  sparse: $(SP_OBJ)
>
> This "sparse" movement looks again contradictory with the goal announced
> in the commit message.

The idea was to group all the phony before all the target, not to put the phony necessarily before the closest target. but ok

Show 6 quoted lines
>
>> @@ -2237,6 +2243,7 @@ check: common-cmds.h
>>               exit 1; \
>>       fi
>>
>> +
My bad :=)
Show 7 quoted lines
>>  ### Installation rules
>
> Useless hunk.
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
Matthieu Moy· Dec 11, 2015, 15:43 UTC · re: Elia Pinto · lore

Re: [PATCHv2] Makefile: add missing phony target

Elia Pinto <gitter.spiros@gmail.com> writes:
Show 14 quoted lines
> 2015-12-11 15:40 GMT+01:00 Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>:
>> Elia Pinto <gitter.spiros@gmail.com> writes:
>>
>>> This is the second version of this patch.
>>> Added the corrections suggested by Matthieu Moy ($gmane/282221)
>>
>> Sorry, but my main concern was that the patch could not be reviewed in
>> good conditions as-is, and I think it still cannot be. It's very hard to
>> spot which .PHONY rules you're adding and which are just code movement.
>> You should really split this into one "code movement" patch and one
>> "actual bugfix" patch. Or someone with better eyes than me should review
>> the patch ;-).
>
> Ok. No problem. I thought there was no need for a patch so simple. But ok.

The point is: once a tricky bug was found in a patch (and I did on v1), you cannot claim anymore that it is "so simple". If it was that simple, you would have cought it before sending.

Show 19 quoted lines
>>> @@ -2215,6 +2221,7 @@ test-svn-fe$X: vcs-svn/lib.a
>>>  test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
>>>       $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
>>>
>>> +.PHONY: check_sha1 $(SP_OBJ) sparse check check-sha1
>>>  check-sha1:: test-sha1$X
>>>       ./test-sha1.sh
>>>
>>> @@ -2224,7 +2231,6 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
>>>       $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
>>>               $(SPARSE_FLAGS) $<
>>>
>>> -.PHONY: sparse $(SP_OBJ)
>>>  sparse: $(SP_OBJ)
>>
>> This "sparse" movement looks again contradictory with the goal announced
>> in the commit message.
> The idea was to group all the phony before all the target, not to put
> the phony necessarily before the closest target. but ok

I personally prefer the old way. I have no strong objection to changing, but currently your commit message says "Also put the .PHONY declaration immediately before the target declaration", which is clearly not a justification to do this change.

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

← back to recent threads