make 中的函数
来源:互联网 发布:机电软件 编辑:程序博客网 时间:2024/06/01 08:13
1.subst 替换
用法:$(subst from,to,text) : 将text中的from 替换为to
eg: $(subst ee,EE,feet on the street) 结果:'fEEt on the strEEt'
用法:
$(patsubst pattern,replecement,text)
eg: $(patsubst %.c,%.o,x.c.c bar.c) 结果: 'x.c.o bar.o'
用法:$(strip string) : 将string 中前导和后缀空格去掉,中间多个空格和为一个。
eg: $(strip a b c ) 结果: 'a b c'
用法:$(findstring find,in) 在in中查找find,若找到返回find否则返回空
eg: $(findstring a,a b c) 结果:'a'
$(findstring a,b c) 结果:''
用法:$(filter pattern...,text) 将text中符合pattern的过滤出来。
eg: sources := foo.c bar.c baz.s ugh.h
foo: $(sources)
cc $(filter %.c %.s,$(sources)) -o foo //cc 命令生成foo 不用ugh.h文件
用法: $(filter-out pattern...,text)
eg: objects=main1.o foo.o main2.o bar.o
mains=main1.o main2.o
$(filter-out $(mains),$(objects)) 结果: 'foo.o bar.o'
用法: $(sort list) 按字典顺序排序,移除重复的。
eg: $(sort foo bar lose) 结果: 'bar foo lose'
用法: $(word n,text) 取text 中第n个词
eg: $(word 2, foo bar baz) 结果: 'bar'
用法: $(wordlist m,n,text) 从text中取从第m到第n个词
eg: $(wordlist 2,3,foo bar baz) result is : 'bar baz'
用法: $(words text) 返回text包含的词的个数
eg: $(word $(words text),text) 返回text中最后一个词
用法: $(firstword names...) 取第一个词
eg: $(firstword foo bar) result is : 'foo'
用法: $(lastword names...) 取最后一个词
eg: $(lastword foo bar ) result is : 'bar'
B.处理文件名的函数
用法: $(dir names) 提取每个文件名的目录部分,以'/'结束。如果文件名不带'/'则目录部分视为'./'.
eg: $(dir src/foo.c hacks) 结果 :'src/ ./'
用法: $(notdir names)
eg: $(dir src/foo.c hacks) 结果 :'foo.c hacks'
用法: $(suffix names...) : 提取文件名后缀
eg: $(suffix src/foo.c src-1.0/bar.c hacks) 结果 :'.c .c'
用法: $(basename names...) : 提取文件名除后缀外的部分,suffix 相反。
eg: $(basename src/foo.c src-1.0/bar hacks) 结果 :'src/foo src-1.0/bar hacks'
用法: $(addsuffix suffix,names...) 添加后缀
eg: $(addsuffix .c,foo bar) 结果 :'foo.c bar.c'
$(addprefix prefix,names...)
eg: $(addprefix src/,foo bar) 结果 :'src/foo src/bar'
$(join list1,list2)
eg: $(join a b,.c .o) 结果:'a.c b.o'
$(wildcard patterns) :
eg: $(wildcard *.c) means all .c files.
objects := $(patsubst %.c,%.o,$(wildcard *.c))
foo:$(objects)
cc -o foo $(objects)
$(realpath names...) : 返回绝对路径,不包含.或..或重复的/或者链接。
$(abspath names...) :与realpath 相似,只是保留链接。
- make 中的函数
- Linux中的 make config, make menuconfig, make oldconfig, make xx_defconfig
- GNU (内部)make函数
- make foreach 函数
- GNU make函数
- make函数学习
- golang make()内置函数
- make origin函数简介
- golang make()内置函数
- Make file 函数
- make 中的config详述
- 【转】makefile 中的$(MAKE)
- android 中的make命令
- make中的include
- make中的shell
- 理解make中的export
- make中的自动化变量
- LINUX中的make
- 风影墙纸,一天看N回。
- 基础总结篇之九:Intent应用详解
- Service生命周期的学习
- 微软MSChart图表插件使用
- 谈谈jetty8 的io模型
- make 中的函数
- HDU2294 Pendant 矩阵应用
- JAVA类的基本应用
- 深入理解JAVA中的栈与堆
- JAVA类的基本应用2
- HDU3732多重背包
- 后缀数组
- 使用scanf函数时应该注意的问题
- hdu1181floyd传递包