【问题标题】:How to tell if a flag in already defined in a variable?如何判断一个标志是否已经在变量中定义?
【发布时间】:2015-07-03 03:31:57
【问题描述】:

我有一个makefile,我想有条件地在其中包含一个特定的src 文件。 makefile 看起来像:

###############################################
# Load default top-level config
include $(WORKROOT)/build/linux/config.mk

ifndef START_TIME
  export START_TIME:="$(shell date +%s)"
endif

#include $(MAK_DIR)/source.inc
include $(WORKROOT)/build/linux/source.inc  

config.mk 中是这样的:

export FLAGS = \
-DFLAGA \
-DFLAGB

source.inc我想:

#IF FLAGA is defined in FLAGS in config.mk THEN:
my-objs += \
$(WORKROOT)/My_DIR/specific_src.cpp
#ENDIF

我该怎么做?

【问题讨论】:

    标签: linux bash makefile


    【解决方案1】:

    如果您在FLAGS 变量中查找文字字符串-DFLAGA,则可以使用$(filter) function

    ifneq (,$(filter -DFLAGA,$(FLAGS)))
    my-objs += \
    $(WORKROOT)/My_DIR/specific_src.cpp
    endif
    

    【讨论】:

      猜你喜欢
      • 2011-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-19
      • 1970-01-01
      • 2020-07-21
      • 1970-01-01
      相关资源
      最近更新 更多