forked from ClickHouse/Turbo-Base64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
133 lines (104 loc) · 3 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
# powturbo (c) Copyright 2016-2019
# Linux: "export CC=clang" "export CXX=clang". windows mingw: "set CC=gcc" "set CXX=g++" or uncomment the CC,CXX lines
CC ?= gcc
CXX ?= g++
#CC=powerpc64le-linux-gnu-gcc
#DEBUG=-DDEBUG -g
#DEFS=$(DEBUG)
#CFLAGS=$(DEBUG)
#------- OS/ARCH -------------------
ifneq (,$(filter Windows%,$(OS)))
OS := Windows
CC=gcc
CXX=g++
ARCH=x86_64
else
OS := $(shell uname -s)
ARCH := $(shell uname -m)
ifneq (,$(findstring aarch64,$(CC)))
ARCH = aarch64
else ifneq (,$(findstring powerpc64le,$(CC)))
ARCH = ppc64le
endif
endif
ifeq ($(ARCH),ppc64le)
CFLAGS=-mcpu=power9 -mtune=power9
MSSE=-D__SSSE3__
else ifeq ($(ARCH),aarch64)
CFLAGS+=-march=armv8-a
ifneq (,$(findstring clang, $(CC)))
CFLAGS+=-march=armv8-a -falign-loops -fomit-frame-pointer
else
CFLAGS+=-march=armv8-a
endif
MSSE=-march=armv8-a
else ifeq ($(ARCH),$(filter $(ARCH),x86_64 ppc64le))
CFLAGS=-march=native
MSSE=-mssse3
endif
ifeq (,$(findstring clang, $(CC)))
DEFS+=-falign-loops
endif
#$(info ARCH="$(ARCH)")
ifeq ($(OS),$(filter $(OS),Linux GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly NetBSD MSYS_NT Haiku))
LDFLAGS+=-lrt
endif
ifeq ($(STATIC),1)
LDFLAGS+=-static
endif
#FPIC=-fPIC
all: tb64app
#libtb64.so
ifeq ($(NCHECK),1)
DEFS+=-DNB64CHECK
else
ifeq ($(FULLCHECK),1)
DEFS+=-DB64CHECK
endif
endif
turbob64c.o: turbob64c.c
$(CC) -O3 $(MARCH) $(DEFS) $(FPIC) -fstrict-aliasing $< -c -o $@
tb64app.o: tb64app.c
$(CC) -O3 $(DEFS) $< -c -o $@
turbob64d.o: turbob64d.c
$(CC) -O3 $(MARCH) $(DEFS) $(FPIC) -fstrict-aliasing $< -c -o $@
turbob64sse.o: turbob64sse.c
$(CC) -O3 $(MSSE) $(DEFS) $(FPIC) -fstrict-aliasing $< -c -o $@
turbob64avx.o: turbob64sse.c
$(CC) -O3 $(DEFS) $(FPIC) -march=corei7-avx -mtune=corei7-avx -mno-aes -fstrict-aliasing $< -c -o turbob64avx.o
turbob64avx2.o: turbob64avx2.c
$(CC) -O3 $(FPIC) $(DEFS) -march=haswell -fstrict-aliasing -falign-loops $< -c -o $@
turbob64avx512.o: turbob64avx512.c
$(CC) -O3 $(FPIC) -march=skylake-avx512 -mavx512vl -fstrict-aliasing -falign-loops $< -c -o $@
_tb64.o: _tb64.c
$(CC) -O3 $(FPIC) -I/usr/include/python2.7 $< -c -o $@
LIB=turbob64c.o turbob64d.o turbob64sse.o
ifeq ($(ARCH),x86_64)
LIB+=turbob64avx.o turbob64avx2.o
endif
ifeq ($(BASE64),1)
include xtb64make
endif
ifeq ($(AVX512),1)
DEFS+=-DUSE_AVX512
LIB+=turbob64avx512.o
endif
#_tb64.so: _tb64.o
# gcc -shared $^ -o $@
libtb64.so: $(LIB)
gcc -shared $^ -o $@
cp libtb64.so ~/.local/lib/
./python/tb64/build.py
cp _tb64.so ~/.local/lib/
tb64app: $(LIB) tb64app.o
$(CC) -O3 $(LIB) tb64app.o $(LDFLAGS) -o tb64app
tb64bench: $(LIB) tb64bench.o
$(CC) -O3 $(LIB) tb64bench.o $(LDFLAGS) -o tb64bench
tb64test: $(LIB) tb64test.o
$(CC) -O3 $(LIB) tb64test.o $(LDFLAGS) -o tb64test
.c.o:
$(CC) -O3 $(CFLAGS) $(MARCH) $< -c -o $@
clean:
@find . -type f -name "*\.o" -delete -or -name "*\~" -delete -or -name "core" -delete -or -name "tb64app" -delete -or -name "_tb64.so" -delete -or -name "_tb64.c" -delete -or -name "xlibtb64.so" -delete -or -name "libtb64.a"
cleanw:
del /S *.o