Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

(Too late, Adding just for Googlers landing here) This works for me. On your Makefile you can control verbosity for each command using something like:

BRIEF = CC HOSTCC HOSTLD AS YASM AR LD
SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM STRIP
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top