Skip to content

Commit 87e9d63

Browse files
committed
update htslib
1 parent 40a2bf6 commit 87e9d63

File tree

2 files changed

+304
-0
lines changed

2 files changed

+304
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ext/htslib/src/
1515
CMakeCache.txt
1616
CMakeFiles
1717
Makefile
18+
!ext/htslib/Makefile
1819
cmake_install.cmake
1920
CTestTestfile.cmake
2021
*~

ext/htslib/Makefile

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
# Makefile for htslib, a C library for high-throughput sequencing data formats.
2+
#
3+
# Copyright (C) 2013-2014 Genome Research Ltd.
4+
#
5+
# Author: John Marshall <[email protected]>
6+
7+
CC ?= gcc
8+
AR = ar
9+
RANLIB = ranlib
10+
11+
# TODO: edit cram code to remove need for -DSAMTOOLS
12+
CPPFLAGS += -I. -DSAMTOOLS=1
13+
# TODO: probably update cram code to make it compile cleanly with -Wc++-compat
14+
CFLAGS := -g -Wall -O2 $(CFLAGS)
15+
EXTRA_CFLAGS_PIC = -fpic
16+
LDFLAGS =
17+
LDLIBS =
18+
19+
prefix = /usr/local
20+
exec_prefix = $(prefix)
21+
bindir = $(exec_prefix)/bin
22+
includedir = $(prefix)/include
23+
libdir = $(exec_prefix)/lib
24+
mandir = $(prefix)/share/man
25+
man1dir = $(mandir)/man1
26+
man5dir = $(mandir)/man5
27+
28+
INSTALL = install -p
29+
INSTALL_PROGRAM = $(INSTALL)
30+
INSTALL_DATA = $(INSTALL) -m 644
31+
32+
BUILT_PROGRAMS = \
33+
bgzip \
34+
tabix
35+
36+
BUILT_TEST_PROGRAMS = \
37+
test/fieldarith \
38+
test/hfile \
39+
test/sam \
40+
test/test_view \
41+
test/test-vcf-api \
42+
test/test-vcf-sweep
43+
44+
all: lib-static lib-shared $(BUILT_PROGRAMS) $(BUILT_TEST_PROGRAMS)
45+
46+
HTSPREFIX =
47+
include htslib_vars.mk
48+
49+
lib-static: libhts.a
50+
51+
# $(shell), :=, and ifeq/.../endif are GNU Make-specific. If you don't have
52+
# GNU Make, comment out the parts of this conditional that don't apply.
53+
PLATFORM := $(shell uname -s)
54+
ifeq "$(PLATFORM)" "Darwin"
55+
SHLIB_FLAVOUR = dylib
56+
lib-shared: libhts.dylib
57+
else
58+
SHLIB_FLAVOUR = so
59+
lib-shared: libhts.so
60+
endif
61+
62+
63+
PACKAGE_VERSION = 0.0.1
64+
LIBHTS_SOVERSION = 0
65+
66+
67+
# $(NUMERIC_VERSION) is for items that must have a numeric X.Y.Z string
68+
# even if this is a dirty or untagged Git working tree.
69+
NUMERIC_VERSION = $(PACKAGE_VERSION)
70+
71+
# If building from a Git repository, replace $(PACKAGE_VERSION) with the Git
72+
# description of the working tree: either a release tag with the same value
73+
# as $(PACKAGE_VERSION) above, or an exact description likely based on a tag.
74+
# Much of this is also GNU Make-specific. If you don't have GNU Make and/or
75+
# are not building from a Git repository, comment out this conditional.
76+
ifneq "$(wildcard .git)" ""
77+
original_version := $(PACKAGE_VERSION)
78+
PACKAGE_VERSION := $(shell git describe --always --dirty)
79+
80+
# Unless the Git description matches /\d*\.\d*(\.\d*)?/, i.e., is exactly a tag
81+
# with a numeric name, revert $(NUMERIC_VERSION) to the original version number
82+
# written above, but with the patchlevel field bumped to 255.
83+
ifneq "$(subst ..,.,$(subst 0,,$(subst 1,,$(subst 2,,$(subst 3,,$(subst 4,,$(subst 5,,$(subst 6,,$(subst 7,,$(subst 8,,$(subst 9,,$(PACKAGE_VERSION))))))))))))" "."
84+
empty :=
85+
NUMERIC_VERSION := $(subst $(empty) ,.,$(wordlist 1,2,$(subst ., ,$(original_version))) 255)
86+
endif
87+
88+
# Force version.h to be remade if $(PACKAGE_VERSION) has changed.
89+
version.h: $(if $(wildcard version.h),$(if $(findstring "$(PACKAGE_VERSION)",$(shell cat version.h)),,force))
90+
endif
91+
92+
version.h:
93+
echo '#define HTS_VERSION "$(PACKAGE_VERSION)"' > $@
94+
95+
96+
.SUFFIXES: .c .o .pico
97+
98+
.c.o:
99+
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
100+
101+
.c.pico:
102+
$(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_CFLAGS_PIC) -c -o $@ $<
103+
104+
105+
LIBHTS_OBJS = \
106+
kfunc.o \
107+
knetfile.o \
108+
kstring.o \
109+
bgzf.o \
110+
faidx.o \
111+
hfile.o \
112+
hfile_net.o \
113+
hts.o \
114+
sam.o \
115+
synced_bcf_reader.o \
116+
vcf_sweep.o \
117+
tbx.o \
118+
vcf.o \
119+
vcfutils.o \
120+
cram/cram_codecs.o \
121+
cram/cram_decode.o \
122+
cram/cram_encode.o \
123+
cram/cram_index.o \
124+
cram/cram_io.o \
125+
cram/cram_samtools.o \
126+
cram/cram_stats.o \
127+
cram/files.o \
128+
cram/mFILE.o \
129+
cram/md5.o \
130+
cram/open_trace_file.o \
131+
cram/pooled_alloc.o \
132+
cram/sam_header.o \
133+
cram/string_alloc.o \
134+
cram/thread_pool.o \
135+
cram/vlen.o \
136+
cram/zfio.o
137+
138+
139+
libhts.a: $(LIBHTS_OBJS)
140+
@-rm -f $@
141+
$(AR) -rc $@ $(LIBHTS_OBJS)
142+
-$(RANLIB) $@
143+
144+
145+
# The target here is libhts.so, as that is the built file that other rules
146+
# depend upon and that is used when -lhts appears in other program's recipes.
147+
# As a byproduct invisible to make, libhts.so.NN is also created, as it is the
148+
# file used at runtime (when $LD_LIBRARY_PATH includes the build directory).
149+
150+
libhts.so: $(LIBHTS_OBJS:.o=.pico)
151+
$(CC) -shared -Wl,-soname,libhts.so.$(LIBHTS_SOVERSION) $(LDFLAGS) -o $@ $(LIBHTS_OBJS:.o=.pico) $(LDLIBS) -lz
152+
ln -sf $@ libhts.so.$(LIBHTS_SOVERSION)
153+
154+
# Similarly this also creates libhts.NN.dylib as a byproduct, so that programs
155+
# when run can find this uninstalled shared library (when $DYLD_LIBRARY_PATH
156+
# includes this project's build directory).
157+
158+
libhts.dylib: $(LIBHTS_OBJS)
159+
$(CC) -dynamiclib -install_name $(libdir)/libhts.$(LIBHTS_SOVERSION).dylib -current_version $(NUMERIC_VERSION) -compatibility_version $(LIBHTS_SOVERSION) $(LDFLAGS) -o $@ $(LIBHTS_OBJS) $(LDLIBS) -lz
160+
ln -sf $@ libhts.$(LIBHTS_SOVERSION).dylib
161+
162+
163+
cram_h = cram/cram.h $(cram_samtools_h) $(cram_sam_header_h) $(cram_structs_h) $(cram_io_h) cram/cram_encode.h cram/cram_decode.h cram/cram_stats.h cram/cram_codecs.h cram/cram_index.h
164+
cram_io_h = cram/cram_io.h $(cram_misc_h)
165+
cram_misc_h = cram/misc.h cram/os.h
166+
cram_sam_header_h = cram/sam_header.h cram/string_alloc.h cram/pooled_alloc.h htslib/khash.h htslib/kstring.h
167+
cram_samtools_h = cram/cram_samtools.h $(htslib_sam_h) $(cram_sam_header_h)
168+
cram_structs_h = cram/cram_structs.h cram/thread_pool.h cram/string_alloc.h htslib/khash.h
169+
cram_open_trace_file_h = cram/open_trace_file.h cram/mFILE.h
170+
hfile_internal_h = hfile_internal.h $(htslib_hfile_h)
171+
172+
bgzf.o bgzf.pico: bgzf.c config.h $(htslib_hts_h) $(htslib_bgzf_h) $(htslib_hfile_h) htslib/khash.h
173+
kstring.o kstring.pico: kstring.c htslib/kstring.h
174+
knetfile.o knetfile.pico: knetfile.c htslib/knetfile.h
175+
hfile.o hfile.pico: hfile.c $(htslib_hfile_h) $(hfile_internal_h)
176+
hfile_net.o hfile_net.pico: hfile_net.c $(hfile_internal_h) htslib/knetfile.h
177+
hts.o hts.pico: hts.c version.h $(htslib_hts_h) $(htslib_bgzf_h) $(cram_h) $(htslib_hfile_h) htslib/khash.h htslib/kseq.h htslib/ksort.h
178+
vcf.o vcf.pico: vcf.c $(htslib_vcf_h) $(htslib_bgzf_h) $(htslib_tbx_h) $(htslib_hfile_h) htslib/khash.h htslib/kseq.h htslib/kstring.h
179+
sam.o sam.pico: sam.c $(htslib_sam_h) $(htslib_bgzf_h) $(cram_h) $(htslib_hfile_h) htslib/khash.h htslib/kseq.h htslib/kstring.h
180+
tbx.o tbx.pico: tbx.c $(htslib_tbx_h) $(htslib_bgzf_h) htslib/khash.h
181+
faidx.o faidx.pico: faidx.c config.h $(htslib_bgzf_h) $(htslib_faidx_h) htslib/khash.h htslib/knetfile.h
182+
synced_bcf_reader.o synced_bcf_reader.pico: synced_bcf_reader.c $(htslib_synced_bcf_reader_h) htslib/kseq.h htslib/khash_str2int.h
183+
vcf_sweep.o vcf_sweep.pico: vcf_sweep.c $(htslib_vcf_sweep_h) $(htslib_bgzf_h)
184+
vcfutils.o vcfutils.pico: vcfutils.c $(htslib_vcfutils_h)
185+
kfunc.o kfunc.pico: kfunc.c htslib/kfunc.h
186+
187+
cram/cram_codecs.o cram/cram_codecs.pico: cram/cram_codecs.c $(cram_h)
188+
cram/cram_decode.o cram/cram_decode.pico: cram/cram_decode.c $(cram_h) cram/os.h cram/md5.h
189+
cram/cram_encode.o cram/cram_encode.pico: cram/cram_encode.c $(cram_h) cram/os.h cram/md5.h
190+
cram/cram_index.o cram/cram_index.pico: cram/cram_index.c $(htslib_hfile_h) $(cram_h) cram/os.h cram/zfio.h
191+
cram/cram_io.o cram/cram_io.pico: cram/cram_io.c $(cram_h) cram/os.h cram/md5.h $(cram_open_trace_file_h) $(htslib_hfile_h)
192+
cram/cram_samtools.o cram/cram_samtools.pico: cram/cram_samtools.c $(cram_h) $(htslib_sam_h)
193+
cram/cram_stats.o cram/cram_stats.pico: cram/cram_stats.c $(cram_h) cram/os.h
194+
cram/files.o cram/files.pico: cram/files.c $(cram_misc_h)
195+
cram/mFILE.o cram/mFILE.pico: cram/mFILE.c cram/os.h cram/mFILE.h cram/vlen.h
196+
cram/md5.o cram/md5.pico: cram/md5.c cram/md5.h
197+
cram/open_trace_file.o cram/open_trace_file.pico: cram/open_trace_file.c $(cram_open_trace_file_h) $(cram_misc_h)
198+
cram/pooled_alloc.o cram/pooled_alloc.pico: cram/pooled_alloc.c cram/pooled_alloc.h
199+
cram/sam_header.o cram/sam_header.pico: cram/sam_header.c $(cram_sam_header_h) cram/string_alloc.h
200+
cram/string_alloc.o cram/string_alloc.pico: cram/string_alloc.c cram/string_alloc.h
201+
cram/thread_pool.o cram/thread_pool.pico: cram/thread_pool.c cram/thread_pool.h
202+
cram/vlen.o cram/vlen.pico: cram/vlen.c cram/vlen.h cram/os.h
203+
cram/zfio.o cram/zfio.pico: cram/zfio.c cram/os.h cram/zfio.h
204+
205+
206+
bgzip: bgzip.o libhts.a
207+
$(CC) -pthread $(LDFLAGS) -o $@ bgzip.o libhts.a $(LDLIBS) -lz
208+
209+
tabix: tabix.o libhts.a
210+
$(CC) -pthread $(LDFLAGS) -o $@ tabix.o libhts.a $(LDLIBS) -lz
211+
212+
bgzip.o: bgzip.c $(htslib_bgzf_h) $(htslib_hts_h)
213+
tabix.o: tabix.c $(htslib_tbx_h) $(htslib_sam_h) $(htslib_vcf_h) htslib/kseq.h $(htslib_bgzf_h) $(htslib_hts_h)
214+
215+
216+
check test: $(BUILT_TEST_PROGRAMS)
217+
test/fieldarith test/fieldarith.sam
218+
test/hfile
219+
test/sam
220+
cd test && ./test_view.pl
221+
cd test && ./test.pl
222+
223+
test/fieldarith: test/fieldarith.o libhts.a
224+
$(CC) -pthread $(LDFLAGS) -o $@ test/fieldarith.o libhts.a $(LDLIBS) -lz
225+
226+
test/hfile: test/hfile.o libhts.a
227+
$(CC) $(LDFLAGS) -o $@ test/hfile.o libhts.a $(LDLIBS) -lz
228+
229+
test/sam: test/sam.o libhts.a
230+
$(CC) -pthread $(LDFLAGS) -o $@ test/sam.o libhts.a $(LDLIBS) -lz
231+
232+
test/test_view: test/test_view.o libhts.a
233+
$(CC) -pthread $(LDFLAGS) -o $@ test/test_view.o libhts.a $(LDLIBS) -lz
234+
235+
test/test-vcf-api: test/test-vcf-api.o libhts.a
236+
$(CC) -pthread $(LDFLAGS) -o $@ test/test-vcf-api.o libhts.a $(LDLIBS) -lz
237+
238+
test/test-vcf-sweep: test/test-vcf-sweep.o libhts.a
239+
$(CC) -pthread $(LDFLAGS) -o $@ test/test-vcf-sweep.o libhts.a $(LDLIBS) -lz
240+
241+
test/fieldarith.o: test/fieldarith.c $(htslib_sam_h)
242+
test/hfile.o: test/hfile.c $(htslib_hfile_h) $(htslib_hts_defs_h)
243+
test/sam.o: test/sam.c $(htslib_sam_h) htslib/kstring.h
244+
test/test_view.o: test/test_view.c $(cram_h) $(htslib_sam_h)
245+
test/test-vcf-api.o: test/test-vcf-api.c $(htslib_hts_h) $(htslib_vcf_h) htslib/kstring.h
246+
test/test-vcf-sweep.o: test/test-vcf-sweep.c $(htslib_vcf_sweep_h)
247+
248+
249+
install: installdirs install-$(SHLIB_FLAVOUR)
250+
$(INSTALL_PROGRAM) $(BUILT_PROGRAMS) $(DESTDIR)$(bindir)
251+
$(INSTALL_DATA) htslib/*.h $(DESTDIR)$(includedir)/htslib
252+
$(INSTALL_DATA) libhts.a $(DESTDIR)$(libdir)/libhts.a
253+
$(INSTALL_DATA) *.1 $(DESTDIR)$(man1dir)
254+
$(INSTALL_DATA) *.5 $(DESTDIR)$(man5dir)
255+
256+
installdirs:
257+
mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)/htslib $(DESTDIR)$(libdir) $(DESTDIR)$(man1dir) $(DESTDIR)$(man5dir)
258+
259+
# After installation, the real file in $(libdir) will be libhts.so.X.Y.Z,
260+
# with symlinks libhts.so (used via -lhts during linking of client programs)
261+
# and libhts.so.NN (used by client executables at runtime).
262+
263+
install-so: libhts.so installdirs
264+
$(INSTALL_DATA) libhts.so $(DESTDIR)$(libdir)/libhts.so.$(PACKAGE_VERSION)
265+
ln -sf libhts.so.$(PACKAGE_VERSION) $(DESTDIR)$(libdir)/libhts.so
266+
ln -sf libhts.so.$(PACKAGE_VERSION) $(DESTDIR)$(libdir)/libhts.so.$(LIBHTS_SOVERSION)
267+
268+
install-dylib: libhts.dylib installdirs
269+
$(INSTALL_PROGRAM) libhts.dylib $(DESTDIR)$(libdir)/libhts.$(PACKAGE_VERSION).dylib
270+
ln -sf libhts.$(PACKAGE_VERSION).dylib $(DESTDIR)$(libdir)/libhts.dylib
271+
ln -sf libhts.$(PACKAGE_VERSION).dylib $(DESTDIR)$(libdir)/libhts.$(LIBHTS_SOVERSION).dylib
272+
273+
274+
testclean:
275+
-rm -f test/*.tmp test/*.tmp.*
276+
277+
mostlyclean: testclean
278+
-rm -f *.o *.pico cram/*.o cram/*.pico test/*.o test/*.dSYM version.h
279+
280+
clean: mostlyclean clean-$(SHLIB_FLAVOUR)
281+
-rm -f libhts.a $(BUILT_PROGRAMS) $(BUILT_TEST_PROGRAMS)
282+
283+
distclean: clean
284+
-rm -f TAGS
285+
286+
clean-so:
287+
-rm -f libhts.so libhts.so.*
288+
289+
clean-dylib:
290+
-rm -f libhts.dylib libhts.*.dylib
291+
292+
293+
tags:
294+
ctags -f TAGS *.[ch] cram/*.[ch] htslib/*.h
295+
296+
297+
force:
298+
299+
300+
.PHONY: all check clean distclean force install installdirs
301+
.PHONY: lib-shared lib-static mostlyclean tags test testclean
302+
.PHONY: clean-so install-so
303+
.PHONY: clean-dylib install-dylib

0 commit comments

Comments
 (0)