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)
相关推荐
fareast_mzh6 天前
redis: undefined reference to `log‘
redis·makefile
冉佳驹7 天前
Linux ——— sudo权限管理和GCC编译工具链的核心操作
linux·makefile·make·gcc·sudo·.phony
攻城狮7号8 天前
【AI时代速通QT】第十节:在 Windows 上配置vs和qmake环境手动编译 Qt 项目
windows·qt·makefile·visual studio·qmake·vcvarsall·nmake/jom
青云交14 天前
ShellCheck命令行工具适配开源鸿蒙PC实战指南
华为·开源·makefile·harmonyos·shellcheck·预编译二进制·hnp 打包
不知所云,17 天前
3. cmake 和 Ninja安装
驱动开发·makefile·make·构建工具·ninja
HalvmånEver1 个月前
Linux:基础开发工具(四)
linux·运维·服务器·开发语言·学习·makefile
Fcy6481 个月前
Linux下的项目自动化构建-make\makefile详解
linux·运维·自动化·makefile·make
边疆.2 个月前
【Linux】自动化构建工具make和Makefile和第一个系统程序—进度条
linux·运维·服务器·makefile·make
LostSpeed2 个月前
debug - MDK - arm-none-eabi - 从MDK工程做一个makefile工程出来
makefile·bat·mdk·arm-none-eabi
DebugKitty3 个月前
硬件开发2-ARM裸机开发1-I.MX6ULL - 汇编点灯
汇编·makefile·imax6ull·gpio·电路复用