我正在尝试根据条件在Makefile中定义变量。由于ifeq 只能在规则中运行,因此我添加了一个额外的规则(def_rule)供每个规则引用。
示例:
def_rule:
ifeq ($(TARGET), android)
CC=arm-linux-androideabi-gcc
else
echo "native build"
endf
all: def_rule tp xi_eid_chipset.o
很遗憾,调用make all会返回以下内容:
ifeq (linux, android)
/bin/sh: Syntax error: word unexpected (expecting ")")
make: *** [def_rule] Error 2
我无法弄清楚原因。我只是按照GNU Make文档中的示例进行操作。
您知道如何在Makefile中进行条件定义吗?