makefile中wildcard notdir patsubst的简单介绍
来源:互联网 发布:黑马就业班java视频 编辑:程序博客网 时间:2024/05/22 12:07
1、wildcard : 扩展通配符
2、notdir : 去除路径
3、patsubst :替换通配符
例子:
建立一个测试目录,在测试目录下建立一个名为sub的子目录
$ mkdir test
$ cd test
$ mkdir sub
在test下,建立a.c和b.c2个文件,在sub目录下,建立sa.c和sb.c2 个文件
建立一个简单的makefile
src=$(wildcard *.c ./sub/*.c)
dir=$(notdir $(src))
obj=$(patsubst %.c,%.o,$(dir) )
all:
@echo $(src)
@echo $(dir)
@echo $(obj)
@echo "end"
执行结果分析:
第一行输出:
a.c b.c ./sub/sa.c ./sub/sb.c
wildcard把 指定目录 ./ 和 ./sub/ 下的所有后缀是c的文件全部展开。
第二行输出:
a.c b.c sa.c sb.c
notdir把展开的文件去除掉路径信息
第三行输出:
a.o b.o sa.o sb.o
在$(patsubst %.c,%.o,$(dir) )中,patsubst把$(dir)中的变量符合后缀是.c的全部替换成.o,
任何输出。
或者可以使用
obj=$(dir:%.c=%.o)
效果也是一样的。
这里用到makefile里的替换引用规则,即用您指定的变量替换另一个变量。
它的标准格式是
$(var:a=b) 或 ${var:a=b}
它的含义是把变量var中的每一个值结尾用b替换掉a
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst的简单介绍
- makefile中wildcard notdir patsubst
- Makefile中wildcard、notdir、patsubst函数的用法
- makefile 文件中得wildcard notdir patsubst
- makefile中的notdir,wildcard和patsubst notdir,wildcard和patsubst是makefile中几个有用的函数
- Makefile之wildcard,notdir,patsubst
- Makefile wildcard notdir patsubst 简介
- makefile中的patsubst, wildcard, notdir
- POJ1054--The Troublesome Frog
- 一个解决JSP中文乱码的过滤器
- Java RMI详解
- c语言各重点语句模块汇总
- android 自定义RadioButton 实现图标居中显示
- makefile中wildcard notdir patsubst的简单介绍
- UVA 10603 (13.07.24)
- KVM-QEMU vdagent实现机制分析(一)
- Android下app生成coredump方法
- Linux makefile 教程
- CFI
- poj 3624 DP
- DWR框架配置
- POJ-1308-Is It A Tree?