title: Makefile - move object files
body: <p>After a bit of searching, I've managed to throw together the following Makefile:</p>
  
  <pre><code>CC = gcc
  CFLAGS = -c -Wall
  LDFLAGS = 
  SOURCEFILES = main.c
  SOURCES = src/$(SOURCEFILES)
  OBJECTS = $(SOURCES:.c=.o)
  EXECUTABLE = netsim
  
  all: $(SOURCES) $(EXECUTABLE)
  
  $(EXECUTABLE): $(OBJECTS)
      $(CC) $(LDFLAGS) $(OBJECTS) -o $@
  
  .c.o:
      $(CC) $(CFLAGS) $&lt; -o $@
  
  clean:
      rm -rf netsim $(OBJECTS)
  </code></pre>
  
  <p>I would like to be able to move my object files into another directory, but have been struggling with getting that to work. What am I missing?</p>