source: trunk/configure.ac @ 3086

Last change on this file since 3086 was 3086, checked in by Peter, 8 years ago

add a new variable YAT_STATIC_LIBS; perform test if LIBM is suitable for libyat.la or should be added to YAT_STATIC_LIBS. refs #737

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