git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Makefile: add missing header dependency rules
@ 2010-01-23 14:42 Jonathan Nieder
  2010-01-23 14:43 ` [PATCH 1/5] Makefile: add missing header file dependencies Jonathan Nieder
                   ` (5 more replies)
  0 siblings, 6 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-23 14:42 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Hi,

As a side-effect of generating dependency rules during the build
locally, it is possible to sanity-check the existing hard-coded
header file dependencies. [1]  Now the original topic of that thread [2]
can be addressed without collateral damage.

That is what patches 1 and 2 do.  The remaining patches are small
clean-ups that decrease the amount of dependencies again.

These patches are independent of the jn/makefile topic.  I sent them
before, but I screwed up the sender so nobody received them.  Anyway,
perhaps they could be useful.

Jonathan Nieder (5):
  Makefile: add missing header file dependencies
  Makefile: make sure test helpers are rebuilt when headers change
  Makefile: remove wt-status.h from LIB_H
  Makefile: clean up http-walker.o dependency rules
  Makefile: drop */*.h dependency rule

 Makefile |   58 +++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 37 insertions(+), 21 deletions(-)

[1] http://thread.gmane.org/gmane.comp.version-control.git/133872/focus=136257
[2] http://thread.gmane.org/gmane.comp.version-control.git/133872/focus=133884

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 1/5] Makefile: add missing header file dependencies
  2010-01-23 14:42 [PATCH 0/5] Makefile: add missing header dependency rules Jonathan Nieder
@ 2010-01-23 14:43 ` Jonathan Nieder
  2010-01-23 14:44 ` [PATCH 2/5] Makefile: make sure test helpers are rebuilt when headers change Jonathan Nieder
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-23 14:43 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

LIB_H is missing exec_cmd.h and color.h.  cache.h includes
SHA1_HEADER, and thus so does almost everything else, so add that
to LIB_H, too.  xdiff-interface.h is not included by any header
files, but so many source files use xdiff that it is simplest to
include it in LIB_H, too.

xdiff-interface.o uses the xdiff library heavily; let it depend
on all xdiff headers to avoid needing to keep track of which
headers it uses.

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

diff --git a/Makefile b/Makefile
index fd7f51e..2a408d7 100644
--- a/Makefile
+++ b/Makefile
@@ -447,6 +447,7 @@ LIB_H += blob.h
 LIB_H += builtin.h
 LIB_H += cache.h
 LIB_H += cache-tree.h
+LIB_H += color.h
 LIB_H += commit.h
 LIB_H += compat/bswap.h
 LIB_H += compat/cygwin.h
@@ -457,6 +458,7 @@ LIB_H += delta.h
 LIB_H += diffcore.h
 LIB_H += diff.h
 LIB_H += dir.h
+LIB_H += exec_cmd.h
 LIB_H += fsck.h
 LIB_H += git-compat-util.h
 LIB_H += graph.h
@@ -499,6 +501,8 @@ LIB_H += unpack-trees.h
 LIB_H += userdiff.h
 LIB_H += utf8.h
 LIB_H += wt-status.h
+LIB_H += xdiff-interface.h
+LIB_H += xdiff/xdiff.h
 
 LIB_OBJS += abspath.o
 LIB_OBJS += advice.o
@@ -1281,10 +1285,12 @@ endif
 ifdef BLK_SHA1
 	SHA1_HEADER = "block-sha1/sha1.h"
 	LIB_OBJS += block-sha1/sha1.o
+	LIB_H += block-sha1/sha1.h
 else
 ifdef PPC_SHA1
 	SHA1_HEADER = "ppc/sha1.h"
 	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
+	LIB_H += ppc/sha1.h
 else
 	SHA1_HEADER = <openssl/sha.h>
 	EXTLIBS += $(LIB_4_CRYPTO)
@@ -1637,14 +1643,25 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)
 
 $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
 $(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)
+builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o: branch.h
+builtin-bundle.o bundle.o transport.o: bundle.h
+builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
+builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
+builtin-send-pack.o transport.o: send-pack.h
+builtin-log.o builtin-shortlog.o: shortlog.h
 builtin-revert.o wt-status.o: wt-status.h
+builtin-prune.o builtin-reflog.o reachable.o: reachable.h
+builtin-tar-tree.o archive-tar.o: tar.h
+builtin-pack-objects.o: thread-utils.h
+http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
 
 $(LIB_FILE): $(LIB_OBJS)
 	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
 
 XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
-$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
+xdiff-interface.o $(XDIFF_OBJS): xdiff/xinclude.h \
+	xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
 	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 
 $(XDIFF_LIB): $(XDIFF_OBJS)
-- 
1.6.6.rc2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 2/5] Makefile: make sure test helpers are rebuilt when headers change
  2010-01-23 14:42 [PATCH 0/5] Makefile: add missing header dependency rules Jonathan Nieder
  2010-01-23 14:43 ` [PATCH 1/5] Makefile: add missing header file dependencies Jonathan Nieder
@ 2010-01-23 14:44 ` Jonathan Nieder
  2010-01-23 14:44 ` [PATCH 3/5] Makefile: remove wt-status.h from LIB_H Jonathan Nieder
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-23 14:44 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

It is not worth the bother to maintain an up-to-date list of
which headers each test helper uses, so depend on $(LIB_H) to
catch them all.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Verified (a few weeks ago) with 'make CHECK_HEADER_DEPENDENCIES=1'.

 Makefile |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 2a408d7..448d552 100644
--- a/Makefile
+++ b/Makefile
@@ -384,6 +384,18 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
 # Empty...
 EXTRA_PROGRAMS =
 
+TEST_PROGRAMS += test-chmtime$X
+TEST_PROGRAMS += test-ctype$X
+TEST_PROGRAMS += test-date$X
+TEST_PROGRAMS += test-delta$X
+TEST_PROGRAMS += test-dump-cache-tree$X
+TEST_PROGRAMS += test-genrandom$X
+TEST_PROGRAMS += test-match-trees$X
+TEST_PROGRAMS += test-parse-options$X
+TEST_PROGRAMS += test-path-utils$X
+TEST_PROGRAMS += test-sha1$X
+TEST_PROGRAMS += test-sigchain$X
+
 # ... and all the rest that could be moved out of bindir to gitexecdir
 PROGRAMS += $(EXTRA_PROGRAMS)
 PROGRAMS += git-fast-import$X
@@ -695,6 +707,8 @@ BUILTIN_OBJS += builtin-verify-pack.o
 BUILTIN_OBJS += builtin-verify-tag.o
 BUILTIN_OBJS += builtin-write-tree.o
 
+TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
+
 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 EXTLIBS =
 
@@ -1641,7 +1655,7 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
 
-$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
+$(LIB_OBJS) $(BUILTIN_OBJS) $(TEST_OBJS): $(LIB_H)
 $(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)
 builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o: branch.h
 builtin-bundle.o bundle.o transport.o: bundle.h
@@ -1732,18 +1746,6 @@ endif
 
 ### Testing rules
 
-TEST_PROGRAMS += test-chmtime$X
-TEST_PROGRAMS += test-ctype$X
-TEST_PROGRAMS += test-date$X
-TEST_PROGRAMS += test-delta$X
-TEST_PROGRAMS += test-dump-cache-tree$X
-TEST_PROGRAMS += test-genrandom$X
-TEST_PROGRAMS += test-match-trees$X
-TEST_PROGRAMS += test-parse-options$X
-TEST_PROGRAMS += test-path-utils$X
-TEST_PROGRAMS += test-sha1$X
-TEST_PROGRAMS += test-sigchain$X
-
 all:: $(TEST_PROGRAMS)
 
 # GNU make supports exporting all variables by "export" without parameters.
@@ -1763,9 +1765,7 @@ test-delta$X: diff-delta.o patch-delta.o
 
 test-parse-options$X: parse-options.o
 
-test-parse-options.o: parse-options.h
-
-.PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
+.PRECIOUS: $(TEST_OBJS)
 
 test-%$X: test-%.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-- 
1.6.6.rc2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 3/5] Makefile: remove wt-status.h from LIB_H
  2010-01-23 14:42 [PATCH 0/5] Makefile: add missing header dependency rules Jonathan Nieder
  2010-01-23 14:43 ` [PATCH 1/5] Makefile: add missing header file dependencies Jonathan Nieder
  2010-01-23 14:44 ` [PATCH 2/5] Makefile: make sure test helpers are rebuilt when headers change Jonathan Nieder
@ 2010-01-23 14:44 ` Jonathan Nieder
  2010-01-23 14:45 ` [PATCH 4/5] Makefile: clean up http-walker.o dependency rules Jonathan Nieder
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-23 14:44 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

A list of the few translation units using this header is
half-populated already.  Including the dependency on this header
twice (once explicitly, once through LIB_H) makes it difficult to
figure out where future headers should be added to the Makefile.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
I imagine the 'status' output is not used widely enough to consider it
a library header yet, but I could be easily convinced otherwise.
More important is to avoid the confusing double-dependency.

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

diff --git a/Makefile b/Makefile
index 448d552..7da52a3 100644
--- a/Makefile
+++ b/Makefile
@@ -512,7 +512,6 @@ LIB_H += tree-walk.h
 LIB_H += unpack-trees.h
 LIB_H += userdiff.h
 LIB_H += utf8.h
-LIB_H += wt-status.h
 LIB_H += xdiff-interface.h
 LIB_H += xdiff/xdiff.h
 
@@ -1663,7 +1662,7 @@ builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
 builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
 builtin-send-pack.o transport.o: send-pack.h
 builtin-log.o builtin-shortlog.o: shortlog.h
-builtin-revert.o wt-status.o: wt-status.h
+builtin-commit.o builtin-revert.o wt-status.o: wt-status.h
 builtin-prune.o builtin-reflog.o reachable.o: reachable.h
 builtin-tar-tree.o archive-tar.o: tar.h
 builtin-pack-objects.o: thread-utils.h
-- 
1.6.6.rc2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 4/5] Makefile: clean up http-walker.o dependency rules
  2010-01-23 14:42 [PATCH 0/5] Makefile: add missing header dependency rules Jonathan Nieder
                   ` (2 preceding siblings ...)
  2010-01-23 14:44 ` [PATCH 3/5] Makefile: remove wt-status.h from LIB_H Jonathan Nieder
@ 2010-01-23 14:45 ` Jonathan Nieder
  2010-01-23 14:45 ` [PATCH 5/5] Makefile: drop dependency on $(wildcard */*.h) Jonathan Nieder
  2010-01-25  4:44 ` [PATCH 0/5] Makefile: add missing header dependency rules Junio C Hamano
  5 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-23 14:45 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

http-walker.o depends on http.h twice: once in the rule listing
files that use http.h, and again in the rule explaining how to
build it.  Messy.

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

diff --git a/Makefile b/Makefile
index 7da52a3..eb225c6 100644
--- a/Makefile
+++ b/Makefile
@@ -1628,7 +1628,7 @@ http.o: http.c GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
 
 ifdef NO_EXPAT
-http-walker.o: http-walker.c http.h GIT-CFLAGS
+http-walker.o: http-walker.c GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
 endif
 
-- 
1.6.6.rc2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 5/5] Makefile: drop dependency on $(wildcard */*.h)
  2010-01-23 14:42 [PATCH 0/5] Makefile: add missing header dependency rules Jonathan Nieder
                   ` (3 preceding siblings ...)
  2010-01-23 14:45 ` [PATCH 4/5] Makefile: clean up http-walker.o dependency rules Jonathan Nieder
@ 2010-01-23 14:45 ` Jonathan Nieder
  2010-01-25  4:44 ` [PATCH 0/5] Makefile: add missing header dependency rules Junio C Hamano
  5 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-23 14:45 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

The files this pulls in are already pulled in by other dependency
rules (some recently added).

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

diff --git a/Makefile b/Makefile
index eb225c6..d6ebc9d 100644
--- a/Makefile
+++ b/Makefile
@@ -1655,7 +1655,7 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)
 		$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
 
 $(LIB_OBJS) $(BUILTIN_OBJS) $(TEST_OBJS): $(LIB_H)
-$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)
+$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H)
 builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o: branch.h
 builtin-bundle.o bundle.o transport.o: bundle.h
 builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
-- 
1.6.6.rc2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 0/5] Makefile: add missing header dependency rules
  2010-01-23 14:42 [PATCH 0/5] Makefile: add missing header dependency rules Jonathan Nieder
                   ` (4 preceding siblings ...)
  2010-01-23 14:45 ` [PATCH 5/5] Makefile: drop dependency on $(wildcard */*.h) Jonathan Nieder
@ 2010-01-25  4:44 ` Junio C Hamano
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
  5 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2010-01-25  4:44 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Junio C Hamano

