Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / 98 / cc631d2a31c6dd2acc6bfe6766b1a39c63a557
1 Return-Path: <amthrax@drake.mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 83F08431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 11 Apr 2012 13:38:44 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 7+rNSTTay-Po for <notmuch@notmuchmail.org>;\r
16         Wed, 11 Apr 2012 13:38:43 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
18         [18.9.25.15])\r
19         by olra.theworths.org (Postfix) with ESMTP id CD353431FAE\r
20         for <notmuch@notmuchmail.org>; Wed, 11 Apr 2012 13:38:43 -0700 (PDT)\r
21 X-AuditID: 1209190f-b7f8a6d000000914-9a-4f85ebd3815b\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 01.EF.02324.3DBE58F4; Wed, 11 Apr 2012 16:38:43 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q3BKcgMb011757; \r
27         Wed, 11 Apr 2012 16:38:42 -0400\r
28 Received: from drake.mit.edu (31-35-38.wireless.csail.mit.edu [128.31.35.38])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3BKcfbs013275\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Wed, 11 Apr 2012 16:38:42 -0400 (EDT)\r
34 Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amthrax@drake.mit.edu>)\r
36         id 1SI4JM-0006Ur-KN; Wed, 11 Apr 2012 16:38:40 -0400\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH v2] Record dependencies during build instead of before\r
40 Date: Wed, 11 Apr 2012 16:38:39 -0400\r
41 Message-Id: <1334176719-24781-1-git-send-email-amdragon@mit.edu>\r
42 X-Mailer: git-send-email 1.7.9.1\r
43 In-Reply-To: <1333857710-24511-1-git-send-email-amdragon@mit.edu>\r
44 References: <1333857710-24511-1-git-send-email-amdragon@mit.edu>\r
45 X-Brightmail-Tracker:\r
46  H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6nrnv5dau/wepeXovrN2cyOzB6PFt1\r
47         izmAMYrLJiU1J7MstUjfLoEr49+Br0wFj8Qqrn1uYG1g3CTUxcjJISFgIrF91k02CFtM4sK9\r
48         9WC2kMA+RonLDx26GLmA7A2MEhvWd7BAOCeZJBa1v2OEqJrPKHH+CzuIzSagIbFt/3KwuIiA\r
49         tMTOu7NZuxg5OJgF1CT+dKmAhIUF3CRW3jrCDGKzCKhKnDywEKyVV8BB4u3CB4wQRyhIPFt3\r
50         nAnE5hRwlHj5o4MZYpWDxP8lkxgnMPIvYGRYxSibklulm5uYmVOcmqxbnJyYl5dapGuil5tZ\r
51         opeaUrqJERQynJL8Oxi/HVQ6xCjAwajEw7trQqu/EGtiWXFl7iFGSQ4mJVHeqa+AQnxJ+SmV\r
52         GYnFGfFFpTmpxYcYJTiYlUR4XWa3+AvxpiRWVqUW5cOkpDlYlMR51bTe+QkJpCeWpGanphak\r
53         FsFkZTg4lCR4vzwFGipYlJqeWpGWmVOCkGbi4AQZzgM0nPsZUA1vcUFibnFmOkT+FKOilDjv\r
54         BZBmAZBERmkeXC8spl8xigO9Isx7EaSKB5gO4LpfAQ1mAhr8eTLI1cUliQgpqQbGtGCBGSWb\r
55         lr19JaZzQ2PJMY1TquvWmL47cD+pKnhWhrXTp2liEn+6/Ux/lwReN+lvXeV+c8nOD0uOCf6o\r
56         0fewncr683Ii/w/eXxfNreJMHvqGRVoGy4RNb/kS8sI/eUX3oT0nZL8ueLjw16Xo+nNtvB83\r
57         1Juo+n3/Petgm9iCm4beE09cumi2UomlOCPRUIu5qDgRAG2Fw77EAgAA\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Wed, 11 Apr 2012 20:38:44 -0000\r
71 \r
72 Previously, the makefile created dependency files in a separate, first\r
73 pass.  In particular, include-ing the dependency files would cause\r
74 make to attempt to rebuild those files using the dependency-generation\r
75 rules in the makefile.  Unfortunately, this approach required obtuse\r
76 rules and silently delayed the start of the build process (by quite a\r
77 bit on a clean tree without any dependency files).  Worse, this\r
78 required the dependency files to themselves depend on all of the\r
79 headers the source file depended on, which meant that, if a header\r
80 file was removed, the depedency file could not be updated because of a\r
81 missing dependency (!), which would cause make to silently fail.\r
82 \r
83 This patch eliminates the dependency generation rules and instead\r
84 generates dependency files as a side-effect of the regular build rule.\r
85 On the first build, we don't need to know the dependencies beforehand;\r
86 the object file doesn't exist, so it will be built anyway.  On\r
87 subsequent builds, if a header file is updated, the dependency rules\r
88 generated by the previous build will force a rebuild.  If a source\r
89 file is updated, the dependency rules may be stale, but it doesn't\r
90 matter because the updated source file will force a rebuild.\r
91 \r
92 In the final case above, the stale dependency rules may refer to a\r
93 header file that no longer exists but is also no longer needed.  In\r
94 order to prevent this from breaking the build, we also pass gcc the\r
95 -MP option, which generates phony targets for every depended-on header\r
96 file, so make won't complain if it can't find them during a later\r
97 build.\r
98 ---\r
99 Sorry, the previous version of this patch was corrupted.  Hopefully\r
100 this one will be correct.\r
101 \r
102  Makefile.local |   18 ++++--------------\r
103  1 files changed, 4 insertions(+), 14 deletions(-)\r
104 \r
105 diff --git a/Makefile.local b/Makefile.local\r
106 index 1131dea..525eda0 100644\r
107 --- a/Makefile.local\r
108 +++ b/Makefile.local\r
109 @@ -256,22 +256,12 @@ endif\r
110  quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))\r
111  \r
112  %.o: %.cc $(global_deps)\r
113 +       @mkdir -p .deps/$(@D)\r
114 +       $(call quiet,CXX $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d\r
115 -       $(call quiet,CXX $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@\r
116  \r
117  %.o: %.c $(global_deps)\r
118 +       @mkdir -p .deps/$(@D)\r
119 +       $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d\r
120 -       $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@\r
121 -\r
122 -.deps/%.d: %.c $(global_deps)\r
123 -       @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \\r
124 -       $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \\r
125 -       sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \\r
126 -       rm -f $@.$$$$\r
127 -\r
128 -.deps/%.d: %.cc $(global_deps)\r
129 -       @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \\r
130 -       $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \\r
131 -       sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \\r
132 -       rm -f $@.$$$$\r
133  \r
134  .PHONY : clean\r
135  clean:\r
136 -- \r
137 1.7.9.1\r
138 \r