- 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
COMPILER=g++
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
.PHONY:all
all: $(TARGET)
$(TARGET): $(OBJS)
$(COMPILER) $(CFLAGS) $(SEARCHDIRS) $(GLOBALS) $(OBJS) $(LIBS) -o $(TARGET)
%.o: %.cpp
$(COMPILER) $(CFLAGS) $(SEARCHDIRS) $(GLOBALS) -o $@ -c $<
.PHONY:clean
clean:
-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:
Post a Comment