
Silence the makefile recipes
Makefile is made up of recipes. Running a recipe in make, prints the recipe and also the output of every command in the recipe. Recipe can be implemented by re-directing the output to /dev/null device. But this approach has a problem. Sometimes, I wanted to read the output of the command and not be re-directed to /dev/null , especially during troubleshooting. In this situation, there is no other way but to change implementation of recipe to remove the redirection. Makefile has a switch -s to silence the printing of the recipe during execution. I wanted to use this switch to decide for redirection. ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) .REDIRECT = > /dev/null 2>&1 else .REDIRECT = endif test : which scala $( .REDIRECT ) || printf "scala is not present." Now, make test prints the recipe and output of the which command. But make test -s completely silences the recipe execution. Makefile provides a way to silence the echoing of recipes but the implementation of recipe, as
Continue reading on Dev.to
Opens in a new tab


