Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress all make output except for errors and warnings

Tags:

makefile

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 there any way to do this?

like image 331
Steve Avatar asked Aug 31 '11 03:08

Steve


People also ask

How do I hide the output of my Makefile?

If you want to inhibit the display of commands during a particular make run, you can use the -s option. If you want to inhibit the display of all command lines in every run, add the special target . SILENT to your makefile . and there is no file named xyz , make halts after rm returns its exit status.

How do I ignore a warning in Makefile?

Maybe you can look for CFLAGS options in Makefile and remove the -Werror flag. The Werror flag will make all warnings into errors. Show activity on this post.

How do I turn off warnings in Linux?

To suppress this warning use the unused attribute (Section 6.32 Specifying Attributes of Variables). To suppress this warning use the unused attribute (Section 6.32 Specifying Attributes of Variables). Warn whenever a statement computes a result that is explicitly not used.


2 Answers

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.

like image 64
PaulW Avatar answered Sep 18 '22 13:09

PaulW


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' 
like image 39
user1792021 Avatar answered Sep 20 '22 13:09

user1792021