2011-08-31 63 views
25

我有一个makefile,它构建了一个包含所有需要构建的文件的项目。为了使事情更加复杂,我在每次调用gcc时都有一些包含的目录(因此每次调用gcc在命令行上看起来都很长)。禁止所有make输出,除了错误和警告

我想禁止所有输出除了错误和警告(这样我可以清楚地看到他们时许运行!)

有没有办法做到这一点?

+1

@pst你是男人!请发帖作为答案,以便我可以标记为已接受。顺便说一句...你知道是否有什么办法可以从makefile中做到这一点,这样'make'命令仍然是直截了当的? – Steve

回答

10

取决于如何“错误和警告”的报道......

make > /dev/null 

将从make命令所有STDOUT(标准输出)(以及所有子进程它产生)重定向到无尽一滴无用的东西。这可能太贪婪,因为有些程序使用STDOUT(而不是STDERR)报告警告。

我不知道从Makefile本身的上下文中全局更改所有子进程的STDOUT。

快乐编码。

+0

谢谢!这正是我需要的。 (与gcc完美配合) – Steve

23

“make -s”应该做得更清晰一些。我不知道如何强制makefile,但GNU手册可能有。

如果你不能检查Linux内核构建系统,因为这似乎自动隐藏标准输出。

希望帮助, 保罗

+0

非常好,正是我需要的 –

19

通过添加“@”的命令的前部,在命令行串被抑制 例如 从

$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c 
     $(CC) -c $(CFLAGS) $< -o [email protected] 

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

将采取

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' 

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

您也可以强制-s选项,通过PaulW directl的建议y在Makefile中。只需添加:

.SILENT: