source: trunk/configure.ac @ 2872

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

prefer YAT_MSG_ERROR. using it in inf test

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