Jonathan Nieder <jrnieder@gmail.com> writes:
> These patches are independent of the jn/makefile topic.  I sent them
> before, but I screwed up the sender so nobody received them.  Anyway,
> perhaps they could be useful.

I found all of them sensible but it seems to be based on version that is a
bit behind...

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 00/12] Re: Makefile: add missing header dependency rules
  2010-01-25  4:44 ` [PATCH 0/5] Makefile: add missing header dependency rules Junio C Hamano
@ 2010-01-26 15:43   ` Jonathan Nieder
  2010-01-26 15:44     ` [PATCH 01/12] Makefile: add missing header file dependencies Jonathan Nieder
                       ` (12 more replies)
  0 siblings, 13 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:43 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:

>> These patches are independent of the jn/makefile topic.  I sent them
>> before, but I screwed up the sender so nobody received them.  Anyway,
>> perhaps they could be useful.
>
> I found all of them sensible but it seems to be based on version that is a
> bit behind...

Thanks.  Patches 1-5 below are those I sent before, rebased against
maint.  Since last time, remote-curl.o gained a few more dependencies,
which are included.

The remainder of this series is based on a merge of master and
patches 1-5:

 Patch 6 adds another missing header dependency rule.  It is not
 included with the others because it applies to master, not maint.

 Patches 7-12 revisit the topic of generating header dependency
 rules on the fly.  I updated them to produce patches 1-6, so I
 thought, why not get some feedback on their present state?

Patch 7 clumps the header dependency rules together.  I think this
makes them more readable; more importantly, later this will allow
ifdef'ing them out later in one fell swoop.

Patches 8-9 and 11 list all targets that can depend on headers in a
new OBJECTS variable, for use in patches 10 and 12.

Patch 10 generates header dependency rules on the fly.  The resulting
dependency rules contain no useless dependencies (unlike the
hard-coded ones where almost everything depends on $(LIB_H)), so this
might be interesting to people wishing to speed up the
edit-compile-run cycle.

This only works with gcc.  It should be possible to teach the relevant
options to clink.pl if there is demand, but not SCO cc.

Patch 12 is what I am most interested in: it uses the computed
dependencies to check that the hard-coded dependency rules are
correct.  In the long term, maybe we will be able to get rid of the
hard-coded header dep rules altogether; in the short term, I am hoping
this checker can be useful for avoiding problems with the hard-coded
rules without spending too much human time on it.

