I'm trying to organize a Makefile with complex commands into something more readable.
I'm trying to break down a long list of parameters, but even single parameters are too bad, hence I wanted to break them too. But I cannot find a way to avoid unwanted spaces for these cases
# network and forward ports
QEMU_NET_FLAGS=-nic user
QEMU_NET_FLAGS+=,id=n1,restrict=on,ipv6=off,hostname=$(VMNAME)
# port forwards:
# hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport
QEMU_NET_FLAGS+=,hostfwd=tcp::$(VMSSH)-:22
QEMU_NET_FLAGS+=,hostfwd=tcp::8000-:8000
QEMU_NET_FLAGS+=,hostfwd=tcp::8080-:8080
QEMU_NET_FLAGS+=,hostfwd=tcp::8081-:8081
Will cause -nic user ,id=1...
instead of -nic user,id=1...
## Tried ::=
First suggestion by @steeldriver:
QEMU_NET_FLAGS::=-nic user
QEMU_NET_FLAGS::=$(QEMU_NET_FLAGS),id=n1,restrict=on,ipv6=off,hostname=$(VMNAME)
QEMU_NET_FLAGS::=$(QEMU_NET_FLAGS),hostfwd=tcp::$(VMSSH)-:22
causes another problem since these are "templates", and variables like VMNAME
and VMSSH
should resolve late (recursively) when the resulting command line is used. And if I use :::=
to then +=
values recursively, we are back to the unwanted space problem.
Asked by gcb
(632 rep)
May 14, 2024, 07:46 PM
Last activity: May 15, 2024, 11:12 AM
Last activity: May 15, 2024, 11:12 AM