Skip to content

Instantly share code, notes, and snippets.

@EvanTheB
Last active June 21, 2018 07:19
Show Gist options
  • Save EvanTheB/74f0edec642c0a2b18b643db496e4097 to your computer and use it in GitHub Desktop.
Save EvanTheB/74f0edec642c0a2b18b643db496e4097 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
# git clone https://github.com/cloudflare/zlib &
[ -d "zlib-1.2.8" ] || curl -L https://github.com/cloudflare/zlib/archive/v1.2.8.tar.gz | tar zx &
# git clone https://github.com/ebiggers/libdeflate.git &
[ -d "libdeflate-1.0" ] || curl -L https://github.com/ebiggers/libdeflate/archive/v1.0.tar.gz | tar zx &
# git clone https://github.com/samtools/htslib.git &
[ -d "htslib-1.8" ] || curl -L https://github.com/samtools/htslib/releases/download/1.8/htslib-1.8.tar.bz2 | tar jx &
# git clone https://github.com/samtools/samtools.git &
[ -d "samtools-1.8" ] || curl -L https://github.com/samtools/samtools/releases/download/1.8/samtools-1.8.tar.bz2 | tar jx &
[ -d "bcftools-1.8" ] || curl -L https://github.com/samtools/bcftools/releases/download/1.8/bcftools-1.8.tar.bz2 | tar jx &
# git clone https://github.com/jkbonfield/io_lib.git &
[ -d "xz-5.2.4" ] || curl -L https://tukaani.org/xz/xz-5.2.4.tar.gz | tar zx &
[ -d "bzip2-1.0.6" ] || curl -L http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz | tar zx &
[ -d "io_lib-1.14.9" ] || curl -L https://github.com/jkbonfield/io_lib/releases/download/io_lib-1-14-9/io_lib-1.14.9.tar.gz | tar zx &
# curl is a bit harder, it has dependencies... probably the system one is fine
# [ -d "curl-7.60.0" ] || curl -L https://curl.haxx.se/download/curl-7.60.0.tar.gz | tar zx &
wait
INSTALL="$PWD/install"
# I try to avoid the .so's so that there is not fooling with LD_LIBRARY_PATH
# avoiding -j on the libtool projects
# LZMA
(
cd "xz-5.2.4"
# this uses libtool, so install it to get rid of the munge
./configure --prefix="$PWD"/install
make clean
make
make install
# hide libtool annoyingness
rm install/lib/*.so* install/lib/*.la
)
(
cd "bzip2-1.0.6"
make clean
make -j4
)
(
cd "zlib-1.2.8"
./configure
make clean
make libz.a -j4
)
(
cd "libdeflate-1.0"
make clean
make libdeflate.a -j4
)
(
cd "htslib-1.8"
env CPPFLAGS="-I$PWD/../libdeflate-1.0" LDFLAGS="-L$PWD/../libdeflate-1.0 -L$PWD/../xz-5.2.4/install/lib/ -L$PWD/../bzip2-1.0.6/ -L$PWD/../zlib-1.2.8/" ./configure --prefix="$INSTALL" --with-libdeflate
make clean
# forcing static link makes the libhts.so want -fPIC. But we can fake it.
make && true
touch libhts.so
make -j4
make install
rm "$INSTALL"/lib/*.so*
)
(
cd "samtools-1.8"
env LDFLAGS="-L../libdeflate-1.0 -L../xz-5.2.4/install/lib/ -L../bzip2-1.0.6/ -L../zlib-1.2.8/" ./configure --prefix="$INSTALL" --without-curses --with-htslib=../htslib-1.8
make clean
make -j4
make install
)
(
cd "bcftools-1.8"
# dependency on libgsl, probably would be good to have an up to date one of them for perf
env LDFLAGS="-L../libdeflate-1.0 -L../xz-5.2.4/install/lib/ -L../bzip2-1.0.6/ -L../zlib-1.2.8/" ./configure --prefix="$INSTALL" --with-htslib=../htslib-1.8 --enable-libgsl
make clean
make -j4
make install
)
(
cd "io_lib-1.14.9"
env LDFLAGS="-L$PWD/../xz-5.2.4/install/lib/ -L$PWD/../bzip2-1.0.6/ -L$PWD/../zlib-1.2.8/" ./configure --prefix="$INSTALL" --enable-shared=no
make clean
make -j4
make install
rm "$INSTALL"/lib/*.la
)
echo
echo "Check that there are no bad dependencies here:"
echo; echo "tabix"; ldd "$INSTALL"/bin/tabix
echo; echo "samtools"; ldd "$INSTALL"/bin/samtools
echo; echo "scramble"; ldd "$INSTALL"/bin/scramble
# ldd /bin/* | sort | uniq
@EvanTheB
Copy link
Author

A script for compiling samtools and scramble while trying to avoid system libraries (because they are old or slow)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment