Makefile: silence the "make[N]:" line specifically

7.8k Views Asked by At

Part of my makefile has the following code:

target.o:
        cd dir; $(MAKE)

Where the file target.o has its own makefile inside of directory dir. During compiling, I get the following output lines:

make[1]: Entering directory `dir'
ifort -c target.f -o target.o
make[1]: Leaving directory `dir'

I would like to silent the first and third output lines but keep the second. Adding the -s to the make in the main makefile eliminates the first and third but also the one I want to keep.

(1) Is there a way to do this?

(2) Is there a reason why doing this might not be such a good idea?

1

There are 1 best solutions below

0
On BEST ANSWER

You want $(MAKE) --no-print-directory.

-w, --print-directory Print the current directory.

--no-print-directory Turn off -w, even if it was turned on implicitly.

You cannot silence only part of a command. The @ prefix is all-or-nothing.

You can echo anything you want of course (this is how the autotools silent output works for example, silence the default make output and then output GEN target.file or whatever).