makefile 函数

1. findstring

$(findstring <find>, <in>)

从 in 中查找 find ,如果找到则返回find,否则返回空

str1=1111
str2=11222

all:
        @echo $(findstring $(str1), $(str2))

 示例 uboot makefile是否编译

# Allow for silent builds
ifeq (,$(findstring s,$(MAKEFLAGS)))
XECHO = echo
else
XECHO = :
endif

2. origin

$(origin var)

返回 var 的来源

可能返回:

undefined
enviroment
default
file
command line
override
automatic

示例

ifeq ("$(origin O)", "command line")
BUILD_DIR := $(O)
endif

3.if

$(if <condition>, <then_return>, [else_return])

如果condition 不为空,则condition为真,则返回 then_return 的内容,否则返回 else_return

示例

OBJTREE         := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))

猜你喜欢

转载自www.cnblogs.com/yangxinrui/p/12670352.html