makefile中的进程运行时生成列表

时间:2014-08-26 09:01:57

标签: makefile

我有几个列表,一个列表包含服务器IP地址,另一个列表包含端口号列表。我想处理每个服务器的每个端口。我有以下源代码,但它没有按照我想要的方式工作。如果查看makefile输出,您可以看到它仅处理第一台服务器的端口,即172.16.0.117。另一个问题是现在端口号是硬编码的,端口列表必须在目标$(GET_PORT_FILE)配方中自动生成。如果我在$(GET_PORT_FILE)配方中分配端口列表,则输出不会考虑任何端口进行处理。你能帮帮我吗?我怎样才能让它发挥作用。发布makefile源代码和输出。

Makefile source code:
SERVERS=172.16.0.117 172.16.0.147
PORTS:=16000 16001

LAUNCHES=$(addprefix Launch-server-, $(SERVERS))
GET_PORT_FILE=$(addprefix Get-port-file-from-server-, $(SERVERS))
CONNECT_SERVER=$(addprefix Connect-to-server-, $(SERVERS))
CONNECT_PORT=$(addprefix Connect-to-port-, $(PORTS))

test-all: test-port-connectivity

test-port-connectivity: $(LAUNCHES) $(GET_PORT_FILE) $(CONNECT_SERVER)
        echo "Test suit 1: Port Connectivity"

$(LAUNCHES):Launch-server-%:%
        echo "Launch Server $^"

$(GET_PORT_FILE):Get-port-file-from-server-%:%
        echo "Get file from server - $^"
#       $(eval PORTS=16000 16001)

$(CONNECT_SERVER):Connect-to-server-%:$(CONNECT_PORT)
        echo "Connect to server - $*"

$(CONNECT_PORT):Connect-to-port-%:%
        echo "Connect to port - $^"

$(SERVERS):

$(PORTS):

Output of makefile:
# make -f Makefile_TestFramework
echo "Launch Server 172.16.0.117"
Launch Server 172.16.0.117
echo "Launch Server 172.16.0.147"
Launch Server 172.16.0.147
echo "Get file from server - 172.16.0.117"
Get file from server - 172.16.0.117
echo "Get file from server - 172.16.0.147"
Get file from server - 172.16.0.147
echo "Connect to port - 16000"
Connect to port - 16000
echo "Connect to port - 16001"
Connect to port - 16001
echo "Connect to server - 172.16.0.117"
Connect to server - 172.16.0.117
echo "Connect to server - 172.16.0.147"
Connect to server - 172.16.0.147
echo "Test suit 1: Port Connectivity"
Test suit 1: Port Connectivity

0 个答案:

没有答案