1 # //******************************************************************
3 # // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 # // http://www.apache.org/licenses/LICENSE-2.0
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.
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 # override with `make BUILD=debug`
22 # default to release build
27 OBJ_DIR := $(OUT_DIR)/obj
30 ROOT_DIR = ../../../..
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 OCMALLOC_DIR = $(ROOT_DIR)/ocmalloc
42 OCTBSTACK_DIR = $(ROOT_DIR)/stack
43 EXTLIBS_DIR = $(ROOT_DIR)/../../extlibs
44 CJSON_DIR = $(EXTLIBS_DIR)/cjson
45 CONNECTIVITY_DIR= $(ROOT_DIR)/connectivity
46 CJSON_SRC = $(CJSON_DIR)
48 OCLOGGER_INC = $(OCLOGGER_DIR)/include
49 OC_LOG_INC = $(OC_LOG_DIR)/include
50 OCRANDOM_INC = $(OCRANDOM_DIR)/include
51 OCSOCKET_INC = $(OCSOCKET_DIR)/include
52 LCOAP_INC = $(LCOAP_DIR)
53 OCCOAP_INC = $(OCCOAP_DIR)/include
54 OCMALLOC_INC = $(OCMALLOC_DIR)/include
55 OCTBSTACK_INC = $(OCTBSTACK_DIR)/include
56 CJSON_INC = $(CJSON_DIR)
58 INC_DIRS := -I$(OCLOGGER_INC)
59 INC_DIRS += -I$(OC_LOG_INC)
60 INC_DIRS += -I$(OCRANDOM_INC)
61 INC_DIRS += -I$(OCSOCKET_INC)
62 INC_DIRS += -I$(LCOAP_INC)
63 INC_DIRS += -I$(OCCOAP_INC)
64 INC_DIRS += -I$(OCMALLOC_INC)
65 INC_DIRS += -I$(OCTBSTACK_INC)
66 INC_DIRS += -I$(CJSON_INC)
68 # TODO-CA Remove -fstack-protector-all before merging to master
69 CC_FLAGS.debug := -O0 -g3 -Wall -fstack-protector-all -ffunction-sections -fdata-sections -fno-exceptions \
70 -std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) -DTB_LOG
71 # TODO-CA Remove -fstack-protector-all before merging to master
72 CC_FLAGS.release := -Os -Wall -fstack-protector-all -fdata-sections -Wl,--gc-sections -Wl,-s -fno-exceptions \
73 -std=c++0x $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) -DTB_LOG
75 LDLIBS += -loctbstack -lpthread -L$(CONNECTIVITY_DIR)/build/out -lconnectivity_abstraction
76 CPPFLAGS += $(CC_FLAGS.$(BUILD)) $(LDLIBS)
78 CJSON_SOURCES := $(CJSON_SRC)/cJSON.c
80 SOURCES := $(CJSON_SOURCES)
81 SOURCES += occlient.cpp ocserver.cpp occlientcoll.cpp ocservercoll.cpp common.cpp ocserverbasicops.cpp occlientbasicops.cpp ocserverslow.cpp occlientslow.cpp
83 OBJECTS:= $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(SOURCES))
87 PROGRAMS += ocserverbasicops
88 PROGRAMS += ocserverslow
89 PROGRAMS += ocservercoll
90 PROGRAMS += occlientcoll
91 PROGRAMS += occlientbasicops
92 PROGRAMS += occlientslow
94 all: c_sdk prep_dirs $(OBJECTS) $(PROGRAMS)
101 cd $(ROOT_DIR) && $(MAKE) BUILD=$(BUILD) PLATFORM=$(PLATFORM)
103 $(OBJ_DIR)/%.o: %.cpp
104 $(CC) -c $(CPPFLAGS) $< -o $@
106 ocserver: $(OBJ_DIR)/ocserver.o $(OBJ_DIR)/common.o
107 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
109 ocserverslow: $(OBJ_DIR)/ocserverslow.o $(OBJ_DIR)/common.o
110 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
112 ocserverbasicops: $(OBJ_DIR)/ocserverbasicops.o $(OBJ_DIR)/common.o
113 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
115 ocservercoll: $(OBJ_DIR)/ocservercoll.o $(OBJ_DIR)/common.o
116 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
118 occlient: $(OBJ_DIR)/occlient.o $(OBJ_DIR)/common.o
119 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
121 occlientbasicops: $(OBJ_DIR)/occlientbasicops.o $(OBJ_DIR)/common.o
122 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
124 occlientslow: $(OBJ_DIR)/occlientslow.o $(OBJ_DIR)/common.o
125 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
127 occlientcoll: $(OBJ_DIR)/occlientcoll.o $(OBJ_DIR)/common.o
128 $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
135 cd $(ROOT_DIR) && $(MAKE) clean
136 cd $(ROOT_DIR) && $(MAKE) deepclean
139 rm -f *.o $(PROGRAMS)