-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile
253 lines (214 loc) · 4.75 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# powturbo (c) Copyright 2013-2023
# Download or clone TurboRC:
# git clone git://github.com/powturbo/Turbo-Range-Coder.git
# fsm predictor
#SF=1
# include BWT
BWT=1
#BWTDIV=1
LIBSAIS16=1
#V8
#BWTSATAN=1
ANS=1
#EXT=1
#NOCOMP=1
#AVX2=1
#NZ=1
#SF=1
#TURBORLE=1
TRANSPOSE=1
#----------------------------------------------
CC ?= gcc
CXX ?= g++
#CC=clang
#CXX=clang++
#CC=powerpc64le-linux-gnu-gcc
#CL = $(CC)
#DEBUG=-DDEBUG -g
DEBUG=-DNDEBUG -s
PREFIX ?= /usr/local
DIRBIN ?= $(PREFIX)/bin
DIRINC ?= $(PREFIX)/include
DIRLIB ?= $(PREFIX)/lib
OPT=-fstrict-aliasing
ifeq (,$(findstring clang, $(CC)))
OPT+=-falign-loops
endif
#------- OS/ARCH -------------------
ifneq (,$(filter Windows%,$(OS)))
OS := Windows
CC=gcc
CXX=g++
# CC=clang
ARCH=x86_64
LDFLAGS=-Wl,--stack,33554432
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)
_SSE=-D__SSSE3__
MARCH=-mcpu=power9 -mtune=power9 $(_SSE)
CFLAGS+=-D_NAVX2 -D_NSCALAR
else ifeq ($(ARCH),aarch64)
MARCH=-march=armv8-a
CFLAGS+=-D_NAVX2 -D_NSCALAR
ifneq (,$(findstring clang, $(CC)))
OPT+=-fomit-frame-pointer
#-fmacro-backtrace-limit=0
endif
_SSE=-march=armv8-a
else ifeq ($(ARCH),$(filter $(ARCH),x86_64))
_SCALAR=-mno-sse2
# set minimum arch sandy bridge SSE4.1 + AVX
_SSE=-march=corei7-avx -mtune=corei7-avx
# _SSE+=-mno-avx -mno-aes
_AVX2=-march=haswell
endif
ifeq ($(AVX2),1)
MARCH=$(_AVX2)
else
MARCH=$(_SSE)
endif
CFLAGS+= $(DEBUG) $(OPT) -w -Wall
#-pedantic
ifeq ($(PGO), 1)
CFLAGS+=-fprofile-generate
LDFLAGS+=-lgcov
else ifeq ($(PGO), 2)
CFLAGS+=-fprofile-use
endif
ifeq ($(OS),$(filter $(OS),Darwin Linux GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly NetBSD MSYS_NT Haiku))
#LDFLAGS+=-lrt
LDFLAGS+=-lm
#-Wl,--stack_size -Wl,20971520
endif
ifeq ($(EXTRC), 1)
CFLAGS+=-DEXTRC
endif
ifeq ($(STATIC),1)
LDFLAGS+=-static
endif
#-------- bwt --------------------------
ifeq ($(BWTSATAN), 1)
CFLAGS+=-D_BWTSATAN
BWT=1
endif
ifeq ($(BWT), 1)
CFLAGS+=-D_BWT
ifeq ($(BWTDIV), 1)
CFLAGS+=-DPROJECT_VERSION_FULL="20137" -DINLINE=inline -Ilibdivsufsort/include -Ilibdivsufsort/build/include
CFLAGS+=-D_BWTDIV
LIBBWT+=libdivsufsort/unbwt.o
ifeq ($(NOCOMP), 1)
else
LIBBWT+=libdivsufsort/lib/sssort.o libdivsufsort/lib/utils.o libdivsufsort/lib/daware.o
LIBBWT+=libdivsufsort/lib/divsufsort.o
endif
else
ifeq ($(BWTX), 1)
LIBBWT =../bwt/sssort.o ../bwt/bwtxinv.o ../bwt/divsufsort.o ../bwt/trsort.o
CFLAGS+=-D_BWTX
else
CFLAGS+=-D_LIBSAIS -Ilibsais/include
LIBBWT+=$(B)libsais/src/libsais.o
ifeq ($(LIBSAIS16), 1)
CFLAGS+=-D_LIBSAIS16
LIBBWT+=$(B)libsais/src/libsais16.o
endif
endif
endif
endif
all: turborc
ifneq ($(NOCOMP), 1)
LIB=rc_ss.o rc_s.o rccdf.o rcutil.o bec_b.o rccm_s.o rccm_ss.o rcqlfc_s.o rcqlfc_ss.o rcqlfc_sf.o
#ifeq ($(DELTA), 1)
#CFLAGS+=-D_DELTA
#LIB+=transform.o
#endif
ifeq ($(ANS), 1)
CFLAGS+=-D_ANS
L=./
$(L)anscdf0.o: $(L)anscdf.c $(L)anscdf_.h
$(CC) -c -O3 $(CFLAGS) $(_SCALAR) -falign-loops=32 $(L)anscdf.c -o $(L)anscdf0.o
$(L)anscdfs.o: $(L)anscdf.c $(L)anscdf_.h
$(CC) -c -O3 $(CFLAGS) $(_SSE) -falign-loops=32 $(L)anscdf.c -o $(L)anscdfs.o
LIB+=$(L)anscdfs.o
ifeq ($(ARCH), x86_64)
$(L)anscdfx.o: $(L)anscdf.c $(L)anscdf_.h
$(CC) -c -O3 $(CFLAGS) -march=haswell -falign-loops=32 $(L)anscdf.c -o $(L)anscdfx.o
LIB+=$(L)anscdfx.o
#$(L)anscdf0.o
endif
endif
ifeq ($(TURBORLE), 1)
CFLAGS+=-D_TURBORLE
LIB+=trlec.o trled.o
endif
ifeq ($(TRANSPOSE), 1)
transpose_avx2.o: transpose.c
$(CC) -O3 -w -mavx2 $(OPT) -c transpose.c -o transpose_avx2.o
CFLAGS+=-D_TRANSPOSE -D_NCPUISA
LIB+=transpose.o transpose_.o
ifeq ($(ARCH), x86_64)
LIB+=transpose_avx2.o
endif
endif
ifeq ($(V8), 1)
CFLAGS+=-D_V8
LIB+=v8.o
endif
#trlec.o trled.o $(L)anscdfx.o $(L)anscdfs.o $(L)anscdf0.o
endif
ifeq ($(BWT), 1)
LIB+=rcbwt.o
endif
ifeq ($(SF), 1)
CFLAGS+=-D_SF
LIB+=rc_sf.o rccm_sf.o rcqlfc_sf.o
endif
ifeq ($(NZ), 1)
LIB+=rc_nz.o rccm_nz.o rcqlfc_nz.o
CFLAGS+=-D_NZ
endif
ifeq ($(SH), 1)
LIB+=rc_sh.o
CFLAGS+=-D_SH
endif
ifeq ($(EXT), 1)
CFLAGS+=-D_EXT
#LIB+=xrc.o
ifeq ($(BWT), 1)
#LIB+=xrcbwt_sf.o
endif
endif
ifeq ($(NOCOMP), 1)
CFLAGS+=-DNO_COMP
endif
#librc.a: $(LIB)
# ar cr $@ $+
turborc.o: turborc.c
$(CC) -O3 $(CFLAGS) $(MARCH) -c turborc.c -o turborc.o
turborc: $(LIB) $(LIBBWT) turborc.o
$(CC) $^ $(LDFLAGS) -o turborc
reorder: $(LIBDIV) reorder.o
$(CC) $^ $(LDFLAGS) -o reorder
.c.o:
$(CC) -O3 $(CFLAGS) $(MARCH) $< -c -o $@
.cpp.o:
$(CXX) -O3 $(MARCH) $(CXXFLAGS) $< -c -o $@
ifeq ($(OS),Windows_NT)
clean:
del /S *.o
del /S *~
else
clean:
@find . -type f -name "*\.o" -delete -or -name "*\~" -delete -or -name "core" -delete -or -name "turborc" -delete -or -name "librc.a" -delete
endif