forked from samtools/samtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
481 lines (391 loc) · 22.7 KB
/
Copy pathMakefile
File metadata and controls
481 lines (391 loc) · 22.7 KB
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# =============================================================================
# Samtools Makefile - Sequence Alignment/Map Format Utilities
# =============================================================================
#
# This Makefile builds samtools with optional CUDA GPU acceleration support.
#
# Copyright (C) 2008-2025 Genome Research Ltd.
# Portions copyright (C) 2010-2012 Broad Institute.
# CUDA GPU acceleration (C) 2025 Akshay Dedaniya <Dedaniya08@hotmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# =============================================================================
# Build Configuration Variables
# =============================================================================
# Standard build tools
CC = gcc
AR = ar
AWK = awk
# Compiler and linker flags
CPPFLAGS =
#CFLAGS = -g -Wall -O2 -pedantic -std=c99 -D_XOPEN_SOURCE=700
CFLAGS = -g -Wall -O2
LDFLAGS =
LIBS =
# =============================================================================
# CUDA GPU Acceleration Configuration
# =============================================================================
# CUDA build tools and flags (populated by configure script)
# These variables are automatically set when --enable-cuda is used with configure
NVCC ?= nvcc # NVIDIA CUDA compiler
CUDA_CPPFLAGS ?= # CUDA preprocessor flags
CUDA_CFLAGS ?= # CUDA compiler flags
CUDA_LDFLAGS ?= # CUDA linker flags
CUDA_LIBS ?= # CUDA libraries to link
CUDA_ARCH ?= # GPU architecture target
CUDA_OBJS ?= # CUDA object files to build
ENABLE_CUDA ?= # CUDA enable flag
# Import configure-generated settings
-include config.mk
# =============================================================================
# Conditional CUDA Build Setup
# =============================================================================
# Add CUDA flags and libraries if GPU acceleration is enabled
ifneq ($(CUDA_OBJS),)
CPPFLAGS += $(CUDA_CPPFLAGS)
LDFLAGS += $(CUDA_LDFLAGS)
LIBS += $(CUDA_LIBS)
# CUDA compilation flags
NVCC_FLAGS = -O2 -std=c++14 -Xcompiler -fPIC
ifneq ($(CUDA_ARCH),)
NVCC_FLAGS += -arch=$(CUDA_ARCH)
endif
endif
LZ4DIR = ./lz4
LZ4_CPPFLAGS = -I$(LZ4DIR)
LZ4_LDFLAGS = -L$(LZ4DIR)
AOBJS= bam_aux.o bam_index.o bam_plcmd.o sam_view.o bam_fastq.o \
bam_cat.o bam_md.o bam_plbuf.o bam_reheader.o bam_sort.o \
bam_rmdup.o bam_rmdupse.o bam_mate.o bam_stat.o bam_color.o \
bamtk.o bam2bcf.o sample.o \
cut_target.o phase.o bam2depth.o coverage.o padding.o bedcov.o bamshuf.o \
faidx.o dict.o stats.o stats_isize.o bam_flags.o bam_split.o \
bam_tview.o bam_tview_curses.o bam_tview_html.o bam_lpileup.o \
bam_quickcheck.o bam_addrprg.o bam_markdup.o tmp_file.o \
bam_ampliconclip.o amplicon_stats.o bam_import.o bam_samples.o \
bam_consensus.o consensus_pileup.o reference.o reset.o cram_size.o \
bam_checksum.o samtools_cuda.o
LZ4OBJS = $(LZ4DIR)/lz4.o
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
datarootdir = $(prefix)/share
mandir = $(datarootdir)/man
man1dir = $(mandir)/man1
# Installation location for $(MISC_PROGRAMS) and $(MISC_SCRIPTS)
misc_bindir = $(bindir)
MKDIR_P = mkdir -p
INSTALL = install -p
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_DIR = $(MKDIR_P) -m 755
INSTALL_MAN = $(INSTALL_DATA)
INSTALL_PROGRAM = $(INSTALL)
INSTALL_SCRIPT = $(INSTALL_PROGRAM)
PROGRAMS = samtools
MISC_PROGRAMS = \
misc/ace2sam misc/maq2sam-long misc/maq2sam-short \
misc/md5fa misc/md5sum-lite misc/wgsim
MISC_SCRIPTS = \
misc/blast2sam.pl misc/bowtie2sam.pl misc/export2sam.pl \
misc/fasta-sanitize.pl misc/interpolate_sam.pl misc/novo2sam.pl \
misc/plot-ampliconstats misc/plot-bamstats misc/psl2sam.pl \
misc/sam2vcf.pl misc/samtools.pl misc/seq_cache_populate.pl \
misc/soap2sam.pl misc/wgsim_eval.pl misc/zoom2sam.pl
TEST_PROGRAMS = \
test/merge/test_bam_translate \
test/merge/test_rtrans_build \
test/merge/test_trans_tbl_init \
test/split/test_count_rg \
test/split/test_expand_format_string \
test/split/test_filter_header_rg \
test/split/test_parse_args \
test/vcf-miniview \
test/test_cuda_config
all: $(PROGRAMS) $(MISC_PROGRAMS) $(TEST_PROGRAMS)
ALL_CPPFLAGS = -I. $(HTSLIB_CPPFLAGS) $(LZ4_CPPFLAGS) $(CUDA_CPPFLAGS) $(CPPFLAGS)
ALL_LDFLAGS = $(HTSLIB_LDFLAGS) $(LZ4_LDFLAGS) $(CUDA_LDFLAGS) $(LDFLAGS)
ALL_LIBS = -lz $(CUDA_LIBS) $(LIBS)
# Usually config.mk and config.h are generated by running configure
# or config.status, but if those aren't used create defaults here.
config.mk:
@sed -e '/^prefix/,/^LIBS/d;s/@Hsource@//;s/@Hinstall@/#/;s#@HTSDIR@#../htslib#g;s/@HTSLIB_CPPFLAGS@/-I$$(HTSDIR)/g;s/@CURSES_LIB@/-lcurses/g' config.mk.in > $@
config.h:
echo '/* Basic config.h generated by Makefile */' > $@
echo '#define HAVE_CURSES' >> $@
echo '#define HAVE_CURSES_H' >> $@
include config.mk
# If not using GNU make, you need to copy the version number from version.sh
# into here.
PACKAGE_VERSION = $(shell ./version.sh)
# Force version.h to be remade if $(PACKAGE_VERSION) has changed.
version.h: $(if $(wildcard version.h),$(if $(findstring "$(PACKAGE_VERSION)",$(shell cat version.h)),,force))
# If you don't have GNU Make but are building from a Git repository, you may
# wish to replace this with a rule that always rebuilds version.h:
# version.h: force
# echo '#define SAMTOOLS_VERSION "`git describe --always --dirty`"' > $@
version.h:
echo '#define SAMTOOLS_VERSION "$(PACKAGE_VERSION)"' > $@
echo '#define SAMTOOLS_CC "$(CC)"' >> $@
echo '#define SAMTOOLS_CPPFLAGS "$(CPPFLAGS)"' >> $@
echo '#define SAMTOOLS_CFLAGS "$(CFLAGS)"' >> $@
echo '#define SAMTOOLS_LDFLAGS "$(LDFLAGS)"' >> $@
echo '#define SAMTOOLS_HTSDIR "$(HTSDIR)"' >> $@
echo '#define SAMTOOLS_LIBS "$(LIBS)"' >> $@
echo '#define SAMTOOLS_CURSES_LIB "$(CURSES_LIB)"' >> $@
print-version:
@echo $(PACKAGE_VERSION)
.SUFFIXES: .c .o .cu
.c.o:
$(CC) $(CFLAGS) $(CUDA_CFLAGS) $(ALL_CPPFLAGS) -c -o $@ $<
.cu.o:
$(NVCC) $(CUDA_CFLAGS) -arch=$(CUDA_ARCH) -I. $(CUDA_CPPFLAGS) -c -o $@ $<
LIBST_OBJS = sam_opts.o sam_utils.o bedidx.o bam.o
# Add CUDA objects to samtools if CUDA is enabled
ifeq ($(ENABLE_CUDA),1)
samtools: $(AOBJS) $(LZ4OBJS) $(CUDA_OBJS) libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ $(AOBJS) $(LZ4OBJS) $(CUDA_OBJS) libst.a $(HTSLIB_LIB) $(CURSES_LIB) -lm $(ALL_LIBS) -lpthread
else
samtools: $(AOBJS) $(LZ4OBJS) libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ $(AOBJS) $(LZ4OBJS) libst.a $(HTSLIB_LIB) $(CURSES_LIB) -lm $(ALL_LIBS) -lpthread
endif
# For building samtools and its test suite only: NOT to be installed.
libst.a: $(LIBST_OBJS)
@-rm -f $@
$(AR) -rcs $@ $(LIBST_OBJS)
bam_h = bam.h $(htslib_sam_h)
bam2bcf_h = bam2bcf.h $(htslib_hts_h) $(htslib_vcf_h)
bam_ampliconclip_h = bam_ampliconclip.h $(htslib_khash_h)
bam_lpileup_h = bam_lpileup.h $(htslib_sam_h)
bam_plbuf_h = bam_plbuf.h $(htslib_sam_h)
bam_tview_h = bam_tview.h $(htslib_hts_h) $(htslib_sam_h) $(htslib_faidx_h) $(bam2bcf_h) $(htslib_khash_h) $(bam_lpileup_h)
bedidx_h = bedidx.h $(htslib_hts_h)
consensus_pileup_h = consensus_pileup.h $(htslib_sam_h)
sam_opts_h = sam_opts.h $(htslib_hts_h)
sam_utils_h = sam_utils.h $(htslib_khash_h) $(htslib_sam_h)
sample_h = sample.h $(htslib_kstring_h)
samtools_h = samtools.h $(htslib_hts_defs_h) $(htslib_sam_h) $(sam_utils_h)
stats_isize_h = stats_isize.h $(htslib_khash_h)
tmp_file_h = tmp_file.h $(htslib_sam_h) $(LZ4DIR)/lz4.h
bam.o: bam.c config.h $(bam_h) $(htslib_kstring_h)
bam2bcf.o: bam2bcf.c config.h $(htslib_hts_h) $(htslib_sam_h) $(bam2bcf_h)
bam2depth.o: bam2depth.c config.h $(htslib_sam_h) $(samtools_h) $(bedidx_h) $(sam_opts_h) $(htslib_khash_h)
coverage.o: coverage.c config.h $(htslib_sam_h) $(htslib_hts_h) $(samtools_h) $(sam_opts_h)
bam_addrprg.o: bam_addrprg.c config.h $(htslib_sam_h) $(htslib_kstring_h) $(samtools_h) $(htslib_thread_pool_h) $(sam_opts_h)
bam_aux.o: bam_aux.c config.h $(htslib_sam_h)
bam_cat.o: bam_cat.c config.h $(htslib_bgzf_h) $(htslib_sam_h) $(htslib_cram_h) $(htslib_kstring_h) $(htslib_hfile_h) $(samtools_h) $(sam_opts_h)
bam_color.o: bam_color.c config.h $(htslib_sam_h)
bam_fastq.o: bam_fastq.c config.h $(htslib_sam_h) $(htslib_klist_h) $(htslib_kstring_h) $(htslib_bgzf_h) $(htslib_thread_pool_h) $(htslib_khash_h) $(samtools_h) $(sam_opts_h)
bam_import.o: bam_import.c config.h $(htslib_sam_h) $(htslib_thread_pool_h) $(samtools_h) $(sam_opts_h)
bam_index.o: bam_index.c config.h $(htslib_hts_h) $(htslib_sam_h) $(htslib_hfile_h) $(htslib_khash_h) $(samtools_h) $(sam_opts_h)
bam_lpileup.o: bam_lpileup.c config.h $(bam_plbuf_h) $(bam_lpileup_h) splaysort.h
bam_mate.o: bam_mate.c config.h $(htslib_thread_pool_h) $(sam_opts_h) $(htslib_kstring_h) $(htslib_sam_h) $(samtools_h)
bam_md.o: bam_md.c config.h $(htslib_faidx_h) $(htslib_sam_h) $(htslib_kstring_h) $(htslib_thread_pool_h) $(sam_opts_h) $(samtools_h)
bam_plbuf.o: bam_plbuf.c config.h $(htslib_hts_h) $(htslib_sam_h) $(bam_plbuf_h)
bam_checksum.o: bam_checksum.c config.h $(htslib_sam_h) $(htslib_khash_h) $(htslib_kstring_h) $(htslib_hts_endian_h) $(sam_opts_h) $(sam_utils_h) $(samtools_h)
bam_consensus.o: bam_consensus.c bam_consensus_tab.h config.h $(htslib_sam_h) $(htslib_hfile_h) $(htslib_faidx_h) $(htslib_thread_pool_h) $(htslib_cram_h) $(samtools_h) $(sam_opts_h) $(bam_plbuf_h) $(consensus_pileup_h)
bam_plcmd.o: bam_plcmd.c config.h $(htslib_sam_h) $(htslib_faidx_h) $(htslib_kstring_h) $(htslib_klist_h) $(htslib_khash_str2int_h) $(samtools_h) $(bedidx_h) $(sam_opts_h) $(sample_h) $(htslib_cram_h) $(bam_plbuf_h)
bam_quickcheck.o: bam_quickcheck.c config.h $(htslib_hts_h) $(htslib_sam_h)
bam_reheader.o: bam_reheader.c config.h $(htslib_bgzf_h) $(htslib_sam_h) $(htslib_hfile_h) $(htslib_cram_h) $(samtools_h)
bam_rmdup.o: bam_rmdup.c config.h $(htslib_sam_h) $(sam_opts_h) $(samtools_h) $(bam_h) $(htslib_khash_h)
bam_rmdupse.o: bam_rmdupse.c config.h $(bam_h) $(htslib_sam_h) $(htslib_khash_h) $(htslib_klist_h) $(samtools_h)
bam_sort.o: bam_sort.c config.h $(htslib_ksort_h) $(htslib_hts_os_h) $(htslib_khash_h) $(htslib_klist_h) $(htslib_kstring_h) $(htslib_sam_h) $(htslib_hts_endian_h) $(htslib_cram_h) $(htslib_thread_pool_h) $(sam_opts_h) $(samtools_h) $(bedidx_h) $(bam_h)
bam_split.o: bam_split.c config.h $(htslib_sam_h) $(htslib_khash_h) $(htslib_kstring_h) $(htslib_cram_h) $(htslib_thread_pool_h) $(sam_opts_h) $(samtools_h)
bam_stat.o: bam_stat.c config.h $(htslib_sam_h) $(samtools_h) $(sam_opts_h)
bam_tview.o: bam_tview.c config.h $(bam_tview_h) $(htslib_faidx_h) $(htslib_sam_h) $(htslib_bgzf_h) $(samtools_h) $(sam_opts_h)
bam_tview_curses.o: bam_tview_curses.c config.h $(bam_tview_h)
bam_tview_html.o: bam_tview_html.c config.h $(bam_tview_h)
bam_flags.o: bam_flags.c config.h $(htslib_sam_h) $(samtools_h)
bamshuf.o: bamshuf.c config.h $(htslib_sam_h) $(htslib_hts_h) $(htslib_ksort_h) $(samtools_h) $(htslib_thread_pool_h) $(sam_opts_h) $(htslib_khash_h)
bamtk.o: bamtk.c config.h $(htslib_hts_h) $(htslib_hfile_h) $(samtools_h) version.h
bedcov.o: bedcov.c config.h $(htslib_kstring_h) $(htslib_sam_h) $(htslib_thread_pool_h) $(samtools_h) $(sam_opts_h) $(htslib_kseq_h)
bedidx.o: bedidx.c config.h $(bedidx_h) $(htslib_ksort_h) $(htslib_kseq_h) $(htslib_khash_h)
consensus_pileup.o: consensus_pileup.c config.h $(htslib_sam_h) $(consensus_pileup_h)
cram_size.o: cram_size.c config.h $(htslib_bgzf_h) $(htslib_sam_h) $(htslib_cram_h) $(htslib_kstring_h) $(htslib_khash_h) $(samtools_h) $(sam_opts_h) $(htslib_hfile_h)
cut_target.o: cut_target.c config.h $(htslib_hts_h) $(htslib_sam_h) $(htslib_faidx_h) $(samtools_h) $(sam_opts_h)
dict.o: dict.c config.h $(htslib_khash_h) $(htslib_kseq_h) $(htslib_hts_h) $(samtools_h)
faidx.o: faidx.c config.h $(htslib_faidx_h) $(htslib_hts_h) $(htslib_hfile_h) $(htslib_kstring_h) $(htslib_bgzf_h) $(htslib_thread_pool_h) $(sam_opts_h) $(samtools_h)
padding.o: padding.c config.h $(htslib_kstring_h) $(htslib_sam_h) $(htslib_faidx_h) $(sam_opts_h) $(samtools_h)
phase.o: phase.c config.h $(htslib_hts_h) $(htslib_sam_h) $(htslib_kstring_h) $(sam_opts_h) $(samtools_h) $(htslib_hts_os_h) $(htslib_kseq_h) $(htslib_khash_h) $(htslib_ksort_h)
reference.o: reference.c config.h $(htslib_sam_h) $(htslib_cram_h) $(samtools_h) $(sam_opts_h)
sam_opts.o: sam_opts.c config.h $(sam_opts_h)
sam_utils.o: sam_utils.c config.h $(sam_utils_h)
sam_view.o: sam_view.c config.h $(htslib_sam_h) $(htslib_faidx_h) $(htslib_khash_h) $(htslib_kstring_h) $(htslib_hfile_h) $(htslib_thread_pool_h) $(htslib_hts_expr_h) $(samtools_h) $(sam_opts_h) $(bam_h) $(bedidx_h) $(sam_utils_h)
sample.o: sample.c config.h $(sample_h) $(htslib_khash_h)
stats_isize.o: stats_isize.c config.h $(stats_isize_h) $(htslib_khash_h)
stats.o: stats.c config.h $(htslib_faidx_h) $(htslib_sam_h) $(htslib_hts_h) $(htslib_hts_defs_h) $(samtools_h) $(htslib_khash_h) $(htslib_kstring_h) $(stats_isize_h) $(sam_opts_h) $(bedidx_h) $(htslib_thread_pool_h)
amplicon_stats.o: amplicon_stats.c config.h $(htslib_sam_h) $(htslib_khash_h) $(samtools_h) $(sam_opts_h) $(bam_ampliconclip_h)
bam_markdup.o: bam_markdup.c config.h $(htslib_thread_pool_h) $(htslib_sam_h) $(sam_opts_h) $(samtools_h) $(htslib_khash_h) $(htslib_klist_h) $(htslib_kstring_h) $(tmp_file_h) $(bam_h)
tmp_file.o: tmp_file.c config.h $(tmp_file_h) $(htslib_sam_h)
bam_ampliconclip.o: bam_ampliconclip.c config.h $(htslib_thread_pool_h) $(sam_opts_h) $(htslib_hts_h) $(htslib_hfile_h) $(htslib_kstring_h) $(htslib_sam_h) $(samtools_h) $(bam_ampliconclip_h)
bam_samples.o: bam_samples.c config.h $(htslib_hts_h) $(htslib_sam_h) $(htslib_faidx_h) $(htslib_khash_h) $(htslib_kseq_h) $(samtools_h)
reset.o: reset.c config.h $(samtools_h) $(htslib_sam_h) $(sam_opts_h) $(htslib_thread_pool_h) $(htslib_khash_h) $(sam_utils_h)
# Maintainer source code checks
# - copyright boilerplate presence
# - tab and trailing space detection
maintainer-check:
test/maintainer/check_copyright.pl .
test/maintainer/check_spaces.pl .
# test programs
# For tests that might use it, set $REF_PATH explicitly to use only reference
# areas within the test suite (or set it to ':' to use no reference areas).
# (regression.sh sets $REF_PATH to a subdirectory itself.)
#
# If using MSYS, avoid poor shell expansion via:
# MSYS2_ARG_CONV_EXCL="*" make check
check test: samtools $(BGZIP) $(TEST_PROGRAMS)
test/split/test_count_rg
test/split/test_expand_format_string
test/split/test_filter_header_rg
test/split/test_parse_args
REF_PATH=: test/test.pl --exec bgzip=$(BGZIP) $${TEST_OPTS:-}
test/merge/test_bam_translate test/merge/test_bam_translate.tmp
test/merge/test_rtrans_build
test/merge/test_trans_tbl_init
cd test/mpileup && AWK="$(AWK)" ../regression.sh mpileup.reg
cd test/mpileup && AWK="$(AWK)" ../regression.sh depth.reg
cd test/mpileup && AWK="$(AWK)" ../regression.sh cram-size.reg
cd test/consensus && AWK="$(AWK)" ../regression.sh consensus.reg
cd test/consensus && AWK="$(AWK)" PARAM="-@4 -Z4" ../regression.sh consensus.reg
cd test/cram_size && AWK="$(AWK)" ../regression.sh cram_size.reg
test/merge/test_bam_translate: test/merge/test_bam_translate.o test/test.o libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/merge/test_bam_translate.o test/test.o libst.a $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test/merge/test_rtrans_build: test/merge/test_rtrans_build.o test/test.o libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/merge/test_rtrans_build.o test/test.o libst.a $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test/merge/test_trans_tbl_init: test/merge/test_trans_tbl_init.o test/test.o libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/merge/test_trans_tbl_init.o test/test.o libst.a $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test/split/test_count_rg: test/split/test_count_rg.o test/test.o libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/split/test_count_rg.o test/test.o libst.a $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test/split/test_expand_format_string: test/split/test_expand_format_string.o test/test.o libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/split/test_expand_format_string.o test/test.o libst.a $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test/split/test_filter_header_rg: test/split/test_filter_header_rg.o test/test.o libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/split/test_filter_header_rg.o test/test.o libst.a $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test/split/test_parse_args: test/split/test_parse_args.o test/test.o libst.a $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/split/test_parse_args.o test/test.o libst.a $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test/vcf-miniview: test/vcf-miniview.o $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/vcf-miniview.o $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test/test_cuda_config: test/test_cuda_config.o $(CUDA_OBJS) $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ test/test_cuda_config.o $(CUDA_OBJS) $(HTSLIB_LIB) $(ALL_LIBS) -lpthread
test_test_h = test/test.h $(htslib_sam_h)
test/merge/test_bam_translate.o: test/merge/test_bam_translate.c config.h bam_sort.o $(test_test_h)
test/merge/test_rtrans_build.o: test/merge/test_rtrans_build.c config.h bam_sort.o
test/merge/test_trans_tbl_init.o: test/merge/test_trans_tbl_init.c config.h bam_sort.o
test/split/test_count_rg.o: test/split/test_count_rg.c config.h bam_split.o $(test_test_h)
test/split/test_expand_format_string.o: test/split/test_expand_format_string.c config.h bam_split.o $(test_test_h)
test/split/test_filter_header_rg.o: test/split/test_filter_header_rg.c config.h $(test_test_h) $(samtools_h) $(htslib_kstring_h)
test/split/test_parse_args.o: test/split/test_parse_args.c config.h bam_split.o $(test_test_h)
test/test.o: test/test.c config.h $(htslib_sam_h) $(test_test_h)
test/vcf-miniview.o: test/vcf-miniview.c config.h $(htslib_vcf_h)
test/test_cuda_config.o: test/test_cuda_config.c config.h
# test HTSlib as well, where it is built alongside SAMtools
check-all test-all: test-htslib test
# misc programs
misc/ace2sam: misc/ace2sam.o $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ misc/ace2sam.o $(HTSLIB_LIB) $(ALL_LIBS)
misc/maq2sam-short: misc/maq2sam-short.o
$(CC) $(LDFLAGS) -o $@ misc/maq2sam-short.o $(ALL_LIBS)
misc/maq2sam-long: misc/maq2sam-long.o
$(CC) $(LDFLAGS) -o $@ misc/maq2sam-long.o $(ALL_LIBS)
misc/md5fa: misc/md5fa.o $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ misc/md5fa.o $(HTSLIB_LIB) $(ALL_LIBS)
misc/md5sum-lite: misc/md5sum-lite.o $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ misc/md5sum-lite.o $(HTSLIB_LIB) $(ALL_LIBS)
misc/wgsim: misc/wgsim.o $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ misc/wgsim.o -lm $(HTSLIB_LIB) $(ALL_LIBS)
misc/ace2sam.o: misc/ace2sam.c config.h $(htslib_kstring_h) $(htslib_kseq_h)
misc/md5fa.o: misc/md5fa.c config.h $(htslib_kseq_h) $(htslib_hts_h)
misc/md5sum-lite.o: misc/md5sum-lite.c config.h $(htslib_hts_h)
misc/wgsim.o: misc/wgsim.c config.h version.h $(htslib_kseq_h) $(htslib_hts_os_h)
misc/maq2sam-short.o: misc/maq2sam.c config.h version.h
$(CC) $(CFLAGS) $(ALL_CPPFLAGS) -c -o $@ misc/maq2sam.c
misc/maq2sam-long.o: misc/maq2sam.c config.h version.h
$(CC) $(CFLAGS) -DMAQ_LONGREADS $(ALL_CPPFLAGS) -c -o $@ misc/maq2sam.c
install: $(PROGRAMS) $(MISC_PROGRAMS)
$(INSTALL_DIR) $(DESTDIR)$(bindir) $(DESTDIR)$(misc_bindir) $(DESTDIR)$(man1dir)
$(INSTALL_PROGRAM) $(PROGRAMS) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) $(MISC_PROGRAMS) $(DESTDIR)$(misc_bindir)
$(INSTALL_SCRIPT) $(MISC_SCRIPTS) $(DESTDIR)$(misc_bindir)
$(INSTALL_MAN) doc/samtools*.1 misc/wgsim.1 $(DESTDIR)$(man1dir)
testclean:
-rm -f test/*.new test/*.tmp test/*/*.new test/*/*.tmp test/*/*.tmp.*
-cd test/consensus && rm -f *.bam *.bam.csi
-cd test/dat && rm -f test_input_*.bam.bai view.*.bam.bai
-cd test/mpileup && rm -f FAIL-*.out* PASS-*.out* *.fa.fai anomalous.[bc]*am indels.[bc]*am mpileup.*.[cs]*am mpileup.*.crai overlap50.[bc]*am expected/1.out xx#depth*.bam*
-cd test/reference && rm -f mpileup.*.fai
mostlyclean: testclean
-rm -f *.o misc/*.o test/*.o test/*/*.o version.h $(LZ4OBJS)
ifneq ($(CUDA_OBJS),)
-rm -f $(CUDA_OBJS)
endif
clean: mostlyclean
-rm -f $(PROGRAMS) libst.a $(MISC_PROGRAMS) $(TEST_PROGRAMS)
distclean: clean
-rm -f config.cache config.h config.log config.mk config.status
-rm -f TAGS
-rm -rf autom4te.cache
clean-all: clean clean-htslib
distclean-all: distclean distclean-htslib
mostlyclean-all: mostlyclean mostlyclean-htslib
testclean-all: testclean testclean-htslib
tags:
ctags -f TAGS *.[ch] misc/*.[ch]
force:
.PHONY: all check check-all clean clean-all distclean distclean-all force
.PHONY: install mostlyclean mostlyclean-all print-version tags
.PHONY: test test-all testclean testclean-all
# CUDA compilation rules
ifneq ($(CUDA_OBJS),)
# Rule for compiling CUDA source files
%.o: %.cu
@if test -z "$(NVCC)"; then \
echo "Error: NVCC not found. Please install CUDA toolkit or disable CUDA."; \
exit 1; \
fi
$(NVCC) $(NVCC_FLAGS) $(CUDA_CPPFLAGS) -c $< -o $@
# Specific CUDA object dependencies
cuda/cuda_config.o: cuda/cuda_config.cu cuda/cuda_config.h
$(NVCC) $(NVCC_FLAGS) $(CUDA_CPPFLAGS) -c $< -o $@
cuda/cuda_sort.o: cuda/cuda_sort.cu cuda/cuda_sort.cuh cuda/cuda_config.h
$(NVCC) $(NVCC_FLAGS) $(CUDA_CPPFLAGS) -c $< -o $@
cuda/cuda_pileup.o: cuda/cuda_pileup.cu cuda/cuda_pileup.cuh cuda/cuda_config.h
$(NVCC) $(NVCC_FLAGS) $(CUDA_CPPFLAGS) -c $< -o $@
cuda/cuda_stats.o: cuda/cuda_stats.cu cuda/cuda_stats.cuh cuda/cuda_config.h
$(NVCC) $(NVCC_FLAGS) $(CUDA_CPPFLAGS) -c $< -o $@
# CUDA info target
cuda-info:
@echo "CUDA Configuration:"
@echo " NVCC: $(NVCC)"
@echo " CUDA_ARCH: $(CUDA_ARCH)"
@echo " CUDA_CPPFLAGS: $(CUDA_CPPFLAGS)"
@echo " CUDA_LDFLAGS: $(CUDA_LDFLAGS)"
@echo " CUDA_LIBS: $(CUDA_LIBS)"
@echo " CUDA_OBJS: $(CUDA_OBJS)"
@echo ""
ifneq ($(CUDA_OBJS),)
@echo "CUDA support: ENABLED"
@if command -v nvidia-smi >/dev/null 2>&1; then \
echo "GPU status:"; \
nvidia-smi -L 2>/dev/null | sed 's/^/ /'; \
else \
echo "GPU status: nvidia-smi not available"; \
fi
else
@echo "CUDA support: DISABLED"
@echo "To enable CUDA: ./configure --enable-cuda"
endif
endif