Reputation:
How do I add comments (with echo) in a Makefile
so that they're printed when ran?
Upvotes: 22
Views: 39527
Reputation: 1060
An imperfect but simple workaround is to add your comments outside the target:
Rule: Dependencies
Command
# Your Comment
Upvotes: 1
Reputation: 6800
Or, since Make just pushes whatever is in a rule to bash, you could just use a pound to have bash treat it as a comment.
Rule: Dependencies
# Your Comment
Command
Will output
$ make Rule
# Your Comment
Command
Upvotes: 11
Reputation: 339786
You should use
target:
@echo "Building!"
Note the @
, which tells Make not to display the command itself. Without this the output would look like:
echo "Building!"
Building!
Upvotes: 33
Reputation: 354356
Since a makefile mostly contains commands to be run when building specific targets, I'd say you use just that: echo
.
Upvotes: 2
Reputation: 75982
Visual C++ nmake has the !message text...
preprocessing directive. I have not used GNU make, so I don't if it has it as weel, but quick search shows it has the $(info text...)
function.
And inside command blocks you can use echo
.
Upvotes: 2
Reputation: 10620
all :
echo "Building!"
$(CC) $(OBJECTS) $(LPATH) $(LIBS) -o $(PROGRAM)
Upvotes: 2