Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables Make变量中的扩展_Variables_Makefile_Autotools_Automake - Fatal编程技术网

Variables Make变量中的扩展

Variables Make变量中的扩展,variables,makefile,autotools,automake,Variables,Makefile,Autotools,Automake,我的Makefile中有两个变量: archs = i386 x86_64 tarball = foo-i386 foo-x86_64 正如你看到的,我的第二个变量实际上是基于第一个变量。但是我想要一些类似正则表达式扩展的东西来使用第一个变量,比如: tarball = foo-$(archs) 但它不是这样工作的。这在GNU Make中扩展为: tarball = foo-i386 x86_64 分配使用myarchs变量的tarball变量的最佳方法是什么?当您可以依赖GNU make

我的Makefile中有两个变量:

archs = i386 x86_64
tarball = foo-i386 foo-x86_64
正如你看到的,我的第二个变量实际上是基于第一个变量。但是我想要一些类似正则表达式扩展的东西来使用第一个变量,比如:

tarball = foo-$(archs)
但它不是这样工作的。这在GNU Make中扩展为:

tarball = foo-i386 x86_64

分配使用my
archs
变量的
tarball
变量的最佳方法是什么?

当您可以依赖GNU make时,
foreach
函数就是您的朋友

若否,建造工程为何?

tarball = $(archs:%=foo-%)

也适用于其他品牌。但是,它仍然依赖于功能。
addprefix
函数不是比
foreach
容易得多吗?@eriktous:“很多”取决于你对很多的定义。我不想费心去记住addprefix和addsuffix,因为$(foreach%,%-foo,)做同样的工作。