-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
91 lines (73 loc) · 2.5 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
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:=
ifeq ($(VERSION), portable)
COMPILATION_MSG="compiling portable version"
DFLAGS:=-D USE_CXX_AES
else ifeq ($(VERSION), aesni)
COMPILATION_MSG="compiling AES-NI version"
DFLAGS:=-D USE_INTEL_AESNI -maes
else ifeq ($(VERSION), neon)
COMPILATION_MSG="compiling AES aarch64 neon version"
DFLAGS:=-D USE_NEON_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 "Recipes : test"
@echo "CXX : g++, clang++"
@echo "TYPE : release, debug"
@echo "VERSION : portable, aesni, neon"
@echo "LINK : dynamic, static"
@echo ""
test:
$(CXX) $(CXX_STANDARD) $(LINKER) tests.cpp -o tests.out $(DFLAGS) $(CXX_FLAGS)
./tests.out
clean:
@rm tests.out microbench.out
clean-cmake:
rm -r tests Makefile CMakeFiles cmake_install.cmake CMakeCache.txt
style:
@clang-format -i -style=file *.cpp *.hpp
microbenchmark:
$(CXX) $(CXX_STANDARD) $(LINKER) microbench.cpp -o microbench1.out -O3 -D USE_CXX_AES
$(CXX) $(CXX_STANDARD) $(LINKER) microbench.cpp -o microbench2.out -O3 -D USE_INTEL_AESNI -maes
@echo "Running micro-benchmarks"
@echo ""
@echo "# **micro-benchmark**" > micro-benchmark.md
@echo "" >> micro-benchmark.md
@echo "Pure C++ Implementation" >> micro-benchmark.md
@echo "| AES Operation | key bits | Duration | Megabytes |" >> micro-benchmark.md
@echo "| --- | --- | --- | --- |" >> micro-benchmark.md
@./microbench1.out >> micro-benchmark.md
@echo "" >> micro-benchmark.md
@echo "AES-NI (Hardware Accelerated)" >> micro-benchmark.md
@echo "| AES Operation | key bits | Duration | Megabytes |" >> micro-benchmark.md
@echo "| --- | --- | --- | --- |" >> micro-benchmark.md
@./microbench2.out >> micro-benchmark.md
@echo "" >> micro-benchmark.md