How do I make a Makefile to log both command and its output to a file?
问题 I want to log both the command and its output to a log file. It seems easy. Just redirect stdout to the log file. myrule: mycommand >> logfile But this only logs the output of the command. Not the command itself. Do I also echo the command and redirect that output to the log file? myrule: @echo mycommand >> logile mycommand >> logfile This duplication of 'mycommand' doesn't look good and it takes up space in the recipe. Especially if the recipe is long. Should I create a function and call it