Makefile Makefile中的-I

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

书上是这样解释的:

-I DIR当包含其他 makefile 文件时,可利用该选项指定搜索目录

读了好多遍都没有懂,结果使我浮想联翩,最后在老师我指导下明白了:

指定目录下(如tmp)的makefile(或者其他名字)在当前Makefile中要有这样一句:include makefile,然后makefile -I tmp时就会在在tmp下找Makefile并把里边的内容添加到当前目录下的Makefile中。

当前目录下的Makefile:

OBJ=main.o fun1.o fun2.oCC=gccCFLAGS=-DDBGhello: $(OBJ) gcc $^ -o helloinclude Makefile

tmp目录下的Makefile:

clean: rm *.o helloinstall: cp hello /usr/binuninstall: rm /usr/bin/hello

在当前目录下执行:

[root@localhost makefile]# make cleanmakefile:8: Makefile: 没有那个文件或目录make: *** 没有规则可以创建目标“Makefile”。 停止。
但是加上这个-I tmp后:

[root@localhost makefile]# make clean -I tmprm *.o hellorm: 无法删除"*.o": 没有那个文件或目录rm: 无法删除"hello": 没有那个文件或目录make: *** [clean] 错误 1[root@localhost makefile]# 

就可以了,是因为它把这个/tmp/Makefile中的内容拷贝到当前目录下的Makefile中了。



           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/hfyutdg/article/details/84101698