title: Makefile: Test directories for existence and take first one found
body: <p>I am using a makefile to compile a MATLAB/C project.  MATLAB can typically be installed into a number of standard locations, depending on its version, e.g. <code>/Applications/MATLAB_2012b.app</code>, <code>/Applications/MATLAB_2013a.app</code>, etc.  </p>
  
  <p>What is the simplest way to see if these paths exist, one by one, and take the first one found?  There will be at least five values I'd like to test.  I found the <code>$(wildcard filename)</code> syntax, but I was wondering if there's anything shorter than writing these out one by one.</p>
  
  <hr>
  
  <p>Clarifications, as requested.  I can piece together something working, but I am sure that this is far from the best/most-concise way of doing this.  Is there a better way?</p>
  
  <pre><code>ifeq ($(MATLAB),)
  ifneq ($(wildcard /Applications/MATLAB_2011b.app),)
      MATLAB = /Applications/MATLAB_2011b.app
  endif
  endif
  
  ifeq ($(MATLAB),)
  ifneq ($(wildcard /Applications/MATLAB_2012a.app),)
      MATLAB = /Applications/MATLAB_2012a.app
  endif
  endif
  
  ifeq ($(MATLAB),)
  ifneq ($(wildcard /Applications/MATLAB_2012b.app),)
      MATLAB = /Applications/MATLAB_2012b.app
  endif
  endif
  
  ifeq ($(MATLAB),)
  ifneq ($(wildcard /Applications/MATLAB_2013a.app),)
      MATLAB = /Applications/MATLAB_2013a.app
  endif
  endif
  </code></pre>