-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
Makefile
221 lines (188 loc) · 6.82 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
# Copyright 2017-2018 Dyne.org foundation
# SPDX-FileCopyrightText: 2017-2021 Dyne.org foundation
#
# SPDX-License-Identifier: AGPL-3.0-or-later
pwd := $(shell pwd)
# ARCH ?=$(shell uname -m)
PREFIX ?= /usr/local
# VERSION is set in src/Makefile
# Targets to be build in this order
BUILDS := apply-patches milagro lua54 embed-lua quantum-proof ed25519-donna mimalloc
# DESTDIR is supported by install target
# include platform specific configurations pattern-matching target labels
include ${pwd}/build/config.mk
all:
@echo "Choose a target:"
@echo "- linux, linux-lib, linux-clang, linux-debug"
@echo "- javascript-web, javascript-wasm, javascript-demo, javascript-rn (need EMSDK)"
@echo "- linux-python3, linux-go, osx-python3, osx-go (language bindings)"
@echo "- osx, osx-lib, ios-lib, ios-armv7, ios-arm64, ios-sim (need Apple/OSX)"
@echo "- win, win-dll (cross-compile using MINGW on Linux)"
@echo "- musl, musl-local, musl-system (full static build)"
@echo "- android-arm android-x86 android-aarch64"
@echo "- cortex-arm, linux-riscv64, aarch64"
@echo "for android and ios see scripts in build/"
# if ! [ -r build/luac ]; then ${gcc} -I${luasrc} -o build/luac ${luasrc}/luac.c ${luasrc}/liblua.a -lm; fi
sonarqube:
@echo "Configure login token in build/sonarqube.sh"
cp -v build/sonar-project.properties .
./build/sonarqube.sh
embed-lua: lua_embed_opts := $(if ${COMPILE_LUA}, compile)
embed-lua:
@echo "Embedding all files in src/lua"
./build/embed-lualibs ${lua_embed_opts}
@echo "File generated: src/lualibs_detected.c"
src/zen_ecdh_factory.c:
${pwd}/build/codegen_ecdh_factory.sh ${ecdh_curve}
src/zen_ecp_factory.c:
${pwd}/build/codegen_ecp_factory.sh ${ecp_curve}
src/zen_big_factory.c:
${pwd}/build/codegen_ecp_factory.sh ${ecp_curve}
apply-patches: src/zen_ecdh_factory.c src/zen_ecp_factory.c src/zen_big_factory.c
# build target for javascript (emscripten)
javascript: ${BUILDS}
CC="${gcc}" AR="${ar}" CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" LDADD="${ldadd}" \
make -C src js
@mkdir -p build/npm
@cp -v src/zenroom.js build/npm/
# build luarock module
include ${pwd}/build/luarock.mk
# experimental target for xtensa embedded boards
esp32: apply-patches milagro lua54
CC=${pwd}/build/xtensa-esp32-elf/bin/xtensa-esp32-elf-${gcc} \
LD=${pwd}/build/xtensa-esp32-elf/bin/xtensa-esp32-elf-ld \
CFLAGS="${cflags}" LDFLAGS="${ldflags}" LDADD="${ldadd}" \
$(MAKE) -C src linux
# static dependencies in lib
# lpeglabel:
# CC=${gcc} CFLAGS="${cflags} -I${pwd}/lib/lua54/src" AR="${ar}" $(MAKE) -C lib/lpeglabel
lua54:
CC="${lua_cc}" CFLAGS="${cflags} ${lua_cflags}" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
$(MAKE) -C ${pwd}/lib/lua54/src liblua.a
android-lua54:
CC="${lua_cc}" CFLAGS="${cflags} ${lua_cflags}" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
$(MAKE) -C ${pwd}/lib/lua54/src ${platform}
musl-lua54:
CC="${lua_cc}" CFLAGS="${cflags} ${lua_cflags}" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
$(MAKE) -C ${pwd}/lib/lua54/src ${platform}
cortex-lua54:
CC="${lua_cc}" CFLAGS="${cflags} ${lua_cflags} -DLUA_BAREBONE" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
$(MAKE) -C ${pwd}/lib/lua54/src ${platform}
milagro-debug: milagro
milagro:
@echo "-- Building milagro (${system})"
if ! [ -r ${pwd}/lib/milagro-crypto-c/build/CMakeCache.txt ]; then \
cd ${pwd}/lib/milagro-crypto-c && \
mkdir -p build && \
cd build && \
CC=${gcc} LD=${ld} AR=${ar} \
cmake ../ -DCMAKE_C_FLAGS="${cflags}" -DCMAKE_SYSTEM_NAME="${system}" \
-DCMAKE_AR=${ar} -DCMAKE_C_COMPILER=${gcc} ${milagro_cmake_flags}; \
fi
if ! [ -r ${pwd}/lib/milagro-crypto-c/build/lib/libamcl_core.a ]; then \
RANLIB=${ranlib} LD=${ld} \
$(MAKE) -C ${pwd}/lib/milagro-crypto-c/build; \
fi
mimalloc-debug: mimalloc
mimalloc:
$(info -- Building mimalloc (${system}))
if ! [ -r ${pwd}/lib/mimalloc/build/CMakeCache.txt ]; then \
cd ${pwd}/lib/mimalloc && \
mkdir -p build && \
cd build && \
CC=${gcc} LD=${ld} AR=${AR} \
cmake ../ ${mimalloc_cmake_flags} \
-DCMAKE_C_FLAGS="${cflags} ${mimalloc_cflags}" \
-DCMAKE_SYSTEM_NAME="${system}" \
-DCMAKE_AR=${ar} -DCMAKE_C_COMPILER=${gcc} \
-DCMAKE_CXX_COMPILER=$(subst gcc,g++,${gcc}); \
fi
if ! [ -r ${pwd}/lib/mimalloc/build/libmimalloc-static.a ]; then \
RANLIB=${ranlib} LD=${ld} \
${MAKE} -C ${pwd}/lib/mimalloc/build; \
fi
quantum-proof-ccache: quantum-proof
quantum-proof-debug: quantum-proof
quantum-proof:
$(info -- Building Quantum-Proof libs)
CC="${quantum_proof_cc}" \
LD=${ld} \
AR=${ar} \
RANLIB=${ranlib} \
LD=${ld} \
CFLAGS="${quantum_proof_cflags} ${cflags}" \
LDFLAGS="${ldflags}" \
${MAKE} -C ${pwd}/lib/pqclean
check-milagro: milagro
CC=${gcc} CFLAGS="${cflags}" $(MAKE) -C ${pwd}/lib/milagro-crypto-c test
ed25519-donna-ccache: ed25519-donna
ed25519-donna:
echo "-- Building ED25519 for EDDSA"
CC="${ed25519_cc}" \
AR=${ar} \
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
$(MAKE) -C ${pwd}/lib/ed25519-donna
# -------------------
# Test suites for all platforms
include ${pwd}/build/tests.mk
install: destbin=${DESTDIR}${PREFIX}/bin
install: destdocs=${DESTDIR}${PREFIX}/share/zenroom
install:
install -p -s src/zenroom ${destbin}/zenroom
install -p -s src/zencode-exec ${destbin}/zencode-exec
install -d ${destdocs}/docs
if [ -d docs/website/site ]; then cd docs/website/site && cp -ra * ${destdocs}/docs/; cd -; fi
if [ -d docs/Zencode_Whitepaper.pdf ]; then cp -ra docs/Zencode_Whitepaper.pdf ${destdocs}/; fi
cp README.md ${destdocs}/README.txt
cp LICENSE.txt ${destdocs}/LICENSE.txt
cp ChangeLog.md ${destdocs}/ChangeLog.txt
install-lua: destlib=${LIBDIR}
install-lua:
mkdir -p ${destlib}
cp src/octet.so ${destlib}
cp src/ecdh.so ${destlib}
clean:
rm -rf ${pwd}/meson
$(MAKE) clean -C ${pwd}/lib/lua54/src
$(MAKE) clean -C ${pwd}/lib/pqclean
rm -rf ${pwd}/lib/milagro-crypto-c/build
rm -rf ${pwd}/lib/mimalloc/build
$(MAKE) clean -C ${pwd}/src
if [ -d "bindings" ]; then $(MAKE) clean -C ${pwd}/bindings; fi
rm -f ${extras}/index.*
rm -rf ${pwd}/build/asmjs
rm -rf ${pwd}/build/wasm
rm -rf ${pwd}/build/rnjs
rm -rf ${pwd}/build/npm
rm -rf ${pwd}/build/demo
rm -f ${pwd}/build/swig_wrap.c
rm -f ${pwd}/.python-version
rm -f ${pwd}/src/zenroom
rm -f ${pwd}/lib/ed25519-donna/libed25519.a
rm -f ${pwd}/lib/ed25519-donna/*.o
rm -f ${pwd}/test/zencode-exec
rm -f ${pwd}/test/zenroom
clean-src:
rm -f src/zen_ecdh_factory.c src/zen_ecp_factory.c src/zen_big_factory.c
$(MAKE) clean -C src
distclean:
rm -rf ${musl}
# -------------------
# Parsing the documentation
needed-docs:
cd ${pwd}/docs/doc_needed; ./run.sh
# -------------------
# Linux benchamrk
linux-benchmark:
./test/benchmark/all_tests/bench.sh
clean-test:
git clean -f docs
git restore docs
rm -f test/zenroom
rm -f test/zencode-exec