Enjoy,
Jonathan Nieder (12):
  Makefile: add missing header file dependencies
  Makefile: make sure test helpers are rebuilt when headers change
  Makefile: remove wt-status.h from LIB_H
  Makefile: clean up http-walker.o dependency rules
  Makefile: drop dependency on $(wildcard */*.h)
  Makefile: transport.o depends on branch.h now
  Makefile: rearrange dependency rules
  Makefile: disable default implicit rules
  Makefile: list generated object files in OBJECTS macro
  Makefile: lazily compute header dependencies
  Makefile: list standalone program object files in PROGRAM_OBJS
  Teach Makefile to check header dependencies

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 01/12] Makefile: add missing header file dependencies
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
@ 2010-01-26 15:44     ` Jonathan Nieder
  2010-01-26 15:45     ` [PATCH 02/12] Makefile: make sure test helpers are rebuilt when headers change Jonathan Nieder
                       ` (11 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:44 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

LIB_H is missing exec_cmd.h and color.h.  cache.h includes
SHA1_HEADER, and thus so does almost everything else, so add that
to LIB_H, too.  xdiff-interface.h is not included by any header
files, but so many source files use xdiff that it is simplest to
include it in LIB_H, too.

xdiff-interface.o uses the xdiff library heavily; let it depend
on all xdiff headers to avoid needing to keep track of which
headers it uses.

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

diff --git a/Makefile b/Makefile
index fd7f51e..bad8f80 100644
--- a/Makefile
+++ b/Makefile
@@ -447,6 +447,7 @@ LIB_H += blob.h
 LIB_H += builtin.h
 LIB_H += cache.h
 LIB_H += cache-tree.h
+LIB_H += color.h
 LIB_H += commit.h
 LIB_H += compat/bswap.h
 LIB_H += compat/cygwin.h
@@ -457,6 +458,7 @@ LIB_H += delta.h
 LIB_H += diffcore.h
 LIB_H += diff.h
 LIB_H += dir.h
+LIB_H += exec_cmd.h
 LIB_H += fsck.h
 LIB_H += git-compat-util.h
 LIB_H += graph.h
@@ -499,6 +501,8 @@ LIB_H += unpack-trees.h
 LIB_H += userdiff.h
 LIB_H += utf8.h
 LIB_H += wt-status.h
+LIB_H += xdiff-interface.h
+LIB_H += xdiff/xdiff.h
 
 LIB_OBJS += abspath.o
 LIB_OBJS += advice.o
@@ -1281,10 +1285,12 @@ endif
 ifdef BLK_SHA1
 	SHA1_HEADER = "block-sha1/sha1.h"
 	LIB_OBJS += block-sha1/sha1.o
+	LIB_H += block-sha1/sha1.h
 else
 ifdef PPC_SHA1
 	SHA1_HEADER = "ppc/sha1.h"
 	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
+	LIB_H += ppc/sha1.h
 else
 	SHA1_HEADER = <openssl/sha.h>
 	EXTLIBS += $(LIB_4_CRYPTO)
@@ -1620,9 +1626,9 @@ git-imap-send$X: imap-send.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
 
-http.o http-walker.o http-push.o: http.h
+http.o http-walker.o http-push.o remote-curl.o: http.h
 
-http.o http-walker.o: $(LIB_H)
+http.o http-walker.o remote-curl.o: $(LIB_H)
 
 git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
@@ -1637,14 +1643,25 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)
 
 $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
 $(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)
+builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o: branch.h
+builtin-bundle.o bundle.o transport.o: bundle.h
+builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
+builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
+builtin-send-pack.o transport.o: send-pack.h
+builtin-log.o builtin-shortlog.o: shortlog.h
+builtin-prune.o builtin-reflog.o reachable.o: reachable.h
 builtin-revert.o wt-status.o: wt-status.h
+builtin-tar-tree.o archive-tar.o: tar.h
+builtin-pack-objects.o: thread-utils.h
+http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
 
 $(LIB_FILE): $(LIB_OBJS)
 	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
 
 XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
-$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
+xdiff-interface.o $(XDIFF_OBJS): \
+	xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
 	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 
 $(XDIFF_LIB): $(XDIFF_OBJS)
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 02/12] Makefile: make sure test helpers are rebuilt when headers change
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
  2010-01-26 15:44     ` [PATCH 01/12] Makefile: add missing header file dependencies Jonathan Nieder
@ 2010-01-26 15:45     ` Jonathan Nieder
  2010-01-26 15:46     ` [PATCH 03/12] Makefile: remove wt-status.h from LIB_H Jonathan Nieder
                       ` (10 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:45 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

It is not worth the bother to maintain an up-to-date list of
which headers each test helper uses, so depend on $(LIB_H) to
catch them all.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
This applies to maint.  Please let me know if you are interested
in the corresponding patch for master.

 Makefile |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index bad8f80..1670ee8 100644
--- a/Makefile
+++ b/Makefile
@@ -402,6 +402,18 @@ PROGRAMS += git-upload-pack$X
 PROGRAMS += git-var$X
 PROGRAMS += git-http-backend$X
 
+TEST_PROGRAMS += test-chmtime$X
+TEST_PROGRAMS += test-ctype$X
+TEST_PROGRAMS += test-date$X
+TEST_PROGRAMS += test-delta$X
+TEST_PROGRAMS += test-dump-cache-tree$X
+TEST_PROGRAMS += test-genrandom$X
+TEST_PROGRAMS += test-match-trees$X
+TEST_PROGRAMS += test-parse-options$X
+TEST_PROGRAMS += test-path-utils$X
+TEST_PROGRAMS += test-sha1$X
+TEST_PROGRAMS += test-sigchain$X
+
 # List built-in command $C whose implementation cmd_$C() is not in
 # builtin-$C.o but is linked in as part of some other command.
 BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
@@ -695,6 +707,8 @@ BUILTIN_OBJS += builtin-verify-pack.o
 BUILTIN_OBJS += builtin-verify-tag.o
 BUILTIN_OBJS += builtin-write-tree.o
 
+TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
+
 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 EXTLIBS =
 
@@ -1642,7 +1656,7 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)
 		$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
 
 $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
-$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)
+$(patsubst git-%$X,%.o,$(PROGRAMS)) $(TEST_OBJS) git.o: $(LIB_H) $(wildcard */*.h)
 builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o: branch.h
 builtin-bundle.o bundle.o transport.o: bundle.h
 builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
@@ -1732,18 +1746,6 @@ endif
 
 ### Testing rules
 
-TEST_PROGRAMS += test-chmtime$X
-TEST_PROGRAMS += test-ctype$X
-TEST_PROGRAMS += test-date$X
-TEST_PROGRAMS += test-delta$X
-TEST_PROGRAMS += test-dump-cache-tree$X
-TEST_PROGRAMS += test-genrandom$X
-TEST_PROGRAMS += test-match-trees$X
-TEST_PROGRAMS += test-parse-options$X
-TEST_PROGRAMS += test-path-utils$X
-TEST_PROGRAMS += test-sha1$X
-TEST_PROGRAMS += test-sigchain$X
-
 all:: $(TEST_PROGRAMS)
 
 # GNU make supports exporting all variables by "export" without parameters.
@@ -1763,9 +1765,7 @@ test-delta$X: diff-delta.o patch-delta.o
 
 test-parse-options$X: parse-options.o
 
-test-parse-options.o: parse-options.h
-
-.PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
+.PRECIOUS: $(TEST_OBJS)
 
 test-%$X: test-%.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 03/12] Makefile: remove wt-status.h from LIB_H
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
  2010-01-26 15:44     ` [PATCH 01/12] Makefile: add missing header file dependencies Jonathan Nieder
  2010-01-26 15:45     ` [PATCH 02/12] Makefile: make sure test helpers are rebuilt when headers change Jonathan Nieder
@ 2010-01-26 15:46     ` Jonathan Nieder
  2010-01-26 15:46     ` [PATCH 04/12] Makefile: clean up http-walker.o dependency rules Jonathan Nieder
                       ` (9 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:46 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

A list of the few translation units using this header is
half-populated already.  Including the dependency on this header
twice (once explicitly, once through LIB_H) makes it difficult to
figure out where future headers should be added to the Makefile.

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

diff --git a/Makefile b/Makefile
index 1670ee8..8cf6383 100644
--- a/Makefile
+++ b/Makefile
@@ -512,7 +512,6 @@ LIB_H += tree-walk.h
 LIB_H += unpack-trees.h
 LIB_H += userdiff.h
 LIB_H += utf8.h
-LIB_H += wt-status.h
 LIB_H += xdiff-interface.h
 LIB_H += xdiff/xdiff.h
 
@@ -1664,7 +1663,7 @@ builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
 builtin-send-pack.o transport.o: send-pack.h
 builtin-log.o builtin-shortlog.o: shortlog.h
 builtin-prune.o builtin-reflog.o reachable.o: reachable.h
-builtin-revert.o wt-status.o: wt-status.h
+builtin-commit.o builtin-revert.o wt-status.o: wt-status.h
 builtin-tar-tree.o archive-tar.o: tar.h
 builtin-pack-objects.o: thread-utils.h
 http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 04/12] Makefile: clean up http-walker.o dependency rules
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (2 preceding siblings ...)
  2010-01-26 15:46     ` [PATCH 03/12] Makefile: remove wt-status.h from LIB_H Jonathan Nieder
