开发者

Suppress all make output except for errors and warnings

I have a makefile which builds a project composed of many files which all need to be built.

To make matters more complicated, I have a number of included directories in each call to gcc (so each call to gcc looks long on the command line).

I'd like to suppress all output except for errors and warnings (so that I can actually see them when make runs!)

Is t开发者_开发技巧here any way to do this?


make -s should do what you're after a bit more neatly. I don't know of a way to force it on the makefiles, but the GNU manual might have one.

Failing that you could check the Linux kernel build system, since that seems to automatically hide stdout.


By adding a "@" to the front of a command, the command line string is suppressed e.g. from

$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c
        $(CC) -c $(CFLAGS) $< -o $@

to

$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c
        @$(CC) -c $(CFLAGS) $< -o $@

will take

make[1]: Entering directory `.../libraries/libgcdc/build'
/home/crowe/arm-tools/gcc-arm-none-eabi-4_6-2012q2/bin/arm-none-eabi-gcc -c -Wall -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Werror-implicit-function-declaration -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -g -O0 -D DEBUG -I.. -I../include -I../../libchip_sam3s -I../../libboard_arm_demo -I../../libboard_generic -I../../libusb/include -Dsam3s4 -DTRACE_LEVEL=5 -Dprintf=iprintf ../source/hid_callbacks.c -o debug_sam3s_svn2/hid_callbacks.o
make[1]: Leaving directory ` .../libraries/libgcdc/build'

to

make[1]: Entering directory `.../libraries/libgcdc/build'
make[1]: Leaving directory `.../libraries/libgcdc/build'


You can also force the -s option as suggested by PaulW directly in the Makefile. Just add:

.SILENT:


Depending on how "errors and warnings" are reported ...

make > /dev/null

That will redirect all STDOUT (Standard Output) from the make command (and thus all sub-processes it spawns) to the endless bit-bucket of nothingness. This may be too greedy though, as some programs use STDOUT (and not STDERR) to report warnings.

I do not know of a way globally change STDOUT of all sub-processes from within the context of the Makefile itself.

Happy coding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