@@ -76,7 +76,8 @@ BUILT_TEST_PROGRAMS = \
7676 test/test_view \
7777 test/test-vcf-api \
7878 test/test-vcf-sweep \
79- test/test-bcf-sr
79+ test/test-bcf-sr \
80+ test/test-bcf-translate
8081
8182BUILT_THRASH_PROGRAMS = \
8283 test/thrash_threads1 \
@@ -91,42 +92,27 @@ all: lib-static lib-shared $(BUILT_PROGRAMS) plugins $(BUILT_TEST_PROGRAMS)
9192HTSPREFIX =
9293include htslib_vars.mk
9394
94-
95- PACKAGE_VERSION = 1.5
95+ # If not using GNU make, you need to copy the version number from version.sh
96+ # into here.
97+ PACKAGE_VERSION := $(shell ./version.sh)
9698LIBHTS_SOVERSION = 2
9799
98-
99100# $(NUMERIC_VERSION) is for items that must have a numeric X.Y.Z string
100101# even if this is a dirty or untagged Git working tree.
101- NUMERIC_VERSION = $(PACKAGE_VERSION )
102-
103- # If building from a Git repository, replace $(PACKAGE_VERSION) with the Git
104- # description of the working tree: either a release tag with the same value
105- # as $(PACKAGE_VERSION) above, or an exact description likely based on a tag.
106- # Much of this is also GNU Make-specific. If you don't have GNU Make and/or
107- # are not building from a Git repository, comment out this conditional.
108- ifneq "$(wildcard .git) " ""
109- original_version := $(PACKAGE_VERSION )
110- PACKAGE_VERSION := $(shell git describe --always --dirty)
111-
112- # Unless the Git description matches /\d*\.\d*(\.\d*)?/, i.e., is exactly a tag
113- # with a numeric name, revert $(NUMERIC_VERSION) to the original version number
114- # written above, but with the patchlevel field bumped to 255.
115- ifneq "$(subst ..,.,$(subst 0,,$(subst 1,,$(subst 2,,$(subst 3,,$(subst 4,,$(subst 5,,$(subst 6,,$(subst 7,,$(subst 8,,$(subst 9,,$(PACKAGE_VERSION ) ) ) ) ) ) ) ) ) ) ) ) " "."
116- empty :=
117- NUMERIC_VERSION := $(subst $(empty ) ,.,$(wordlist 1,2,$(subst ., ,$(original_version ) ) ) 255)
118- endif
102+ NUMERIC_VERSION := $(shell ./version.sh numeric)
119103
120104# Force version.h to be remade if $(PACKAGE_VERSION) has changed.
121105version.h : $(if $(wildcard version.h) ,$(if $(findstring "$(PACKAGE_VERSION ) ",$(shell cat version.h) ) ,,force) )
122- endif
123106
124107version.h :
125108 echo ' #define HTS_VERSION "$(PACKAGE_VERSION)"' > $@
126109
127110print-version :
128111 @echo $(PACKAGE_VERSION )
129112
113+ show-version :
114+ @echo PACKAGE_VERSION = $(PACKAGE_VERSION )
115+ @echo NUMERIC_VERSION = $(NUMERIC_VERSION )
130116
131117.SUFFIXES : .bundle .c .cygdll .dll .o .pico .so
132118
@@ -148,6 +134,7 @@ LIBHTS_OBJS = \
148134 hfile.o \
149135 hfile_net.o \
150136 hts.o \
137+ hts_os.o\
151138 md5.o \
152139 multipart.o \
153140 probaln.o \
@@ -208,6 +195,8 @@ config.h:
208195 echo ' /* Default config.h generated by Makefile */' > $@
209196 echo ' #define HAVE_LIBBZ2 1' >> $@
210197 echo ' #define HAVE_LIBLZMA 1' >> $@
198+ echo ' #define HAVE_FSEEKO 1' >> $@
199+ echo ' #define HAVE_DRAND48 1' >> $@
211200
212201# And similarly for htslib.pc.tmp ("pkg-config template"). No dependency
213202# on htslib.pc.in listed, as if that file is newer the usual way to regenerate
@@ -235,6 +224,9 @@ lib-shared: libhts.dylib
235224else ifeq "$(findstring CYGWIN,$(PLATFORM))" "CYGWIN"
236225SHLIB_FLAVOUR = cygdll
237226lib-shared : cyghts-$(LIBHTS_SOVERSION ) .dll
227+ else ifeq "$(findstring MSYS,$(PLATFORM))" "MSYS"
228+ SHLIB_FLAVOUR = dll
229+ lib-shared : hts-$(LIBHTS_SOVERSION ) .dll
238230else
239231SHLIB_FLAVOUR = so
240232lib-shared : libhts.so
@@ -276,6 +268,9 @@ libhts.dylib: $(LIBHTS_OBJS)
276268cyghts-$(LIBHTS_SOVERSION ) .dll : $(LIBHTS_OBJS )
277269 $(CC ) -shared -Wl,--out-implib=libhts.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import $(LDFLAGS ) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS ) -Wl,--no-whole-archive $(LIBS ) -lpthread
278270
271+ hts-$(LIBHTS_SOVERSION ) .dll : $(LIBHTS_OBJS )
272+ $(CC ) -shared -Wl,--out-implib=hts.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import $(LDFLAGS ) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS ) -Wl,--no-whole-archive $(LIBS ) -lpthread
273+
279274
280275.pico.so :
281276 $(CC ) -shared -Wl,-E $(LDFLAGS ) -o $@ $< $(LIBS ) -lpthread
@@ -286,6 +281,9 @@ cyghts-$(LIBHTS_SOVERSION).dll: $(LIBHTS_OBJS)
286281.o.cygdll :
287282 $(CC ) -shared $(LDFLAGS ) -o $@ $< libhts.dll.a $(LIBS )
288283
284+ .o.dll :
285+ $(CC ) -shared $(LDFLAGS ) -o $@ $< hts.dll.a $(LIBS )
286+
289287
290288bgzf.o bgzf.pico : bgzf.c config.h $(htslib_hts_h ) $(htslib_bgzf_h ) $(htslib_hfile_h ) $(htslib_thread_pool_h ) cram/pooled_alloc.h $(htslib_khash_h )
291289errmod.o errmod.pico : errmod.c config.h $(htslib_hts_h ) $(htslib_ksort_h )
@@ -348,6 +346,9 @@ tabix.o: tabix.c config.h $(htslib_tbx_h) $(htslib_sam_h) $(htslib_vcf_h) $(htsl
348346
349347# For tests that might use it, set $REF_PATH explicitly to use only reference
350348# areas within the test suite (or set it to ':' to use no reference areas).
349+ #
350+ # If using MSYS, avoid poor shell expansion via:
351+ # MSYS2_ARG_CONV_EXCL="*" make check
351352check test : $(BUILT_PROGRAMS ) $(BUILT_TEST_PROGRAMS )
352353 test/hts_endian
353354 test/fieldarith test/fieldarith.sam
@@ -356,7 +357,7 @@ check test: $(BUILT_PROGRAMS) $(BUILT_TEST_PROGRAMS)
356357 cd test/tabix && ./test-tabix.sh tabix.tst
357358 REF_PATH=: test/sam test/ce.fa test/faidx.fa
358359 test/test-regidx
359- cd test && REF_PATH=: ./test.pl
360+ cd test && REF_PATH=: ./test.pl $$ {TEST_OPTS:-}
360361
361362test/hts_endian : test/hts_endian.o
362363 $(CC ) $(LDFLAGS ) -o $@ test/hts_endian.o $(LIBS )
@@ -388,6 +389,9 @@ test/test-vcf-sweep: test/test-vcf-sweep.o libhts.a
388389test/test-bcf-sr : test/test-bcf-sr.o libhts.a
389390 $(CC ) $(LDFLAGS ) -o $@ test/test-bcf-sr.o libhts.a -lz $(LIBS ) -lpthread
390391
392+ test/test-bcf-translate : test/test-bcf-translate.o libhts.a
393+ $(CC ) $(LDFLAGS ) -o $@ test/test-bcf-translate.o libhts.a -lz $(LIBS ) -lpthread
394+
391395test/hts_endian.o : test/hts_endian.c $(htslib_hts_endian_h )
392396test/fieldarith.o : test/fieldarith.c config.h $(htslib_sam_h )
393397test/hfile.o : test/hfile.c config.h $(htslib_hfile_h ) $(htslib_hts_defs_h )
@@ -398,6 +402,7 @@ test/test_view.o: test/test_view.c config.h $(cram_h) $(htslib_sam_h)
398402test/test-vcf-api.o : test/test-vcf-api.c config.h $(htslib_hts_h ) $(htslib_vcf_h ) $(htslib_kstring_h ) $(htslib_kseq_h )
399403test/test-vcf-sweep.o : test/test-vcf-sweep.c config.h $(htslib_vcf_sweep_h )
400404test/test-bcf-sr.o : test/test-bcf-sr.c config.h $(htslib_vcf_sweep_h ) bcf_sr_sort.h
405+ test/test-bcf-translate.o : test/test-bcf-translate.c config.h
401406
402407
403408test/thrash_threads1 : test/thrash_threads1.o libhts.a
@@ -446,6 +451,10 @@ install-cygdll: cyghts-$(LIBHTS_SOVERSION).dll installdirs
446451 $(INSTALL_PROGRAM ) cyghts-$(LIBHTS_SOVERSION ) .dll $(DESTDIR )$(bindir ) /cyghts-$(LIBHTS_SOVERSION ) .dll
447452 $(INSTALL_PROGRAM ) libhts.dll.a $(DESTDIR )$(libdir ) /libhts.dll.a
448453
454+ install-dll : hts-$(LIBHTS_SOVERSION ) .dll installdirs
455+ $(INSTALL_PROGRAM ) hts-$(LIBHTS_SOVERSION ) .dll $(DESTDIR )$(bindir ) /hts-$(LIBHTS_SOVERSION ) .dll
456+ $(INSTALL_PROGRAM ) hts.dll.a $(DESTDIR )$(libdir ) /hts.dll.a
457+
449458install-dylib : libhts.dylib installdirs
450459 $(INSTALL_PROGRAM ) libhts.dylib $(DESTDIR )$(libdir ) /libhts.$(PACKAGE_VERSION ) .dylib
451460 ln -sf libhts.$(PACKAGE_VERSION ) .dylib $(DESTDIR )$(libdir ) /libhts.dylib
@@ -483,6 +492,9 @@ clean-so:
483492clean-cygdll :
484493 -rm -f cyghts-* .dll libhts.dll.a
485494
495+ clean-dll :
496+ -rm -f hts-* .dll hts.dll.a
497+
486498clean-dylib :
487499 -rm -f libhts.dylib libhts.* .dylib
488500
@@ -498,7 +510,8 @@ tags TAGS:
498510# (The wildcards attempt to omit non-exported files (.git*, README.md,
499511# etc) and other detritus that might be in the top-level directory.)
500512distdir :
501- tar -c * .[ch15] [ILMNRcht]* [ELSbcekmnt] | (cd $( distdir) && tar -x)
513+ @if [ -z " $( distdir) " ]; then echo " Please supply a distdir=DIR argument." ; false ; fi
514+ tar -c * .[ch15] [ILMNRchtv]* [ELSbcekmnth] | (cd $( distdir) && tar -x)
502515 +cd $(distdir ) && $(MAKE ) distclean
503516
504517force :
@@ -507,7 +520,8 @@ force:
507520.PHONY : all check clean distclean distdir force
508521.PHONY : install install-pkgconfig installdirs lib-shared lib-static
509522.PHONY : maintainer-clean mostlyclean plugins print-config print-version
510- .PHONY : tags test testclean
523+ .PHONY : show-version tags test testclean
511524.PHONY : clean-so install-so
512525.PHONY : clean-cygdll install-cygdll
526+ .PHONY : clean-dll install-dll
513527.PHONY : clean-dylib install-dylib
0 commit comments