forked from scipr-lab/libsnark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
157 lines (125 loc) · 4.67 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
#********************************************************************************
# Makefile for the libsnark library.
#********************************************************************************
#* @authors Eli Ben-Sasson, Alessandro Chiesa, Daniel Genkin,
#* Shaul Kfir, Eran Tromer, Madars Virza.
#* This file is part of libsnark, developed by SCIPR Lab <http://scipr-lab.org>.
#* @copyright MIT license (see LICENSE file)
#*******************************************************************************/
CXXFLAGS += -O2 -Wall -Wextra -Wno-unused-parameter -Wno-comment -march=native -mtune=native -std=c++11 -fopenmp
DEPSRC=depsrc
DEPINST=depinst
LDLIBS += -L $(DEPINST)/lib -Wl,-rpath $(DEPINST)/lib -L . -lgmpxx -lgmp -lzm
CXXFLAGS += -I $(DEPINST)/include -I src -I . -DUSE_ASM
DEFAULT_CURVE=BN128
GTESTDIR=/usr/src/gtest
SRCS= \
src/algebra/curves/alt_bn128/alt_bn128_g1.cpp \
src/algebra/curves/alt_bn128/alt_bn128_g2.cpp \
src/algebra/curves/alt_bn128/alt_bn128_init.cpp \
src/algebra/curves/alt_bn128/alt_bn128_pairing.cpp \
src/algebra/curves/alt_bn128/alt_bn128_pp.cpp \
src/common/profiling.cpp \
src/common/utils.cpp \
src/gadgetlib2/examples/simple_example.cpp \
src/gadgetlib2/infrastructure.cpp \
src/gadgetlib2/adapters.cpp \
src/gadgetlib2/constraint.cpp \
src/gadgetlib2/gadget.cpp \
src/gadgetlib2/integration.cpp \
src/gadgetlib2/pp.cpp \
src/gadgetlib2/protoboard.cpp \
src/gadgetlib2/variable.cpp \
src/algebra/curves/bn128/bn128_g1.cpp \
src/algebra/curves/bn128/bn128_g2.cpp \
src/algebra/curves/bn128/bn128_gt.cpp \
src/algebra/curves/bn128/bn128_init.cpp \
src/algebra/curves/bn128/bn128_pairing.cpp \
src/algebra/curves/bn128/bn128_pp.cpp \
src/algebra/curves/edwards/edwards_g1.cpp \
src/algebra/curves/edwards/edwards_g2.cpp \
src/algebra/curves/edwards/edwards_init.cpp \
src/algebra/curves/edwards/edwards_pairing.cpp \
src/algebra/curves/edwards/edwards_pp.cpp
EXECUTABLES= \
src/r1cs_ppzksnark/examples/profile_r1cs_ppzksnark \
src/gadgetlib2/examples/tutorial \
src/gadgetlib2/tests/gadgetlib2_test
DOCS= README.html
OBJS=$(patsubst %.cpp,%.o,$(SRCS))
# Recompile GTest, if we can (e.g., Ubuntu). Otherwise use precompiled one (e.g., Fedora).
# See https://code.google.com/p/googletest/wiki/FAQ#Why_is_it_not_recommended_to_install_a_pre-compiled_copy_of_Goog .
COMPILE_GTEST=$(shell test -d $(GTESTDIR) && echo 1) # Found GTest sourcecode?
ifeq ($(COMPILE_GTEST),1)
else
LDFLAGS += -lgtest
endif
# For documentation of the following options, see README.md .
ifeq ($(MINDEPS),1)
CXXFLAGS += -DMINDEPS
else
LDLIBS += -lprocps
endif
ifeq ($(LOWMEM),1)
CXXFLAGS += -DLOWMEM
endif
ifeq ($(STATIC),1)
CXXFLAGS += -static -DSTATIC
endif
ifeq ($(PROFILE_OP_COUNTS),1)
CXXFLAGS += -static -DPROFILE_OP_COUNTS
endif
ifeq ($(MULTICORE),1)
CXXFLAGS += -DMULTICORE
endif
ifeq ($(CPPDEBUG),1)
CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
DEBUG = 1
endif
ifeq ($(DEBUG),1)
CXXFLAGS += -DDEBUG -ggdb3
endif
ifeq ($(PERFORMANCE),1)
CXXFLAGS += -flto -fuse-linker-plugin
CXXFLAGS += -march=native -mtune=native
CXXFLAGS += -DNDEBUG
LDFLAGS += -flto
endif
ifeq ($(CURVE),)
CXXFLAGS += -DCURVE_$(DEFAULT_CURVE)
else
CXXFLAGS += -DCURVE_$(CURVE)
endif
all: $(EXECUTABLES) $(DOCS)
doc: $(DOCS)
# In order to detect changes to #include dependencies. -MMD below generates a .d file for .cpp file. Include the .d file.
-include $(SRCS:.cpp=.d)
$(OBJS): %.o: %.cpp
$(CXX) -o $@ $< -c -MMD $(CXXFLAGS)
ifeq ($(COMPILE_GTEST),1)
OBJS += $(DEPINST)/gtest-all.o
$(DEPINST)/gtest-all.o: $(GTESTDIR)/src/gtest-all.cc
$(CXX) -o $@ $< $(CXXFLAGS) -I $(GTESTDIR) -c
endif
src/gadgetlib2/tests/gadgetlib2_test: src/gadgetlib2/tests/adapters_UTEST.cpp src/gadgetlib2/tests/constraint_UTEST.cpp src/gadgetlib2/tests/gadget_UTEST.cpp src/gadgetlib2/tests/protoboard_UTEST.cpp src/gadgetlib2/tests/variable_UTEST.cpp
$(EXECUTABLES): %: %.o $(OBJS)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)
$(DOCS): %.html: %.md
markdown_py -f $@ $^ -x toc -x extra --noisy
# TODO: Would be nice to enable "-x smartypants" but Ubuntu 12.04 doesn't support that.
# TODO: switch to redcarpet, to produce same output as GitHub's processing of README.md. But what about TOC?
doxy:
doxygen doxygen.conf
# Clean generated files, except locally-compiled dependencies
clean:
$(RM) \
$(OBJS) \
$(EXECUTABLES) \
$(DOCS) \
${patsubst %,%.o,${EXECUTABLES}} \
${patsubst %.cpp,%.d,${SRCS}} \
rm -fr doxygen/
# Clean all, including locally-compiled dependencies
clean-all: clean
rm -fr $(DEPSRC) $(DEPINST)
.PHONY: all clean clean-all doc doxy