2008/10/26

Make eCos compile quietly

It would be nice that eCos offers an option to build quietly.
eCos Makefiles always print out the very long GCC command line to build every single file. This may lead to leave warning messages unnoticed, buried under the numerous lines of regular GCC option switches:

arm-elf-gcc -c  -I/tmp/build/ecos_build/../ecos_install/include -I/tmp/ecos/packages/infra/current -I/tmp/ecos/packages/infra/current/src -I/tmp/ecos/packages/infra/current/tests -I. -I/tmp/ecos/packages/infra/current/src/ -finline-limit=7000 -g -O0 -Wall -Wpointer-arith  -Wno-inline -Wundef -Woverloaded-virtual -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions   -Wp,-MD,src/delete.tmp -o src/infra_delete.o /tmp/ecos/packages/infra/current/src/delete.cxx
arm-elf-gcc -c  -I/tmp/build/ecos_build/../ecos_install/include -I/tmp/ecos/packages/infra/current -I/tmp/ecos/packages/infra/current/src -I/tmp/ecos/packages/infra/current/tests -I. -I/tmp/ecos/packages/infra/current/src/ -finline-limit=7000 -g -O0 -Wall -Wpointer-arith -Wstrict-prototypes -Wno-inline -Wundef  -ffunction-sections -fdata-sections  -fno-exceptions   -Wp,-MD,src/eprintf.tmp -o src/infra_eprintf.o /tmp/ecos/packages/infra/current/src/eprintf.c
arm-elf-gcc -c  -I/tmp/build/ecos_build/../ecos_install/include -I/tmp/ecos/packages/infra/current -I/tmp/ecos/packages/infra/current/src -I/tmp/ecos/packages/infra/current/tests -I. -I/tmp/ecos/packages/infra/current/src/ -finline-limit=7000 -g -O0 -Wall -Wpointer-arith  -Wno-inline -Wundef -Woverloaded-virtual -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions   -Wp,-MD,src/pure.tmp -o src/infra_pure.o /tmp/ecos/packages/infra/current/src/pure.cxx

The following patch tells eCos to build quielty, only showing the source files being compiled and linked up:

 [CC] infra/current/src/delete.cxx
 [CC] infra/current/src/eprintf.c
 [CC] infra/current/src/pure.cxx

To restore the original behaviour, simply runs make from within the eCos build tree with the VERBOSE=1 option.

Note that the patch requires to modify several files. If you use another processor but an ARM, you may need to tweak other files, using the same rules.

Index: ecos/host/tools/configtool/common/common/build.cxx
===================================================================
--- ecos/host/tools/configtool/common/common/build.cxx (revision 1925)
+++ ecos/host/tools/configtool/common/common/build.cxx (revision 4424)
@@ -454,7 +454,12 @@
 		fprintf (stream, "OBJECTS := $(OBJECTS:.c=.o.d)\n");
 		fprintf (stream, "OBJECTS := $(OBJECTS:.S=.o.d)\n\n");
 		fprintf (stream, "$(LIBRARY).stamp: $(OBJECTS)\n");
+		fprintf (stream, "ifeq ($(VERBOSE),1)\n");
 		fprintf (stream, "\t$(AR) rcs $(PREFIX)/lib/$(@:.stamp=) $(foreach obj,$?,$(dir $(obj))$(OBJECT_PREFIX)_$(notdir $(obj:.o.d=.o)))\n");
+		fprintf (stream, "else\n");
+		fprintf (stream, "\t@echo \" [AR] $(subst $(REPOSITORY)/,,$(LIBRARY))\"\n");
+		fprintf (stream, "\t@$(AR) rcs $(PREFIX)/lib/$(@:.stamp=) $(foreach obj,$?,$(dir $(obj))$(OBJECT_PREFIX)_$(notdir $(obj:.o.d=.o)))\n");
+		fprintf (stream, "endif\n");
 		fprintf (stream, "\t@cat $^ > $(@:.stamp=.deps)\n");
 		fprintf (stream, "\t@touch $@\n\n");
 	}	
