[sr-dev] git:master: makefile: quiet output support

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Oct 9 16:48:55 CEST 2009


Module: sip-router
Branch: master
Commit: e37e8d6a6158d49aa5fa1092d91b595cf0d91e2d
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e37e8d6a6158d49aa5fa1092d91b595cf0d91e2d

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Fri Oct  9 15:30:02 2009 +0200

makefile: quiet output support

Support for quiet output (without all the flags and compile
options): make Q=1 or make QUIET=1.
It can be saved in the config (e.g. make config Q=1) and it can be
overridden any time (e.g. make utils Q=0).
Compilation is a little faster in quiet mode and the same speed as
before in normal mode.

Example module output:
CC (gcc) [M tm.so]              uac.o
LD (gcc) [M tm.so]              tm.so

Lib example:
LD (gcc) [L libbinrpc.so.0.1]           libbinrpc.so.0.1

---

 Makefile.defs  |    3 ++-
 Makefile.rules |   28 ++++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/Makefile.defs b/Makefile.defs
index f883a0b..a9bd307 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -1901,7 +1901,8 @@ saved_fixed_vars:=	MAIN_NAME  CFG_NAME SCR_NAME \
 		PREFIX LOCALBASE \
 		TAR \
 		INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
-		INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE
+		INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE \
+		Q
 
 # variable changeable at compile time
 # extra: prefix DESTDIR BASEDIR basedirt
diff --git a/Makefile.rules b/Makefile.rules
index 99042c3..55c7897 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -52,9 +52,33 @@ endif
 
 ALLDEP+=makecfg.lst
 
+# returns current type: "" core/unknown, "M" module, "L" libray, "U" util
+crt_type=$(if $(MOD_NAME),M,$(if $(LIB_NAME),L,$(if $(UTIL_NAME),U)))
+
+cmd_CC=$(CC) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) -c $< -o $@
+cmd_LD=$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(ALL_LIBS) $(SER_RPATH) \
+	-o $(NAME)
+
+# what will be displayed if quiet==silent
+silent_cmd_CC=CC ($(CC)) [$(strip $(crt_type) $(NAME))]		$@
+silent_cmd_LD=LD ($(LD)) [$(strip $(crt_type) $(NAME))]		$@
+
+ifneq (,$(filter 1 yes on, $(Q) $(QUIET)))
+quiet=silent
+Q=1
+else
+Q=0
+quiet=verbose
+endif
+
+quote:= "
+escall= $(subst $$,$$$$,$(subst $(quote),\$(quote),$1))
+exec_cmd= $(if $($(quiet)_cmd_$(1)),\
+			@echo "$(call escall,$($(quiet)_cmd_$(1)))" ;) $(cmd_$(1))
+
 #implicit rules
 %.o:%.c  $(ALLDEP)
-	$(CC) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) -c $< -o $@
+	$(call exec_cmd,CC)
 
 %.d: %.c $(ALLDEP)
 	@set -e; $(MKDEP) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) $<\
@@ -149,7 +173,7 @@ endif
 
 # normal rules
 $(NAME): $(objs) $(ALLDEP)
-	$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(ALL_LIBS) $(SER_RPATH) -o $(NAME)
+	$(call exec_cmd,LD)
 
 
 librpath.lst: $(ALLDEP)




More information about the sr-dev mailing list