1
1
# Makefile for htslib, a C library for high-throughput sequencing data formats.
2
2
#
3
- # Copyright (C) 2013-2022 Genome Research Ltd.
3
+ # Copyright (C) 2013-2023 Genome Research Ltd.
4
4
#
5
5
# Author: John Marshall <[email protected] >
6
6
#
@@ -39,6 +39,7 @@ CFLAGS = -g -Wall -O2 -fvisibility=hidden
39
39
EXTRA_CFLAGS_PIC = -fpic
40
40
TARGET_CFLAGS =
41
41
LDFLAGS = -fvisibility=hidden
42
+ VERSION_SCRIPT_LDFLAGS = -Wl,-version-script,$(srcprefix ) htslib.map
42
43
LIBS = $(htslib_default_libs )
43
44
44
45
prefix = /usr/local
@@ -58,7 +59,8 @@ MKDIR_P = mkdir -p
58
59
INSTALL = install -p
59
60
INSTALL_DATA = $(INSTALL ) -m 644
60
61
INSTALL_DIR = $(MKDIR_P ) -m 755
61
- INSTALL_LIB = $(INSTALL_DATA )
62
+ LIB_PERM = 644
63
+ INSTALL_LIB = $(INSTALL ) -m $(LIB_PERM )
62
64
INSTALL_MAN = $(INSTALL_DATA )
63
65
INSTALL_PROGRAM = $(INSTALL )
64
66
@@ -80,6 +82,7 @@ BUILT_TEST_PROGRAMS = \
80
82
test/sam \
81
83
test/test_bgzf \
82
84
test/test_expr \
85
+ test/test_faidx \
83
86
test/test_kfunc \
84
87
test/test_kstring \
85
88
test/test_mod \
@@ -140,8 +143,8 @@ LIBHTS_SOVERSION = 3
140
143
# is not strictly necessary and should be removed the next time
141
144
# LIBHTS_SOVERSION is bumped (see #1144 and
142
145
# https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html#//apple_ref/doc/uid/TP40002013-SW23)
143
- MACH_O_COMPATIBILITY_VERSION = 3.1.16
144
- MACH_O_CURRENT_VERSION = 3.1.16
146
+ MACH_O_COMPATIBILITY_VERSION = 3.1.17
147
+ MACH_O_CURRENT_VERSION = 3.1.17
145
148
146
149
# $(NUMERIC_VERSION) is for items that must have a numeric X.Y.Z string
147
150
# even if this is a dirty or untagged Git working tree.
@@ -160,12 +163,20 @@ show-version:
160
163
@echo PACKAGE_VERSION = $(PACKAGE_VERSION )
161
164
@echo NUMERIC_VERSION = $(NUMERIC_VERSION )
162
165
166
+ config_vars.h : override escape=$(subst ',\x27,$(subst ",\",$(subst \,\\,$(1 ) ) ) )
167
+ config_vars.h : override hts_cc_escaped=$(call escape,$(CC ) )
168
+ config_vars.h : override hts_cppflags_escaped=$(call escape,$(CPPFLAGS ) )
169
+ config_vars.h : override hts_cflags_escaped=$(call escape,$(CFLAGS ) )
170
+ config_vars.h : override hts_ldflags_escaped=$(call escape,$(LDFLAGS ) )
171
+ config_vars.h : override hts_libs_escaped=$(call escape,$(LIBS ) )
172
+
163
173
config_vars.h :
164
- echo ' #define HTS_CC "$(CC)"' > $@
165
- echo ' #define HTS_CPPFLAGS "$(CPPFLAGS)"' >> $@
166
- echo ' #define HTS_CFLAGS "$(CFLAGS)"' >> $@
167
- echo ' #define HTS_LDFLAGS "$(LDFLAGS)"' >> $@
168
- echo ' #define HTS_LIBS "$(LIBS)"' >> $@
174
+ printf ' #define HTS_CC "%s"\n#define HTS_CPPFLAGS "%s"\n#define HTS_CFLAGS "%s"\n#define HTS_LDFLAGS "%s"\n#define HTS_LIBS "%s"\n' \
175
+ ' $(hts_cc_escaped)' \
176
+ ' $(hts_cppflags_escaped)' \
177
+ ' $(hts_cflags_escaped)' \
178
+ ' $(hts_ldflags_escaped)' \
179
+ ' $(hts_libs_escaped)' > $@
169
180
170
181
.SUFFIXES : .bundle .c .cygdll .dll .o .pico .so
171
182
@@ -344,7 +355,7 @@ print-config:
344
355
# file used at runtime (when $LD_LIBRARY_PATH includes the build directory).
345
356
346
357
libhts.so : $(LIBHTS_OBJS:.o=.pico )
347
- $(CC ) -shared -Wl,-soname,libhts.so.$(LIBHTS_SOVERSION ) $(LDFLAGS ) -o $@ $(LIBHTS_OBJS:.o=.pico ) $(LIBS ) -lpthread
358
+ $(CC ) -shared -Wl,-soname,libhts.so.$(LIBHTS_SOVERSION ) $(VERSION_SCRIPT_LDFLAGS ) $( LDFLAGS ) -o $@ $(LIBHTS_OBJS:.o=.pico ) $(LIBS ) -lpthread
348
359
ln -sf $@ libhts.so.$(LIBHTS_SOVERSION )
349
360
350
361
# Similarly this also creates libhts.NN.dylib as a byproduct, so that programs
@@ -494,7 +505,7 @@ htsfile: htsfile.o libhts.a
494
505
tabix : tabix.o libhts.a
495
506
$(CC ) $(LDFLAGS ) -o $@ tabix.o libhts.a $(LIBS ) -lpthread
496
507
497
- bgzip.o : bgzip.c config.h $(htslib_bgzf_h ) $(htslib_hts_h )
508
+ bgzip.o : bgzip.c config.h $(htslib_bgzf_h ) $(htslib_hts_h ) $( htslib_hfile_h )
498
509
htsfile.o : htsfile.c config.h $(htslib_hfile_h ) $(htslib_hts_h ) $(htslib_sam_h ) $(htslib_vcf_h )
499
510
tabix.o : tabix.c config.h $(htslib_tbx_h ) $(htslib_sam_h ) $(htslib_vcf_h ) $(htslib_kseq_h ) $(htslib_bgzf_h ) $(htslib_hts_h ) $(htslib_regidx_h ) $(htslib_hts_defs_h ) $(htslib_hts_log_h )
500
511
@@ -583,12 +594,13 @@ check test: all $(HTSCODECS_TEST_TARGETS)
583
594
fi
584
595
test/test_bgzf test/bgziptest.txt
585
596
test/test-parse-reg -t test/colons.bam
597
+ cd test/faidx && ./test-faidx.sh faidx.tst
586
598
cd test/sam_filter && ./filter.sh filter.tst
587
599
cd test/tabix && ./test-tabix.sh tabix.tst
588
600
cd test/mpileup && ./test-pileup.sh mpileup.tst
589
601
cd test/fastq && ./test-fastq.sh
590
602
cd test/base_mods && ./base-mods.sh base-mods.tst
591
- REF_PATH=: test/sam test/ce.fa test/faidx.fa test/fastqs.fq
603
+ REF_PATH=: test/sam test/ce.fa test/faidx/faidx .fa test/faidx /fastqs.fq
592
604
test/test-regidx
593
605
cd test && REF_PATH=: ./test.pl $$ {TEST_OPTS:-}
594
606
@@ -622,6 +634,9 @@ test/test_bgzf: test/test_bgzf.o libhts.a
622
634
test/test_expr : test/test_expr.o libhts.a
623
635
$(CC ) $(LDFLAGS ) -o $@ test/test_expr.o libhts.a -lz $(LIBS ) -lpthread
624
636
637
+ test/test_faidx : test/test_faidx.o libhts.a
638
+ $(CC ) $(LDFLAGS ) -o $@ test/test_faidx.o libhts.a -lz $(LIBS ) -lpthread
639
+
625
640
test/test_kfunc : test/test_kfunc.o libhts.a
626
641
$(CC ) $(LDFLAGS ) -o $@ test/test_kfunc.o libhts.a -lz $(LIBS ) -lpthread
627
642
@@ -739,6 +754,7 @@ test/test-regidx.o: test/test-regidx.c config.h $(htslib_kstring_h) $(htslib_reg
739
754
test/test_str2int.o : test/test_str2int.c config.h $(textutils_internal_h )
740
755
test/test_time_funcs.o : test/test_time_funcs.c config.h $(hts_time_funcs_h )
741
756
test/test_view.o : test/test_view.c config.h $(cram_h ) $(htslib_sam_h ) $(htslib_vcf_h ) $(htslib_hts_log_h )
757
+ test/test_faidx.o : test/test_faidx.c config.h $(htslib_faidx_h )
742
758
test/test_index.o : test/test_index.c config.h $(htslib_sam_h ) $(htslib_vcf_h )
743
759
test/test-vcf-api.o : test/test-vcf-api.c config.h $(htslib_hts_h ) $(htslib_vcf_h ) $(htslib_kstring_h ) $(htslib_kseq_h )
744
760
test/test-vcf-sweep.o : test/test-vcf-sweep.c config.h $(htslib_vcf_sweep_h )
@@ -789,14 +805,39 @@ header-exports.txt: test/header_syms.pl htslib/*.h
789
805
test/header_syms.pl htslib/* .h | sort -u -o $@
790
806
791
807
shlib-exports-so.txt : libhts.so
792
- nm -D -g libhts.so | awk ' $$2 == "T" { print $$3 }' | sort -u -o $@
808
+ nm -D -g libhts.so | awk ' $$2 == "T" { sub("@.*", "", $$3); print $$3 }' | sort -u -o $@
793
809
794
810
shlib-exports-dylib.txt : libhts.dylib
795
811
nm -Ug libhts.dylib | awk ' $$2 == "T" { sub("^_", "", $$3); print $$3 }' | sort -u -o $@
796
812
797
813
shlib-exports-dll.txt : hts.dll.a
798
814
nm -g hts.dll.a | awk ' $$2 == "T" { print $$3 }' | sort -u -o $@
799
815
816
+ $(srcprefix ) htslib.map : libhts.so
817
+ LC_ALL=C ; export LC_ALL; \
818
+ curr_vers=` expr ' X$(PACKAGE_VERSION)' : ' X\([0-9]*\.[0-9.]*\)' ` ; \
819
+ last_vers=` awk ' /^HTSLIB_[0-9](\.[0-9]+)+/ { lv = $$1 } END { print lv }' htslib.map` ; \
820
+ if test " x$$ curr_vers" = ' x' || test " x$$ last_vers" = ' x' ; then \
821
+ echo " Version check failed : $$ curr_vers / $$ las_vers" 1>&2 ; \
822
+ exit 1 ; \
823
+ fi && \
824
+ if test " HTSLIB_$$ curr_vers" = " $$ last_vers" ; then \
825
+ echo " Refusing to update $@ - HTSlib version not changed" 1>&2 ; \
826
+ exit 1 ; \
827
+ fi && \
828
+ nm --with-symbol-versions -D -g libhts.so | awk ' $$2 ~ /^[DGRT]$$/ && $$3 ~ /@@Base$$/ && $$3 !~ /^(_init|_fini|_edata)@@/ { sub(/@@Base$$/, ";", $$3); print " " $$3 }' > $@ .tmp && \
829
+ if [ -s $@ .tmp ] ; then \
830
+ cat $@ > $@ .new.tmp && \
831
+ printf ' \n%s {\n' " HTSLIB_$$ curr_vers" >> $@ .new.tmp && \
832
+ cat $@ .tmp >> $@ .new.tmp && \
833
+ printf ' } %s;\n' " $$ last_vers" >> $@ .new.tmp && \
834
+ rm -f $@ .tmp && \
835
+ mv $@ .new.tmp $@ ; \
836
+ fi ; \
837
+ else \
838
+ rm -f $@ .tmp ; \
839
+ fi
840
+
800
841
install : libhts.a $(BUILT_PROGRAMS ) $(BUILT_PLUGINS ) installdirs install-$(SHLIB_FLAVOUR ) install-pkgconfig
801
842
$(INSTALL_PROGRAM ) $(BUILT_PROGRAMS ) $(DESTDIR )$(bindir )
802
843
if test -n " $( BUILT_PLUGINS) " ; then $( INSTALL_PROGRAM) $( BUILT_PLUGINS) $( DESTDIR) $( plugindir) ; fi
@@ -845,7 +886,9 @@ htslib-uninstalled.pc: htslib.pc.tmp
845
886
846
887
847
888
testclean :
848
- -rm -f test/* .tmp test/* .tmp.* test/longrefs/* .tmp.* test/tabix/* .tmp.* test/tabix/FAIL* header-exports.txt shlib-exports-$(SHLIB_FLAVOUR ) .txt
889
+ -rm -f test/* .tmp test/* .tmp.* test/faidx/* .tmp* test/faidx/FAIL* \
890
+ test/longrefs/*.tmp.* test/tabix/*.tmp.* test/tabix/FAIL* \
891
+ header-exports.txt shlib-exports-$(SHLIB_FLAVOUR).txt
849
892
-rm -rf htscodecs/tests/test.out
850
893
851
894
# Only remove this in git checkouts
0 commit comments