blob: 5be263d51ed625d5eaf44cf3b09d468afeaf47bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# //******************************************************************
# //
# // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
# //
# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# //
# // Licensed under the Apache License, Version 2.0 (the "License");
# // you may not use this file except in compliance with the License.
# // You may obtain a copy of the License at
# //
# // http://www.apache.org/licenses/LICENSE-2.0
# //
# // Unless required by applicable law or agreed to in writing, software
# // distributed under the License is distributed on an "AS IS" BASIS,
# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# // See the License for the specific language governing permissions and
# // limitations under the License.
# //
# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# override with `make BUILD=debug`
# default to release build
BUILD := release
PLATFORM := linux
CXX := g++
ROOT_DIR = ./
GTEST_DIR= ../../extlibs/gtest-1.7.0
MOCKS_DIR= ../../extlibs/hippomocks-master
OUT_DIR := $(BUILD)
ifeq ($(ROOT_DIR),)
ROOT_DIR:=$(PWD)
endif
CONNECTIVITY_DIR= $(ROOT_DIR)/../csdk/connectivity
INC_DIRS := -I../include/
INC_DIRS += -I../oc_logger/include
INC_DIRS += -I../csdk/stack/include
INC_DIRS += -I../csdk/ocrandom/include
INC_DIRS += -I../csdk/logger/include
INC_DIRS += -I$(GTEST_DIR)/include
INC_DIRS += -I$(MOCKS_DIR)/HippoMocks
INC_DIRS += -I$(MOCKS_DIR)/HippoMocksTest
LIB_OC_LOGGER := ../oc_logger/lib/oc_logger.a
GTEST_LIBS := $(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a
CXX_LIBS := ../$(BUILD)/obj/liboc.a ../csdk/$(PLATFORM)/$(BUILD)/liboctbstack.a $(LIB_OC_LOGGER)
CXX_LIBS += $(GTEST_LIBS) -L$(CONNECTIVITY_DIR)/build/out -lconnectivity_abstraction
CC_FLAGS.debug := -g -O0 -g3 -Wall -ffunction-sections -fdata-sections \
-std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/$(BUILD) -DTB_LOG
CC_FLAGS.release := -Os -Wall -fdata-sections -Wl,--gc-sections -Wl,-s \
-std=c++0x $(INC_DIRS) -L$(ROOT_DIR)/$(BUILD)
CPPFLAGS += $(CC_FLAGS.$(BUILD)) $(CXX_LIBS) -lpthread
all: prep_dirs $(MOCKS_DIR) unittests
prep_dirs:
-mkdir -p $(OUT_DIR)
unittests: OCPlatformTest.cpp OCResourceTest.cpp ConstructResourceTest.cpp OCRepresentationTest.cpp $(GTEST_LIBS)
$(CXX) $^ $(CPPFLAGS) -o $(OUT_DIR)/$@
$(GTEST_DIR):
cd ../../extlibs && \
wget -q https://googletest.googlecode.com/files/gtest-1.7.0.zip && \
unzip gtest-1.7.0.zip
$(GTEST_LIBS): $(GTEST_DIR)
cd $(GTEST_DIR) && ./configure && make
$(MOCKS_DIR):
cd ../../extlibs && \
wget -q https://github.com/dascandy/hippomocks/archive/master.zip && \
unzip master.zip
.PHONY: clean
clean:
-rm -rf release
-rm -rf debug
|