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)
相关推荐
李日灐4 天前
< 6 > Linux 自动化构建工具:makefile 详解 + 进度条实战小项目
linux·运维·服务器·后端·自动化·进度条·makefile
送外卖的CV工程师18 天前
STM32+Makefile编译+OpenOCD 烧录调试
stm32·单片机·嵌入式硬件·makefile·调试·烧录·openocd
zhang-ge18 天前
Makefile调试技巧:打印信息与变量调试
makefile
送外卖的CV工程师20 天前
STM32 CubeMX Makefile 工程编译 入门指南
stm32·单片机·嵌入式硬件·学习·makefile·stm32cubemx
H Journey24 天前
C++之 CMake、CMakeLists.txt、Makefile
开发语言·c++·makefile·cmake
【骠姚校尉】1 个月前
Makefile核心教程(六) --- 一文吃透 Makefile 通配符
linux·makefile·通配符·核心教程
星光20251 个月前
Makefile语法
makefile
阿昭L1 个月前
Windows通用的C/C++工程CMakeLists
c语言·c++·windows·makefile·cmake
数字IC那些事儿1 个月前
CMakeLists.txt 语法解释
makefile·system c
一只自律的鸡3 个月前
【MakeFile】基础培训2
makefile