1 # override with `make BUILD=release`
2 # default to debug build
5 # You must create the file "local.propertiessudo" 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
21 TEST_DIR:= ../../test/linux
22 INC_DIR := ../../include
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
67 $(CXX) -o $@ $^ $(LD_FLAGS) $(LIBS)
68 # $(CXX) -o $@ $^ $(GTEST_DIR)/make/gtest_main.a -lpthread
69 mv ./$(PROG) ./$(BIN_DIR)
71 #$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/%.h $(H_FILES)
72 # $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<
74 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/%.h $(H_FILES)
76 $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<
78 $(OBJ_DIR)/%.o: $(TEST_DIR)/%.cpp $(H_FILES)
80 $(CXX) $(CXX_FLAGS) $(INC) -c -o $@ $<
86 rm -rf ./obj/release/*
88 rm -rf ./lib/release/*
90 rm -rf ./bin/release/*
91 rm -rf ./test/tst_*.txt
98 @echo 'BUILD = '$(value BUILD)
99 @echo 'INC = '$(value INC)
100 @echo 'CPP_FILES = '$(value CPP_FILES)
101 @echo 'LIBS = '$(value LIBS)