设为首页收藏本站

嘻皮客娱乐学习网

 找回密码
 中文注册
搜索
打印 上一主题 下一主题
开启左侧

[面试题库] 什么是makefile? 如何编写makefile?

[复制链接]
跳转到指定楼层
楼主
发表于 2014-11-30 15:19:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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
回复

使用道具 举报

小黑屋|手机版|嘻皮客网 ( 京ICP备10218169号|京公网安备11010802013797  

GMT+8, 2024-5-17 06:34 , Processed in 0.215319 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表