Sunday, January 17, 2010

Make It Fast!

Sharing a template for an easy to use make file system.
  • Self-maintaining: No need for manually adding files.
  • Quick-and-dirty: Get started fast!

Here goes:

SOURCE_FILES= $(wildcard *.cpp) ../../commando/sonar/Sonar.cpp
# Automatically gets the file-list from the directory!
# Add extra files from other dirs at the end if needed (Sonar.cpp above)

OBJS=$(patsubst %.cpp, %.o,$(SOURCE_FILES))
# Rule for specifying object file list
# The rest of this is standard make-file stuff   
CFLAGS= -W -g -O0 -fexceptions -finline-functions -D_THREAD_SAFE -fpack-struct=4
#Compiler options
LIBS= -lboost_filesystem
#Libraries to link to
SEARCHDIRS = -I../inc -L../lib
#Include and library directories  

TARGET= ../../homebase/linux/nuboat
# Output file

all: $(TARGET)


%.o: %.cpp

-rm -f $(OBJS) $(TARGET)

You can use this so long as you don't have source files floating around in the Makefile's directory, which should not be included in the build.

No comments: