source: trunk/configure.ac @ 2120

Last change on this file since 2120 was 2120, checked in by Peter, 12 years ago

fix so -Wno-long-long is turned on when included boost header use long long, avoid unneeded correlation in configure

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.5 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 2120 2009-12-13 03:58:07Z 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#
11# This file is part of the yat library, http://dev.thep.lu.se/yat
12#
13# The yat library is free software; you can redistribute it
14# and/or modify it under the terms of the GNU General Public License as
15# published by the Free Software Foundation; either version 3 of the
16# License, or (at your option) any later version.
17#
18# The yat library is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with yat. If not, see <http://www.gnu.org/licenses/>.
25#
26# If you grabbed the source from the subversion repository you should,
27# at top-level, execute:
28#     ./bootstrap
29# To push subsequent changes of this file into the build scripts you
30# must issue:
31#     autoreconf
32
33m4_include([m4/version.m4])
34AC_INIT([yat],[YAT_VERSION],[jari@thep.lu.se],,[http://dev.thep.lu.se/yat])
35AC_PREREQ(2.63)
36AC_CONFIG_SRCDIR([yat/utility/Matrix.h])
37AC_CONFIG_AUX_DIR([autotools])
38dnl arg below should be the same as in Makefile.am
39AC_CONFIG_MACRO_DIR([m4])
40AC_PREFIX_DEFAULT([/usr/local])
41
42AC_SUBST([YAT_LT_VERSION], [YAT_LT_VERSION_INFO])
43AC_SUBST([YAT_MAJOR_VERSION], [MAJOR_VERSION])
44AC_SUBST([YAT_MINOR_VERSION], [MINOR_VERSION])
45AC_SUBST([YAT_PATCH_VERSION], [PATCH_VERSION])
46AC_SUBST([YAT_DEV_BUILD], [DEV_BUILD])
47
48AC_CONFIG_HEADER([config.h])
49AM_INIT_AUTOMAKE([1.10 std-options])
50
51# Set default programming language
52AC_LANG(C++)
53
54# propagate selected configure variables to DISTCHECK_CONFIGURE_FLAGS
55for var in CPPFLAGS CXX CXXFLAGS CXXCPP LDFLAGS LIBS; do
56  eval isset=\${$var+set}
57  if test "$isset" = 'set' ; then
58    eval val=$`echo $var`
59    DISTCHECK_CONFIGURE_FLAGS="${DISTCHECK_CONFIGURE_FLAGS}'${var}=${val}' "
60  fi
61done
62AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
63
64# Let user overide default CXXFLAGS
65if test "${CXXFLAGS+set}" != set; then
66  CXXFLAGS=""  # Setting CXXFLAGS here to prevent expansion in AC_PROG_CXX
67fi
68# Checks for programs.
69AC_PROG_CXX
70AC_PROG_INSTALL
71AC_PROG_SED
72AC_PROG_LIBTOOL
73# fall back to echo unless ECHO not already set (by libtool)
74AS_IF([test "x$ECHO" = x], [ECHO=echo])
75AC_SUBST(ECHO)
76
77AC_MSG_NOTICE(dnl
78[checking whether tools for generating documentation are available])
79
80have_doxygen=no
81dx_enable_latex=no
82dx_enable_dvi=no
83dx_enable_ps=no
84dx_enable_pdf=no
85AC_PATH_PROG([DOXYGEN], [doxygen], [no])
86if test "$DOXYGEN" = "no"; then
87   AC_MSG_WARN([unable to find doxygen application])
88else
89   doxygen_min_version=1.5
90   AC_MSG_CHECKING([if doxygen is at least $doxygen_min_version])
91   doxygen_version=`$DOXYGEN --version`
92   AX_COMPARE_VERSION([$doxygen_version], [ge], [$doxygen_min_version],
93                      [have_doxygen=yes])
94   AC_MSG_RESULT([$doxygen_version])
95   dx_enable_latex=yes
96   # doxygen 1.5.8 has a bug for latex output and enums
97   AS_IF([test $have_doxygen = yes],
98         [AX_COMPARE_VERSION([$doxygen_version], [eq], [1.5.8],
99                 [AC_MSG_WARN([doxygen 1.5.8 detected - latex output turned off])
100                  dx_enable_latex=no])])
101fi
102
103# we need latex output to generate dvi, ps, and pdf
104AS_IF([test $dx_enable_latex = yes],
105  [dx_enable_pdf=yes
106   ACLTX_PROG_PDFLATEX([dx_enable_pdf=no])
107   ACLTX_PROG_MAKEINDEX([dx_enable_pdf=no])
108   dx_enable_dvi=yes
109   ACLTX_PROG_LATEX([dx_enable_dvi=no])
110   # ps needs dvi
111   dx_enable_ps=$dx_enable_dvi
112   ACLTX_PROG_DVIPS([dx_enable_ps=no])
113   AS_IF([test "x$dx_enable_ps" != xno], [
114     YAT_PROG_DVIPS_PSPICTURE([], [dx_enable_ps=no
115                                   AC_MSG_NOTICE([ps generation turned off])])
116   ])
117  ]
118)
119
120AC_SUBST(have_doxygen)
121AM_CONDITIONAL([DX_ENABLE_HTML], [test x$have_doxygen = xyes])
122AM_CONDITIONAL([DX_ENABLE_LATEX], [test x$dx_enable_latex = xyes])
123AM_CONDITIONAL([DX_ENABLE_DVI], [test x$dx_enable_dvi = xyes])
124AM_CONDITIONAL([DX_ENABLE_PS], [test x$dx_enable_ps = xyes])
125AM_CONDITIONAL([DX_ENABLE_PDF], [test x$dx_enable_pdf = xyes])
126AC_CONFIG_FILES([test/documentation_test.sh],
127                [chmod +x test/documentation_test.sh])
128
129# check for quiet_NaN support in OS
130# Check at run-time, but if we are cross-compiling fall back on a
131# compilation test
132AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
133AC_RUN_IFELSE(
134  [AC_LANG_PROGRAM(
135    [@%:@include <limits>],
136    [return !std::numeric_limits<double>::has_quiet_NaN])],
137  [quiet_nan=yes
138   AC_MSG_RESULT($quiet_nan)],
139  [quiet_nan=no
140   AC_MSG_RESULT($quiet_nan)],
141  # if we are cross-compiling fall back on compilation test
142  [AC_MSG_RESULT(cross-compiling)
143   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
144    AC_COMPILE_IFELSE(
145     [AC_LANG_PROGRAM(
146        [@%:@include <limits>
147         extern void f(double);],
148        [f(std::numeric_limits<double>::quiet_NaN())])],
149     [quiet_nan=yes],
150     [quiet_nan=no])
151   AC_MSG_RESULT($quiet_nan)])
152# Check for infinity support for doubles in OS
153# Check at run-time, but if we are cross-compiling fall back on a
154# compilation test
155AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
156AC_RUN_IFELSE(
157  [AC_LANG_PROGRAM(
158    [@%:@include <limits>],
159    [return !std::numeric_limits<double>::has_infinity])],
160  [has_infinity=yes
161   AC_MSG_RESULT($has_infinity)],
162  [has_infinity=no
163   AC_MSG_RESULT($has_infinity)],
164  # if we are cross-compiling fall back on compilation test
165  [AC_MSG_RESULT(cross-compiling)
166   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
167    AC_COMPILE_IFELSE(
168     [AC_LANG_PROGRAM(
169        [@%:@include <limits>
170         extern void f(double);],
171        [f(std::numeric_limits<double>::infinity())])],
172     [has_infinity=yes],
173     [has_infinity=no])
174   AC_MSG_RESULT($has_infinity)])
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
207
208# find library implementing BLAS C API, or use gslcblas
209YAT_LIB_CBLAS([YAT_CBLAS_LIB=$CBLAS_LIB], [YAT_CBLAS_LIB=-lgslcblas])
210
211# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
212# Including AX_PATH_GSL macro from gsl.m4 distributed by GSL
213gsl_version="1.8"
214AC_SUBST(gsl_version)
215gsl_ok=yes
216YAT_CHECK_GSL([$gsl_version],[gsl_ok=yes],[gsl_ok=no])
217
218# Boost http://www.boost.org
219boost_version=1.33
220AC_SUBST(boost_version)
221AX_BOOST_BASE(["$boost_version"])
222boost_version_check=$succeeded;
223YAT_CPP_ADD_FLAG([CPPFLAGS], [$BOOST_CPPFLAGS])
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.
235YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wall -pedantic])
236YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DHAVE_INLINE=1])
237AC_ARG_ENABLE([debug],
238  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
239if test "${enable_debug}" = "yes" ; then
240  YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DYAT_DEBUG=1])
241  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-g -O])
242else
243  # avoid defining GSL_RANGE_CHECK_OFF if GSL_RANGE_CHECK is already defined
244  AC_CHECK_DECL([GSL_RANGE_CHECK],[],
245                [YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS],[-DGSL_RANGE_CHECK_OFF])])
246  YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DNDEBUG])
247  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-O3])
248fi
249
250# some versions of boost uses long long - turn off compiler warnings
251# with -Wno-long-long
252yat_save_CXXFLAGS=$CXXFLAGS
253# turn warnings into errors
254YAT_CXX_ADD_FLAG([CXXFLAGS], [-pedantic-errors])
255AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
256  [
257    @%:@include <boost/iterator/transform_iterator.hpp>
258    @%:@include <cmath>
259    @%:@include <functional>
260    @%:@include <vector>
261  ],[
262      using namespace boost;
263      typedef std::pointer_to_unary_function<double, double> F;
264      std::vector<double> vec;
265      transform_iterator<F, std::vector<double>::iterator>
266        i(vec.begin(), std::ptr_fun(fabs));
267  ])],
268[],
269[YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wno-long-long])])
270# restore CXXFLAGS
271CXXFLAGS=$yat_save_CXXFLAGS
272
273AC_ARG_ENABLE([svn-support],
274              [AS_HELP_STRING([--enable-svn-support],
275                              [enable svn support - used by yat maintainer])])
276
277if test "x$enable_svn-support" = "xyes"; then
278  svn_error_msg="svn support cannot be enabled:"
279  AS_IF([test "x$MD5" = "xno"],
280        [AC_MSG_ERROR([$svn_error_msg tool to create md5 file not found])])
281
282  AS_IF([test -d $srcdir/.svn], [],
283        [AC_MSG_ERROR([$svn_error_msg `$srcdir' is not an svn wc.])])
284fi
285AM_CONDITIONAL([ENABLE_SVN_SUPPORT], [test "x$enable_svn_support" = "xyes"])
286
287
288# yat specific settings
289YAT_LIBNAME="yat"
290YAT_LIB_LOCATION="yat"
291AC_SUBST(YAT_LIBNAME)
292AC_SUBST(YAT_LIB_LOCATION)
293
294#doxygen stuff
295DX_HTML_OUTPUT=html
296DX_LATEX_OUTPUT=latex
297AC_SUBST(DX_HTML_OUTPUT)
298AC_SUBST(DX_LATEX_OUTPUT)
299
300
301AC_CONFIG_FILES([test/create_yathello.sh], [chmod +x test/create_yathello.sh])
302AC_CONFIG_FILES([Makefile
303     build_support/Makefile
304     doc/Makefile
305     doc/doxygen.config
306     doc/first_page.doxygen
307     m4/Makefile
308     test/Makefile
309     test/common_defs.sh
310     test/environment.h
311     test/data/Makefile
312     yat/Makefile
313     yat/classifier/Makefile
314     yat/normalizer/Makefile
315     yat/random/Makefile
316     yat/regression/Makefile
317     yat/statistics/Makefile
318     yat/utility/version.h
319     yat/utility/Makefile])
320
321AC_CONFIG_HEADER([yat/utility/config_public.h])
322
323# Print failure status information about selected items, and exit if
324# fatal errors were encountered. No output will be created if
325# configure is halted prematurely.
326
327# used to trigger exit before creation of output
328all_reqs_ok="true"
329
330# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
331# of created binary, will fail.
332if test "${quiet_nan}" = "no" ; then
333  all_reqs_ok="false"
334  AC_MSG_WARN([
335  Support for quiet NAN required.
336  Yat will not work on this system!])
337fi
338
339# No support for infinity is fatal -- sub-sequent compilation, or execution
340# of created binary, will fail.
341if test "${has_infinity}" = "no" ; then
342  all_reqs_ok="false"
343  AC_MSG_WARN([
344  Support for infinity required.
345  Yat will not work on this system!])
346fi
347
348
349# Non-existing GSL is fatal -- sub-sequent compilation will fail.
350if test "x$gsl_ok" != "xyes" ; then
351  all_reqs_ok="false"
352  AC_MSG_WARN([
353  GSL $gsl_version (or newer) not found. The GNU Scientific Library
354  (GSL) library cannot be found. Please make sure GSL is
355  installed. Please refer to warnings above for more details])
356fi
357
358if test "x$want_boost" = "xyes"; then
359# Too old Boost is fatal -- sub-sequent compilation will fail.
360if test "${boost_version_check}" != "yes" ; then
361  all_reqs_ok="false"
362  AC_MSG_WARN([
363  Boost found but not the required version. Please install
364  Boost version ${boost_version} or later])
365fi
366fi
367
368if (test "$all_reqs_ok" = "false") ; then
369  AC_MSG_FAILURE([
370  Some pre-requisites were not fulfilled, aborting configure.
371  Please consult the 'README' file for more information about what
372  is needed to compile yat and refer to above warning messages.
373  Needed files were NOT created.])
374fi
375
376# Reset flags
377APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, YAT_)
378APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, YAT_)
379APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, YAT_)
380APR_RESTORE_THE_ENVIRONMENT(LIBS, YAT_)
381
382YAT_PRIMARY_LIBS=-lgsl
383YAT_LIBS="$YAT_PRIMARY_LIBS $YAT_CBLAS_LIB $LIBM"
384AC_SUBST(YAT_PRIMARY_LIBS)
385AC_SUBST(YAT_LIBS)
386AC_SUBST(YAT_CBLAS_LIB)
387
388# set and AC_SUBST variables that are interpreted by Automake
389AM_CPPFLAGS="-I\$(top_srcdir) $INTERNAL_CPPFLAGS $YAT_CPPFLAGS"
390AM_CXXFLAGS="$INTERNAL_CXXFLAGS $YAT_CXXFLAGS"
391AM_LDFLAGS="$INTERNAL_LDFLAGS $YAT_LDFLAGS"
392
393AC_SUBST(AM_CPPFLAGS)
394AC_SUBST(AM_CXXFLAGS)
395AC_SUBST(AM_LDFLAGS)
396
397YAT_SVN_RELEASE
398
399# Create output.
400AC_OUTPUT
401
402# Some more messages.
403AC_MSG_NOTICE([])
404AC_MSG_NOTICE([ Ready to compile the yat library])
405AS_IF([test x$have_doxygen = xyes],
406  [AC_MSG_NOTICE([ Documentation will be generated in the following formats:])
407   dox_formats="   html";
408   AS_IF([test x$dx_enable_pdf = xyes], [dox_formats="$dox_formats pdf"])
409   AS_IF([test x$dx_enable_ps = xyes],  [dox_formats="$dox_formats ps"])
410   AS_IF([test x$dx_enable_dvi = xyes], [dox_formats="$dox_formats dvi"])
411   AC_MSG_NOTICE([$dox_formats])
412  ],
413  [AC_MSG_NOTICE([Generation of documentation is disabled])
414   AC_MSG_NOTICE([doxygen could not be found])
415  ])
416AC_MSG_NOTICE()
417AC_MSG_NOTICE([ The following flags and libraries will be used:])
418AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
419AC_MSG_NOTICE([  CPPFLAGS=$CPPFLAGS])
420AC_MSG_NOTICE([  AM_CPPFLAGS=$AM_CPPFLAGS])
421AC_MSG_NOTICE([  CXXFLAGS=$CXXFLAGS])
422AC_MSG_NOTICE([  AM_CXXFLAGS=$AM_CXXFLAGS])
423AC_MSG_NOTICE([  LDFLAGS=$LDFLAGS])
424AC_MSG_NOTICE([  AM_LDFLAGS=$AM_LDFLAGS])
425AC_MSG_NOTICE([  LIBS=$LIBS])
426AC_MSG_NOTICE([  YAT_LIBS=$YAT_LIBS])
427AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
428AC_MSG_NOTICE([])
429if test "x$YAT_CBLAS_LIB" = "x-lgslcblas"; then
430AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
431AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
432AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
433AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
434AC_MSG_NOTICE([])
435fi
436AC_MSG_NOTICE([ Now type 'make && make check'.])
Note: See TracBrowser for help on using the repository browser.