Makefile
来源:互联网 发布:知有儿童挑促织的意思 编辑:程序博客网 时间:2024/06/08 03:26
规则:
target:prerequisites
command
预定义常量:
$*
不包含扩展名的目标文件名称。
$+
所有的依赖文件,以空格分开,并以出现的先后为序,可能包含重复的依赖文件。
$<
第一个依赖文件的名称。
$?
所有的依赖文件,以空格分开,这些依赖文件的修改日期比目标的创建日期晚。
$@
目标的完整名称。
$^
所有的依赖文件,以空格分开,不包含重复的依赖文件。
$%
如果目标是归档成员,则该变量表示目标的归档成员名称。例如,如果目标名称为
mytarget.so(image.o),则 $@ 为 mytarget.so,而 $% 为 image.o。。
-放在命令开头,表示出错了继续执行下面的命令
伪目标
.phony: clean
clean:
-rm *.tmp
VPATH: search path for all prerequisites
vpath: the directive specifies a search path for file names that match a particular pattern
vpath %.c directory
静态模式:
targets: target-pattern: prereq-patters
objects=foo.o bar.o
$(objects):%.o:%.c
$(CC) -c $(CFLAGS) $< -o $@
常用函数:
字符串替换
$(subst <from>,<to>,<text>)
模式字符串替换
$(patsubst <pattern>,<replacement>,<text>)
去掉空格
$(strip <string>)
查找字符串函数
$(findstring <find>,<in>)
过滤函数
$(filter <pattern...>,<text>)
排序函数
$(sort <list>)
取前缀函数
$(basename <names...>)
取后缀函数
$(suffix <names...>)
连接函数
$(join <list1>,<list2>)
immediate = deferred
immediate ?= deferred
immediate := immediate
immediate += deferred or immediate
For include file in %.c, the 'gcc -M' output the dependancies.
%.d: %.c
@set -e; rm -f $@; \ #nomally, make output the command before it is executed; when a line starts with a'@', the echoing of the line is supressed.
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@;
# rm -f $@.$$$$
-include $(sources:.c=.d) # '-' 出错继续执行,不报错;否则报错‘找不到文件’。 被include的文件也被当作目标来尝试,可以匹配规则'%d:%c'。 用';'隔开的命令为子命令,在同一个进程中执行。
- Makefile
- Makefile
- makefile
- makefile
- makefile
- Makefile
- Makefile
- Makefile
- Makefile
- Makefile
- Makefile
- makefile
- Makefile
- makefile
- Makefile
- makefile
- makefile
- makefile
- java中的锁池和等待池
- JAVA多线程编程详解
- 在eclipse下自动部署项目
- 设计原则(1)-单一职责原则
- Android中将布局文件/View添加至窗口过程分析 ---- 从setContentView()谈起
- Makefile
- PL/SQL函数
- 用AutoCompleteTextView实现历史记录提示
- 设计原则(2)-开放封闭原则
- Linux - one command per day--rm
- Jquery学习4-3---jquery用法之访问dom元素包含信息。
- pl/sql常用方法
- 设计原则(3)-里氏代换原则
- Java2十大经典中文图书