可变参数列表到Makefile [英] Variable arguments list to a Makefile
本文介绍了可变参数列表到Makefile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做些类似的事情.我想要一个Makefile的变量参数列表.
I would like do something like following. I would like to have a variable argument list for a Makefile.
make VAR_ARG_LIST=src1,src2,src3,src4
我可以这样吗?如果可以,如何从Makefile中的变量VAR_ARG_LIST中提取src1,src2或src3?
Can I do like this? If I can, how do I extract src1,src2 or src3 from the variable VAR_ARG_LIST inside the Makefile?
谢谢
推荐答案
您确实没有为解决方案提供足够的信息.为什么要提取这些值?您想和他们做什么?
You really haven't provided enough information for a solution. Why do you want to extract those values? What do you want to do with them?
但是,我可以回答您提出的问题,并希望它会有用.如果您使用的是GNU make,则可以执行以下操作:
However, I can answer the question you asked and hope it is useful. If you're using GNU make you can do this:
COMMA := ,
VAR_ARG_LIST_A := $(subst $(COMMA), ,$(VAR_ARG_LIST))
VAR_ARG_LIST_1 := $(word 1,$(VAR_ARG_LIST_A))
VAR_ARG_LIST_2 := $(word 2,$(VAR_ARG_LIST_A))
等
这篇关于可变参数列表到Makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文