Makefile相关函数
来源:互联网 发布:mac whirl亚洲人试色 编辑:程序博客网 时间:2024/06/10 01:04
$(wildcard *.c)
获取该目录下所有的.c文件
$(addsuffix SUFFIX,NAMES)
给NAMES加上后缀SUFFIX
PS:结合以上两个函数可以实现获取指定目录下的所有指定类型文件:
SRCDIR := src1 src2 src3SRCS := $(wildcard $(addsuffix /*.cpp, $(SRCDIR))) #获取src1 src2 src3 目录下所有的.cpp文件#相当于 SRCS := $(wildcard src1/*.cpp src2/*.cpp src3/*.cpp)
$(subst from,to,texts)
把字串texts中的from字符串替换成to。
$(patsubst %.c,%.o,texts)
把字符串texts中的.c替换成.o [其中,%代表任意长度的字符串]
OBJS := $(patsubst %.cpp,%.o,$(SRCS)) #将SRCS中文件的".cpp"转化为".o"
[例子]假设当前目录下存在文件夹build(用来保存编译出来的.o文件),src(用来放.cpp源文件),include(用来放.h头文件)三个文件夹,
SRCDIR := src SRCS := $(wildcard $(addsuffix /*.cpp, $(SRCDIR))) OBJS := $(patsubst %.cpp,%.o,$(subst src,build,$(SRCS)))
则SRCS为src目录下所有.cpp文件,OBJS为将编译成build下的与.cpp同名的.o文件,如src/a.cpp将转化为build/a.
那么编译命令可以为:
$(OBJS) : $(SRCS) g++ -o $@ -c $(patsubst %.o,%.cpp, $(subst build,src,$@)) $(INCLUDE_PATH)
其中,
$(strip texts)
把texts前后的空格去掉
$(strip a b c) -> "abc"
阅读全文
0 0
- Makefile相关函数
- Linux相关-------Makefile常用函数表
- makefile 相关
- Makefile 相关
- makefile相关
- makefile相关
- Makefile相关
- Makefile相关
- makefile相关
- makefile相关
- [编译相关]系列1:makefile 中的 wildcard 与 patsubst 函数
- [编译相关]系列4:Makefile中常用的函数
- makefile 函数
- makefile 函数
- Makefile函数
- 函数-Makefile
- Makefile 函数
- makefile--函数
- 使用struts2.5版本遇到的问题
- URAL 1519 Formula 1(插头DP)
- [简单DP]Tickets HDU
- shortcuts实现
- <Android 应用 之路> 每日一文简单版<Kotlin>
- Makefile相关函数
- 【Oracle】sql的使用总结
- HDU 5131 Song Jiang's rank list (确定排名经典问题)
- 将二叉搜索树转换成一个排序的双向链表
- Sublime Text3 + Golang搭建开发环境
- android nfc中MifareClassic格式的读写
- 隐藏状态栏(适用Android Studio)
- vs2017 安卓开发
- Java String类&StringBuffer类