forked from SergeyBel/AES
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (101 loc) · 3.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
OS := $(shell uname)
CXX=g++
CXX_STANDARD=-std=c++17
########################## link ##########################
LINK=dynamic
ifeq ($(LINK), dynamic)
LINKER=
else ifeq ($(LINK), static)
LINKER=-static
endif
########################## sanitizer ##########################
ifeq ($(CXX), clang++)
ADDRESS_SANITIZER=-fsanitize=address
THREADS_SANITIZER=-fsanitize=thread
else
ADDRESS_SANITIZER=
THREADS_SANITIZER=
endif
########################## version ##########################
VERSION=portable
ifeq ($(VERSION), portable)
COMPILATION_MSG="compiling portable version"
DFLAGS=
else ifeq ($(VERSION), aesni)
COMPILATION_MSG="compiling AES-NI version"
DFLAGS=-DUSE_AESNI -maes
else ifeq ($(VERSION), neon)
COMPILATION_MSG="compiling AES aarch64 neon version"
DFLAGS=-DUSE_ARM_AES -march=armv8-a+crypto
endif
########################## type ##########################
TYPE=release
ifeq ($(TYPE), release)
CXX_FLAGS=-O3 -Wall -Wextra
else ifeq ($(TYPE), debug)
CXX_FLAGS=-O2 -Wall -Wextra $(ADDRESS_SANITIZER)
endif
########################## CLASSIC MAKEFILE ##########################
default:
@echo "Makefile variables and possible values"
@echo "The the first element are always the default value"
@echo "CXX : g++, clang++"
@echo "TYPE : release, debug"
@echo "VERSION : portable, aesni, neon"
@echo "LINK : dynamic, static"
@echo ""
@echo "Makefile recipes"
bench:
@echo "compiling benchmark : START"
@$(CXX) tests/benchmark.cpp -o bin/benchmark.out -O3
@$(CXX) tests/benchmark.cpp -o bin/benchmark-aesni.out -DUSE_AESNI -maes -O3
@echo "compiling benchmark : DONE"
@echo "# Benchmark" > docs/benchmarks/benchmark-$(CXX).md
@echo "" >> docs/benchmarks/benchmark-$(CXX).md
@echo "Compiler : $(CXX)" >> docs/benchmarks/benchmark-$(CXX).md
@echo "running benchmark : START"
@echo "" >> docs/benchmarks/benchmark-$(CXX).md
@echo "## Pure C++" >> docs/benchmarks/benchmark-$(CXX).md
@echo "" >> docs/benchmarks/benchmark-$(CXX).md
@echo "| Block Cipher | Mode | MB | Seconds | Speed | Result |" >> docs/benchmarks/benchmark-$(CXX).md
@echo "| ------------ | ---- | -- | ------- | ----- | ------ |" >> docs/benchmarks/benchmark-$(CXX).md
@./bin/benchmark.out >> docs/benchmarks/benchmark-$(CXX).md
@echo "" >> docs/benchmarks/benchmark-$(CXX).md
@echo "## AES-NI" >> docs/benchmarks/benchmark-$(CXX).md
@echo "" >> docs/benchmarks/benchmark-$(CXX).md
@echo "| Block Cipher | Mode | MB | Seconds | Speed | Result |" >> docs/benchmarks/benchmark-$(CXX).md
@echo "| ------------ | ---- | -- | ------- | ----- | ------ |" >> docs/benchmarks/benchmark-$(CXX).md
@./bin/benchmark-aesni.out >> docs/benchmarks/benchmark-$(CXX).md
@echo "running benchmark : DONE"
compile:
$(CXX) $(LINKER) $(CXX_STANDARD) tests/byte_array.cpp -o bin/byte_array.out $(DFLAGS) $(ADDRESS_SANITIZER) $(CXX_FLAGS)
$(CXX) $(LINKER) $(CXX_STANDARD) tests/testvectors.cpp -o bin/test.out $(DFLAGS) $(ADDRESS_SANITIZER) $(CXX_FLAGS)
test_portable:
@echo "Compiling portable version"
$(MAKE) compile TYPE=debug VERSION=portable
@echo "Running portable test"
$(MAKE) run_test
test_aesni:
@echo "Compiling aesni version"
$(MAKE) compile TYPE=debug VERSION=aesni
@echo "Running aesni test"
$(MAKE) run_test
test_neon:
@echo "Compiling neon version"
$(MAKE) compile TYPE=debug VERSION=neon
@echo "Running neon test"
$(MAKE) run_test
run_test:
./bin/test.out
./bin/byte_array.out
run_debug:
./bin/debug.out
run_profile:
./bin/profile.out
run_release:
./bin/release.out
run_clean:
rm -rf bin
mkdir bin -p
style:
@clang-format -i -style=file *.cpp *.hpp tests/*.hpp tests/*.cpp src/*.hpp src/*.cpp src/mode/*.hpp src/mode/*.cpp src/padding/*.hpp src/padding/*.cpp src/blockcipher/AES/*.hpp src/blockcipher/AES/*.cpp