Changeset for reviewing RI-CA integration changes.
[platform/upstream/iotivity.git] / resource / unittests / makefile
1 # //******************************************************************
2 # //
3 # // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 # //
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 # //
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
10 # //
11 # //      http://www.apache.org/licenses/LICENSE-2.0
12 # //
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.
18 # //
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 #
21 # override with `make BUILD=debug`
22 # default to release build
23 BUILD    := release
24 PLATFORM := linux
25 CXX      := g++
26
27 ROOT_DIR        = ./
28
29 GTEST_DIR= ../../extlibs/gtest-1.7.0
30 MOCKS_DIR= ../../extlibs/hippomocks-master
31
32 OUT_DIR   := $(BUILD)
33
34 ifeq ($(ROOT_DIR),)
35         ROOT_DIR:=$(PWD)
36 endif
37
38 CONNECTIVITY_DIR= $(ROOT_DIR)/../csdk/connectivity
39
40 INC_DIRS  := -I../include/
41 INC_DIRS  += -I../oc_logger/include
42 INC_DIRS  += -I../csdk/stack/include
43 INC_DIRS  += -I../csdk/ocrandom/include
44 INC_DIRS  += -I../csdk/logger/include
45 INC_DIRS  += -I$(GTEST_DIR)/include
46 INC_DIRS  += -I$(MOCKS_DIR)/HippoMocks
47 INC_DIRS  += -I$(MOCKS_DIR)/HippoMocksTest
48
49 LIB_OC_LOGGER := ../oc_logger/lib/oc_logger.a
50
51 GTEST_LIBS := $(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a 
52 CXX_LIBS  := ../$(BUILD)/obj/liboc.a ../csdk/$(PLATFORM)/$(BUILD)/liboctbstack.a $(LIB_OC_LOGGER)
53 CXX_LIBS  += $(GTEST_LIBS) -L$(CONNECTIVITY_DIR)/build/out -lconnectivity_abstraction
54
55 CC_FLAGS.debug      := -g -O0 -g3 -Wall -ffunction-sections -fdata-sections \
56                         -std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/$(BUILD) -DTB_LOG 
57 CC_FLAGS.release    := -Os -Wall -fdata-sections -Wl,--gc-sections -Wl,-s \
58                         -std=c++0x $(INC_DIRS) -L$(ROOT_DIR)/$(BUILD) 
59
60 CPPFLAGS        += $(CC_FLAGS.$(BUILD)) $(CXX_LIBS) -lpthread
61
62
63
64 all: prep_dirs $(MOCKS_DIR) unittests 
65
66 prep_dirs:
67         -mkdir -p $(OUT_DIR)
68
69 unittests: OCPlatformTest.cpp OCResourceTest.cpp ConstructResourceTest.cpp OCRepresentationTest.cpp $(GTEST_LIBS)
70         $(CXX) $^ $(CPPFLAGS) -o $(OUT_DIR)/$@
71         
72 $(GTEST_DIR):           
73         cd ../../extlibs && \
74         wget -q https://googletest.googlecode.com/files/gtest-1.7.0.zip && \
75         unzip gtest-1.7.0.zip
76         
77 $(GTEST_LIBS): $(GTEST_DIR)             
78         cd $(GTEST_DIR) && ./configure && make          
79
80 $(MOCKS_DIR):
81         cd ../../extlibs && \
82         wget -q https://github.com/dascandy/hippomocks/archive/master.zip && \
83         unzip master.zip        
84
85 .PHONY: clean
86
87 clean:
88         -rm -rf release
89         -rm -rf debug
90