source: trunk/configure.ac @ 2308

Last change on this file since 2308 was 2308, checked in by Peter, 11 years ago

creating dummie doxygen.mk during configure. fixes #636

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