-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathMakefile
344 lines (281 loc) · 11.7 KB
/
Makefile
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# Directories
BOAT_BASE_DIR := $(CURDIR)
BOAT_SDK_DIR := $(BOAT_BASE_DIR)/sdk
BOAT_LIB_DIR := $(BOAT_BASE_DIR)/lib
BOAT_BUILD_DIR := $(BOAT_BASE_DIR)/build
# Set chain support
# Set to 1 to enable releated chain, to 0 to disable
BOAT_PROTOCOL_USE_ETHEREUM ?= 1
BOAT_PROTOCOL_USE_PLATON ?= 1
BOAT_PROTOCOL_USE_PLATONE ?= 1
BOAT_PROTOCOL_USE_FISCOBCOS ?= 1
BOAT_PROTOCOL_USE_HLFABRIC ?= 1
BOAT_PROTOCOL_USE_HWBCS ?= 1
BOAT_PROTOCOL_USE_CHAINMAKER_V1 ?= 0
BOAT_PROTOCOL_USE_CHAINMAKER_V2 ?= 1
BOAT_DISCOVERY_PEER_QUERY ?= 0
BOAT_PROTOCOL_USE_VENACHAIN ?= 1
BOAT_PROTOCOL_USE_QUORUM ?= 1
BOAT_PROTOCOL_USE_CITA ?= 1
# Chain config check
ifeq ($(BOAT_PROTOCOL_USE_ETHEREUM)_$(BOAT_PROTOCOL_USE_PLATON)_$(BOAT_PROTOCOL_USE_PLATONE)_$(BOAT_PROTOCOL_USE_FISCOBCOS)_$(BOAT_PROTOCOL_USE_HLFABRIC)_$(BOAT_PROTOCOL_USE_HWBCS)_$(BOAT_PROTOCOL_USE_CHAINMAKER_V1)_$(BOAT_PROTOCOL_USE_CHAINMAKER_V2)_$(BOAT_PROTOCOL_USE_VENACHAIN)_$(BOAT_PROTOCOL_USE_QUORUM)_$(BOAT_PROTOCOL_USE_CITA), 0_0_0_0_0_0_0_0_0_0)
$(error Select at least one chain)
endif
ifeq ($(BOAT_PROTOCOL_USE_CHAINMAKER_V1)_$(BOAT_PROTOCOL_USE_CHAINMAKER_V2), 1_1)
$(error Select only one chainmaker version)
endif
# Set parameter to scripts
SCRIPTS_PARAM += "BOAT_PROTOCOL_USE_ETHEREUM=$(BOAT_PROTOCOL_USE_ETHEREUM)" \
"BOAT_PROTOCOL_USE_PLATON=$(BOAT_PROTOCOL_USE_PLATON)" \
"BOAT_PROTOCOL_USE_PLATONE=$(BOAT_PROTOCOL_USE_PLATONE)" \
"BOAT_PROTOCOL_USE_FISCOBCOS=$(BOAT_PROTOCOL_USE_FISCOBCOS)" \
"BOAT_PROTOCOL_USE_HLFABRIC=$(BOAT_PROTOCOL_USE_HLFABRIC)" \
"BOAT_PROTOCOL_USE_HWBCS=$(BOAT_PROTOCOL_USE_HWBCS)" \
"BOAT_PROTOCOL_USE_CHAINMAKER_V1=$(BOAT_PROTOCOL_USE_CHAINMAKER_V1)" \
"BOAT_PROTOCOL_USE_CHAINMAKER_V2=$(BOAT_PROTOCOL_USE_CHAINMAKER_V2)" \
"BOAT_DISCOVERY_PEER_QUERY=$(BOAT_DISCOVERY_PEER_QUERY)" \
"BOAT_PROTOCOL_USE_VENACHAIN=$(BOAT_PROTOCOL_USE_VENACHAIN)" \
"BOAT_PROTOCOL_USE_QUORUM=$(BOAT_PROTOCOL_USE_QUORUM)" \
"BOAT_PROTOCOL_USE_CITA=$(BOAT_PROTOCOL_USE_CITA)"
# Platform target
# The valid option value of PLATFORM_TARGET list as below:
# - linux-default : Default linux platform
# - Fibocom-L610 : Fibocom's LTE Cat.1 module
# - Quectel-BG95 : Quectel's NB-IoT/GSM module
# - Neoway-N58 : Neoway's LTE Cat.1 module
# - YanFei-CUIot-MZ-6 : China Unicom's LTE Cat.1 module
# - ChinaMobile-ML302 : China Mobile's LTE Cat.1 module
# - ChinaMobile-ML302v2 : China Mobile's LTE Cat.1 module API version 2
# - MTK-MT3620 : MTK MT3620
# - XinYi-XY1100 : XY1100 R13
# - Fibocom-MA510 : MA510
# - XinYi-XY1100-R14 : XY1100 R14
# - mobiletek-L503C-6S : mobiletek-L503C-6S
# - Simcom-A7670C : Simcom-A7670C
PLATFORM_TARGET ?= linux-default
# Environment-specific Settings
include $(BOAT_BASE_DIR)/vendor/platform/$(PLATFORM_TARGET)/external.env
# Check gcc version
ifneq (,$(CC))
GCCVERSION := $(shell $(CC) -v 2>&1)
else
GCCVERSION := "NONE"
endif
ifneq (,$(findstring arm,$(GCCVERSION))) # Target: arm-oe-linux-gnueabi
COMPILER_TYPE = "ARM"
else ifneq (,$(findstring linux,$(GCCVERSION))) # Target: x86_64-redhat-linux
COMPILER_TYPE = "LINUX"
else ifneq (,$(findstring cygwin,$(GCCVERSION))) # Target: x86_64-pc-cygwin
COMPILER_TYPE = "CYGWIN"
else
COMPILER_TYPE = "NOTSUPPORT" # Not supported
endif
# Environment Language
LANG := en_US # zh_CN.UTF-8
# Compiling Flags
# Target-independent Flags
BOAT_INCLUDE := -I$(BOAT_BASE_DIR)/include \
-I$(BOAT_SDK_DIR) \
-I$(BOAT_SDK_DIR)/include \
-I$(BOAT_SDK_DIR)/platform \
-I$(BOAT_SDK_DIR)/protocol \
-I$(BOAT_SDK_DIR)/protocol/common/web3intf \
-I$(BOAT_BASE_DIR)/vendor/platform/include \
-I$(BOAT_BASE_DIR)/vendor/platform/$(PLATFORM_TARGET)/src/log \
-I$(BOAT_BASE_DIR)/vendor/platform/$(PLATFORM_TARGET)/src/inet \
-I$(BOAT_BASE_DIR)/contract/generated \
-I$(BOAT_BASE_DIR)/demo \
-I$(BOAT_BASE_DIR)/tests \
$(EXTERNAL_INC)
ifeq ($(BOAT_PROTOCOL_USE_ETHEREUM),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/ethereum \
-I$(BOAT_SDK_DIR)/protocol/boatethereum
endif
ifeq ($(BOAT_PROTOCOL_USE_HLFABRIC),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/hlfabric \
-I$(BOAT_SDK_DIR)/protocol/boathlfabric \
-I$(BOAT_SDK_DIR)/protocol/common/http2intf \
-I$(BOAT_SDK_DIR)/third-party/protos \
-I$(BOAT_SDK_DIR)/third-party/nghttp2/include \
-I$(BOAT_SDK_DIR)/third-party/protobuf-c/include
endif
ifeq ($(BOAT_PROTOCOL_USE_PLATONE),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/platone \
-I$(BOAT_SDK_DIR)/protocol/boatplatone
endif
ifeq ($(BOAT_PROTOCOL_USE_VENACHAIN),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/venachain \
-I$(BOAT_SDK_DIR)/protocol/boatvenachain
endif
ifeq ($(BOAT_PROTOCOL_USE_PLATON),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/platon \
-I$(BOAT_SDK_DIR)/protocol/boatplaton
endif
ifeq ($(BOAT_PROTOCOL_USE_FISCOBCOS),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/fiscobcos \
-I$(BOAT_SDK_DIR)/protocol/boatfiscobcos
endif
ifeq ($(BOAT_PROTOCOL_USE_QUORUM),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/quorum \
-I$(BOAT_SDK_DIR)/protocol/boatquorum
endif
ifeq ($(BOAT_PROTOCOL_USE_HWBCS),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/hwbcs \
-I$(BOAT_SDK_DIR)/protocol/boathwbcs \
-I$(BOAT_SDK_DIR)/protocol/boathwbcs/protos \
-I$(BOAT_SDK_DIR)/protocol/common/http2intf \
-I$(BOAT_SDK_DIR)/third-party/protos \
-I$(BOAT_SDK_DIR)/third-party/nghttp2/include \
-I$(BOAT_SDK_DIR)/third-party/protobuf-c/include
endif
ifeq ($(BOAT_PROTOCOL_USE_CHAINMAKER_V1),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/chainmaker \
-I$(BOAT_SDK_DIR)/protocol/boatchainmaker_v1 \
-I$(BOAT_SDK_DIR)/protocol/boatchainmaker_v1/protos \
-I$(BOAT_SDK_DIR)/protocol/common/http2intf \
-I$(BOAT_SDK_DIR)/third-party/protos \
-I$(BOAT_SDK_DIR)/third-party/nghttp2/include \
-I$(BOAT_SDK_DIR)/third-party/protobuf-c/include
BOAT_CHAINMAKER_VERSION_CFLAGS = -DCHAINMAKER_V1
endif
ifeq ($(BOAT_PROTOCOL_USE_CHAINMAKER_V2),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/chainmaker \
-I$(BOAT_SDK_DIR)/protocol/boatchainmaker_v2 \
-I$(BOAT_SDK_DIR)/protocol/boatchainmaker_v2/protos \
-I$(BOAT_SDK_DIR)/protocol/common/http2intf \
-I$(BOAT_SDK_DIR)/third-party/protos \
-I$(BOAT_SDK_DIR)/third-party/nghttp2/include \
-I$(BOAT_SDK_DIR)/third-party/protobuf-c/include
BOAT_CHAINMAKER_VERSION_CFLAGS += -DCHAINMAKER_V2
endif
ifeq ($(BOAT_PROTOCOL_USE_CITA),1)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/network/cita \
-I$(BOAT_SDK_DIR)/protocol/boatcita \
-I$(BOAT_SDK_DIR)/protocol/boatcita/protos \
-I$(BOAT_SDK_DIR)/third-party/protobuf-c/include
endif
BOAT_CSTD_FLAGS := -std=c99
#BOAT_OPTIMIZATION_FLAGS := -g #-Os
BOAT_OPTIMIZATION_FLAGS := -Os
BOAT_WARNING_FLAGS := -Wall
BOAT_DEFINED_MACROS := #-DDEBUG_LOG
# BOAT_COMMON_LINK_FLAGS := -Wl,-Map,$(BOAT_BUILD_DIR)/boat.map
# Target-specific Flags
ifeq ($(COMPILER_TYPE), "ARM")
TARGET_SPEC_CFLAGS := -mthumb -ffunction-sections -fdata-sections
TARGET_SPEC_LIBS :=
TARGET_SPEC_LINK_FLAGS :=
else ifeq ($(COMPILER_TYPE), "LINUX")
TARGET_SPEC_CFLAGS := -ffunction-sections -fdata-sections
TARGET_SPEC_LIBS :=
TARGET_SPEC_LINK_FLAGS := -Wl,-gc-sections
else ifeq ($(COMPILER_TYPE), "CYGWIN")
TARGET_SPEC_CFLAGS :=
TARGET_SPEC_LIBS :=
TARGET_SPEC_LINK_FLAGS :=
else
TARGET_SPEC_CFLAGS :=
TARGET_SPEC_LIBS :=
TARGET_SPEC_LINK_FLAGS :=
endif
# Soft-crypto Dependencies
# The valid option value of SOFT_CRYPTO list as below:
# - CRYPTO_DEFAULT : default soft crypto algorithm
# - CRYPTO_MBEDTLS : mbedtls crypto algorithm
# SOFT_CRYPTO ?= CRYPTO_MBEDTLS
SOFT_CRYPTO ?= CRYPTO_DEFAULT
# ifeq ($(PLATFORM_TARGET), linux-default)
# SOFT_CRYPTO ?= CRYPTO_DEFAULT
# else ifeq ($(PLATFORM_TARGET), mobiletek-L503C-6S)
# SOFT_CRYPTO ?= CRYPTO_DEFAULT
# else
# $(error not support this platform : $(PLATFORM_TARGET))
# endif
ifeq ($(SOFT_CRYPTO), CRYPTO_DEFAULT)
BOAT_INCLUDE += -I$(BOAT_BASE_DIR)/vendor/common/crypto/crypto_default \
-I$(BOAT_BASE_DIR)/vendor/common/crypto/crypto_default/aes \
-I$(BOAT_BASE_DIR)/vendor/common/storage
else
BOAT_INCLUDE +=
endif
# cJSON Dependencies
#
# - CJSON_DEFAULT : default cJSON library
# - CJSON_OUTTER : externally provided by users
CJSON_LIBRARY ?= CJSON_DEFAULT
ifeq ($(CJSON_LIBRARY), CJSON_DEFAULT)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/third-party/cJSON
endif
ifeq ($(BOAT_TEST), TEST_MODE)
BOAT_TEST_FLAG = -fprofile-arcs\
-ftest-coverage
ifeq ($(BOAT_NODES_DISCOVER), OPEN)
BOAT_DISCOVERY_PEER_QUERY = 1
else
BOAT_DISCOVERY_PEER_QUERY = 0
endif
endif
# Combine FLAGS
BOAT_CFLAGS := $(TARGET_SPEC_CFLAGS) \
$(BOAT_INCLUDE) \
$(BOAT_CSTD_FLAGS) \
$(BOAT_OPTIMIZATION_FLAGS) \
$(BOAT_WARNING_FLAGS) \
$(BOAT_DEFINED_MACROS) \
$(EXTERNAL_CFLAGS) \
$(BOAT_TEST_FLAG) \
$(BOAT_CHAINMAKER_VERSION_CFLAGS)
BOAT_LFLAGS := $(BOAT_COMMON_LINK_FLAGS) $(TARGET_SPEC_LINK_FLAGS) $(EXTERNAL_LFLAGS)
LINK_LIBS := $(EXTERNAL_LIBS) $(TARGET_SPEC_LIBS)
export BOAT_PROTOCOL_USE_ETHEREUM
export BOAT_PROTOCOL_USE_PLATON
export BOAT_PROTOCOL_USE_PLATONE
export BOAT_PROTOCOL_USE_FISCOBCOS
export BOAT_PROTOCOL_USE_HLFABRIC
export BOAT_PROTOCOL_USE_HWBCS
export BOAT_PROTOCOL_USE_CHAINMAKER_V1
export BOAT_PROTOCOL_USE_CHAINMAKER_V2
export BOAT_PROTOCOL_USE_VENACHAIN
export BOAT_PROTOCOL_USE_QUORUM
export BOAT_PROTOCOL_USE_CITA
export BOAT_DISCOVERY_PEER_QUERY
export BOAT_USE_DEFAULT_CJSON
export SOFT_CRYPTO
export CJSON_LIBRARY
export PLATFORM_TARGET
export BOAT_BASE_DIR
export BOAT_LIB_DIR
export BOAT_BUILD_DIR
export BOAT_CFLAGS
export BOAT_LFLAGS
export LINK_LIBS
.PHONY: all boatlibs createdir boatwalletlib vendorlib demo tests clean cleanboatwallet cleanvendor cleantests
#all: boatlibs demo tests
all: boatlibs
boatlibs: createdir boatwalletlib vendorlib
createdir:
@echo generate header file boatconfig.h...
python ./vendor/platform/$(PLATFORM_TARGET)/scripts/gen.py $(PLATFORM_TARGET) $(SCRIPTS_PARAM)
@echo generate done.
$(BOAT_MKDIR) -p $(BOAT_LIB_DIR)
$(BOAT_MKDIR) -p $(BOAT_BUILD_DIR)
boatwalletlib:
make -C $(BOAT_BASE_DIR)/sdk all
vendorlib:
make -C $(BOAT_BASE_DIR)/vendor all
demo: boatlibs
make -C $(BOAT_BASE_DIR)/demo all
rulecheck:
cppcheck --enable=all -i$(BOAT_BASE_DIR)/sdk/third-party/ -i$(BOAT_BASE_DIR)/vendor/common/crypto/ -i$(BOAT_BASE_DIR)/sdk/protocol/boathlfabric/protos --force $(BOAT_BASE_DIR)
tests: boatlibs
make -C $(BOAT_BASE_DIR)/tests all
clean: cleanboatwallet cleanvendor cleandemo cleantests
-$(BOAT_RM) $(BOAT_BUILD_DIR)
cleanboatwallet:
make -C $(BOAT_BASE_DIR)/sdk clean
cleanvendor:
make -C $(BOAT_BASE_DIR)/vendor clean
cleandemo:
make -C $(BOAT_BASE_DIR)/demo clean
cleantests:
make -C $(BOAT_BASE_DIR)/tests clean