--- /dev/null
+Return-Path: <amthrax@drake.mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 83F08431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 11 Apr 2012 13:38:44 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 7+rNSTTay-Po for <notmuch@notmuchmail.org>;\r
+ Wed, 11 Apr 2012 13:38:43 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id CD353431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 11 Apr 2012 13:38:43 -0700 (PDT)\r
+X-AuditID: 1209190f-b7f8a6d000000914-9a-4f85ebd3815b\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 01.EF.02324.3DBE58F4; Wed, 11 Apr 2012 16:38:43 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q3BKcgMb011757; \r
+ Wed, 11 Apr 2012 16:38:42 -0400\r
+Received: from drake.mit.edu (31-35-38.wireless.csail.mit.edu [128.31.35.38])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3BKcfbs013275\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Wed, 11 Apr 2012 16:38:42 -0400 (EDT)\r
+Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amthrax@drake.mit.edu>)\r
+ id 1SI4JM-0006Ur-KN; Wed, 11 Apr 2012 16:38:40 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] Record dependencies during build instead of before\r
+Date: Wed, 11 Apr 2012 16:38:39 -0400\r
+Message-Id: <1334176719-24781-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1333857710-24511-1-git-send-email-amdragon@mit.edu>\r
+References: <1333857710-24511-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6nrnv5dau/wepeXovrN2cyOzB6PFt1\r
+ izmAMYrLJiU1J7MstUjfLoEr49+Br0wFj8Qqrn1uYG1g3CTUxcjJISFgIrF91k02CFtM4sK9\r
+ 9WC2kMA+RonLDx26GLmA7A2MEhvWd7BAOCeZJBa1v2OEqJrPKHH+CzuIzSagIbFt/3KwuIiA\r
+ tMTOu7NZuxg5OJgF1CT+dKmAhIUF3CRW3jrCDGKzCKhKnDywEKyVV8BB4u3CB4wQRyhIPFt3\r
+ nAnE5hRwlHj5o4MZYpWDxP8lkxgnMPIvYGRYxSibklulm5uYmVOcmqxbnJyYl5dapGuil5tZ\r
+ opeaUrqJERQynJL8Oxi/HVQ6xCjAwajEw7trQqu/EGtiWXFl7iFGSQ4mJVHeqa+AQnxJ+SmV\r
+ GYnFGfFFpTmpxYcYJTiYlUR4XWa3+AvxpiRWVqUW5cOkpDlYlMR51bTe+QkJpCeWpGanphak\r
+ FsFkZTg4lCR4vzwFGipYlJqeWpGWmVOCkGbi4AQZzgM0nPsZUA1vcUFibnFmOkT+FKOilDjv\r
+ BZBmAZBERmkeXC8spl8xigO9Isx7EaSKB5gO4LpfAQ1mAhr8eTLI1cUliQgpqQbGtGCBGSWb\r
+ lr19JaZzQ2PJMY1TquvWmL47cD+pKnhWhrXTp2liEn+6/Ux/lwReN+lvXeV+c8nOD0uOCf6o\r
+ 0fewncr683Ii/w/eXxfNreJMHvqGRVoGy4RNb/kS8sI/eUX3oT0nZL8ueLjw16Xo+nNtvB83\r
+ 1Juo+n3/Petgm9iCm4beE09cumi2UomlOCPRUIu5qDgRAG2Fw77EAgAA\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 11 Apr 2012 20:38:44 -0000\r
+\r
+Previously, the makefile created dependency files in a separate, first\r
+pass. In particular, include-ing the dependency files would cause\r
+make to attempt to rebuild those files using the dependency-generation\r
+rules in the makefile. Unfortunately, this approach required obtuse\r
+rules and silently delayed the start of the build process (by quite a\r
+bit on a clean tree without any dependency files). Worse, this\r
+required the dependency files to themselves depend on all of the\r
+headers the source file depended on, which meant that, if a header\r
+file was removed, the depedency file could not be updated because of a\r
+missing dependency (!), which would cause make to silently fail.\r
+\r
+This patch eliminates the dependency generation rules and instead\r
+generates dependency files as a side-effect of the regular build rule.\r
+On the first build, we don't need to know the dependencies beforehand;\r
+the object file doesn't exist, so it will be built anyway. On\r
+subsequent builds, if a header file is updated, the dependency rules\r
+generated by the previous build will force a rebuild. If a source\r
+file is updated, the dependency rules may be stale, but it doesn't\r
+matter because the updated source file will force a rebuild.\r
+\r
+In the final case above, the stale dependency rules may refer to a\r
+header file that no longer exists but is also no longer needed. In\r
+order to prevent this from breaking the build, we also pass gcc the\r
+-MP option, which generates phony targets for every depended-on header\r
+file, so make won't complain if it can't find them during a later\r
+build.\r
+---\r
+Sorry, the previous version of this patch was corrupted. Hopefully\r
+this one will be correct.\r
+\r
+ Makefile.local | 18 ++++--------------\r
+ 1 files changed, 4 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/Makefile.local b/Makefile.local\r
+index 1131dea..525eda0 100644\r
+--- a/Makefile.local\r
++++ b/Makefile.local\r
+@@ -256,22 +256,12 @@ endif\r
+ quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))\r
+ \r
+ %.o: %.cc $(global_deps)\r
++ @mkdir -p .deps/$(@D)\r
++ $(call quiet,CXX $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d\r
+- $(call quiet,CXX $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@\r
+ \r
+ %.o: %.c $(global_deps)\r
++ @mkdir -p .deps/$(@D)\r
++ $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d\r
+- $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@\r
+-\r
+-.deps/%.d: %.c $(global_deps)\r
+- @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \\r
+- $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \\r
+- sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \\r
+- rm -f $@.$$$$\r
+-\r
+-.deps/%.d: %.cc $(global_deps)\r
+- @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \\r
+- $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \\r
+- sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \\r
+- rm -f $@.$$$$\r
+ \r
+ .PHONY : clean\r
+ clean:\r
+-- \r
+1.7.9.1\r
+\r