Hermann Schachner
Hermann Schachner

Reputation: 550

Is it possible to enforce recipe echoing with GNU Make?

According to the GNU make manual, echoing of shell commands can be suppressed by prefixing the according lines with @.

Using the option -n or --just-print, one can make a dry run and print all those prefixed lines without actually doing them.

Is it possible to execute the make recipes and print the shell commands at the same time? Put differently, can I enforce echoing for all recipes, no matter whether they have a @at the beginning, or not?

Upvotes: 3

Views: 715

Answers (1)

Louis
Louis

Reputation: 151411

With GNU Make 4.0 there's the option --trace. (I don't know how what is the earliest version that supports --trace. I just know that 4.0 supports it.)

'--trace'

Show tracing information for 'make' execution. Prints the entire recipe to be executed, even for recipes that are normally silent (due to '.SILENT' or '@'). Also prints the makefile name and line number where the recipe was defined, and information on why the target is being rebuilt.

With this Makefile:

all:
    @echo foo
    echo blah

A regular run:

$ make
foo
echo blah
blah

With --trace:

$ make --trace
Makefile:2: target 'all' does not exist
echo foo
foo
echo blah
blah

echo foo is output even though it begins with @.

Upvotes: 4

Related Questions