-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
94 lines (75 loc) · 2.2 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
#### Makefile for compilation on Linux ####
OPT=-O3 # Optimization option by default
ifeq "$(CC)" "gcc"
COMPILER=gcc
else ifeq "$(CC)" "clang"
COMPILER=clang
endif
ifeq "$(ARCH)" "x64"
ARCHITECTURE=_AMD64_
else ifeq "$(ARCH)" "x86"
ARCHITECTURE=_X86_
else ifeq "$(ARCH)" "ARM"
ARCHITECTURE=_ARM_
endif
ADDITIONAL_SETTINGS=
ifeq "$(SET)" "EXTENDED"
ADDITIONAL_SETTINGS=-fwrapv -fomit-frame-pointer -march=native
endif
ifeq "$(ASM)" "TRUE"
USE_ASM=-D _ASM_
endif
ifeq "$(GENERIC)" "TRUE"
USE_GENERIC=-D _GENERIC_
endif
ifeq "$(AVX2)" "TRUE"
USE_AVX2=-D _AVX2_
SIMD=-mavx2
endif
ifeq "$(ARCH)" "ARM"
ARM_SETTING=-lrt
endif
cc=$(COMPILER)
CFLAGS=-c $(OPT) $(ADDITIONAL_SETTINGS) $(SIMD) -D $(ARCHITECTURE) -D __LINUX__ $(USE_AVX2) $(USE_ASM) $(USE_GENERIC)
LDFLAGS=
ifeq "$(GENERIC)" "TRUE"
OTHER_OBJECTS=ntt.o
else
ifeq "$(ASM)" "TRUE"
OTHER_OBJECTS=ntt_x64.o consts.o
ASM_OBJECTS=ntt_x64_asm.o error_asm.o
endif
endif
OBJECTS=kex.o random.o ntt_constants.o $(ASM_OBJECTS) $(OTHER_OBJECTS)
OBJECTS_TEST=tests.o test_extras.o $(OBJECTS)
OBJECTS_ALL=$(OBJECTS) $(OBJECTS_TEST)
test: $(OBJECTS_TEST)
$(CC) -o test $(OBJECTS_TEST) $(ARM_SETTING)
kex.o: kex.c LatticeCrypto_priv.h
$(CC) $(CFLAGS) kex.c
random.o: random.c LatticeCrypto_priv.h
$(CC) $(CFLAGS) random.c
ntt_constants.o: ntt_constants.c LatticeCrypto_priv.h
$(CC) $(CFLAGS) ntt_constants.c
ifeq "$(GENERIC)" "TRUE"
ntt.o: generic/ntt.c LatticeCrypto_priv.h
$(CC) $(CFLAGS) generic/ntt.c
else
ifeq "$(ASM)" "TRUE"
ntt_x64.o: AMD64/ntt_x64.c
$(CC) $(CFLAGS) AMD64/ntt_x64.c
ntt_x64_asm.o: AMD64/ntt_x64_asm.S
$(CC) $(CFLAGS) AMD64/ntt_x64_asm.S
error_asm.o: AMD64/error_asm.S
$(CC) $(CFLAGS) AMD64/error_asm.S
consts.o: AMD64/consts.c
$(CC) $(CFLAGS) AMD64/consts.c
endif
endif
test_extras.o: tests/test_extras.c tests/test_extras.h LatticeCrypto_priv.h
$(CC) $(CFLAGS) tests/test_extras.c
tests.o: tests/tests.c LatticeCrypto_priv.h
$(CC) $(CFLAGS) tests/tests.c
.PHONY: clean
clean:
rm -f test ntt.o ntt_x64.o ntt_x64_asm.o error_asm.o consts.o $(OBJECTS_ALL)