makefile-- 其他函数

fuctions

join

复制代码
​$(join <list1>,<list2>)

连接函数

把list2 中单词对应的添加到list1 的后面

若list1 的单词个数> list2 ,多出的list1 保持不变

若list2 的单词个数> list21,多出的list2 添加到list1 后面

foreach

复制代码
​$(foreach <var>,<list>,<text>)

for循环函数

把list的单词逐一取出放在参数 var 里面,然后在执行text所包含的表达式

call

复制代码
​$(call <function>,<param1>,<param2>,...)

call 调用其他的函数

param1 对应$(1) ,以此类推

origin

复制代码
​$(origin var)

查询var变量的来源

有如下几种返回值

default,默认的

environment,环境变量

undefined,未定义的

file,makefile内定义的

command line

override,被override重新定义的

automatic,自动化变量

shell

复制代码
​$(shell  pwd)

可以与awk 和sed 使用

error

复制代码
​$(error  <texts> )

makefile 控制函数,输出error 信息

warning

复制代码
​$(warning  <texts>)

makefile 控制函数,输出warning 信息

example

cpp 复制代码
list1 := 111 222 333
list2 := aaa bbb ccc ddd 
list :=  $(join $(list1),$(list2) ) 


################################################
#### foreach var,list,text
####  loop in list ,and put evevy item in var and do  text 
################################################
for_data= item env monitor 
rst_for := $(foreach var,$(for_data),$(var).sv )

################################################
#### common if 
#### when  condition return is not "" [strip xxx],call  'then_part' ,else call 'else part' 
#### $(if <condition>,<then patr>,<else part> ) 
#### $(if <condition>,<then patr>) 
rst_if = $(if name==ryz, name is ryz,name is not ryz)

################################################
#### call function,param1,param2,param3,....
#### call others functions 
################################################
max=$(2) $(1).sv
rst_call:=$(call max,119,33)

################################################
#### origin var 
#### tell var from 
#### if var not define ,return undefined
#### if define in makefine ,return file
#### if var is a default  ,return default 
#### if var is a environment and make not -e option ,return environment
#### if define in makefine ,return file
#### return command line 
#### return override 
#### return automatic 
################################################
var_file := llll
var_file:=$(origin $(var_file) )
var_undefined = $(origin $(var_no) )


################################################
#### shell 
#### using awk and sed         
################################################

rst_pwd := $(shell pwd)


################################################
#### makefile control functions 
#### $(error text),quit now
#### $(warning text),only type text,not quit
################################################
warning_info := $(warning get a warning msg)
error_info =$(error  get an error)

ifdef ERROR_MSG
	$(error_info)
endif


err:$(error_info)

war:$(warning_info)

all:
	@echo $(list)
	@echo $(rst_for)
	@echo $(rst_if)
	@echo $(rst_call)
	@echo $(var_file)
	@echo $(rst_pwd)
相关推荐
tod1132 天前
Makefile进阶(上)
linux·运维·服务器·windows·makefile·进程
一个平凡而乐于分享的小比特16 天前
Makefile 源码编译系统详解
linux·makefile
一个平凡而乐于分享的小比特20 天前
Autoconf:Linux自动生成Makefile的详解
makefile·cmake·autoconf
一个平凡而乐于分享的小比特24 天前
Linux内核构建三剑客:Kconfig、.config与Makefile关系详解
linux·makefile·kconfig·.config
ベadvance courageouslyミ25 天前
项目一(线程邮箱)
c语言·线程·makefile·进程间通信·线程邮箱
熊猫钓鱼>_>1 个月前
Makefile应用场景实践日志:构建高效C/C++项目工作流
c语言·c++·bug·mfc·makefile·编译·kmp
___波子 Pro Max.1 个月前
Makefile设置DEBUG宏定义方法总结
makefile·make
乖乖是干饭王1 个月前
Linux 内核 Kbuild 中的 ld 调用机制
linux·c·makefile
fareast_mzh2 个月前
redis: undefined reference to `log‘
redis·makefile
冉佳驹2 个月前
Linux ——— sudo权限管理和GCC编译工具链的核心操作
linux·makefile·make·gcc·sudo·.phony