Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to split in GNU makefile list of files into separate lines
    primarykey
    data
    text
    <p>I have a variable containing list of files separated with string <code>_NEWLINE_</code>. I need to output that variable into a file so that each file is in a separate line. The trick is that it needs to works on FreeBSD and Solaris.</p> <p>This is what I am trying now:</p> <pre><code>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' </code></pre> <p>This works on FreeBSD and in shell on Solaris. But when run in GNUmakefile on Solaris I am getting this (notice $ at the end of each line):</p> <pre><code>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$ </code></pre> <p>If I remove <code>\'$'</code> from sed then it works on Solaris but doesn't on FreeBSD. Maybe there is a way of telling which version to use depending on which system the makefile is executed?</p> <p><strong>EDIT:</strong> Thanks to the solution proposed by <strong>bobbogo</strong> I created an exemplary makefile that provides the desired outcome and seems to be working on both FreeBSD and Solaris:</p> <pre><code>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_,' &amp;&amp; echo ',${one-line})'; } .PHONY: all all: $(shell $(many-lines) &gt; test.txt) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload