Easy Makefiles

Here's a handy g++ option that will let you make up accurate makefiles in a jiffy, -MM.

g++ -MM *.cpp

Run that on your source directory and you'll get a makefile style list of includes. If it doesn't work, make sure you add in your compile time defines (like -D_x86 -D_LINUX). This won't actually check that you need the files you have included, it just makes a list of the ones you have included.

I like to add a sed line to make breaks between source files, like so.

g++ -MM *.cpp | sed 's/^\([a-zA-Z]\)/\n\1/'

It's very literal though, so if you do "../StaticDevice.h" type includes, watch out for double entries.

$ g++ -MM -D_x86 -D_LINUX devices/*.cpp | sed 's/^\([a-zA-Z]\)/\n\1/'

BaseDevice.o: devices/BaseDevice.cpp devices/BaseDevice.h devices/Enums.h

BaseStream.o: devices/BaseStream.cpp devices/BaseStream.h

CameraTest.o: devices/CameraTest.cpp devices/../camera.h \
  devices/../devices/Nikon/NikonDevice.h \
  devices/../devices/Nikon/../StaticDevice.h \
  devices/../devices/StaticDevice.h \
  devices/../devices/Panasonic/PanasonicDevice.h \
  devices/../devices/Panasonic/../StaticDevice.h \
  devices/../devices/BaseDevice.h devices/../devices/Enums.h \
  devices/../devices/Prosilica/ProsilicaStaticDevice.h \
  devices/../devices/Prosilica/ProsilicaDevice.h \
  devices/../devices/Prosilica/../BaseDevice.h \
  devices/../devices/Prosilica/ProsilicaDeviceConfigurator.h \
  devices/../devices/Prosilica/../inc-pc/PvApi.h \
  devices/../devices/Prosilica/../Enums.h \