forked from dyne/Zenroom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
179 lines (147 loc) · 5.94 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
# Zenroom (GNU Makefile build system)
#
# (c) Copyright 2017-2018 Dyne.org foundation
# designed, written and maintained by Denis Roio <[email protected]>
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License version
# 3 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
pwd := $(shell pwd)
ARCH=$(shell uname -m)
PREFIX ?= /usr/local
# VERSION is set in src/Makefile
VERSION := $(shell awk '/ZENROOM_VERSION :=/ { print $$3; exit }' src/Makefile | tee VERSION)
# 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 etc. (need EMSDK)"
@echo "- linux-python3, linux-go, osx-python3, osx-go (language bindings)"
@echo "- osx, 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
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 targets for javascript (emscripten)
include ${pwd}/build/javascript.mk
# build targets for windows (mingw32 cross compile on Linux)
include ${pwd}/build/windows.mk
# build targets for linux systems (also musl and android)
include ${pwd}/build/linux.mk
# build targets for apple systems (OSX and IOS)
include ${pwd}/build/osx.mk
# build docker images and releasing
include ${pwd}/build/docker.mk
# build luarock module
include ${pwd}/build/luarock.mk
# experimental target for xtensa embedded boards
esp32: apply-patches milagro lua53
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/lua53/src" AR="${ar}" make -C lib/lpeglabel
zlib:
CC=${gcc} CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
pwd="${pwd}" make -C ${pwd}/build/zlib -f ZenMakefile
android-lua53:
CC=${gcc} CFLAGS="${cflags} ${lua_cflags}" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
make -C ${pwd}/lib/lua53/src ${platform}
musl-lua53:
CC=${gcc} CFLAGS="${cflags} ${lua_cflags}" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
make -C ${pwd}/lib/lua53/src ${platform}
lua53:
CC=${gcc} CFLAGS="${cflags} ${lua_cflags}" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
make -C ${pwd}/lib/lua53/src ${platform}
cortex-lua53:
CC=${gcc} CFLAGS="${cflags} ${lua_cflags} -DLUA_BAREBONE" \
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
make -C ${pwd}/lib/lua53/src ${platform}
milagro:
@echo "-- Building milagro (${system})"
if ! [ -r ${pwd}/lib/milagro-crypto-c/CMakeCache.txt ]; then \
cd ${pwd}/lib/milagro-crypto-c && \
CC=${gcc} LD=${ld} \
cmake . -DCMAKE_C_FLAGS="${cflags}" -DCMAKE_SYSTEM_NAME="${system}" \
-DCMAKE_AR=/usr/bin/ar -DCMAKE_C_COMPILER=${gcc} ${milagro_cmake_flags}; \
fi
if ! [ -r ${pwd}/lib/milagro-crypto-c/lib/libamcl_core.a ]; then \
CC=${gcc} CFLAGS="${cflags}" AR=${ar} RANLIB=${ranlib} LD=${ld} \
make -C ${pwd}/lib/milagro-crypto-c; \
fi
check-milagro: milagro
CC=${gcc} CFLAGS="${cflags}" make -C ${pwd}/lib/milagro-crypto-c test
# -------------------
# Test suites for all platforms
include ${pwd}/build/tests.mk
install: destbin=${DESTDIR}${PREFIX}/bin/zenroom
install: destdocs=${DESTDIR}${PREFIX}/share/zenroom
install:
install -p -s src/zenroom ${destbin}
install -d ${destdocs}/docs
if [ -d docs/website/site ]; then cd docs/website/site && cp -ra * ${destdocs}/docs/; cd -; fi
install -d ${destdocs}/examples \
&& cp -ra examples/* ${destdocs}/examples/
install -d ${destdocs}/scenarios/coconut \
&& cp -ra test/zencode_coconut/*.zen ${destdocs}/scenarios/coconut/
install -d ${destdocs}/scenarios/simple \
&& cp -ra test/zencode_simple/*.zen ${destdocs}/scenarios/simple/
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:
make clean -C ${pwd}/lib/lua53/src
make clean -C ${pwd}/lib/milagro-crypto-c
rm -f ${pwd}/lib/milagro-crypto-c/CMakeCache.txt
rm -rf ${pwd}/lib/milagro-crypto-c/CMakeFiles
make clean -C src
make clean -C bindings
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
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}