Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress "nothing to be done for 'all' "

Tags:

shell

makefile

I am writing a short shell script which calls 'make all'. It's not critical, but is there a way I can suppress the message saying 'nothing to be done for all' if that is the case? I am hoping to find a flag for make which suppresses this (not sure there is one), but an additional line or 2 of code would work too.

FYI I'm using bash.

Edit: to be more clear, I only want to suppess messages that therer is nothing to be done. Otherwise, I want to display the output.

like image 453
sas4740 Avatar asked Aug 05 '10 17:08

sas4740


3 Answers

You can make "all" a PHONY target (if it isn't already) which has the real target as a prerequisite, and does something inconspicuous:

.PHONY: all

all: realTarget
    @echo > /dev/null
like image 94
Beta Avatar answered Oct 17 '22 07:10

Beta


I would like to improve on the previous solution, just to make it a little bit more efficient...:)

.PHONY: all
all: realTarget
        @:

@true would also work but is a little slower than @: (I've done some performance tests). In any case both are quite faster than "echo > /dev/null"...

like image 28
Mark Veltzer Avatar answered Oct 17 '22 06:10

Mark Veltzer


The flag -s silences make: make -s all

EDIT: I originally answered that the flag -q silenced make. It works for me, although the manpage specifies -s, --silent, --quiet as the valid flags.

like image 2
Ryan Tenney Avatar answered Oct 17 '22 06:10

Ryan Tenney