16

I have a makefile that compiles every .c file in my project. For each file, I get the whole compile command printed out to the shell, with all the options and flags. This is the example output for one file:

arm-none-eabi-gcc -c -mcpu=cortex-m3 -O0 -dM -g -gdwarf-2 -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=src/sim/sim_configuration.lst -include ./lib/stm32core/stm32f2xx_conf.h -I . -I./lib/ARMStandardLibrary -I./lib/LwIP -I./lib/LwIP/src/include -I./lib/LwIP/src/include -I./lib/LwIP/src/include/ipv4 -I./lib/LwIP/src/include/ipv6 -I./lib/FatFS -I./lib/stm32core -I./src -I./src/sim -I./src/sd -I./src/tftp src/sim/sim_configuration.c -o src/sim/sim_configuration.o

The problem is that various warnings get lost inside this whole mess of command outputs. Is there a way to only print the warnings and errors that appear (not the original command)?

4 Answers 4

24

Execute make with the -s option. From the man page.

-s, --silent, --quiet
    Silent operation; do not print the commands as they are executed.
Sign up to request clarification or add additional context in comments.

Comments

6

Just prepend the command with the @ symbol.

If you rely on built-in implicit rules, you will have to make them explicit or, in your specific case, you could use:

.SILENT: *.o

for silencing all commands used for building to the %.o targets.

4 Comments

Instead of (or in addition to) using @, you can do MAKEFLAGS += --quiet. That will work for built-in rules as well.
Yes, but then every command in every rule will not be echoed.
As always, it's a trade off, but it handles built-in rules. In general, making built-in rules explicit is a very bad idea, so setting MAKEFLAGS may be a better method. Or not, of course.
Maybe the .SILENT solution is better?
5

You could always filter all the output from stdout, which should leave you with all the errors on stderr:

make 1>/dev/null

Comments

4

Use @ before a command to hide the it:

rule1:
  @gcc someting

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.