source: trunk/configure.ac @ 3018

Last change on this file since 3018 was 3018, checked in by Peter, 10 years ago

merge patch release 0.10.2 into trunk

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