Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing output from my Makefile

Tags:

I have ;

 default :            gcc -o function function.c 

When I type make in terminal, following message is emitted

         user@user-laptop:~/Desktop$ make          gcc -o function function.c           user@user-laptop:~/Desktop$   

But I want

         user@user-laptop:~/Desktop$ make          user@user-laptop:~/Desktop$   

How can I do that?

like image 995
oscego Avatar asked Apr 29 '12 10:04

oscego


People also ask

How do I hide output in makefile?

If you want to inhibit the display of commands during a particular make run, you can use the -s option. If you want to inhibit the display of all command lines in every run, add the special target . SILENT to your makefile .

What is @echo in makefile?

The ' @ ' is discarded before the line is passed to the shell. Typically you would use this for a command whose only effect is to print something, such as an echo command to indicate progress through the makefile: @echo About to make distribution files.

What does $< in makefile mean?

The $@ and $< are called automatic variables. The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file. For example: hello.o: hello.c hello.h gcc -c $< -o $@ Here, hello.o is the output file.


2 Answers

Use an @ to quiet the output:

default:     @gcc -o ... 

You can find the documentation here: Recipe echoing. (Or you can invoke make with make -s to suppress all echoing.)

like image 135
Mat Avatar answered Nov 30 '22 23:11

Mat


You can use make --silent (at least for GNU make)

like image 34
Pubby Avatar answered Dec 01 '22 01:12

Pubby