Browse code

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

Andrei Pelinescu-Onciul authored on 09/10/2009 13:30:02
Showing 2 changed files
... ...
@@ -1901,7 +1901,8 @@ saved_fixed_vars:=	MAIN_NAME  CFG_NAME SCR_NAME \
1901 1901
 		PREFIX LOCALBASE \
1902 1902
 		TAR \
1903 1903
 		INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
1904
-		INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE
1904
+		INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE \
1905
+		Q
1905 1906
 
1906 1907
 # variable changeable at compile time
1907 1908
 # extra: prefix DESTDIR BASEDIR basedirt
... ...
@@ -52,9 +52,33 @@ endif
52 52
 
53 53
 ALLDEP+=makecfg.lst
54 54
 
55
+# returns current type: "" core/unknown, "M" module, "L" libray, "U" util
56
+crt_type=$(if $(MOD_NAME),M,$(if $(LIB_NAME),L,$(if $(UTIL_NAME),U)))
57
+
58
+cmd_CC=$(CC) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) -c $< -o $@
59
+cmd_LD=$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(ALL_LIBS) $(SER_RPATH) \
60
+	-o $(NAME)
61
+
62
+# what will be displayed if quiet==silent
63
+silent_cmd_CC=CC ($(CC)) [$(strip $(crt_type) $(NAME))]		$@
64
+silent_cmd_LD=LD ($(LD)) [$(strip $(crt_type) $(NAME))]		$@
65
+
66
+ifneq (,$(filter 1 yes on, $(Q) $(QUIET)))
67
+quiet=silent
68
+Q=1
69
+else
70
+Q=0
71
+quiet=verbose
72
+endif
73
+
74
+quote:= "
75
+escall= $(subst $$,$$$$,$(subst $(quote),\$(quote),$1))
76
+exec_cmd= $(if $($(quiet)_cmd_$(1)),\
77
+			@echo "$(call escall,$($(quiet)_cmd_$(1)))" ;) $(cmd_$(1))
78
+
55 79
 #implicit rules
56 80
 %.o:%.c  $(ALLDEP)
57
-	$(CC) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) -c $< -o $@
81
+	$(call exec_cmd,CC)
58 82
 
59 83
 %.d: %.c $(ALLDEP)
60 84
 	@set -e; $(MKDEP) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) $<\
... ...
@@ -149,7 +173,7 @@ endif
149 149
 
150 150
 # normal rules
151 151
 $(NAME): $(objs) $(ALLDEP)
152
-	$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(ALL_LIBS) $(SER_RPATH) -o $(NAME)
152
+	$(call exec_cmd,LD)
153 153
 
154 154
 
155 155
 librpath.lst: $(ALLDEP)