makefile
Makefile笔记
[TOC]
foreach
- 格式 source里的变量用n表示,采用1 $(foreach n, source, operation(n)) operation对n进行操作,返回操作后的结果
- 例子 得到的1 
 2foo=a b c 
 target=$(foreach n, $(foo), $(i).cpp)target= a.cpp b.cpp c.cpp
wrod, i
- 格式 - 1 - $(word i, source) - 返回source里的第i个变量 
- 例子 得到的- 1 
 2- foo=a b c 
 target=$(word 2, $(foo))- target=b
filter
- 格式 - 1 - $$(filter method, source) - 使用method方法对source进行筛选,返回符合source里符合method筛选后的结果 
- 例子 得到的- 1 
 2- foo=a.cpp b.h c.c 
 target=$$(filter %.cpp, $(foo))- target=a.cpp
ifeq
- 格式 - 1 
 2
 3- ifeq(a,b) 
 function
 endif- 如果ifeq的条件满足,就执行function 
- 例子 不会执行xx的内容,因为foo不等于空- 1 
 2
 3
 4- foo=a b c 
 ifeq($(foo),)
 xx
 endif
call
- 格式 - 1 - $(call function, param1, param2,... ) - 调用函数function,并且为该函数传入参数param1, etc 
- 例子 - 1 
 2- reverse = $(2) $(1) 
 target = $(call reverse,a,b)- 得到的 - target=b a
template
- 格式 - 1 - $(word i, source) - 返回source里的第i个变量 
- 例子 得到的- 1 
 2- foo=a b c 
 target=$(word 2, $(foo))- target=b