Merge "Modified makefiles so that each makefile could build its own dependencies...
[platform/upstream/iotivity.git] / examples / 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=release`
22 # default to release build
23 BUILD     := release
24 CXX           := g++
25 #CXX      := clang
26 OUT_DIR   := $(PWD)/$(BUILD)
27
28 CXX_FLAGS.debug     := -O0 -g3 -std=c++0x -Wall -pthread
29
30 CXX_FLAGS.release   := -O3 -std=c++0x -Wall -pthread
31
32 CXX_INC   := -I../include/
33 CXX_INC   += -I../oc_logger/include
34
35 CXX_INC   += -I../csdk/stack/include
36 CXX_INC   += -I../csdk/ocsocket/include
37 CXX_INC   += -I../csdk/ocrandom/include
38 CXX_INC   += -I../csdk/logger/include
39 CXX_INC   += -I../csdk/libcoap
40
41 LIB_OC_LOGGER := ../oc_logger/lib/oc_logger.a
42
43 CXX_LIBS  := ../$(BUILD)/obj/liboc.a ../csdk/$(BUILD)/liboctbstack.a $(LIB_OC_LOGGER)
44
45 APPS  += simpleserver
46 APPS  += simpleclient
47 APPS  += simpleclientserver
48 APPS  += roomserver
49 APPS  += roomclient
50 APPS  += presenceserver
51 APPS  += presenceclient
52 APPS  += garageserver
53 APPS  += garageclient
54 APPS  += ocicuc
55
56 # Force metatargets to build:
57 .PHONY: prep_dirs oc_cpp_sdk $(APPS)
58
59 all: .PHONY
60
61 apps: prep_dirs $(APPS)
62
63 prep_dirs:
64         -mkdir -p $(OUT_DIR)
65         
66 oc_cpp_sdk:
67         cd ../ && $(MAKE) cpp_sdk "BUILD=$(BUILD)"
68
69 simpleserver: simpleserver.cpp
70         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ simpleserver.cpp $(CXX_INC) $(CXX_LIBS)
71
72 simpleclient: simpleclient.cpp
73         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ simpleclient.cpp $(CXX_INC) $(CXX_LIBS)
74
75 fridgeserver: fridgeserver.cpp
76         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ fridgeserver.cpp $(CXX_INC) $(CXX_LIBS)
77
78 fridgeclient: fridgeclient.cpp
79         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ fridgeclient.cpp $(CXX_INC) $(CXX_LIBS)
80
81 presenceserver: presenceserver.cpp
82         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ presenceserver.cpp $(CXX_INC) $(CXX_LIBS)
83
84 presenceclient: presenceclient.cpp
85         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ presenceclient.cpp $(CXX_INC) $(CXX_LIBS)
86
87 simpleclientserver: simpleclientserver.cpp
88         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ simpleclientserver.cpp $(CXX_INC) $(CXX_LIBS)
89
90 roomserver: roomserver.cpp
91         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ roomserver.cpp $(CXX_INC) $(CXX_LIBS)
92
93 roomclient: roomclient.cpp
94         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ roomclient.cpp $(CXX_INC) $(CXX_LIBS)
95
96 garageserver: garageserver.cpp
97         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ garageserver.cpp $(CXX_INC) $(CXX_LIBS)
98
99 garageclient: garageclient.cpp
100         $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ garageclient.cpp $(CXX_INC) $(CXX_LIBS)
101
102 ocicuc:
103         cd ocicuc && $(MAKE) apps
104         
105 clean: 
106         rm -rf $(OUT_DIR)
107         cd ../ && $(MAKE) clean_cpp_sdk
108         cd ocicuc && $(MAKE) clean_apps
109
110 clean_apps:
111         rm -rf $(OUT_DIR)
112         cd ocicuc && $(MAKE) clean_apps