我正在尝试使用命令行var来选择我们用来编译的工具包.在命令行中我使用如下行:
make all-arm OUR_TOOLKIT=1
Run Code Online (Sandbox Code Playgroud)
并且,在每个makefile暗示,我把这包括
include ARM_Compiler.inc
Run Code Online (Sandbox Code Playgroud)
然后,在每个makefile中,
all: setToolkit $(otherOperations)
Run Code Online (Sandbox Code Playgroud)
而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
Run Code Online (Sandbox Code Playgroud)
感谢0A0D的帮助,我发现TOOLKIT值始终为空.我已经改变了一点代码.现在问题是make抛出错误
../makefile-includes/ARM-compiler.inc:10: *** commands commence before first target
Run Code Online (Sandbox Code Playgroud)
在这一行:
ifeq ($(TOOLKIT), 1)
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?谢谢
这个问题的变体出现了很多.
每个命令都在自己的子shell中执行; 在一个命令中设置的变量不能在另一个命令中使用.
但是您可以在规则之外设置变量:只需从上面的条件语句中删除所有主要的TAB.这将适用于除PATH和之外的所有事情LD_LIBRARY_PATH.在我看来,这些都不是Make应该弄乱的东西,但是有办法获得你想要的效果.你可以PATH像这样处理:
ifeq ($(TOOLKIT), 1)
TOOLKITPATH = /path/to/our/toolkit
endif
...
sometarget:
$(TOOLKITPATH)/sometool somearg
Run Code Online (Sandbox Code Playgroud)
或者像这样:
all:
export PATH=$$PATH:$(TOOLKITPATH) ; $(MAKE) $(otherOperations)
Run Code Online (Sandbox Code Playgroud)
你根本不应该使用它LD_LIBRARY_PATH.
| 归档时间: |
|
| 查看次数: |
10610 次 |
| 最近记录: |