gnu make - How to split in GNU makefile list of files into separate lines -
i have variable containing list of files separated string _newline_
. need output variable file each file in separate line. trick needs works on freebsd , solaris.
this trying now:
echo "lib/alarms-1.2/priv/snmp_conf/agent.conf: lib/alarms/priv/snmp_conf/agent.conf_newline_lib/alarms-1.2/priv/snmp_conf/agent.conf.src: lib/alarms/priv/snmp_conf/agent.conf.src_newline_lib/alarms-1.2/priv/snmp_conf/community.conf: lib/alarms/priv/snmp_conf/community.conf" | sed 's|_newline_|\'$'\n|g'
this works on freebsd , in shell on solaris. when run in gnumakefile on solaris getting (notice $ @ end of each line):
lib/alarms-1.2/priv/snmp_conf/agent.conf: lib/alarms/priv/snmp_conf/agent.conf$ lib/alarms-1.2/priv/snmp_conf/agent.conf.src: lib/alarms/priv/snmp_conf/agent.conf.src$ lib/alarms-1.2/priv/snmp_conf/community.conf: lib/alarms/priv/snmp_conf/community.conf$
if remove \'$'
sed works on solaris doesn't on freebsd. maybe there way of telling version utilize depending on scheme makefile executed?
edit: solution proposed bobbogo created exemplary makefile provides desired outcome , seems working on both freebsd , solaris:
one-line := lib/alarms-1.2/priv/snmp_conf/agent.conf: lib/alarms/priv/snmp_conf/agent.conf_newline_lib/alarms-1.2/\ priv/snmp_conf/agent.conf.src: lib/alarms/priv/snmp_conf/agent.conf.src_newline_lib/alarms-1.2/priv/snmp_conf/comm\ unity.conf: lib/alarms/priv/snmp_conf/community.conf many-lines := { echo '$(subst _newline_,' && echo ',${one-line})'; } .phony: all: $(shell $(many-lines) > test.txt)
if gnu make, in make.
one-line := lib/alarms-1.2/priv/snmp_conf/agent.conf: lib/alarms/priv/snmp_conf/agent.conf_newline_lib/alarms-1.2/priv/snmp_conf/agent.conf.src: lib/alarms/priv/snmp_conf/agent.conf.src_newline_lib/alarms-1.2/priv/snmp_conf/community.conf: lib/alarms/priv/snmp_conf/community.conf define \n endef many-lines := $(subst _newline_,${\n},${one-line})
now ${many-lines}
has want. annoyingly, it's quite hard utilize in shell lines. if this:
tgt: echo '${many-lines}'
make invoke separate shell each line. first shell invocation un-paired '
, exit error.
.oneshell: tgt: echo '${many-lines}'
will work in invasive sort of way. proper prepare ensure each line of ${many-lines}
has valid sh syntax. mouthfull like:
echolines = $(subst ${\n},'${\n}echo ',echo '${many-lines}') .phony: aa aa: $(call echolines,${many-lines})
sheesh.
makefile gnu-make freebsd solaris-10
No comments:
Post a Comment