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