-
Notifications
You must be signed in to change notification settings - Fork 41
/
makefile
153 lines (126 loc) · 3.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
# powturbo (c) Copyright 2016-2023
# 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=aarch64-linux-gnu-gcc
#CC=powerpc64le-linux-gnu-gcc
# uncomment to disable checking for more faster decoding
#NCHECK=1
#uncomment for full base64 checking (default=partial checking, detect allmost all errors)
#FULLCHECK=1
#uncomment for use memcpy instead of unaligned loads
#UAMEMCPY=1
#NAVX512=1
#NAVX2=1
#NSSE=1
#NAVX=1
#RDTSC=1
#XBASE64=1
#CFLAGS+=-DDEBUG -g
CFLAGS+=-DNDEBUG
#------- OS/ARCH -------------------
ifneq (,$(filter Windows%,$(OS)))
OS := Windows
ARCH=x86_64
else
OS := $(shell uname -s)
ARCH := $(shell uname -m)
ifneq (,$(findstring aarch64,$(CC)))
ARCH = aarch64
else ifneq (,$(findstring arm64,$(ARCH)))
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+=-fomit-frame-pointer
endif
MSSE=-march=armv8-a
else ifeq ($(ARCH),$(filter $(ARCH),x86_64 ppc64le))
MSSE=-mssse3
endif
ifeq (,$(findstring clang, $(CC)))
CFLAGS+=-falign-loops
endif
#---------------------------------------------------
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
ifeq ($(NCHECK),1)
DEFS+=-DNB64CHECK
else
ifeq ($(FULLCHECK),1)
DEFS+=-DB64CHECK
endif
endif
ifeq ($(RDTSC),1)
DEFS+=-D_RDTSC
endif
ifeq ($(UAMEMCPY),1)
DEFS+=-DUA_MEMCPY
endif
ifeq ($(XBASE64),1)
include xtb64.mak
endif
all: tb64app libtb64.so libtb64.a
tb64app.o: CFLAGS+=$(XDEFS) $(MARCH)
turbob64c.o: CFLAGS+=$(DEFS) $(FPIC) -fstrict-aliasing $(MARCH)
turbob64d.o: CFLAGS+=$(DEFS) $(FPIC) -fstrict-aliasing $(MARCH)
turbob64v128.o: CFLAGS+=$(DEFS) $(FPIC) -fstrict-aliasing $(MSSE)
turbob64v256.o: CFLAGS+=$(DEFS) $(FPIC) -fstrict-aliasing -march=haswell
turbob64v512.o: CFLAGS+=$(DEFS) $(FPIC) -fstrict-aliasing -march=skylake-avx512 -mavx512vbmi
turbob64v128a.o: turbob64v128.c
$(CC) -O3 $(CFLAGS) $(DEFS) $(FPIC) -fstrict-aliasing -march=corei7-avx -mtune=corei7-avx -mno-aes $< -c -o turbob64v128a.o
#_tb64.o: _tb64.c
# $(CC) -O3 $(FPIC) -I/usr/include/python2.7 $< -c -o $@
LIB=turbob64c.o turbob64d.o turbob64v128.o
ifeq ($(ARCH),x86_64)
LIB+=turbob64v128a.o turbob64v256.o
ifneq ($(NAVX512),1)
LIB+=turbob64v512.o
else
DEFS+=-DNAVX512
endif
endif
#_tb64.so: _tb64.o
# $(CC) -shared $^ -o $@
libtb64.a: $(LIB)
ar cr $@ $+
libtb64.so: $(LIB)
$(CC) -shared $^ -o $@
install:
cp libtb64.so ~/.local/lib/
cp libtb64.a ~/.local/lib/
# FIXME: how does one build _tb64.so?
# ./python/tb64/build.py
# cp _tb64.so ~/.local/lib/
tb64app: $(LIB) $(XLIB) tb64app.o
$(CC) -O3 $(LIB) $(XLIB) $(XDEFS) 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) $< -c -o $@
.cc.o:
$(CXX) -O3 $(CXXFLAGS) $< -c -o $@
ifeq ($(OS),Windows)
clean:
del /S *.o
del *.a
del *.so
else
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" -delete -or -name "libtb64.so"
endif