How do I add comments (with echo) in a Makefile
so that they\'re printed when ran?
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!
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
.
Since a makefile mostly contains commands to be run when building specific targets, I'd say you use just that: echo
.
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
all :
echo "Building!"
$(CC) $(OBJECTS) $(LPATH) $(LIBS) -o $(PROGRAM)