-
Notifications
You must be signed in to change notification settings - Fork 8
/
makefile
168 lines (119 loc) · 4.49 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
# Copyright 2022
# This file is part of QUANTAS. QUANTAS is free software: you can
# redistribute it and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.
# QUANTAS 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 QUANTAS. If not,
# see <https://www.gnu.org/licenses/>.
PROJECT_DIR := quantas
################
#
# configure this for the specific algorithm and input file
#
INPUTFILE := ExampleInput.json
# ALGFILE := TrailPeer
ALGFILE := ExamplePeer
# ALGFILE := BitcoinPeer
# ALGFILE := EthereumPeer
# ALGFILE := PBFTPeer
# ALGFILE := RaftPeer
# ALGFILE := SmartShardsPeer
# ALGFILE := LinearChordPeer
# ALGFILE := KademliaPeer
# ALGFILE := AltBitPeer
# ALGFILE := StableDataLinkPeer
# ALGFILE := ChangRobertsPeer
# ALGFILE := DynamicPeer
# ALGFILE := KPTPeer
# ALGFILE := KSMPeer
# ALGFILE := CycleOfTreesPeer
####### end algorithm configuration
####### All algorithms
INPUTFILE := $(PROJECT_DIR)/$(ALGFILE)/$(INPUTFILE)
CPPFLAGS := -Iinclude -MMD -MP
CXXFLAGS = -pthread -include $(PROJECT_DIR)/$(ALGFILE)/$(ALGFILE).hpp
CXX := g++
GCC_VERSION := $(shell $(CXX) -dumpversion)
GCC_MIN_VERSION := 8
check-version:
@if [ "$(GCC_VERSION)" -lt "$(GCC_MIN_VERSION)" ]; then echo "Default version of g++ must be higher than 8."; fi
@if [ "$(GCC_VERSION)" -lt "$(GCC_MIN_VERSION)" ]; then echo "To change the default version visit: https://linuxconfig.org/how-to-switch-between-multiple-gcc-and-g-compiler-versions-on-ubuntu-20-04-lts-focal-fossa"; fi
@if [ "$(GCC_VERSION)" -lt "$(GCC_MIN_VERSION)" ]; then exit 1; fi
EXE := quantas.exe
OBJS = $(PROJECT_DIR)/main.o $(PROJECT_DIR)/$(ALGFILE)/$(ALGFILE).o $(PROJECT_DIR)/Common/Distribution.o
# extra debug and release flags
release: CXXFLAGS += -O3 -s -std=c++17
debug: CXXFLAGS += -O0 -g -D_GLIBCXX_DEBUG -std=c++17
clang: CXX := clang++
clang: CXXFLAGS += -std=c++17
.PHONY: all clean run release debug
all: release
release: check-version $(EXE)
debug: check-version $(EXE)
clang: all
./$(EXE) $(INPUTFILE)
$(EXE): $(OBJS)
$(CXX) $(CXXFLAGS) $^ -o $(EXE)
$(PROJECT_DIR)/%.o: $(PROJECT_DIR)/%.c
$(CXX) $(CXXFLAGS) -c $< -o $@
run: all
./$(EXE) $(INPUTFILE)
run_debug: debug
./$(EXE) $(INPUTFILE)
# in the future this could be generalized to go through every file in "Tests"
rand_test: $(PROJECT_DIR)/Tests/randtest.cpp $(PROJECT_DIR)/Common/Distribution.cpp
$(CXX) -pthread -std=c++17 $^ -o [email protected]
TESTS = check-version rand_test test_Example test_Bitcoin test_Ethereum test_PBFT test_Raft test_SmartShards test_LinearChord test_Kademlia test_AltBit test_StableDataLink test_ChangRoberts test_Dynamic test_KPT test_KSM
############################### Compile and run all tests - uses a wild card.
test: $(TESTS)
@make --no-print-directory clean
@echo all tests successful
test_%: ALGFILE = $*Peer
test_%: CXXFLAGS += -O0 -g -D_GLIBCXX_DEBUG -std=c++17
test_%:
@make --no-print-directory clean
@echo Testing $(ALGFILE)
@$(CXX) $(CXXFLAGS) -c -o quantas/main.o quantas/main.cpp
@$(CXX) $(CXXFLAGS) -c -o quantas/$(ALGFILE)/$(ALGFILE).o quantas/$(ALGFILE)/$(ALGFILE).cpp
@$(CXX) $(CXXFLAGS) -c -o quantas/Common/Distribution.o quantas/Common/Distribution.cpp
@$(CXX) $(CXXFLAGS) quantas/main.o quantas/$(ALGFILE)/$(ALGFILE).o quantas/Common/Distribution.o -o $(EXE)
@./$(EXE) quantas/$(ALGFILE)/$*Input.json
@$(RM) quantas/$(ALGFILE)/*.o
@echo $(ALGFILE) successful
clean:
@$(RM) *.exe
@$(RM) *.out
@$(RM) *.o
@$(RM) -r *.dSYM
@$(RM) $(PROJECT_DIR)/*.gch
@$(RM) $(PROJECT_DIR)/*.tmp
@$(RM) $(PROJECT_DIR)/*.o
@$(RM) $(PROJECT_DIR)/*.d
@$(RM) $(PROJECT_DIR)/Common/*.gch
@$(RM) $(PROJECT_DIR)/Common/*.tmp
@$(RM) $(PROJECT_DIR)/Common/*.o
@$(RM) $(PROJECT_DIR)/Common/*.d
@$(RM) $(PROJECT_DIR)/$(ALGFILE)/*.gch
@$(RM) $(PROJECT_DIR)/$(ALGFILE)/*.tmp
@$(RM) $(PROJECT_DIR)/$(ALGFILE)/*.o
@$(RM) $(PROJECT_DIR)/$(ALGFILE)/*.d
@$(RM) quantas_test/*.gch
@$(RM) quantas_test/*.tmp
@$(RM) quantas_test/*.o
@$(RM) quantas_test/*.d
# enables recursive glob patterns for bash
cleanRec: SHELL := /bin/bash -O globstar
cleanRec:
@$(RM) **/*.out
@$(RM) **/*.o
@$(RM) **/*.d
@$(RM) **/*.dSYM
@$(RM) **/*.gch
@$(RM) **/*.tmp
@$(RM) **/*.exe
-include $(OBJS:.o=.d)