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

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

prefer flat_namespace on darwin (OSX). refs #745

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