1 # override with `make BUILD=release`
2 # default to debug build
5 # You must create the file "local.properties" on your local machine which contains any local paths, etc
6 # local_settings.mk should NOT be committed to repo
7 include ./local.properties
8 # GTEST_DIR contains the path to Google Test libs and must be defined in local.properties
10 # GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
12 # NOTE: to run app, make sure that LD_LIBRARY_PATH env variable
13 # contains $(GTEST_DIR)/lib/.libs
24 CC_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -std=c99 -fpic -D TB_LOG
25 CC_FLAGS.release := -O0 -g3 -Wall -c -fmessage-length=0 -std=c99 -fpic
26 CC_FLAGS := $(CC_FLAGS.$(BUILD))
28 CXX_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -std=c++0x -fpic -D TB_LOG
29 CXX_FLAGS.release := -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -fpic
30 CXX_FLAGS := $(CXX_FLAGS.$(BUILD))
35 INC += -I$(GTEST_DIR)/include
38 # using make's computed variables to select object and bin folders
39 # depending on the build type
40 OBJ_DIR.debug := ./obj/debug
41 OBJ_DIR.release := ./obj/release
42 OBJ_DIR := $(OBJ_DIR.$(BUILD))
44 BIN_DIR.debug := ./bin/debug
45 BIN_DIR.release := ./bin/release
46 BIN_DIR := $(BIN_DIR.$(BUILD))
48 C_FILES := $(wildcard $(SRC_DIR)/*.c)
49 #CPP_FILES := $(wildcard $(SRC_DIR)/*.cpp)
50 CPP_FILES := $(wildcard $(TEST_DIR)/*.cpp)
51 OBJ_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o) $(C_FILES:.c=.o)))
52 H_FILES := $(wildcard $(TEST_DIR)/*.h)
53 H_FILES += $(wildcard $(INC_DIR)/*.h)
54 LD_FLAGS := -L/usr/lib
55 LD_FLAGS += -L$(GTEST_DIR)/lib/.libs
66 $(CXX) -o $@ $^ $(LD_FLAGS) $(LIBS)
67 mv ./$(PROG) ./$(BIN_DIR)
69 #$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/%.h $(H_FILES)
70 # $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<
72 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/%.h $(H_FILES)
73 $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<
75 $(OBJ_DIR)/%.o: $(TEST_DIR)/%.cpp $(H_FILES)
76 $(CXX) $(CXX_FLAGS) $(INC) -c -o $@ $<
82 rm -rf ./obj/release/*
84 rm -rf ./lib/release/*
86 rm -rf ./bin/release/*
87 rm -rf ./test/tst_*.txt
94 @echo 'BUILD = '$(value BUILD)
95 @echo 'INC = '$(value INC)
96 @echo 'CPP_FILES = '$(value CPP_FILES)
97 @echo 'LIBS = '$(value LIBS)