@ 2010-01-26 15:46     ` Jonathan Nieder
  2010-01-26 15:46     ` [PATCH 05/12] Makefile: drop dependency on $(wildcard */*.h) Jonathan Nieder
                       ` (8 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:46 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

http-walker.o depends on http.h twice: once in the rule listing
files that use http.h, and again in the rule explaining how to
build it.  Messy.

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

diff --git a/Makefile b/Makefile
index 8cf6383..593801a 100644
--- a/Makefile
+++ b/Makefile
@@ -1628,7 +1628,7 @@ http.o: http.c GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
 
 ifdef NO_EXPAT
-http-walker.o: http-walker.c http.h GIT-CFLAGS
+http-walker.o: http-walker.c GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
 endif
 
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 05/12] Makefile: drop dependency on $(wildcard */*.h)
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (3 preceding siblings ...)
  2010-01-26 15:46     ` [PATCH 04/12] Makefile: clean up http-walker.o dependency rules Jonathan Nieder
@ 2010-01-26 15:46     ` Jonathan Nieder
  2010-01-26 15:47     ` [PATCH 06/12] Makefile: transport.o depends on branch.h now Jonathan Nieder
                       ` (7 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:46 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

The files this pulls in are already pulled in by other dependency
rules (some recently added).

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

diff --git a/Makefile b/Makefile
index 593801a..98810b2 100644
--- a/Makefile
+++ b/Makefile
@@ -1655,7 +1655,7 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)
 		$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
 
 $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
-$(patsubst git-%$X,%.o,$(PROGRAMS)) $(TEST_OBJS) git.o: $(LIB_H) $(wildcard */*.h)
+$(patsubst git-%$X,%.o,$(PROGRAMS)) $(TEST_OBJS) git.o: $(LIB_H)
 builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o: branch.h
 builtin-bundle.o bundle.o transport.o: bundle.h
 builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 06/12] Makefile: transport.o depends on branch.h now
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (4 preceding siblings ...)
  2010-01-26 15:46     ` [PATCH 05/12] Makefile: drop dependency on $(wildcard */*.h) Jonathan Nieder
@ 2010-01-26 15:47     ` Jonathan Nieder
  2010-01-26 15:49     ` [PATCH 07/12] Makefile: rearrange dependency rules Jonathan Nieder
                       ` (6 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:47 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Since commit e9fcd1e2 (Add push --set-upstream, 2010-01-16),
transport.c uses branch.h.

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

diff --git a/Makefile b/Makefile
index 59a46e2..5678991 100644
--- a/Makefile
+++ b/Makefile
@@ -1719,7 +1719,7 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)
 
 $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
 $(patsubst git-%$X,%.o,$(PROGRAMS)) $(TEST_OBJS) git.o: $(LIB_H)
-builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o: branch.h
+builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o transport.o: branch.h
 builtin-bundle.o bundle.o transport.o: bundle.h
 builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
 builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 07/12] Makefile: rearrange dependency rules
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (5 preceding siblings ...)
  2010-01-26 15:47     ` [PATCH 06/12] Makefile: transport.o depends on branch.h now Jonathan Nieder
@ 2010-01-26 15:49     ` Jonathan Nieder
  2010-01-26 15:51     ` [PATCH 08/12] Makefile: disable default implicit rules Jonathan Nieder
                       ` (5 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:49 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Put rules listing dependencies of compiled objects (.o files) on
header files (.h files) in one place, to make them easier to
compare and modify all at once.

Add a GIT_OBJS variable listing objects that depend on LIB_H,
for similar reasons.

No change in build-time behavior intended.

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

diff --git a/Makefile b/Makefile
index 5678991..84ce137 100644
--- a/Makefile
+++ b/Makefile
@@ -1666,6 +1666,12 @@ git.o git.spec \
 	$(patsubst %.perl,%,$(SCRIPT_PERL)) \
 	: GIT-VERSION-FILE
 
+GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(TEST_OBJS) \
+	git.o http.o http-walker.o remote-curl.o \
+	$(patsubst git-%$X,%.o,$(PROGRAMS))
+XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
+	xdiff/xmerge.o xdiff/xpatience.o
+
 %.o: %.c GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 %.s: %.c GIT-CFLAGS FORCE
@@ -1673,6 +1679,25 @@ git.o git.spec \
 %.o: %.S GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 
+$(GIT_OBJS): $(LIB_H)
+builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o transport.o: branch.h
+builtin-bundle.o bundle.o transport.o: bundle.h
+builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
+builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
+builtin-send-pack.o transport.o: send-pack.h
+builtin-log.o builtin-shortlog.o: shortlog.h
+builtin-prune.o builtin-reflog.o reachable.o: reachable.h
+builtin-commit.o builtin-revert.o wt-status.o: wt-status.h
+builtin-tar-tree.o archive-tar.o: tar.h
+builtin-pack-objects.o: thread-utils.h
+http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
+http.o http-walker.o http-push.o remote-curl.o: http.h
+
+
+xdiff-interface.o $(XDIFF_OBJS): \
+	xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
+	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
+
 exec_cmd.s exec_cmd.o: ALL_CFLAGS += \
 	'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
 	'-DBINDIR="$(bindir_relative_SQ)"' \
@@ -1696,10 +1721,6 @@ git-imap-send$X: imap-send.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
 
-http.o http-walker.o http-push.o remote-curl.o: http.h
-
-http.o http-walker.o remote-curl.o: $(LIB_H)
-
 git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(LIBS) $(CURL_LIBCURL)
@@ -1717,29 +1738,9 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
 
-$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
-$(patsubst git-%$X,%.o,$(PROGRAMS)) $(TEST_OBJS) git.o: $(LIB_H)
-builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o transport.o: branch.h
-builtin-bundle.o bundle.o transport.o: bundle.h
-builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
-builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
-builtin-send-pack.o transport.o: send-pack.h
-builtin-log.o builtin-shortlog.o: shortlog.h
-builtin-prune.o builtin-reflog.o reachable.o: reachable.h
-builtin-commit.o builtin-revert.o wt-status.o: wt-status.h
-builtin-tar-tree.o archive-tar.o: tar.h
-builtin-pack-objects.o: thread-utils.h
-http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
-
 $(LIB_FILE): $(LIB_OBJS)
 	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
 
-XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
-	xdiff/xmerge.o xdiff/xpatience.o
-xdiff-interface.o $(XDIFF_OBJS): \
-	xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
-	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
-
 $(XDIFF_LIB): $(XDIFF_OBJS)
 	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
 
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 08/12] Makefile: disable default implicit rules
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (6 preceding siblings ...)
  2010-01-26 15:49     ` [PATCH 07/12] Makefile: rearrange dependency rules Jonathan Nieder
@ 2010-01-26 15:51     ` Jonathan Nieder
  2010-01-26 15:52     ` [PATCH 09/12] Makefile: list generated object files in OBJECTS Jonathan Nieder
                       ` (4 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:51 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

The git makefile never uses any default implicit rules.
Unfortunately, if a prerequisite for one of the intended rules is
missing, a default rule can be used in its place:

	$ make var.s
	    CC var.s
	$ rm var.c
	$ make var.o
	    as   -o var.o var.s

Avoiding the default rules avoids this hard-to-debug behavior.
It also should speed things up a little in the normal case.

Future patches may restrict the scope of the %.o: %.c pattern.
This patch would then ensure that for targets not listed, we do
not fall back to the default rule.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Sadly, this does not really speed things up in the normal case.
I am not sure why, but make needs the -r option to avoid
considering the default rules, even though clearing the .SUFFIXES:
guarantees it will never use them.

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

diff --git a/Makefile b/Makefile
index 84ce137..60ef711 100644
--- a/Makefile
+++ b/Makefile
@@ -1672,6 +1672,8 @@ GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(TEST_OBJS) \
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
 
+.SUFFIXES:
+
 %.o: %.c GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 %.s: %.c GIT-CFLAGS FORCE
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 09/12] Makefile: list generated object files in OBJECTS
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (7 preceding siblings ...)
  2010-01-26 15:51     ` [PATCH 08/12] Makefile: disable default implicit rules Jonathan Nieder
