title: Makefile - loop through a list and select a specific value
body: <p>I'm trying to do something like this (assuming $input is something provided by the user):</p>
  
  <pre><code>LIST = pre1 pre2 pre3 pre4 pre5 pre6 pre7 pre8 pre9 pre10
  START = 0
  
  for prefix in $(LIST); do \
      if $(input) == $(prefix) then
          START = 1
      endif \
      if $(START) == 1 then \
          if [ -f  $(prefix)&lt;file_name&gt; ]; then &lt;do_A&gt;; else &lt;do_B&gt;; fi
      endif \
  done
  </code></pre>
  
  <p>my problem is with the two if's mentioned above. i don't know how can i choose a specific string value from a list while iterating it (if $(input) == $(prefix) then) and i don't know how to check if a value is 1 or 0 (if $(START) == 1 then).</p>
  
  <p>My intent with this code is to use the same makefile for different directories which have the same file name, but with a different prefix. sometimes, a directory might contain multiple versions of the file with a different prefix and i want to define a hierarchy of those prefixes (defined by LIST in my example). when the user provide a version, the idea is to start searching for the most up-to date version, starting from the version he provides (e.g. if the user provide pre4, then i need to search pre4 first and if it's not exist - i'll go on and search for pre5 and so on. but in this example, i won't search for pre1 even if it do exist in the current directory).</p>
  
  <p>Anyone has an idea on how can i do that?</p>
  
  <p>Thanks in advance.</p>