Monday, 7 September 2009

Makefile - incremental compilation

The big change from the last Makefile is that I am now separating my compiling so that only things that change get recompiled.


LIBS = -lGL \
-lboost_unit_test_framework \

INCPATH = -Iapp \
-Icritter \
-Ienvironment \
-Igraphics \
-Iui \
-Iutils \
-I/usr/local/Trolltech/Qt-4.4.3/include/QtCore \
-I/usr/local/Trolltech/Qt-4.4.3/include/QtGui \
-I/usr/local/Trolltech/Qt-4.4.3/include/QtOpenGL \
-I/usr/local/Trolltech/Qt-4.4.3/include \

all : TestGenome.o brain.o BrainParam.o misc.o genome.o
g++ $(CXXFLAGS) \
TestGenome.o \
brain.o \
BrainParam.o \
misc.o \
genome.o \
$(LIBS) \

TestGenome.o: test/TestGenome.cpp
g++ -c $(CXXFLAGS) test/TestGenome.cpp $(INCPATH)

brain.o: critter/brain.cp critter/brain.h
g++ -c $(CXXFLAGS) critter/brain.cp $(INCPATH)

BrainParam.o: critter/BrainParam.cp critter/BrainParam.h
g++ -c $(CXXFLAGS) critter/BrainParam.cp $(INCPATH)

misc.o: utils/misc.cp utils/misc.h
g++ -c $(CXXFLAGS) utils/misc.cp $(INCPATH)

genome.o: critter/genome.cp critter/genome.h
g++ -c $(CXXFLAGS) critter/genome.cp $(INCPATH)

If you look at the line beginning with 'brain.o:' you'll see that it is followed by 'critter/brain.cp' and 'critter/brain.h'. This specifies that if 'critter/brain.cp' or 'critter/brain.h' changes, then brain.o should be recompiled.

Though this is useful, there are still problems with dependencies. For example, what if 'critter/brain.h' refers to another header file that has changed? I'm not sure but I'll follow up on that soon.

No comments:

Post a Comment