@@ -560,16 +565,28 @@
 	fprintf (stream, "build: headers $(PREFIX)/include/pkgconf/ecos.mak\n");
 	for (make = 0; make < info_make_vector.size (); make++) { // for each make
 		if (info_make_vector [make].loadable->makes [info_make_vector [make].make].priority < 100) { // if priority higher than default complilation
+			fprintf (stream, "ifeq ($(VERBOSE),1)\n");
 			fprintf (stream, "\t$(MAKE) -r -C %s %s\n", info_make_vector [make].loadable->directory.c_str (), resolve_tokens (info_make_vector [make].loadable->makes [info_make_vector [make].make].target).c_str ());
+			fprintf (stream, "else\n");
+			fprintf (stream, "\t@$(MAKE) -r -C %s %s\n", info_make_vector [make].loadable->directory.c_str (), resolve_tokens (info_make_vector [make].loadable->makes [info_make_vector [make].make].target).c_str ());
+			fprintf (stream, "endif\n");
 		}
 	}
 	for (loadable = 0; loadable < info_vector.size (); loadable++) { // for each buildable loaded package
 		const std::string source_path = info_vector [loadable].directory;
+		fprintf (stream, "ifeq ($(VERBOSE),1)\n");
 		fprintf (stream, "\t$(MAKE) -r -C %s $@\n", source_path.c_str ());
+		fprintf (stream, "else\n");
+		fprintf (stream, "\t@$(MAKE) -r -C %s $@\n", source_path.c_str ());
+		fprintf (stream, "endif\n");
 	}
 	for (make = 0; make < info_make_vector.size (); make++) { // for each make
 		if (info_make_vector [make].loadable->makes [info_make_vector [make].make].priority >= 100) { // if priority lower than or equal to default complilation
+			fprintf (stream, "ifeq ($(VERBOSE),1)\n");
 			fprintf (stream, "\t$(MAKE) -r -C %s %s\n", info_make_vector [make].loadable->directory.c_str (), resolve_tokens (info_make_vector [make].loadable->makes [info_make_vector [make].make].target).c_str ());
+			fprintf (stream, "else\n");
+			fprintf (stream, "\t@$(MAKE) -r -C %s %s\n", info_make_vector [make].loadable->directory.c_str (), resolve_tokens (info_make_vector [make].loadable->makes [info_make_vector [make].make].target).c_str ());
+			fprintf (stream, "endif\n");
 		}
 	}
 	fprintf (stream, "\t@echo $@ finished\n\n");
@@ -577,21 +594,33 @@
 	fprintf (stream, "clean:\n");
 	for (loadable = 0; loadable < info_vector.size (); loadable++) { // for each buildable loaded package
 		const std::string source_path = info_vector [loadable].directory;
+		fprintf (stream, "ifeq ($(VERBOSE),1)\n");
 		fprintf (stream, "\t$(MAKE) -r -C %s $@\n", source_path.c_str ());
+		fprintf (stream, "else\n");
+		fprintf (stream, "\t@$(MAKE) -r -C %s $@\n", source_path.c_str ());
+		fprintf (stream, "endif\n");
 	}
 	fprintf (stream, "\t@echo $@ finished\n\n");
 
 	fprintf (stream, "tests: build\n");
 	for (loadable = 0; loadable < info_vector.size (); loadable++) { // for each buildable loaded package
 		const std::string source_path = info_vector [loadable].directory;
+		fprintf (stream, "ifeq ($(VERBOSE),1)\n");
 		fprintf (stream, "\t$(MAKE) -r -C %s $@\n", source_path.c_str ());
+		fprintf (stream, "else\n");
+		fprintf (stream, "\t@$(MAKE) -r -C %s $@\n", source_path.c_str ());
+		fprintf (stream, "endif\n");
 	}
 	fprintf (stream, "\t@echo $@ finished\n\n");
 
 	fprintf (stream, "headers:\n");
 	for (loadable = 0; loadable < info_vector.size (); loadable++) { // for each buildable loaded package
 		const std::string source_path = info_vector [loadable].directory;
+		fprintf (stream, "ifeq ($(VERBOSE),1)\n");
 		fprintf (stream, "\t$(MAKE) -r -C %s $@\n", source_path.c_str ());
+		fprintf (stream, "else\n");
+		fprintf (stream, "\t@$(MAKE) -r -C %s $@\n", source_path.c_str ());
+		fprintf (stream, "endif\n");
 	}
 	fprintf (stream, "\t@echo $@ finished\n\n");
