title: makefile: find a position of word in a variable
body: <p>In my makefile, I need to make a variable assignment based on a command line variable value. for example, I do:</p>
  
  <pre><code>make var_1=xxx
  </code></pre>
  
  <p>where <code>var_1</code> can have one of say 100 possible values. Based on the value of <code>var_1</code>, I need to assign a value to <code>var_2</code> in my makefile. I could do:</p>
  
  <pre><code>ifeq ($(var_1), a)
     var_2 = A
  endif
  ifeq ($(var_1), b)
     var_2 = B
  endif
  </code></pre>
  
  <p>and so on for all 100 possible combinations of <code>var_1</code>, <code>var_2</code>. Here <code>a</code>,<code>A</code>,<code>b</code>,<code>B</code> represent some strings. How do I do this to avoid 100's of <code>if</code> statements? I was thinking to define two variables:</p>
  
  <pre><code>var_1_values = a b c d     
  var_2_values = A B C D
  </code></pre>
  
  <p>I can use <code>$(findstring $(var_1),$(var_1_values))</code> to see if <code>$(var_1)</code> is among <code>$(var_1_values)</code>, but how do I locate the position of <code>$(var_1)</code> among all <code>$(var_1_values)</code>? That position is then to be used to pick the corresponding word inside <code>$(var_2_values)</code>.</p>