In this makefile
dirs = $(shell ls)
clean:
$(foreach dir,$(dirs),echo $(dir);)
The output is
$ make clean
echo bin; echo install.sh; echo Makefile; echo README.md; echo utils;
bin
install.sh
Makefile
README.md
utils
Why does it first show the command, then execute it? How I can omit the first line?
Prepend the command with the @ character. Example:
dirs = $(shell ls)
clean:
@$(foreach dir,$(dirs),echo $(dir);)
From the manual (5.2 Recipe Echoing, bold emphasis mine):
Normally make prints each line of the recipe before it is executed. We call this echoing because it gives the appearance that you are typing the lines yourself.
When a line starts with
@
, the echoing of that line is suppressed. The@
is discarded before the line is passed to the shell. [...]
Alternatively:
The
-s
or--silent
flag to make prevents all echoing, as if all recipes started with@
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With