Time Until Wedding
Days
Hours
Minutes
Seconds
 
Navigation
 
Search
 
My Usable Projects
 
Reading...
 
Listening...
 
Random Image
IMG_0253.JPG
 
Archives
 
Me. Elsewhere.
 
Feeds and Such

Google Reader or Homepage
Add to My Yahoo!
Add to Technorati Favorites!
Bookmark del.icio.us
Bookmark Furl
Bookmark Spurl
 
Darcy
 
Things I Like
GDB
 
License
 
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 \
  devices/../devices/Prosilica/../StaticDevice.h
$

Posted October 8th, 2007 - Permalink
Categories: Linux - Programming - Snippets - Uncategorized
You can leave a comment, or trackback from your own site.
 
Adjacent Posts
 
Comments