Makefile 在数组中查找
如果我有这样的内容:
PROJECTS += path/to/first
PROJECTS += path/to/second
PROJECTS += path/to/third
以及
LIBS += lib_output/first.lib
LIBS += lib_output/second.lib
LIBS += lib_output/third.lib
如何将 PROJECTS += path/to/first
中的项目与 LIBS += lib_output/first.lib
关联起来? makefile 中是否有类似哈希映射的内容?或者可以在数组中搜索?
If I have something like this:
PROJECTS += path/to/first
PROJECTS += path/to/second
PROJECTS += path/to/third
and
LIBS += lib_output/first.lib
LIBS += lib_output/second.lib
LIBS += lib_output/third.lib
How could I associate the project from PROJECTS += path/to/first
with LIBS += lib_output/first.lib
? Is there something like a hashmap available in a makefile? Or possibility to search in an array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用计算变量名称来模拟查找表以及创建变量名称的事实可以包含一些特殊字符,例如点和正斜杠:
输出:
You can simulate lookup tables using computed variable names and the fact that make variable names can include some special characters like dot and forward slash:
Outputs:
我不确定我是否完全理解你的问题,但我认为
word
函数可能正是你所需要的(它可能是 GNU make 扩展):$(word 2, $( PROJECTS))
返回路径/到/第二个
,$(word 2, $(LIBS))
返回lib_output/second.lib
。I'm not sure if I completely understand your question, but I think the
word
function might be what you need (it may be a GNU make extension):$(word 2, $(PROJECTS))
returnspath/to/second
,$(word 2, $(LIBS))
returnslib_output/second.lib
.