{"thread":{"id":"21769","subject":"[PATCH] Makefile: determine the list of header files using a glob","startedAt":"2009-11-27T08:04:53Z","lastAt":"2010-01-07T13:22:08Z","messageCount":28,"participants":["Johannes Sixt","Mike Hommey","Johannes Schindelin","Jonathan Nieder","Junio C Hamano","Sverre Rabbelier","Andreas Schwab","Nanako Shiraishi","Erik Faye-Lund"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"128540","messageId":"4B0F8825.3040107@viscovery.net","threadId":"21769","inReplyTo":null,"subject":"[PATCH] Makefile: determine the list of header files using a glob","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-11-27T08:04:53Z","receivedAt":"2009-11-27T08:04:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <j6t@kdbg.org>\n\nThe list of header files was incomplete because a number of header files\nwere added to the code base, but were not added to the list LIB_H that we\nhave in the Makefile. This meant that no rebuild was triggered if one of\nthe missing headers was changed because we do not have automatic\ndependency tracking, either.\n\nSidestep the issue by computing the list using $(wildcard).\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n Makefile |   63 +------------------------------------------------------------\n 1 files changed, 2 insertions(+), 61 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 5a0b3d4..279c7e4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -326,7 +326,6 @@ BUILTIN_OBJS =\n BUILT_INS =\n COMPAT_CFLAGS =\n COMPAT_OBJS =\n-LIB_H =\n LIB_OBJS =\n PROGRAMS =\n SCRIPT_PERL =\n@@ -429,65 +428,7 @@ export PERL_PATH\n LIB_FILE=libgit.a\n XDIFF_LIB=xdiff/lib.a\n\n-LIB_H += advice.h\n-LIB_H += archive.h\n-LIB_H += attr.h\n-LIB_H += blob.h\n-LIB_H += builtin.h\n-LIB_H += cache.h\n-LIB_H += cache-tree.h\n-LIB_H += commit.h\n-LIB_H += compat/bswap.h\n-LIB_H += compat/cygwin.h\n-LIB_H += compat/mingw.h\n-LIB_H += csum-file.h\n-LIB_H += decorate.h\n-LIB_H += delta.h\n-LIB_H += diffcore.h\n-LIB_H += diff.h\n-LIB_H += dir.h\n-LIB_H += fsck.h\n-LIB_H += git-compat-util.h\n-LIB_H += graph.h\n-LIB_H += grep.h\n-LIB_H += hash.h\n-LIB_H += help.h\n-LIB_H += levenshtein.h\n-LIB_H += list-objects.h\n-LIB_H += ll-merge.h\n-LIB_H += log-tree.h\n-LIB_H += mailmap.h\n-LIB_H += merge-recursive.h\n-LIB_H += notes.h\n-LIB_H += object.h\n-LIB_H += pack.h\n-LIB_H += pack-refs.h\n-LIB_H += pack-revindex.h\n-LIB_H += parse-options.h\n-LIB_H += patch-ids.h\n-LIB_H += pkt-line.h\n-LIB_H += progress.h\n-LIB_H += quote.h\n-LIB_H += reflog-walk.h\n-LIB_H += refs.h\n-LIB_H += remote.h\n-LIB_H += rerere.h\n-LIB_H += revision.h\n-LIB_H += run-command.h\n-LIB_H += sha1-lookup.h\n-LIB_H += sideband.h\n-LIB_H += sigchain.h\n-LIB_H += strbuf.h\n-LIB_H += string-list.h\n-LIB_H += submodule.h\n-LIB_H += tag.h\n-LIB_H += transport.h\n-LIB_H += tree.h\n-LIB_H += tree-walk.h\n-LIB_H += unpack-trees.h\n-LIB_H += userdiff.h\n-LIB_H += utf8.h\n-LIB_H += wt-status.h\n+LIB_H = $(wildcard *.h */*.h compat/*/*.h)\n\n LIB_OBJS += abspath.o\n LIB_OBJS += advice.o\n@@ -1611,7 +1552,7 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n\n $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)\n-$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)\n+$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H)\n builtin-revert.o wt-status.o: wt-status.h\n\n $(LIB_FILE): $(LIB_OBJS)\n-- \n1.6.6.rc0.43.g50037\n"},{"id":"128543","messageId":"20091127082624.GA19875@glandium.org","threadId":"21769","inReplyTo":"4B0F8825.3040107@viscovery.net","subject":"Re: [PATCH] Makefile: determine the list of header files using a glob","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2009-11-27T08:26:24Z","receivedAt":"2009-11-27T08:26:24Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Fri, Nov 27, 2009 at 09:04:53AM +0100, Johannes Sixt wrote:\n> From: Johannes Sixt <j6t@kdbg.org>\n> \n> The list of header files was incomplete because a number of header files\n> were added to the code base, but were not added to the list LIB_H that we\n> have in the Makefile. This meant that no rebuild was triggered if one of\n> the missing headers was changed because we do not have automatic\n> dependency tracking, either.\n> \n> Sidestep the issue by computing the list using $(wildcard).\n\nI don't know if the current Makefile works with Solaris' make, or if GNU\nmake has to be used, but $(wildcard) is definitely not supported by\nSolaris' make.\n\nMike\n"},{"id":"128546","messageId":"4B0F92E7.8090403@viscovery.net","threadId":"21769","inReplyTo":"20091127082624.GA19875@glandium.org","subject":"Re: [PATCH] Makefile: determine the list of header files using a glob","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-11-27T08:50:47Z","receivedAt":"2009-11-27T08:50:47Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Mike Hommey schrieb:\n> I don't know if the current Makefile works with Solaris' make,...\n\nNo, it doesn't. You have to use GNU make anyway.\n\n-- Hannes\n"},{"id":"128547","messageId":"20091127085802.GA21217@glandium.org","threadId":"21769","inReplyTo":"4B0F92E7.8090403@viscovery.net","subject":"Re: [PATCH] Makefile: determine the list of header files using a glob","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2009-11-27T08:58:02Z","receivedAt":"2009-11-27T08:58:02Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Fri, Nov 27, 2009 at 09:50:47AM +0100, Johannes Sixt wrote:\n> Mike Hommey schrieb:\n> > I don't know if the current Makefile works with Solaris' make,...\n> \n> No, it doesn't. You have to use GNU make anyway.\n\nThen it's fine. But shouldn't that be noted somewhere, like in the\nINSTALL file ?\n\nMike\n"},{"id":"128552","messageId":"alpine.DEB.1.00.0911271033460.4521@intel-tinevez-2-302","threadId":"21769","inReplyTo":"4B0F8825.3040107@viscovery.net","subject":"Re: [PATCH] Makefile: determine the list of header files using a glob","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-11-27T09:36:17Z","receivedAt":"2009-11-27T09:36:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 27 Nov 2009, Johannes Sixt wrote:\n\n> From: Johannes Sixt <j6t@kdbg.org>\n> \n> The list of header files was incomplete because a number of header files\n> were added to the code base, but were not added to the list LIB_H that we\n> have in the Makefile. This meant that no rebuild was triggered if one of\n> the missing headers was changed because we do not have automatic\n> dependency tracking, either.\n> \n> Sidestep the issue by computing the list using $(wildcard).\n\nFunny; I thought that not all header files are library header files, i.e. \nnot all header changes should trigger a full new build of libgit.a.\n\nAm I wrong?\n\nCiao,\nDscho\n\nP.S.: Something that comes to mind is the http.h header, which should \nreally be independent of libgit.a.  Which reminds me: do we _still_ tell \nlibgit.a at _compile time_ whether git-remote-http is compiled with cURL?\n"},{"id":"128579","messageId":"20091127174558.GA3461@progeny.tock","threadId":"21769","inReplyTo":"alpine.DEB.1.00.0911271033460.4521@intel-tinevez-2-302","subject":"[PATCH/RFC 0/2] Lazily generate header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-27T17:45:58Z","receivedAt":"2009-11-27T17:45:58Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Johannes Schindelin wrote:\n\n> Funny; I thought that not all header files are library header files, i.e. \n> not all header changes should trigger a full new build of libgit.a.\n\nMaybe something like this could help?\n\nJonathan Nieder (2):\n  Makefile: use target-specific variable to pass flags to cc\n  Makefile: automatically track header dependencies\n\n .gitignore |    1 +\n Makefile   |   46 +++++++++++++++++++++++++++++-----------------\n 2 files changed, 30 insertions(+), 17 deletions(-)\n"},{"id":"128580","messageId":"20091127174932.GB3461@progeny.tock","threadId":"21769","inReplyTo":"20091127174558.GA3461@progeny.tock","subject":"[PATCH/RFC 1/2] Makefile: use target-specific variable to pass flags to cc","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-27T17:49:33Z","receivedAt":"2009-11-27T17:49:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Remove some duplicated Makefile code by reusing the %.o: %.c rule\neven for objects that need to be built with special flags.  This\nmakes the relevant -D parameters more prominent on the command\nline and means any changes to the rules for compilation only have\nto happen in one place.\n\nTarget-specific variables have been supported in GNU make since\nversion 3.77 from 1998.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n Makefile |   31 +++++++++++++++----------------\n 1 files changed, 15 insertions(+), 16 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 5a0b3d4..ed0f461 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1440,19 +1440,18 @@ strip: $(PROGRAMS) git$X\n \t$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X\n \n git.o: git.c common-cmds.h GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n-\t\t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n-\t\t$(ALL_CFLAGS) -o $@ -c $(filter %.c,$^)\n+git.o: ALL_CFLAGS += -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n+\t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"'\n \n git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \\\n \t\t$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)\n \n builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \\\n-\t\t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n-\t\t'-DGIT_MAN_PATH=\"$(mandir_SQ)\"' \\\n-\t\t'-DGIT_INFO_PATH=\"$(infodir_SQ)\"' $<\n+builtin-help.o: ALL_CFLAGS += \\\n+\t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n+\t'-DGIT_MAN_PATH=\"$(mandir_SQ)\"' \\\n+\t'-DGIT_INFO_PATH=\"$(infodir_SQ)\"'\n \n $(BUILT_INS): git$X\n \t$(QUIET_BUILT_IN)$(RM) $@ && \\\n@@ -1568,24 +1567,24 @@ git.o git.spec \\\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n \n exec_cmd.o: exec_cmd.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \\\n-\t\t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n-\t\t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n-\t\t'-DPREFIX=\"$(prefix_SQ)\"' \\\n-\t\t$<\n+exec_cmd.o: ALL_CFLAGS += \\\n+\t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n+\t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n+\t'-DPREFIX=\"$(prefix_SQ)\"'\n \n builtin-init-db.o: builtin-init-db.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ)\"' $<\n+builtin-init-db.o: ALL_CFLAGS += \\\n+\t-DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ)\"'\n \n config.o: config.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"' $<\n+config.o: ALL_CFLAGS += -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n \n http.o: http.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='\"git/$(GIT_VERSION)\"' $<\n+http.o: ALL_CFLAGS += -DGIT_USER_AGENT='\"git/$(GIT_VERSION)\"'\n \n ifdef NO_EXPAT\n http-walker.o: http-walker.c http.h GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<\n+http-walker.o: ALL_CFLAGS += -DNO_EXPAT\n endif\n \n git-%$X: %.o $(GITLIBS)\n-- \n1.6.5.3\n"},{"id":"128581","messageId":"20091127175043.GC3461@progeny.tock","threadId":"21769","inReplyTo":"20091127174558.GA3461@progeny.tock","subject":"[PATCH/RFC 2/2] Makefile: automatically compute header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-27T17:50:43Z","receivedAt":"2009-11-27T17:50:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Use the gcc -MMD -MP -MF options to generate dependency rules as a\nbyproduct when building .o files.\n\nA bit remains to be done:\n\n - add the same support to the .c.s rule\n - make this optional (not all compilers support this, and not all\n   developers necessarily want to litter the directory with .*.o.d\n   files)\n - document what gcc version introduced these options\n - find equivalent options for other compilers (e.g., Intel C,\n   SunWSPro, MSVC)\n\nbut this should give the idea.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nGood idea?  Bad idea?\n\nGood night,\nJonathan\n\n .gitignore |    1 +\n Makefile   |   15 ++++++++++++++-\n 2 files changed, 15 insertions(+), 1 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex ac02a58..c7b2736 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -170,6 +170,7 @@\n *.exe\n *.[aos]\n *.py[co]\n+.*.o.d\n *+\n /config.mak\n /autom4te.cache\ndiff --git a/Makefile b/Makefile\nindex ed0f461..af3f874 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -488,6 +488,7 @@ LIB_H += unpack-trees.h\n LIB_H += userdiff.h\n LIB_H += utf8.h\n LIB_H += wt-status.h\n+LIB_H :=\n \n LIB_OBJS += abspath.o\n LIB_OBJS += advice.o\n@@ -1559,13 +1560,23 @@ git.o git.spec \\\n \t$(patsubst %.perl,%,$(SCRIPT_PERL)) \\\n \t: GIT-VERSION-FILE\n \n+dep_file = $(dir $@).$(notdir $@).d\n+dep_args = -MF $(dep_file) -MMD -MP\n+\n %.o: %.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<\n %.s: %.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<\n %.o: %.S\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n \n+objects := $(wildcard *.o block-sha1/*.o arm/*.o ppc/*.o \\\n+\t\tcompat/*.o compat/*/*.o xdiff/*.o)\n+dep_files := $(wildcard $(foreach f,$(objects),$(dir $f).$(notdir $f).d))\n+ifneq ($(dep_files),)\n+include $(dep_files)\n+endif\n+\n exec_cmd.o: exec_cmd.c GIT-CFLAGS\n exec_cmd.o: ALL_CFLAGS += \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n@@ -1875,6 +1886,8 @@ distclean: clean\n clean:\n \t$(RM) *.o block-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n \t\t$(LIB_FILE) $(XDIFF_LIB)\n+\t$(RM) .*.o.d block-sha1/.*.o.d arm/.*.o.d ppc/.*.o.d compat/.*.o.d \\\n+\t\tcompat/*/.*.o.d xdiff/.*.o.d\n \t$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X\n \t$(RM) $(TEST_PROGRAMS)\n \t$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*\n-- \n1.6.5.3\n"},{"id":"128584","messageId":"7v7htbom95.fsf@alter.siamese.dyndns.org","threadId":"21769","inReplyTo":"20091127085802.GA21217@glandium.org","subject":"Re: [PATCH] Makefile: determine the list of header files using a glob","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-27T18:28:38Z","receivedAt":"2009-11-27T18:28:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Hommey <mh@glandium.org> writes:\n\n> On Fri, Nov 27, 2009 at 09:50:47AM +0100, Johannes Sixt wrote:\n>> Mike Hommey schrieb:\n>> > I don't know if the current Makefile works with Solaris' make,...\n>> \n>> No, it doesn't. You have to use GNU make anyway.\n>\n> Then it's fine. But shouldn't that be noted somewhere, like in the\n> INSTALL file ?\n\nSurely.  Please make it so.\n"},{"id":"128585","messageId":"7v1vjjom8z.fsf@alter.siamese.dyndns.org","threadId":"21769","inReplyTo":"alpine.DEB.1.00.0911271033460.4521@intel-tinevez-2-302","subject":"Re: [PATCH] Makefile: determine the list of header files using a glob","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-27T18:28:44Z","receivedAt":"2009-11-27T18:28:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> Sidestep the issue by computing the list using $(wildcard).\n>\n> Funny; I thought that not all header files are library header files, i.e. \n> not all header changes should trigger a full new build of libgit.a.\n>\n> Am I wrong?\n\nYou are right.\n"},{"id":"128610","messageId":"fabb9a1e0911271457k31d8addcwbbc8fd34f9aedd8c@mail.gmail.com","threadId":"21769","inReplyTo":"20091127175043.GC3461@progeny.tock","subject":"Re: [PATCH/RFC 2/2] Makefile: automatically compute header dependencies","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-11-27T22:57:01Z","receivedAt":"2009-11-27T22:57:01Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Fri, Nov 27, 2009 at 18:50, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Good idea?  Bad idea?\n\nUgh, git/git is already a horror to 'ls', adding another n files...\n:(. Which brings me back to \"if only git had a seperate src/ and maybe\n/build directories\" :P.\n\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"128613","messageId":"20091128042403.GA4006@progeny.tock","threadId":"21769","inReplyTo":"fabb9a1e0911271457k31d8addcwbbc8fd34f9aedd8c@mail.gmail.com","subject":"Re: [PATCH/RFC 2/2] Makefile: automatically compute header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-28T04:24:03Z","receivedAt":"2009-11-28T04:24:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Sverre Rabbelier wrote:\n\n> Ugh, git/git is already a horror to 'ls', adding another n files...\n> :(.\n\nThey are dotfiles, though depending on how your 'ls' works, that may or\nmay not help.\n\n> Which brings me back to \"if only git had a seperate src/ and maybe\n> /build directories\" :P.\n\nHmm, I don’t want to work on that in general, but a separate deps/\ndirectory does not sound like a bad idea at all.\n\ni.e., something vaguely like this.\n\n .gitignore |    1 +\n Makefile   |   20 ++++++++++++++++++--\n 2 files changed, 19 insertions(+), 2 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex ac02a58..803247f 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -170,6 +170,7 @@\n *.exe\n *.[aos]\n *.py[co]\n+*.o.d\n *+\n /config.mak\n /autom4te.cache\ndiff --git a/Makefile b/Makefile\nindex ed0f461..1cc149b 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -488,6 +488,7 @@ LIB_H += unpack-trees.h\n LIB_H += userdiff.h\n LIB_H += utf8.h\n LIB_H += wt-status.h\n+LIB_H :=\n \n LIB_OBJS += abspath.o\n LIB_OBJS += advice.o\n@@ -1559,13 +1560,23 @@ git.o git.spec \\\n \t$(patsubst %.perl,%,$(SCRIPT_PERL)) \\\n \t: GIT-VERSION-FILE\n \n+dep_file = $(dir $@)deps/$(notdir $@).d\n+dep_args = -MF $(dep_file) -MMD -MP\n+\n %.o: %.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<\n %.s: %.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<\n %.o: %.S\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n \n+objects := $(wildcard *.o block-sha1/*.o ppc/*.o compat/*.o \\\n+\t\tcompat/*/*.o xdiff/*.o)\n+dep_files := $(wildcard $(foreach f,$(objects),$(dir $f)deps/$(notdir $f).d))\n+ifneq ($(dep_files),)\n+include $(dep_files)\n+endif\n+\n exec_cmd.o: exec_cmd.c GIT-CFLAGS\n exec_cmd.o: ALL_CFLAGS += \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n@@ -1657,6 +1668,9 @@ TRACK_CFLAGS = $(subst ','\\'',$(ALL_CFLAGS)):\\\n              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)\n \n GIT-CFLAGS: .FORCE-GIT-CFLAGS\n+\tmkdir -p deps block-sha1/deps ppc/deps compat/deps \\\n+\t\tcompat/regex/deps compat/nedmalloc/deps compat/fnmatch/deps \\\n+\t\txdiff/deps\n \t@FLAGS='$(TRACK_CFLAGS)'; \\\n \t    if test x\"$$FLAGS\" != x\"`cat GIT-CFLAGS 2>/dev/null`\" ; then \\\n \t\techo 1>&2 \"    * new build flags or prefix\"; \\\n@@ -1873,8 +1887,10 @@ distclean: clean\n \t$(RM) configure\n \n clean:\n-\t$(RM) *.o block-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n+\t$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n \t\t$(LIB_FILE) $(XDIFF_LIB)\n+\t$(RM) -r deps block-sha1/deps ppc/deps compat/deps \\\n+\t\tcompat/*/deps xdiff/deps\n \t$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X\n \t$(RM) $(TEST_PROGRAMS)\n \t$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*\n-- \n1.6.5.3\n"},{"id":"128616","messageId":"m2bpint2yk.fsf@igel.home","threadId":"21769","inReplyTo":"20091128092948.GA8515@progeny.tock","subject":"Re: [PATCH/RFC 2/2 v3] Makefile: lazily compute header dependencies","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2009-11-28T09:26:27Z","receivedAt":"2009-11-28T09:26:27Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n>  GIT-CFLAGS: .FORCE-GIT-CFLAGS\n> +\tmkdir -p deps block-sha1/deps ppc/deps compat/deps \\\n> +\t\tcompat/regex/deps compat/nedmalloc/deps compat/fnmatch/deps \\\n> +\t\txdiff/deps\n\nIMHO the list of directories should be factored out in a variable for\neasier maintenance.\n\n> @@ -1873,8 +1898,10 @@ distclean: clean\n>  \t$(RM) configure\n>  \n>  clean:\n> -\t$(RM) *.o block-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n> +\t$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n>  \t\t$(LIB_FILE) $(XDIFF_LIB)\n> +\t$(RM) -r deps block-sha1/deps ppc/deps compat/deps \\\n> +\t\tcompat/*/deps xdiff/deps\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"128615","messageId":"20091128092948.GA8515@progeny.tock","threadId":"21769","inReplyTo":"20091127175043.GC3461@progeny.tock","subject":"[PATCH/RFC 2/2 v3] Makefile: lazily compute header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-28T09:29:48Z","receivedAt":"2009-11-28T09:29:48Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Use the gcc -MMD -MP -MF options to generate dependencies as a\nbyproduct of building .o files.\n\nThis feature has to be optional (I don’t think MSVC, for example,\nsupports anything like this), so unless someone hooks in a rule\nto check the static header dependencies for correctness, this\nwon’t help much with header dependency maintainance.  It is\nenabled by setting the COMPUTE_HEADER_DEPENDENCIES variable,\nunset by default.\n\nThe scope of the %.o: %.c pattern rule has been restricted to\nmake it easier to tell if a new object file has not been hooked\ninto the dependency generation machinery.\n\nAn unrelated fix also snuck in: the %.s: %.c pattern rule to\ngenerate an assembler listing did not have correct dependencies.\nIt is meant to be invoked by hand and should always run.\n\nTo avoid litering the build directory with even more build\nproducts, the generated Makefile fragments are squirreled away\ninto deps/ subdirectories of each directory containing object\nfiles.  These directories are currently generated as a\nside-effect of the GIT-CFLAGS rule, to guarantee they will be\navailable whenever the %.o: %.c and %.o: %.S pattern rules are\nbeing used.  This is really not ideal, especially because it\nrequires hard-coding the list of directories with objects.\n\ngcc learned the -MMD -MP -MF options in version 3.0, so most gcc\nusers should have them by now.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nI’ll send the .c.s and dependency fixes separately.\n\nThoughts? Advice?\n\nThanks,\nJonathan\n\n .gitignore |    1 +\n Makefile   |   63 ++++++++++++++++++++++++++++++++++++++++++-----------------\n 2 files changed, 46 insertions(+), 18 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex ac02a58..803247f 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -170,6 +170,7 @@\n *.exe\n *.[aos]\n *.py[co]\n+*.o.d\n *+\n /config.mak\n /autom4te.cache\ndiff --git a/Makefile b/Makefile\nindex ed0f461..fb20302 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -216,6 +216,9 @@ all::\n #   DEFAULT_EDITOR='~/bin/vi',\n #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',\n #   DEFAULT_EDITOR='\"C:\\Program Files\\Vim\\gvim.exe\" --nofork'\n+#\n+# Define COMPUTE_HEADER_DEPENDENCIES if you want to avoid rebuilding objects\n+# when an unrelated header file changes and your compiler supports it.\n \n GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE\n \t@$(SHELL_PATH) ./GIT-VERSION-GEN\n@@ -1559,12 +1562,42 @@ git.o git.spec \\\n \t$(patsubst %.perl,%,$(SCRIPT_PERL)) \\\n \t: GIT-VERSION-FILE\n \n-%.o: %.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n-%.s: %.c GIT-CFLAGS\n+GIT_OBJS := http.o http-walker.o http-push.o \\\n+\t$(LIB_OBJS) $(BUILTIN_OBJS) \\\n+\t$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o\n+\n+OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)\n+\n+ifndef COMPUTE_HEADER_DEPENDENCIES\n+$(GIT_OBJS): $(LIB_H)\n+\n+$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \\\n+\txdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h\n+\n+http.o http-walker.o http-push.o: http.h\n+\n+builtin-revert.o wt-status.o: wt-status.h\n+\n+$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(wildcard */*.h)\n+else\n+dep_files := $(wildcard $(foreach f,$(OBJECTS),$(dir $f)deps/$(notdir $f).d))\n+\n+ifneq ($(dep_files),)\n+include $(dep_files)\n+endif\n+\n+# Take advantage of gcc's dependency generation.\n+# See <http://gcc.gnu.org/gcc-3.0/features.html>.\n+dep_args = -MF $(dep_file) -MMD -MP\n+dep_file = $(dir $@)deps/$(notdir $@).d\n+endif\n+\n+$(OBJECTS): %.o: %.c GIT-CFLAGS\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<\n+%.s: %.c GIT-CFLAGS .FORCE-LISTING\n \t$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<\n-%.o: %.S\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n+$(OBJECTS): %.o: %.S GIT-CFLAGS\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<\n \n exec_cmd.o: exec_cmd.c GIT-CFLAGS\n exec_cmd.o: ALL_CFLAGS += \\\n@@ -1594,10 +1627,6 @@ git-imap-send$X: imap-send.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)\n \n-http.o http-walker.o http-push.o: http.h\n-\n-http.o http-walker.o: $(LIB_H)\n-\n git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL)\n@@ -1609,22 +1638,15 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n-$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)\n-$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)\n-builtin-revert.o wt-status.o: wt-status.h\n-\n $(LIB_FILE): $(LIB_OBJS)\n \t$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)\n \n XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \\\n \txdiff/xmerge.o xdiff/xpatience.o\n-$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \\\n-\txdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h\n \n $(XDIFF_LIB): $(XDIFF_OBJS)\n \t$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)\n \n-\n doc:\n \t$(MAKE) -C Documentation all\n \n@@ -1657,6 +1679,9 @@ TRACK_CFLAGS = $(subst ','\\'',$(ALL_CFLAGS)):\\\n              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)\n \n GIT-CFLAGS: .FORCE-GIT-CFLAGS\n+\tmkdir -p deps block-sha1/deps ppc/deps compat/deps \\\n+\t\tcompat/regex/deps compat/nedmalloc/deps compat/fnmatch/deps \\\n+\t\txdiff/deps\n \t@FLAGS='$(TRACK_CFLAGS)'; \\\n \t    if test x\"$$FLAGS\" != x\"`cat GIT-CFLAGS 2>/dev/null`\" ; then \\\n \t\techo 1>&2 \"    * new build flags or prefix\"; \\\n@@ -1873,8 +1898,10 @@ distclean: clean\n \t$(RM) configure\n \n clean:\n-\t$(RM) *.o block-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n+\t$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n \t\t$(LIB_FILE) $(XDIFF_LIB)\n+\t$(RM) -r deps block-sha1/deps ppc/deps compat/deps \\\n+\t\tcompat/*/deps xdiff/deps\n \t$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X\n \t$(RM) $(TEST_PROGRAMS)\n \t$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*\n@@ -1899,7 +1926,7 @@ endif\n .PHONY: all install clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\n .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS\n-.PHONY: .FORCE-GIT-BUILD-OPTIONS\n+.PHONY: .FORCE-GIT-BUILD-OPTIONS .FORCE-LISTING\n \n ### Check documentation\n #\n-- \n1.6.5.3\n"},{"id":"128623","messageId":"20091128114937.GA10199@progeny.tock","threadId":"21769","inReplyTo":"m2bpint2yk.fsf@igel.home","subject":"Re: [PATCH/RFC 2/2 v3] Makefile: lazily compute header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-28T11:49:37Z","receivedAt":"2009-11-28T11:49:37Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Andreas Schwab wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n\n>>  GIT-CFLAGS: .FORCE-GIT-CFLAGS\n>> +\tmkdir -p deps block-sha1/deps ppc/deps compat/deps \\\n>> +\t\tcompat/regex/deps compat/nedmalloc/deps compat/fnmatch/deps \\\n>> +\t\txdiff/deps\n> \n> IMHO the list of directories should be factored out in a variable for\n> easier maintenance.\n\nGood idea, thanks.\n\nPerhaps the the value for such a variable could be computed at build time.\ne.g.\n\ndepdirs := $(addsuffix /deps,$(sort $(dir $(OBJECTS))))\n\n>> @@ -1873,8 +1898,10 @@ distclean: clean\n>>  \t$(RM) configure\n>>  \n>>  clean:\n>> -\t$(RM) *.o block-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n>> +\t$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \\\n>>  \t\t$(LIB_FILE) $(XDIFF_LIB)\n>> +\t$(RM) -r deps block-sha1/deps ppc/deps compat/deps \\\n>> +\t\tcompat/*/deps xdiff/deps\n"},{"id":"130524","messageId":"20091230080002.GA31088@glandium.org","threadId":"21769","inReplyTo":"7v7htbom95.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Makefile: determine the list of header files using a glob","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2009-12-30T08:00:02Z","receivedAt":"2009-12-30T08:00:02Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"(Nanako's bunch of reminders reminded me of this thread)\n\nOn Fri, Nov 27, 2009 at 10:28:38AM -0800, Junio C Hamano wrote:\n> Mike Hommey <mh@glandium.org> writes:\n> \n> > On Fri, Nov 27, 2009 at 09:50:47AM +0100, Johannes Sixt wrote:\n> >> Mike Hommey schrieb:\n> >> > I don't know if the current Makefile works with Solaris' make,...\n> >> \n> >> No, it doesn't. You have to use GNU make anyway.\n> >\n> > Then it's fine. But shouldn't that be noted somewhere, like in the\n> > INSTALL file ?\n> \n> Surely.  Please make it so.\n\nI had another idea in the interim. If GNU make is necessary, why not\nmake the Makefile an explicit GNU make only Makefile, by renaming it\nGNUmakefile ?\n\nThat wouldn't remove the need to add a note in the INSTALL file, though.\n\nMike\n"},{"id":"130529","messageId":"7vd41w4zp4.fsf@alter.siamese.dyndns.org","threadId":"21769","inReplyTo":"20091230080002.GA31088@glandium.org","subject":"Re: [PATCH] Makefile: determine the list of header files using a glob","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-30T08:45:59Z","receivedAt":"2009-12-30T08:45:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Hommey <mh@glandium.org> writes:\n\n> On Fri, Nov 27, 2009 at 10:28:38AM -0800, Junio C Hamano wrote:\n>> Mike Hommey <mh@glandium.org> writes:\n>> ...\n>> > Then it's fine. But shouldn't that be noted somewhere, like in the\n>> > INSTALL file ?\n>> \n>> Surely.  Please make it so.\n>\n> I had another idea in the interim. If GNU make is necessary, why not\n> make the Makefile an explicit GNU make only Makefile, by renaming it\n> GNUmakefile ?\n>\n> That wouldn't remove the need to add a note in the INSTALL file, though.\n\nI think you answered the question yourself.\n\nPersonally, when I am dealing with other people's projects, I dislike ones\nthat do not name their own Makefile \"Makefile\", as I traditionally have\ndone my local customization by having a higher precedence Makefile\n(\"makefile\" in the old world order, or \"GNUmakefile\" for gmake) that sets\nthings up and then call into upstream \"Makefile\".  For this project, since\nI am the upstream, I do want to keep the file named \"Makefile\".\n"},{"id":"130644","messageId":"20100101090550.6117@nanako3.lavabit.com","threadId":"21769","inReplyTo":"20091127174558.GA3461@progeny.tock","subject":"Re: [PATCH/RFC 0/2] Lazily generate header dependencies","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2010-01-01T00:05:50Z","receivedAt":"2010-01-01T00:05:50Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Junio, could you tell us what happened to this thread?\n\nMakefile improvements.  No discussion.\n"},{"id":"130883","messageId":"7vwrzwnirz.fsf@alter.siamese.dyndns.org","threadId":"21769","inReplyTo":"20100101090550.6117@nanako3.lavabit.com","subject":"Re: [PATCH/RFC 0/2] Lazily generate header dependencies","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-06T01:06:56Z","receivedAt":"2010-01-06T01:06:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nanako Shiraishi <nanako3@lavabit.com> writes:\n\n> Junio, could you tell us what happened to this thread?\n>\n> Makefile improvements.  No discussion.\n\nI was mildly interested in the series, but after this:\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/133872/focus=133911\n\nthe progress seems to have stopped.\n"},{"id":"130909","messageId":"alpine.DEB.1.00.1001061024400.11013@intel-tinevez-2-302","threadId":"21769","inReplyTo":"7vwrzwnirz.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC 0/2] Lazily generate header dependencies","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-01-06T09:26:00Z","receivedAt":"2010-01-06T09:26:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 5 Jan 2010, Junio C Hamano wrote:\n\n> Nanako Shiraishi <nanako3@lavabit.com> writes:\n> \n> > Junio, could you tell us what happened to this thread?\n> >\n> > Makefile improvements.  No discussion.\n> \n> I was mildly interested in the series, but after this:\n> \n> http://thread.gmane.org/gmane.comp.version-control.git/133872/focus=133911\n> \n> the progress seems to have stopped.\n\nLike I said yesterday, I do not want to spend time chasing old threads.  \nBut if you spend just two more minutes to summarize what came out of that \nthread (two well spent minutes in the global time balance, if you ask me), \nI will gladly comment.\n\nCiao,\nDscho\n"},{"id":"130910","messageId":"20100106093642.GA10650@progeny.tock","threadId":"21769","inReplyTo":"alpine.DEB.1.00.1001061024400.11013@intel-tinevez-2-302","subject":"Re: [PATCH/RFC 0/2] Lazily generate header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-01-06T09:36:43Z","receivedAt":"2010-01-06T09:36:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nJohannes Schindelin wrote:\n> On Tue, 5 Jan 2010, Junio C Hamano wrote:\n\n>> I was mildly interested in the series, but after this:\n>> \n>> http://thread.gmane.org/gmane.comp.version-control.git/133872/focus=133911\n>> \n>> the progress seems to have stopped.\n>\n> Like I said yesterday, I do not want to spend time chasing old threads.  \n> But if you spend just two more minutes to summarize what came out of that \n> thread (two well spent minutes in the global time balance, if you ask me), \n> I will gladly comment.\n\nI received some feedback (a suggestion to tuck the makefile snippets in\na separate directory and a follow-up suggestion to make the list of\ndirectories needed for this more maintainable) but have not sent an updated\npatch yet.  Hopefully tomorrow I will have more to comment on.\n\nApologies again for the long silence,\nJonathan\n"},{"id":"130980","messageId":"20100107071305.GA11777@progeny.tock","threadId":"21769","inReplyTo":"20100101090550.6117@nanako3.lavabit.com","subject":"[PATCH v2 0/5] Lazily generate header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-01-07T07:13:05Z","receivedAt":"2010-01-07T07:13:05Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nanako Shiraishi wrote:\n> Junio, could you tell us what happened to this thread?\n> \n> Makefile improvements.  No discussion.\n\nMy bad.  The previous version was very rough because I was not sure\nyet how this could help in making the header dependency rules more\nmaintainable.  If all compilers worth using support something like\ngcc's -MD option (does MSVC?), we could switch over completely;\notherwise, we need some way to use the generated dependencies to\ncheck the static ones, or the static ones will go stale.\n\nThat is, maybe something like this.  With these patches applied,\nrunning\n\n\techo COMPUTE_HEADER_DEPENDENCIES=YesPlease >> config.mak\n\tmake clean\n\tmake\n\tmake CHECK_HEADER_DEPENDENCIES=YesPlease\n\nwill fail unless the dependency rules in the Makefile account for\nall #includes gcc noticed with the current configuration.\n\nPatch 5 is a little rough around the edges, but I am hoping it\nwill convey the idea.\n\nEnjoy,\nJonathan Nieder (5):\n  Makefile: rearrange dependency rules\n  Makefile: clear list of default rules\n  Makefile: list generated object files in OBJECTS macro\n  Makefile: lazily compute header dependencies\n  Teach Makefile to check header dependencies\n\n .gitignore |    1 +\n Makefile   |  158 +++++++++++++++++++++++++++++++++++++++++++++++++-----------\n 2 files changed, 130 insertions(+), 29 deletions(-)\n"},{"id":"130981","messageId":"20100107071605.GB11777@progeny.tock","threadId":"21769","inReplyTo":"20100107071305.GA11777@progeny.tock","subject":"[PATCH 1/5] Makefile: rearrange dependency rules","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-01-07T07:16:06Z","receivedAt":"2010-01-07T07:16:06Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Collect header dependency rules after the pattern rules to make\nit easier to modify them all at once.  No change in behavior is\nintended.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n Makefile |   26 +++++++++++++-------------\n 1 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8ce6fd7..fa08535 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1630,6 +1630,11 @@ git.o git.spec \\\n \t$(patsubst %.perl,%,$(SCRIPT_PERL)) \\\n \t: GIT-VERSION-FILE\n \n+GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) git.o http.o http-walker.o \\\n+\t$(patsubst git-%$X,%.o,$(PROGRAMS))\n+XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \\\n+\txdiff/xmerge.o xdiff/xpatience.o\n+\n %.o: %.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n %.s: %.c GIT-CFLAGS FORCE\n@@ -1637,6 +1642,14 @@ git.o git.spec \\\n %.o: %.S GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n \n+$(GIT_OBJS): $(LIB_H)\n+http.o http-walker.o http-push.o: http.h\n+$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(wildcard */*.h)\n+builtin-revert.o wt-status.o: wt-status.h\n+\n+$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \\\n+\txdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h\n+\n exec_cmd.s exec_cmd.o: ALL_CFLAGS += \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n \t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n@@ -1661,10 +1674,6 @@ git-imap-send$X: imap-send.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)\n \n-http.o http-walker.o http-push.o: http.h\n-\n-http.o http-walker.o: $(LIB_H)\n-\n git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL)\n@@ -1676,18 +1685,9 @@ git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n-$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)\n-$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)\n-builtin-revert.o wt-status.o: wt-status.h\n-\n $(LIB_FILE): $(LIB_OBJS)\n \t$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)\n \n-XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \\\n-\txdiff/xmerge.o xdiff/xpatience.o\n-$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \\\n-\txdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h\n-\n $(XDIFF_LIB): $(XDIFF_OBJS)\n \t$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)\n \n-- \n1.6.6.rc2\n"},{"id":"130982","messageId":"20100107071824.GC11777@progeny.tock","threadId":"21769","inReplyTo":"20100107071305.GA11777@progeny.tock","subject":"[PATCH 2/5] Makefile: clear list of default rules","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-01-07T07:18:25Z","receivedAt":"2010-01-07T07:18:25Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The git makefile never uses any default implicit rules.  If a\nprerequisite for one of the intended rules is missing, a default\nrule can be used in its place:\n\n\t$ make var.s\n\t    CC var.s\n\t$ rm var.c\n\t$ make var.o\n\t    as   -o var.o var.s\n\nAvoiding the default rules increases performance and avoids\nhard-to-debug behaviour.  Especially, once the scope of the\n%.o: %.c pattern rule is restricted, we should not fall back\nto the default %.o: %.c pattern rule.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n'make -d' reveals that GNU make still ponders the default rules with\nthis patch applied, though at least it does not use them any more.  Is\nit possible to set something like the make '-r' option from within a\nmakefile?\n\n Makefile |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex fa08535..9a5d897 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1635,6 +1635,8 @@ GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) git.o http.o http-walker.o \\\n XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \\\n \txdiff/xmerge.o xdiff/xpatience.o\n \n+.SUFFIXES:\n+\n %.o: %.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n %.s: %.c GIT-CFLAGS FORCE\n-- \n1.6.6.rc2\n"},{"id":"130983","messageId":"20100107071943.GD11777@progeny.tock","threadId":"21769","inReplyTo":"20100107071305.GA11777@progeny.tock","subject":"[PATCH 3/5] Makefile: add OBJECTS variable listing object files","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-01-07T07:19:43Z","receivedAt":"2010-01-07T07:19:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"To find the generated dependencies to include, we will need a\ncomprehensive list of all object file targets.  To make sure it\nis truly comprehensive, restrict the scope of the\n%.o pattern rule to only generate objects in that list.\n\nAttempts to build other object files will fail loudly:\n\n\t$ touch foo.c\n\t$ make foo.o\n\tmake: *** No rule to make target `foo.o'.  Stop.\n\nproviding a reminder to add the new object to the OBJECTS list.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n Makefile |   34 ++++++++++++++++++++--------------\n 1 files changed, 20 insertions(+), 14 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 9a5d897..87de3c3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -388,6 +388,18 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \\\n # Empty...\n EXTRA_PROGRAMS =\n \n+TEST_PROGRAMS += test-chmtime$X\n+TEST_PROGRAMS += test-ctype$X\n+TEST_PROGRAMS += test-date$X\n+TEST_PROGRAMS += test-delta$X\n+TEST_PROGRAMS += test-dump-cache-tree$X\n+TEST_PROGRAMS += test-genrandom$X\n+TEST_PROGRAMS += test-match-trees$X\n+TEST_PROGRAMS += test-parse-options$X\n+TEST_PROGRAMS += test-path-utils$X\n+TEST_PROGRAMS += test-sha1$X\n+TEST_PROGRAMS += test-sigchain$X\n+\n # ... and all the rest that could be moved out of bindir to gitexecdir\n PROGRAMS += $(EXTRA_PROGRAMS)\n PROGRAMS += git-fast-import$X\n@@ -1634,14 +1646,20 @@ GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) git.o http.o http-walker.o \\\n \t$(patsubst git-%$X,%.o,$(PROGRAMS))\n XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \\\n \txdiff/xmerge.o xdiff/xpatience.o\n+TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))\n+OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(TEST_OBJS)\n+\n+ASM_SRC := $(wildcard $(OBJECTS:o=S))\n+ASM_OBJ := $(ASM_SRC:S=o)\n+C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))\n \n .SUFFIXES:\n \n-%.o: %.c GIT-CFLAGS\n+$(C_OBJ): %.o: %.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n %.s: %.c GIT-CFLAGS FORCE\n \t$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<\n-%.o: %.S GIT-CFLAGS\n+$(ASM_OBJ): %.o: %.S GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n \n $(GIT_OBJS): $(LIB_H)\n@@ -1757,18 +1775,6 @@ endif\n \n ### Testing rules\n \n-TEST_PROGRAMS += test-chmtime$X\n-TEST_PROGRAMS += test-ctype$X\n-TEST_PROGRAMS += test-date$X\n-TEST_PROGRAMS += test-delta$X\n-TEST_PROGRAMS += test-dump-cache-tree$X\n-TEST_PROGRAMS += test-genrandom$X\n-TEST_PROGRAMS += test-match-trees$X\n-TEST_PROGRAMS += test-parse-options$X\n-TEST_PROGRAMS += test-path-utils$X\n-TEST_PROGRAMS += test-sha1$X\n-TEST_PROGRAMS += test-sigchain$X\n-\n all:: $(TEST_PROGRAMS)\n \n # GNU make supports exporting all variables by \"export\" without parameters.\n-- \n1.6.6.rc2\n"},{"id":"130984","messageId":"20100107072303.GE11777@progeny.tock","threadId":"21769","inReplyTo":"20100107071305.GA11777@progeny.tock","subject":"[PATCH 4/5] Makefile: lazily compute header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-01-07T07:23:03Z","receivedAt":"2010-01-07T07:23:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Use the gcc -MMD -MP -MF options to generate dependency rules as\na byproduct when building .o files.\n\nThis feature has to be optional (MSVC does not seem to support\nanything like this), so unfortunately it does not make the\nMakefile much easier to maintain.  The feature is enabled by the\nCOMPUTE_HEADER_DEPENDENCIES variable, which is unset by default.\n\nThe generated Makefile fragments are saved in deps/\nsubdirectories of each directory containing object files.  These\ndirectories are generated if missing at the start of each build.\nA dependency on $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))\navoids needlessly regenerating files when the directories'\ntimestamps change.\n\ngcc learned the -MMD -MP -MF options in version 3.0, so most gcc\nusers should have them by now.\n\nThe dependencies this option computes are more specific than the\nrough estimate hard-coded in the Makefile, greatly speeding up\nrebuilds when only a little-used header file has changed.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nTimings:\n\nfor arg in YesPlease \"\"\ndo\n\t{\n\t\techo NO_CURL=1\n\t\techo NO_TCLTK=1\n\t\techo NO_PERL=1\n\t\techo COMPUTE_HEADER_DEPENDENCIES=\"$arg\"\n\t} >config.mak\n\tmake\n\tmake clean\n\n\ttime -p make\n\ttouch levenshtein.h\n\ttime -p make\n\n\tmake clean\ndone >/dev/null\n\nBuild\tCOMPUTE_HEADER_DEPENDENCIES\treal\tuser\tsys\nfirst\tYesPlease\t\t\t55.06\t45.13\t5.23\nsecond\tYesPlease\t\t\t3.13\t2.04\t0.79\nfirst\t\t\t\t\t55.45\t45.49\t4.99\nsecond\t\t\t\t\t53.14\t43.19\t4.70\n\n .gitignore |    1 +\n Makefile   |   40 ++++++++++++++++++++++++++++++++++++----\n 2 files changed, 37 insertions(+), 4 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex ac02a58..803247f 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -170,6 +170,7 @@\n *.exe\n *.[aos]\n *.py[co]\n+*.o.d\n *+\n /config.mak\n /autom4te.cache\ndiff --git a/Makefile b/Makefile\nindex 87de3c3..578843c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -221,6 +221,9 @@ all::\n #   DEFAULT_EDITOR='~/bin/vi',\n #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',\n #   DEFAULT_EDITOR='\"C:\\Program Files\\Vim\\gvim.exe\" --nofork'\n+#\n+# Define COMPUTE_HEADER_DEPENDENCIES if you want to avoid rebuilding objects\n+# when an unrelated header file changes and your compiler supports it.\n \n GIT-VERSION-FILE: FORCE\n \t@$(SHELL_PATH) ./GIT-VERSION-GEN\n@@ -1653,15 +1656,38 @@ ASM_SRC := $(wildcard $(OBJECTS:o=S))\n ASM_OBJ := $(ASM_SRC:S=o)\n C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))\n \n+ifdef COMPUTE_HEADER_DEPENDENCIES\n+dep_dirs := $(addsuffix deps,$(sort $(dir $(OBJECTS))))\n+dep_dir_dep := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))\n+\n+$(dep_dirs):\n+\tmkdir -p $@\n+else\n+dep_dirs =\n+dep_dir_dep =\n+endif\n+\n .SUFFIXES:\n \n-$(C_OBJ): %.o: %.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n+$(C_OBJ): %.o: %.c GIT-CFLAGS $(dep_dir_dep)\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<\n %.s: %.c GIT-CFLAGS FORCE\n \t$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<\n-$(ASM_OBJ): %.o: %.S GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n+$(ASM_OBJ): %.o: %.S GIT-CFLAGS $(dep_dir_dep)\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<\n+\n+ifdef COMPUTE_HEADER_DEPENDENCIES\n+# Take advantage of gcc's dependency generation\n+# See <http://gcc.gnu.org/gcc-3.0/features.html>.\n+dep_files := $(wildcard $(foreach f,$(OBJECTS),$(dir f)deps/$(notdir $f).d))\n \n+ifneq ($(dep_files),)\n+include $(dep_files)\n+endif\n+\n+dep_file = $(dir $@)deps/$(notdir $@).d\n+dep_args = -MF $(dep_file) -MMD -MP\n+else\n $(GIT_OBJS): $(LIB_H)\n http.o http-walker.o http-push.o: http.h\n $(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(wildcard */*.h)\n@@ -1670,6 +1696,9 @@ builtin-revert.o wt-status.o: wt-status.h\n $(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \\\n \txdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h\n \n+dep_args =\n+endif\n+\n exec_cmd.s exec_cmd.o: ALL_CFLAGS += \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n \t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n@@ -1794,7 +1823,9 @@ test-delta$X: diff-delta.o patch-delta.o\n \n test-parse-options$X: parse-options.o\n \n+ifndef COMPUTE_HEADER_DEPENDENCIES\n test-parse-options.o: parse-options.h\n+endif\n \n .PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))\n \n@@ -1954,6 +1985,7 @@ clean:\n \t\t$(LIB_FILE) $(XDIFF_LIB)\n \t$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X\n \t$(RM) $(TEST_PROGRAMS)\n+\t$(RM) -r $(dep_dirs)\n \t$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*\n \t$(RM) -r autom4te.cache\n \t$(RM) config.log config.mak.autogen config.mak.append config.status config.cache\n-- \n1.6.6.rc2\n"},{"id":"130985","messageId":"20100107073010.GF11777@progeny.tock","threadId":"21769","inReplyTo":"20100107071305.GA11777@progeny.tock","subject":"[PATCH/RFC 5/5] Teach Makefile to check header dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-01-07T07:30:11Z","receivedAt":"2010-01-07T07:30:11Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Portability means we cannot completely switch over to\nautomatically generated dependencies on header files, since some\ncompilers do not support them.  This would seem to lead to a\ndangerous situation in which the hand-written dependency rules\nare needed for some configurations but poorly maintained because\nmost configurations do not use them.\n\nLuckily, there is a way out: as part of testing git, ask the\nbuild system to verify that the hand-written dependency rules are\nconsistent with the automatically generated ones.  This patch is\na start towards that goal.\n\nThe actual patch requires a few steps:\n\n 1. Separate out a USE_COMPUTED_HEADER_DEPENDENCIES option to\n    tell make to use the makefile snippets stored in deps/*\n    without necessarily regenerating them;\n\n 2. Add a PRINT_HEADER_DEPENDENCIES option to turn on\n    USE_COMPUTED_HEADER_DEPENDENCIES and make the %.o: %.c rule\n    print its prerequisites instead of compiling anything;\n\n 3. Add a CHECK_HEADER_DEPENDENCIES option to turn off\n    USE_COMPUTED_HEADER_DEPENDENCIES and make the %.o: %.c rule\n    check that its prerequisites includes all files listed by\n    'make -s PRINT_HEADER_DEPENDENCIES=YesPlease $@' instead of\n    compiling anything.\n\nWith this patch applied,\n\n\techo COMPUTE_HEADER_DEPENDENCIES=YesPlease >> config.mak\n\tmake clean\n\tmake\n\tmake CHECK_HEADER_DEPENDENCIES=YesPlease\n\nproduces a useful error message:\n\n\tCHECK fast-import.o\n\tmissing dependencies: exec_cmd.h\n\tmake: *** [fast-import.o] Error 1\n\nProbably we should check for missing deps/%.o.d files to avoid\nfalse negatives if some are missing.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nI look forward to your thoughts.\n\nThis is a bit clunky, but it is useful enough to detect a few problems\nwith the current dependency rules.  Patches should follow soon.\n\n Makefile |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------\n 1 files changed, 67 insertions(+), 7 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 578843c..e642a24 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -224,6 +224,8 @@ all::\n #\n # Define COMPUTE_HEADER_DEPENDENCIES if you want to avoid rebuilding objects\n # when an unrelated header file changes and your compiler supports it.\n+#\n+# Define CHECK_HEADER_DEPENDENCIES after a successful build to find problems.\n \n GIT-VERSION-FILE: FORCE\n \t@$(SHELL_PATH) ./GIT-VERSION-GEN\n@@ -1064,6 +1066,28 @@ endif\n -include config.mak.autogen\n -include config.mak\n \n+ifdef PRINT_HEADER_DEPENDENCIES\n+CHECK_HEADER_DEPENDENCIES = YesPlease\n+endif\n+\n+ifdef CHECK_HEADER_DEPENDENCIES\n+ifndef COMPUTE_HEADER_DEPENDENCIES\n+$(error checking dependencies requires build with COMPUTE_HEADER_DEPENDENCIES)\n+endif\n+endif\n+\n+ifdef COMPUTE_HEADER_DEPENDENCIES\n+ifdef CHECK_HEADER_DEPENDENCIES\n+ifdef PRINT_HEADER_DEPENDENCIES\n+USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease\n+else\n+USE_COMPUTED_HEADER_DEPENDENCIES =\n+endif\n+else\n+USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease\n+endif\n+endif\n+\n ifdef SANE_TOOL_PATH\n SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n@@ -1669,14 +1693,48 @@ endif\n \n .SUFFIXES:\n \n+ifdef CHECK_HEADER_DEPENDENCIES\n+\n+ifdef PRINT_HEADER_DEPENDENCIES\n+$(C_OBJ): %.o: %.c FORCE\n+\techo $^\n+$(ASM_OBJ): %.o: %.S FORCE\n+\techo $^\n+else\n+missing_deps = $(filter-out $^, \\\n+\t$(shell $(MAKE) -s PRINT_HEADER_DEPENDENCIES=1 $@))\n+\n+$(C_OBJ): %.o: %.c FORCE\n+\t@set -e; echo CHECK $@; \\\n+\tmissing_deps=\"$(missing_deps)\"; \\\n+\tif test \"$$missing_deps\"; \\\n+\tthen \\\n+\t\techo missing dependencies: $$missing_deps; \\\n+\t\tfalse; \\\n+\tfi\n+$(ASM_OBJ): %.o: %.S FORCE\n+\t@set -e; echo CHECK $@; \\\n+\tmissing_deps=\"$(missing_deps)\"; \\\n+\tif test \"$$missing_deps\"; \\\n+\tthen \\\n+\t\techo missing dependencies: $$missing_deps; \\\n+\t\tfalse; \\\n+\tfi\n+endif\n+\n+else\n+\n $(C_OBJ): %.o: %.c GIT-CFLAGS $(dep_dir_dep)\n \t$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<\n-%.s: %.c GIT-CFLAGS FORCE\n-\t$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<\n $(ASM_OBJ): %.o: %.S GIT-CFLAGS $(dep_dir_dep)\n \t$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<\n \n-ifdef COMPUTE_HEADER_DEPENDENCIES\n+endif\n+\n+%.s: %.c GIT-CFLAGS FORCE\n+\t$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<\n+\n+ifdef USE_COMPUTED_HEADER_DEPENDENCIES\n # Take advantage of gcc's dependency generation\n # See <http://gcc.gnu.org/gcc-3.0/features.html>.\n dep_files := $(wildcard $(foreach f,$(OBJECTS),$(dir f)deps/$(notdir $f).d))\n@@ -1684,9 +1742,6 @@ dep_files := $(wildcard $(foreach f,$(OBJECTS),$(dir f)deps/$(notdir $f).d))\n ifneq ($(dep_files),)\n include $(dep_files)\n endif\n-\n-dep_file = $(dir $@)deps/$(notdir $@).d\n-dep_args = -MF $(dep_file) -MMD -MP\n else\n $(GIT_OBJS): $(LIB_H)\n http.o http-walker.o http-push.o: http.h\n@@ -1695,7 +1750,12 @@ builtin-revert.o wt-status.o: wt-status.h\n \n $(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \\\n \txdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h\n+endif\n \n+ifdef COMPUTE_HEADER_DEPENDENCIES\n+dep_file = $(dir $@)deps/$(notdir $@).d\n+dep_args = -MF $(dep_file) -MMD -MP\n+else\n dep_args =\n endif\n \n@@ -1823,7 +1883,7 @@ test-delta$X: diff-delta.o patch-delta.o\n \n test-parse-options$X: parse-options.o\n \n-ifndef COMPUTE_HEADER_DEPENDENCIES\n+ifndef USE_COMPUTED_HEADER_DEPENDENCIES\n test-parse-options.o: parse-options.h\n endif\n \n-- \n1.6.6.rc2\n"},{"id":"130994","messageId":"40aa078e1001070522k2be6c490se5d45faffca764f1@mail.gmail.com","threadId":"21769","inReplyTo":"20100107071305.GA11777@progeny.tock","subject":"Re: [PATCH v2 0/5] Lazily generate header dependencies","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-01-07T13:22:08Z","receivedAt":"2010-01-07T13:22:08Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, Jan 7, 2010 at 8:13 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Nanako Shiraishi wrote:\n>> Junio, could you tell us what happened to this thread?\n>>\n>> Makefile improvements.  No discussion.\n>\n> My bad.  The previous version was very rough because I was not sure\n> yet how this could help in making the header dependency rules more\n> maintainable.  If all compilers worth using support something like\n> gcc's -MD option (does MSVC?), we could switch over completely;\n> otherwise, we need some way to use the generated dependencies to\n> check the static ones, or the static ones will go stale.\n\nNope, there's no support for -MD in MSVC. It does have an \"/MD\"\noption, but it means something completely different (link with\nmultithreaded DLL CRT). There IS the \"/showIncludes\" option [1], which\nshould make it possible to do some build-magic to generate the correct\ndependency-files, though.\n\n[1] http://msdn.microsoft.com/en-us/library/hdkef6tk(VS.71).aspx\n\n-- \nErik \"kusma\" Faye-Lund\n"}]}