[PATCH] RFC: quiet make

classic Classic list List threaded Threaded
3 messages Options
Mikhail Gusarov Mikhail Gusarov
Reply | Threaded
Open this post in threaded view
|

[PATCH] RFC: quiet make

I don't entirely like duplicating every command line in makefile,
so this patch is RFC. Someone with bigger Make-fu than mine probably
knows a better way.

Signed-off-by: Mikhail Gusarov <[hidden email]>
---
 Makefile           |   36 ++++++++++++++++++++++++++++++++++++
 Makefile.local     |   10 ++++++++++
 lib/Makefile.local |    5 +++++
 3 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index b6861e9..72a72ae 100644
--- a/Makefile
+++ b/Makefile
@@ -32,29 +32,65 @@ include lib/Makefile.local
 include Makefile.config
 
 %.o: %.cc $(all_deps)
+ifeq ($(V),1)
  $(CXX) -c $(CFLAGS) $(CXXFLAGS) $< -o $@
+else
+ @echo CXX $<
+ @$(CXX) -c $(CFLAGS) $(CXXFLAGS) $< -o $@
+endif
 
 %.o: %.c $(all_deps)
+ifeq ($(V),1)
  $(CC) -c $(CFLAGS) $< -o $@
+else
+ @echo CC $<
+ @$(CC) -c $(CFLAGS) $< -o $@
+endif
 
 %.elc: %.el
+ifeq ($(V),1)
  emacs -batch -f batch-byte-compile $<
+else
+ @echo ELCOMPILE $<
+ @emacs -batch -f batch-byte-compile $<
+endif
 
 .deps/%.d: %.c $(all_deps)
+ifeq ($(V),1)
+ set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
+ $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
+ sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+else
+ @echo DEPCXX $<
  @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
  $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
  sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
  rm -f $@.$$$$
+endif
 
 .deps/%.d: %.cc $(all_deps)
+ifeq ($(V),1)
+ set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
+ $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
+ sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+else
+ @echo DEPCC $<
  @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
  $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
  sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
  rm -f $@.$$$$
+endif
 
 DEPS := $(SRCS:%.c=.deps/%.d)
 DEPS := $(DEPS:%.cc=.deps/%.d)
 -include $(DEPS)
 
 clean:
+ifeq ($(V),1)
  rm -f $(CLEAN); rm -rf .deps
+else
+ @echo CLEAN
+ @rm -f $(CLEAN); rm -rf .deps
+endif
diff --git a/Makefile.local b/Makefile.local
index bf81c03..0addfed 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -20,10 +20,20 @@ notmuch_client_srcs = \
 
 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
 notmuch: $(notmuch_client_modules) lib/notmuch.a
+ifeq ($(V),1)
  $(CXX) $^ $(LDFLAGS) -o $@
+else
+ @echo LINK $^
+ @$(CXX) $^ $(LDFLAGS) -o $@
+endif
 
 notmuch.1.gz: notmuch.1
+ifeq ($(V),1)
  gzip --stdout notmuch.1 > notmuch.1.gz
+else
+ @echo GZIP $<
+ @gzip --stdout notmuch.1 > notmuch.1.gz
+endif
 
 install: all notmuch.1.gz
  for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/share/man/man1 \
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 79f7b0b..5a66716 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -18,7 +18,12 @@ libnotmuch_cxx_srcs = \
 
 libnotmuch_modules = $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
 $(dir)/notmuch.a: $(libnotmuch_modules)
+ifeq ($(V),1)
  $(AR) rcs $@ $^
+else
+ @echo AR $^
+ @$(AR) rcs $@ $^
+endif
 
 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
 CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/notmuch.a
--
1.6.3.3


Carl Worth-2 Carl Worth-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] RFC: quiet make

On Fri, 20 Nov 2009 19:18:27 +0600, Mikhail Gusarov <[hidden email]> wrote:
> I don't entirely like duplicating every command line in makefile,
> so this patch is RFC. Someone with bigger Make-fu than mine probably
> knows a better way.

Hi Mikhail,

Getting a quieter compile out is a great idea.

But, you're right that duplicating the command line invocations is a
problem. That sets up a fragile system where we'll end up with "make"
and "make V=1" actually doing different things.

Meanwhile, the feature I've always wanted with systems like this is to
document to the user that there's the possibility of adding a "V=1" to
the command line to get the full output.

Fortunately, I'm sitting next to Chris Wilson right now, and I know that
all I need to do is to mention the idea to him, and he'll give us a
solution that doesn't duplicate the commands, documents V=1, and will
just be a tiny change to our Makefiles.

-Carl

Mikhail Gusarov Mikhail Gusarov
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] RFC: quiet make


Twas brillig at 14:16:52 21.11.2009 UTC+01 when [hidden email] did gyre and gimble:

 CW> Meanwhile, the feature I've always wanted with systems like this is
 CW> to document to the user that there's the possibility of adding a
 CW> "V=1" to the command line to get the full output.

I have had another idea in mind which might be useful: a "header" for
silent make mode which explains what commands are run exactly, including
placeholders like $@ $^, so it is not necessary to run with make V=1 to
figure out what's going on.

--
  http://fossarchy.blogspot.com/

attachment0 (834 bytes) Download Attachment