Makefile: compile *.cc separately
authorBrian Norris <banorris@uci.edu>
Tue, 3 Jul 2012 19:54:03 +0000 (12:54 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 3 Jul 2012 19:54:03 +0000 (12:54 -0700)
This Makefile rule doesn't have to include all *.cc files at once. They can be
compiled separately.

Note that this slows down compilation slightly, but it also allows better
parallel (jobserver) compilation; for example, you can use `make -j4' to
perform separate compilations using 4 different threads, utilizing a multi-core
system more effectively.

Makefile

index ddc89cb2440926aaf0551084fe89c88a3e2bbdfa..6ef1e94de3cc5e879d402dfe424b5b21c79b8120 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,8 +50,8 @@ mymemory.o: mymemory.h snapshotimp.h snapshot.h mymemory.cc
 snapshot.o: mymemory.h snapshot.h snapshotimp.h snapshot.cc
        $(CXX) -fPIC -c snapshot.cc $(CPPFLAGS)
 
-$(MODEL_O): $(MODEL_CC) $(MODEL_H)
-       $(CXX) -fPIC -c $(MODEL_CC) $(CPPFLAGS)
+%.o: %.cc $(MODEL_H)
+       $(CXX) -fPIC -c $< $(CPPFLAGS)
 
 clean:
        rm -f $(BIN) *.o *.so