设为首页 加入收藏

TOP

什么是makefile? 如何编写makefile?
2014-11-23 20:29:07 来源: 作者: 【 】 浏览:15
Tags:什么 makefile 如何 编写

makefile:一个文本形式的文件,其中包含一些规则告诉make编译哪些文件以及怎样编译这些文件,每条规则包含以下内容:
一个target,即最终创建的东西
一个和多个dependencies列表,通常是编译目标文件所需要的其他文件
需要执行的一系列commands,用于从指定的相关文件创建目标文件


make执行时按顺序查找名为GNUmakefile,makefile或者Makefile文件,通常,大多数人常用Makefile
Makefile规则:
target: dependency dependency [..] command command [..]
注意:command前面必须是制表符
例子:
editor: editor.o screen.o keyboard.o
gcc -o editor editor.o screen.o keyboard.o
editor.o : editor.c editor.h keyboard.h screen.h
gcc -c editor.c
screen.o: screen.c screen.h
gcc -c screen.c
keyboard.o : keyboard.c keyboard.h
gcc -c keyboard.c
clean:
rm editor *.o


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇写一个方法1000 的阶乘。 下一篇“Traditional ” Interview with..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: