How to add multi line comments in makefiles

前端 未结 6 1824
野的像风
野的像风 2021-01-30 03:32

Is there a way to comment out multiple lines in makefiles like as in C syntax /* */ ?

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-30 04:23

    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:

    # This is the first line of a comment \
    and this is still part of the comment \
    as is this, since I keep ending each line \
    with a backslash character
    

    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:

    ifeq ("x","y")
    # here's all your 'commented' makefile content...
    endif
    

    Hope that helps.

提交回复
热议问题