forked from cryptobiu/libscapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile_libs
268 lines (228 loc) · 10.3 KB
/
makefile_libs
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
export builddir=$(abspath ./build)
export prefix=$(abspath ./install)
CXX=g++
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
ARCH := $(shell getconf LONG_BIT)
SHARED_LIB_EXT:=.so
INCLUDE_ARCHIVES_START = -Wl,-whole-archive # linking options, we prefer our generated shared object will be self-contained.
INCLUDE_ARCHIVES_END = -Wl,-no-whole-archive
SHARED_LIB_OPT:=-shared
export uname_S
export ARCH
export SHARED_LIB_EXT
export INCLUDE_ARCHIVES_START
export INCLUDE_ARCHIVES_END
export SHARED_LIB_OPT
export exec_prefix=$(prefix)
export includedir=$(prefix)/include
export bindir=$(exec_prefix)/bin
export libdir=$(prefix)/lib
SLib = scapi.a
CPP_FILES := $(wildcard src/*/*.cpp)
C_FILES := $(wildcard src/*/*.c)
OBJ_FILES := $(patsubst src/%.cpp,obj/%.o,$(CPP_FILES))
OBJ_FILES += $(patsubst src/%.c,obj/%.o,$(C_FILES))
OUT_DIR = obj obj/mid_layer obj/circuits obj/comm obj/infra obj/interactive_mid_protocols obj/primitives obj/circuits_c
INC = -Ilib -Iinstall/include -Ilib/OTExtensionBristol
CPP_OPTIONS := -std=c++11 $(INC) -maes -mpclmul -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-parentheses -O3
$(COMPILE.cpp) = g++ -c $(CPP_OPTIONS) -o $@ $<
LINKER_OPTIONS = $(INCLUDE_ARCHIVES_START) install/lib/libOTExtensionBristol.a install/lib/libsimpleot.a install/lib/libntl.a install/lib/libboost_sytem.a install/lib/libboost_thread.a install/lib/libmiracl.a install/lib/libblake2.a -lpthread -lgmp -lcrypto -lssl -lOTExtension -lMaliciousOTExtension -ldl $(INCLUDE_ARCHIVES_END)
LIBRARIES_DIR = -L$(HOME)/boost_1_64_0/stage/lib -Linstall/lib
LD_FLAGS =
SUMO = no
all: libs
echo $(WITH_EMP)
libs: compile-boost compile-ntl compile-emp-tool compile-emp-ot compile-emp-m2pc compile-blake compile-FourQlib compile-miracl compile-otextension compile-otextension-malicious compile-otextension-bristol compile-json
libscapi: directories $(SLib)
directories: $(OUT_DIR)
$(OUT_DIR):
mkdir -p $(OUT_DIR)
$(SLib): $(OBJ_FILES)
ar ru $@ $^
ranlib $@
obj/circuits/%.o: src/circuits/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/circuits_c/%.o: src/circuits_c/%.c
gcc -fPIC -mavx -maes -mpclmul -DRDTSC -DTEST=AES128 -O3 -c -o $@ $<
obj/comm/%.o: src/comm/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/infra/%.o: src/infra/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/interactive_mid_protocols/%.o: src/interactive_mid_protocols/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/primitives/%.o: src/primitives/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/mid_layer/%.o: src/mid_layer/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
tests: compile-tests
cd ./test; ./tests.exe
.PHONY: compile-tests
compile-tests:
@cd ./test; \
g++ -std=c++11 -maes -mavx -I/usr/include/openssl -I../install/include -o tests.exe tests.cpp interactiveMidProtocolsTests.cpp ../scapi.a -ldl -lpthread -L../install/lib ../install/lib/libboost_system.a ../install/lib/libboost_thread.a -lssl -lntl -lgmp -lblake2 -lcrypto;
@cd ..
prepare-emp:
ifeq ($(SUMO),yes)
@mkdir -p $(builddir)/EMP
@cp -r lib/EMP/. $(builddir)/EMP
@cmake -DALIGN=16 -DARCH=X64 -DARITH=curve2251-sse -DCHECK=off -DFB_POLYN=251 -DFB_METHD="INTEG;INTEG;QUICK;QUICK;QUICK;QUICK;LOWER;SLIDE;QUICK" -DFB_PRECO=on -DFB_SQRTF=off -DEB_METHD="PROJC;LODAH;COMBD;INTER" -DEC_METHD="CHAR2" -DCOMP="-O3 -funroll-loops -fomit-frame-pointer -march=native -msse4.2 -mpclmul -Wno-unused-function -Wno-unused-variable -Wno-return-type -Wno-discarded-qualifiers" -DTIMER=CYCLE -DWITH="MD;DV;BN;FB;EB;EC" -DWORD=64 $(builddir)/EMP/relic/CMakeLists.txt
@cd $(builddir)/EMP/relic && $(MAKE)
@cd $(builddir)/EMP/relic && $(MAKE) install
@touch prepare-emp
endif
compile-emp-tool:prepare-emp
ifeq ($(SUMO),yes)
@cd $(builddir)/EMP/emp-tool
@cmake -D CMAKE_CXX_FLAGS="-Wno-unused-function -Wno-unused-variable -Wno-return-type" $(builddir)/EMP/emp-tool/CMakeLists.txt
@cd $(builddir)/EMP/emp-tool/ && $(MAKE)
@cd $(builddir)/EMP/emp-tool/ && $(MAKE) install
@touch compile-emp-tool
endif
compile-emp-ot:prepare-emp
ifeq ($(SUMO),yes)
@cd $(builddir)/EMP/emp-ot
@cmake -D CMAKE_CXX_FLAGS="-Wno-unused-function -Wno-unused-variable -Wno-return-type" $(builddir)/EMP/emp-ot/CMakeLists.txt
@cd $(builddir)/EMP/emp-ot/ && $(MAKE)
@cd $(builddir)/EMP/emp-ot/ && $(MAKE) install
@touch compile-emp-ot
endif
compile-emp-m2pc:compile-emp-ot compile-emp-tool
ifeq ($(SUMO),yes)
@cd $(builddir)/EMP/emp-m2pc
@cmake -D CMAKE_CXX_FLAGS="-Wno-unused-function -Wno-unused-variable -Wno-return-type -Wno-unused-result" $(builddir)/EMP/emp-m2pc/CMakeLists.txt
@cd $(builddir)/EMP/emp-m2pc/ && $(MAKE)
@touch compile-emp-m2pc
endif
compile-blake:
@echo "Compiling the BLAKE2 library"
@mkdir -p $(builddir)/BLAKE2/
@cp -r lib/BLAKE2/sse/. $(builddir)/BLAKE2
@$(MAKE) -C $(builddir)/BLAKE2
@$(MAKE) -C $(builddir)/BLAKE2 BUILDDIR=$(builddir) install
# @ cp $(builddir)/BLAKE2/libblake2.a install/lib/
@touch compile-blake
compile-FourQlib:
@mkdir -p $(CURDIR)/install/lib
echo "Compiling the FourQlib library"
cp -r lib/FourQlib $(builddir)
cd $(builddir)/FourQlib/FourQ_64bit_and_portable/; $(MAKE) ARCH=x64
cd $(builddir)/FourQlib/FourQ_64bit_and_portable/; ar cr libFourQlib.a crypto_tests.o eccp2_core.o eccp2.o fp2_1271_AVX2.o kex.o schnorrq.o test_extras.o crypto_util.o eccp2_no_endo.o ecc_tests.o fp_tests.o random.o sha512.o
cd $(builddir)/FourQlib/FourQ_64bit_and_portable/; ranlib libFourQlib.a
cp $(builddir)/FourQlib/FourQ_64bit_and_portable/*.a $(CURDIR)/install/lib/
mkdir -p $(CURDIR)/install/include/FourQlib
cp $(builddir)/FourQlib/FourQ_64bit_and_portable/FourQ_api.h $(CURDIR)/install/include/FourQlib
touch compile-FourQlib
compile-json:
@echo "Compiling JSON library..."
@cp -r lib/JsonCpp $(builddir)/JsonCpp
@cmake $(builddir)/JsonCpp/CMakeLists.txt
@$(MAKE) -C $(builddir)/JsonCpp/
@cp $(builddir)/JsonCpp/src/lib_json/libjsoncpp.a $(CURDIR)/install/lib/
@touch compile-json
compile-boost:
@mkdir -p $(CURDIR)/install/lib
@mkdir -p $(CURDIR)/install/include
@mkdir -p $(builddir)/
echo "Compiling the boost library"
@cp -r lib/boost_1_64_0/ $(builddir)/boost_1_64_0
cd $(builddir)/boost_1_64_0/; bash -c "BOOST_BUILD_PATH='./' ./bootstrap.sh --with-libraries=thread,system && ./b2";
@cp $(builddir)/boost_1_64_0/stage/lib/*.a $(CURDIR)/install/lib/
@cp -r $(builddir)/boost_1_64_0/boost/ $(CURDIR)/install/include/
@touch compile-boost
compile-ntl:
echo "Compiling the NTL library..."
mkdir -p $(builddir)/NTL
cp -r lib/NTL/unix/. $(builddir)/NTL
chmod 777 $(builddir)/NTL/src/configure
cd $(builddir)/NTL/src/ && ./configure CXX=$(CXX) WIZARD=off
$(MAKE) -C $(builddir)/NTL/src/
$(MAKE) -C $(builddir)/NTL/src/ PREFIX=$(prefix) install
touch compile-ntl
prepare-miracl:
@echo "Copying the miracl source files into the miracl build dir..."
@mkdir -p $(builddir)/$(MIRACL_DIR)
@find lib/Miracl/ -type f -exec cp '{}' $(builddir)/$(MIRACL_DIR)/ \;
@rm -f $(builddir)/$(MIRACL_DIR)/mirdef.h
@rm -f $(builddir)/$(MIRACL_DIR)/mrmuldv.c
@cp -r lib/MiraclCompilation/* $(builddir)/$(MIRACL_DIR)/
compile-miracl:
@$(MAKE) prepare-miracl MIRACL_DIR=Miracl
@echo "Compiling the Miracl library (C)..."
@$(MAKE) -C $(builddir)/Miracl MIRACL_TARGET_LANG=c
@echo "Installing the Miracl library..."
@$(MAKE) -C $(builddir)/Miracl MIRACL_TARGET_LANG=c install
@touch compile-miracl
compile-miracl-cpp:
@$(MAKE) prepare-miracl MIRACL_DIR=MiraclCPP CXX=$(CXX)
@echo "Compiling the Miracl library (C++)..."
@$(MAKE) -C $(builddir)/MiraclCPP MIRACL_TARGET_LANG=cpp CXX=$(CXX)
@echo "Installing the Miracl library..."
@$(MAKE) -C $(builddir)/MiraclCPP MIRACL_TARGET_LANG=cpp CXX=$(CXX) install
@touch compile-miracl-cpp
compile-otextension: compile-miracl-cpp
@echo "Compiling the OtExtension library..."
@cp -r lib/OTExtension $(builddir)/OTExtension
@$(MAKE) -C $(builddir)/OTExtension CXX=$(CXX)
@$(MAKE) -C $(builddir)/OTExtension CXX=$(CXX) SHARED_LIB_EXT=$(SHARED_LIB_EXT) install
@touch compile-otextension
compile-otextension-malicious: compile-miracl-cpp
@echo "Compiling the OtExtension malicious library..."
@cp -r lib/MaliciousOTExtension $(builddir)/MaliciousOTExtension
@$(MAKE) -C $(builddir)/MaliciousOTExtension CXX=$(CXX)
@$(MAKE) -C $(builddir)/MaliciousOTExtension CXX=$(CXX) SHARED_LIB_EXT=$(SHARED_LIB_EXT) install
@touch compile-otextension-malicious
compile-otextension-bristol:
@echo "Compiling the OtExtension malicious Bristol library..."
@cp -r lib/OTExtensionBristol $(builddir)/OTExtensionBristol
@$(MAKE) -C $(builddir)/OTExtensionBristol CXX=$(CXX)
@$(MAKE) -C $(builddir)/OTExtensionBristol CXX=$(CXX) install
@touch compile-otextension-bristol
clean-miracl:
@echo "Cleaning the miracl build dir..."
@rm -rf $(builddir)/Miracl
@rm -f compile-miracl
clean-miracl-cpp:
@echo "Cleaning the miracl build dir..."
@rm -rf $(builddir)/MiraclCPP
@rm -f compile-miracl-cpp
clean-otextension:
@echo "Cleaning the otextension build dir..."
@rm -rf $(builddir)/OTExtension
@rm -f compile-otextension
clean-otextension-malicious:
@echo "Cleaning the otextension malicious build dir..."
@rm -rf $(builddir)/MaliciousOTExtension
@rm -f compile-otextension-malicious
clean-otextension-bristol:
@echo "Cleaning the otextension malicious bristol build dir..."
@rm -rf $(builddir)/OTExtensionBristol
@rm -f compile-otextension-bristol
clean-ntl:
echo "Cleaning the ntl build dir..."
rm -rf $(builddir)/NTL
rm -f compile-ntl
clean-blake:
@echo "Cleaning blake library"
@rm -rf $(builddir)/BLAKE2
@rm -f compile-blake
clean-json:
@echo "Cleaning JSON library"
@rm -rf $(builddir)/JsonCpp/
@rm -f compile-json
clean-FourQlib:
@echo "Cleaning FourQlib library"
@rm -rf $(builddir)/FourQlib
@rm -f compile-FourQlib
clean-emp:
@echo "Cleaning EMP library"
@rm -rf $(builddir)/EMP
@rm -f prepare-emp compile-emp-tool compile-emp-ot compile-emp-m2pc
clean-install:
@rm -rf install/*
clean-tests:
@rm -f test/tests.exe
clean-boost:
@echo "Cleaning boost library"
@rm -rf $(builddir)/boost_1_64_0
@rm -f compile-boost
clean: clean-boost clean-emp clean-otextension-bristol clean-otextension-malicious clean-otextension clean-ntl clean-blake clean-FourQlib clean-miracl clean-miracl-cpp clean-cpp clean-install clean-tests