makefile中的条件分支

ifeq-else-endif

if-else形式:

ifeq(<arg1>,<arg2>)
语句1
else
语句2
endif

 如果带多个条件判断,使用下面的形式:

ifeq(<arg1>,<arg2>)
语句1
else ifeq(<arg3>,<arg4>)
语句2
else
语句3 
endif

其中,arg1 arg3可以是makefile中的变量,例如$(HARBOR),示例:根据港口的不同在工程中包含不同的文件:

ifeq ($(HARBOR), SHANG_HAI_TOPIC)
    include ./shanghaitopic.mk
else ifeq ($(HARBOR),SHANG_HAI)
    include ./shanghai.mk
else ifeq ($(HARBOR),SHUI_SHANG_GONG_AN)
    include ./shanghaigongan.mk
endif

ifneq-else-endif

ifneq(<arg1>,<arg2>)
语句1
else
语句2
endif

ifdef-endif

在ifdef语句中,变量名称不能加$(),例如:ifdef RELEASE

ifdef <variable-name>
语句1
endif

ifndef-endif

ifndef <variable-name>
语句1
endif

 

make文件学习:https://blog.csdn.net/haoel/article/details/2887

 

posted @ 2020-09-03 18:15  adfas  阅读(680)  评论(0编辑  收藏  举报