blob: 2d36f1d6488eb20cd5968bcb535fa9d55dbcab02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# //******************************************************************
# //
# // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
# //
# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# //
# // Licensed under the Apache License, Version 2.0 (the "License");
# // you may not use this file except in compliance with the License.
# // You may obtain a copy of the License at
# //
# // http://www.apache.org/licenses/LICENSE-2.0
# //
# // Unless required by applicable law or agreed to in writing, software
# // distributed under the License is distributed on an "AS IS" BASIS,
# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# // See the License for the specific language governing permissions and
# // limitations under the License.
# //
# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# override with `make BUILD=debug`
# default to release build
BUILD := release
PLATFORM := linux
CC := g++
OUT_DIR := $(BUILD)
OBJ_DIR := $(OUT_DIR)/obj
ifeq ($(ROOT_DIR), )
ROOT_DIR = ../../../..
endif
OUT_DIR = .
OCLOGGER_DIR = $(ROOT_DIR)/logger
OC_LOG_DIR = $(ROOT_DIR)/../oc_logger
OCRANDOM_DIR = $(ROOT_DIR)/ocrandom
OCSOCKET_DIR = $(ROOT_DIR)/ocsocket
OCMALLOC_DIR = $(ROOT_DIR)/ocmalloc
OCTBSTACK_DIR = $(ROOT_DIR)/stack
EXTLIBS_DIR = $(ROOT_DIR)/../../extlibs
CJSON_DIR = $(EXTLIBS_DIR)/cjson
CONNECTIVITY_DIR= $(ROOT_DIR)/connectivity
CJSON_SRC = $(CJSON_DIR)
OCLOGGER_INC = $(OCLOGGER_DIR)/include
OC_LOG_INC = $(OC_LOG_DIR)/include
OCRANDOM_INC = $(OCRANDOM_DIR)/include
OCSOCKET_INC = $(OCSOCKET_DIR)/include
OCMALLOC_INC = $(OCMALLOC_DIR)/include
OCTBSTACK_INC = $(OCTBSTACK_DIR)/include
CJSON_INC = $(CJSON_DIR)
INC_DIRS := -I$(OCLOGGER_INC)
INC_DIRS += -I$(OC_LOG_INC)
INC_DIRS += -I$(OCRANDOM_INC)
INC_DIRS += -I$(OCSOCKET_INC)
INC_DIRS += -I$(OCMALLOC_INC)
INC_DIRS += -I$(OCTBSTACK_INC)
INC_DIRS += -I$(CJSON_INC)
# TODO-CA Remove -fstack-protector-all before merging to master
CC_FLAGS.debug := -O0 -g3 -Wall -fstack-protector-all -ffunction-sections -fdata-sections -fno-exceptions \
-std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) -L$(CONNECTIVITY_DIR)/build/out \
'-Wl,-rpath=../$(CONNECTIVITY_DIR)/build/out' -DTB_LOG
# TODO-CA Remove -fstack-protector-all before merging to master
CC_FLAGS.release := -Os -Wall -fstack-protector-all -fdata-sections -Wl,--gc-sections -Wl,-s -fno-exceptions \
-std=c++0x $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) -L$(CONNECTIVITY_DIR)/build/out \
'-Wl,-rpath=../$(CONNECTIVITY_DIR)/build/out' -DTB_LOG
LDLIBS += -loctbstack -lpthread -lconnectivity_abstraction
CPPFLAGS += $(CC_FLAGS.$(BUILD)) $(LDLIBS)
CJSON_SOURCES := $(CJSON_SRC)/cJSON.c
SOURCES := $(CJSON_SOURCES)
SOURCES += occlient.cpp ocserver.cpp occlientcoll.cpp ocservercoll.cpp common.cpp ocserverbasicops.cpp occlientbasicops.cpp ocserverslow.cpp occlientslow.cpp
OBJECTS:= $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(SOURCES))
PROGRAMS += ocserver
PROGRAMS += occlient
PROGRAMS += ocserverbasicops
PROGRAMS += ocserverslow
PROGRAMS += ocservercoll
PROGRAMS += occlientcoll
PROGRAMS += occlientbasicops
PROGRAMS += occlientslow
all: c_sdk prep_dirs $(OBJECTS) $(PROGRAMS)
prep_dirs:
-mkdir -p $(OUT_DIR)
-mkdir -p $(OBJ_DIR)
c_sdk:
cd $(ROOT_DIR) && $(MAKE) BUILD=$(BUILD) PLATFORM=$(PLATFORM)
$(OBJ_DIR)/%.o: %.cpp
$(CC) -c $(CPPFLAGS) $< -o $@
ocserver: $(OBJ_DIR)/ocserver.o $(OBJ_DIR)/common.o
$(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
ocserverslow: $(OBJ_DIR)/ocserverslow.o $(OBJ_DIR)/common.o
$(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
ocserverbasicops: $(OBJ_DIR)/ocserverbasicops.o $(OBJ_DIR)/common.o
$(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
ocservercoll: $(OBJ_DIR)/ocservercoll.o $(OBJ_DIR)/common.o
$(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
occlient: $(OBJ_DIR)/occlient.o $(OBJ_DIR)/common.o
$(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
occlientbasicops: $(OBJ_DIR)/occlientbasicops.o $(OBJ_DIR)/common.o
$(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
occlientslow: $(OBJ_DIR)/occlientslow.o $(OBJ_DIR)/common.o
$(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
occlientcoll: $(OBJ_DIR)/occlientcoll.o $(OBJ_DIR)/common.o
$(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
.PHONY: clean
clean: legacy_clean
-rm -rf release
-rm -rf debug
cd $(ROOT_DIR) && $(MAKE) clean
cd $(ROOT_DIR) && $(MAKE) deepclean
legacy_clean:
rm -f *.o $(PROGRAMS)
|