Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control the output of a make command to be less verbose, don't echo each command

Currently, I'm using a Makefile to keep track of all dependencies and copilation of my project. The problem is that make simply outputs everything it's doing, and that makes it hard to spot (or even read) more important information (such as compiler warnings).

Is there a way to control what information is displayed on the terminal? I know there's a -s option that silences make, but that's not what I want. I need something a little more refined, perhaps showing the compilation target without showing the entire compilation command.

Is there any way to control that?

Note: There's a similar question regarding the automake and autoconf commands. But I don't use those, and I'm specifically looking for something on make.

like image 585
Malabarba Avatar asked Sep 11 '25 23:09

Malabarba


2 Answers

Well there's the usual business

target: dependency1 dependency2
    @echo Making $@
    @$(CC) -o $@ $(OPTIONS) $^

The leading @'s suppress the usual behavior of echoing the action without suppressing its output.

The output of various actions can be suppressed by redirecting it to /dev/null. Remember to grad the standard error too if you want a line to be really silent.

like image 184
dmckee --- ex-moderator kitten Avatar answered Sep 14 '25 23:09

dmckee --- ex-moderator kitten


The standard Unix answer (`make`` is a Unix tool, after all):

make (...) | grep (whatever you want to see)

Why is that not an appropriate solution here?

You could also put filtering within the Makefile itself, e.g. by tweaking the SHELL variable or adding a target that calls $(MAKE) | grep.

The main idea is to allow the filtering to be switched on and off as the caller pleases.

like image 29
reinierpost Avatar answered Sep 14 '25 23:09

reinierpost