source: trunk/configure.ac @ 2873

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

prefer using YAT_MSG_ERROR and simplify computation of YAT_PRIMARY_LIBS and YAT_LIBS

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