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