Index: ecos/packages/services/memalloc/common/current/cdl/memalloc.cdl
===================================================================
--- ecos/packages/services/memalloc/common/current/cdl/memalloc.cdl (revision 1926)
+++ ecos/packages/services/memalloc/common/current/cdl/memalloc.cdl (revision 4423)
@@ -271,7 +271,8 @@
 
         make -priority 50 {
             heapgeninc.tcl : /src/heapgen.cpp
-            $(CC) $(ACTUAL_CXXFLAGS) $(INCLUDE_PATH) -Wp,-MD,heapgen.tmp -E $< -o $@
+            @echo " [CC] $(subst $(REPOSITORY)/,,$<)"
+            @$(CC) $(ACTUAL_CXXFLAGS) $(INCLUDE_PATH) -Wp,-MD,heapgen.tmp -E $< -o $@
             @sed -e '/^ *\\/d' -e "s#.*: #$@: #" heapgen.tmp > $(notdir $@).deps
             @rm heapgen.tmp
         }
@@ -283,6 +284,7 @@
         # an absolute path.
         make -priority 50 {
             heaps.cxx : heapgeninc.tcl /src/heapgen.tcl
+            @echo " [CC] $(subst $(REPOSITORY)/,,$<)"
             XPWD=`pwd` ; cd $(REPOSITORY)/$(PACKAGE)/src ; sh heapgen.tcl "$(PREFIX)" "$$XPWD"
             @cp heaps.hxx "$(PREFIX)"/include/pkgconf/heaps.hxx
             @chmod u+w "$(PREFIX)"/include/pkgconf/heaps.hxx
@@ -290,7 +292,8 @@
 
         make_object {
             heaps.o.d : heaps.cxx
-            $(CC) $(ACTUAL_CXXFLAGS) $(INCLUDE_PATH) -Wp,-MD,heaps.tmp -c -o $(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+            @echo " [CC] $(subst $(REPOSITORY)/,,$<)"
+            @$(CC) $(ACTUAL_CXXFLAGS) $(INCLUDE_PATH) -Wp,-MD,heaps.tmp -c -o $(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
             @sed -e '/^ *\\/d' -e "s#.*: #$@: #" heaps.tmp > $@
             @rm heaps.tmp
         }
Index: ecos/packages/pkgconf/rules.mak
===================================================================
--- ecos/packages/pkgconf/rules.mak (revision 1930)
+++ ecos/packages/pkgconf/rules.mak (revision 4423)
@@ -91,7 +91,12 @@
 else
 	@mkdir -p $(dir $@)
 endif
+ifeq ($(VERBOSE),1)
 	$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+else
+	@echo " [CC] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+endif
 	@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
 	@rm $(@:.o.d=.tmp)
 
@@ -101,7 +106,12 @@
 else
 	@mkdir -p $(dir $@)
 endif
+ifeq ($(VERBOSE),1)
 	$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+else
+	@echo " [CC] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+endif
 	@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
 	@rm $(@:.o.d=.tmp)
 
@@ -111,7 +121,12 @@
 else
 	@mkdir -p $(dir $@)
 endif
+ifeq ($(VERBOSE),1)
 	$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+else
+	@echo " [CC] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+endif
 	@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
 	@rm $(@:.o.d=.tmp)
 
@@ -121,7 +136,12 @@
 else
 	@mkdir -p $(dir $@)
 endif	
+ifeq ($(VERBOSE),1)
 	$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+else
+	@echo " [AS] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+endif
 	@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
 	@rm $(@:.o.d=.tmp)
 
@@ -134,7 +154,12 @@
 else
 	@mkdir -p $(dir $@)
 endif
+ifeq ($(VERBOSE),1)
 	$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+else
+	@echo " [DEP] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+endif
 	@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
 	@rm $(@:.d=.tmp)
 
@@ -144,7 +169,12 @@
 else
 	@mkdir -p $(dir $@)
 endif
+ifeq ($(VERBOSE),1)
 	$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+else
+	@echo " [DEP] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+endif
 	@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
 	@rm $(@:.d=.tmp)
 
@@ -154,7 +184,12 @@
 else
 	@mkdir -p $(dir $@)
 endif
+ifeq ($(VERBOSE),1)
 	$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+else
+	@echo " [DEP] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+endif
 	@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
 	@rm $(@:.d=.tmp)
 
@@ -164,7 +199,12 @@
 else
 	@mkdir -p $(dir $@)
 endif	
+ifeq ($(VERBOSE),1)
 	$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+else
+	@echo " [DEP] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+endif
 	@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
 	@rm $(@:.d=.tmp)
 
@@ -176,9 +216,19 @@
 	@mkdir -p $(dir $@)
 endif	
 ifneq ($(IGNORE_LINK_ERRORS),)
+ifeq ($(VERBOSE),1)
 	-$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS)
 else
+	@echo " [LD] $(subst $(REPOSITORY)/,,$<)"
+	@-$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS)
+endif
+else
+ifeq ($(VERBOSE),1)
 	$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS) 
