背景:我有一个定制的工具链,将由Makefile使用。工具链被签出(通过svn:externals)到项目的工作副本中。Makefile必须调整PATH变量。否则,无法找到工具链二进制文件。在´.bashrc´或´.profile´中调整“PATH”是没有选择的,因为有几个项目使用不同版本的工具链。
请参见这个很小的Makefile,演示了对交叉编译器‘cc’的调用,它位于/home/edeviser/bin中的其他几个工具旁边:
export PATH:=/home/edeviser/bin:$(PATH)$
$(info Compiler used: $(shell which cc))
all:
@echo "Compiler used: $(shell which cc)"
@echo -n "Compiler used: "
@which cc调用make后的输出
Compiler used: /usr/bin/cc
Compiler used: /usr/bin/cc
Compiler used: /home/edeviser/bin/cc我的期望是:
Compiler used: /home/edeviser/bin/cc
Compiler used: /home/edeviser/bin/cc
Compiler used: /home/edeviser/bin/cc如何修改GNU中的路径并使用$(shell .)执行命令成功?
发布于 2020-09-02 13:23:03
您必须编写如下shell调用:
$(info Compiler used: $(shell PATH='$(PATH)' which cc))若要在shell函数中设置路径,请执行以下操作。
https://stackoverflow.com/questions/63701012
复制相似问题