-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
111 lines (96 loc) · 3.5 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
# lua-zenroom (GNU Makefile build system)
#
# (c) Copyright 2020-2021 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/>.
version=0.1.0
pwd := $(shell pwd)
ARCH=$(shell uname -m)
gcc := gcc
luaver := 5.1
system := $(shell uname -s)
ldflags :=
ldflags_macos := -dynamiclib -undefined dynamic_lookup
ldflags_linux := -fPIC -shared
ar := $(shell which ar) # cmake requires full path
ranlib := ranlib
ld := ld
platform := posix
ifeq ($(system),Darwin)
ldflags+=$(ldflags_macos)
else
ldflags+=$(ldflags_linux)
endif
# ----------------
# milagro settings
rsa_bits := ""
ecdh_curve := "SECP256K1"
ecp_curve := "BLS381"
milagro_cmake_flags := -DBUILD_SHARED_LIBS=OFF -DBUILD_PYTHON=OFF -DBUILD_DOXYGEN=OFF -DBUILD_DOCS=OFF -DBUILD_BENCHMARKS=OFF -DBUILD_EXAMPLES=OFF -DWORD_SIZE=64 -DBUILD_PAILLIER=ON -DBUILD_X509=OFF -DBUILD_WCC=OFF -DBUILD_MPIN=OFF -DAMCL_CURVE=${ecdh_curve},${ecp_curve} -DAMCL_RSA="" -DAMCL_PREFIX=AMCL_ -DCMAKE_SHARED_LIBRARY_LINK_FLAGS="" -DC99=1
milagro_cflags := -fPIC
milib := ${pwd}/lib/milagro-crypto-c/build/lib
ldadd += ${milib}/libamcl_curve_${ecp_curve}.a
ldadd += ${milib}/libamcl_pairing_${ecp_curve}.a
ldadd += ${milib}/libamcl_curve_${ecdh_curve}.a
ldadd += ${milib}/libamcl_paillier.a
ldadd += ${milib}/libamcl_core.a
all: milagro codegen zenroom
codegen:
cd src && ./codegen_ecdh_factory.sh ${ecdh_curve}
cd src && ./codegen_ecp_factory.sh ${ecp_curve}
debug: milagro codegen
CC="${gcc}" AR="${ar}" \
LDFLAGS="${ldflags}" LDADD="${ldadd}" CFLAGS="-O0 -ggdb -DDEBUG=3 -Wall" \
VERSION="${version}" \
make -C src
zenroom:
CC="${gcc}" AR="${ar}" \
LDFLAGS="${ldflags}" LDADD="${ldadd}" \
VERSION="${version}" \
make -C src
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} \
cmake ../ -DCMAKE_C_FLAGS="${cflags} ${milagro_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 \
CC=${gcc} CFLAGS="${cflags}" AR=${ar} RANLIB=${ranlib} LD=${ld} \
make -C ${pwd}/lib/milagro-crypto-c/build; \
fi
check: cflags += -O0 -ggdb -DDEBUG
check: milagro zenroom
LUAVER=${luaver} make -C src check
check-random:
if ! command -v rngtest; then echo "No rngtest found, install rng-tools"; fi
lua5.1 test/nist/check_rsp.lua
gdb:
LUAVER=${luaver} make -C src gdb
clean:
rm -rf ${pwd}/lib/milagro-crypto-c/build
make clean -C ${pwd}/src
install: PREFIX ?= /usr/local
install: DEST_LIBDIR ?= ${PREFIX}/lib/lua/5.1
install: DEST_SHAREDIR ?= ${PREFIX}/share/lua/5.1
install:
mkdir -p ${DEST_LIBDIR} ${DEST_SHAREDIR}
install src/libzenroom.so ${DEST_LIBDIR}/libzenroom.so
install src/lua/init.lua -D ${DEST_SHAREDIR}/zenroom/init.lua
cp -v src/lua/zenroom_*.lua ${DEST_SHAREDIR}/zenroom/