@ 2010-01-26 15:52     ` Jonathan Nieder
  2010-01-26 15:52     ` [PATCH 10/12] Makefile: lazily compute header dependencies Jonathan Nieder
                       ` (3 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:52 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Set the OBJECTS variable to a comprehensive list of all object
file targets.  To make sure it is truly comprehensive, restrict
the scope of the %.o pattern rule to only generate objects in
this list.

Attempts to build other object files will fail loudly:

	$ touch foo.c
	$ make foo.o
	make: *** No rule to make target `foo.o'.  Stop.

providing a reminder to add the new object to the OBJECTS list.

The new variable is otherwise unused.  The intent is for later
patches to take advantage of it.

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

diff --git a/Makefile b/Makefile
index 60ef711..0e4e8ff 100644
--- a/Makefile
+++ b/Makefile
@@ -1671,14 +1671,19 @@ GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(TEST_OBJS) \
 	$(patsubst git-%$X,%.o,$(PROGRAMS))
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
+OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
+
+ASM_SRC := $(wildcard $(OBJECTS:o=S))
+ASM_OBJ := $(ASM_SRC:S=o)
+C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
 
 .SUFFIXES:
 
-%.o: %.c GIT-CFLAGS
+$(C_OBJ): %.o: %.c GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 %.s: %.c GIT-CFLAGS FORCE
 	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
