Fix failed unit tests for CSDK stack.
[platform/upstream/iotivity.git] / resource / 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 CXX       := g++
25 #CXX      := clang
26
27 ifeq ($(ROOT_DIR), )
28         ROOT_DIR := $(PWD)
29 endif
30 ifeq ($(PLATFORM), )
31         PLATFORM := "linux"
32 endif
33
34 DEPEND_DIR:= $(ROOT_DIR)/dependencies
35 CEREAL_DIR:= $(DEPEND_DIR)/cereal
36
37 OUT_DIR   := $(ROOT_DIR)/$(BUILD)
38 OBJ_DIR   := $(OUT_DIR)/obj
39
40 #TODO-CA Need to remove flag later
41 CXX_FLAGS.debug     := -g3 -std=c++0x -Wall -pthread -O0 -DCA_INT
42 CXX_FLAGS.release   := -std=c++0x -Wall -pthread -O3 -DCA_INT
43
44 CXX_INC   := -I./include/
45 CXX_INC   += -I./oc_logger/include
46
47 CXX_INC   += -I./csdk/stack/include
48 CXX_INC   += -I./csdk/ocsocket/include
49 CXX_INC   += -I./csdk/ocrandom/include
50 CXX_INC   += -I./csdk/logger/include
51 CXX_INC   += -I./csdk/libcoap
52 CXX_INC   += -I$(CEREAL_DIR)/include
53 # Force metatargets to build:
54 all.PHONY: applyDepPatches prep_dirs c_sdk oc_logger_target liboc.a examples
55
56 buildScript_all.PHONY: applyDepPatches prep_dirs oc_logger_target liboc.a
57
58 all:    all.PHONY
59
60 buildScript_all:  buildScript_all.PHONY
61
62 prep_dirs: deps
63         -mkdir -p $(OUT_DIR)
64         -mkdir -p $(OBJ_DIR)
65
66 # used to fetch all dependencies
67 deps:
68         -mkdir -p $(DEPEND_DIR)
69 #cereal fetch
70         if [ ! -d "$(CEREAL_DIR)" ]; then\
71                 cd $(DEPEND_DIR) && git clone https://github.com/USCiLab/cereal.git;\
72                 cd $(CEREAL_DIR) && git checkout 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245;\
73         fi
74
75 applyDepPatches: deps
76 #reset git to the 'base version', so we can apply our patch without issues
77         cd $(CEREAL_DIR) && git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245;
78         cd $(CEREAL_DIR) && git apply $(ROOT_DIR)/patches/cereal_gcc46.patch
79
80 c_sdk:
81         cd csdk && $(MAKE) "BUILD=$(BUILD)" "PLATFORM=$(PLATFORM)"
82
83 oc_logger_target:
84         cd oc_logger && $(MAKE) "BUILD=$(BUILD)"
85
86 cpp_sdk: prep_dirs c_sdk liboc.a
87
88 examples: liboc.a
89         cd examples && $(MAKE) apps "BUILD=$(BUILD)"
90
91 liboc.a: OCPlatform_impl.o OCPlatform.o OCResource.o OCException.o OCUtilities.o InProcServerWrapper.o InProcClientWrapper.o OCRepresentation.o
92         ar -cvq $(OBJ_DIR)/liboc.a $(OBJ_DIR)/OCPlatform_impl.o $(OBJ_DIR)/OCPlatform.o $(OBJ_DIR)/OCResource.o $(OBJ_DIR)/OCException.o $(OBJ_DIR)/OCUtilities.o $(OBJ_DIR)/InProcServerWrapper.o $(OBJ_DIR)/InProcClientWrapper.o $(OBJ_DIR)/OCRepresentation.o
93
94 OCPlatform_impl.o: src/OCPlatform_impl.cpp
95         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OBJ_DIR)/$@ -c src/OCPlatform_impl.cpp $(CXX_INC)
96
97 OCPlatform.o: src/OCPlatform.cpp
98         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OBJ_DIR)/$@ -c src/OCPlatform.cpp $(CXX_INC)
99
100 OCRepresentation.o: src/OCRepresentation.cpp
101         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OBJ_DIR)/$@ -c src/OCRepresentation.cpp $(CXX_INC)
102
103 OCResource.o: src/OCResource.cpp
104         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OBJ_DIR)/$@ -c src/OCResource.cpp $(CXX_INC)
105
106 OCException.o: src/OCException.cpp
107         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OBJ_DIR)/$@ -c src/OCException.cpp $(CXX_INC)
108
109 OCUtilities.o: src/OCUtilities.cpp
110         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OBJ_DIR)/$@ -c src/OCUtilities.cpp $(CXX_INC)
111
112 InProcServerWrapper.o: src/InProcServerWrapper.cpp
113         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OBJ_DIR)/$@ -c src/InProcServerWrapper.cpp $(CXX_INC)
114
115 InProcClientWrapper.o: src/InProcClientWrapper.cpp
116         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OBJ_DIR)/$@ -c src/InProcClientWrapper.cpp $(CXX_INC)
117
118 clean: clean_legacy
119         -rm -rf release
120         -rm -rf debug
121         cd oc_logger && $(MAKE) clean
122
123 clean_cpp_sdk: clean_legacy
124         -rm -rf release
125         -rm -rf debug
126
127 clean_legacy:
128         -rm -f -v $(OBJ_DIR)/liboc.a $(OBJ_DIR)/*.o
129         cd csdk && $(MAKE) clean
130         cd csdk && $(MAKE) deepclean