title: Working with makefile and subdirectories
body: <p>I'm trying to figure out how to use makefile and subdirectories. But unluck till now. I want to put all the .o files in an "build" subdirecotry, all the .cpp should be in an "src" and the executable file in an "bin" file.</p>
  
  <p>And this makefile was my attempt:</p>
  
  <pre><code>PROG = prog1
  BINPATH = bin/
  CC = g++
  CPPFLAGS = -Wall -pedantic -ansi -Iinclude
  OBJS = main.o calc.o show.o
  BUILDPATH = build/
  SRCPATH = src/$(PROG):$(BUILDPATH)$(OBJS)
  $(CC) -o $(BINPATH)$(PROG) $(BUILDPATH)$(OBJS)
  $(BUILDPATH)main.o:
      $(CC) $(CPPFLAGS) -c $(SRCPATH)main.cpp
  $(BUILDPATH)cacula.o:calc.h
      $(CC) $(CPPFLAGS) -c $(SRCPATH)calc.cpp
  $(BUILDPATH)show.o:show.h
      $(CC) $(CPPFLAGS) -c $(SRCPATH)show.cpp
  clean:
      rm -f core $(BINPATH)$(PROG) $(BUILDPATH)$(OBJS)
  </code></pre>