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=debug`
22 # default to release build
28 ROOT_DIR = $(PWD)/../../..
31 # You must create the file "local.properties" on your local machine which contains any local paths, etc
32 # local.properties should NOT be committed to repo
33 include $(ROOT_DIR)/local.properties
34 # GTEST_DIR contains the path to Google Test libs and must be defined in local.properties
36 # GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
38 # NOTE: to run app, make sure that LD_LIBRARY_PATH env variable
39 # contains $(GTEST_DIR)/lib/.libs
41 OUT_DIR := $(PWD)/$(BUILD)
42 OBJ_DIR := $(OUT_DIR)/obj
47 OCLOGGER_DIR = $(ROOT_DIR)/logger
48 OCMALLOC_DIR = $(ROOT_DIR)/ocmalloc
49 OCRANDOM_DIR = $(ROOT_DIR)/ocrandom
50 OCSOCKET_DIR = $(ROOT_DIR)/ocsocket
51 OCTBSTACK_DIR = $(ROOT_DIR)/stack
53 OCLOGGER_INC = $(OCLOGGER_DIR)/include
54 OCMALLOC_INC = $(OCMALLOC_DIR)/include
55 OCRANDOM_INC = $(OCRANDOM_DIR)/include
56 OCSOCKET_INC = $(OCSOCKET_DIR)/include
57 OCTBSTACK_INC = $(OCTBSTACK_DIR)/include
59 INC_DIRS := -I$(OCLOGGER_INC)
60 INC_DIRS += -I$(OCMALLOC_INC)
61 INC_DIRS += -I$(OCRANDOM_INC)
62 INC_DIRS += -I$(OCSOCKET_INC)
63 INC_DIRS += -I$(OCTBSTACK_INC)
64 INC_DIRS += -I$(OCTBSTACK_INC)/internal
65 INC_DIRS += -I$(GTEST_DIR)/include
67 CC_FLAGS.debug := -g -O0 -g3 -Wall -ffunction-sections -fdata-sections -fno-exceptions \
68 -std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) -DTB_LOG
69 CC_FLAGS.release := -Os -Wall -fdata-sections -Wl,--gc-sections -Wl,-s -fno-exceptions \
70 -std=c++0x $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD)
72 LDLIBS += -loctbstack -lpthread
73 CPPFLAGS += $(CC_FLAGS.$(BUILD)) $(LDLIBS) $(GTEST_DIR)/lib/.libs/libgtest.a \
74 $(GTEST_DIR)/lib/.libs/libgtest_main.a
76 SOURCES := unittest.cpp
78 OBJECTS:= $(patsubst %.c, $(OBJ_DIR)/%.o, $(SOURCES))
82 all: prep_dirs $(OBJECTS) $(PROGRAMS)
89 $(CC) -c $(CPPFLAGS) $< -o $@
91 unittest: $(OBJ_DIR)/unittest.o
92 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
101 rm -f *.o $(PROGRAMS)