source: trunk/configure.ac @ 2107

Last change on this file since 2107 was 2107, checked in by Peter, 14 years ago

using AC_CHECK_DECL (from autoconf) rather than AX_C_IFDEF (from autoconf macro archive).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.6 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 2107 2009-11-07 15:53:27Z 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_CHECK_PROGS([MD5], [md5sum md5 md5deep], [no])
78
79AC_MSG_NOTICE(dnl
80[checking whether tools for generating documentation are available])
81
82have_doxygen=no
83dx_enable_latex=no
84dx_enable_dvi=no
85dx_enable_ps=no
86dx_enable_pdf=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])
96   AC_MSG_RESULT([$doxygen_version])
97   dx_enable_latex=yes
98   # doxygen 1.5.8 has a bug for latex output and enums
99   AS_IF([test $have_doxygen = yes],
100         [AX_COMPARE_VERSION([$doxygen_version], [eq], [1.5.8],
101                 [AC_MSG_WARN([doxygen 1.5.8 detected - latex output turned off])
102                  dx_enable_latex=no])])
103fi
104
105# we need latex output to generate dvi, ps, and pdf
106AS_IF([test $dx_enable_latex = yes],
107  [dx_enable_pdf=yes
108   ACLTX_PROG_PDFLATEX([dx_enable_pdf=no])
109   ACLTX_PROG_MAKEINDEX([dx_enable_pdf=no])
110   dx_enable_dvi=yes
111   ACLTX_PROG_LATEX([dx_enable_dvi=no])
112   # ps needs dvi
113   dx_enable_ps=$dx_enable_dvi
114   ACLTX_PROG_DVIPS([dx_enable_ps=no])
115   AS_IF([test "x$dx_enable_ps" != xno], [
116     YAT_PROG_DVIPS_PSPICTURE([], [dx_enable_ps=no
117                                   AC_MSG_NOTICE([ps generation turned off])])
118   ])
119  ]
120)
121
122AC_SUBST(have_doxygen)
123AM_CONDITIONAL([DX_ENABLE_HTML], [test x$have_doxygen = xyes])
124AM_CONDITIONAL([DX_ENABLE_LATEX], [test x$dx_enable_latex = xyes])
125AM_CONDITIONAL([DX_ENABLE_DVI], [test x$dx_enable_dvi = xyes])
126AM_CONDITIONAL([DX_ENABLE_PS], [test x$dx_enable_ps = xyes])
127AM_CONDITIONAL([DX_ENABLE_PDF], [test x$dx_enable_pdf = xyes])
128AC_CONFIG_FILES([test/documentation_test.sh],
129                [chmod +x test/documentation_test.sh])
130
131# check for quiet_NaN support in OS
132# Check at run-time, but if we are cross-compiling fall back on a
133# compilation test
134AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
135AC_RUN_IFELSE(
136  [AC_LANG_PROGRAM(
137    [@%:@include <limits>],
138    [return !std::numeric_limits<double>::has_quiet_NaN])],
139  [quiet_nan=yes
140   AC_MSG_RESULT($quiet_nan)],
141  [quiet_nan=no
142   AC_MSG_RESULT($quiet_nan)],
143  # if we are cross-compiling fall back on compilation test
144  [AC_MSG_RESULT(cross-compiling)
145   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
146    AC_COMPILE_IFELSE(
147     [AC_LANG_PROGRAM(
148        [@%:@include <limits>
149         extern void f(double);],
150        [f(std::numeric_limits<double>::quiet_NaN())])],
151     [quiet_nan=yes],
152     [quiet_nan=no])
153   AC_MSG_RESULT($quiet_nan)])
154# Check for infinity support for doubles in OS
155# Check at run-time, but if we are cross-compiling fall back on a
156# compilation test
157AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
158AC_RUN_IFELSE(
159  [AC_LANG_PROGRAM(
160    [@%:@include <limits>],
161    [return !std::numeric_limits<double>::has_infinity])],
162  [has_infinity=yes
163   AC_MSG_RESULT($has_infinity)],
164  [has_infinity=no
165   AC_MSG_RESULT($has_infinity)],
166  # if we are cross-compiling fall back on compilation test
167  [AC_MSG_RESULT(cross-compiling)
168   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
169    AC_COMPILE_IFELSE(
170     [AC_LANG_PROGRAM(
171        [@%:@include <limits>
172         extern void f(double);],
173        [f(std::numeric_limits<double>::infinity())])],
174     [has_infinity=yes],
175     [has_infinity=no])
176   AC_MSG_RESULT($has_infinity)])
177
178AC_MSG_CHECKING([g++ deprecation attribute])
179AC_COMPILE_IFELSE(
180   [AC_LANG_PROGRAM([[void f() __attribute__ ((deprecated));]],)], 
181   [AC_DEFINE([YAT_HAVE_GCC_DEPRECATED], [1],
182              [Define if compiler supports deprecated attribute, as in g++ 4.0])
183    AC_MSG_RESULT([yes])],
184   [AC_MSG_RESULT([no])] )
185
186AC_MSG_CHECKING([if std::multiset::iterator is mutable])
187AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <set>
188                                     @%:@include <vector>]],
189                                   [[std::set<std::vector<double> > s;
190                                     std::vector<double> v;
191                                     s.insert(v);
192                                     s.begin()->reserve(100);
193                                   ]])],
194                  [AC_DEFINE([MULTISET_ITERATOR_IS_MUTABLE], [1],
195                             [Define if std::multiset::iterator is mutable])
196                   AC_MSG_RESULT([yes])
197                  ],
198                  [AC_MSG_RESULT([no])] )
199
200# Save user-defined environment settings for later restoration
201APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
202APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
203APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
204APR_SAVE_THE_ENVIRONMENT(LIBS)
205
206# Checks for libraries.
207AC_MSG_NOTICE([checking for libraries])
208AC_CHECK_LIBM
209
210# find library implementing BLAS C API, or use gslcblas
211YAT_LIB_CBLAS([YAT_CBLAS_LIB=$CBLAS_LIB], [YAT_CBLAS_LIB=-lgslcblas])
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)
217gsl_ok=yes
218YAT_CHECK_GSL([$gsl_version],[gsl_ok=yes],[gsl_ok=no])
219
220# Boost http://www.boost.org
221boost_version=1.33
222AC_SUBST(boost_version)
223AX_BOOST_BASE(["$boost_version"])
224boost_version_check=$succeeded;
225YAT_CPP_ADD_FLAG([CPPFLAGS], [$BOOST_CPPFLAGS])
226
227#support for large files
228AC_SYS_LARGEFILE
229if test "$enable_largefile" = "no"; then
230  AC_DEFINE([YAT_LFS_DISABLED], 1,
231            [defined to 1 if large file support is disabled])
232fi
233
234# we use prefix INTERNAL_ for variables that are solely needed for
235# building yat, i.e., they are not needed for a user of yat and are
236# not propagated to yat-config or yat.m4.
237YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wall -pedantic])
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# some versions of boost uses long long - turn off compiler warnings
253# with -Wno-long-long
254yat_save_CXXFLAGS=$CXXFLAGS
255# use -pedantic and friends in CXXFLAGS temporarily
256CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
257# turn warnings into errors
258YAT_CXX_ADD_FLAG([CXXFLAGS], [-Werror])
259AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
260  [
261    @%:@include <boost/iterator/transform_iterator.hpp>
262    @%:@include <cmath>
263    @%:@include <functional>
264    @%:@include <vector>
265  ],[
266      using namespace boost;
267      typedef std::pointer_to_unary_function<double, double> F;
268      std::vector<double> vec;
269      transform_iterator<F, std::vector<double>::iterator>
270        i(vec.begin(), std::ptr_fun(fabs));
271  ])],
272[],
273[YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-Wno-long-long])])
274# restore CXXFLAGS
275CXXFLAGS=$yat_save_CXXFLAGS
276
277AC_ARG_ENABLE([svn-support],
278              [AS_HELP_STRING([--enable-svn-support],
279                              [enable svn support - used by yat maintainer])])
280
281if test "x$enable_svn-support" = "xyes"; then
282  svn_error_msg="svn support cannot be enabled:"
283  AS_IF([test "x$MD5" = "xno"],
284        [AC_MSG_ERROR([$svn_error_msg tool to create md5 file not found])])
285
286  AS_IF([test -d $srcdir/.svn], [],
287        [AC_MSG_ERROR([$svn_error_msg `$srcdir' is not an svn wc.])])
288fi
289AM_CONDITIONAL([ENABLE_SVN_SUPPORT], [test "x$enable_svn_support" = "xyes"])
290
291
292# yat specific settings
293YAT_LIBNAME="yat"
294YAT_LIB_LOCATION="yat"
295AC_SUBST(YAT_LIBNAME)
296AC_SUBST(YAT_LIB_LOCATION)
297
298#doxygen stuff
299DX_HTML_OUTPUT=html
300DX_LATEX_OUTPUT=latex
301AC_SUBST(DX_HTML_OUTPUT)
302AC_SUBST(DX_LATEX_OUTPUT)
303
304
305AC_CONFIG_FILES([test/create_yathello.sh], [chmod +x test/create_yathello.sh])
306AC_CONFIG_FILES([Makefile
307     build_support/Makefile
308     doc/Makefile
309     doc/doxygen.config
310     doc/first_page.doxygen
311     m4/Makefile
312     test/Makefile
313     test/common_defs.sh
314     test/environment.h
315     test/data/Makefile
316     yat/Makefile
317     yat/classifier/Makefile
318     yat/normalizer/Makefile
319     yat/random/Makefile
320     yat/regression/Makefile
321     yat/statistics/Makefile
322     yat/utility/version.h
323     yat/utility/Makefile])
324
325AC_CONFIG_HEADER([yat/utility/config_public.h])
326
327# Print failure status information about selected items, and exit if
328# fatal errors were encountered. No output will be created if
329# configure is halted prematurely.
330
331# used to trigger exit before creation of output
332all_reqs_ok="true"
333
334# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
335# of created binary, will fail.
336if test "${quiet_nan}" = "no" ; then
337  all_reqs_ok="false"
338  AC_MSG_WARN([
339  Support for quiet NAN required.
340  Yat will not work on this system!])
341fi
342
343# No support for infinity is fatal -- sub-sequent compilation, or execution
344# of created binary, will fail.
345if test "${has_infinity}" = "no" ; then
346  all_reqs_ok="false"
347  AC_MSG_WARN([
348  Support for infinity required.
349  Yat will not work on this system!])
350fi
351
352
353# Non-existing GSL is fatal -- sub-sequent compilation will fail.
354if test "x$gsl_ok" != "xyes" ; then
355  all_reqs_ok="false"
356  AC_MSG_WARN([
357  GSL $gsl_version (or newer) not found. The GNU Scientific Library
358  (GSL) library cannot be found. Please make sure GSL is
359  installed. Please refer to warnings above for more details])
360fi
361
362if test "x$want_boost" = "xyes"; then
363# Too old Boost is fatal -- sub-sequent compilation will fail.
364if test "${boost_version_check}" != "yes" ; then
365  all_reqs_ok="false"
366  AC_MSG_WARN([
367  Boost found but not the required version. Please install
368  Boost version ${boost_version} or later])
369fi
370fi
371
372if (test "$all_reqs_ok" = "false") ; then
373  AC_MSG_FAILURE([
374  Some pre-requisites were not fulfilled, aborting configure.
375  Please consult the 'README' file for more information about what
376  is needed to compile yat and refer to above warning messages.
377  Needed files were NOT created.])
378fi
379
380# Reset flags
381APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, YAT_)
382APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, YAT_)
383APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, YAT_)
384APR_RESTORE_THE_ENVIRONMENT(LIBS, YAT_)
385
386YAT_PRIMARY_LIBS=-lgsl
387YAT_LIBS="$YAT_PRIMARY_LIBS $YAT_CBLAS_LIB $LIBM"
388AC_SUBST(YAT_PRIMARY_LIBS)
389AC_SUBST(YAT_LIBS)
390AC_SUBST(YAT_CBLAS_LIB)
391
392# set and AC_SUBST variables that are interpreted by Automake
393AM_CPPFLAGS="-I\$(top_srcdir) $INTERNAL_CPPFLAGS $YAT_CPPFLAGS"
394AM_CXXFLAGS="$INTERNAL_CXXFLAGS $YAT_CXXFLAGS"
395AM_LDFLAGS="$INTERNAL_LDFLAGS $YAT_LDFLAGS"
396
397AC_SUBST(AM_CPPFLAGS)
398AC_SUBST(AM_CXXFLAGS)
399AC_SUBST(AM_LDFLAGS)
400
401
402# Create output.
403AC_OUTPUT
404
405# Some more messages.
406AC_MSG_NOTICE([])
407AC_MSG_NOTICE([ Ready to compile the yat library])
408AS_IF([test x$have_doxygen = xyes],
409  [AC_MSG_NOTICE([ Documentation will be generated in the following formats:])
410   dox_formats="   html";
411   AS_IF([test x$dx_enable_pdf = xyes], [dox_formats="$dox_formats pdf"])
412   AS_IF([test x$dx_enable_ps = xyes],  [dox_formats="$dox_formats ps"])
413   AS_IF([test x$dx_enable_dvi = xyes], [dox_formats="$dox_formats dvi"])
414   AC_MSG_NOTICE([$dox_formats])
415  ],
416  [AC_MSG_NOTICE([Generation of documentation is disabled])
417   AC_MSG_NOTICE([doxygen could not be found])
418  ])
419AC_MSG_NOTICE()
420AC_MSG_NOTICE([ The following flags and libraries will be used:])
421AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
422AC_MSG_NOTICE([  CPPFLAGS=$CPPFLAGS])
423AC_MSG_NOTICE([  AM_CPPFLAGS=$AM_CPPFLAGS])
424AC_MSG_NOTICE([  CXXFLAGS=$CXXFLAGS])
425AC_MSG_NOTICE([  AM_CXXFLAGS=$AM_CXXFLAGS])
426AC_MSG_NOTICE([  LDFLAGS=$LDFLAGS])
427AC_MSG_NOTICE([  AM_LDFLAGS=$AM_LDFLAGS])
428AC_MSG_NOTICE([  LIBS=$LIBS])
429AC_MSG_NOTICE([  YAT_LIBS=$YAT_LIBS])
430AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
431AC_MSG_NOTICE([])
432if test "x$YAT_CBLAS_LIB" = "x-lgslcblas"; then
433AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
434AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
435AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
436AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
437AC_MSG_NOTICE([])
438fi
439AC_MSG_NOTICE([ Now type 'make && make check'.])
Note: See TracBrowser for help on using the repository browser.