Implemented libcoap's tinyDTLS interface
[contrib/iotivity.git] / resource / csdk / stack / samples / linux / secure / 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 CC       := g++
26 OUT_DIR   := $(BUILD)
27 OBJ_DIR   := $(OUT_DIR)/obj
28
29 ifeq ($(ROOT_DIR), )
30 ROOT_DIR        = ../../../..
31 endif
32
33 OUT_DIR = .
34
35 OCLOGGER_DIR    = $(ROOT_DIR)/logger
36 OC_LOG_DIR = $(ROOT_DIR)/../oc_logger
37 OCRANDOM_DIR    = $(ROOT_DIR)/ocrandom
38 OCSOCKET_DIR    = $(ROOT_DIR)/ocsocket
39 LCOAP_DIR       = $(ROOT_DIR)/libcoap-4.1.1
40 OCCOAP_DIR      = $(ROOT_DIR)/occoap
41 OCTBSTACK_DIR   = $(ROOT_DIR)/stack
42 EXTLIBS_DIR     = $(ROOT_DIR)/../../extlibs
43 CJSON_DIR       = $(EXTLIBS_DIR)/cjson
44
45 CJSON_SRC       = $(CJSON_DIR)
46
47 OCLOGGER_INC    = $(OCLOGGER_DIR)/include
48 OC_LOG_INC      = $(OC_LOG_DIR)/include
49 OCRANDOM_INC    = $(OCRANDOM_DIR)/include
50 OCSOCKET_INC    = $(OCSOCKET_DIR)/include
51 LCOAP_INC       = $(LCOAP_DIR)
52 OCCOAP_INC      = $(OCCOAP_DIR)/include
53 OCTBSTACK_INC   = $(OCTBSTACK_DIR)/include
54 CJSON_INC       = $(CJSON_DIR)
55
56 INC_DIRS        := -I$(OCLOGGER_INC)
57 INC_DIRS        += -I$(OC_LOG_INC)
58 INC_DIRS        += -I$(OCRANDOM_INC)
59 INC_DIRS        += -I$(OCSOCKET_INC)
60 INC_DIRS        += -I$(LCOAP_INC)
61 INC_DIRS        += -I$(OCCOAP_INC)
62 INC_DIRS        += -I$(OCTBSTACK_INC)
63 INC_DIRS        += -I$(CJSON_INC)
64
65 CC_FLAGS.debug   := -O0 -g3 -Wall -ffunction-sections -fdata-sections -fno-exceptions \
66                         -std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) -DTB_LOG
67 CC_FLAGS.release := -Os -Wall -fdata-sections -Wl,--gc-sections -Wl,-s -fno-exceptions \
68                         -std=c++0x $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) -DTB_LOG
69
70 LDLIBS          += -loctbstack -lpthread
71 CPPFLAGS        += $(CC_FLAGS.$(BUILD)) $(LDLIBS)
72
73 CJSON_SOURCES           := $(CJSON_SRC)/cJSON.c
74
75 SOURCES         := $(CJSON_SOURCES)
76 SOURCES     += common.cpp ocserverbasicops.cpp occlientbasicops.cpp
77
78 OBJECTS:= $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(SOURCES))
79
80 PROGRAMS        += ocserverbasicops
81 PROGRAMS        += occlientbasicops
82
83 all:    c_sdk prep_dirs $(OBJECTS) $(PROGRAMS)
84
85 prep_dirs:
86         -mkdir -p $(OUT_DIR)
87         -mkdir -p $(OBJ_DIR)
88
89 c_sdk:
90         cd $(ROOT_DIR) && $(MAKE) BUILD=$(BUILD) PLATFORM=$(PLATFORM)
91
92 $(OBJ_DIR)/%.o: %.cpp
93         $(CC) -c $(CPPFLAGS) $< -o $@
94
95 ocserverbasicops: $(OBJ_DIR)/ocserverbasicops.o $(OBJ_DIR)/common.o
96         $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
97
98 occlientbasicops: $(OBJ_DIR)/occlientbasicops.o $(OBJ_DIR)/common.o
99         $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
100
101 .PHONY: clean
102
103 clean: legacy_clean
104         -rm -rf release
105         -rm -rf debug
106         cd $(ROOT_DIR) && $(MAKE) clean
107         cd $(ROOT_DIR) && $(MAKE) deepclean
108
109 legacy_clean:
110         rm -f *.o $(PROGRAMS)