This repository has been archived by the owner on Dec 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
101 lines (87 loc) · 2.99 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
DCURL_DIR := third_party/dcurl
DCURL_LIB := $(DCURL_DIR)/build/libdcurl.so
MOSQUITTO_DIR := third_party/mosquitto
MOSQUITTO_LIB := $(MOSQUITTO_DIR)/lib/libmosquitto.so.1
PEM_DIR = pem
# Default pem file. See pem/README.md for more information
PEM := $(PEM_DIR)/cert.pem
OUTPUT_BASE_DIR := output_base
# Endpoint build target. The default intends to the platform of your development system.
EP_TARGET := simulator
# Build test suite
TESTS := false
# Enable endpoint HTTPS connection to tangle-accelerator.
# The endpoint uses HTTP connection to transmit encrypted data by default.
# See "HTTPS Connection Support" in docs/endpoint.md for more information.
ENFORCE_EP_HTTPS := false
# The flags that will be preprocessed by mkapp program, part of Legato Application Framework.
# Eventually, the processed flags are passed as compiler-time options.
LEGATO_FLAGS :=
DEPS += $(DCURL_LIB)
# Determine to enable HTTPS connection
ifeq ($(ENFORCE_EP_HTTPS), true)
LEGATO_FLAGS += -DENDPOINT_HTTPS
endif
# Determine to build test suite
ifeq ($(TESTS), true)
LEGATO_FLAGS += -DENABLE_ENDPOINT_TEST
endif
# The tangle-acclerator host for endpoint to connect
ifdef EP_TA_HOST
LEGATO_FLAGS += -DEP_TA_HOST=${EP_TA_HOST}
endif
# The tangle-acclerator port for endpoint to connect
ifdef EP_TA_PORT
LEGATO_FLAGS += -DEP_TA_PORT=${EP_TA_PORT}
endif
# The ssl seed for endpoint (optional)
ifdef EP_SSL_SEED
LEGATO_FLAGS += -DEP_SSL_SEED=${EP_SSL_SEED}
endif
# Pass target into endpoint build process
LEGATO_FLAGS += -DEP_TARGET=$(EP_TARGET)
# Prepend the "-C" flag at the beginging for passing cflags into mkapp
LEGATO_FLAGS := $(foreach flags, $(LEGATO_FLAGS), -C $(flags))
export EP_TARGET
export LEGATO_FLAGS
all: $(DEPS) cert
.PHONY: $(DCURL_LIB) $(MOSQUITTO_LIB) legato cert check_pem
$(DCURL_LIB): $(DCURL_DIR)
git submodule update --init $^
$(MAKE) -C $^ config
@echo
$(info Modify $^/build/local.mk for your environments.)
$(MAKE) -C $^ all
MQTT: $(DCURL_LIB) $(MOSQUITTO_LIB) cert
$(MOSQUITTO_LIB): $(MOSQUITTO_DIR)
git submodule update --init $^
@echo
$(MAKE) -C $^ WITH_DOCS=no
# Build endpoint Legato app
legato: cert
# FIXME: Build the accelerator to get ta default logger from IOTA default
# repository. Remove this after all of the ta logger has been replaced by
# legato logger inside endpoint.
bazel --output_base=$(OUTPUT_BASE_DIR) build //accelerator
endpoint/build-legato.sh
$(MAKE) -C endpoint $(EP_TARGET)
cert: check_pem
@xxd -i $(PEM) > $(PEM_DIR)/ca_crt.inc
@sed -E \
-e 's/(unsigned char)(.*)(\[\])(.*)/echo "\1 ca_crt_pem\3\4"/ge' \
-e 's/(unsigned int)(.*)(=)(.*)/echo "\1 ca_crt_pem_len \3\4"/ge' \
-e 's/^unsigned/static &/' \
-e 's/(.*)(pem_len = )([0-9]+)(.*)/echo "\1\2$$((\3+1))\4"/ge' \
-e 's/(0[xX][[[:xdigit:]]+)$$/\1, 0x0/g' \
-i $(PEM_DIR)/ca_crt.inc
check_pem:
ifndef PEM
$(error PEM is not set)
endif
clean:
$(MAKE) -C $(DCURL_DIR) clean
$(MAKE) -C $(MOSQUITTO_DIR) clean
$(MAKE) -C endpoint clean
distclean: clean
$(RM) -r $(DCURL_DIR)
git checkout $(DCURL_DIR)