Learning Notmuch
[notmuch-archives.git] / 04 / abcc89bdbecd1cabd53786afbad07227b1d7d1
1 Return-Path: <chris@chris-wilson.co.uk>\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 BF42E431FC0\r
6         for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 11:02:28 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id 7KscHBcn0qvN for <notmuch@notmuchmail.org>;\r
11         Sat, 21 Nov 2009 11:02:27 -0800 (PST)\r
12 Received: from orsmga101.jf.intel.com (mga06.intel.com [134.134.136.21])\r
13         by olra.theworths.org (Postfix) with ESMTP id 8B395431FAE\r
14         for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 11:02:27 -0800 (PST)\r
15 Received: from orsmga001.jf.intel.com ([10.7.209.18])\r
16         by orsmga101.jf.intel.com with ESMTP; 21 Nov 2009 11:02:19 -0800\r
17 X-ExtLoop1: 1\r
18 X-IronPort-AV: E=Sophos;i="4.47,264,1257148800"; d="scan'208";a="571844771"\r
19 Received: from unknown (HELO localhost.localdomain) ([10.255.16.192])\r
20         by orsmga001.jf.intel.com with ESMTP; 21 Nov 2009 11:02:15 -0800\r
21 From: Chris Wilson <chris@chris-wilson.co.uk>\r
22 To: notmuch@notmuchmail.org\r
23 Date: Sat, 21 Nov 2009 19:02:22 +0000\r
24 Message-Id: <1258830142-13311-1-git-send-email-chris@chris-wilson.co.uk>\r
25 X-Mailer: git-send-email 1.6.5.3\r
26 Subject: [notmuch] [PATCH] Makefile: Magic silent rules.\r
27 X-BeenThere: notmuch@notmuchmail.org\r
28 X-Mailman-Version: 2.1.12\r
29 Precedence: list\r
30 List-Id: "Use and development of the notmuch mail system."\r
31         <notmuch.notmuchmail.org>\r
32 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
33         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
34 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
35 List-Post: <mailto:notmuch@notmuchmail.org>\r
36 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
37 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
39 X-List-Received-Date: Sat, 21 Nov 2009 19:02:28 -0000\r
40 \r
41 Use the facilities of GNU make to create a magic function that will\r
42 on the first invocation print a description of how to enable verbose\r
43 compile lines and then print the quiet rule.\r
44 \r
45 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>\r
46 Signed-off-by: Carl Worth <cworth@cworth.org>\r
47 Cc: Mikhail Gusarov <dottedmag@dottedmag.net>\r
48 ---\r
49  Makefile           |   22 +++++++++++++++++++---\r
50  Makefile.local     |    4 ++--\r
51  lib/Makefile.local |    2 +-\r
52  3 files changed, 22 insertions(+), 6 deletions(-)\r
53 \r
54 diff --git a/Makefile b/Makefile\r
55 index 3fedcf1..77e70ed 100644\r
56 --- a/Makefile\r
57 +++ b/Makefile\r
58 @@ -2,6 +2,10 @@\r
59  WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum\r
60  CFLAGS=-O2\r
61  \r
62 +# Additional programs that are used during the compilation process.\r
63 +EMACS ?= emacs\r
64 +GZIP ?= gzip\r
65 +\r
66  # Additional flags that we will append to whatever the user set.\r
67  # These aren't intended for the user to manipulate.\r
68  extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)\r
69 @@ -31,14 +35,26 @@ include lib/Makefile.local\r
70  # And get user settings from the output of configure\r
71  include Makefile.config\r
72  \r
73 +# The user has not set any verbosity, default to quiet mode and inform the\r
74 +# user how to enable verbose compiles.\r
75 +ifeq ($(V),)\r
76 +quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"\r
77 +quiet = @echo $(quiet_DOC)$(eval quiet_DOC:=)"  $1     $@"; $($1)\r
78 +endif\r
79 +# The user has explicitly enabled quiet compilation.\r
80 +ifeq ($(V),0)\r
81 +quiet = @echo "  $1    $@"; $($1)\r
82 +endif\r
83 +# Otherwise, print the full command line.\r
84 +\r
85  %.o: %.cc $(all_deps)\r
86 -       $(CXX) -c $(CXXFLAGS) $< -o $@\r
87 +       $(call quiet,CXX) -c $(CXXFLAGS) $< -o $@\r
88  \r
89  %.o: %.c $(all_deps)\r
90 -       $(CC) -c $(CFLAGS) $< -o $@\r
91 +       $(call quiet,CC) -c $(CFLAGS) $< -o $@\r
92  \r
93  %.elc: %.el\r
94 -       emacs -batch -f batch-byte-compile $<\r
95 +       $(call quiet,EMACS) -batch -f batch-byte-compile $<\r
96  \r
97  .deps/%.d: %.c $(all_deps)\r
98         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \\r
99 diff --git a/Makefile.local b/Makefile.local\r
100 index 3c99624..5fd5d4f 100644\r
101 --- a/Makefile.local\r
102 +++ b/Makefile.local\r
103 @@ -20,10 +20,10 @@ notmuch_client_srcs =               \\r
104  \r
105  notmuch_client_modules = $(notmuch_client_srcs:.c=.o)\r
106  notmuch: $(notmuch_client_modules) lib/notmuch.a\r
107 -       $(CXX) $^ $(LDFLAGS) -o $@\r
108 +       $(call quiet,CXX) $^ $(LDFLAGS) -o $@\r
109  \r
110  notmuch.1.gz: notmuch.1\r
111 -       gzip --stdout notmuch.1 > notmuch.1.gz\r
112 +       $(call quiet,GZIP) --stdout $^ > $@\r
113  \r
114  install: all notmuch.1.gz\r
115         for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/share/man/man1 \\r
116 diff --git a/lib/Makefile.local b/lib/Makefile.local\r
117 index 79f7b0b..a7562c9 100644\r
118 --- a/lib/Makefile.local\r
119 +++ b/lib/Makefile.local\r
120 @@ -18,7 +18,7 @@ libnotmuch_cxx_srcs =         \\r
121  \r
122  libnotmuch_modules = $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)\r
123  $(dir)/notmuch.a: $(libnotmuch_modules)\r
124 -       $(AR) rcs $@ $^\r
125 +       $(call quiet,AR) rcs $@ $^\r
126  \r
127  SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)\r
128  CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/notmuch.a\r
129 -- \r
130 1.6.5.3\r
131 \r