+else
+	@echo " [LD] $(subst $(REPOSITORY)/,,$<)"
+	@$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS) 
+endif
 endif
 
 # rule to generate all tests and create a dependency file "tests.deps" by
Index: ecos/packages/hal/arm/arch/current/cdl/hal_arm.cdl
===================================================================
--- ecos/packages/hal/arm/arch/current/cdl/hal_arm.cdl (revision 1926)
+++ ecos/packages/hal/arm/arch/current/cdl/hal_arm.cdl (revision 4423)
@@ -67,8 +67,9 @@
     # n.b. grep does not behave itself under win32
     make -priority 1 {
         arm.inc : /src/hal_mk_defs.c
-        $(CC) $(ACTUAL_CFLAGS) $(INCLUDE_PATH) -Wp,-MD,arm.tmp -o hal_mk_defs.tmp -S $<
-        fgrep .equ hal_mk_defs.tmp | sed s/#// > $@
+        @echo " [CPP] $(subst $(REPOSITORY)/,,$<)"
+        @$(CC) $(ACTUAL_CFLAGS) $(INCLUDE_PATH) -Wp,-MD,arm.tmp -o hal_mk_defs.tmp -S $<
+        @fgrep .equ hal_mk_defs.tmp | sed s/#// > $@
         @echo $@ ": \\" > $(notdir $@).deps
         @tail -n +2 arm.tmp >> $(notdir $@).deps
         @echo >> $(notdir $@).deps
@@ -77,7 +78,8 @@
 
     make {
         /lib/vectors.o : /src/vectors.S
-        $(CC) -Wp,-MD,vectors.tmp $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -c -o $@ $<
+        @echo " [AS] $(subst $(REPOSITORY)/,,$<)"
+        @$(CC) -Wp,-MD,vectors.tmp $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -c -o $@ $<
         @echo $@ ": \\" > $(notdir $@).deps
         @tail -n +2 vectors.tmp >> $(notdir $@).deps
         @echo >> $(notdir $@).deps
@@ -86,7 +88,8 @@
 
     make {
         /lib/target.ld: /src/arm.ld
-        $(CC) -E -P -Wp,-MD,target.tmp -xc $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -o $@ $<
+        @echo " [CPP] $(subst $(REPOSITORY)/,,$<)"
+        @$(CC) -E -P -Wp,-MD,target.tmp -xc $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -o $@ $<
         @echo $@ ": \\" > $(notdir $@).deps
         @tail -n +2 target.tmp >> $(notdir $@).deps
         @echo >> $(notdir $@).deps
Index: ecos/packages/hal/common/current/cdl/hal.cdl
===================================================================
--- ecos/packages/hal/common/current/cdl/hal.cdl (revision 1926)
+++ ecos/packages/hal/common/current/cdl/hal.cdl (revision 4423)
@@ -71,7 +71,8 @@
 
     make -priority 250 {
         /lib/extras.o: /lib/libextras.a
-        $(CC) $(CFLAGS) -nostdlib -Wl,-r -Wl,--whole-archive -o $@ $<
+        @echo " [LD] $(subst $(REPOSITORY)/,,$<)"
+        @$(CC) $(CFLAGS) -nostdlib -Wl,-r -Wl,--whole-archive -o $@ $<
     }   

No comments: