Is there a way to comment out multiple lines in makefiles like as in C syntax /* */
?
相关问题
- CMakeList file to generate LLVM bitcode file from
- Makefile to compile lists of source files
- Have make fail if unit tests fail
- C++ - Compiling multiple files
- Undefined symbols for architecture x86_64: (Mac OS
相关文章
- How to arrange a Makefile to compile a kernel modu
- Makefile and use of $$
- Makefile: all vs default targets
- Automake Variables to tidy up Makefile.am
- How do I check the exit status of a Makefile shell
- Marking a makefile dependency as optional or other
- How to instruct Makefile to use different compiler
- Why does this makefile execute a target on 'ma
No, there is nothing like C-style
/* */
comments in makefiles. As somebody else suggested, you can make a multi-line comment by using line continuations. For example:However, I imagine that you are probably looking to temporarily comment out a chunk of your makefile for debugging reasons, and adding a backslash on every line is not really practical. If you are using GNU make, I suggest you use the
ifeq
directive with a deliberately false expression. For example:Hope that helps.
A note about the idea of using
ifeq
to do multi-line comments in make(1). They don't work very well since if you write the following:The text between the ifeq and endif will still be parsed by make which means that you cannot write whatever you want in that section. And if you want to write a long comment and write whatever you want in the comment (including $ signs, colons and more which all have a meaning for make) then you must comment every single line. So why the
ifeq
...:)I believe the answer is no. The only comment styling I can find is # for each line, or use \ to wrap the first line.
Not exactly what you're looking for, but similar in spirit. I don't expect it to be the accepted answer, but maybe it can help someone.
Assuming you're editing your makefiles in VIM:
Either decide which lines you want to comment or select them with 'v'.
Then you can use the regex
s/^/#/
to comment out the linesand
s/^#//
to revert them.--Notes--
:
(colon).,+n
'<,'>s/^/#/
In emacs, you can mark the region you want to comment out and hit
M-;
(which runscomment-dwim
).