aboutsummaryrefslogtreecommitdiff
path: root/biology
diff options
context:
space:
mode:
authorJason W. Bacon <jwb@FreeBSD.org>2021-06-22 17:55:15 +0000
committerJason W. Bacon <jwb@FreeBSD.org>2021-06-22 17:55:15 +0000
commit69656bf0d7d99660e536c22472a5eae639695a97 (patch)
tree1eec14b05b8f280276d6e0dbc1063d9f91d4a327 /biology
parent754ca6f4c9c3c1ce86e13bdf62db3e3282346cbf (diff)
downloadports-69656bf0d7d99660e536c22472a5eae639695a97.tar.gz
ports-69656bf0d7d99660e536c22472a5eae639695a97.zip
biology/sra-tools: NCBI's toolkit for handling data in INSDC Sequence Read Archives
SRA tools is a toolkit for using data in the INSDC Sequence Read Archives. SRAs operated by International Nucleotide Sequence Database Collaboration houses sequence reads and alignments generated by "next-gen" sequencers. This port is a bit convoluted due to the fact that the sra-tools build requires access to the ncbi-vdb source tree. Hence, ncbi-vdb is treated as a submodule here rather than a separate library port. We are working with upstream with hope for long-term improvements.
Diffstat (limited to 'biology')
-rw-r--r--biology/Makefile1
-rw-r--r--biology/sra-tools/Makefile105
-rw-r--r--biology/sra-tools/distinfo7
-rw-r--r--biology/sra-tools/files/Makefile.bsd72
-rw-r--r--biology/sra-tools/files/byteswap.h40
-rwxr-xr-xbiology/sra-tools/files/ld.bsd.clang.sh47
-rwxr-xr-xbiology/sra-tools/files/ld.bsd.cmn.sh158
-rwxr-xr-xbiology/sra-tools/files/ld.bsd.dlib.sh308
-rwxr-xr-xbiology/sra-tools/files/ld.bsd.exe.sh326
-rwxr-xr-xbiology/sra-tools/files/ld.bsd.gcc.sh47
-rwxr-xr-xbiology/sra-tools/files/ld.bsd.ln.sh98
-rwxr-xr-xbiology/sra-tools/files/ld.bsd.slib.sh146
-rw-r--r--biology/sra-tools/files/patch-build_ld.linux.exe.sh11
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.clang30
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.env25
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.gcc35
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.install11
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.shell31
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_interfaces_os_sun_atomic32.h85
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_libs_ext_Makefile12
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_libs_kfg_config.c20
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_libs_klib_unix_systime.c11
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_libs_kns_unix_syssock.c10
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_libs_ncbi-vdb_Makefile20
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_libs_search_Makefile12
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_setup_konfigure.perl243
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_setup_os-arch.prl20
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_test_kapp_run-sig-core.sh49
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_test_kfg_kfgtest.cpp11
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_test_klib_printf-test.c11
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_test_kns_Makefile19
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_test_vdb_test-dependencies.cpp11
-rw-r--r--biology/sra-tools/files/patch-ncbi-vdb_test_vfs_redirect-rejected-names-cgi-http-to-https.cpp11
-rw-r--r--biology/sra-tools/files/patch-setup_install.perl13
-rw-r--r--biology/sra-tools/files/patch-setup_konfigure.perl121
-rw-r--r--biology/sra-tools/files/patch-tools_bam-loader_loader-imp.c10
-rw-r--r--biology/sra-tools/files/patch-tools_copycat_Makefile11
-rw-r--r--biology/sra-tools/files/patch-tools_driver-tool_Makefile16
-rw-r--r--biology/sra-tools/files/patch-tools_driver-tool_cmdline.cpp13
-rw-r--r--biology/sra-tools/files/patch-tools_driver-tool_utf8proc_Makefile11
-rw-r--r--biology/sra-tools/files/patch-tools_fastq-loader_spot-assembler.c11
-rw-r--r--biology/sra-tools/files/patch-tools_sra-sort_Makefile13
-rw-r--r--biology/sra-tools/files/patch-tools_util_validate-names4.c13
-rw-r--r--biology/sra-tools/pkg-descr18
-rw-r--r--biology/sra-tools/pkg-plist57
45 files changed, 2350 insertions, 0 deletions
diff --git a/biology/Makefile b/biology/Makefile
index ec9728ced8ee..158eb70ede1a 100644
--- a/biology/Makefile
+++ b/biology/Makefile
@@ -175,6 +175,7 @@
SUBDIR += smithwaterman
SUBDIR += snpeff
SUBDIR += spoa
+ SUBDIR += sra-tools
SUBDIR += stacks
SUBDIR += star
SUBDIR += stringtie
diff --git a/biology/sra-tools/Makefile b/biology/sra-tools/Makefile
new file mode 100644
index 000000000000..0b6a54bd67ca
--- /dev/null
+++ b/biology/sra-tools/Makefile
@@ -0,0 +1,105 @@
+PORTNAME= sra-tools
+DISTVERSION= 2.11.0
+CATEGORIES= biology
+
+MAINTAINER= jwb@FreeBSD.org
+COMMENT= NCBI's toolkit for handling data in INSDC Sequence Read Archives
+
+LICENSE= PD LGPL21+
+LICENSE_COMB= multi
+LICENSE_FILE_PD= ${WRKSRC}/LICENSE
+LICENSE_DISTFILES_LGPL21+ =
+
+ONLY_FOR_ARCHS= amd64
+ONLY_FOR_ARCHS_REASON= NCBI-VDB requires SSE2 instructions, no 32-bit support
+
+BUILD_DEPENDS= bash:shells/bash \
+ ${LOCALBASE}/lib/libngs-c++.a:biology/ngs-sdk
+LIB_DEPENDS= libxml2.so:textproc/libxml2 \
+ libhdf5.so:science/hdf5 \
+ libepoll-shim.so:devel/libepoll-shim
+
+USES= compiler:c11 gmake localbase:ldflags perl5 shebangfix
+USE_PERL5= build
+USE_GITHUB= yes
+
+SHEBANG_GLOB= *.sh *.pl
+GH_ACCOUNT= ncbi
+GH_TUPLE+= ncbi:ngs:${DISTVERSION}:ngs/ngs # ported as biology/ngs-sdk
+GH_TUPLE+= ncbi:ncbi-vdb:${DISTVERSION}:vdb/ncbi-vdb
+
+GNU_CONFIGURE= yes
+CONFIGURE_ARGS= --with-ngs-sdk-prefix=${LOCALBASE} \
+ --with-ncbi-vdb-sources=${NCBI_VDB_WRKSRC} \
+ --with-xml2-prefix=${LOCALBASE} \
+ --with-hdf5-prefix=${LOCALBASE} \
+ CC="${CC}" CXX="${CXX}" TOOLS="${CHOSEN_COMPILER_TYPE}" \
+ --with-ncbi-vdb-build=${NCBI_VDB_WRKSRC}/amd64-portbld-freebsd$$(${FREEBSD_RELEASE})
+MAKE_ARGS= CCNAME=${CC} CXXNAME=${CXX} PKGCFLAGS="${CFLAGS}" \
+ INST_ETCDIR=${STAGEDIR}${PREFIX}/etc
+
+NCBI_VDB_WRKSRC= ${WRKSRC}/ncbi-vdb
+NCBI_VDB_FILESDIR= ${FILESDIR}
+FREEBSD_RELEASE= uname -r | cut -d - -f 1
+
+CFLAGS+= -I${WRKSRC}/interfaces/os/sun
+CXXFLAGS+= -I${WRKSRC}/interfaces/os/sun
+
+BINARY_ALIAS= gcc=${CC} g++=${CXX}
+
+# for port developers, building with these options may fail
+OPTIONS_DEFINE= DEBUG OPTIMIZED_CFLAGS TEST
+DEBUG_PREVENTS= OPTIMIZED_CFLAGS
+DEBUG_CONFIGURE_WITH= debug
+OPTIMIZED_CFLAGS_MAKE_ARGS_OFF= OPT=""
+TEST_TEST_TARGET= test
+TEST_USES= python
+
+# ncbi-vdb build extras
+VDB_CONFIGURE_ARGS= \
+ --with-xml2-prefix=${LOCALBASE} \
+ --with-hdf5-prefix=${LOCALBASE} \
+ --prefix=${PREFIX} \
+ --build=amd64-portbld-freebsd$$(${FREEBSD_RELEASE}) \
+ CC="${CC}" CXX="${CXX}" TOOLS="${CHOSEN_COMPILER_TYPE}"
+VDB_MAKE_ARGS+= -j 1 CCNAME=${CC} CXXNAME=${CXX} PKGCFLAGS="${CFLAGS}"
+MAKE_ENV+= CPATH="${LOCALBASE}/include/libepoll-shim"
+CFLAGS+= -I${WRKSRC}/lib
+
+pre-patch:
+ @${CP} ${FILESDIR}/Makefile.bsd ${NCBI_VDB_WRKSRC}/build/
+ @${CP} ${FILESDIR}/ld.bsd.*.sh ${NCBI_VDB_WRKSRC}/build/
+ @${MKDIR} ${NCBI_VDB_WRKSRC}/interfaces/os/bsd
+ @${CP} -p ${NCBI_VDB_WRKSRC}/interfaces/os/mac/endian.h \
+ ${NCBI_VDB_WRKSRC}/interfaces/os/bsd/
+
+post-patch:
+ @${GREP} -q '@@PREFIX@@' ${WRKSRC}/ncbi-vdb/libs/kfg/config.c || (echo "@@PREFIX@@ in file/patch-libs_kfg_config.c is overwritten probably due to using 'make makepatch'"; exit 1)
+ @${REINPLACE_CMD} -e 's#@@PREFIX@@#"${PREFIX}"#' ${WRKSRC}/ncbi-vdb/libs/kfg/config.c
+ @${LN} -s ${WRKSRC}/ncbi-vdb/interfaces/cc/gcc/x86_64 ${WRKSRC}/ncbi-vdb/interfaces/cc/gcc/amd64
+
+post-patch-TEST-on:
+ @${REINPLACE_CMD} -e 's|python|${PYTHON_CMD}|' ${WRKSRC}/test/kget/Makefile
+
+pre-configure:
+ @${CP} ${NCBI_VDB_WRKSRC}/setup/os-arch.prl ${WRKSRC}/setup/os-arch.prl
+ # same as in biology/ncbi-vdb
+ @${CP} ${NCBI_VDB_FILESDIR}/Makefile.bsd ${WRKSRC}/build/
+ @${CP} ${NCBI_VDB_WRKSRC}/build/ld.bsd.*.sh ${WRKSRC}/build/
+ @${MKDIR} ${WRKSRC}/interfaces/override
+ @${CP} ${NCBI_VDB_WRKSRC}/interfaces/os/sun/atomic32.h ${WRKSRC}/interfaces/override
+ @${CP} ${FILESDIR}/byteswap.h ${WRKSRC}/interfaces/override
+ @cd ${WRKSRC}/ncbi-vdb && ./configure ${VDB_CONFIGURE_ARGS}
+ @${ECHO} ${CHOSEN_COMPILER_TYPE} > ${WRKSRC}/ncbi-vdb/build/COMP
+ @cd ${WRKSRC}/ncbi-vdb && ${DO_MAKE_BUILD} ${VDB_MAKE_ARGS}
+
+post-build-TEST-on: do-test
+
+do-install:
+ cd ${WRKSRC}/amd64-portbld-freebsd*/sra-tools/bsd/clang/*/rel/bin && \
+ for f in `ls *.${PORTVERSION}`; do \
+ ${INSTALL_PROGRAM} $${f} \
+ ${STAGEDIR}${PREFIX}/bin/`basename $${f%%.${PORTVERSION}}`; \
+ done
+
+.include <bsd.port.mk>
diff --git a/biology/sra-tools/distinfo b/biology/sra-tools/distinfo
new file mode 100644
index 000000000000..fa75acf23fe6
--- /dev/null
+++ b/biology/sra-tools/distinfo
@@ -0,0 +1,7 @@
+TIMESTAMP = 1624382289
+SHA256 (ncbi-sra-tools-2.11.0_GH0.tar.gz) = 10ac0a4d1fafc274bc107de811891d3e803d0713a247581dece4448231883810
+SIZE (ncbi-sra-tools-2.11.0_GH0.tar.gz) = 8966605
+SHA256 (ncbi-ngs-2.11.0_GH0.tar.gz) = 5fde50784760c00b403c2cc42ead15a4e9477697ee439f0a16edb4de3f52dfcc
+SIZE (ncbi-ngs-2.11.0_GH0.tar.gz) = 1100365
+SHA256 (ncbi-ncbi-vdb-2.11.0_GH0.tar.gz) = 9a65e3885b9ae1ebecbec871f04ce3162ac3764fb556ecdc8c1e61993e2164aa
+SIZE (ncbi-ncbi-vdb-2.11.0_GH0.tar.gz) = 22277539
diff --git a/biology/sra-tools/files/Makefile.bsd b/biology/sra-tools/files/Makefile.bsd
new file mode 100644
index 000000000000..7692ec277948
--- /dev/null
+++ b/biology/sra-tools/files/Makefile.bsd
@@ -0,0 +1,72 @@
+# ===========================================================================
+#
+# PUBLIC DOMAIN NOTICE
+# National Center for Biotechnology Information
+#
+# This software/database is a "United States Government Work" under the
+# terms of the United States Copyright Act. It was written as part of
+# the author's official duties as a United States Government employee and
+# thus cannot be copyrighted. This software/database is freely available
+# to the public for use. The National Library of Medicine and the U.S.
+# Government have not placed any restriction on its use or reproduction.
+#
+# Although all reasonable efforts have been taken to ensure the accuracy
+# and reliability of the software and data, the NLM and the U.S.
+# Government do not and cannot warrant the performance or results that
+# may be obtained by using this software or data. The NLM and the U.S.
+# Government disclaim all warranties, express or implied, including
+# warranties of performance, merchantability or fitness for any particular
+# purpose.
+#
+# Please cite the author in any work or product based on this material.
+#
+# ===========================================================================
+
+
+# default compiler
+ifeq (,$(COMP))
+ COMP = clang
+endif
+
+# handle attempts to set cross-compilation architecture
+# note that if your installation is set up for cross compilation,
+# you can try to enable it on your own.
+ifeq (i386,$(ARCH))
+i386:
+ @ true
+x86_64:
+ @ echo "FreeBSD builds do not support cross-compilation to this architecture"
+endif
+
+ifeq (x86_64,$(ARCH))
+i386:
+ @ echo "FreeBSD builds do not support cross-compilation to this architecture"
+x86_64:
+ @ true
+endif
+
+.PHONY: i386 x86_64
+
+
+# library prefix
+LPFX = lib
+
+# file extensions
+OBJX = o
+LOBX = pic.o
+LIBX = a
+SHLX = so
+
+# compilation defines
+DEFINES := -DBSD -DUNIX -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DPKGNAME=bsd$(BITS)
+
+# FreeBSD is a Unix variant; for most cases, linux sources do well
+OS_DAD = linux
+OS_GDAD = unix
+
+# flex+bison: on Mac, use source-controlled generated .c/.h files
+YACC = @ true
+LEX = @ true
+
+# build matrix
+COMPILERS = CLANG GCC
diff --git a/biology/sra-tools/files/byteswap.h b/biology/sra-tools/files/byteswap.h
new file mode 100644
index 000000000000..ef07fe98db64
--- /dev/null
+++ b/biology/sra-tools/files/byteswap.h
@@ -0,0 +1,40 @@
+/*===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government have not placed any restriction on its use or reproduction.
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* Please cite the author in any work or product based on this material.
+*
+* ===========================================================================
+*
+*/
+
+#ifndef _h_byteswap_
+#define _h_byteswap_
+
+#include <stdint.h>
+#include <sys/endian.h>
+
+/* N.B. Sun's BSWAP seems to be macro-based,
+ meaning that (x) will be evaluated multiple times */
+
+#define bswap_16(x) bswap16 (x)
+#define bswap_32(x) bswap32 (x)
+#define bswap_64(x) bswap64 (x)
+
+#endif /* _h_byteswap_ */
diff --git a/biology/sra-tools/files/ld.bsd.clang.sh b/biology/sra-tools/files/ld.bsd.clang.sh
new file mode 100755
index 000000000000..61c7779adcf1
--- /dev/null
+++ b/biology/sra-tools/files/ld.bsd.clang.sh
@@ -0,0 +1,47 @@
+#!/usr/local/bin/bash
+# ===========================================================================
+#
+# PUBLIC DOMAIN NOTICE
+# National Center for Biotechnology Information
+#
+# This software/database is a "United States Government Work" under the
+# terms of the United States Copyright Act. It was written as part of
+# the author's official duties as a United States Government employee and
+# thus cannot be copyrighted. This software/database is freely available
+# to the public for use. The National Library of Medicine and the U.S.
+# Government have not placed any restriction on its use or reproduction.
+#
+# Although all reasonable efforts have been taken to ensure the accuracy
+# and reliability of the software and data, the NLM and the U.S.
+# Government do not and cannot warrant the performance or results that
+# may be obtained by using this software or data. The NLM and the U.S.
+# Government disclaim all warranties, express or implied, including
+# warranties of performance, merchantability or fitness for any particular
+# purpose.
+#
+# Please cite the author in any work or product based on this material.
+#
+# ===========================================================================
+
+# define linker params
+LD_EXPORT_GLOBAL="-Wl,--export-dynamic"
+LD_MULTIPLE_DEFS="-Wl,-zmuldefs"
+LD_STATIC="-Wl,-Bstatic"
+LD_DYNAMIC="-Wl,-Bdynamic"
+LD_ALL_SYMBOLS="-Wl,-whole-archive"
+LD_REF_SYMBOLS="-Wl,-no-whole-archive"
+
+# build command
+DLIB_CMD="$LD -shared"
+EXE_CMD="$LD"
+
+# versioned output
+if [ "$VERS" = "" ]
+then
+ DLIB_CMD="$DLIB_CMD -o $TARG"
+ EXE_CMD="$EXE_CMD -o $TARG"
+else
+ set-vers $(echo $VERS | tr '.' ' ')
+ DLIB_CMD="$DLIB_CMD -o $OUTDIR/$NAME$DBGAP.so.$VERS -Wl,-soname,$NAME.so.$MAJ"
+ EXE_CMD="$EXE_CMD -o $OUTDIR/$NAME$DBGAP.$VERS"
+fi
diff --git a/biology/sra-tools/files/ld.bsd.cmn.sh b/biology/sra-tools/files/ld.bsd.cmn.sh
new file mode 100755
index 000000000000..a0a65f39884b
--- /dev/null
+++ b/biology/sra-tools/files/ld.bsd.cmn.sh
@@ -0,0 +1,158 @@
+#!/usr/local/bin/bash
+# ===========================================================================
+#
+# PUBLIC DOMAIN NOTICE
+# National Center for Biotechnology Information
+#
+# This software/database is a "United States Government Work" under the
+# terms of the United States Copyright Act. It was written as part of
+# the author's official duties as a United States Government employee and
+# thus cannot be copyrighted. This software/database is freely available
+# to the public for use. The National Library of Medicine and the U.S.
+# Government have not placed any restriction on its use or reproduction.
+#
+# Although all reasonable efforts have been taken to ensure the accuracy
+# and reliability of the software and data, the NLM and the U.S.
+# Government do not and cannot warrant the performance or results that
+# may be obtained by using this software or data. The NLM and the U.S.
+# Government disclaim all warranties, express or implied, including
+# warranties of performance, merchantability or fitness for any particular
+# purpose.
+#
+# Please cite the author in any work or product based on this material.
+#
+# ===========================================================================
+
+# script name
+SELF_NAME="$(basename $0)"
+
+# parameters
+LD="$1"
+ARCH="$2"
+BUILD="$3"
+shift 3
+
+SRCDIR="$1"
+BINDIR="$2"
+OUTDIR="$3"
+TARG="$4"
+NAME="$5"
+DBGAP="$6"
+shift 6
+
+VERS="$1"
+VERSFILE="$2"
+DEPFILE="$3"
+shift 3
+
+MODE="$1"
+SCMFLAGS="$2"
+LDFLAGS="$3"
+shift 3
+
+LDIRS="$1"
+XDIRS="$2"
+shift 2
+
+OBJS="$1"
+LIBS="$2"
+
+# decode MODE
+STATIC=$(expr $MODE % 2)
+MODE=$(expr $MODE / 2)
+DYLD=$(expr $MODE % 2)
+MODE=$(expr $MODE / 2)
+KPROC=$(expr $MODE % 2)
+MODE=$(expr $MODE / 2)
+THREADS=$(expr $MODE % 2)
+MODE=$(expr $MODE / 2)
+HAVE_M=$(expr $MODE % 2)
+MODE=$(expr $MODE / 2)
+HAVE_XML=$(expr $MODE % 2)
+
+# decode SCMFLAGS
+CHECKSUM=$(expr $SCMFLAGS % 2)
+STATICSYSLIBS=$(expr $SCMFLAGS / 2)
+
+# return parameter for find-lib
+LIBPATH=''
+
+# initial command state
+CMD=''
+LD_STATIC_STATE=0
+LD_ALL_STATE=0
+
+# for breaking out version
+set-vers ()
+{
+ MAJ=$1
+ MIN=$2
+ REL=$3
+}
+
+# for locating libraries
+find-lib ()
+{
+ _lib="lib$1"
+ _dirs="$2"
+
+ LIBPATH=''
+
+ while [ "$_dirs" != "" ]
+ do
+ _dir="${_dirs%%:*}"
+
+ if [ "$_dir" != "" ]
+ then
+ if [ -e "$_dir/$_lib" ]
+ then
+ while [ -L "$_dir/$_lib" ]
+ do
+ _lib=$(readlink -n "$_dir/$_lib")
+ done
+ LIBPATH="$_dir/$_lib"
+ break;
+ fi
+ fi
+
+ _dirs="${_dirs#$_dir}"
+ _dirs="${_dirs#:}"
+ done
+}
+
+# setting state
+load-static ()
+{
+ if [ $LD_STATIC_STATE -eq 0 ]
+ then
+ CMD="$CMD $LD_STATIC"
+ LD_STATIC_STATE=1
+ fi
+}
+
+load-dynamic ()
+{
+ if [ $LD_STATIC_STATE -eq 1 ]
+ then
+ CMD="$CMD $LD_DYNAMIC"
+ LD_STATIC_STATE=0
+ fi
+}
+
+load-all-symbols ()
+{
+ if [ $LD_ALL_STATE -eq 0 ]
+ then
+ CMD="$CMD $LD_ALL_SYMBOLS"
+ LD_ALL_STATE=1
+ fi
+}
+
+load-ref-symbols ()
+{
+ if [ $LD_ALL_STATE -eq 1 ]
+ then
+ CMD="$CMD $LD_REF_SYMBOLS"
+ LD_ALL_STATE=0
+ fi
+}
diff --git a/biology/sra-tools/files/ld.bsd.dlib.sh b/biology/sra-tools/files/ld.bsd.dlib.sh
new file mode 100755
index 000000000000..a74f2b006818
--- /dev/null
+++ b/biology/sra-tools/files/ld.bsd.dlib.sh
@@ -0,0 +1,308 @@
+#!/usr/local/bin/bash
+# ===========================================================================
+#
+# PUBLIC DOMAIN NOTICE
+# National Center for Biotechnology Information
+#
+# This software/database is a "United States Government Work" under the
+# terms of the United States Copyright Act. It was written as part of
+# the author's official duties as a United States Government employee and
+# thus cannot be copyrighted. This software/database is freely available
+# to the public for use. The National Library of Medicine and the U.S.
+# Government have not placed any restriction on its use or reproduction.
+#
+# Although all reasonable efforts have been taken to ensure the accuracy
+# and reliability of the software and data, the NLM and the U.S.
+# Government do not and cannot warrant the performance or results that
+# may be obtained by using this software or data. The NLM and the U.S.
+# Government disclaim all warranties, express or implied, including
+# warranties of performance, merchantability or fitness for any particular
+# purpose.
+#
+# Please cite the author in any work or product based on this material.
+#
+# ===========================================================================
+
+
+# ===========================================================================
+# input library types, and their handling
+#
+# normal linkage
+# -l : find shared or static
+# -s : require static
+# -d : require shared
+#
+# static linkage
+# -l : require static
+# -s : require static
+# -d : ignore
+# ===========================================================================
+
+
+# script name
+SELF_NAME="$(basename $0)"
+BUILD_DIR="$(dirname $0)"
+
+# parameters and common functions
+source "${0%dlib.sh}cmn.sh"
+
+# discover tool chain
+case "$LD" in
+g*)
+ source "${0%dlib.sh}gcc.sh"
+ ;;
+c*)
+ source "${0%dlib.sh}clang.sh"
+ ;;
+ *)
+ echo "$SELF_NAME: unrecognized ld tool - '$LD'"
+ exit 5
+esac
+
+# DLIB_CMD was started in tool-specific source
+CMD="$DLIB_CMD $LDFLAGS"
+
+# tack on object files
+CMD="$CMD $OBJS"
+
+# list of static libraries used to create dynamic lib
+SLIBS=''
+
+# initial dependency upon Makefile and vers file
+DEPS="$SRCDIR/Makefile"
+if [ "$LIBS" != "" ]
+then
+ # tack on paths
+ DIRS="$LDIRS:$XDIRS"
+ while [ "$DIRS" != "" ]
+ do
+ DIR="${DIRS%%:*}"
+ [ "$DIR" != "" ] && CMD="$CMD -L$DIR"
+ DIRS="${DIRS#$DIR}"
+ DIRS="${DIRS#:}"
+ done
+
+ # update LD_LIBRARY_PATH
+ unset LD_LIBRARY_PATH
+ export LD_LIBRARY_PATH="$LDIRS:$XDIRS"
+
+ # tack on libraries, finding as we go
+ for LIB in $LIBS
+ do
+
+ # strip off switch
+ LIBNAME="${LIB#-[lsd]}"
+
+ # look at linkage
+ case "$LIB" in
+ -ldl|-ddl)
+
+ # always load libdl as shared library
+ load-ref-symbols
+ load-dynamic
+# CMD="$CMD -ldl"
+ ;;
+
+ -l*)
+
+ # normal or dynamic linkage
+ FOUND=0
+ if [ $STATIC -eq 0 ]
+ then
+ find-lib $LIBNAME.so $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # found it
+ FOUND=1
+
+ # load normally
+ load-ref-symbols
+ load-dynamic
+ CMD="$CMD -l$LIBNAME"
+
+ fi
+ fi
+
+ # try static only
+ if [ $FOUND -eq 0 ]
+ then
+ find-lib $LIBNAME.a $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # found it
+ FOUND=1
+
+ # add it to dependencies
+ DEPS="$DEPS $LIBPATH"
+ SLIBS="$SLIBS $(dirname $LIBPATH)/lib$LIBNAME.a"
+
+ # load static
+ load-static
+ load-all-symbols
+ CMD="$CMD -l$LIBNAME"
+
+ fi
+ fi
+
+ # not found within our directories
+ if [ $FOUND -eq 0 ]
+ then
+
+ if [ $STATICSYSLIBS -eq 1 ]
+ then
+ case "$LIBNAME" in
+ z|bz2)
+ # set load to static
+ load-static
+ load-all-symbols
+ ;;
+
+ *)
+ # set load to dynamic
+ load-ref-symbols
+ load-dynamic
+ ;;
+
+ esac
+ else
+ # set load to normal
+ load-ref-symbols
+ load-dynamic
+ fi
+
+ CMD="$CMD -l$LIBNAME"
+ fi
+ ;;
+
+ -s*)
+
+ # force static load
+ FOUND=0
+ find-lib $LIBNAME.a $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # found it
+ FOUND=1
+
+ # add it to dependencies
+ DEPS="$DEPS $LIBPATH"
+ SLIBS="$SLIBS $(dirname $LIBPATH)/lib$LIBNAME.a"
+
+ # load static
+ load-static
+ load-all-symbols
+ CMD="$CMD -l$LIBNAME"
+
+ fi
+
+ # not found within our directories
+ if [ $FOUND -eq 0 ]
+ then
+
+ if [ $STATIC -eq 1 ] || [ $STATICSYSLIBS -eq 1 ]
+ then
+ # set load to static
+ load-static
+ load-all-symbols
+ else
+
+ case "$LIBNAME" in
+ z|bz2)
+ # set load to dynamic
+ load-ref-symbols
+ load-dynamic
+ ;;
+
+ *)
+ # set load to static
+ load-static
+ load-all-symbols
+ ;;
+ esac
+ fi
+
+ CMD="$CMD -l$LIBNAME"
+ fi
+ ;;
+
+ -d*)
+
+ # only dynamic linkage
+ FOUND=0
+ if [ $STATIC -eq 0 ]
+ then
+ find-lib $LIBNAME.so $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # found it
+ FOUND=1
+
+ # load normally
+ load-ref-symbols
+ load-dynamic
+ CMD="$CMD -l$LIBNAME"
+
+ fi
+ fi
+
+ # not found within our directories
+ if [ $FOUND -eq 0 ]
+ then
+ # set load to normal
+ load-ref-symbols
+ load-dynamic
+ CMD="$CMD -l$LIBNAME"
+ fi
+ ;;
+
+ esac
+
+ done
+fi
+
+# put state back to normal
+load-ref-symbols
+load-dynamic
+
+# add in pthreads
+if [ $THREADS -ne 0 ]
+then
+ CMD="$CMD -lpthread"
+fi
+
+# add in xml
+if [ $HAVE_XML -ne 0 ]
+then
+ CMD="$CMD -lxml2"
+fi
+
+# add in math library
+if [ $HAVE_M -ne 0 ]
+then
+ CMD="$CMD -lm"
+fi
+
+# produce shared library
+echo "$CMD"
+$CMD || exit $?
+
+# produce dependencies
+if [ "$DEPFILE" != "" ]
+then
+ echo "$TARG: $DEPS" > "$DEPFILE"
+fi
+
+if [ $CHECKSUM -eq 1 ]
+then
+ SCM_DIR="${BUILD_DIR%/*}/scm"
+ LOGFILE="$SCM_DIR/scm.log"
+ MSG=">>>>> scm: calling the collect script from ld.linux.dlib.sh <<<<<<"
+ #echo "$MSG"
+ echo "$MSG" >> $LOGFILE
+
+ "$BUILD_DIR/scm-collect.sh" "$OBJS" "$SLIBS" | sort -u > "$TARG.md5"
+fi
diff --git a/biology/sra-tools/files/ld.bsd.exe.sh b/biology/sra-tools/files/ld.bsd.exe.sh
new file mode 100755
index 000000000000..650a212780c3
--- /dev/null
+++ b/biology/sra-tools/files/ld.bsd.exe.sh
@@ -0,0 +1,326 @@
+#!/usr/local/bin/bash
+# ===========================================================================
+#
+# PUBLIC DOMAIN NOTICE
+# National Center for Biotechnology Information
+#
+# This software/database is a "United States Government Work" under the
+# terms of the United States Copyright Act. It was written as part of
+# the author's official duties as a United States Government employee and
+# thus cannot be copyrighted. This software/database is freely available
+# to the public for use. The National Library of Medicine and the U.S.
+# Government have not placed any restriction on its use or reproduction.
+#
+# Although all reasonable efforts have been taken to ensure the accuracy
+# and reliability of the software and data, the NLM and the U.S.
+# Government do not and cannot warrant the performance or results that
+# may be obtained by using this software or data. The NLM and the U.S.
+# Government disclaim all warranties, express or implied, including
+# warranties of performance, merchantability or fitness for any particular
+# purpose.
+#
+# Please cite the author in any work or product based on this material.
+#
+# ===========================================================================
+
+
+# ===========================================================================
+# input library types, and their handling
+#
+# normal linkage
+# -l : find shared or static
+# -s : require static
+# -d : ignore - will be dynamically loaded
+#
+# static linkage
+# -l : require static
+# -s : require static
+# -d : require static
+# ===========================================================================
+
+
+# script name
+SELF_NAME="$(basename $0)"
+BUILD_DIR="$(dirname $0)"
+
+# parameters and common functions
+source "${0%exe.sh}cmn.sh"
+
+# discover tool chain
+case "$LD" in
+g*)
+ source "${0%exe.sh}gcc.sh"
+ ;;
+c*)
+ source "${0%exe.sh}clang.sh"
+ ;;
+*)
+ echo "$SELF_NAME: unrecognized ld tool - '$LD'"
+ exit 5
+esac
+
+# EXE_CMD was started in tool-specific source
+CMD="$EXE_CMD $LDFLAGS"
+
+# if building a static executable against dynamic libraries
+# the main application will substitute for name lookup
+if [ $STATIC -eq 1 ] && [ $DYLD -eq 1 ]
+then
+# CMD="$CMD $LD_EXPORT_GLOBAL $LD_MULTIPLE_DEFS"
+ CMD="$CMD $LD_EXPORT_GLOBAL"
+fi
+
+# tack on object files
+CMD="$CMD $OBJS"
+
+# list of static libraries used to create executable
+SLIBS=''
+
+# initial dependency upon Makefile and vers file
+DEPS="$SRCDIR/Makefile $VERSFILE"
+if [ "$LIBS" != "" ]
+then
+ # tack on paths
+ DIRS="$LDIRS:$XDIRS"
+ while [ "$DIRS" != "" ]
+ do
+ DIR="${DIRS%%:*}"
+ [ "$DIR" != "" ] && CMD="$CMD -L$DIR"
+ DIRS="${DIRS#$DIR}"
+ DIRS="${DIRS#:}"
+ done
+
+ # update LD_LIBRARY_PATH
+ unset LD_LIBRARY_PATH
+ export LD_LIBRARY_PATH="$LDIRS:$XDIRS"
+
+ # tack on libraries, finding as we go
+ for LIB in $LIBS
+ do
+
+ # strip off switch
+ LIBNAME="${LIB#-[lsd]}"
+
+ # look at linkage
+ case "$LIB" in
+ -ldl|-ddl)
+
+ # always load libdl as shared library
+ load-ref-symbols
+ load-dynamic
+# CMD="$CMD -ldl"
+ ;;
+
+ -l*)
+
+ # normal or dynamic linkage
+ FOUND=0
+ if [ $STATIC -eq 0 ]
+ then
+ find-lib $LIBNAME.so $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # found it
+ FOUND=1
+
+ # load dynamic
+ load-dynamic
+ CMD="$CMD -l$LIBNAME"
+
+ fi
+ fi
+
+ # try static only
+ if [ $FOUND -eq 0 ]
+ then
+ find-lib $LIBNAME.a $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # found it
+ FOUND=1
+
+ # add it to dependencies
+ DEPS="$DEPS $LIBPATH"
+ SLIBS="$SLIBS $(dirname $LIBPATH)/lib$LIBNAME.a"
+
+ # load static
+ load-static
+ [ $STATIC -eq 1 ] && load-all-symbols
+ CMD="$CMD -l$LIBNAME"
+
+ fi
+ fi
+
+ # not found within our directories
+ if [ $FOUND -eq 0 ]
+ then
+
+ # do not need to load all symbols for external libs
+ [ $STATIC -eq 1 ] && load-ref-symbols
+
+ if [ $STATICSYSLIBS -eq 1 ]
+ then
+ case "$LIBNAME" in
+ z|bz2)
+ # set load to static
+ load-static
+ ;;
+
+ *)
+ # set load to dynamic
+ load-dynamic
+ ;;
+
+ esac
+ else
+ # set load to normal
+ load-dynamic
+ fi
+
+ CMD="$CMD -l$LIBNAME"
+ fi
+ ;;
+
+ -s*)
+
+ # force static load
+ FOUND=0
+ find-lib $LIBNAME.a $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # found it
+ FOUND=1
+
+ # add it to dependencies
+ DEPS="$DEPS $LIBPATH"
+ SLIBS="$SLIBS $(dirname $LIBPATH)/lib$LIBNAME.a"
+
+ # load static
+ load-static
+ [ $STATIC -eq 1 ] && load-all-symbols
+ CMD="$CMD -l$LIBNAME"
+
+ fi
+
+ # not found within our directories
+ if [ $FOUND -eq 0 ]
+ then
+
+ # do not need to load all symbols for external libs
+ [ $STATIC -eq 1 ] && load-ref-symbols
+
+ if [ $STATIC -eq 1 ] || [ $STATICSYSLIBS -eq 1 ]
+ then
+
+ # set load to static
+ load-static
+
+ else
+
+ # special case for libs we have in "ext"
+ # that are sometimes requested as static
+ case "$LIBNAME" in
+ z|bz2)
+ # set load to dynamic
+ load-dynamic
+ ;;
+ *)
+ load-static
+ ;;
+ esac
+ fi
+
+ CMD="$CMD -l$LIBNAME"
+ fi
+ ;;
+
+ -d*)
+
+ FOUND=0
+ if [ $STATIC -eq 1 ]
+ then
+ find-lib $LIBNAME.a $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # found it
+ FOUND=1
+
+ # add it to dependencies
+ DEPS="$DEPS $LIBPATH"
+ SLIBS="$SLIBS $(dirname $LIBPATH)/lib$LIBNAME.a"
+
+ # load static
+ load-static
+ load-all-symbols
+
+ CMD="$CMD -l$LIBNAME"
+
+ fi
+
+ # not found within our directories
+ if [ $FOUND -eq 0 ]
+ then
+ load-static
+ load-all-symbols
+
+ CMD="$CMD -l$LIBNAME"
+ fi
+ fi
+ ;;
+
+
+ esac
+
+ done
+fi
+
+# return to normal
+load-ref-symbols
+load-dynamic
+
+# add in pthreads
+if [ $THREADS -ne 0 ]
+then
+ CMD="$CMD -lpthread"
+fi
+
+# add in xml
+# Doesn't work since ld.sh uses HAVE_XML=32, passed here as part of MODE
+if [ "$HAVE_XML2" = "1" ]
+then
+ CMD="$CMD -lxml2"
+fi
+
+# For sra-tools tools/*
+CMD="$CMD -lepoll-shim -lxml2 -lbz2 -lz"
+
+# add in math library
+if [ $HAVE_M -ne 0 ]
+then
+ CMD="$CMD -lm"
+fi
+
+# produce shared library
+echo $CMD
+$CMD || exit $?
+
+# produce dependencies
+if [ "$DEPFILE" != "" ]
+then
+ echo "$TARG: $DEPS" > "$DEPFILE"
+fi
+
+if [ $CHECKSUM -eq 1 ]
+then
+ SCM_DIR="${BUILD_DIR%/*}/scm"
+ LOGFILE="$SCM_DIR/scm.log"
+ MSG=">>>>> scm: calling the collect script from ld.linux.exe.sh <<<<<<"
+ #echo "$MSG"
+ echo "$MSG" >> $LOGFILE
+
+ "$BUILD_DIR/scm-collect.sh" "$OBJS" "$SLIBS" | sort -u > "$TARG.md5"
+fi
diff --git a/biology/sra-tools/files/ld.bsd.gcc.sh b/biology/sra-tools/files/ld.bsd.gcc.sh
new file mode 100755
index 000000000000..61c7779adcf1
--- /dev/null
+++ b/biology/sra-tools/files/ld.bsd.gcc.sh
@@ -0,0 +1,47 @@
+#!/usr/local/bin/bash
+# ===========================================================================
+#
+# PUBLIC DOMAIN NOTICE
+# National Center for Biotechnology Information
+#
+# This software/database is a "United States Government Work" under the
+# terms of the United States Copyright Act. It was written as part of
+# the author's official duties as a United States Government employee and
+# thus cannot be copyrighted. This software/database is freely available
+# to the public for use. The National Library of Medicine and the U.S.
+# Government have not placed any restriction on its use or reproduction.
+#
+# Although all reasonable efforts have been taken to ensure the accuracy
+# and reliability of the software and data, the NLM and the U.S.
+# Government do not and cannot warrant the performance or results that
+# may be obtained by using this software or data. The NLM and the U.S.
+# Government disclaim all warranties, express or implied, including
+# warranties of performance, merchantability or fitness for any particular
+# purpose.
+#
+# Please cite the author in any work or product based on this material.
+#
+# ===========================================================================
+
+# define linker params
+LD_EXPORT_GLOBAL="-Wl,--export-dynamic"
+LD_MULTIPLE_DEFS="-Wl,-zmuldefs"
+LD_STATIC="-Wl,-Bstatic"
+LD_DYNAMIC="-Wl,-Bdynamic"
+LD_ALL_SYMBOLS="-Wl,-whole-archive"
+LD_REF_SYMBOLS="-Wl,-no-whole-archive"
+
+# build command
+DLIB_CMD="$LD -shared"
+EXE_CMD="$LD"
+
+# versioned output
+if [ "$VERS" = "" ]
+then
+ DLIB_CMD="$DLIB_CMD -o $TARG"
+ EXE_CMD="$EXE_CMD -o $TARG"
+else
+ set-vers $(echo $VERS | tr '.' ' ')
+ DLIB_CMD="$DLIB_CMD -o $OUTDIR/$NAME$DBGAP.so.$VERS -Wl,-soname,$NAME.so.$MAJ"
+ EXE_CMD="$EXE_CMD -o $OUTDIR/$NAME$DBGAP.$VERS"
+fi
diff --git a/biology/sra-tools/files/ld.bsd.ln.sh b/biology/sra-tools/files/ld.bsd.ln.sh
new file mode 100755
index 000000000000..4897950a2144
--- /dev/null
+++ b/biology/sra-tools/files/ld.bsd.ln.sh
@@ -0,0 +1,98 @@
+#!/usr/local/bin/bash
+# ===========================================================================
+#
+# PUBLIC DOMAIN NOTICE
+# National Center for Biotechnology Information
+#
+# This software/database is a "United States Government Work" under the
+# terms of the United States Copyright Act. It was written as part of
+# the author's official duties as a United States Government employee and
+# thus cannot be copyrighted. This software/database is freely available
+# to the public for use. The National Library of Medicine and the U.S.
+# Government have not placed any restriction on its use or reproduction.
+#
+# Although all reasonable efforts have been taken to ensure the accuracy
+# and reliability of the software and data, the NLM and the U.S.
+# Government do not and cannot warrant the performance or results that
+# may be obtained by using this software or data. The NLM and the U.S.
+# Government disclaim all warranties, express or implied, including
+# warranties of performance, merchantability or fitness for any particular
+# purpose.
+#
+# Please cite the author in any work or product based on this material.
+#
+# ===========================================================================
+
+# script name
+SELF_NAME="$(basename $0)"
+
+# parameters
+TYPE="$1"
+OUTDIR="$2"
+TARG="$3"
+NAME="$4"
+DBGAP="$5"
+EXT="$6"
+VERS="$7"
+
+# find target
+TARG=$(basename "$TARG")
+
+# put extension back onto name
+NAME="$NAME$DBGAP"
+STATIC_NAME="$NAME-static"
+if [ "$EXT" != "" ]
+then
+ NAME="$NAME.$EXT"
+ STATIC_NAME="$STATIC_NAME.$EXT"
+fi
+
+# break out version
+set-vers ()
+{
+ MAJ=$1
+ MIN=$2
+ REL=$3
+}
+
+set-vers $(echo $VERS | tr '.' ' ')
+
+cd "$OUTDIR" || exit 5
+
+# create link
+create-link ()
+{
+ rm -f "$2"
+ local CMD="ln -s $1 $2"
+ echo $CMD
+ $CMD
+}
+
+# test for version in target name
+if [ "$TARG" != "$NAME.$MAJ.$MIN.$REL" ]
+then
+
+ # for simple name, create 2 links
+ if [ "$TARG" = "$NAME" ]
+ then
+ create-link "$NAME.$MAJ.$MIN.$REL" "$NAME.$MAJ"
+ create-link "$NAME.$MAJ" "$NAME"
+
+ # for static libraries, create special link
+ if [ "$TYPE" = "slib" ]
+ then
+ create-link "$NAME" "$STATIC_NAME"
+ fi
+
+ # for name with major version in it
+ elif [ "$TARG" = "$NAME.$MAJ" ]
+ then
+ create-link "$NAME.$MAJ.$MIN.$REL" "$NAME.$MAJ"
+
+
+ # for name with major & minor version in it
+ elif [ "$TARG" = "$NAME.$MAJ.$MIN" ]
+ then
+ create-link "$NAME.$MAJ.$MIN.$REL" "$NAME.$MAJ.$MIN"
+ fi
+fi
diff --git a/biology/sra-tools/files/ld.bsd.slib.sh b/biology/sra-tools/files/ld.bsd.slib.sh
new file mode 100755
index 000000000000..c0e85183ea4e
--- /dev/null
+++ b/biology/sra-tools/files/ld.bsd.slib.sh
@@ -0,0 +1,146 @@
+#!/usr/local/bin/bash
+# ===========================================================================
+#
+# PUBLIC DOMAIN NOTICE
+# National Center for Biotechnology Information
+#
+# This software/database is a "United States Government Work" under the
+# terms of the United States Copyright Act. It was written as part of
+# the author's official duties as a United States Government employee and
+# thus cannot be copyrighted. This software/database is freely available
+# to the public for use. The National Library of Medicine and the U.S.
+# Government have not placed any restriction on its use or reproduction.
+#
+# Although all reasonable efforts have been taken to ensure the accuracy
+# and reliability of the software and data, the NLM and the U.S.
+# Government do not and cannot warrant the performance or results that
+# may be obtained by using this software or data. The NLM and the U.S.
+# Government disclaim all warranties, express or implied, including
+# warranties of performance, merchantability or fitness for any particular
+# purpose.
+#
+# Please cite the author in any work or product based on this material.
+#
+# ===========================================================================
+
+
+# ===========================================================================
+# input library types, and their handling
+#
+# normal or static linkage
+# -l : require static
+# -s : require static
+# -d : ignore
+# ===========================================================================
+
+# script name
+SELF_NAME="$(basename $0)"
+BUILD_DIR="$(dirname $0)"
+
+# parameters and common functions
+source "${0%slib.sh}cmn.sh"
+
+# initialize command
+CMD="ar -rc"
+
+# function to convert an archive into individual object files
+convert-static ()
+{
+ # list members
+ local path="$1"
+ local mbrs="$(ar -t $path)"
+
+ # unpack archive into temporary directory
+ mkdir -p ld-tmp
+ if ! cd ld-tmp
+ then
+ echo "$SELF_NAME: failed to cd to ld-tmp"
+ exit 5
+ fi
+ ar -x "$path"
+
+ # rename and add to source files list
+ local m=
+ for m in $mbrs
+ do
+ mv $m $LIBNAME-$m
+ CMD="$CMD ld-tmp/$LIBNAME-$m"
+ done
+
+ # return to prior location
+ cd - > /dev/null
+}
+
+# versioned output
+if [ "$VERS" = "" ]
+then
+ CMD="$CMD $TARG"
+else
+ set-vers $(echo $VERS | tr '.' ' ')
+ CMD="$CMD $OUTDIR/$NAME$DBGAP.a.$VERS"
+fi
+
+# tack on object files
+CMD="$CMD $OBJS"
+
+# list of static libraries used to create this lib
+SLIBS=''
+
+# initial dependency upon Makefile and vers file
+DEPS="$SRCDIR/Makefile"
+if [ "$LIBS" != "" ]
+then
+ # tack on libraries, finding as we go
+ for LIB in $LIBS
+ do
+
+ # strip off switch
+ LIBNAME="${LIB#-[lsd]}"
+
+ # look at linkage
+ case "$LIB" in
+ -s*)
+
+ # force static load
+ find-lib $LIBNAME.a $LDIRS
+ if [ "$LIBPATH" != "" ]
+ then
+
+ # add it to dependencies
+ DEPS="$DEPS $LIBPATH"
+ SLIBS="$SLIBS $(dirname $LIBPATH)/lib$LIBNAME.a"
+
+ # convert to individual object files
+ convert-static "$LIBPATH" || exit $?
+
+ fi
+ ;;
+
+ esac
+
+ done
+fi
+
+# produce static library
+echo $CMD
+$CMD || exit $?
+
+# remove temporaries
+rm -rf ld-tmp
+
+# produce dependencies
+if [ "$DEPFILE" != "" ] && [ "$DEPS" != "" ]
+then
+ echo "$TARG: $DEPS" > "$DEPFILE"
+fi
+
+if [ $CHECKSUM -eq 1 ]
+then
+ SCM_DIR="${BUILD_DIR%/*}/scm"
+ LOGFILE="$SCM_DIR/scm.log"
+ MSG=">>>>> scm: calling the collect script from ld.linux.slib.sh <<<<<<"
+ #echo "$MSG"
+ echo "$MSG" >> $LOGFILE
+
+ "$BUILD_DIR/scm-collect.sh" "$OBJS" "$SLIBS" | sort -u > "$TARG.md5"
+fi
diff --git a/biology/sra-tools/files/patch-build_ld.linux.exe.sh b/biology/sra-tools/files/patch-build_ld.linux.exe.sh
new file mode 100644
index 000000000000..970a7e10aac8
--- /dev/null
+++ b/biology/sra-tools/files/patch-build_ld.linux.exe.sh
@@ -0,0 +1,11 @@
+--- build/ld.linux.exe.sh.orig 2021-06-20 16:32:05 UTC
++++ build/ld.linux.exe.sh
+@@ -313,6 +313,8 @@ then
+ fi
+ fi
+
++CMD="$CMD -lepoll-thread -lbz2 -lz"
++
+ # add in math library
+ if [ $HAVE_M -ne 0 ]
+ then
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.clang b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.clang
new file mode 100644
index 000000000000..99878e619099
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.clang
@@ -0,0 +1,30 @@
+--- ncbi-vdb/build/Makefile.clang.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/build/Makefile.clang
+@@ -24,23 +24,23 @@
+
+
+ # compilers
+-CC = @ $(TOP)/build/cc.sh $(OS) 'clang -c' \
++CC = @ $(TOP)/build/cc.sh $(OS) '$(CCNAME) -c' \
+ $(CHECKSUM) --objx $(OBJX) --cflags "$(CFLAGS)" -MD
+-CP = @ $(TOP)/build/cc.sh $(OS) 'clang++ -c' \
++CP = @ $(TOP)/build/cc.sh $(OS) '$(CXXNAME) -c' \
+ $(CHECKSUM) --objx $(OBJX) -stdlib=libc++ --cflags "$(CPFLAGS)" -MD
+
+ # C preprocessor
+ PP = gcc -E $(CFLAGS)
+
+ # linkers
+-LD = @ $(TOP)/build/ld.sh $(OS) $(ARCH) clang \
++LD = @ $(TOP)/build/ld.sh $(OS) $(ARCH) $(CCNAME) \
+ --build $(BUILD) --ldflags "$(LDFLAGS)" $(STATIC) \
+ $(STATICSYSLIBS) $(CHECKSUM) --objx $(OBJX) --shlx $(SHLX) --libx $(LIBX) \
+ -MD --srcdir $(SRCDIR) --bindir $(BINDIR) -L$(LIBDIR):$(ILIBDIR)
+
+ LPFLAGS = $(LDFLAGS)
+
+-LP = @ $(TOP)/build/ld.sh $(OS) $(ARCH) clang++ \
++LP = @ $(TOP)/build/ld.sh $(OS) $(ARCH) $(CXXNAME) \
+ --build $(BUILD) --ldflags "$(LDFLAGS)" $(STATIC) \
+ $(STATICSYSLIBS) $(CHECKSUM) --objx $(OBJX) --shlx $(SHLX) --libx $(LIBX) \
+ -MD --srcdir $(SRCDIR) --bindir $(BINDIR) -L$(LIBDIR):$(ILIBDIR)
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.env b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.env
new file mode 100644
index 000000000000..4e0b80a9bf78
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.env
@@ -0,0 +1,25 @@
+--- ncbi-vdb/build/Makefile.env.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/build/Makefile.env
+@@ -333,6 +333,22 @@ INCDIRS = \
+ $(addprefix -I,$(XTINC) $(NGSINC)) \
+ -I.
+
++# linker paths
++LDPATHS =
++
++ifneq (,$(HDF5_LIBDIR))
++ LDPATHS += -L$(HDF5_LIBDIR)
++endif
++ifneq (,$(XML2_LIBDIR))
++ LDPATHS += -L$(XML2_LIBDIR)
++endif
++ifneq (,$(MAGIC_LIBDIR))
++ LDPATHS += -L$(MAGIC_LIBDIR)
++endif
++ifneq (,$(FUSE_LIBDIR))
++ LDPATHS += -L$(FUSE_LIBDIR)
++endif
++
+
+ # defines that describe os & architecture
+ DLLX ?= $(SHLX)
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.gcc b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.gcc
new file mode 100644
index 000000000000..d2fc4c4e04c6
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.gcc
@@ -0,0 +1,35 @@
+--- ncbi-vdb/build/Makefile.gcc.orig 2017-07-14 21:55:36 UTC
++++ ncbi-vdb/build/Makefile.gcc
+@@ -22,25 +22,27 @@
+ #
+ # ===========================================================================
+
++CCNAME ?= gcc
++CXXNAME ?= g++
+
+ # compilers
+-CC = @ $(TOP)/build/cc.sh $(OS) 'gcc -c' \
++CC = @ $(TOP)/build/cc.sh $(OS) '$(CCNAME) -c' \
+ $(CHECKSUM) --objx $(OBJX) --cflags "$(CFLAGS)" -MD
+-CP = @ $(TOP)/build/cc.sh $(OS) 'g++ -c' \
++CP = @ $(TOP)/build/cc.sh $(OS) '$(CXXNAME) -c' \
+ $(CHECKSUM) --objx $(OBJX) --cflags "$(CPFLAGS)" -MD
+
+ # C preprocessor
+-PP = gcc -E $(CFLAGS)
++PP = $(CCNAME) -E $(CFLAGS)
+
+ # linkers
+-LD = @ $(TOP)/build/ld.sh $(OS) $(ARCH) gcc \
++LD = @ $(TOP)/build/ld.sh $(OS) $(ARCH) $(CCNAME) \
+ --build $(BUILD) --ldflags "$(LDFLAGS)" $(STATIC) \
+ $(STATICSYSLIBS) $(CHECKSUM) --objx $(OBJX) --shlx $(SHLX) --libx $(LIBX) \
+ -MD --srcdir $(SRCDIR) --bindir $(BINDIR) -L$(LIBDIR):$(ILIBDIR)
+
+ LPFLAGS = $(LDFLAGS)
+
+-LP = @ $(TOP)/build/ld.sh $(OS) $(ARCH) g++ \
++LP = @ $(TOP)/build/ld.sh $(OS) $(ARCH) $(CXXNAME) \
+ --build $(BUILD) --ldflags "$(LPFLAGS)" $(STATIC) \
+ $(STATICSYSLIBS) $(CHECKSUM) --objx $(OBJX) --shlx $(SHLX) --libx $(LIBX) \
+ -MD --srcdir $(SRCDIR) --bindir $(BINDIR) -L$(LIBDIR):$(ILIBDIR)
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.install b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.install
new file mode 100644
index 000000000000..143eb4d07868
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.install
@@ -0,0 +1,11 @@
+--- ncbi-vdb/build/Makefile.install.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/build/Makefile.install
+@@ -69,7 +69,7 @@ ifeq (1,$(HAVE_HDF5))
+ endif
+
+
+-LIB_TARGET = $(INST_LIBDIR)$(BITS)
++LIB_TARGET = $(INST_LIBDIR)
+
+ LIBRARIES_WITH_PREFIX = \
+ $(addprefix $(LIB_TARGET)/$(LPFX),$(LIBRARIES_TO_INSTALL))
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.shell b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.shell
new file mode 100644
index 000000000000..fb98fc610def
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_build_Makefile.shell
@@ -0,0 +1,31 @@
+--- ncbi-vdb/build/Makefile.shell.orig 2017-07-14 21:55:36 UTC
++++ ncbi-vdb/build/Makefile.shell
+@@ -36,6 +36,9 @@ endif
+ ifeq (Linux, $(UNAME))
+ HOST_OS = linux
+ endif
++ifeq (FreeBSD, $(UNAME))
++ HOST_OS = bsd
++endif
+ ifeq (SunOS, $(UNAME))
+ HOST_OS = sun
+ ARCHITECTURES = x86_64 i386
+@@ -83,6 +86,9 @@ else
+ ifeq (x86_64, $(MARCH))
+ HOST_ARCH = x86_64
+ endif
++ ifeq (amd64, $(MARCH))
++ HOST_ARCH = x86_64
++ endif
+ ifeq (i86pc, $(MARCH))
+ HOST_ARCH = x86_64
+ ARCHITECTURES = x86_64 i386
+@@ -93,7 +99,7 @@ else
+ endif
+ endif
+
+-ARCH = $(HOST_ARCH)
++override ARCH = $(HOST_ARCH)
+ REMOTE_ARCH = $(ARCH)
+
+ # pick up dependencies from object directory
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_interfaces_os_sun_atomic32.h b/biology/sra-tools/files/patch-ncbi-vdb_interfaces_os_sun_atomic32.h
new file mode 100644
index 000000000000..3edaa3fa3fb3
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_interfaces_os_sun_atomic32.h
@@ -0,0 +1,85 @@
+--- ncbi-vdb/interfaces/os/sun/atomic32.h.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/interfaces/os/sun/atomic32.h
+@@ -1,3 +1,66 @@
++#ifndef _h_atomic32_
++#define _h_atomic32_
++
++#include <sys/types.h>
++#include <machine/atomic.h>
++
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++/*
++ * /usr/src/sys/cddl/compat/opensolaris/sys/atomic.h
++ * BSD license
++ */
++
++#if defined(__i386__) || defined(__amd64__) || defined(__arm__)
++/* No spurious failures from fcmpset. */
++#define STRONG_FCMPSET
++#endif
++
++static inline uint32_t
++atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval)
++{
++#ifdef STRONG_FCMPSET
++ (void) atomic_fcmpset_32(target, &cmp, newval);
++#else
++ uint32_t expected = cmp;
++
++ do {
++ if (atomic_fcmpset_32(target, &cmp, newval))
++ break;
++ } while (cmp == expected);
++#endif
++ return (cmp);
++}
++
++static inline void atomic_inc_32(volatile uint32_t *target)
++{
++ atomic_add_32(target, 1);
++}
++
++static __inline uint32_t atomic_add_32_nv(volatile uint32_t *target, int32_t delta)
++{
++ return (atomic_fetchadd_32(target, delta) + delta);
++}
++
++static __inline uint32_t atomic_inc_32_nv(volatile uint32_t *target)
++{
++ return (atomic_add_32_nv(target, 1));
++}
++
++static __inline void
++atomic_dec_32(volatile uint32_t *target)
++{
++ atomic_subtract_32(target, 1);
++}
++
++static __inline uint32_t
++atomic_dec_32_nv(volatile uint32_t *target)
++{
++ return (atomic_fetchadd_32(target, -1) - 1);
++}
++
+ /*===========================================================================
+ *
+ * PUBLIC DOMAIN NOTICE
+@@ -23,15 +86,6 @@
+ * ===========================================================================
+ *
+ */
+-
+-#ifndef _h_atomic32_
+-#define _h_atomic32_
+-
+-#include <sys/atomic.h>
+-
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+
+ #ifndef __inline__
+ #define __inline__ inline
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_libs_ext_Makefile b/biology/sra-tools/files/patch-ncbi-vdb_libs_ext_Makefile
new file mode 100644
index 000000000000..4d3fae2846fd
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_libs_ext_Makefile
@@ -0,0 +1,12 @@
+--- ncbi-vdb/libs/ext/Makefile.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/libs/ext/Makefile
+@@ -32,9 +32,6 @@ include $(TOP)/build/Makefile.shell
+ # default
+ #
+ SUBDIRS = \
+- zlib \
+- bzip2 \
+- magic \
+ mbedtls
+
+ include $(TOP)/build/Makefile.targets
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_libs_kfg_config.c b/biology/sra-tools/files/patch-ncbi-vdb_libs_kfg_config.c
new file mode 100644
index 000000000000..f454a2b79c16
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_libs_kfg_config.c
@@ -0,0 +1,20 @@
+--- ncbi-vdb/libs/kfg/config.c.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/libs/kfg/config.c
+@@ -2577,7 +2577,7 @@ bool load_from_std_location ( KConfig *self, const KDi
+ const char * std_locs [] =
+ {
+ #if ! WINDOWS
+- "/etc/ncbi",
++ @@PREFIX@@ "/etc/ncbi",
+ #else
+ "/c/ncbi",
+ #endif
+@@ -2850,6 +2850,8 @@ void add_predefined_nodes ( KConfig * self, const char
+ #define OS "win"
+ #elif SUN
+ #define OS "sun"
++#elif BSD
++ #define OS "bsd"
+ #else
+ #error unrecognized OS
+ #endif
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_libs_klib_unix_systime.c b/biology/sra-tools/files/patch-ncbi-vdb_libs_klib_unix_systime.c
new file mode 100644
index 000000000000..3732c47ce93a
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_libs_klib_unix_systime.c
@@ -0,0 +1,11 @@
+--- ncbi-vdb/libs/klib/unix/systime.c.orig 2017-07-14 21:55:36 UTC
++++ ncbi-vdb/libs/klib/unix/systime.c
+@@ -142,7 +142,7 @@ LIB_EXPORT KTime_t CC KTimeMakeTime ( co
+ t . tm_isdst = self -> dst;
+
+ ts = mktime ( &t );
+- ts -= timezone;
++ ts += localtime(&ts)->tm_gmtoff;
+ }
+
+ return ts;
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_libs_kns_unix_syssock.c b/biology/sra-tools/files/patch-ncbi-vdb_libs_kns_unix_syssock.c
new file mode 100644
index 000000000000..50484bb1d503
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_libs_kns_unix_syssock.c
@@ -0,0 +1,10 @@
+--- ncbi-vdb/libs/kns/unix/syssock.c.orig 2017-07-14 21:55:36 UTC
++++ ncbi-vdb/libs/kns/unix/syssock.c
+@@ -66,6 +66,7 @@
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/un.h>
++#include <netinet/in.h>
+ #include <netinet/tcp.h>
+ #include <poll.h>
+ #include <unistd.h>
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_libs_ncbi-vdb_Makefile b/biology/sra-tools/files/patch-ncbi-vdb_libs_ncbi-vdb_Makefile
new file mode 100644
index 000000000000..7f5ad0a8802f
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_libs_ncbi-vdb_Makefile
@@ -0,0 +1,20 @@
+--- ncbi-vdb/libs/ncbi-vdb/Makefile.orig 2021-06-20 15:15:25 UTC
++++ ncbi-vdb/libs/ncbi-vdb/Makefile
+@@ -138,9 +138,7 @@ VDB_LIB_CMN = \
+ klib \
+ kproc \
+ $(LIBKQ) \
+- kfc \
+- bz2 \
+- z \
++ kfc
+
+ VDB_LIB_RD = \
+ align-reader \
+@@ -198,4 +196,4 @@ fuzz:
+ $(TOP)/build/ld.sh linux x86_64 gcc --build dbg --ldflags "-g -m64" --objx o --shlx so --libx a --srcdir $(SRCDIR) --bindir $(BINDIR) --slib -o $(FLIBDIR)/libncbi-vdb.$(LIBX) -L$(FLIBDIR) $(VDB_LIB) $(VDB_NGS_LIB)
+
+ cleanfuzz:
+- rm -rf $(FLIBDIR)/*
+\ No newline at end of file
++ rm -rf $(FLIBDIR)/*
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_libs_search_Makefile b/biology/sra-tools/files/patch-ncbi-vdb_libs_search_Makefile
new file mode 100644
index 000000000000..b1c52cb7ecf4
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_libs_search_Makefile
@@ -0,0 +1,12 @@
+--- ncbi-vdb/libs/search/Makefile.orig 2017-07-14 21:55:36 UTC
++++ ncbi-vdb/libs/search/Makefile
+@@ -39,6 +39,9 @@ OBJFILES = \
+
+ include $(TOP)/build/Makefile.env
+
++CARCH += -msse2
++# nucstrstr.c requires SSE2
++
+ #-------------------------------------------------------------------------------
+ # outer targets
+ #
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_setup_konfigure.perl b/biology/sra-tools/files/patch-ncbi-vdb_setup_konfigure.perl
new file mode 100644
index 000000000000..8d293bbd71cc
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_setup_konfigure.perl
@@ -0,0 +1,243 @@
+--- ncbi-vdb/setup/konfigure.perl.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/setup/konfigure.perl
+@@ -192,7 +192,7 @@ if ($OPT{'help'}) {
+ foreach (@ARGV) {
+ @_ = split('=');
+ next if ($#_ != 1);
+- $OPT{$_[0]} = $_[1] if ($_[0] eq 'CXX' || $_[0] eq 'LDFLAGS');
++ $OPT{$_[0]} = $_[1] if ($_[0] eq 'CC' || $_[0] eq 'CXX' || $_[0] eq 'LDFLAGS' || $_[0] eq 'TOOLS');
+ }
+
+ println "Configuring $PACKAGE_NAME package";
+@@ -204,7 +204,7 @@ print "checking system type... " unless ($AUTORUN);
+ my ($OS, $ARCH, $OSTYPE, $MARCH, @ARCHITECTURES) = OsArch();
+ println $OSTYPE unless ($AUTORUN);
+
+-unless ($OSTYPE =~ /linux/i || $OSTYPE =~ /darwin/i || $OSTYPE eq 'win') {
++unless ($OSTYPE =~ /linux/i || $OSTYPE =~ /freebsd/i || $OSTYPE =~ /darwin/i || $OSTYPE eq 'win') {
+ println "configure: error: unsupported system '$OSTYPE'";
+ exit 1;
+ }
+@@ -225,7 +225,7 @@ if ($OS eq 'linux') {
+
+ print "checking machine architecture... " unless ($AUTORUN);
+ println $MARCH unless ($AUTORUN);
+-unless ($MARCH =~ /x86_64/i || $MARCH =~ /i?86/i || $MARCH =~ /aarch64/) {
++unless ($MARCH =~ /x86_64/i || $MARCH =~ /amd64/i || $MARCH =~ /i?86/i || $MARCH =~ /aarch64/) {
+ println "configure: error: unsupported architecture '$OSTYPE':'$MARCH'";
+ exit 1;
+ }
+@@ -310,7 +310,7 @@ print "checking for supported architecture... " unless
+
+ my $BITS;
+
+-if ($MARCH =~ /x86_64/i) {
++if ($MARCH =~ /(x86_|amd)64/i) {
+ $BITS = 64;
+ } elsif ($MARCH eq 'fat86') {
+ $BITS = '32_64';
+@@ -337,6 +337,19 @@ if ($OSTYPE =~ /linux/i) {
+ $OSINC = 'unix';
+ $TOOLS = 'gcc' unless ($TOOLS);
+ $PYTHON = 'python';
++} elsif ($OSTYPE =~ /freebsd/i) {
++ $LPFX = 'lib';
++ $OBJX = 'o';
++ $LOBX = 'pic.o';
++ $LIBX = 'a';
++ $SHLX = 'so';
++ $EXEX = '';
++ $OSINC = 'unix';
++ unless ($TOOLS) {
++ $TOOLS = 'clang';
++ $TOOLS = $OPT{TOOLS} if ($OPT{TOOLS});
++ }
++ $PYTHON = $ENV{FREEBSD_PYTHON_CMD};
+ } elsif ($OSTYPE =~ /darwin/i) {
+ $LPFX = 'lib';
+ $OBJX = 'o';
+@@ -362,17 +375,19 @@ my ($ARCH_FL, $DBG, $OPT, $PIC, $INC, $MD, $LDFLAGS) =
+
+ print "checking for supported tool chain... " unless ($AUTORUN);
+
++$CC = $OPT{CC } if ($OPT{CC });
+ $CPP = $OPT{CXX } if ($OPT{CXX });
+ $LDFLAGS = $OPT{LDFLAGS} if ($OPT{LDFLAGS});
+
+ if ($TOOLS =~ /gcc$/) {
+ $CPP = 'g++' unless ($CPP);
+- $CC = "$TOOLS -c";
++ $CC = 'gcc' unless ($CC);
++ $LD = $CC;
++ $CC = "$CC -c";
+ $CP = "$CPP -c";
+ $AR = 'ar rc';
+ $ARX = 'ar x';
+ $ARLS = 'ar t';
+- $LD = $TOOLS;
+ $LP = $CPP;
+
+ $DBG = '-g -DDEBUG';
+@@ -382,21 +397,24 @@ if ($TOOLS =~ /gcc$/) {
+ $MD = '-MD';
+ } elsif ($TOOLS eq 'clang') {
+ $CPP = 'clang++' unless ($CPP);
+- $CC = 'clang -c';
+- my $versionMin = '-mmacosx-version-min=10.10';
++ $CC = 'clang' unless ($CC);
++ $LD = $CC;
++ $CC = "$CC -c";
++ my $versionMin = '';
++ $versionMin = '-mmacosx-version-min=10.6' if ($OSTYPE =~ /darwin/i);
+ $CP = "$CPP -c $versionMin";
+ if ($BITS ne '32_64') {
+ $ARCH_FL = '-arch i386' if ($BITS == 32);
+ $OPT = '-O3';
+ $AR = 'ar rc';
+- $LD = "clang $ARCH_FL";
++ $LD = "$LD $ARCH_FL";
+ $LP = "$CPP $versionMin $ARCH_FL";
+ } else {
+ $MAKE_MANIFEST = '( echo "$^" > $@/manifest )';
+ $ARCH_FL = '-arch i386 -arch x86_64';
+ $OPT = '-O3';
+ $AR = 'libtool -static -o';
+- $LD = "clang -Wl,-arch_multiple $ARCH_FL -Wl,-all_load";
++ $LD = "$LD -Wl,-arch_multiple $ARCH_FL -Wl,-all_load";
+ $LP = "$CPP $versionMin -Wl,-arch_multiple $ARCH_FL -Wl,-all_load";
+ }
+ $ARX = 'ar x';
+@@ -826,13 +844,13 @@ OS_ARCH = \$(shell perl \$(TOP)/setup/os-arch.perl)
+ # install paths
+ EndText
+
+- L($F, "INST_BINDIR = $OPT{'bindir'}" ) if ($OPT{'bindir'});
+- L($F, "INST_LIBDIR = $OPT{'libdir'}" ) if ($OPT{'libdir'});
+- L($F, "INST_INCDIR = $OPT{'includedir'}" ) if ($OPT{'includedir'});
+- L($F, "INST_SCHEMADIR = $OPT{'shemadir'}" ) if ($OPT{'shemadir'});
+- L($F, "INST_SHAREDIR = $OPT{'sharedir'}" ) if ($OPT{'sharedir'});
+- L($F, "INST_JARDIR = $OPT{'javadir'}" ) if ($OPT{'javadir'});
+- L($F, "INST_PYTHONDIR = $OPT{'pythondir'}") if ($OPT{'pythondir'});
++ L($F, "INST_BINDIR = \$(DESTDIR)$OPT{'bindir'}" ) if ($OPT{'bindir'});
++ L($F, "INST_LIBDIR = \$(DESTDIR)$OPT{'libdir'}" ) if ($OPT{'libdir'});
++ L($F, "INST_INCDIR = \$(DESTDIR)$OPT{'includedir'}" ) if ($OPT{'includedir'});
++ L($F, "INST_SCHEMADIR = \$(DESTDIR)$OPT{'shemadir'}" ) if ($OPT{'shemadir'});
++ L($F, "INST_SHAREDIR = \$(DESTDIR)$OPT{'sharedir'}" ) if ($OPT{'sharedir'});
++ L($F, "INST_JARDIR = \$(DESTDIR)$OPT{'javadir'}" ) if ($OPT{'javadir'});
++ L($F, "INST_PYTHONDIR = \$(DESTDIR)$OPT{'pythondir'}") if ($OPT{'pythondir'});
+
+ my ($E_VERSION_SHLX, $VERSION_SHLX,
+ $E_MAJVERS_SHLX , $MAJMIN_SHLX, $MAJVERS_SHLX);
+@@ -896,7 +914,7 @@ MAJMIN_EXEX = \$(EXEX).\$(MAJMIN)
+ MAJVERS_EXEX = \$(EXEX).\$(MAJVERS)
+
+ # system architecture and wordsize
+-ARCH = $ARCH
++override ARCH = $ARCH
+ EndText
+
+ L($F, "# ARCH = $ARCH ( $MARCH )") if ($ARCH ne $MARCH);
+@@ -932,7 +950,7 @@ EndText
+ }
+ L($F, "PIC = $PIC") if ($PIC);
+ if ($PKG{LNG} eq 'C') {
+- if ($TOOLS =~ /clang/i) {
++ if ($OSTYPE =~ /darwin/i) {
+ L($F, 'SONAME = -install_name ' .
+ '$(INST_LIBDIR)$(BITS)/$(subst $(VERSION),$(MAJVERS),$(@F)) \\');
+ L($F, ' -compatibility_version $(MAJMIN) -current_version $(VERSION) \\');
+@@ -1043,7 +1061,7 @@ EndText
+ L($F, '# directory rules');
+ if ($PKG{LNG} eq 'C') {
+ L($F, '$(BINDIR) $(LIBDIR) $(ILIBDIR) '
+- . '$(OBJDIR) $(INST_LIBDIR) $(INST_LIBDIR)$(BITS):');
++ . '$(OBJDIR) $(INST_LIBDIR):');
+ T($F, 'mkdir -p $@');
+ } elsif ($PKG{LNG} eq 'JAVA') {
+ # test if we have jni header path
+@@ -1073,12 +1091,12 @@ EndText
+ L($F, 'export CONFIGURE_FOUND_XML2');
+ L($F);
+
+- if ($OS eq 'linux' || $OS eq 'mac') {
++ if ($OS eq 'linux' || $OS eq 'bsd' || $OS eq 'mac') {
+ L($F, '# installation rules');
+ L($F,
+- '$(INST_LIBDIR)$(BITS)/%.$(VERSION_LIBX): $(LIBDIR)/%.$(VERSION_LIBX)');
++ '$(INST_LIBDIR)/%.$(VERSION_LIBX): $(LIBDIR)/%.$(VERSION_LIBX)');
+ T($F, '@ echo -n "installing \'$(@F)\'... "');
+- T($F, '@ if cp $^ $@ && chmod 644 $@; \\');
++ T($F, '@ if $(BSD_INSTALL_DATA) $^ $@; \\');
+ T($F, ' then \\');
+ T($F, ' rm -f $(patsubst %$(VERSION),%$(MAJVERS),$@) '
+ . '$(patsubst %$(VERSION_LIBX),%$(LIBX),$@) '
+@@ -1087,7 +1105,7 @@ EndText
+ T($F, ' ln -s $(patsubst %$(VERSION),%$(MAJVERS),$(@F)) '
+ . '$(patsubst %$(VERSION_LIBX),%$(LIBX),$@); \\');
+ T($F, ' ln -s $(patsubst %$(VERSION_LIBX),%$(LIBX),$(@F)) ' .
+- '$(INST_LIBDIR)$(BITS)/$(patsubst %.$(VERSION_LIBX),%-static.$(LIBX),$(@F));'
++ '$(INST_LIBDIR)/$(patsubst %.$(VERSION_LIBX),%-static.$(LIBX),$(@F));'
+ . ' \\');
+ T($F, ' echo success; \\');
+ T($F, ' else \\');
+@@ -1097,15 +1115,15 @@ EndText
+ L($F);
+
+ L($F,
+- '$(INST_LIBDIR)$(BITS)/%.$(VERSION_SHLX): $(LIBDIR)/%.$(VERSION_SHLX)');
++ '$(INST_LIBDIR)/%.$(VERSION_SHLX): $(LIBDIR)/%.$(VERSION_SHLX)');
+ T($F, '@ echo -n "installing \'$(@F)\'... "');
+- T($F, '@ if cp $^ $@ && chmod 755 $@; \\');
++ T($F, '@ if $(BSD_INSTALL_LIB) $^ $@; \\');
+ T($F, ' then \\');
+ if ($OS ne 'mac') {
+ T($F, ' rm -f $(patsubst %$(VERSION),%$(MAJVERS),$@) '
+ . '$(patsubst %$(VERSION_SHLX),%$(SHLX),$@); \\');
+ }
+- if ($OS eq 'linux') {
++ if ($OS eq 'linux' || $OS eq 'bsd') {
+ T($F, ' ln -s $(@F) $(patsubst %$(VERSION),%$(MAJVERS),$@); \\');
+ } elsif ($OS eq 'mac') {
+ T($F, ' ln -sf $(@F) '
+@@ -1124,7 +1142,7 @@ EndText
+
+ L($F, '$(INST_BINDIR)/%$(VERSION_EXEX): $(BINDIR)/%$(VERSION_EXEX)');
+ T($F, '@ echo -n "installing \'$(@F)\'... "');
+- T($F, '@ if cp $^ $@ && chmod 755 $@; \\');
++ T($F, '@ if $(BSD_INSTALL_PROGRAM) $^ $@; \\');
+ T($F, ' then \\');
+ T($F, ' rm -f $(patsubst %$(VERSION),%$(MAJVERS),$@) '
+ . '$(patsubst %$(VERSION_EXEX),%$(EXEX),$@); \\');
+@@ -1406,7 +1424,7 @@ sub find_in_dir {
+ ++$found;
+ }
+ if (! $found) {
+- my $libdir = File::Spec->catdir($dir, 'lib' . $BITS);
++ my $libdir = File::Spec->catdir($dir, 'lib');
+ my $f = File::Spec->catdir($libdir, $lib);
+ print "\tchecking $f\n\t" if ($OPT{'debug'});
+ if (-e $f) {
+@@ -1628,12 +1646,12 @@ sub find_lib {
+
+ sub check_compiler {
+ my ($t, $n, $I, @l) = @_;
+- my $tool = $TOOLS;
++ my $tool = $CC;
+
+ if ($t eq 'L') {
+ print "checking for $n library... ";
+ } elsif ($t eq 'O') {
+- if ($tool && ($tool =~ /gcc$/ || $tool =~ /g\+\+$/)) {
++ if ($tool && ($tool =~ /gcc/ || $tool =~ /g\+\+/)) {
+ print "checking whether $tool accepts $n... ";
+ } else {
+ return;
+@@ -1706,7 +1724,7 @@ sub check_compiler {
+ }
+ }
+ my $gcc = "| $tool -xc $flags " . ($I ? "-I$I " : ' ')
+- . ($l ? "-L$l " : ' ') . "- $library";
++ . ($l ? "-L$l " : ' ') . "-o a.out - $library";
+ $gcc .= ' 2> /dev/null' unless ($OPT{'debug'});
+
+ open GCC, $gcc or last;
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_setup_os-arch.prl b/biology/sra-tools/files/patch-ncbi-vdb_setup_os-arch.prl
new file mode 100644
index 000000000000..01cb9824ff7b
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_setup_os-arch.prl
@@ -0,0 +1,20 @@
+--- ncbi-vdb/setup/os-arch.prl.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/setup/os-arch.prl
+@@ -11,6 +11,8 @@ sub OsArch {
+ chomp $UNAME;
+ if ($UNAME =~ /Darwin/) {
+ $HOST_OS = 'mac';
++ } elsif ($UNAME =~ /.*BSD/) {
++ $HOST_OS = 'bsd';
+ } elsif ($UNAME =~ /Linux/) {
+ $HOST_OS = 'linux';
+ } elsif ($UNAME =~ /SunOS/) {
+@@ -48,6 +50,8 @@ sub OsArch {
+ $HOST_ARCH = 'i386';
+ }
+ } elsif ($MARCH =~ /x86_64/) {
++ $HOST_ARCH = 'x86_64';
++ } elsif ($MARCH =~ /amd64/) {
+ $HOST_ARCH = 'x86_64';
+ } elsif ($MARCH =~ /i86pc/) {
+ $HOST_ARCH = 'x86_64';
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_test_kapp_run-sig-core.sh b/biology/sra-tools/files/patch-ncbi-vdb_test_kapp_run-sig-core.sh
new file mode 100644
index 000000000000..ebc81bd3fc5b
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_test_kapp_run-sig-core.sh
@@ -0,0 +1,49 @@
+--- ncbi-vdb/test/kapp/run-sig-core.sh.orig 2017-10-27 07:23:08 UTC
++++ ncbi-vdb/test/kapp/run-sig-core.sh
+@@ -29,12 +29,12 @@ BUILD_TYPE="$3"
+
+ SIGQUIT=3
+
+-function killFromBackground ()
++killFromBackground ()
+ {
+ PARENT_PID=$1
+ for I in 1 2 3 4 5
+ do
+- COMMAND="ps -ef|awk '\$3==${PARENT_PID} && \$8==\"${BINARY_PATH}\" {print \$2}'"
++ COMMAND="ps awwo pid,ppid,command|awk '\$2==${PARENT_PID} && \$3==\"${BINARY_PATH}\" {print \$1}'"
+ eval PID=\`${COMMAND}\`
+ if [ "$PID" = "" ]; then
+ sleep 1
+@@ -44,7 +44,7 @@ function killFromBackground ()
+ done
+
+ if [ "$PID" != "" ]; then
+- kill -s $SIGQUIT $PID
++ kill -s QUIT $PID
+ fi
+
+ echo $PID > killed.pid
+@@ -63,6 +63,13 @@ if [ "$HOST_OS" = "mac" ]; then
+ fi
+
+ CORE_FOLDER="/core/"
++elif [ "$HOST_OS" = "bsd" ]; then
++ if [ "`ulimit -c`" = "0" ] || [ "`/sbin/sysctl -n kern.coredump`" != "1" ]; then
++ echo "Core files are disabled. Skipping core file tests"
++ exit 0
++ fi
++
++ CORE_FOLDER="./"
+ elif [ "$HOST_OS" = "linux" ]; then
+ if [ "`ulimit -c`" = "0" ]; then
+ echo "Core files are disabled. Skipping core file tests"
+@@ -92,7 +99,7 @@ wait
+ BINARY_PID=`cat killed.pid`
+ rm killed.pid
+
+-CORE_FILE="${CORE_FOLDER}core.${BINARY_PID}"
++CORE_FILE="${CORE_FOLDER}${BINARY_PATH##*/}.core"
+
+ if [ "$BUILD_TYPE" = "dbg" ]; then
+ if [ -f $CORE_FILE ]; then
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_test_kfg_kfgtest.cpp b/biology/sra-tools/files/patch-ncbi-vdb_test_kfg_kfgtest.cpp
new file mode 100644
index 000000000000..468483b89535
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_test_kfg_kfgtest.cpp
@@ -0,0 +1,11 @@
+--- ncbi-vdb/test/kfg/kfgtest.cpp.orig 2019-08-20 18:27:10 UTC
++++ ncbi-vdb/test/kfg/kfgtest.cpp
+@@ -280,6 +280,8 @@ FIXTURE_TEST_CASE(predef_OS, KfgFixture)
+ CreateAndLoad(GetName(), "var=$(OS)\n");
+ #if LINUX
+ #define OS "linux"
++ #elif BSD
++ #define OS "bsd"
+ #elif SUN
+ #define OS "sun"
+ #elif MAC
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_test_klib_printf-test.c b/biology/sra-tools/files/patch-ncbi-vdb_test_klib_printf-test.c
new file mode 100644
index 000000000000..76b1210a7ae7
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_test_klib_printf-test.c
@@ -0,0 +1,11 @@
+--- ncbi-vdb/test/klib/printf-test.c.orig 2019-08-20 18:27:10 UTC
++++ ncbi-vdb/test/klib/printf-test.c
+@@ -503,7 +503,7 @@ rc_t run ( const char *progname )
+ if ( rc == 0 )
+ {
+ rc = make_initial_test ( field_width, precision, " ", "s", "Kurt is having a fit" );
+-#if !defined(__SunOS) && !defined(__sun__)
++#if !defined(__SunOS) && !defined(__sun__) && !defined(__FreeBSD__)
+ /* Solaris printf doesn't cope with NULLs */
+ rc = make_initial_test ( field_width, precision, " ", "s", NULL );
+ #endif
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_test_kns_Makefile b/biology/sra-tools/files/patch-ncbi-vdb_test_kns_Makefile
new file mode 100644
index 000000000000..958399985cc9
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_test_kns_Makefile
@@ -0,0 +1,19 @@
+--- ncbi-vdb/test/kns/Makefile.orig 2021-03-15 18:16:43 UTC
++++ ncbi-vdb/test/kns/Makefile
+@@ -25,7 +25,7 @@
+
+ default: runtests
+
+-runtests: run-tests run-test-proxy-with-scheme
++runtests:
+
+ TOP ?= $(abspath ../..)
+ MODULE = test/kns
+@@ -133,6 +133,7 @@ $(TEST_BINDIR)/test-kns: $(KNSTEST_OBJ)
+ $(LP) --exe -o $@ $^ $(KNSTEST_LIB)
+
+ kns: test-kns
++ if [ ! -d $(HOME)/.ncbi ]; then mkdir $(HOME)/.ncbi; fi
+ $(TEST_BINDIR)/test-kns #-l=all
+
+ #----------------------------------------------------------------
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_test_vdb_test-dependencies.cpp b/biology/sra-tools/files/patch-ncbi-vdb_test_vdb_test-dependencies.cpp
new file mode 100644
index 000000000000..52bcf0460632
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_test_vdb_test-dependencies.cpp
@@ -0,0 +1,11 @@
+--- ncbi-vdb/test/vdb/test-dependencies.cpp.orig 2019-08-20 18:27:10 UTC
++++ ncbi-vdb/test/vdb/test-dependencies.cpp
+@@ -115,7 +115,7 @@ class EmptyFixture : public DepFixture { (public)
+
+ class RefseqFixture : public DepFixture {
+
+- #if LINUX
++ #if LINUX || BSD
+ #define PATH "kfg/linux"
+ #elif MAC
+ #define PATH "kfg/mac"
diff --git a/biology/sra-tools/files/patch-ncbi-vdb_test_vfs_redirect-rejected-names-cgi-http-to-https.cpp b/biology/sra-tools/files/patch-ncbi-vdb_test_vfs_redirect-rejected-names-cgi-http-to-https.cpp
new file mode 100644
index 000000000000..12780a95a08a
--- /dev/null
+++ b/biology/sra-tools/files/patch-ncbi-vdb_test_vfs_redirect-rejected-names-cgi-http-to-https.cpp
@@ -0,0 +1,11 @@
+--- ncbi-vdb/test/vfs/redirect-rejected-names-cgi-http-to-https.cpp.orig 2017-07-14 21:55:36 UTC
++++ ncbi-vdb/test/vfs/redirect-rejected-names-cgi-http-to-https.cpp
+@@ -148,7 +148,7 @@ struct Test : protected ncbi :: NK :: Sh
+
+ TEST_CASE(TEST) {
+
+-#define RESOLVER_CGI_HEAD "test.ncbi.nlm.nih."
++#define RESOLVER_CGI_HEAD "www.ncbi.nlm.nih."
+
+ #ifdef VDB_3162
+ #else
diff --git a/biology/sra-tools/files/patch-setup_install.perl b/biology/sra-tools/files/patch-setup_install.perl
new file mode 100644
index 000000000000..cc2eade52c15
--- /dev/null
+++ b/biology/sra-tools/files/patch-setup_install.perl
@@ -0,0 +1,13 @@
+--- setup/install.perl.orig 2021-03-15 18:25:25 UTC
++++ setup/install.perl
+@@ -1283,8 +1283,8 @@ sub prepare {
+ ' $_{INST_JARDIR } = "$_{PREFIX}/jar"; ' .
+ ' $_{INST_SHAREDIR} = "$_{PREFIX}/share"; ' .
+ ' $_{INCDIR } = "$Bin/../include"; ' .
+- ' $_{LIBDIR64 } = "$Bin/../lib64"; ' .
+- ' $_{LIBDIR32 } = "$Bin/../lib32"; ';
++ ' $_{LIBDIR64 } = "$Bin/../lib"; ' .
++ ' $_{LIBDIR32 } = "$Bin/../lib"; ';
+ if ($HAVE{TWO_LIBS}) {
+ $code .=
+ '$_{INST_NGSLIBDIR} = "' . "$root/usr/local/ngs/ngs-sdk/lib\";"
diff --git a/biology/sra-tools/files/patch-setup_konfigure.perl b/biology/sra-tools/files/patch-setup_konfigure.perl
new file mode 100644
index 000000000000..aacfe898be6d
--- /dev/null
+++ b/biology/sra-tools/files/patch-setup_konfigure.perl
@@ -0,0 +1,121 @@
+--- setup/konfigure.perl.orig 2021-03-15 18:25:25 UTC
++++ setup/konfigure.perl
+@@ -204,7 +204,7 @@ print "checking system type... " unless ($AUTORUN);
+ my ($OS, $ARCH, $OSTYPE, $MARCH, @ARCHITECTURES) = OsArch();
+ println $OSTYPE unless ($AUTORUN);
+
+-unless ($OSTYPE =~ /linux/i || $OSTYPE =~ /darwin/i || $OSTYPE eq 'win') {
++unless ($OSTYPE =~ /linux/i || $OSTYPE =~ /darwin/i || $OSTYPE eq 'win' || $OSTYPE =~ /freebsd/i) {
+ println "configure: error: unsupported system '$OSTYPE'";
+ exit 1;
+ }
+@@ -225,7 +225,7 @@ if ($OS eq 'linux') {
+
+ print "checking machine architecture... " unless ($AUTORUN);
+ println $MARCH unless ($AUTORUN);
+-unless ($MARCH =~ /x86_64/i || $MARCH =~ /i?86/i || $MARCH =~ /aarch64/) {
++unless ($MARCH =~ /x86_64/i || $MARCH =~ /amd64/i || $MARCH =~ /i?86/i || $MARCH =~ /aarch64/) {
+ println "configure: error: unsupported architecture '$OSTYPE':'$MARCH'";
+ exit 1;
+ }
+@@ -310,7 +310,7 @@ print "checking for supported architecture... " unless
+
+ my $BITS;
+
+-if ($MARCH =~ /x86_64/i) {
++if ($MARCH =~ /x86_64/i || $MARCH =~ /amd64/i) {
+ $BITS = 64;
+ } elsif ($MARCH eq 'fat86') {
+ $BITS = '32_64';
+@@ -337,6 +337,16 @@ if ($OSTYPE =~ /linux/i) {
+ $OSINC = 'unix';
+ $TOOLS = 'gcc' unless ($TOOLS);
+ $PYTHON = 'python';
++} elsif ($OSTYPE =~ /freebsd/i) {
++ $LPFX = 'lib';
++ $OBJX = 'o';
++ $LOBX = 'pic.o';
++ $LIBX = 'a';
++ $SHLX = 'so';
++ $EXEX = '';
++ $OSINC = 'unix';
++ $TOOLS = 'clang' unless ($TOOLS);
++ $PYTHON = 'python';
+ } elsif ($OSTYPE =~ /darwin/i) {
+ $LPFX = 'lib';
+ $OBJX = 'o';
+@@ -512,7 +522,7 @@ foreach my $href (DEPENDS()) {
+ $I = $t if (-e $t);
+ }
+ push ( @L, File::Spec->catdir($OPT{$o}, 'lib') );
+- push ( @L, File::Spec->catdir($OPT{$o}, 'lib64') );
++ #push ( @L, File::Spec->catdir($OPT{$o}, 'lib64') );
+ }
+ my ($i, $l) = find_lib($_, $I, @L);
+ if (defined $i || $l) {
+@@ -934,7 +944,7 @@ EndText
+ if ($PKG{LNG} eq 'C') {
+ if ($TOOLS =~ /clang/i) {
+ L($F, 'SONAME = -install_name ' .
+- '$(INST_LIBDIR)$(BITS)/$(subst $(VERSION),$(MAJVERS),$(@F)) \\');
++ '$(INST_LIBDIR)/$(subst $(VERSION),$(MAJVERS),$(@F)) \\');
+ L($F, ' -compatibility_version $(MAJMIN) -current_version $(VERSION) \\');
+ L($F, ' -flat_namespace -undefined suppress');
+ } else {
+@@ -1043,7 +1053,7 @@ EndText
+ L($F, '# directory rules');
+ if ($PKG{LNG} eq 'C') {
+ L($F, '$(BINDIR) $(LIBDIR) $(ILIBDIR) '
+- . '$(OBJDIR) $(INST_LIBDIR) $(INST_LIBDIR)$(BITS):');
++ . '$(OBJDIR) $(INST_LIBDIR) $(INST_LIBDIR):');
+ T($F, 'mkdir -p $@');
+ } elsif ($PKG{LNG} eq 'JAVA') {
+ # test if we have jni header path
+@@ -1076,7 +1086,7 @@ EndText
+ if ($OS eq 'linux' || $OS eq 'mac') {
+ L($F, '# installation rules');
+ L($F,
+- '$(INST_LIBDIR)$(BITS)/%.$(VERSION_LIBX): $(LIBDIR)/%.$(VERSION_LIBX)');
++ '$(INST_LIBDIR)/%.$(VERSION_LIBX): $(LIBDIR)/%.$(VERSION_LIBX)');
+ T($F, '@ echo -n "installing \'$(@F)\'... "');
+ T($F, '@ if cp $^ $@ && chmod 644 $@; \\');
+ T($F, ' then \\');
+@@ -1087,7 +1097,7 @@ EndText
+ T($F, ' ln -s $(patsubst %$(VERSION),%$(MAJVERS),$(@F)) '
+ . '$(patsubst %$(VERSION_LIBX),%$(LIBX),$@); \\');
+ T($F, ' ln -s $(patsubst %$(VERSION_LIBX),%$(LIBX),$(@F)) ' .
+- '$(INST_LIBDIR)$(BITS)/$(patsubst %.$(VERSION_LIBX),%-static.$(LIBX),$(@F));'
++ '$(INST_LIBDIR)/$(patsubst %.$(VERSION_LIBX),%-static.$(LIBX),$(@F));'
+ . ' \\');
+ T($F, ' echo success; \\');
+ T($F, ' else \\');
+@@ -1097,7 +1107,7 @@ EndText
+ L($F);
+
+ L($F,
+- '$(INST_LIBDIR)$(BITS)/%.$(VERSION_SHLX): $(LIBDIR)/%.$(VERSION_SHLX)');
++ '$(INST_LIBDIR)/%.$(VERSION_SHLX): $(LIBDIR)/%.$(VERSION_SHLX)');
+ T($F, '@ echo -n "installing \'$(@F)\'... "');
+ T($F, '@ if cp $^ $@ && chmod 755 $@; \\');
+ T($F, ' then \\');
+@@ -1168,9 +1178,9 @@ EndText
+ print $F " \$_{INCDIR } = '" . expand("$Bin/.." ) . "';\n";
+ if ($PKG{LNG} ne 'PYTHON') {
+ print $F " \$_{BINDIR$BITS} = '" . expand($E_BINDIR ) . "';\n";
+- print $F " \$_{LIBDIR$BITS} = '" . expand($E_LIBDIR ) . "';\n";
++ print $F " \$_{LIBDIR} = '" . expand($E_LIBDIR ) . "';\n";
+ } elsif ($OPT{PYTHON_LIB_PATH}) {
+- print $F " \$_{LIBDIR$BITS} = '$OPT{PYTHON_LIB_PATH}';\n";
++ print $F " \$_{LIBDIR} = '$OPT{PYTHON_LIB_PATH}';\n";
+ }
+ print $F " \$_{OTHER_PREFIX } = '$PKG{UPATH}';\n";
+ print $F " \$_{PREFIX } = '$OPT{'prefix'}';\n";
+@@ -1406,7 +1416,7 @@ sub find_in_dir {
+ ++$found;
+ }
+ if (! $found) {
+- my $libdir = File::Spec->catdir($dir, 'lib' . $BITS);
++ my $libdir = File::Spec->catdir($dir, 'lib');
+ my $f = File::Spec->catdir($libdir, $lib);
+ print "\tchecking $f\n\t" if ($OPT{'debug'});
+ if (-e $f) {
diff --git a/biology/sra-tools/files/patch-tools_bam-loader_loader-imp.c b/biology/sra-tools/files/patch-tools_bam-loader_loader-imp.c
new file mode 100644
index 000000000000..9b78a578a601
--- /dev/null
+++ b/biology/sra-tools/files/patch-tools_bam-loader_loader-imp.c
@@ -0,0 +1,10 @@
+--- tools/bam-loader/loader-imp.c.orig 2021-06-20 16:59:47 UTC
++++ tools/bam-loader/loader-imp.c
+@@ -71,6 +71,7 @@
+ #include <sysalloc.h>
+ #include <atomic32.h>
+
++#include <sys/stat.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/mman.h>
diff --git a/biology/sra-tools/files/patch-tools_copycat_Makefile b/biology/sra-tools/files/patch-tools_copycat_Makefile
new file mode 100644
index 000000000000..fb24ac9e5d4e
--- /dev/null
+++ b/biology/sra-tools/files/patch-tools_copycat_Makefile
@@ -0,0 +1,11 @@
+--- tools/copycat/Makefile.orig 2021-06-20 17:45:49 UTC
++++ tools/copycat/Makefile
+@@ -92,7 +92,7 @@ COPYCAT_LIB = \
+ -stk-version \
+ -sncbi-vdb \
+ -skff \
+- -smagic-static
++ -smagic
+
+
+ $(BINDIR)/copycat: $(COPYCAT_OBJ)
diff --git a/biology/sra-tools/files/patch-tools_driver-tool_Makefile b/biology/sra-tools/files/patch-tools_driver-tool_Makefile
new file mode 100644
index 000000000000..408b82819a43
--- /dev/null
+++ b/biology/sra-tools/files/patch-tools_driver-tool_Makefile
@@ -0,0 +1,16 @@
+--- tools/driver-tool/Makefile.orig 2021-03-15 18:25:25 UTC
++++ tools/driver-tool/Makefile
+@@ -97,7 +97,12 @@ SRATOOLS_OBJ = \
+ SRATOOLS_LIB = \
+ -sncbi-vdb \
+ -sjson \
+- -lm
++ -lepoll-shim \
++ -lmbedtls \
++ -lm \
++ -lexecinfo \
++ -lz \
++ -lbz2
+
+ $(BINDIR)/sratools: $(SRATOOLS_OBJ) $(ILIBDIR)/libjson.$(LIBX)
+ $(LP) --exe --vers $(SRCDIR)/../../shared/toolkit.vers -o $@ $^ $(SRATOOLS_LIB)
diff --git a/biology/sra-tools/files/patch-tools_driver-tool_cmdline.cpp b/biology/sra-tools/files/patch-tools_driver-tool_cmdline.cpp
new file mode 100644
index 000000000000..46747e4840e5
--- /dev/null
+++ b/biology/sra-tools/files/patch-tools_driver-tool_cmdline.cpp
@@ -0,0 +1,13 @@
+--- tools/driver-tool/cmdline.cpp.orig 2021-04-21 19:42:12 UTC
++++ tools/driver-tool/cmdline.cpp
+@@ -50,6 +50,10 @@
+ #define environ (*_NSGetEnviron())
+ #endif
+
++#if defined(__FreeBSD__)
++extern char **environ;
++#endif
++
+ #define TRACE( lvl, ... ) /* ignore */
+
+ namespace ncbi
diff --git a/biology/sra-tools/files/patch-tools_driver-tool_utf8proc_Makefile b/biology/sra-tools/files/patch-tools_driver-tool_utf8proc_Makefile
new file mode 100644
index 000000000000..c5c827645c95
--- /dev/null
+++ b/biology/sra-tools/files/patch-tools_driver-tool_utf8proc_Makefile
@@ -0,0 +1,11 @@
+--- tools/driver-tool/utf8proc/Makefile.orig 2021-04-29 14:50:48 UTC
++++ tools/driver-tool/utf8proc/Makefile
+@@ -79,7 +79,7 @@ libutf8proc.a: utf8proc.o
+
+ libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH): utf8proc.o
+ $(CC) $(LDFLAGS) -shared -o $@ -Wl,-soname -Wl,libutf8proc.so.$(MAJOR) utf8proc.o
+- chmod a-x $@
++ # FIX .so build so this will work: chmod a-x $@
+
+ libutf8proc.so: libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH)
+ ln -f -s libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH) $@
diff --git a/biology/sra-tools/files/patch-tools_fastq-loader_spot-assembler.c b/biology/sra-tools/files/patch-tools_fastq-loader_spot-assembler.c
new file mode 100644
index 000000000000..0a8f0fd3ccb1
--- /dev/null
+++ b/biology/sra-tools/files/patch-tools_fastq-loader_spot-assembler.c
@@ -0,0 +1,11 @@
+--- tools/fastq-loader/spot-assembler.c.orig 2021-06-20 17:00:29 UTC
++++ tools/fastq-loader/spot-assembler.c
+@@ -26,6 +26,8 @@
+
+ #include "spot-assembler.h"
+
++#include <sys/stat.h>
++
+ #include <klib/status.h>
+ #include <klib/printf.h>
+
diff --git a/biology/sra-tools/files/patch-tools_sra-sort_Makefile b/biology/sra-tools/files/patch-tools_sra-sort_Makefile
new file mode 100644
index 000000000000..8e96b1a43f97
--- /dev/null
+++ b/biology/sra-tools/files/patch-tools_sra-sort_Makefile
@@ -0,0 +1,13 @@
+--- tools/sra-sort/Makefile.orig 2021-06-20 22:24:20 UTC
++++ tools/sra-sort/Makefile
+@@ -135,7 +135,9 @@ DBB_OBJ = \
+ $(addsuffix .$(OBJX),$(DBB_SRC))
+
+ DBB_LIB = \
+- -lncbi-vdb \
++ -sncbi-vdb \
+
+ $(BINDIR)/dump-blob-boundaries: $(DBB_OBJ)
++ @echo "LD = ${LD}"
++ @echo "DBB_LIB = ${DBB_LIB}"
+ $(LD) --exe -o $@ $^ $(DBB_LIB)
diff --git a/biology/sra-tools/files/patch-tools_util_validate-names4.c b/biology/sra-tools/files/patch-tools_util_validate-names4.c
new file mode 100644
index 000000000000..5d66976db304
--- /dev/null
+++ b/biology/sra-tools/files/patch-tools_util_validate-names4.c
@@ -0,0 +1,13 @@
+--- tools/util/validate-names4.c.orig 2021-06-20 17:53:25 UTC
++++ tools/util/validate-names4.c
+@@ -30,8 +30,8 @@
+ #include <klib/rc.h> /* RC */
+ #include <vfs/path.h> /* VPath */
+
+-#include "../../../ncbi-vdb/libs/vfs/json-response.h" /* Response4Make4 */
+-#include "../../../ncbi-vdb/libs/vfs/services-priv.h"/*KServiceGetKSrvResponse*/
++#include "../libs/vfs/json-response.h" /* Response4Make4 */
++#include "../libs/vfs/services-priv.h"/*KServiceGetKSrvResponse*/
+
+ #define RELEASE(type, obj) do { rc_t rc2 = type##Release(obj); \
+ if (rc2 && !rc) { rc = rc2; } obj = NULL; } while (false)
diff --git a/biology/sra-tools/pkg-descr b/biology/sra-tools/pkg-descr
new file mode 100644
index 000000000000..e9324dc5a96a
--- /dev/null
+++ b/biology/sra-tools/pkg-descr
@@ -0,0 +1,18 @@
+SRA tools is a toolkit for using data in the INSDC Sequence Read Archives.
+
+SRAs operated by International Nucleotide Sequence Database Collaboration
+houses sequence reads and alignments generated by "next-gen" sequencers.
+SRA tools allows conversion of .sra files, which INSDC SRAs maintain,
+from/to other formats that the 'next-gen' sequenecers generate including:
+
+* csfasta/csqual (ABI SOLiD)
+* fastq (and fasta for writing)
+* hdf5 (PacBio, reading only)
+* qseq (older Illumina)
+* sam (writing only) / bam (reading only)
+* sff
+
+The toolkit uses NCBI-VDB back-end enabling seamless access to remote SRA data
+and local SRA files.
+
+WWW: https://github.com/ncbi/sra-tools/wiki
diff --git a/biology/sra-tools/pkg-plist b/biology/sra-tools/pkg-plist
new file mode 100644
index 000000000000..dad924be78f4
--- /dev/null
+++ b/biology/sra-tools/pkg-plist
@@ -0,0 +1,57 @@
+bin/abi-dump
+bin/abi-load
+bin/align-cache
+bin/align-info
+bin/bam-load
+bin/cache-mgr
+bin/ccextract
+bin/cg-load
+bin/check-corrupt
+bin/copycat
+bin/fasterq-dump
+bin/fastq-dump
+bin/fastq-load
+bin/helicos-load
+bin/illumina-dump
+bin/illumina-load
+bin/kar
+bin/kar+
+bin/kar+meta
+bin/kdb-index
+bin/kdbmeta
+bin/kget
+bin/latf-load
+bin/make-read-filter
+bin/md5cp
+bin/ngs-pileup
+bin/pacbio-correct
+bin/pacbio-loadxml
+bin/prefetch
+bin/qual-recalib-stat
+bin/rcexplain
+bin/read-filter-redact
+bin/sam-dump
+bin/samview
+bin/schema-replace
+bin/sff-dump
+bin/sff-load
+bin/sra-pileup
+bin/sra-sort
+bin/sra-sort-cg
+bin/sra-stat
+bin/srapath
+bin/sratools
+bin/srf-load
+bin/test-read-write-cursor
+bin/test-sra
+bin/vdb-config
+bin/vdb-copy
+bin/vdb-decrypt
+bin/vdb-diff
+bin/vdb-dump
+bin/vdb-encrypt
+bin/vdb-lock
+bin/vdb-passwd
+bin/vdb-sql
+bin/vdb-unlock
+bin/vdb-validate