Chinaunix首页 | 论坛 | 博客
  • 博客访问: 171068
  • 博文数量: 31
  • 博客积分: 728
  • 博客等级: 军士长
  • 技术积分: 295
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-28 15:29
个人简介

To be Ols!

文章分类

全部博文(31)

文章存档

2013年(1)

2012年(30)

我的朋友

分类: LINUX

2012-10-23 16:33:52

Makefile Comments

注释在 makefile 中起着重要的作用,它帮助我们更快更好的理解 makefile 的内容。

# 注释符
# 字符是注释符,makefile 把 # 字符后面的内容作为注释内容处理(shell、perl 脚本也是使用 # 字符作为注释符)。如果某行的第一个非空字符为 #,则此行会被 make 解释为注释行(命令行除外,如果 Tab 字符之后使用 # 字符,则会被 make 解释为命令行)。
注释行的结尾如果存在反斜线(\),那么下一行也被作为注释行。
建议在书写 makefile 时将注释作为一个独立的行,而不要和 makefile 的有效行放在同一行中书写。make 有时候会把 # 字符之前的内容作为有效行的内容(如定义变量的时候)。
当在 makefile 中需要使用字符 # 时,可以使用 \ 加 #(\#)来实现,表示将 # 字符作为一个普通字符而不是注释符。

示例 1
Makefile 文件的内容如下
# this makefile \
for test comments

makefile_version = 3.82  # there has two spaces before #
comments = "the \# character as the comment contents!"

print :
    echo $(comments)
    printf "make $(makefile_version) welcome! \n"

在命令提示符下输入 “make -s”,执行结果如下:
the # character as the comment contents!
make 3.82   welcome!

阅读(1540) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~