forked from 0xPolygonHermez/zkevm-prover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (69 loc) · 3.22 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
TARGET_ZKP := zkProver
TARGET_BCT := bctree
TARGET_MNG += mainGenerator
TARGET_PLG += polsGenerator
TARGET_TEST := zkProverTest
BUILD_DIR := ./build
SRC_DIRS := ./src ./test ./tools
LIBOMP := $(shell find /usr/lib/llvm-* -name "libomp.so" | sed 's/libomp.so//')
ifndef LIBOMP
$(error LIBOMP is not set, you need to install libomp-dev)
endif
CXX := g++
AS := nasm
CXXFLAGS := -std=c++17 -Wall -pthread -flarge-source-files -Wno-unused-label -rdynamic -mavx2 #-Wfatal-errors
LDFLAGS := -lprotobuf -lsodium -lgrpc -lgrpc++ -lgrpc++_reflection -lgpr -lpthread -lpqxx -lpq -lgmp -lstdc++ -lomp -lgmpxx -lsecp256k1 -lcrypto -luuid -L$(LIBOMP)
CFLAGS := -fopenmp
ASFLAGS := -felf64
# Debug build flags
ifeq ($(dbg),1)
CXXFLAGS += -g -D DEBUG
else
CXXFLAGS += -O3
endif
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
SRCS_ZKP := $(shell find $(SRC_DIRS) ! -path "./tools/starkpil/bctree/*" ! -path "./test/prover/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/tests/*" ! -path "./src/main_generator/*" ! -path "./src/pols_generator/*" -name *.cpp -or -name *.c -or -name *.asm -or -name *.cc)
OBJS_ZKP := $(SRCS_ZKP:%=$(BUILD_DIR)/%.o)
DEPS_ZKP := $(OBJS_ZKP:.o=.d)
SRCS_BCT := $(shell find $(SRC_DIRS) ! -path "./src/main.cpp" ! -path "./test/prover/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/tests/*" ! -path "./src/main_generator/*" ! -path "./src/pols_generator/*" -name *.cpp -or -name *.c -or -name *.asm -or -name *.cc)
OBJS_BCT := $(SRCS_BCT:%=$(BUILD_DIR)/%.o)
DEPS_BCT := $(OBJS_BCT:.o=.d)
SRCS_TEST := $(shell find $(SRC_DIRS) ! -path "./src/main.cpp" ! -path "./tools/starkpil/bctree/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/tests/*" ! -path "./src/main_generator/*" ! -path "./src/pols_generator/*" -name *.cpp -or -name *.c -or -name *.asm -or -name *.cc)
OBJS_TEST := $(SRCS_TEST:%=$(BUILD_DIR)/%.o)
DEPS_TEST := $(OBJS_TEST:.o=.d)
all: $(BUILD_DIR)/$(TARGET_ZKP)
bctree: $(BUILD_DIR)/$(TARGET_BCT)
test: $(BUILD_DIR)/$(TARGET_TEST)
$(BUILD_DIR)/$(TARGET_ZKP): $(OBJS_ZKP)
$(CXX) $(OBJS_ZKP) $(CXXFLAGS) -o $@ $(LDFLAGS)
$(BUILD_DIR)/$(TARGET_BCT): $(OBJS_BCT)
$(CXX) $(OBJS_BCT) $(CXXFLAGS) -o $@ $(LDFLAGS)
$(BUILD_DIR)/$(TARGET_TEST): $(OBJS_TEST)
$(CXX) $(OBJS_TEST) $(CXXFLAGS) -o $@ $(LDFLAGS)
# assembly
$(BUILD_DIR)/%.asm.o: %.asm
$(MKDIR_P) $(dir $@)
$(AS) $(ASFLAGS) $< -o $@
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(BUILD_DIR)/%.cc.o: %.cc
$(MKDIR_P) $(dir $@)
$(CXX) $(CFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
main_generator: $(BUILD_DIR)/$(TARGET_MNG)
$(BUILD_DIR)/$(TARGET_MNG): ./src/main_generator/main_generator.cpp
$(MKDIR_P) $(BUILD_DIR)
g++ -g ./src/main_generator/main_generator.cpp -o $@ -lgmp
pols_generator: $(BUILD_DIR)/$(TARGET_PLG)
$(BUILD_DIR)/$(TARGET_PLG): ./src/pols_generator/pols_generator.cpp
$(MKDIR_P) $(BUILD_DIR)
g++ -g ./src/pols_generator/pols_generator.cpp -o $@ -lgmp
.PHONY: clean
clean:
$(RM) -r $(BUILD_DIR)
-include $(DEPS_ZKP)
-include $(DEPS_BCT)
MKDIR_P ?= mkdir -p