4
我试图使用命令行var来选择我们用来编译的工具包。当在命令行中我用这样一行:如何在生成文件中执行条件语句
make all-arm OUR_TOOLKIT=1
而且,在暗示每个Makefile,我把这个包括
include ARM_Compiler.inc
然后,在每个Makefile,
all: setToolkit $(otherOperations)
而ARM_Compiler的内容是选择编译器的逻辑:
setToolkit:
ifdef OUR_TOOLKIT
TOOLKIT=1
endif
ifdef CUSTOMER_TOOLKIT
TOOLKIT=2
endif
ifeq ($(TOOLKIT), 1)
$(info "=========Our toolkit selected======================")
rm=/bin/rm -f
CC= arm-linux-c++ -fPIC
CXX= arm-linux-c++ -fPIC
LINK= arm-linux-c++ -shared -Wl
AR= ar cq
RANLIB= ranlib
STRIP=arm-linux-strip
# para que se utilicen las herramientas y librerias del cross compiler
PATH:=$(PATH):/path/to/our/toolkit
LD_LIBRAY_PATH:=$(LD_LIBRAY_PATH):/path/to/our/toolkit
endif
ifeq ($(TOOLKIT), 2)
$(info "================Customer toolkit selected====================")
rm=/bin/rm -f
CC= arm-none-linux-gnueabi-c++ -fPIC
CXX= arm-none-linux-gnueabi-c++ -fPIC
LINK= arm-none-linux-gnueabi-c++ -shared -Wl
AR= ar cq
RANLIB= ranlib
STRIP= arm-none-linux-gnueabi-strip
# para que se utilicen las herramientas y librerias del cross compiler
PATH:=$(PATH):/path/to/other/toolkit
LD_LIBRAY_PATH:=$(LD_LIBRAY_PATH):/path/to/other/toolkit
endif
感谢0A0D的帮助,我发现TOOLKIT值总是空的。我已经改变了一些代码。现在的问题是,使引发错误
../makefile-includes/ARM-compiler.inc:10: *** commands commence before first target
在这一行:
ifeq ($(TOOLKIT), 1)
任何人有一些想法? 谢谢
类似:http://stackoverflow.com/questions/8811526/using-conditional-rules-in-a-makefile – 2012-06-04 15:28:05