| 1 |
Building and Installing HTSlib |
| 2 |
============================== |
| 3 |
|
| 4 |
Requirements |
| 5 |
============ |
| 6 |
|
| 7 |
Building HTSlib requires a few programs and libraries to be present. |
| 8 |
See the "System Specific Details" below for guidance on how to install |
| 9 |
these. |
| 10 |
|
| 11 |
At least the following are required: |
| 12 |
|
| 13 |
GNU make |
| 14 |
C compiler (e.g. gcc or clang) |
| 15 |
|
| 16 |
In addition, building the configure script requires: |
| 17 |
|
| 18 |
autoheader |
| 19 |
autoconf |
| 20 |
autoreconf |
| 21 |
|
| 22 |
Running the configure script uses awk, along with a number of |
| 23 |
standard UNIX tools (cat, cp, grep, mv, rm, sed, among others). Almost |
| 24 |
all installations will have these already. |
| 25 |
|
| 26 |
Running the test harness (make test) uses: |
| 27 |
|
| 28 |
bash |
| 29 |
perl |
| 30 |
|
| 31 |
HTSlib uses the following external libraries. Building requires both the |
| 32 |
library itself, and include files needed to compile code that uses functions |
| 33 |
from the library. Note that some Linux distributions put include files in |
| 34 |
a development ('-dev' or '-devel') package separate from the main library. |
| 35 |
|
| 36 |
zlib (required) |
| 37 |
libbz2 (required, unless configured with --disable-bz2) |
| 38 |
liblzma (required, unless configured with --disable-lzma) |
| 39 |
libcurl (optional, but strongly recommended) |
| 40 |
libcrypto (optional for Amazon S3 support; not needed on MacOS) |
| 41 |
libdeflate (optional, but strongly recommended for faster gzip) |
| 42 |
|
| 43 |
Disabling libbzip2 and liblzma will make some CRAM files unreadable, so |
| 44 |
is not recommended. |
| 45 |
|
| 46 |
Using libcurl provides HTSlib with network protocol support, for |
| 47 |
example it enables the use of ftp://, http://, and https:// URLs. |
| 48 |
It is also required if direct access to Amazon S3 or Google Cloud |
| 49 |
Storage is enabled. |
| 50 |
|
| 51 |
Amazon S3 support requires an HMAC function to calculate a message |
| 52 |
authentication code. On MacOS, the CCHmac function from the standard |
| 53 |
library is used. Systems that do not have CCHmac will get this from |
| 54 |
libcrypto. libcrypto is part of OpenSSL or one of its derivatives (LibreSSL |
| 55 |
or BoringSSL). |
| 56 |
|
| 57 |
On Microsoft Windows we recommend use of Mingw64/Msys2. Whilst the |
| 58 |
code may work on Windows with other environments, these have not been |
| 59 |
verified. Use of the configure script is a requirement too. |
| 60 |
|
| 61 |
Update htscodecs submodule |
| 62 |
========================== |
| 63 |
|
| 64 |
Note that this section only applies to git checkouts. If you're building |
| 65 |
from a release tar file, you can skip this section. |
| 66 |
|
| 67 |
Some parts of HTSlib are provided by the external "htscodecs" project. This |
| 68 |
is included as a submodule. When building from the git repository, |
| 69 |
either clone the project using "git clone --recurse-submodules", or run: |
| 70 |
|
| 71 |
git submodule update --init --recursive |
| 72 |
|
| 73 |
to ensure the correct version of the submodule is present. |
| 74 |
|
| 75 |
It is also possible to link against an external libhtscodecs library |
| 76 |
by using the '--with-external-htscodecs' configure option. When |
| 77 |
this is used, the submodule files will be ignored. |
| 78 |
|
| 79 |
Building Configure |
| 80 |
================== |
| 81 |
|
| 82 |
This step is only needed if configure.ac has been changed, or if configure |
| 83 |
does not exist (for example, when building from a git clone). The |
| 84 |
configure script and config.h.in can be built by running: |
| 85 |
|
| 86 |
autoreconf -i |
| 87 |
|
| 88 |
Basic Installation |
| 89 |
================== |
| 90 |
|
| 91 |
To build and install HTSlib, 'cd' to the htslib-1.x directory containing |
| 92 |
the package's source and type the following commands: |
| 93 |
|
| 94 |
./configure |
| 95 |
make |
| 96 |
make install |
| 97 |
|
| 98 |
The './configure' command checks your build environment and allows various |
| 99 |
optional functionality to be enabled (see Configuration below). If you |
| 100 |
don't want to select any optional functionality, you may wish to omit |
| 101 |
configure and just type 'make; make install' as for previous versions |
| 102 |
of HTSlib. However if the build fails you should run './configure' as |
| 103 |
it can diagnose the common reasons for build failures. |
| 104 |
|
| 105 |
The 'make' command builds the HTSlib library and various useful |
| 106 |
utilities: bgzip, htsfile, and tabix. If compilation fails you should |
| 107 |
run './configure' as it can diagnose problems with your build environment |
| 108 |
that cause build failures. |
| 109 |
|
| 110 |
The 'make install' command installs the libraries, library header files, |
| 111 |
utilities, several manual pages, and a pkgconfig file to /usr/local. |
| 112 |
The installation location can be changed by configuring with --prefix=DIR |
| 113 |
or via 'make prefix=DIR install' (see Installation Locations below). |
| 114 |
Shared library permissions can be set via e.g. 'make install LIB_PERM=755'. |
| 115 |
|
| 116 |
|
| 117 |
Configuration |
| 118 |
============= |
| 119 |
|
| 120 |
By default, './configure' examines your build environment, checking for |
| 121 |
requirements such as the zlib development files, and arranges for a plain |
| 122 |
HTSlib build. The following configure options can be used to enable |
| 123 |
various features and specify further optional external requirements: |
| 124 |
|
| 125 |
--enable-plugins |
| 126 |
Use plugins to implement exotic file access protocols and other |
| 127 |
specialised facilities. This enables such facilities to be developed |
| 128 |
and packaged outwith HTSlib, and somewhat isolates HTSlib-using programs |
| 129 |
from their library dependencies. By default (or with --disable-plugins), |
| 130 |
any enabled pluggable facilities (such as libcurl file access) are built |
| 131 |
directly within HTSlib. |
| 132 |
|
| 133 |
Programs that are statically linked to a libhts.a with plugins enabled |
| 134 |
need to be linked using -rdynamic or a similar linker option. |
| 135 |
|
| 136 |
The <https://github.com/samtools/htslib-plugins> repository contains |
| 137 |
several additional plugins, including the iRODS (<http://irods.org/>) |
| 138 |
file access plugin previously distributed with HTSlib. |
| 139 |
|
| 140 |
--with-plugin-dir=DIR |
| 141 |
Specifies the directory into which plugins built while building HTSlib |
| 142 |
should be installed; by default, LIBEXECDIR/htslib. |
| 143 |
|
| 144 |
--with-plugin-path=DIR:DIR:DIR... |
| 145 |
Specifies the list of directories that HTSlib will search for plugins. |
| 146 |
By default, only the directory specified via --with-plugin-dir will be |
| 147 |
searched; you can use --with-plugin-path='DIR:$(plugindir):DIR' and so |
| 148 |
on to cause additional directories to be searched. |
| 149 |
|
| 150 |
--with-external-htscodecs |
| 151 |
Build and link against an external copy of the htscodecs library |
| 152 |
instead of using the source files in the htscodecs directory. |
| 153 |
|
| 154 |
--enable-libcurl |
| 155 |
Use libcurl (<http://curl.se/>) to implement network access to |
| 156 |
remote files via FTP, HTTP, HTTPS, etc. By default or with |
| 157 |
--enable-libcurl=check, configure will probe for libcurl and include |
| 158 |
this functionality if libcurl is available. Use --disable-libcurl |
| 159 |
to prevent this. |
| 160 |
|
| 161 |
--enable-gcs |
| 162 |
Implement network access to Google Cloud Storage. By default or with |
| 163 |
--enable-gcs=check, this is enabled when libcurl is enabled. |
| 164 |
|
| 165 |
--enable-s3 |
| 166 |
Implement network access to Amazon AWS S3. By default or with |
| 167 |
--enable-s3=check, this is enabled when libcurl is enabled. |
| 168 |
|
| 169 |
--disable-bz2 |
| 170 |
Bzip2 is an optional compression codec format for CRAM, included |
| 171 |
in HTSlib by default. It can be disabled with --disable-bz2, but |
| 172 |
be aware that not all CRAM files may be possible to decode. |
| 173 |
|
| 174 |
--disable-lzma |
| 175 |
LZMA is an optional compression codec for CRAM, included in HTSlib |
| 176 |
by default. It can be disabled with --disable-lzma, but be aware |
| 177 |
that not all CRAM files may be possible to decode. |
| 178 |
|
| 179 |
--with-libdeflate |
| 180 |
Libdeflate is a heavily optimized library for DEFLATE-based compression |
| 181 |
and decompression. It also includes a fast crc32 implementation. |
| 182 |
By default, ./configure will probe for libdeflate and use it if |
| 183 |
available. To prevent this, use --without-libdeflate. |
| 184 |
|
| 185 |
Each --enable-FEATURE/--disable-FEATURE/--with-PACKAGE/--without-PACKAGE |
| 186 |
option listed also has an opposite, e.g., --without-external-htscodecs |
| 187 |
or --disable-plugins. However, apart from those options for which the |
| 188 |
default is to probe for related facilities, using these opposite options |
| 189 |
is mostly unnecessary as they just select the default configure behaviour. |
| 190 |
|
| 191 |
The configure script also accepts the usual options and environment variables |
| 192 |
for tuning installation locations and compilers: type './configure --help' |
| 193 |
for details. For example, |
| 194 |
|
| 195 |
./configure CC=icc --prefix=/opt/icc-compiled |
| 196 |
|
| 197 |
would specify that HTSlib is to be built with icc and installed into bin, |
| 198 |
lib, etc subdirectories under /opt/icc-compiled. |
| 199 |
|
| 200 |
If dependencies have been installed in non-standard locations (i.e. not on |
| 201 |
the normal include and library search paths) then the CPPFLAGS and LDFLAGS |
| 202 |
environment variables can be used to set the options needed to find them. |
| 203 |
For example, NetBSD users may use: |
| 204 |
|
| 205 |
./configure CPPFLAGS=-I/usr/pkg/include \ |
| 206 |
LDFLAGS='-L/usr/pkg/lib -Wl,-R/usr/pkg/lib' |
| 207 |
|
| 208 |
to allow compiling and linking against dependencies installed via the ports |
| 209 |
collection. |
| 210 |
|
| 211 |
Installation Locations |
| 212 |
====================== |
| 213 |
|
| 214 |
By default, 'make install' installs HTSlib libraries under /usr/local/lib, |
| 215 |
HTSlib header files under /usr/local/include, utility programs under |
| 216 |
/usr/local/bin, etc. (To be precise, the header files are installed within |
| 217 |
a fixed 'htslib' subdirectory under the specified .../include location.) |
| 218 |
|
| 219 |
You can specify a different location to install HTSlib by configuring |
| 220 |
with --prefix=DIR or specify locations for particular parts of HTSlib by |
| 221 |
configuring with --libdir=DIR and so on. Type './configure --help' for |
| 222 |
the full list of such install directory options. |
| 223 |
|
| 224 |
Alternatively you can specify different locations at install time by |
| 225 |
typing 'make prefix=DIR install' or 'make libdir=DIR install' and so on. |
| 226 |
Consult the list of prefix/exec_prefix/etc variables near the top of the |
| 227 |
Makefile for the full list of such variables that can be overridden. |
| 228 |
|
| 229 |
You can also specify a staging area by typing 'make DESTDIR=DIR install', |
| 230 |
possibly in conjunction with other --prefix or prefix=DIR settings. |
| 231 |
For example, |
| 232 |
|
| 233 |
make DESTDIR=/tmp/staging prefix=/opt |
| 234 |
|
| 235 |
would install into bin, lib, etc subdirectories under /tmp/staging/opt. |
| 236 |
|
| 237 |
|
| 238 |
System Specific Details |
| 239 |
======================= |
| 240 |
|
| 241 |
Installing the prerequisites is system dependent and there is more |
| 242 |
than one correct way of satisfying these, including downloading them |
| 243 |
from source, compiling and installing them yourself. |
| 244 |
|
| 245 |
For people with super-user access, we provide an example set of commands |
| 246 |
below for installing the dependencies on a variety of operating system |
| 247 |
distributions. Note these are not specific recommendations on distribution, |
| 248 |
compiler or SSL implementation. It is assumed you already have the core set |
| 249 |
of packages for the given distribution - the lists may be incomplete if |
| 250 |
this is not the case. |
| 251 |
|
| 252 |
Debian / Ubuntu |
| 253 |
--------------- |
| 254 |
|
| 255 |
sudo apt-get update # Ensure the package list is up to date |
| 256 |
sudo apt-get install autoconf automake make gcc perl zlib1g-dev libbz2-dev liblzma-dev libcurl4-gnutls-dev libssl-dev libdeflate-dev |
| 257 |
|
| 258 |
Note: libcurl4-openssl-dev can be used as an alternative to libcurl4-gnutls-dev. |
| 259 |
|
| 260 |
RedHat / CentOS |
| 261 |
--------------- |
| 262 |
|
| 263 |
sudo yum install autoconf automake make gcc perl-Data-Dumper zlib-devel bzip2 bzip2-devel xz-devel curl-devel openssl-devel libdeflate-devel |
| 264 |
|
| 265 |
Note: On some versions perl FindBin will need to be installed to make the tests work. |
| 266 |
|
| 267 |
sudo yum install perl-FindBin |
| 268 |
|
| 269 |
Alpine Linux |
| 270 |
------------ |
| 271 |
|
| 272 |
doas apk update # Ensure the package list is up to date |
| 273 |
doas apk add autoconf automake make gcc musl-dev perl bash zlib-dev bzip2-dev xz-dev curl-dev openssl-dev |
| 274 |
|
| 275 |
Ideally also install a copy of libdeflate-dev for faster (de)compression. |
| 276 |
This can be found in the Alpine community repository. |
| 277 |
|
| 278 |
Note: some older Alpine versions use libressl-dev rather than openssl-dev. |
| 279 |
|
| 280 |
OpenSUSE |
| 281 |
-------- |
| 282 |
|
| 283 |
sudo zypper install autoconf automake make gcc perl zlib-devel libbz2-devel xz-devel libcurl-devel libopenssl-devel |
| 284 |
|
| 285 |
Also install libdeflate-devel, available on OpenSUSE Leap 15.4 onwards |
| 286 |
or directly via git releases above. |
| 287 |
|
| 288 |
FreeBSD |
| 289 |
------- |
| 290 |
|
| 291 |
As root: |
| 292 |
pkg install autoconf automake bash curl gmake libdeflate perl5 |
| 293 |
|
| 294 |
Build as a normal user. When building, compiler flags need to be set so that |
| 295 |
the packages installed above are found. It is also necessary to use "gmake": |
| 296 |
|
| 297 |
./configure CPPFLAGS='-I/usr/local/include' LDFLAGS='-L/usr/local/lib -Wl,-R/usr/local/lib' |
| 298 |
gmake && gmake check |
| 299 |
|
| 300 |
NetBSD |
| 301 |
------ |
| 302 |
|
| 303 |
Make sure you have installed the "comp" file set to get a compiler, then |
| 304 |
get the following packages as root: |
| 305 |
|
| 306 |
pkg_add autoconf automake bash curl gmake libdeflate perl |
| 307 |
|
| 308 |
Build as a normal user. When building, compiler flags need to be set so that |
| 309 |
the packages installed above are found. It is also necessary to use "gmake": |
| 310 |
|
| 311 |
./configure CPPFLAGS='-I/usr/pkg/include' LDFLAGS='-L/usr/pkg/lib -Wl,-R/usr/pkg/lib' |
| 312 |
gmake && gmake check |
| 313 |
|
| 314 |
OpenBSD |
| 315 |
------- |
| 316 |
|
| 317 |
Make sure you have installed the "comp" file set to get a compiler, then |
| 318 |
get the following packages as root: |
| 319 |
|
| 320 |
pkg_add autoconf automake bash bzip2 curl gmake libdeflate xz |
| 321 |
|
| 322 |
You should select the most recent versions of autoconf and automake if asked. |
| 323 |
|
| 324 |
Build as a normal user. When building, compiler flags need to be set so that |
| 325 |
the packages installed above are found. It is also necessary to use "gmake": |
| 326 |
|
| 327 |
./configure CPPFLAGS='-I/usr/local/include' LDFLAGS='-L/usr/local/lib -Wl,-R/usr/local/lib' |
| 328 |
gmake && gmake check |
| 329 |
|
| 330 |
Windows MSYS2/MINGW64 |
| 331 |
--------------------- |
| 332 |
|
| 333 |
The configure script must be used as without it the compilation will |
| 334 |
likely fail. |
| 335 |
|
| 336 |
Follow MSYS2 installation instructions at |
| 337 |
https://www.msys2.org/wiki/MSYS2-installation/ |
| 338 |
|
| 339 |
Then relaunch to MSYS2 shell using the "MSYS2 MinGW x64" executable. |
| 340 |
Once in that environment (check $MSYSTEM equals "MINGW64") install the |
| 341 |
compilers using pacman -S and the following package list: |
| 342 |
|
| 343 |
base-devel mingw-w64-x86_64-toolchain |
| 344 |
mingw-w64-x86_64-libdeflate mingw-w64-x86_64-zlib mingw-w64-x86_64-bzip2 |
| 345 |
mingw-w64-x86_64-xz mingw-w64-x86_64-curl mingw-w64-x86_64-autotools |
| 346 |
mingw-w64-x86_64-tools-git |
| 347 |
|
| 348 |
(The last is only needed for building libraries compatible with MSVC.) |
| 349 |
|
| 350 |
HP-UX |
| 351 |
----- |
| 352 |
|
| 353 |
HP-UX requires that shared libraries have execute permission. The |
| 354 |
default for HTSlib is to install with permission 644 (read-write for |
| 355 |
owner and read-only for group / other). This can be overridden by |
| 356 |
setting the LIB_PERM variable at install time with: |
| 357 |
|
| 358 |
make install LIB_PERM=755 |