1 # Configure script for htslib, a C library for high-throughput sequencing data.
3 # Copyright (C) 2015-2017 Genome Research Ltd.
5 # Author: John Marshall <jm18@sanger.ac.uk>
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 # DEALINGS IN THE SOFTWARE.
25 dnl Process this file with autoconf to produce a configure script
26 AC_INIT([HTSlib], m4_esyscmd_s([make print-version]),
27 [samtools-help@lists.sourceforge.net], [], [http://www.htslib.org/])
28 AC_PREREQ(2.63) dnl This version introduced 4-argument AC_CHECK_HEADER
29 AC_CONFIG_SRCDIR(hts.c)
30 AC_CONFIG_HEADERS(config.h)
32 dnl Copyright notice to be copied into the generated configure script
33 AC_COPYRIGHT([Portions copyright (C) 2016 Genome Research Ltd.
35 This configure script is free software: you are free to change and
36 redistribute it. There is NO WARRANTY, to the extent permitted by law.])
38 dnl Notes to be copied (by autoheader) into the generated config.h.in
39 AH_TOP([/* If you use configure, this file provides @%:@defines reflecting your
40 configuration choices. If you have not run configure, suitable
41 conservative defaults will be used.
43 Autoheader adds a number of items to this template file that are not
44 used by HTSlib: STDC_HEADERS and most HAVE_*_H header file defines
45 are immaterial, as we assume standard ISO C headers and facilities;
46 the PACKAGE_* defines are unused and are overridden by the more
47 accurate PACKAGE_VERSION as computed by the Makefile. */])
52 dnl Avoid chicken-and-egg problem where pkg-config supplies the
53 dnl PKG_PROG_PKG_CONFIG macro, but we want to use it to check
55 m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG], [PKG_CONFIG=""])
64 [AS_HELP_STRING([--disable-bz2],
65 [omit support for BZ2-compressed CRAM files])],
69 [AS_HELP_STRING([--enable-gcs],
70 [support Google Cloud Storage URLs])],
71 [], [enable_gcs=check])
75 AC_ARG_ENABLE([libcurl],
76 [AS_HELP_STRING([--enable-libcurl],
77 [enable libcurl-based support for http/https/etc URLs])],
78 [], [enable_libcurl=check])
81 [AS_HELP_STRING([--disable-lzma],
82 [omit support for LZMA-compressed CRAM files])],
83 [], [enable_lzma=yes])
85 AC_ARG_ENABLE([plugins],
86 [AS_HELP_STRING([--enable-plugins],
87 [enable separately-compiled plugins for file access])],
88 [], [enable_plugins=no])
89 AC_SUBST(enable_plugins)
91 AC_ARG_WITH([plugin-dir],
92 [AS_HELP_STRING([--with-plugin-dir=DIR],
93 [plugin installation location [LIBEXECDIR/htslib]])],
95 yes|no) AC_MSG_ERROR([no directory specified for --with-plugin-dir]) ;;
97 [with_plugin_dir='$(libexecdir)/htslib'])
98 AC_SUBST([plugindir], $with_plugin_dir)
100 AC_ARG_WITH([plugin-path],
101 [AS_HELP_STRING([--with-plugin-path=PATH],
102 [default HTS_PATH plugin search path [PLUGINDIR]])],
104 yes) AC_MSG_ERROR([no path specified for --with-plugin-path]) ;;
105 no) with_plugin_path= ;;
107 [with_plugin_path=$with_plugin_dir])
108 AC_SUBST([pluginpath], $with_plugin_path)
111 [AS_HELP_STRING([--enable-s3],
112 [support Amazon AWS S3 URLs])],
113 [], [enable_s3=check])
115 AC_MSG_CHECKING([shared library type])
116 test -n "$host_alias" || host_alias=unknown-`uname -s`
118 *-cygwin* | *-CYGWIN*)
119 host_result="Cygwin DLL"
123 *-darwin* | *-Darwin*)
124 host_result="Darwin dylib"
129 host_result="plain .so"
134 AC_MSG_RESULT([$host_result])
137 dnl FIXME This pulls in dozens of standard header checks
139 AC_CHECK_FUNCS(gmtime_r)
141 # Darwin has a dubious fdatasync() symbol, but no declaration in <unistd.h>
142 AC_CHECK_DECL([fdatasync(int)], [AC_CHECK_FUNCS(fdatasync)])
144 if test $enable_plugins != no; then
145 AC_SEARCH_LIBS([dlopen], [dl], [],
146 [AC_MSG_ERROR([dlopen() not found
148 Plugin support requires dynamic linking facilities from the operating system.
149 Either configure with --disable-plugins or resolve this error to build HTSlib.])])
150 # TODO Test whether this is required and/or needs tweaking per-platform
151 LDFLAGS="$LDFLAGS -rdynamic"
152 static_LDFLAGS="$static_LDFLAGS -rdynamic"
153 case "$ac_cv_search_dlopen" in
154 -l*) static_LIBS="$static_LIBS $ac_cv_search_dlopen" ;;
156 AC_DEFINE([ENABLE_PLUGINS], 1, [Define if HTSlib should enable plugins.])
157 AC_SUBST([PLUGIN_EXT])
158 AC_DEFINE_UNQUOTED([PLUGIN_EXT], ["$PLUGIN_EXT"],
159 [Platform-dependent plugin filename extension.])
162 AC_SEARCH_LIBS([log], [m], [],
163 [AC_MSG_ERROR([log() not found
165 HTSLIB requires a working floating-point math library.
166 FAILED. This error must be resolved in order to build HTSlib successfully.])])
169 dnl Set a trivial non-empty INCLUDES to avoid excess default includes tests
170 AC_CHECK_HEADER([zlib.h], [], [zlib_devel=missing], [;])
171 AC_CHECK_LIB(z, inflate, [], [zlib_devel=missing])
173 if test $zlib_devel != ok; then
174 AC_MSG_ERROR([zlib development files not found
176 HTSlib uses compression routines from the zlib library <http://zlib.net>.
177 Building HTSlib requires zlib development files to be installed on the build
178 machine; you may need to ensure a package such as zlib1g-dev (on Debian or
179 Ubuntu Linux) or zlib-devel (on RPM-based Linux distributions or Cygwin)
182 FAILED. This error must be resolved in order to build HTSlib successfully.])
185 dnl connect() etc. fns are in libc on linux, but libsocket on illumos/Solaris
187 AC_SEARCH_LIBS(connect, socket, [libsocket=needed], [])
190 if test "$enable_bz2" != no; then
192 AC_CHECK_HEADER([bzlib.h], [], [bz2_devel=missing], [;])
193 AC_CHECK_LIB([bz2], [BZ2_bzBuffToBuffCompress], [], [bz2_devel=missing])
194 if test $bz2_devel != ok; then
195 AC_MSG_ERROR([libbzip2 development files not found
197 The CRAM format may use bzip2 compression, which is implemented in HTSlib
198 by using compression routines from libbzip2 <http://www.bzip.org/>.
200 Building HTSlib requires libbzip2 development files to be installed on the
201 build machine; you may need to ensure a package such as libbz2-dev (on Debian
202 or Ubuntu Linux) or bzip2-devel (on RPM-based Linux distributions or Cygwin)
205 Either configure with --disable-bz2 (which will make some CRAM files
206 produced elsewhere unreadable) or resolve this error to build HTSlib.])
208 dnl Unfortunately the 'bzip2' package-cfg module is not standard.
209 dnl Redhat/Fedora has it; Debian/Ubuntu does not.
210 if test -n "$PKG_CONFIG" && "$PKG_CONFIG" --exists bzip2; then
211 pc_requires="$pc_requires bzip2"
213 private_LIBS="$private_LIBS -lbz2"
215 static_LIBS="$static_LIBS -lbz2"
218 if test "$enable_lzma" != no; then
220 AC_CHECK_HEADER([lzma.h], [], [lzma_devel=missing], [;])
221 AC_CHECK_LIB([lzma], [lzma_easy_buffer_encode], [], [lzma_devel=missing])
222 if test $lzma_devel != ok; then
223 AC_MSG_ERROR([liblzma development files not found
225 The CRAM format may use LZMA2 compression, which is implemented in HTSlib
226 by using compression routines from liblzma <http://tukaani.org/xz/>.
228 Building HTSlib requires liblzma development files to be installed on the
229 build machine; you may need to ensure a package such as liblzma-dev (on Debian
230 or Ubuntu Linux), xz-devel (on RPM-based Linux distributions or Cygwin), or
231 xz (via Homebrew on macOS) is installed; or build XZ Utils from source.
233 Either configure with --disable-lzma (which will make some CRAM files
234 produced elsewhere unreadable) or resolve this error to build HTSlib.])
236 pc_requires="$pc_requires liblzma"
237 static_LIBS="$static_LIBS -llzma"
241 if test "$enable_libcurl" != no; then
242 AC_CHECK_LIB([curl], [curl_easy_pause],
243 [AC_DEFINE([HAVE_LIBCURL], 1, [Define if libcurl file access is enabled.])
245 [AC_CHECK_LIB([curl], [curl_easy_init],
246 [message="library is too old (7.18+ required)"],
247 [message="library not found"])
248 case "$enable_libcurl" in
249 check) AC_MSG_WARN([libcurl not enabled: $message]) ;;
250 *) AC_MSG_ERROR([libcurl $message
252 Support for HTTPS and other SSL-based URLs requires routines from the libcurl
253 library <http://curl.haxx.se/libcurl/>. Building HTSlib with libcurl enabled
254 requires libcurl development files to be installed on the build machine; you
255 may need to ensure a package such as libcurl4-{gnutls,nss,openssl}-dev (on
256 Debian or Ubuntu Linux) or libcurl-devel (on RPM-based Linux distributions
257 or Cygwin) is installed.
259 Either configure with --disable-libcurl or resolve this error to build HTSlib.])
262 dnl -lcurl is only needed for static linking if hfile_libcurl is not a plugin
263 if test "$libcurl" = enabled ; then
264 if test "$enable_plugins" != yes ; then
265 static_LIBS="$static_LIBS -lcurl"
272 if test "$enable_gcs" != no; then
273 if test $libcurl = enabled; then
274 AC_DEFINE([ENABLE_GCS], 1, [Define if HTSlib should enable GCS support.])
277 case "$enable_gcs" in
278 check) AC_MSG_WARN([GCS support not enabled: requires libcurl support]) ;;
279 *) AC_MSG_ERROR([GCS support not enabled
281 Support for Google Cloud Storage URLs requires libcurl support to be enabled
282 in HTSlib. Configure with --enable-libcurl in order to use GCS URLs.])
290 if test "$enable_s3" != no; then
291 if test $libcurl = enabled; then
293 need_crypto="$enable_s3"
296 check) AC_MSG_WARN([S3 support not enabled: requires libcurl support]) ;;
297 *) AC_MSG_ERROR([S3 support not enabled
299 Support for Amazon AWS S3 URLs requires libcurl support to be enabled
300 in HTSlib. Configure with --enable-libcurl in order to use S3 URLs.])
307 if test $need_crypto != no; then
308 AC_CHECK_FUNC([CCHmac],
309 [AC_DEFINE([HAVE_COMMONCRYPTO], 1,
310 [Define if you have the Common Crypto library.])],
312 AC_SEARCH_LIBS([HMAC], [crypto],
313 [AC_DEFINE([HAVE_HMAC], 1, [Define if you have libcrypto-style HMAC().])
314 case "$ac_cv_search_HMAC" in
315 -l*) CRYPTO_LIBS=$ac_cv_search_HMAC ;;
317 [case "$need_crypto" in
318 check) AC_MSG_WARN([S3 support not enabled: requires SSL development files])
320 *) AC_MSG_ERROR([SSL development files not found
322 Support for AWS S3 URLs requires routines from an SSL library. Building
323 HTSlib with libcurl enabled requires SSL development files to be installed
324 on the build machine; you may need to ensure a package such as libgnutls-dev,
325 libnss3-dev, or libssl-dev (on Debian or Ubuntu Linux, corresponding to the
326 libcurl4-*-dev package installed), or openssl-devel (on RPM-based Linux
327 distributions or Cygwin) is installed.
329 Either configure with --disable-s3 or resolve this error to build HTSlib.]) ;;
332 dnl Only need to add to static_LIBS if not building as a plugin
333 if test "$enable_plugins" != yes ; then
334 static_LIBS="$static_LIBS $CRYPTO_LIBS"
338 dnl Look for PTHREAD_MUTEX_RECURSIVE.
339 dnl This is normally in pthread.h except on some broken glibc implementations.
340 AC_CHECK_DECL(PTHREAD_MUTEX_RECURSIVE, [], [AC_DEFINE([_XOPEN_SOURCE],[600], [Needed for PTHREAD_MUTEX_RECURSIVE])], [[#include <pthread.h>]])
342 if test "$s3" = enabled ; then
343 AC_DEFINE([ENABLE_S3], 1, [Define if HTSlib should enable S3 support.])
346 AC_SUBST([CRYPTO_LIBS])
348 AC_SUBST([pc_requires])
349 AC_SUBST([private_LIBS])
350 AC_SUBST([static_LDFLAGS])
351 AC_SUBST([static_LIBS])
353 AC_CONFIG_FILES([config.mk htslib.pc.tmp:htslib.pc.in])