source: trunk/configure.ac @ 2769

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

refs #568. test using multithreaded RNG

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