@@ -37,6 +37,7 @@ CPPFLAGS =
3737# CFLAGS = -g -Wall -O2 -pedantic -std=c99 -D_XOPEN_SOURCE=600
3838CFLAGS = -g -Wall -O2 -fvisibility=hidden
3939EXTRA_CFLAGS_PIC = -fpic
40+ TARGET_CFLAGS =
4041LDFLAGS = -fvisibility=hidden
4142LIBS = $(htslib_default_libs )
4243
@@ -85,6 +86,7 @@ BUILT_TEST_PROGRAMS = \
8586 test/test_realn \
8687 test/test-regidx \
8788 test/test_str2int \
89+ test/test_time_funcs \
8890 test/test_view \
8991 test/test_index \
9092 test/test-vcf-api \
@@ -93,7 +95,8 @@ BUILT_TEST_PROGRAMS = \
9395 test/fuzz/hts_open_fuzzer.o \
9496 test/test-bcf-translate \
9597 test/test-parse-reg \
96- test/test_introspection
98+ test/test_introspection \
99+ test/test-bcf_set_variant_type
97100
98101BUILT_THRASH_PROGRAMS = \
99102 test/thrash_threads1 \
@@ -114,10 +117,16 @@ ALL_CPPFLAGS = -I. $(CPPFLAGS)
114117htscodecs.mk :
115118 echo ' # Default htscodecs.mk generated by Makefile' > $@
116119 echo ' include $$(HTSPREFIX)htscodecs_bundled.mk' >> $@
120+ $(srcdir ) /hts_probe_cc.sh ' $(CC)' ' $(CFLAGS) $(CPPFLAGS)' ' $(LDFLAGS)' >> $@
117121
118122srcdir = .
119123srcprefix =
120124HTSPREFIX =
125+
126+ HTS_CFLAGS_AVX2 =
127+ HTS_CFLAGS_AVX512 =
128+ HTS_CFLAGS_SSE4 =
129+
121130include htslib_vars.mk
122131include htscodecs.mk
123132
@@ -131,8 +140,8 @@ LIBHTS_SOVERSION = 3
131140# is not strictly necessary and should be removed the next time
132141# LIBHTS_SOVERSION is bumped (see #1144 and
133142# https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html#//apple_ref/doc/uid/TP40002013-SW23)
134- MACH_O_COMPATIBILITY_VERSION = 3.1.15
135- MACH_O_CURRENT_VERSION = 3.1.15
143+ MACH_O_COMPATIBILITY_VERSION = 3.1.16
144+ MACH_O_CURRENT_VERSION = 3.1.16
136145
137146# $(NUMERIC_VERSION) is for items that must have a numeric X.Y.Z string
138147# even if this is a dirty or untagged Git working tree.
@@ -161,10 +170,10 @@ config_vars.h:
161170.SUFFIXES : .bundle .c .cygdll .dll .o .pico .so
162171
163172.c.o :
164- $(CC ) $(CFLAGS ) $(ALL_CPPFLAGS ) -c -o $@ $<
173+ $(CC ) $(CFLAGS ) $(TARGET_CFLAGS ) $( ALL_CPPFLAGS ) -c -o $@ $<
165174
166175.c.pico :
167- $(CC ) $(CFLAGS ) $(ALL_CPPFLAGS ) $(EXTRA_CFLAGS_PIC ) -c -o $@ $<
176+ $(CC ) $(CFLAGS ) $(TARGET_CFLAGS ) $( ALL_CPPFLAGS ) $(EXTRA_CFLAGS_PIC ) -c -o $@ $<
168177
169178
170179LIBHTS_OBJS = \
@@ -226,6 +235,7 @@ bcf_sr_sort_h = bcf_sr_sort.h $(htslib_synced_bcf_reader_h) $(htslib_kbitset_h)
226235header_h = header.h cram/string_alloc.h cram/pooled_alloc.h $(htslib_khash_h ) $(htslib_kstring_h ) $(htslib_sam_h )
227236hfile_internal_h = hfile_internal.h $(htslib_hts_defs_h ) $(htslib_hfile_h ) $(textutils_internal_h )
228237hts_internal_h = hts_internal.h $(htslib_hts_h ) $(textutils_internal_h )
238+ hts_time_funcs_h = hts_time_funcs.h
229239sam_internal_h = sam_internal.h $(htslib_sam_h )
230240textutils_internal_h = textutils_internal.h $(htslib_kstring_h )
231241thread_pool_internal_h = thread_pool_internal.h $(htslib_thread_pool_h )
@@ -253,6 +263,20 @@ config.h:
253263 echo ' #endif' >> $@
254264 echo ' #define HAVE_DRAND48 1' >> $@
255265 echo ' #define HAVE_LIBCURL 1' >> $@
266+ if [ " x$( HTS_CFLAGS_SSE4) " != " x" ] ; then \
267+ echo ' #define HAVE_POPCNT 1' >> $@ ; \
268+ echo ' #define HAVE_SSE4_1 1' >> $@ ; \
269+ echo ' #define HAVE_SSSE3 1' >> $@ ; \
270+ echo ' #if defined(HTS_ALLOW_UNALIGNED) && HTS_ALLOW_UNALIGNED == 0' >> $@ ; \
271+ echo ' #define UBSAN 1' >> $@ ; \
272+ echo ' #endif' >> $@ ; \
273+ fi
274+ if [ " x$( HTS_CFLAGS_AVX2) " != " x" ] ; then \
275+ echo ' #define HAVE_AVX2 1' >> $@ ; \
276+ fi
277+ if [ " x$( HTS_CFLAGS_AVX512) " != " x" ] ; then \
278+ echo ' #define HAVE_AVX512 1' >> $@ ; \
279+ fi
256280
257281# And similarly for htslib.pc.tmp ("pkg-config template"). No dependency
258282# on htslib.pc.in listed, as if that file is newer the usual way to regenerate
@@ -293,6 +317,9 @@ endif
293317
294318BUILT_PLUGINS = $(PLUGIN_OBJS:.o=$(PLUGIN_EXT ) )
295319
320+ ifneq "$(BUILT_PLUGINS ) " ""
321+ plugins : lib-shared
322+ endif
296323plugins : $(BUILT_PLUGINS )
297324
298325
@@ -302,6 +329,10 @@ libhts.a: $(LIBHTS_OBJS)
302329 -$(RANLIB ) $@
303330
304331print-config :
332+ @echo HTS_CFLAGS_AVX2 = $(HTS_CFLAGS_AVX2 )
333+ @echo HTS_CFLAGS_AVX512 = $(HTS_CFLAGS_AVX512 )
334+ @echo HTS_CFLAGS_SSE4 = $(HTS_CFLAGS_SSE4 )
335+ @echo HTS_HAVE_NEON = $(HTS_HAVE_NEON )
305336 @echo LDFLAGS = $(LDFLAGS )
306337 @echo LIBHTS_OBJS = $(LIBHTS_OBJS )
307338 @echo LIBS = $(LIBS )
@@ -399,9 +430,9 @@ hfile.o hfile.pico: hfile.c config.h $(htslib_hfile_h) $(hfile_internal_h) $(hts
399430hfile_gcs.o hfile_gcs.pico : hfile_gcs.c config.h $(htslib_hts_h ) $(htslib_kstring_h ) $(hfile_internal_h )
400431hfile_libcurl.o hfile_libcurl.pico : hfile_libcurl.c config.h $(hfile_internal_h ) $(htslib_hts_h ) $(htslib_kstring_h ) $(htslib_khash_h )
401432hfile_s3_write.o hfile_s3_write.pico : hfile_s3_write.c config.h $(hfile_internal_h ) $(htslib_hts_h ) $(htslib_kstring_h ) $(htslib_khash_h )
402- hfile_s3.o hfile_s3.pico : hfile_s3.c config.h $(hfile_internal_h ) $(htslib_hts_h ) $(htslib_kstring_h )
433+ hfile_s3.o hfile_s3.pico : hfile_s3.c config.h $(hfile_internal_h ) $(htslib_hts_h ) $(htslib_kstring_h ) $( hts_time_funcs_h )
403434hts.o hts.pico : hts.c config.h os/lzma_stub.h $(htslib_hts_h ) $(htslib_bgzf_h ) $(cram_h ) $(htslib_hfile_h ) $(htslib_hts_endian_h ) version.h config_vars.h $(hts_internal_h ) $(hfile_internal_h ) $(sam_internal_h ) $(htslib_hts_expr_h ) $(htslib_hts_os_h ) $(htslib_khash_h ) $(htslib_kseq_h ) $(htslib_ksort_h ) $(htslib_tbx_h ) $(htscodecs_htscodecs_h )
404- hts_expr.o hts_expr.pico : hts_expr.c config.h $(htslib_hts_expr_h ) $(textutils_internal_h )
435+ hts_expr.o hts_expr.pico : hts_expr.c config.h $(htslib_hts_expr_h ) $(htslib_hts_log_h ) $( textutils_internal_h )
405436hts_os.o hts_os.pico : hts_os.c config.h $(htslib_hts_defs_h ) os/rand.c
406437vcf.o vcf.pico : vcf.c config.h $(htslib_vcf_h ) $(htslib_bgzf_h ) $(htslib_tbx_h ) $(htslib_hfile_h ) $(hts_internal_h ) $(htslib_khash_str2int_h ) $(htslib_kstring_h ) $(htslib_sam_h ) $(htslib_khash_h ) $(htslib_kseq_h ) $(htslib_hts_endian_h )
407438sam.o sam.pico : sam.c config.h $(htslib_hts_defs_h ) $(htslib_sam_h ) $(htslib_bgzf_h ) $(cram_h ) $(hts_internal_h ) $(sam_internal_h ) $(htslib_hfile_h ) $(htslib_hts_endian_h ) $(htslib_hts_expr_h ) $(header_h ) $(htslib_khash_h ) $(htslib_kseq_h ) $(htslib_kstring_h )
@@ -423,7 +454,7 @@ textutils.o textutils.pico: textutils.c config.h $(htslib_hfile_h) $(htslib_kstr
423454
424455cram/cram_codecs.o cram/cram_codecs.pico : cram/cram_codecs.c config.h $(htslib_hts_endian_h ) $(htscodecs_varint_h ) $(htscodecs_pack_h ) $(htscodecs_rle_h ) $(cram_h )
425456cram/cram_decode.o cram/cram_decode.pico : cram/cram_decode.c config.h $(cram_h ) $(cram_os_h ) $(htslib_hts_h )
426- cram/cram_encode.o cram/cram_encode.pico : cram/cram_encode.c config.h $(cram_h ) $(cram_os_h ) $(sam_internal_h ) $(htslib_hts_h ) $(htslib_hts_endian_h )
457+ cram/cram_encode.o cram/cram_encode.pico : cram/cram_encode.c config.h $(cram_h ) $(cram_os_h ) $(sam_internal_h ) $(htslib_hts_h ) $(htslib_hts_endian_h ) $( textutils_internal_h )
427458cram/cram_external.o cram/cram_external.pico : cram/cram_external.c config.h $(htslib_hfile_h ) $(cram_h )
428459cram/cram_index.o cram/cram_index.pico : cram/cram_index.c config.h $(htslib_bgzf_h ) $(htslib_hfile_h ) $(hts_internal_h ) $(cram_h ) $(cram_os_h )
429460cram/cram_io.o cram/cram_io.pico : cram/cram_io.c config.h os/lzma_stub.h $(cram_h ) $(cram_os_h ) $(htslib_hts_h ) $(cram_open_trace_file_h ) $(htscodecs_rANS_static_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_arith_dynamic_h ) $(htscodecs_tokenise_name3_h ) $(htscodecs_fqzcomp_qual_h ) $(htscodecs_varint_h ) $(htslib_hfile_h ) $(htslib_bgzf_h ) $(htslib_faidx_h ) $(hts_internal_h )
@@ -435,14 +466,24 @@ cram/string_alloc.o cram/string_alloc.pico: cram/string_alloc.c config.h cram/st
435466thread_pool.o thread_pool.pico : thread_pool.c config.h $(thread_pool_internal_h ) $(htslib_hts_log_h )
436467
437468htscodecs/htscodecs/arith_dynamic.o htscodecs/htscodecs/arith_dynamic.pico : htscodecs/htscodecs/arith_dynamic.c config.h $(htscodecs_arith_dynamic_h ) $(htscodecs_varint_h ) $(htscodecs_pack_h ) $(htscodecs_utils_h ) $(htscodecs_c_simple_model_h )
438- htscodecs/htscodecs/fqzcomp_qual.o htscodecs/htscodecs/fqzcomp_qual.pico : htscodecs/htscodecs/fqzcomp_qual.c config.h $(htscodecs_fqzcomp_qual_h ) $(htscodecs_varint_h ) $(htscodecs_c_simple_model_h )
469+ htscodecs/htscodecs/fqzcomp_qual.o htscodecs/htscodecs/fqzcomp_qual.pico : htscodecs/htscodecs/fqzcomp_qual.c config.h $(htscodecs_fqzcomp_qual_h ) $(htscodecs_varint_h ) $(htscodecs_utils_h ) $( htscodecs_c_simple_model_h )
439470htscodecs/htscodecs/htscodecs.o htscodecs/htscodecs/htscodecs.pico : htscodecs/htscodecs/htscodecs.c $(htscodecs_htscodecs_h ) $(htscodecs_version_h )
440471htscodecs/htscodecs/pack.o htscodecs/htscodecs/pack.pico : htscodecs/htscodecs/pack.c config.h $(htscodecs_pack_h )
441- htscodecs/htscodecs/rANS_static4x16pr.o htscodecs/htscodecs/rANS_static4x16pr.pico : htscodecs/htscodecs/rANS_static4x16pr.c config.h $(htscodecs_rANS_word_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_varint_h ) $(htscodecs_pack_h ) $(htscodecs_rle_h ) $(htscodecs_utils_h )
472+ htscodecs/htscodecs/rANS_static32x16pr.o htscodecs/htscodecs/rANS_static32x16pr.pico : htscodecs/htscodecs/rANS_static32x16pr.c config.h $(htscodecs_rANS_word_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_rANS_static16_int_h ) $(htscodecs_varint_h ) $(htscodecs_utils_h )
473+ htscodecs/htscodecs/rANS_static32x16pr_avx2.o htscodecs/htscodecs/rANS_static32x16pr_avx2.pico : htscodecs/htscodecs/rANS_static32x16pr_avx2.c config.h $(htscodecs_rANS_word_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_rANS_static16_int_h ) $(htscodecs_varint_h ) $(htscodecs_utils_h ) $(htscodecs_permute_h )
474+ htscodecs/htscodecs/rANS_static32x16pr_avx512.o htscodecs/htscodecs/rANS_static32x16pr_avx512.pico : htscodecs/htscodecs/rANS_static32x16pr_avx512.c config.h $(htscodecs_rANS_word_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_rANS_static16_int_h ) $(htscodecs_varint_h ) $(htscodecs_utils_h )
475+ htscodecs/htscodecs/rANS_static32x16pr_neon.o htscodecs/htscodecs/rANS_static32x16pr_neon.pico : htscodecs/htscodecs/rANS_static32x16pr_neon.c config.h $(htscodecs_rANS_word_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_rANS_static16_int_h ) $(htscodecs_varint_h ) $(htscodecs_utils_h )
476+ htscodecs/htscodecs/rANS_static32x16pr_sse4.o htscodecs/htscodecs/rANS_static32x16pr_sse4.pico : htscodecs/htscodecs/rANS_static32x16pr_sse4.c config.h $(htscodecs_rANS_word_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_rANS_static16_int_h ) $(htscodecs_varint_h ) $(htscodecs_utils_h )
477+ htscodecs/htscodecs/rANS_static4x16pr.o htscodecs/htscodecs/rANS_static4x16pr.pico : htscodecs/htscodecs/rANS_static4x16pr.c config.h $(htscodecs_rANS_word_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_rANS_static16_int_h ) $(htscodecs_pack_h ) $(htscodecs_rle_h ) $(htscodecs_utils_h ) $(htscodecs_rANS_static32x16pr_h )
442478htscodecs/htscodecs/rANS_static.o htscodecs/htscodecs/rANS_static.pico : htscodecs/htscodecs/rANS_static.c config.h $(htscodecs_rANS_byte_h ) $(htscodecs_utils_h ) $(htscodecs_rANS_static_h )
443479htscodecs/htscodecs/rle.o htscodecs/htscodecs/rle.pico : htscodecs/htscodecs/rle.c config.h $(htscodecs_varint_h ) $(htscodecs_rle_h )
444- htscodecs/htscodecs/tokenise_name3.o htscodecs/htscodecs/tokenise_name3.pico : htscodecs/htscodecs/tokenise_name3.c config.h $(htscodecs_pooled_alloc_h ) $(htscodecs_arith_dynamic_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_tokenise_name3_h ) $(htscodecs_varint_h )
480+ htscodecs/htscodecs/tokenise_name3.o htscodecs/htscodecs/tokenise_name3.pico : htscodecs/htscodecs/tokenise_name3.c config.h $(htscodecs_pooled_alloc_h ) $(htscodecs_arith_dynamic_h ) $(htscodecs_rANS_static4x16_h ) $(htscodecs_tokenise_name3_h ) $(htscodecs_varint_h ) $(htscodecs_utils_h )
481+ htscodecs/htscodecs/utils.o htscodecs/htscodecs/utils.pico : htscodecs/htscodecs/utils.c config.h $(htscodecs_utils_h )
445482
483+ # Extra CFLAGS for specific files
484+ htscodecs/htscodecs/rANS_static32x16pr_avx2.o htscodecs/htscodecs/rANS_static32x16pr_avx2.pico : TARGET_CFLAGS = $(HTS_CFLAGS_AVX2 )
485+ htscodecs/htscodecs/rANS_static32x16pr_avx512.o htscodecs/htscodecs/rANS_static32x16pr_avx512.pico : TARGET_CFLAGS = $(HTS_CFLAGS_AVX512 )
486+ htscodecs/htscodecs/rANS_static32x16pr_sse4.o htscodecs/htscodecs/rANS_static32x16pr_sse4.pico : TARGET_CFLAGS = $(HTS_CFLAGS_SSE4 )
446487
447488bgzip : bgzip.o libhts.a
448489 $(CC ) $(LDFLAGS ) -o $@ bgzip.o libhts.a $(LIBS ) -lpthread
@@ -525,16 +566,21 @@ SRC = $(srcprefix)
525566#
526567# If using MSYS, avoid poor shell expansion via:
527568# MSYS2_ARG_CONV_EXCL="*" make check
528- check test : $( BUILT_PROGRAMS ) $( BUILT_TEST_PROGRAMS ) $( BUILT_PLUGINS ) $(HTSCODECS_TEST_TARGETS )
569+ check test : all $(HTSCODECS_TEST_TARGETS )
529570 test/hts_endian
530571 test/test_expr
531572 test/test_kfunc
532573 test/test_kstring
533574 test/test_str2int
575+ test/test_time_funcs
534576 test/fieldarith test/fieldarith.sam
535577 test/hfile
536- HTS_PATH=. test/with-shlib.sh test/plugins-dlhts -g ./libhts.$(SHLIB_FLAVOUR )
537- HTS_PATH=. test/with-shlib.sh test/plugins-dlhts -l ./libhts.$(SHLIB_FLAVOUR )
578+ if test " x$( BUILT_PLUGINS) " ! = " x" ; then \
579+ HTS_PATH=. test/with-shlib.sh test/plugins-dlhts -g ./libhts.$(SHLIB_FLAVOUR ) ; \
580+ fi
581+ if test " x$( BUILT_PLUGINS) " ! = " x" ; then \
582+ HTS_PATH=. test/with-shlib.sh test/plugins-dlhts -l ./libhts.$(SHLIB_FLAVOUR ) ; \
583+ fi
538584 test/test_bgzf test/bgziptest.txt
539585 test/test-parse-reg -t test/colons.bam
540586 cd test/sam_filter && ./filter.sh filter.tst
@@ -597,6 +643,9 @@ test/test-parse-reg: test/test-parse-reg.o libhts.a
597643test/test_str2int : test/test_str2int.o libhts.a
598644 $(CC ) $(LDFLAGS ) -o $@ test/test_str2int.o libhts.a $(LIBS ) -lpthread
599645
646+ test/test_time_funcs : test/test_time_funcs.o
647+ $(CC ) $(LDFLAGS ) -o $@ test/test_time_funcs.o
648+
600649test/test_view : test/test_view.o libhts.a
601650 $(CC ) $(LDFLAGS ) -o $@ test/test_view.o libhts.a $(LIBS ) -lpthread
602651
@@ -618,6 +667,9 @@ test/test-bcf-translate: test/test-bcf-translate.o libhts.a
618667test/test_introspection : test/test_introspection.o libhts.a
619668 $(CC ) $(LDFLAGS ) -o $@ test/test_introspection.o libhts.a $(LIBS ) -lpthread
620669
670+ test/test-bcf_set_variant_type : test/test-bcf_set_variant_type.o libhts.a
671+ $(CC ) $(LDFLAGS ) -o $@ test/test-bcf_set_variant_type.o libhts.a $(LIBS ) -lpthread
672+
621673# Extra tests for bundled htscodecs
622674test_htscodecs_rans4x8 : htscodecs/tests/rans4x8
623675 cd htscodecs/tests && srcdir=. && export srcdir && ./rans4x8.test
@@ -685,13 +737,15 @@ test/test-parse-reg.o: test/test-parse-reg.c config.h $(htslib_hts_h) $(htslib_s
685737test/test_realn.o : test/test_realn.c config.h $(htslib_hts_h ) $(htslib_sam_h ) $(htslib_faidx_h )
686738test/test-regidx.o : test/test-regidx.c config.h $(htslib_kstring_h ) $(htslib_regidx_h ) $(htslib_hts_defs_h ) $(textutils_internal_h )
687739test/test_str2int.o : test/test_str2int.c config.h $(textutils_internal_h )
740+ test/test_time_funcs.o : test/test_time_funcs.c config.h $(hts_time_funcs_h )
688741test/test_view.o : test/test_view.c config.h $(cram_h ) $(htslib_sam_h ) $(htslib_vcf_h ) $(htslib_hts_log_h )
689742test/test_index.o : test/test_index.c config.h $(htslib_sam_h ) $(htslib_vcf_h )
690743test/test-vcf-api.o : test/test-vcf-api.c config.h $(htslib_hts_h ) $(htslib_vcf_h ) $(htslib_kstring_h ) $(htslib_kseq_h )
691744test/test-vcf-sweep.o : test/test-vcf-sweep.c config.h $(htslib_vcf_sweep_h )
692745test/test-bcf-sr.o : test/test-bcf-sr.c config.h $(htslib_synced_bcf_reader_h )
693746test/test-bcf-translate.o : test/test-bcf-translate.c config.h $(htslib_vcf_h )
694747test/test_introspection.o : test/test_introspection.c config.h $(htslib_hts_h ) $(htslib_hfile_h )
748+ test/test-bcf_set_variant_type.o : test/test-bcf_set_variant_type.c config.h $(htslib_hts_h ) vcf.c
695749
696750
697751test/thrash_threads1 : test/thrash_threads1.o libhts.a
0 commit comments