3
votes

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.

3
While this is easy enough to do with @, please reconsider using it if you are going for a wider audience with your project. The "I hate reading compiler invocations but want some kind of progress indicator so I use @echo" point is understandable. However, if you expect anyone but you will ever compile your project, leave the full compiler lines in, or you'll be asking for the lines in bug reports and they will be hacking your Makefile to get them back.thiton
@thiton Good point. I'll keep that in mind when I near release.Malabarba
Related: the opposite question How do I force make/gcc to show me the commands?smci

3 Answers

4
votes

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.

1
votes

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.

1
votes

(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