title: Makefile removes object files for no reason
body: <p>Here is the Makefile code:</p>
  
  <pre><code>CC=gcc 
  CXX=g++ 
  OBJS=OMXComponent.o Event.o hello_jpeg.o JPEG.o OMXCore.o Locker.o Logger.o
  BIN=hello_jpeg.bin
  
  # include ../Makefile.include
  
  
  CFLAGS+=-DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi
  
  LDFLAGS+=-L$(SDKSTAGE)/opt/vc/lib/ -lGLESv2 -lEGL -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lpthread -lrt -L../libs/ilclient -L../libs/vgfont
  
  INCLUDES+=-I$(SDKSTAGE)/opt/vc/include/ -I$(SDKSTAGE)/opt/vc/include/interface/vcos/pthreads -I$(SDKSTAGE)/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont
  
  all: $(BIN) $(LIB)
  
  %.o: %.c
      @rm -f $@ 
      $(CC) $(CFLAGS) $(INCLUDES) -g -c $&lt; -o $@ -Wno-deprecated-declarations
  
  %.o: %.cpp
      @rm -f $@ 
      $(CXX) $(CFLAGS) $(INCLUDES) -g -c $&lt; -o $@ -Wno-deprecated-declarations
  
  %.bin: $(OBJS)
      $(CC) -o $@ -Wl,--whole-archive $(OBJS) $(LDFLAGS) -Wl,--no-whole-archive -rdynamic
  </code></pre>
  
  <p>I am not sure why, but suddenly when I am calling my Makefile, it started deleting all the object files !!! It was not deleting before, but lately after running the Makefile, this is 
  what I get in the console window:</p>
  
  <pre><code> rm OMXCore.o JPEG.o OMXComponent.o Logger.o hello_jpeg.o Locker.o Event.o
  </code></pre>
  
  <p>Any idea why it is removing my object files? and how to stop Make from deleting it? 
  What is even more strange is that it was not deleting it yesterday, and it all started today, without me doing any upgrades or making any changes!!!
  Now when I make a small change in one of my src files, now I have to wait a long time for all the other object files to rebuilt again, which is not necessary and it slows me down.</p>
  
  <p>I am making sure that I am in the correct directory, 
  I even gave "make" a complete path, in case if it is picking up a different Makefile</p>
  
  <p>make -f /my_full_path/Makefile </p>
  
  <p>While Makefile was running, I was doing "ls" in a different terminal, and I noticed that I am correctly accumulating object files, as below:</p>
  
  <pre><code>-rw-rw-r-- 1 pi pi   1170 Mar  3 19:28 Makefile
  -rw-r--r-- 1 pi pi 482052 Mar  3 19:30 OMXComponent.o
  -rw-r--r-- 1 pi pi  19984 Mar  3 19:30 Event.o
  -rw-r--r-- 1 pi pi  14688 Mar  3 19:30 hello_jpeg.o
  -rw-r--r-- 1 pi pi 162260 Mar  3 19:31 JPEG.o
  -rw-r--r-- 1 pi pi 215492 Mar  3 19:31 OMXCore.o
  -rw-r--r-- 1 pi pi  76384 Mar  3 19:31 Locker.o
  -rw-r--r-- 1 pi pi      0 Mar  3 19:31 Logger.o
  </code></pre>
  
  <p>But all of a sudden, after everything is built, all the object files get removed !!!</p>
  
  <p>And, here is the output of the Makefile command:</p>
  
  <pre><code>pi@raspberrypi /opt/vc/src/hello_pi/hello_jpeg_v2 $ make -f /opt/vc/src/hello_pi/hello_jpeg_v2/Makefile 
  g++ -g -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont -g -c OMXComponent.cpp -o OMXComponent.o -Wno-deprecated-declarations
  g++ -g -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont -g -c Event.cpp -o Event.o -Wno-deprecated-declarations
  g++ -g -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont -g -c hello_jpeg.cpp -o hello_jpeg.o -Wno-deprecated-declarations
  g++ -g -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont -g -c JPEG.cpp -o JPEG.o -Wno-deprecated-declarations
  g++ -g -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont -g -c OMXCore.cpp -o OMXCore.o -Wno-deprecated-declarations
  g++ -g -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont -g -c Locker.cpp -o Locker.o -Wno-deprecated-declarations
  g++ -g -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont -g -c Logger.cpp -o Logger.o -Wno-deprecated-declarations
  g++ -g -o hello_jpeg.bin -Wl,--whole-archive OMXComponent.o Event.o hello_jpeg.o JPEG.o OMXCore.o Locker.o Logger.o -L/opt/vc/lib/ -lGLESv2 -lEGL -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lpthread -lrt -L../libs/ilclient -L../libs/vgfont -Wl,--no-whole-archive -rdynamic
  rm OMXCore.o JPEG.o OMXComponent.o Logger.o hello_jpeg.o Locker.o Event.o
  </code></pre>