makefile 备忘

来源:互联网 发布:nginx 全局 header 编辑:程序博客网 时间:2024/05/17 23:47

1。首要第一条,负责执行的命令(the target build instructions)必须以tab开头!否则会得到:

 

Makefile:2: *** missing separator.  Stop.

or

"Makefile", line 2: Need an operatorFatal errors encountered -- cannot continue

 

2。插播一个刚解决的问题:很多Makefile会用g++ -M *.cpp 让系统自动生成一个dependent file,比如叫Makefile.depend。意图是好的,但clean中一定要记住删除这个system dependent的文件!否则换了机器编译可能找不到相应的头文件

 

3。2中的cc/g++ -M 选项,可以让系统生成依赖关系(头文件)。-M 会包括标准库函数的头文件的依赖(比如/usr/include/math.h),有时应该步需要,可以用-MM选项,则不会包含标准库。

 

4。自动化变量

原创粉丝点击