title: Creating two separate executables from a makefile (g++)
body: <p>Currently, I have my makefile set up to compile and make a fairly large project.  I have written a second cpp file with main function for running tests.  I want these to run separately, but build together and they use the same files.  How is this accomplished?</p>
  
  <p><strong>edit</strong>: As reference, here is my current makefile.  I'm not sure how to adjust it.</p>
  
  <pre><code>CC=g++
  CFLAGS=-c -Wall -DDEBUG -g
  LDFLAGS=
  SOURCES=main.cpp Foo.cpp Bar.cpp Test.cpp A.cpp B.cpp C.cpp
  OBJECTS=$(SOURCES:.cpp=.o)
  EXECUTABLE=myprogram
  
  all: $(SOURCES) $(EXECUTABLE)
  
  $(EXECUTABLE): $(OBJECTS)
      $(CC) $(LDFLAGS) $(OBJECTS) -o $@
  
  .cpp.o:
      $(CC) $(CFLAGS) $&lt; -o $@
  </code></pre>