source: branches/0.10-stable/configure.ac @ 2954

Last change on this file since 2954 was 2954, checked in by Peter, 9 years ago

fixes #733 and #736. Do not link -lbam into libyat.la, but do mention it in yat-config and yat.pc. Also mention -lz in yat.pc (#736)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.4 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 2954 2013-01-16 08:33:07Z peter $
4
5# Copyright (C) 2003 Daniel Dalevi, Jari Häkkinen
6# Copyright (C) 2004 Jari Häkkinen
7# Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson
8# Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
9# Copyright (C) 2009 Jari Häkkinen, Peter Johansson
10# Copyright (C) 2010, 2011 Peter Johansson
11# Copyright (C) 2012 Jari Häkkinen, Peter Johansson
12#
13# This file is part of the yat library, http://dev.thep.lu.se/yat
14#
15# The yat library is free software; you can redistribute it
16# and/or modify it under the terms of the GNU General Public License as
17# published by the Free Software Foundation; either version 3 of the
18# License, or (at your option) any later version.
19#
20# The yat library is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23# General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with yat. If not, see <http://www.gnu.org/licenses/>.
27#
28# If you grabbed the source from the subversion repository you should,
29# at top-level, execute:
30#     ./bootstrap
31# To push subsequent changes of this file into the build scripts you
32# must issue:
33#     autoreconf
34
35
36m4_include([m4/version.m4])
37AC_INIT([yat],[my_VERSION],[libyat-users@lists.sourceforge.net],,
38        [http://dev.thep.lu.se/yat])
39MY_VERSION
40AC_PREREQ(2.63)
41AC_CONFIG_SRCDIR([yat/utility/Matrix.h])
42AC_CONFIG_AUX_DIR([autotools])
43dnl arg below should be the same as in Makefile.am
44AC_CONFIG_MACRO_DIR([m4])
45AC_PREFIX_DEFAULT([/usr/local])
46
47# Set default htmldir to ${docdir}/html
48AS_IF([test $htmldir = '${docdir}'], [htmldir='${docdir}/html'])
49
50dnl FIXME remove when we assume autoconf 2.64
51m4_ifndef([AC_PACKAGE_URL],
52          [AC_DEFINE([PACKAGE_URL], ["http://dev.thep.lu.se/yat"],
53                     [Define to home page for this package])
54           AC_SUBST([PACKAGE_URL], ["http://dev.thep.lu.se/yat"])])
55
56AC_SUBST([YAT_LT_VERSION], [YAT_LT_VERSION_INFO])
57AC_DEFINE([YAT_VERSION], ["my_VERSION"], [version])
58
59AC_CONFIG_HEADERS([config.h])
60AM_INIT_AUTOMAKE([1.11 std-options color-tests parallel-tests
61                  silent-rules subdir-objects])
62
63dnl When fatal error are detected we use macro YAT_MSG_ERROR that
64dnl collects all error messages and aborts configure [just] before
65dnl creating output files with this message below plus collected
66dnl messages from YAT_MSG_ERROR calls.
67YAT_MSG_ERROR_PREPARE([
68        Some pre-requisites were not fulfilled, aborting configure.
69        Please consult the 'README' file for more information about what
70        is needed to compile yat and refer to messages below.
71])
72
73
74# Set default programming language
75AC_LANG(C++)
76
77# propagate selected configure variables to DISTCHECK_CONFIGURE_FLAGS
78for var in CPPFLAGS CXX CXXFLAGS CXXCPP LDFLAGS LIBS; do
79  eval isset=\${$var+set}
80  if test "$isset" = 'set' ; then
81    eval val=$`echo $var`
82    DISTCHECK_CONFIGURE_FLAGS="${DISTCHECK_CONFIGURE_FLAGS}'${var}=${val}' "
83  fi
84done
85AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
86
87# record if CXXFLAGS was set by user for further use below
88AS_IF([test "${CXXFLAGS+set}" = set], [
89  CXXFLAGS_set_by_user=yes
90],[
91  CXXFLAGS_set_by_user=no
92  # set CXXFLAGS to avoid expansion in AC_PROG_CXX
93  CXXFLAGS=
94])
95
96# Checks for programs.
97AC_PROG_CXX
98AC_PROG_SED
99AC_PROG_LIBTOOL
100
101# find the compiler vendor: gnu, intel, etc
102AX_COMPILER_VENDOR
103
104have_doxygen=no
105AC_PATH_PROG([DOXYGEN], [doxygen], [no])
106if test "$DOXYGEN" = "no"; then
107   AC_MSG_WARN([unable to find doxygen application])
108else
109   doxygen_min_version=1.5
110   AC_MSG_CHECKING([if doxygen is at least $doxygen_min_version])
111   doxygen_version=`$DOXYGEN --version`
112   AX_COMPARE_VERSION([$doxygen_version], [ge], [$doxygen_min_version],
113                      [have_doxygen=yes], [have_doxygen=old])
114   AC_MSG_RESULT([$doxygen_version])
115fi
116
117AC_SUBST(have_doxygen)
118AM_CONDITIONAL([DX_ENABLE_HTML], [test x$have_doxygen = xyes])
119
120# check for quiet_NaN support in OS
121# Check at run-time, but if we are cross-compiling fall back on a
122# compilation test
123AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
124AC_RUN_IFELSE(
125  [AC_LANG_PROGRAM(
126    [@%:@include <limits>],
127    [return !std::numeric_limits<double>::has_quiet_NaN])],
128  [quiet_nan=yes
129   AC_MSG_RESULT($quiet_nan)],
130  [quiet_nan=no
131   AC_MSG_RESULT($quiet_nan)],
132  # if we are cross-compiling fall back on compilation test
133  [AC_MSG_RESULT(cross-compiling)
134   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
135    AC_COMPILE_IFELSE(
136     [AC_LANG_PROGRAM(
137        [@%:@include <limits>
138         extern void f(double);],
139        [f(std::numeric_limits<double>::quiet_NaN())])],
140     [quiet_nan=yes],
141     [quiet_nan=no])
142   AC_MSG_RESULT($quiet_nan)])
143# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
144# of created binary, will fail.
145AS_IF([test x"$quiet_nan" = x"no"], [
146  YAT_MSG_ERROR([dnl
147Support for quiet NAN required. yat will not work on this system!])
148])
149
150# Check for infinity support for doubles in OS
151# Check at run-time, but if we are cross-compiling fall back on a
152# compilation test
153AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
154AC_RUN_IFELSE(
155  [AC_LANG_PROGRAM(
156    [@%:@include <limits>],
157    [return !std::numeric_limits<double>::has_infinity])],
158  [has_infinity=yes
159   AC_MSG_RESULT($has_infinity)],
160  [has_infinity=no
161   AC_MSG_RESULT($has_infinity)],
162  # if we are cross-compiling fall back on compilation test
163  [AC_MSG_RESULT(cross-compiling)
164   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
165    AC_COMPILE_IFELSE(
166     [AC_LANG_PROGRAM(
167        [@%:@include <limits>
168         extern void f(double);],
169        [f(std::numeric_limits<double>::infinity())])],
170     [has_infinity=yes],
171     [has_infinity=no])
172   AC_MSG_RESULT($has_infinity)])
173# No support for infinity is fatal -- sub-sequent compilation, or execution
174# of created binary, will fail.
175AS_IF([test x"${has_infinity}" = x"no"], [
176YAT_MSG_ERROR([dnl
177Support for infinity required. yat will not work on this system!])
178])
179
180
181AC_MSG_CHECKING([g++ deprecation attribute])
182AC_COMPILE_IFELSE(
183   [AC_LANG_PROGRAM([[void f() __attribute__ ((deprecated));]],)],
184   [AC_DEFINE([YAT_HAVE_GCC_DEPRECATED], [1],
185              [Define if compiler supports deprecated attribute, as in g++ 4.0])
186    AC_MSG_RESULT([yes])],
187   [AC_MSG_RESULT([no])] )
188
189AC_MSG_CHECKING([if std::multiset::iterator is mutable])
190AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <set>
191                                     @%:@include <vector>]],
192                                   [[std::set<std::vector<double> > s;
193                                     std::vector<double> v;
194                                     s.insert(v);
195                                     s.begin()->reserve(100);
196                                   ]])],
197                  [AC_DEFINE([MULTISET_ITERATOR_IS_MUTABLE], [1],
198                             [Define if std::multiset::iterator is mutable])
199                   AC_MSG_RESULT([yes])
200                  ],
201                  [AC_MSG_RESULT([no])] )
202
203# Save user-defined environment settings for later restoration
204APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
205APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
206APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
207APR_SAVE_THE_ENVIRONMENT(LIBS)
208
209# Checks for libraries.
210AC_MSG_NOTICE([checking for libraries])
211AC_CHECK_LIBM
212LIBS="$LIBM $LIBS"
213
214# find library implementing BLAS C API, or use gslcblas
215YAT_LIB_CBLAS([YAT_CBLAS_LIB=$CBLAS_LIB], [YAT_CBLAS_LIB=-lgslcblas])
216LIBS="$YAT_CBLAS_LIB $LIBS"
217
218# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
219# Including AX_PATH_GSL macro from gsl.m4 distributed by GSL
220gsl_version="1.8"
221AC_SUBST(gsl_version)
222YAT_CHECK_GSL([$gsl_version],[LIBS="-lgsl $LIBS"],[YAT_MSG_ERROR([dnl
223GSL $gsl_version (or newer) not found. The GNU Scientific Library
224(GSL) library cannot be found. Please make sure GSL is
225installed. Please refer to warnings above for more details])
226])
227
228# Boost http://www.boost.org
229boost_version=1.35
230AC_SUBST(boost_version)
231AX_BOOST_BASE(["$boost_version"], [], [YAT_MSG_ERROR([dnl
232Boost ${boost_version} (or newer) not found. Please install boost, or provide
233CPPFLAGS=-I/path/to/boost])
234])
235# skip boost link tests if boost is not wanted (--without-boost)
236AS_IF([test x"$want_boost" = x"yes"],[
237  AX_BOOST_THREAD
238  AX_BOOST_SYSTEM
239  YAT_CPP_ADD_FLAG([CPPFLAGS], [$BOOST_CPPFLAGS])
240  YAT_LD_ADD_FLAG([LDFLAGS], [$BOOST_LDFLAGS])
241  # boost tests above only test compilation, so let's try link in the libs
242  LIBS="$LIBS $BOOST_THREAD_LIB $BOOST_SYSTEM_LIB"
243  AC_MSG_CHECKING([for thread_specific_ptr])
244  AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <boost/thread/tss.hpp>],
245                                  [boost::thread_specific_ptr<int> x;
246                                   x.reset(new int(1));])],
247                 [AC_MSG_RESULT([yes])],
248                 [AC_MSG_RESULT([no])
249                  YAT_MSG_ERROR([Boost thread library not found. Please install library boost-thread.])
250                 ])
251])
252
253# see tickets #648 #687
254AC_MSG_CHECKING([whether constructor in boost concept is supported])
255AC_COMPILE_IFELSE([
256  AC_LANG_PROGRAM(
257    [
258     @%:@include <boost/concept_check.hpp>
259     template <typename T>
260     class MyConcept
261     {
262     public:
263       MyConcept(void) {}
264       BOOST_CONCEPT_USAGE(MyConcept){}
265     };
266    ],[
267     MyConcept<double> x;
268     x = x;
269    ])
270  ],
271  [AC_MSG_RESULT([yes])
272   AC_DEFINE([YAT_HAVE_BOOST_CONCEPT_WITH_CONSTRUCTOR],[1],
273             [define if compiler supports boost concept with constructor])
274  ],
275  [AC_MSG_RESULT([no])]
276)
277
278
279# samtools API from http://samtools.sourceforge.net
280AC_ARG_WITH([samtools],
281            [AS_HELP_STRING([--without-samtools],
282                            [disable samtools support])],
283            [],
284            [with_samtools=yes])
285
286AS_IF([test x"$with_samtools" != x"no"], [
287  AC_CHECK_HEADER([zlib.h], [],
288    [YAT_MSG_ERROR([Header file 'zlib.h' was not found])])
289  AC_CHECK_LIB([z], [inflateEnd], [],
290    [YAT_MSG_ERROR([Library 'libz' was not found])])
291  YAT_CHECK_HEADER_BAM([],[YAT_MSG_ERROR([Header file 'bam.h' was not found])])
292  # try link against libbam
293  YAT_CHECK_LIBBAM([LIBS="$BAM_LIBS $LIBS"
294                    AC_DEFINE([HAVE_LIBBAM], [1],
295                              [Define to 1 if libbam is available])],
296    [YAT_MSG_ERROR([Library 'libbam' was not found])])
297  AC_PATH_PROG([SAMTOOLS], [samtools], [false])
298  AC_ARG_VAR([SAMTOOLS], [Tools for alignment in the SAM format])
299], [
300  SAMTOOLS=false
301])
302AM_CONDITIONAL([HAVE_LIBBAM], [test x"$with_samtools" = x"yes"])
303AM_CONDITIONAL([HAVE_SAMTOOLS], [test x"$SAMTOOLS" != x"false"])
304AC_SUBST([SAMTOOLS])
305AS_IF([test x"$SAMTOOLS" = x"false"], [], [
306  AC_DEFINE([HAVE_SAMTOOLS], [1], [Define if samtools executable is available])
307])
308
309#support for large files
310AC_SYS_LARGEFILE
311if test "$enable_largefile" = "no"; then
312  AC_DEFINE([YAT_LFS_DISABLED], 1,
313            [defined to 1 if large file support is disabled])
314fi
315
316AC_DEFINE([HAVE_INLINE], [1], [Define if inline is available on system])
317AC_ARG_ENABLE([debug],
318  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
319
320# If neither --enable-assert nor --disable-assert, set enable_assert
321# to same as enable_debug
322AC_ARG_ENABLE([assert],
323              [AS_HELP_STRING([--enable-assert], [turn on assertions])],
324              [], [enable_assert=$enable_debug])
325
326# we use prefix INTERNAL_ for variables that are solely needed for
327# building yat, i.e., they are not needed for a user of yat and are
328# not propagated to yat-config or yat.m4.
329AS_IF([test "${enable_debug}" = "yes"], [
330  AC_DEFINE([YAT_DEBUG], [1], [Define to activate yat assertioons])
331  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wall -pedantic -g -O])
332], [
333  # avoid defining GSL_RANGE_CHECK_OFF if GSL_RANGE_CHECK is already defined
334  AC_CHECK_DECL([GSL_RANGE_CHECK],[],
335                [AC_DEFINE([GSL_RANGE_CHECK_OFF], [1],
336                           [Define to turn off GSL range checks])])
337  # If CXXFLAGS not set by user, set it to default value
338  AS_IF([test x$CXXFLAGS_set_by_user != xyes], [
339    YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS],[-O3])
340  ])
341])
342
343AS_IF([test x"$enable_assert" = x"no"], [
344  AC_DEFINE([NDEBUG], [1], [Define to turn off assertions])
345])
346
347# turn off compiler warning #654 from intel compiler
348AS_IF([test x"$ax_cv_cxx_compiler_vendor" = x"intel"], [
349  YAT_CXX_ADD_FLAG([CXXFLAGS], ['-diag-disable 654'])
350])
351
352# Turns warnings to errors in compilation tests. Only put tests that
353# should be warning sensitive below this point. Can't find any
354# mechanism to revert AC_LANG_WERROR
355AC_LANG_WERROR
356
357# GCC 4.0.1 on OSX complains about -pthread (issue #713)
358AS_IF([AS_ECHO(["$CPPFLAGS"]) | $GREP '\-pthread' > /dev/null],
359  [AX_CHECK_PREPROC_FLAG([-pthread], [],
360     [CPPFLAGS=`AS_ECHO(["$CPPFLAGS"]) | $SED 's%-pthread%%'`],
361     [$INTERNAL_CPPFLAGS])
362])
363
364AS_IF([test x$enable_debug = xyes], [
365  # some versions of boost uses long long - turn off compiler warnings
366  # with -Wno-long-long
367  yat_save_CXXFLAGS=$CXXFLAGS
368  AC_MSG_CHECKING([whether boost uses long long])
369  CXXFLAGS="$INTERNAL_CXXFLAGS $CXXFLAGS"
370  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
371    [
372      @%:@include <boost/iterator/transform_iterator.hpp>
373      @%:@include <boost/thread.hpp>
374      @%:@include <cmath>
375      @%:@include <functional>
376      @%:@include <vector>
377    ],[
378      using namespace boost;
379      typedef std::pointer_to_unary_function<double, double> F;
380      std::vector<double> vec;
381      transform_iterator<F, std::vector<double>::iterator>
382        i(vec.begin(), std::ptr_fun(fabs));
383      int x = boost::thread::hardware_concurrency();
384      ++x;
385    ])],
386  [AC_MSG_RESULT([no])],
387  [AC_MSG_RESULT([yes])
388   YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wno-long-long])
389  ])
390  # restore CXXFLAGS
391  CXXFLAGS=$yat_save_CXXFLAGS
392])
393
394#doxygen stuff
395DX_HTML_OUTPUT=html
396AC_SUBST(DX_HTML_OUTPUT)
397
398AC_CONFIG_FILES([build_support/gen_yat_pc.sh],
399                [chmod +x build_support/gen_yat_pc.sh])
400AC_CONFIG_FILES([build_support/tag_and_release.sh],
401                [chmod +x-w build_support/tag_and_release.sh])
402AC_CONFIG_FILES([Makefile
403     doc/doxygen.config
404     doc/first_page.doxygen
405     test/common_defs.sh
406])
407
408AC_CONFIG_HEADERS([yat/utility/config_public.h])
409# for the test suite
410yat_abs_top_srcdir=`cd $srcdir && pwd`
411AC_DEFINE_UNQUOTED([YAT_ABS_TOP_SRCDIR], ["$yat_abs_top_srcdir"],
412                   [Define to absolute path to top yat src dir])
413
414# Reset flags
415APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, YAT_)
416APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, YAT_)
417APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, YAT_)
418APR_RESTORE_THE_ENVIRONMENT(LIBS, YAT_)
419
420# YAT_LIBS minus cblas and math libraries
421YAT_PRIMARY_LIBS=
422for lib in $YAT_LIBS; do
423  AS_CASE([$lib], [$YAT_CBLAS_LIB], [],
424          [$LIBM], [],
425          [YAT_PRIMARY_LIBS="$YAT_PRIMARY_LIBS $lib"])
426done
427# workaround for ticket #736
428for lib in $BAM_LIBS; do
429  APR_REMOVEFROM([YAT_PRIMARY_LIBS], [$lib])
430done
431AC_SUBST(BAM_LIBS)
432AC_SUBST(YAT_PRIMARY_LIBS)
433AC_SUBST(YAT_LIBS)
434AC_SUBST(YAT_CBLAS_LIB)
435
436# set and AC_SUBST variables that are interpreted by Automake
437AM_CPPFLAGS="$INTERNAL_CPPFLAGS $YAT_CPPFLAGS"
438AM_CXXFLAGS="$INTERNAL_CXXFLAGS $YAT_CXXFLAGS"
439AM_LDFLAGS="$INTERNAL_LDFLAGS $YAT_LDFLAGS"
440
441AC_SUBST(AM_CPPFLAGS)
442AC_SUBST(AM_CXXFLAGS)
443AC_SUBST(AM_LDFLAGS)
444AC_SUBST(enable_static)
445
446YAT_SVN_RELEASE([am/maintainer.am])
447
448# set some variable for final message
449AS_CASE([$have_doxygen],
450        [yes], [doxygen_message=yes],
451        [no], [doxygen_message="no (doxygen not found)"],
452        [old], [doxygen_message="no (\`$DOXYGEN' too old)"],
453        [AC_MSG_WARN([unexpected value \$have_doxygen: '$have_doxygen'])
454         AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT)
455        ])
456
457yat_gslcblas_message=
458AS_IF([test "x$YAT_CBLAS_LIB" = "x-lgslcblas"], [
459yat_gslcblas_message='
460  GSL CBLAS found. This is a reference implementation only.
461  Consider using hardware optimized BLAS.
462  ATLAS (http://math-atlas.sourceforge.net/) provides an
463  optimized BLAS library. It is supported by yat!
464'
465])
466
467# Create output.
468AC_OUTPUT
469
470
471# Some more messages.
472AC_MSG_RESULT([
473yat is configured as follows:
474
475  Build Shared Library: $enable_shared
476  Build Static Library: $enable_static
477  Build Documentation:  $doxygen_message
478  With Bam Support:     $with_samtools
479
480Options used to compile and link:
481  VERSION     = $VERSION
482  CXX         = $CXX
483  CPPFLAGS    = $CPPFLAGS
484  YAT_CPPFLAGS= $AM_CPPFLAGS
485  CXXFLAGS    = $CXXFLAGS
486  YAT_CXXFLAGS= $AM_CXXFLAGS
487  LD          = $LD
488  LDFLAGS     = $LDFLAGS
489  YAT_LDFLAGS = $AM_LDFLAGS
490  LIBS        = $LIBS
491  YAT_LIBS    = $YAT_LIBS
492${yat_gslcblas_message}dnl
493----------------------------------------------------------------
494Now type `make'. dnl
495])
Note: See TracBrowser for help on using the repository browser.