diff --git a/Makefile b/Makefile index e98f287..ab3fdc1 100644 --- a/Makefile +++ b/Makefile @@ -145,6 +145,8 @@ HTS_BUILD_AVX2 = HTS_BUILD_AVX512 = HTS_BUILD_SSE4 = +PTHREAD = -pthread + include htslib_vars.mk include htscodecs.mk @@ -191,10 +193,10 @@ config_vars.h: .SUFFIXES: .bundle .c .cygdll .dll .o .pico .so .c.o: - $(CC) $(CFLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) $(PTHREAD) -c -o $@ $< .c.pico: - $(CC) $(CFLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) $(EXTRA_CFLAGS_PIC) -c -o $@ $< + $(CC) $(CFLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) $(PTHREAD) $(EXTRA_CFLAGS_PIC) -c -o $@ $< ref_cache/%.o: ref_cache/%.c $(CC) $(CFLAGS) $(REF_CACHE_EXTRA_C_FLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) -c -o $@ $< @@ -409,7 +411,7 @@ print-config: # file used at runtime (when $LD_LIBRARY_PATH includes the build directory). libhts.so: $(LIBHTS_OBJS:.o=.pico) - $(CC) -shared -Wl,-soname,libhts.so.$(LIBHTS_SOVERSION) $(VERSION_SCRIPT_LDFLAGS) $(LDFLAGS) -o $@ $(LIBHTS_OBJS:.o=.pico) $(LIBS) -lpthread + $(CC) -shared -Wl,-soname,libhts.so.$(LIBHTS_SOVERSION) $(VERSION_SCRIPT_LDFLAGS) $(LDFLAGS) -o $@ $(LIBHTS_OBJS:.o=.pico) $(LIBS) $(PTHREAD) ln -sf $@ libhts.so.$(LIBHTS_SOVERSION) # Similarly this also creates libhts.NN.dylib as a byproduct, so that programs @@ -421,10 +423,10 @@ libhts.dylib: $(LIBHTS_OBJS) ln -sf $@ libhts.$(LIBHTS_SOVERSION).dylib cyghts-$(LIBHTS_SOVERSION).dll libhts.dll.a: $(LIBHTS_OBJS) - $(CC) -shared -Wl,--out-implib=libhts.dll.a -Wl,--enable-auto-import $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) -lpthread + $(CC) -shared -Wl,--out-implib=libhts.dll.a -Wl,--enable-auto-import $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) $(PTHREAD) hts-$(LIBHTS_SOVERSION).dll hts.dll.a: $(LIBHTS_OBJS) - $(CC) -shared -Wl,--out-implib=hts.dll.a -Wl,--enable-auto-import -Wl,--exclude-all-symbols $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) -lpthread + $(CC) -shared -Wl,--out-implib=hts.dll.a -Wl,--enable-auto-import -Wl,--exclude-all-symbols $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) $(PTHREAD) hts-$(LIBHTS_SOVERSION).def: hts-$(LIBHTS_SOVERSION).dll gendef hts-$(LIBHTS_SOVERSION).dll @@ -471,7 +473,7 @@ hts-object-files: $(LIBHTS_OBJS) # may not be able to access libhts symbols via the main program's libhts # if that was dynamically loaded without an explicit RTLD_GLOBAL. %.so: %.pico libhts.so - $(CC) -shared -Wl,-E $(LDFLAGS) -o $@ $< libhts.so $(LIBS) -lpthread + $(CC) -shared -Wl,-E $(LDFLAGS) -o $@ $< libhts.so $(LIBS) $(PTHREAD) # For programs *statically* linked to libhts.a, on macOS loading a plugin # linked to a shared libhts.NN.dylib would lead to conflicting duplicate @@ -553,16 +555,16 @@ htscodecs/htscodecs/rANS_static32x16pr_avx512.o htscodecs/htscodecs/rANS_static3 htscodecs/htscodecs/rANS_static32x16pr_sse4.o htscodecs/htscodecs/rANS_static32x16pr_sse4.pico: TARGET_CFLAGS = $(HTS_CFLAGS_SSE4) annot-tsv: annot-tsv.o libhts.a - $(CC) $(LDFLAGS) -o $@ annot-tsv.o libhts.a $(LIBS) -lpthread + $(CC) $(LDFLAGS) -o $@ annot-tsv.o libhts.a $(LIBS) $(PTHREAD) bgzip: bgzip.o libhts.a - $(CC) $(LDFLAGS) -o $@ bgzip.o libhts.a $(LIBS) -lpthread + $(CC) $(LDFLAGS) -o $@ bgzip.o libhts.a $(LIBS) $(PTHREAD) htsfile: htsfile.o libhts.a - $(CC) $(LDFLAGS) -o $@ htsfile.o libhts.a $(LIBS) -lpthread + $(CC) $(LDFLAGS) -o $@ htsfile.o libhts.a $(LIBS) $(PTHREAD) tabix: tabix.o libhts.a - $(CC) $(LDFLAGS) -o $@ tabix.o libhts.a $(LIBS) -lpthread + $(CC) $(LDFLAGS) -o $@ tabix.o libhts.a $(LIBS) $(PTHREAD) ref_cache/ref-cache: $(REF_CACHE_OBJS) $(CC) $(LDFLAGS) $(REF_CACHE_EXTRA_LD_FLAGS) -o $@ $(REF_CACHE_OBJS) -lcurl