source: branches/0.9-stable/configure.ac @ 2830

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

add link tests with boost. closes #719

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