-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
423 lines (338 loc) · 12.6 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
all: bkc satc satc_dump satc_undump satc_filter satc_to_fasta satc_merge sig_anch read_selector compactors download_kmc lookup_table splash supervised_test dsv_manip gap_shortener fafq_filter tsv_to_fasta
dummy := $(shell git submodule update --init --recursive)
SPLASH_LIBS_DIR = libs
LIBS_DIR = . #/usr/local/lib
INCLUDE_DIR= libs
ZLIB_INCLUDE_DIR = libs/zlib-ng/build-g++
ZLIB_INCLUDE_DIR_FOR_FILE_WRAPPER = libs/zlib-ng/build-g++/zlib-ng
ZSTD_INCLUDE_DIR = libs/zstd/lib
LIBDEFLATE_INCLUDE_DIR = libs/libdeflate
ISAL_INCLUDE_DIR = libs/isa-l/include
MIMALLOC_INLUCDE_DIR = libs/mimalloc/include
SATC_MAIN_DIR=src/satc
SATC_MERGE_MAIN_DIR=src/satc_merge
SATC_DUMP_MAIN_DIR=src/satc_dump
SATC_UNDUMP_MAIN_DIR=src/satc_undump
SATC_FILTER_MAIN_DIR=src/satc_filter
SATC_TO_FASTA_MAIN_DIR=src/satc_to_fasta
SIG_ANCH_MAIN_DIR=src/sig_anch
LOOKUP_TABLE_MAIN_DIR=src/lookup_table
DSV_MANIP_MAIN_DIR=src/dsv_manip
GAP_SHORTENER_MAIN_DIR=src/gap_shortener
FAFQ_FILTER_MAIN_DIR=src/fafq_filter
TSV_TO_FASTA_MAIN_DIR=src/tsv_to_fasta
COMMON_DIR=src/common
READ_SELECTOR_MAIN_DIR=src/read_selector
COMPACTORS_MAIN_DIR=src/compactors
OUT_BIN_DIR=bin
MIMALLOC_OBJ=libs/mimalloc/mimalloc.o
# Check if the selected C/C++ compilers are GNU gcc/g++
CXX_VERSION := $(shell $(CXX) --version 2>/dev/null | grep 'g++')
CC_VERSION := $(shell $(CC) --version 2>/dev/null | grep 'gcc')
#This is mainly for MAC OS, lets try to get some installeg g++
ifeq ($(CXX_VERSION),)
CXX := $(shell basename $$(which g++-14 || which g++-13 || which g++-12 || which g++-11 || which g++-10 || which g++-9 || echo "g++"))
CXX_VERSION := $(shell $(CXX) --version 2>/dev/null | grep 'g++')
endif
ifeq ($(CC_VERSION),)
CC := $(shell basename $$(which gcc-14 || which gcc-13 || which gcc-12 || which gcc-11 || which gcc-10 || which gcc-9 || echo "gcc"))
CC_VERSION := $(shell $(CC) --version 2>/dev/null | grep 'gcc')
endif
ifeq ($(CXX_VERSION),)
WRONG_CXX_OR_CC = yes
endif
ifeq ($(CC_VERSION),)
WRONG_CXX_OR_CC = yes
endif
ifdef WRONG_CXX_OR_CC
$(error The selected C++ compiler ($(CXX)) or C compiler ($(CC)) is not GNU g++/gcc. Please specify a GNU g++/gcc compiler. If you are using MACOS you may get one with brew (https://brew.sh/), and after installing run make CC=gcc-<version> CXX=g++-<version>)
endif
ifdef MSVC # Avoid the MingW/Cygwin sections
UNAME_S := Windows
else # If uname not available => 'not'
UNAME_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
UNAME_M := $(shell uname -m)
endif
D_OS =
D_ARCH =
ifeq ($(UNAME_S),Darwin)
D_OS=MACOS
ifeq ($(UNAME_M),arm64)
D_ARCH=ARM64
else
D_ARCH=X64
endif
else
D_OS=LINUX
D_ARCH=X64
ifeq ($(UNAME_M),arm64)
D_ARCH=ARM64
endif
ifeq ($(UNAME_M),aarch64)
D_ARCH=ARM64
endif
endif
ifeq ($(D_ARCH),X64)
dummy_install_nasm := $(shell \
if [ ! -f build_tools/nasm/nasm ]; then \
cd build_tools/nasm && ./autogen.sh && ./configure && make -j; \
fi)
endif
NASM_V := $(shell build_tools/nasm/nasm --version 2>/dev/null)
CMAKE_OSX_SYSROOT_FLAG =
ifeq ($(UNAME_S),Darwin)
SDK_PATH := $(shell $(CXX) -v 2>&1 | grep -- '--with-sysroot' | sed -E 's/.*--with-sysroot=([^ ]+).*/\1/')
CMAKE_OSX_SYSROOT_FLAG := -DCMAKE_OSX_SYSROOT=$(SDK_PATH)
endif
CPU_FLAGS =
STATIC_LFLAGS =
PLATFORM_SPECIFIC_FLAGS =
#in some cases we can have different results on ARM
#I guess this is exactly the same as here: https://bugs.mysql.com/bug.php?id=82760
ifeq ($(D_ARCH),ARM64)
PLATFORM_SPECIFIC_FLAGS = -ffp-contract=off
endif
ifeq ($(D_OS),MACOS)
ifeq ($(D_ARCH),ARM64)
CPU_FLAGS = -march=armv8.4-a
else
CPU_FLAGS = -m64
endif
STATIC_LFLAGS = -static-libgcc -static-libstdc++ -pthread
else
ifeq ($(D_ARCH),ARM64)
CPU_FLAGS = -march=armv8-a
STATIC_LFLAGS = -static-libgcc -static-libstdc++ -lpthread
else
CPU_FLAGS = -m64
STATIC_LFLAGS = -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
endif
endif
LIB_ZLIB=$(SPLASH_LIBS_DIR)/zlib-ng/build-g++/zlib-ng/libz.a
LIB_ISAL=$(SPLASH_LIBS_DIR)/isa-l/bin/isa-l.a
LIB_ZSTD=$(SPLASH_LIBS_DIR)/zstd/lib/libzstd.a
LIB_LIBDEFLATE=$(SPLASH_LIBS_DIR)/libdeflate/build/libdeflate.a
LIB_GZ=$(LIB_ZLIB)
REFRESH_FLAGS =
ifeq ($(UNAME_S),Linux)
ifeq ($(UNAME_M),x86_64)
REFRESH_FLAGS +=-DARCH_X64
ifdef NASM_V
LIB_GZ=$(LIB_ISAL)
REFRESH_FLAGS += -DREFRESH_USE_IGZIP -I $(ISAL_INCLUDE_DIR)
else
REFRESH_FLAGS +=-DREFRESH_USE_ZLIB
endif
else
REFRESH_FLAGS +=-DREFRESH_USE_ZLIB
endif
else
REFRESH_FLAGS +=-DREFRESH_USE_ZLIB
endif
CFLAGS = -fPIC -Wall -O3 $(PLATFORM_SPECIFIC_FLAGS) $(CPU_FLAGS) $(REFRESH_FLAGS) -std=c++17 -pthread -I $(ZLIB_INCLUDE_DIR) -I $(ZLIB_INCLUDE_DIR_FOR_FILE_WRAPPER) -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -I $(ZSTD_INCLUDE_DIR) -I $(LIBDEFLATE_INCLUDE_DIR) -fpermissive
CLINK = -lm -std=c++17 -lpthread
release: CLINK = -lm -std=c++17 $(STATIC_LFLAGS)
release: CFLAGS = -fPIC -Wall -O3 -DNDEBUG $(PLATFORM_SPECIFIC_FLAGS) $(CPU_FLAGS) $(REFRESH_FLAGS) -std=c++17 -pthread -I $(ZLIB_INCLUDE_DIR) -I $(ZLIB_INCLUDE_DIR_FOR_FILE_WRAPPER) -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -I $(ZSTD_INCLUDE_DIR) -I $(LIBDEFLATE_INCLUDE_DIR) -fpermissive
#release: satc_undump satc_filter satc_to_fasta fafq_filter
release: all
debug: CFLAGS = -fPIC -Wall -O0 -g $(PLATFORM_SPECIFIC_FLAGS) $(CPU_FLAGS) $(REFRESH_FLAGS) -std=c++17 -pthread -I $(ZLIB_INCLUDE_DIR) -I $(ZLIB_INCLUDE_DIR_FOR_FILE_WRAPPER) -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -I $(ZSTD_INCLUDE_DIR) -I $(LIBDEFLATE_INCLUDE_DIR) -fpermissive
debug: all
ifeq ($(UNAME_S),Linux)
CLINK+=-fabi-version=6
endif
# default install location (binary placed in the /bin folder)
prefix = /usr/local
# optional install location
exec_prefix = $(prefix)
$(LIB_ZLIB):
cd $(SPLASH_LIBS_DIR)/zlib-ng; cmake $(CMAKE_OSX_SYSROOT_FLAG) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_C_COMPILER=$(CC) -B build-g++/zlib-ng -S . -DZLIB_COMPAT=ON; cmake --build build-g++/zlib-ng --config Release --target zlibstatic
$(LIB_ISAL):
cd $(SPLASH_LIBS_DIR)/isa-l && PATH=../../build_tools/nasm:$$PATH make -f Makefile.unx
$(LIB_ZSTD):
cd $(SPLASH_LIBS_DIR)/zstd; make -j
$(LIB_LIBDEFLATE):
cd $(SPLASH_LIBS_DIR)/libdeflate; cmake $(CMAKE_OSX_SYSROOT_FLAG) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_C_COMPILER=$(CC) -B build && cmake --build build
$(MIMALLOC_OBJ):
$(CXX) -DMI_MALLOC_OVERRIDE -O3 -DNDEBUG -fPIC -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden -ftls-model=initial-exec -fno-builtin-malloc -c -I libs/mimalloc/include libs/mimalloc/src/static.c -o $(MIMALLOC_OBJ)
src/lookup_table/%.o: src/lookup_table/%.cpp $(SPLASH_LIBS_DIR)/SBWT/build/external/sdsl-lite/build/lib/libsdsl.a
$(CXX) $(CFLAGS) -I libs/SBWT/include -I libs/SBWT/sdsl-lite/include -I libs/SBWT/SeqIO/include -I libs/SBWT/build/external/sdsl-lite/build/external/libdivsufsort/include/ -c $< -o $@
%.o: %.cpp $(LIB_ZLIB) $(LIB_GZ)
$(CXX) $(CFLAGS) -c $< -o $@
bkc: $(OUT_BIN_DIR)/bkc
$(OUT_BIN_DIR)/bkc:
(cd $(SPLASH_LIBS_DIR)/bkc; make CC=$(CC) CXX=$(CXX) release SHARED_INCLUDE_DIR=../../src/common BKC_OUT_BIN_DIR=../../bin -j)
satc: $(OUT_BIN_DIR)/satc
$(OUT_BIN_DIR)/satc: $(SATC_MAIN_DIR)/satc.o \
$(COMMON_DIR)/kmc_api/kmc_file.o \
$(COMMON_DIR)/kmc_api/mmer.o \
$(COMMON_DIR)/kmc_api/kmer_api.o \
$(LIB_ZSTD)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_ZSTD) \
$(CLINK)
satc_merge: $(OUT_BIN_DIR)/satc_merge
$(OUT_BIN_DIR)/satc_merge: $(SATC_MERGE_MAIN_DIR)/satc_merge.o \
$(SATC_MERGE_MAIN_DIR)/pvals.o \
$(SATC_MERGE_MAIN_DIR)/anchor.o \
$(SATC_MERGE_MAIN_DIR)/extra_stats.o \
$(LIB_LIBDEFLATE) \
$(LIB_ZSTD)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_ZSTD) \
$(LIB_LIBDEFLATE) \
$(CLINK)
satc_dump: $(OUT_BIN_DIR)/satc_dump
$(OUT_BIN_DIR)/satc_dump: $(SATC_DUMP_MAIN_DIR)/satc_dump.o $(LIB_ZSTD)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_LIBDEFLATE) \
$(LIB_ZSTD) \
$(CLINK)
satc_undump: $(OUT_BIN_DIR)/satc_undump
$(OUT_BIN_DIR)/satc_undump: $(SATC_UNDUMP_MAIN_DIR)/satc_undump.o $(LIB_ZSTD)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_ZSTD) \
$(CLINK)
satc_filter: $(OUT_BIN_DIR)/satc_filter
$(OUT_BIN_DIR)/satc_filter: $(SATC_FILTER_MAIN_DIR)/satc_filter.o $(LIB_ZSTD)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_ZSTD) \
$(CLINK)
satc_to_fasta: $(OUT_BIN_DIR)/satc_to_fasta
$(OUT_BIN_DIR)/satc_to_fasta: $(SATC_TO_FASTA_MAIN_DIR)/satc_to_fasta.o $(LIB_ZSTD)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_ZSTD) \
$(CLINK)
tsv_to_fasta: $(OUT_BIN_DIR)/tsv_to_fasta
$(OUT_BIN_DIR)/tsv_to_fasta: $(TSV_TO_FASTA_MAIN_DIR)/tsv_to_fasta.o
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(CLINK)
fafq_filter: $(OUT_BIN_DIR)/fafq_filter
$(OUT_BIN_DIR)/fafq_filter: $(FAFQ_FILTER_MAIN_DIR)/fafq_filter.o \
$(FAFQ_FILTER_MAIN_DIR)/app.o \
$(FAFQ_FILTER_MAIN_DIR)/worker.o \
$(LIB_GZ) \
$(LIB_ZSTD)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_GZ) \
$(LIB_ZSTD) \
$(CLINK)
sig_anch: $(OUT_BIN_DIR)/sig_anch
$(OUT_BIN_DIR)/sig_anch: $(SIG_ANCH_MAIN_DIR)/sig_anch.o \
$(COMMON_DIR)/csv.o
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(CLINK)
read_selector: $(OUT_BIN_DIR)/read_selector
$(OUT_BIN_DIR)/read_selector: $(READ_SELECTOR_MAIN_DIR)/read_selector.o \
$(LIB_ZLIB)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_ZLIB) \
$(CLINK)
compactors: $(OUT_BIN_DIR)/compactors
$(OUT_BIN_DIR)/compactors: $(COMPACTORS_MAIN_DIR)/main.o \
$(COMPACTORS_MAIN_DIR)/console.o \
$(COMPACTORS_MAIN_DIR)/engine.o \
$(COMPACTORS_MAIN_DIR)/io.o \
$(COMPACTORS_MAIN_DIR)/main.o \
$(COMPACTORS_MAIN_DIR)/read_select.o \
$(COMMON_DIR)/edit_distance.o \
$(LIB_ZLIB) \
$(SPLASH_LIBS_DIR)/cdflib/cdflib.o
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(LIB_ZLIB) \
$(CLINK)
$(SPLASH_LIBS_DIR)/SBWT/build/libsbwt_static.a:
(cd $(SPLASH_LIBS_DIR)/SBWT/build; cmake $(CMAKE_OSX_SYSROOT_FLAG) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_C_COMPILER=$(CC) .. -DMAX_KMER_LENGTH=32; make -j)
$(SPLASH_LIBS_DIR)/SBWT/build/external/sdsl-lite/build/lib/libsdsl.a: $(SPLASH_LIBS_DIR)/SBWT/build/libsbwt_static.a
$(SPLASH_LIBS_DIR)/SBWT/build/external/KMC/build/libkmc_core.a: $(SPLASH_LIBS_DIR)/SBWT/build/libsbwt_static.a
$(SPLASH_LIBS_DIR)/SBWT/build/external/KMC/build/libkmc_tools.a: $(SPLASH_LIBS_DIR)/SBWT/build/libsbwt_static.a
lookup_table: $(OUT_BIN_DIR)/lookup_table splash
cp $(LOOKUP_TABLE_MAIN_DIR)/build_lookup_table.py bin/build_lookup_table.py
$(OUT_BIN_DIR)/lookup_table: \
$(MIMALLOC_OBJ) \
$(LOOKUP_TABLE_MAIN_DIR)/lookup_table.o \
$(LOOKUP_TABLE_MAIN_DIR)/lookup.o \
$(LOOKUP_TABLE_MAIN_DIR)/kmer_index_sbwt.o \
$(LOOKUP_TABLE_MAIN_DIR)/build.o \
$(LOOKUP_TABLE_MAIN_DIR)/query.o \
$(LOOKUP_TABLE_MAIN_DIR)/query_many.o \
$(LOOKUP_TABLE_MAIN_DIR)/query_common.o \
$(COMMON_DIR)/kmc_api/kmc_file.o \
$(COMMON_DIR)/kmc_api/mmer.o \
$(COMMON_DIR)/kmc_api/kmer_api.o \
$(SPLASH_LIBS_DIR)/refresh/parallel_queues/lib/parallel-queues-monitor.o \
$(SPLASH_LIBS_DIR)/SBWT/build/libsbwt_static.a \
$(SPLASH_LIBS_DIR)/SBWT/build/external/sdsl-lite/build/lib/libsdsl.a \
$(SPLASH_LIBS_DIR)/SBWT/build/external/KMC/build/libkmc_core.a \
$(SPLASH_LIBS_DIR)/SBWT/build/external/KMC/build/libkmc_tools.a \
$(LIB_ZLIB)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(CLINK)
dsv_manip: $(OUT_BIN_DIR)/dsv_manip
$(OUT_BIN_DIR)/dsv_manip: $(DSV_MANIP_MAIN_DIR)/dsv_manip.o \
$(DSV_MANIP_MAIN_DIR)/dsv_common.o \
$(DSV_MANIP_MAIN_DIR)/limit_mode.o \
$(DSV_MANIP_MAIN_DIR)/sort_mode.o
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(CLINK)
gap_shortener: $(OUT_BIN_DIR)/gap_shortener
$(OUT_BIN_DIR)/gap_shortener: $(GAP_SHORTENER_MAIN_DIR)/gap_shortener.o \
$(GAP_SHORTENER_MAIN_DIR)/reader.o \
$(GAP_SHORTENER_MAIN_DIR)/pseudoreads_maker.o \
$(LIB_ZLIB)
-mkdir -p $(OUT_BIN_DIR)
$(CXX) -o $@ $^ \
$(CLINK)
download_kmc:
-mkdir -p $(OUT_BIN_DIR)
./download_kmc.py $(OUT_BIN_DIR)
splash:
mkdir -p bin
cp src/splash.py bin/splash
cp -R postprocessing bin/
supervised_test:
cp src/supervised_test/supervised_test.R bin
install: all
cp -r bin/* /usr/local/bin
uninstall:
-rm /usr/local/bin/satc
-rm /usr/local/bin/bkc
-rm /usr/local/bin/bkc_dump
-rm /usr/local/bin/read_selector
-rm /usr/local/bin/compactors
-rm /usr/local/bin/satc_dump
-rm /usr/local/bin/satc_merge
-rm /usr/local/bin/sig_anch
-rm /usr/local/bin/splash
-rm /usr/local/bin/kmc
-rm /usr/local/bin/kmc_tools
clean:
-rm $(SPLASH_LIBS_DIR)/refresh/*.o
-rm $(SATC_MAIN_DIR)/*.o
-rm $(COMMON_DIR)/kmc_api/*.o
-rm $(SATC_MERGE_MAIN_DIR)/*.o
-rm $(SATC_DUMP_MAIN_DIR)/*.o
-rm $(FAFQ_FILTER_MAIN_DIR)/*.o
-rm $(SATC_FILTER_MAIN_DIR)/*.o
-rm $(READ_SELECTOR_MAIN_DIR)/*.o
-rm $(COMPACTORS_MAIN_DIR)/*.o
-rm $(COMMON_DIR)/*.o
-rm $(SIG_ANCH_MAIN_DIR)/*.o
-rm $(LOOKUP_TABLE_MAIN_DIR)/*.o
-rm $(DSV_MANIP_MAIN_DIR)/*.o
-rm $(GAP_SHORTENER_MAIN_DIR)/*.o
-rm -rf $(OUT_BIN_DIR)
-rm $(SPLASH_LIBS_DIR)/cdflib/*.o
(cd $(SPLASH_LIBS_DIR)/bkc; make clean)