source: trunk/configure.ac @ 2131

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

prefer using AC_CONFIG_HEADERS rather than AC_CONFIG_HEADER

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