title: Conditional variable define in Makefile with ifeq
body: <p>I am trying to define variables in a Makefile, according to conditions. As ifeq can be run only in rules, I have added an additional rule (def_rule) I refer to for each rule.</p>
  
  <p>Example:</p>
  
  <pre><code>def_rule:
  ifeq ($(TARGET), android)
      CC=arm-linux-androideabi-gcc
  else
      echo "native build" 
  endf
  
  all:    def_rule tp xi_eid_chipset.o
  </code></pre>
  
  <p>Unfortunately, invoking make all returns this:</p>
  
  <blockquote>
    <p>ifeq (linux, android)<br>
    /bin/sh: Syntax error: word unexpected (expecting ")")<br>
    make: *** [def_rule] Error 2</p>
  </blockquote>
  
  <p>I cannot figure out why. I have just followed examples in GNU Make documentation.</p>
  
  <p>Do you know how to do conditional defines in Makefiles ?</p>