title: Makefile - remove ../ from path
body: <p>I have object files coming in with paths that might look like this:</p>
  
  <pre><code> '../../src/foo/bar.c'
  </code></pre>
  
  <p>I'd like them to be output to</p>
  
  <pre><code> 'build/src/foo/bar.o'
  </code></pre>
  
  <p>Currently using:</p>
  
  <pre><code> COBJS      :=  $(notdir $(CFILES))
   COBJS      :=  $(patsubst %,$(BUILD)%.o,$(COBJS))
  </code></pre>
  
  <p>I can achieve</p>
  
  <pre><code> 'build/bar.o'
  </code></pre>
  
  <p>This is problematic if any two library/project contains the same class name.</p>
  
  <p>So the question is, how can one remove multiple '../' from a path in Make.  I've attempted the obvious and naive approaches with no results.</p>
  
  <p>Update, the following will match exactly ../../ and replace it with the rest.  This is perfect except that it is specific to ../../.  Just need to make it match any number of ../../</p>
  
  <pre><code> COBJS      :=  $(CFILES:../../%=%)
  </code></pre>
  
  <p>Update,</p>
  
  <p>SOLVED, just three reputation shy of posting my own answer.</p>
  
  <pre><code> COBJS      :=  $(subst ../,,$(CFILES))
  </code></pre>