title: How to write build target for sources from different paths?
body: <p><em>At first, I'm a noobie in makefiles...</em><br>
  I have next targets in my <strong>Makefile</strong>:  </p>
  
  <pre><code>$(BUILD_PATH)/%.o: %.c $(GEN_PATH)/%.c
      $(CC) $(FLAGS) $(CFLAGS) $(HEADERS) -c $&lt; -o $@
  
  server: $(BUILD_PATH)/main.o $(BUILD_PATH)/socket.o $(BUILD_PATH)/settings.o $(BUILD_PATH)/options.o
      $(CC) -L$(LIB_PATH) -Wl,-rpath=$(LIB_PATH) $(FLAGS) $(CFLAGS) -o $(DIST_PATH)/server $^ $(LDFLAGS)
  </code></pre>
  
  <p>I specified that object files must be compiled from the current folder and <code>$(GEN_PATH)</code> but it doesn't work and I am getting error:  </p>
  
  <pre><code>make: *** No rule to make target '../build/server/options.o', needed by 'server'.  Stop.
  </code></pre>
  
  <p><strong>How can I write this rule right?</strong></p>
  
  <p><strong>P.S.</strong> It's not primary question but how can I write my input targets shorter? I tried this variant:  </p>
  
  <pre><code>server: $(BUILD_PATH)/%.o
      $(CC) -L$(LIB_PATH) -Wl,-rpath=$(LIB_PATH) $(FLAGS) $(CFLAGS) -o $(DIST_PATH)/server $^ $(LDFLAGS)
  </code></pre>
  
  <p>But it didn't work.</p>