title: How to replace entries of a makefile variable
body: <p>I have a variable <code>MY_VAR</code> inside a Makefile defined as <code>MY_VAR = read orange yellow blue green white black</code>. I am trying to write a Makefile function/macro that takes a list of colors as input and replaces them by appending a suffix to them. Inside the Makefile I can do this as
  <code>MY_NEW_VAR = $(shell echo $(MY_VAR) | sed -e 's/black/blackcolor/' -e 's/red/redcolor/' -e 's/white/whitecolor/')</code> but running into problems when doing this using a function with <code>for</code> loop.</p>
  
  <pre><code>define append_color
  for color in $(2); do \
    $(eval $(1) += $(shell echo $(MY_VAR) | sed 's/$$color/$$color$(3)/')); \
  done;      
  endef  
  </code></pre>
  
  <p>Here <code>$2</code> is the list of colors to replace and <code>$(1)</code> will contain the result and <code>$3</code> contains the suffix to append.
  Below is the function call inside Makefile:</p>
  
  <pre><code>MY_VAR = read orange yellow blue green white black
  $(call append_color,MY_NEW_VAR,black red white,color)    
  </code></pre>
  
  <p>The makefile returns the following error at the point of call to this function inside the Makefile:</p>
  
  <pre><code>Makefile.mk:50: *** missing separator.  Stop.  
  </code></pre>
  
  <p>Any suggestions on what I am missing or alternatives for doing the same ?</p>
  
  <p>Thanks    </p>