1 # //******************************************************************
3 # // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # // Licensed under the Apache License, Version 2.0 (the "License");
8 # // you may not use this file except in compliance with the License.
9 # // You may obtain a copy of the License at
11 # // http://www.apache.org/licenses/LICENSE-2.0
13 # // Unless required by applicable law or agreed to in writing, software
14 # // distributed under the License is distributed on an "AS IS" BASIS,
15 # // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # // See the License for the specific language governing permissions and
17 # // limitations under the License.
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 # override with `make BUILD=release`
22 # default to release build
25 # You must create the file "local.properties" on your local machine which contains any local paths, etc
26 # local_settings.mk should NOT be committed to repo
27 include ./local.properties
28 # GTEST_DIR contains the path to Google Test libs and must be defined in local.properties
30 # GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
32 # NOTE: to run app, make sure that LD_LIBRARY_PATH env variable
33 # contains $(GTEST_DIR)/lib/.libs
44 #STACK_DIR := ../stack
46 CC_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -std=c99 -fpic -DTB_LOG
47 CC_FLAGS.release := -Os -Wall -c -fmessage-length=0 -std=c99 -fpic
48 CC_FLAGS := $(CC_FLAGS.$(BUILD))
50 CXX_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -std=c++0x -fpic -DTB_LOG
51 CXX_FLAGS.release := -Os -Wall -c -fmessage-length=0 -std=c++0x -fpic
52 CXX_FLAGS := $(CXX_FLAGS.$(BUILD))
57 #INC += -I$(LOG_DIR)/include
58 #INC += -I$(STACK_DIR)/include
59 INC += -I$(GTEST_DIR)/include
62 # using make's computed variables to select object and bin folders
63 # depending on the build type
64 OBJ_DIR.debug := ./obj/debug
65 OBJ_DIR.release := ./obj/release
66 OBJ_DIR := $(OBJ_DIR.$(BUILD))
68 BIN_DIR.debug := ./bin/debug
69 BIN_DIR.release := ./bin/release
70 BIN_DIR := $(BIN_DIR.$(BUILD))
72 #C_FILES := $(wildcard $(LOG_DIR)/src/*.c)
73 #C_FILES += $(wildcard $(SRC_DIR)/*.c)
74 #CPP_FILES := $(wildcard $(SRC_DIR)/*.cpp)
75 CPP_FILES := $(wildcard $(TEST_DIR)/*.cpp)
76 #CPP_FILES += $(wildcard $(LOG_DIR)/src/*.c)
77 OBJ_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o) $(C_FILES:.c=.o)))
78 H_FILES := $(wildcard $(TEST_DIR)/*.h)
79 #H_FILES += $(wildcard $(INC_DIR)/*.h)
80 #H_FILES += $(wildcard $(LOG_DIR)/include/*.h)
81 LD_FLAGS := -L/usr/lib
82 LD_FLAGS += -L$(GTEST_DIR)/lib/.libs
95 $(CXX) -o $@ $^ $(LD_FLAGS) $(LIBS)
97 mv ./$(PROG) ./$(BIN_DIR)
99 #$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h $(H_FILES)
100 # $(CXX) $(CXX_FLAGS) $(INC) -c -o $@ $<
102 #$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(INC_DIR)/%.h $(H_FILES)
103 # $(CXX) $(CXX_FLAGS) $(INC) -c -o $@ $<
105 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/%.h $(H_FILES)
106 mkdir -p ./$(OBJ_DIR)
107 $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<
109 $(OBJ_DIR)/%.o: $(LOG_DIR)/src/%.c $(LOG_DIR)/include/%.h $(H_FILES)
110 mkdir -p ./$(OBJ_DIR)
111 $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<
113 $(OBJ_DIR)/%.o: $(TEST_DIR)/%.cpp $(H_FILES)
114 mkdir -p ./$(OBJ_DIR)
115 $(CXX) $(CXX_FLAGS) $(INC) -c -o $@ $<
120 rm -rf ./obj/release/*
123 rm -rf ./bin/release/*
130 @echo 'BUILD = '$(value BUILD)
131 @echo 'INC = '$(value INC)
132 @echo 'CPP_FILES = '$(value CPP_FILES)
133 @echo 'C_FILES = '$(value C_FILES)
134 @echo 'LIBS = '$(value LIBS)
135 @echo 'OBJ_FILES = '$(value OBJ_FILES)
136 @echo 'SRC_DIR = '$(value SRC_DIR)