在Makefile中合并两个列表

在Makefile中合并两个列表,makefile,Makefile,makefile中有以下两个列表: SERVERS=172.16.0.117 172.16.0.147 PORTS=1600 1601 我想要新的清单如下 172.16.0.117-1600 172.16.0.17-1601 172.16.0.147-1600 172.16.0.147-1601 我不知道我做错了什么。你能帮我一下吗?请看一下makefile源代码和输出。提前谢谢 Makefile源代码: SERVERS=172.16.0.117 172.16.0.147 PORTS=160

makefile中有以下两个列表:

SERVERS=172.16.0.117 172.16.0.147
PORTS=1600 1601
我想要新的清单如下

172.16.0.117-1600 172.16.0.17-1601 172.16.0.147-1600 172.16.0.147-1601
我不知道我做错了什么。你能帮我一下吗?请看一下makefile源代码和输出。提前谢谢

Makefile源代码:

SERVERS=172.16.0.117 172.16.0.147
PORTS=1600 1601

SERVER=$(addprefix Connect-to-, $(SERVERS))
PORT=$(addprefix $(SERVER)-, $(PORTS))

testall:
        echo "PORTS - $(PORT)"

Output of makefile:
#make
echo "PORTS - Connect-to-172.16.0.117 Connect-to-172.16.0.147-1600 Connect-to-172.16.0.117 Connect-to-172.16.0.147-1601"
PORTS - Connect-to-172.16.0.117 Connect-to-172.16.0.147-1600 Connect-to-172.16.0.117 Connect-to-172.16.0.147-1601
像这样的

PORT := $(foreach p,$(PORTS),$(patsubst %,%-$p,$(SERVERS)))

addprefix
采用单个前缀,而不是前缀列表。因此,这就是将
$(服务器)
的全部值预先添加到
$(端口)
中的每个单词中。为了更清楚地了解您的输出,这里有
端口-“Connect-to-172.16.0.117 Connect-to-172.16.0.147-1600”“Connect-to-172.16.0.117 Connect-to-172.16.0.147-1601”