Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ignoring at (@) symbol in makefiles

Tags:

makefile

In makefiles, a line prefixed with an at symbols disables the print of the output. I have a makefile where every line is prefixed with an at, but for debug I need to see what's going on. Is there a way to tell make to ignore the at and output the line ? the debug is excessive, and the -n option prints them, but does not do anything (it's for dry run)

like image 812
Stefano Borini Avatar asked Oct 05 '10 08:10

Stefano Borini


People also ask

What does $@ mean in Makefiles?

The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file.

What does AT symbol do in makefile?

The @ symbol is commonly seen at the beginning of an action lines and means that the action line itself is not be be echoed on the screen as it is executed. Macros are commonly used in makefiles to decrease the amount of typing required.

What is $$ in makefile?

$$ means be interpreted as a $ by the shell. the $(UNZIP_PATH) gets expanded by make before being interpreted by the shell.


1 Answers

Make a variable that has a default value of @:

AT := @

And then use that in your Makefile:

foo:
    $(AT)fooc -o $@

Then run make as make AT=. You can get fancier than that, if you like:

V := 0
AT_0 := @
AT_1 :=
AT = $(AT_$(V))

This will make commands silent, unless V is set to 1 (e.g., make V=1). This uses the non-POSIX, but common feature of recursive variable expansion.

like image 73
Jack Kelly Avatar answered Oct 27 '22 22:10

Jack Kelly