Skip to content

Commit

Permalink
Always link with -rdynamic/-ldl [hack]
Browse files Browse the repository at this point in the history
As a quick hack to make plain "make" work in both typical HTSlib
scenarios (plain HTSlib; HTSlib configured with --enable-plugins),
add -rdynamic and -ldl to link commands ALWAYS.  In future, we would
prefer to communicate the exact linking needs from HTSlib via perhaps
htslib.pc and/or more configure delving.

Introduce $(ALL_LIBS), which will outlast this hack being reverted.
  • Loading branch information
jmarshall committed Dec 15, 2015
1 parent ea6d10c commit 3c15c88
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ BUILT_TEST_PROGRAMS = \

all: $(PROGRAMS) $(BUILT_MISC_PROGRAMS) $(BUILT_TEST_PROGRAMS)

# TODO Use configure or htslib.pc to add -rdynamic/-ldl conditionally
ALL_CPPFLAGS = $(DFLAGS) -I. $(HTSLIB_CPPFLAGS) $(CPPFLAGS)
ALL_LDFLAGS = $(HTSLIB_LDFLAGS) $(LDFLAGS)
ALL_LDFLAGS = -rdynamic $(HTSLIB_LDFLAGS) $(LDFLAGS)
ALL_LIBS = -lz -ldl $(LIBS)

# Usually config.mk and config.h are generated by running configure
# or config.status, but if those aren't used create defaults here.
Expand Down Expand Up @@ -134,7 +136,7 @@ libbam.a:$(LOBJS)
$(AR) -csru $@ $(LOBJS)

samtools: $(AOBJS) libbam.a $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ $(AOBJS) libbam.a $(HTSLIB_LIB) $(CURSES_LIB) -lm -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ $(AOBJS) libbam.a $(HTSLIB_LIB) $(CURSES_LIB) -lm $(ALL_LIBS)

bam_h = bam.h $(htslib_bgzf_h) $(htslib_sam_h)
bam2bcf_h = bam2bcf.h $(htslib_vcf_h) errmod.h
Expand Down Expand Up @@ -209,28 +211,28 @@ check test: samtools $(BGZIP) $(BUILT_TEST_PROGRAMS)


test/merge/test_bam_translate: test/merge/test_bam_translate.o test/test.o sam_opts.o $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/merge/test_bam_translate.o test/test.o sam_opts.o $(HTSLIB_LIB) -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/merge/test_bam_translate.o test/test.o sam_opts.o $(HTSLIB_LIB) $(ALL_LIBS)

test/merge/test_rtrans_build: test/merge/test_rtrans_build.o sam_opts.o $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/merge/test_rtrans_build.o sam_opts.o $(HTSLIB_LIB) -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/merge/test_rtrans_build.o sam_opts.o $(HTSLIB_LIB) $(ALL_LIBS)

test/merge/test_trans_tbl_init: test/merge/test_trans_tbl_init.o sam_opts.o $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/merge/test_trans_tbl_init.o sam_opts.o $(HTSLIB_LIB) -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/merge/test_trans_tbl_init.o sam_opts.o $(HTSLIB_LIB) $(ALL_LIBS)

test/split/test_count_rg: test/split/test_count_rg.o test/test.o sam_opts.o $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/split/test_count_rg.o test/test.o sam_opts.o $(HTSLIB_LIB) -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/split/test_count_rg.o test/test.o sam_opts.o $(HTSLIB_LIB) $(ALL_LIBS)

test/split/test_expand_format_string: test/split/test_expand_format_string.o test/test.o sam_opts.o $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/split/test_expand_format_string.o test/test.o sam_opts.o $(HTSLIB_LIB) -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/split/test_expand_format_string.o test/test.o sam_opts.o $(HTSLIB_LIB) $(ALL_LIBS)

test/split/test_filter_header_rg: test/split/test_filter_header_rg.o test/test.o sam_opts.o $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/split/test_filter_header_rg.o test/test.o sam_opts.o $(HTSLIB_LIB) -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/split/test_filter_header_rg.o test/test.o sam_opts.o $(HTSLIB_LIB) $(ALL_LIBS)

test/split/test_parse_args: test/split/test_parse_args.o test/test.o sam_opts.o $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/split/test_parse_args.o test/test.o sam_opts.o $(HTSLIB_LIB) -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/split/test_parse_args.o test/test.o sam_opts.o $(HTSLIB_LIB) $(ALL_LIBS)

test/vcf-miniview: test/vcf-miniview.o $(HTSLIB)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/vcf-miniview.o $(HTSLIB_LIB) -lz $(LIBS)
$(CC) -pthread $(ALL_LDFLAGS) -o $@ test/vcf-miniview.o $(HTSLIB_LIB) $(ALL_LIBS)

test_test_h = test/test.h $(htslib_sam_h)

Expand All @@ -248,22 +250,22 @@ test/vcf-miniview.o: test/vcf-miniview.c $(htslib_vcf_h)
# misc programs

misc/ace2sam: misc/ace2sam.o
$(CC) $(LDFLAGS) -o $@ misc/ace2sam.o -lz $(LIBS)
$(CC) $(LDFLAGS) -o $@ misc/ace2sam.o $(ALL_LIBS)

misc/maq2sam-short: misc/maq2sam-short.o
$(CC) $(LDFLAGS) -o $@ misc/maq2sam-short.o -lz $(LIBS)
$(CC) $(LDFLAGS) -o $@ misc/maq2sam-short.o $(ALL_LIBS)

misc/maq2sam-long: misc/maq2sam-long.o
$(CC) $(LDFLAGS) -o $@ misc/maq2sam-long.o -lz $(LIBS)
$(CC) $(LDFLAGS) -o $@ misc/maq2sam-long.o $(ALL_LIBS)

misc/md5fa: misc/md5fa.o $(HTSLIB)
$(CC) $(ALL_LDFLAGS) -o $@ misc/md5fa.o $(HTSLIB_LIB) -lz $(LIBS)
$(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) $(LIBS)
$(CC) $(ALL_LDFLAGS) -o $@ misc/md5sum-lite.o $(HTSLIB_LIB) $(ALL_LIBS)

misc/wgsim: misc/wgsim.o
$(CC) $(LDFLAGS) -o $@ misc/wgsim.o -lm -lz $(LIBS)
$(CC) $(LDFLAGS) -o $@ misc/wgsim.o -lm $(ALL_LIBS)

misc/ace2sam.o: misc/ace2sam.c $(htslib_kstring_h) $(htslib_kseq_h)
misc/md5fa.o: misc/md5fa.c $(htslib_kseq_h) $(htslib_hts_h)
Expand Down

0 comments on commit 3c15c88

Please sign in to comment.