-%.o: %.S GIT-CFLAGS
+$(ASM_OBJ): %.o: %.S GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 
 $(GIT_OBJS): $(LIB_H)
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 10/12] Makefile: lazily compute header dependencies
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (8 preceding siblings ...)
  2010-01-26 15:52     ` [PATCH 09/12] Makefile: list generated object files in OBJECTS Jonathan Nieder
@ 2010-01-26 15:52     ` Jonathan Nieder
  2010-01-26 15:54     ` [PATCH 11/12] Makefile: list standalone program object files in PROGRAM_OBJS Jonathan Nieder
                       ` (2 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:52 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Use the gcc -MMD -MP -MF options to generate dependency rules as
a byproduct when building .o files if the
COMPUTE_HEADER_DEPENDENCIES variable is defined.  That variable
is left undefined by default for now.

As each object file is built, write a makefile fragment
containing its dependencies in the deps/ subdirectory of its
containing directory.  The deps/ directories should be generated
if they are missing at the start of each build.  So let each
object file depend on $(missing_dep_dirs), which lists only the
directories of this kind that are missing to avoid needlessly
regenerating files when the directories' timestamps change.

gcc learned the -MMD -MP -MF options in version 3.0, so most gcc
users should have them by now.

The dependencies this option computes are more specific than the
rough estimates hard-coded in the Makefile, greatly speeding up
rebuilds when only a little-used header file has changed.

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

diff --git a/.gitignore b/.gitignore
index 8df8f88..7b3acb7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -177,6 +177,7 @@
 *.exe
 *.[aos]
 *.py[co]
+*.o.d
 *+
 /config.mak
 /autom4te.cache
diff --git a/Makefile b/Makefile
index 0e4e8ff..2e75f05 100644
--- a/Makefile
+++ b/Makefile
@@ -217,6 +217,10 @@ all::
 #   DEFAULT_EDITOR='~/bin/vi',
 #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
 #   DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
+#
+# Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
+# and you want to avoid rebuilding objects when an unrelated header file
+# changes.
 
 GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1677,14 +1681,48 @@ ASM_SRC := $(wildcard $(OBJECTS:o=S))
 ASM_OBJ := $(ASM_SRC:S=o)
 C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
 
+ifdef COMPUTE_HEADER_DEPENDENCIES
+dep_dirs := $(addsuffix deps,$(sort $(dir $(OBJECTS))))
+$(dep_dirs):
+	mkdir -p $@
+
+missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
+else
+dep_dirs =
+missing_dep_dirs =
+endif
+
 .SUFFIXES:
 
-$(C_OBJ): %.o: %.c GIT-CFLAGS
-	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
+$(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
+	$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
 %.s: %.c GIT-CFLAGS FORCE
 	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
-$(ASM_OBJ): %.o: %.S GIT-CFLAGS
-	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
+$(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
+	$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
+
+ifdef COMPUTE_HEADER_DEPENDENCIES
+# Take advantage of gcc's on-the-fly dependency generation
+# See <http://gcc.gnu.org/gcc-3.0/features.html>.
+dep_files := $(wildcard $(foreach f,$(OBJECTS),$(dir f)deps/$(notdir $f).d))
+ifneq ($(dep_files),)
+include $(dep_files)
+endif
+
+dep_file = $(dir $@)deps/$(notdir $@).d
+dep_args = -MF $(dep_file) -MMD -MP
+else
+dep_args =
+
+# Dependencies on header files, for platforms that do not support
+# the gcc -MMD option.
+#
+# Dependencies on automatically generated headers such as common-cmds.h
+# should _not_ be included here, since they are necessary even when
+# building an object for the first time.
+#
+# XXX. Please check occasionally that these include all dependencies
+# gcc detects!
 
 $(GIT_OBJS): $(LIB_H)
 builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o transport.o: branch.h
@@ -1700,10 +1738,10 @@ builtin-pack-objects.o: thread-utils.h
 http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
 http.o http-walker.o http-push.o remote-curl.o: http.h
 
-
 xdiff-interface.o $(XDIFF_OBJS): \
 	xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
 	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
+endif
 
 exec_cmd.s exec_cmd.o: ALL_CFLAGS += \
 	'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
@@ -2011,6 +2049,7 @@ clean:
 	$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
 	$(RM) $(TEST_PROGRAMS)
 	$(RM) -r bin-wrappers
+	$(RM) -r $(dep_dirs)
 	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
 	$(RM) -r autom4te.cache
 	$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 11/12] Makefile: list standalone program object files in PROGRAM_OBJS
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (9 preceding siblings ...)
  2010-01-26 15:52     ` [PATCH 10/12] Makefile: lazily compute header dependencies Jonathan Nieder
@ 2010-01-26 15:54     ` Jonathan Nieder
  2010-01-27  9:07       ` [PATCH v2 " Jonathan Nieder
  2010-01-26 15:57     ` [PATCH 12/12] Teach Makefile to check header dependencies Jonathan Nieder
  2010-01-26 16:19     ` [PATCH 00/12] Re: Makefile: add missing header dependency rules Jonathan Nieder
  12 siblings, 1 reply; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:54 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Because of new commands like git-remote-http, the OBJECTS list
contains fictitious objects such as remote-http.o.  Thus any
out-of-tree rules that require all $(OBJECTS) to be buildable
are broken.  Add a list of real program objects to avoid this
problem.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Preparing for patch 12.

 Makefile |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 2e75f05..ceaae1c 100644
--- a/Makefile
+++ b/Makefile
@@ -341,6 +341,7 @@ COMPAT_CFLAGS =
 COMPAT_OBJS =
 LIB_H =
 LIB_OBJS =
+PROGRAM_OBJS =
 PROGRAMS =
 SCRIPT_PERL =
 SCRIPT_PYTHON =
@@ -390,12 +391,15 @@ EXTRA_PROGRAMS =
 
 # ... and all the rest that could be moved out of bindir to gitexecdir
 PROGRAMS += $(EXTRA_PROGRAMS)
-PROGRAMS += git-fast-import$X
-PROGRAMS += git-imap-send$X
-PROGRAMS += git-shell$X
-PROGRAMS += git-show-index$X
-PROGRAMS += git-upload-pack$X
-PROGRAMS += git-http-backend$X
+
+PROGRAM_OBJS += fast-import.o
+PROGRAM_OBJS += imap-send.o
+PROGRAM_OBJS += shell.o
+PROGRAM_OBJS += show-index.o
+PROGRAM_OBJS += upload-pack.o
+PROGRAM_OBJS += http-backend.o
+
+PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 
 TEST_PROGRAMS_NEED_X += test-chmtime
 TEST_PROGRAMS_NEED_X += test-ctype
@@ -1139,10 +1143,12 @@ else
 	REMOTE_CURL_PRIMARY = git-remote-http$X
 	REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
 	REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
+	PROGRAM_OBJS += http-fetch.o
 	PROGRAMS += $(REMOTE_CURL_NAMES) git-http-fetch$X
 	curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
 	ifeq "$(curl_check)" "070908"
 		ifndef NO_EXPAT
+			PROGRAM_OBJS += http-push.o
 			PROGRAMS += git-http-push$X
 		endif
 	endif
@@ -1163,6 +1169,7 @@ endif
 EXTLIBS += -lz
 
 ifndef NO_POSIX_ONLY_PROGRAMS
+	PROGRAM_OBJS += daemon.o
 	PROGRAMS += git-daemon$X
 endif
 ifndef NO_OPENSSL
@@ -1670,9 +1677,8 @@ git.o git.spec \
 	$(patsubst %.perl,%,$(SCRIPT_PERL)) \
 	: GIT-VERSION-FILE
 
-GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(TEST_OBJS) \
-	git.o http.o http-walker.o remote-curl.o \
-	$(patsubst git-%$X,%.o,$(PROGRAMS))
+GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
+	git.o http.o http-walker.o remote-curl.o
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 12/12] Teach Makefile to check header dependencies
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (10 preceding siblings ...)
  2010-01-26 15:54     ` [PATCH 11/12] Makefile: list standalone program object files in PROGRAM_OBJS Jonathan Nieder
@ 2010-01-26 15:57     ` Jonathan Nieder
  2010-01-31 20:42       ` Junio C Hamano
  2010-01-26 16:19     ` [PATCH 00/12] Re: Makefile: add missing header dependency rules Jonathan Nieder
  12 siblings, 1 reply; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 15:57 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Add a target to use the gcc-generated makefile snippets for
dependencies on header files to check the hard-coded dependencies.

With this patch applied, if any dependencies are missing, then

	make clean
	make COMPUTE_HEADER_DEPENDENCIES=YesPlease
	make CHECK_HEADER_DEPENDENCIES=YesPlease

will produce an error message like the following:

	CHECK fast-import.o
	missing dependencies: exec_cmd.h
	make: *** [fast-import.o] Error 1

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
That’s the end of the series.  Thanks for reading.

 Makefile |   95 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 80 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index ceaae1c..be357a8 100644
--- a/Makefile
+++ b/Makefile
@@ -221,6 +221,9 @@ all::
 # Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
 # and you want to avoid rebuilding objects when an unrelated header file
 # changes.
+#
+# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
+# dependency rules.
 
 GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1088,6 +1091,14 @@ endif
 -include config.mak.autogen
 -include config.mak
 
+ifdef CHECK_HEADER_DEPENDENCIES
+USE_COMPUTED_HEADER_DEPENDENCIES =
+endif
+
+ifdef COMPUTE_HEADER_DEPENDENCIES
+USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
+endif
+
 ifdef SANE_TOOL_PATH
 SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
 BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
@@ -1683,9 +1694,7 @@ XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
 
-ASM_SRC := $(wildcard $(OBJECTS:o=S))
-ASM_OBJ := $(ASM_SRC:S=o)
-C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
+dep_files := $(foreach f,$(OBJECTS),$(dir $f)deps/$(notdir $f).d)
 
 ifdef COMPUTE_HEADER_DEPENDENCIES
 dep_dirs := $(addsuffix deps,$(sort $(dir $(OBJECTS))))
@@ -1693,33 +1702,89 @@ $(dep_dirs):
 	mkdir -p $@
 
 missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
-else
+dep_file = $(dir $@)deps/$(notdir $@).d
+dep_args = -MF $(dep_file) -MMD -MP
+ifdef CHECK_HEADER_DEPENDENCIES
+$(error cannot compute header dependencies outside a normal build. \
+Please unset CHECK_HEADER_DEPENDENCIES and try again)
+endif
+endif
+
+ifndef COMPUTE_HEADER_DEPENDENCIES
+ifndef CHECK_HEADER_DEPENDENCIES
 dep_dirs =
 missing_dep_dirs =
+dep_args =
+endif
+endif
+
+ifdef CHECK_HEADER_DEPENDENCIES
+ifndef PRINT_HEADER_DEPENDENCIES
+missing_deps = $(filter-out $(notdir $^), \
+	$(notdir $(shell $(MAKE) -s $@ \
+		CHECK_HEADER_DEPENDENCIES=YesPlease \
+		USE_COMPUTED_HEADER_DEPENDENCIES=YesPlease \
+		PRINT_HEADER_DEPENDENCIES=YesPlease)))
+endif
 endif
 
+ASM_SRC := $(wildcard $(OBJECTS:o=S))
+ASM_OBJ := $(ASM_SRC:S=o)
+C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
+
 .SUFFIXES:
 
+ifdef PRINT_HEADER_DEPENDENCIES
+$(C_OBJ): %.o: %.c FORCE
+	echo $^
+$(ASM_OBJ): %.o: %.S FORCE
+	echo $^
+
+ifndef CHECK_HEADER_DEPENDENCIES
+$(error cannot print header dependencies during a normal build. \
+Please set CHECK_HEADER_DEPENDENCIES and try again)
+endif
+endif
+
+ifndef PRINT_HEADER_DEPENDENCIES
+ifdef CHECK_HEADER_DEPENDENCIES
+$(C_OBJ): %.o: %.c $(dep_files) FORCE
+	@set -e; echo CHECK $@; \
+	missing_deps="$(missing_deps)"; \
+	if test "$$missing_deps"; \
+	then \
+		echo missing dependencies: $$missing_deps; \
+		false; \
+	fi
+$(ASM_OBJ): %.o: %.S $(dep_files) FORCE
+	@set -e; echo CHECK $@; \
+	missing_deps="$(missing_deps)"; \
+	if test "$$missing_deps"; \
+	then \
+		echo missing dependencies: $$missing_deps; \
+		false; \
+	fi
+endif
+endif
+
+ifndef CHECK_HEADER_DEPENDENCIES
 $(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
 	$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
-%.s: %.c GIT-CFLAGS FORCE
-	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
 $(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
 	$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
+endif
 
-ifdef COMPUTE_HEADER_DEPENDENCIES
+%.s: %.c GIT-CFLAGS FORCE
+	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
+
+ifdef USE_COMPUTED_HEADER_DEPENDENCIES
 # Take advantage of gcc's on-the-fly dependency generation
 # See <http://gcc.gnu.org/gcc-3.0/features.html>.
-dep_files := $(wildcard $(foreach f,$(OBJECTS),$(dir f)deps/$(notdir $f).d))
-ifneq ($(dep_files),)
-include $(dep_files)
+dep_files_present := $(wildcard $(dep_files))
+ifneq ($(dep_files_present),)
+include $(dep_files_present)
 endif
-
-dep_file = $(dir $@)deps/$(notdir $@).d
-dep_args = -MF $(dep_file) -MMD -MP
 else
-dep_args =
-
 # Dependencies on header files, for platforms that do not support
 # the gcc -MMD option.
 #
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/12] Re: Makefile: add missing header dependency rules
  2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
                       ` (11 preceding siblings ...)
  2010-01-26 15:57     ` [PATCH 12/12] Teach Makefile to check header dependencies Jonathan Nieder
@ 2010-01-26 16:19     ` Jonathan Nieder
  12 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-26 16:19 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Jonathan Nieder wrote:

> The remainder of this series is based on a merge of master and
> patches 1-5:
[...]
> Jonathan Nieder (12):
>   Makefile: add missing header file dependencies
>   Makefile: make sure test helpers are rebuilt when headers change
>   Makefile: remove wt-status.h from LIB_H
>   Makefile: clean up http-walker.o dependency rules
>   Makefile: drop dependency on $(wildcard */*.h)
>   Makefile: transport.o depends on branch.h now
>   Makefile: rearrange dependency rules
>   Makefile: disable default implicit rules
>   Makefile: list generated object files in OBJECTS macro
>   Makefile: lazily compute header dependencies
>   Makefile: list standalone program object files in PROGRAM_OBJS
>   Teach Makefile to check header dependencies

For those would like to avoid redoing the conflict resolution (and
who wouldn’t?), this series is also available in the git repository
at

  git://repo.or.cz/git/jrn.git autodep

If you’re interested, please take a look around and try it out.  I’d
be happy to hear about any bugs you find.

Thanks again,
Jonathan

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 11/12] Makefile: list standalone program object files in PROGRAM_OBJS
  2010-01-26 15:54     ` [PATCH 11/12] Makefile: list standalone program object files in PROGRAM_OBJS Jonathan Nieder
@ 2010-01-27  9:07       ` Jonathan Nieder
  0 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-27  9:07 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Because of new commands like git-remote-http, the OBJECTS list
contains fictitious objects such as remote-http.o.  Thus any
out-of-tree rules that require all $(OBJECTS) to be buildable
are broken.  Add a list of real program objects to avoid this
problem.

To avoid duplication of effort, calculate the command list in
the PROGRAMS variable using the expansion of PROGRAM_OBJS.
This calculation occurs at the time $(PROGRAMS) is expanded,
so later additions to PROGRAM_OBJS will be reflected in it,
provided they occur before the build rules begin on line 1489.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
The previous version of this patch had a bug: I assumed that

	PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))

would add to PROGRAMS a list of command names derived from the value
of PROGRAM_OBJS at the time that line is first read; but in fact, what
matters is the value of PROGRAM_OBJS at expansion time.

More importantly, my process had a bug: I didn’t try 'make install'
before sending.  Sorry about that.  Here’s a fixed patch, at least.

I have pushed out this fix to

  git://repo.or.cz/git/jrn.git autodep-rebased
  git://repo.or.cz/git/jrn.git autodep

The former has been rerolled to include the fixed patch 11; the
latter includes a fixup commit at the end.

Thanks to Junio for the report.

 Makefile |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index df36173..630687f 100644
--- a/Makefile
+++ b/Makefile
@@ -341,6 +341,7 @@ COMPAT_CFLAGS =
 COMPAT_OBJS =
 LIB_H =
 LIB_OBJS =
+PROGRAM_OBJS =
 PROGRAMS =
 SCRIPT_PERL =
 SCRIPT_PYTHON =
@@ -390,12 +391,15 @@ EXTRA_PROGRAMS =
 
 # ... and all the rest that could be moved out of bindir to gitexecdir
 PROGRAMS += $(EXTRA_PROGRAMS)
-PROGRAMS += git-fast-import$X
-PROGRAMS += git-imap-send$X
-PROGRAMS += git-shell$X
-PROGRAMS += git-show-index$X
-PROGRAMS += git-upload-pack$X
-PROGRAMS += git-http-backend$X
+
+PROGRAM_OBJS += fast-import.o
+PROGRAM_OBJS += imap-send.o
+PROGRAM_OBJS += shell.o
+PROGRAM_OBJS += show-index.o
+PROGRAM_OBJS += upload-pack.o
+PROGRAM_OBJS += http-backend.o
+
+PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 
 TEST_PROGRAMS_NEED_X += test-chmtime
 TEST_PROGRAMS_NEED_X += test-ctype
@@ -1139,11 +1143,12 @@ else
 	REMOTE_CURL_PRIMARY = git-remote-http$X
 	REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
 	REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
-	PROGRAMS += $(REMOTE_CURL_NAMES) git-http-fetch$X
+	PROGRAM_OBJS += http-fetch.o
+	PROGRAMS += $(REMOTE_CURL_NAMES)
 	curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
 	ifeq "$(curl_check)" "070908"
 		ifndef NO_EXPAT
-			PROGRAMS += git-http-push$X
+			PROGRAM_OBJS += http-push.o
 		endif
 	endif
 	ifndef NO_EXPAT
@@ -1163,7 +1168,7 @@ endif
 EXTLIBS += -lz
 
 ifndef NO_POSIX_ONLY_PROGRAMS
-	PROGRAMS += git-daemon$X
+	PROGRAM_OBJS += daemon.o
 endif
 ifndef NO_OPENSSL
 	OPENSSL_LIBSSL = -lssl
@@ -1670,9 +1675,8 @@ git.o git.spec \
 	$(patsubst %.perl,%,$(SCRIPT_PERL)) \
 	: GIT-VERSION-FILE
 
-GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(TEST_OBJS) \
-	git.o http.o http-walker.o remote-curl.o \
-	$(patsubst git-%$X,%.o,$(PROGRAMS))
+GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
+	git.o http.o http-walker.o remote-curl.o
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 12/12] Teach Makefile to check header dependencies
  2010-01-26 15:57     ` [PATCH 12/12] Teach Makefile to check header dependencies Jonathan Nieder
@ 2010-01-31 20:42       ` Junio C Hamano
  2010-01-31 21:14         ` Jonathan Nieder
  2010-01-31 21:23         ` [PATCH 13/12] Makefile: tuck away generated makefile fragments in .depend Jonathan Nieder
  0 siblings, 2 replies; 27+ messages in thread
From: Junio C Hamano @ 2010-01-31 20:42 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Git Mailing List, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Jonathan Nieder <jrnieder@gmail.com> writes:

> Add a target to use the gcc-generated makefile snippets for
> dependencies on header files to check the hard-coded dependencies.
>
> With this patch applied, if any dependencies are missing, then
>
> 	make clean
> 	make COMPUTE_HEADER_DEPENDENCIES=YesPlease
> 	make CHECK_HEADER_DEPENDENCIES=YesPlease
>
> will produce an error message like the following:
>
> 	CHECK fast-import.o
> 	missing dependencies: exec_cmd.h
> 	make: *** [fast-import.o] Error 1
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> That’s the end of the series.  Thanks for reading.

Thanks.

Three observations:

 * "make distclean" should remove $(dep_files);

 * "deps/" should probably be ".depend/" or something less distracting;

 * I wish CHECK_HEADER_DEPENDENCIES pointed out unnecessary dependencies
   hardcoded in the Makefile.

-- >8 --
Subject: [PATCH] Makefile: "make distclean" should remove dependency files

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 45b1f54..8578b31 100644
--- a/Makefile
+++ b/Makefile
@@ -2110,7 +2110,7 @@ dist-doc:
 ### Cleaning rules
 
 distclean: clean
-	$(RM) configure
+	$(RM) configure $(dep_files)
 
 clean:
 	$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \
-- 
1.7.0.rc1.141.gd3fd2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 12/12] Teach Makefile to check header dependencies
  2010-01-31 20:42       ` Junio C Hamano
@ 2010-01-31 21:14         ` Jonathan Nieder
  2010-01-31 21:26           ` Junio C Hamano
  2010-01-31 21:23         ` [PATCH 13/12] Makefile: tuck away generated makefile fragments in .depend Jonathan Nieder
  1 sibling, 1 reply; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-31 21:14 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Git Mailing List, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Junio C Hamano wrote:

> Thanks.
> 
> Three observations:
> 
>  * "make distclean" should remove $(dep_files);

It removes $(dep_dirs) in "make clean".  Do you think they should be
kept around?  Or is this about when COMPUTE_HEADER_DEPENDENCIES is
turned off but .o.d files remain?

>  * "deps/" should probably be ".depend/" or something less distracting;

Good idea.

>  * I wish CHECK_HEADER_DEPENDENCIES pointed out unnecessary dependencies
>    hardcoded in the Makefile.

That would not be hard to do, but wouldn’t the $(GIT_OBJS): $(LIB_H)
rule create a lot of noise?

How about if it checks for duplicate dependencies and unnecessary
dependencies that are not in LIB_H?

> -- >8 --
> Subject: [PATCH] Makefile: "make distclean" should remove dependency files
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  Makefile |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 45b1f54..8578b31 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2110,7 +2110,7 @@ dist-doc:
>  ### Cleaning rules
>  
>  distclean: clean
> -	$(RM) configure
> +	$(RM) configure $(dep_files)

This couldn’t hurt, but I wonder whether it is necessary; see above.

Thanks for the feedback,
Jonathan

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 13/12] Makefile: tuck away generated makefile fragments in .depend
  2010-01-31 20:42       ` Junio C Hamano
  2010-01-31 21:14         ` Jonathan Nieder
@ 2010-01-31 21:23         ` Jonathan Nieder
  1 sibling, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-31 21:23 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Git Mailing List, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

When building with COMPUTE_HEADER_DEPENDENCIES on, save
dependency information to .depend/ instead of deps/ so it does
not show up in ‘ls’ output.  Otherwise, the extra directories can
be distracting.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Junio C Hamano wrote:

>  * "deps/" should probably be ".depend/" or something less distracting;

Good idea.  Here goes...

 Makefile |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 45b1f54..c939139 100644
--- a/Makefile
+++ b/Makefile
@@ -1692,15 +1692,15 @@ XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
 
-dep_files := $(foreach f,$(OBJECTS),$(dir $f)deps/$(notdir $f).d)
+dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
 
 ifdef COMPUTE_HEADER_DEPENDENCIES
-dep_dirs := $(addsuffix deps,$(sort $(dir $(OBJECTS))))
+dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
 $(dep_dirs):
 	mkdir -p $@
 
 missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
-dep_file = $(dir $@)deps/$(notdir $@).d
+dep_file = $(dir $@).depend/$(notdir $@).d
 dep_args = -MF $(dep_file) -MMD -MP
 ifdef CHECK_HEADER_DEPENDENCIES
 $(error cannot compute header dependencies outside a normal build. \
-- 
1.7.0.rc1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 12/12] Teach Makefile to check header dependencies
  2010-01-31 21:14         ` Jonathan Nieder
@ 2010-01-31 21:26           ` Junio C Hamano
  2010-01-31 21:37             ` [PATCH 14/12] Makefile: always remove .depend directories on 'make clean' Jonathan Nieder
  0 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2010-01-31 21:26 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Junio C Hamano, Git Mailing List, Johannes Schindelin,
	Erik Faye-Lund, Sverre Rabbelier, Andreas Schwab

Jonathan Nieder <jrnieder@gmail.com> writes:

> Junio C Hamano wrote:
> ...
>> Three observations:
>> 
>>  * "make distclean" should remove $(dep_files);
>
> It removes $(dep_dirs) in "make clean".  Do you think they should be
> kept around?  Or is this about when COMPUTE_HEADER_DEPENDENCIES is
> turned off but .o.d files remain?

Yes, the last one.  After playing around, with or without COMPUTE/CHECK,
and then making a final build, it would be nice if "make distclean"
removed all the intermediate build products without the same special
"debug build" options (and without COMPUTE, dep_dirs is empty so nothing
is removed).  It is also fine if "make clean" did so.

>>  * I wish CHECK_HEADER_DEPENDENCIES pointed out unnecessary dependencies
>>    hardcoded in the Makefile.
>
> That would not be hard to do, but wouldn’t the $(GIT_OBJS): $(LIB_H)
> rule create a lot of noise?
>
> How about if it checks for duplicate dependencies and unnecessary
> dependencies that are not in LIB_H?

That would be ideal, I think.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 14/12] Makefile: always remove .depend directories on 'make clean'
  2010-01-31 21:26           ` Junio C Hamano
@ 2010-01-31 21:37             ` Jonathan Nieder
  0 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2010-01-31 21:37 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Git Mailing List, Johannes Schindelin, Erik Faye-Lund,
	Sverre Rabbelier, Andreas Schwab

Even if COMPUTE_HEADER_DEPENDENCIES is not set, some .o.d files
might be lying around from previous builds when it was.  This
is especially likely because using the CHECK_HEADER_DEPENDENCIES
feature requires building sometimes with COMPUTE... on and
sometimes with it off.  At the end of such an exercise, to get
a blank slate, the user ought to be able to just run 'make clean'.
Make it so.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Junio C Hamano wrote:

> Yes, the last one.  After playing around, with or without COMPUTE/CHECK,
> and then making a final build, it would be nice if "make distclean"
> removed all the intermediate build products without the same special
> "debug build" options (and without COMPUTE, dep_dirs is empty so nothing
> is removed).

Another good idea. :)

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

diff --git a/Makefile b/Makefile
index c939139..93e1a92 100644
--- a/Makefile
+++ b/Makefile
@@ -1693,9 +1693,9 @@ XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
 
 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
+dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
 
 ifdef COMPUTE_HEADER_DEPENDENCIES
-dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
 $(dep_dirs):
 	mkdir -p $@
 
-- 
1.7.0.rc1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2010-01-31 21:37 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-23 14:42 [PATCH 0/5] Makefile: add missing header dependency rules Jonathan Nieder
2010-01-23 14:43 ` [PATCH 1/5] Makefile: add missing header file dependencies Jonathan Nieder
2010-01-23 14:44 ` [PATCH 2/5] Makefile: make sure test helpers are rebuilt when headers change Jonathan Nieder
2010-01-23 14:44 ` [PATCH 3/5] Makefile: remove wt-status.h from LIB_H Jonathan Nieder
2010-01-23 14:45 ` [PATCH 4/5] Makefile: clean up http-walker.o dependency rules Jonathan Nieder
2010-01-23 14:45 ` [PATCH 5/5] Makefile: drop dependency on $(wildcard */*.h) Jonathan Nieder
2010-01-25  4:44 ` [PATCH 0/5] Makefile: add missing header dependency rules Junio C Hamano
2010-01-26 15:43   ` [PATCH 00/12] " Jonathan Nieder
2010-01-26 15:44     ` [PATCH 01/12] Makefile: add missing header file dependencies Jonathan Nieder
2010-01-26 15:45     ` [PATCH 02/12] Makefile: make sure test helpers are rebuilt when headers change Jonathan Nieder
2010-01-26 15:46     ` [PATCH 03/12] Makefile: remove wt-status.h from LIB_H Jonathan Nieder
2010-01-26 15:46     ` [PATCH 04/12] Makefile: clean up http-walker.o dependency rules Jonathan Nieder
2010-01-26 15:46     ` [PATCH 05/12] Makefile: drop dependency on $(wildcard */*.h) Jonathan Nieder
2010-01-26 15:47     ` [PATCH 06/12] Makefile: transport.o depends on branch.h now Jonathan Nieder
2010-01-26 15:49     ` [PATCH 07/12] Makefile: rearrange dependency rules Jonathan Nieder
2010-01-26 15:51     ` [PATCH 08/12] Makefile: disable default implicit rules Jonathan Nieder
2010-01-26 15:52     ` [PATCH 09/12] Makefile: list generated object files in OBJECTS Jonathan Nieder
2010-01-26 15:52     ` [PATCH 10/12] Makefile: lazily compute header dependencies Jonathan Nieder
2010-01-26 15:54     ` [PATCH 11/12] Makefile: list standalone program object files in PROGRAM_OBJS Jonathan Nieder
2010-01-27  9:07       ` [PATCH v2 " Jonathan Nieder
2010-01-26 15:57     ` [PATCH 12/12] Teach Makefile to check header dependencies Jonathan Nieder
2010-01-31 20:42       ` Junio C Hamano
2010-01-31 21:14         ` Jonathan Nieder
2010-01-31 21:26           ` Junio C Hamano
2010-01-31 21:37             ` [PATCH 14/12] Makefile: always remove .depend directories on 'make clean' Jonathan Nieder
2010-01-31 21:23         ` [PATCH 13/12] Makefile: tuck away generated makefile fragments in .depend Jonathan Nieder
2010-01-26 16:19     ` [PATCH 00/12] Re: Makefile: add missing header dependency rules Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).