Makefile: Splitting a string and looping through results
<p>I am trying to write a target in a makefile which will read a variable(having IPs) from one of the .mk file and if a space separated list found split it and take some action. </p>

<p>Issue i am facing that the string do not split and in for loop do not get the value either.</p>

<p>Have tried following</p>

<pre><code>GWTS_FE_IPS=2600:40f0:3e::2 2600:40f0:3e::3 2600:40f0:3e::4 2600:40f0:3e::5

test:
    $(eval IPS=$(shell echo "$(GW_IPS)" |awk -F " " '{print NF}'))
    if [ ${IPS} -gt 1 ]; then \
        echo "Multiple Ips [$(GW_IPS)]"; \
        for ip in $(shell echo "${GW_IPS}" | sed -e 's/ /\n/g'); \
        do \
            echo ".... $(ip) ...."; \
        done \
    else \
        echo "Single IP [$(GW_IPS)]"; \
    fi
</code></pre>

<p>Result i get is </p>

<pre><code>2600:40f0:3e::2n2600:40f0:3e::3n2600:40f0:3e::4n2600:40f0:3e::5
if [ 4 -gt 1 ]; then \
        echo "Multiple Ips [2600:40f0:3e::2 2600:40f0:3e::3 2600:40f0:3e::4 2600:40f0:3e::5]"; \
        for ip in 2600:40f0:3e::2n2600:40f0:3e::3n2600:40f0:3e::4n2600:40f0:3e::5; \
        do \
            echo "....  ...."; \
        done \
    else \
        echo "Single IP [2600:40f0:3e::2 2600:40f0:3e::3 2600:40f0:3e::4 2600:40f0:3e::5]"; \
    fi
Multiple Ips [2600:40f0:3e::2 2600:40f0:3e::3 2600:40f0:3e::4 2600:40f0:3e::5]
....  ....
</code></pre>

<p>Can any one give some pointers.</p>