source: trunk/configure.ac @ 2112

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

Note, this will likely break the Makefile; you need to run autoreconf -m.

Moving maintainer rules to an m4 autoconf macro to make it more
reusable. The macro creates an automake fragment file, which is
included in the top Makefile.am. The macro also searches a tool to
calculate md5sum. We prefer gmd5sum over md5, i.e., on Darwin we
prefer the GNU version installed by port.

  • 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 2112 2009-11-15 16:59:00Z 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# use -pedantic and friends in CXXFLAGS temporarily
254CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
255# turn warnings into errors
256YAT_CXX_ADD_FLAG([CXXFLAGS], [-Werror])
257AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
258  [
259    @%:@include <boost/iterator/transform_iterator.hpp>
260    @%:@include <cmath>
261    @%:@include <functional>
262    @%:@include <vector>
263  ],[
264      using namespace boost;
265      typedef std::pointer_to_unary_function<double, double> F;
266      std::vector<double> vec;
267      transform_iterator<F, std::vector<double>::iterator>
268        i(vec.begin(), std::ptr_fun(fabs));
269  ])],
270[],
271[YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-Wno-long-long])])
272# restore CXXFLAGS
273CXXFLAGS=$yat_save_CXXFLAGS
274
275AC_ARG_ENABLE([svn-support],
276              [AS_HELP_STRING([--enable-svn-support],
277                              [enable svn support - used by yat maintainer])])
278
279if test "x$enable_svn-support" = "xyes"; then
280  svn_error_msg="svn support cannot be enabled:"
281  AS_IF([test "x$MD5" = "xno"],
282        [AC_MSG_ERROR([$svn_error_msg tool to create md5 file not found])])
283
284  AS_IF([test -d $srcdir/.svn], [],
285        [AC_MSG_ERROR([$svn_error_msg `$srcdir' is not an svn wc.])])
286fi
287AM_CONDITIONAL([ENABLE_SVN_SUPPORT], [test "x$enable_svn_support" = "xyes"])
288
289
290# yat specific settings
291YAT_LIBNAME="yat"
292YAT_LIB_LOCATION="yat"
293AC_SUBST(YAT_LIBNAME)
294AC_SUBST(YAT_LIB_LOCATION)
295
296#doxygen stuff
297DX_HTML_OUTPUT=html
298DX_LATEX_OUTPUT=latex
299AC_SUBST(DX_HTML_OUTPUT)
300AC_SUBST(DX_LATEX_OUTPUT)
301
302
303AC_CONFIG_FILES([test/create_yathello.sh], [chmod +x test/create_yathello.sh])
304AC_CONFIG_FILES([Makefile
305     build_support/Makefile
306     doc/Makefile
307     doc/doxygen.config
308     doc/first_page.doxygen
309     m4/Makefile
310     test/Makefile
311     test/common_defs.sh
312     test/environment.h
313     test/data/Makefile
314     yat/Makefile
315     yat/classifier/Makefile
316     yat/normalizer/Makefile
317     yat/random/Makefile
318     yat/regression/Makefile
319     yat/statistics/Makefile
320     yat/utility/version.h
321     yat/utility/Makefile])
322
323AC_CONFIG_HEADER([yat/utility/config_public.h])
324
325# Print failure status information about selected items, and exit if
326# fatal errors were encountered. No output will be created if
327# configure is halted prematurely.
328
329# used to trigger exit before creation of output
330all_reqs_ok="true"
331
332# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
333# of created binary, will fail.
334if test "${quiet_nan}" = "no" ; then
335  all_reqs_ok="false"
336  AC_MSG_WARN([
337  Support for quiet NAN required.
338  Yat will not work on this system!])
339fi
340
341# No support for infinity is fatal -- sub-sequent compilation, or execution
342# of created binary, will fail.
343if test "${has_infinity}" = "no" ; then
344  all_reqs_ok="false"
345  AC_MSG_WARN([
346  Support for infinity required.
347  Yat will not work on this system!])
348fi
349
350
351# Non-existing GSL is fatal -- sub-sequent compilation will fail.
352if test "x$gsl_ok" != "xyes" ; then
353  all_reqs_ok="false"
354  AC_MSG_WARN([
355  GSL $gsl_version (or newer) not found. The GNU Scientific Library
356  (GSL) library cannot be found. Please make sure GSL is
357  installed. Please refer to warnings above for more details])
358fi
359
360if test "x$want_boost" = "xyes"; then
361# Too old Boost is fatal -- sub-sequent compilation will fail.
362if test "${boost_version_check}" != "yes" ; then
363  all_reqs_ok="false"
364  AC_MSG_WARN([
365  Boost found but not the required version. Please install
366  Boost version ${boost_version} or later])
367fi
368fi
369
370if (test "$all_reqs_ok" = "false") ; then
371  AC_MSG_FAILURE([
372  Some pre-requisites were not fulfilled, aborting configure.
373  Please consult the 'README' file for more information about what
374  is needed to compile yat and refer to above warning messages.
375  Needed files were NOT created.])
376fi
377
378# Reset flags
379APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, YAT_)
380APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, YAT_)
381APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, YAT_)
382APR_RESTORE_THE_ENVIRONMENT(LIBS, YAT_)
383
384YAT_PRIMARY_LIBS=-lgsl
385YAT_LIBS="$YAT_PRIMARY_LIBS $YAT_CBLAS_LIB $LIBM"
386AC_SUBST(YAT_PRIMARY_LIBS)
387AC_SUBST(YAT_LIBS)
388AC_SUBST(YAT_CBLAS_LIB)
389
390# set and AC_SUBST variables that are interpreted by Automake
391AM_CPPFLAGS="-I\$(top_srcdir) $INTERNAL_CPPFLAGS $YAT_CPPFLAGS"
392AM_CXXFLAGS="$INTERNAL_CXXFLAGS $YAT_CXXFLAGS"
393AM_LDFLAGS="$INTERNAL_LDFLAGS $YAT_LDFLAGS"
394
395AC_SUBST(AM_CPPFLAGS)
396AC_SUBST(AM_CXXFLAGS)
397AC_SUBST(AM_LDFLAGS)
398
399YAT_SVN_RELEASE
400
401# Create output.
402AC_OUTPUT
403
404# Some more messages.
405AC_MSG_NOTICE([])
406AC_MSG_NOTICE([ Ready to compile the yat library])
407AS_IF([test x$have_doxygen = xyes],
408  [AC_MSG_NOTICE([ Documentation will be generated in the following formats:])
409   dox_formats="   html";
410   AS_IF([test x$dx_enable_pdf = xyes], [dox_formats="$dox_formats pdf"])
411   AS_IF([test x$dx_enable_ps = xyes],  [dox_formats="$dox_formats ps"])
412   AS_IF([test x$dx_enable_dvi = xyes], [dox_formats="$dox_formats dvi"])
413   AC_MSG_NOTICE([$dox_formats])
414  ],
415  [AC_MSG_NOTICE([Generation of documentation is disabled])
416   AC_MSG_NOTICE([doxygen could not be found])
417  ])
418AC_MSG_NOTICE()
419AC_MSG_NOTICE([ The following flags and libraries will be used:])
420AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
421AC_MSG_NOTICE([  CPPFLAGS=$CPPFLAGS])
422AC_MSG_NOTICE([  AM_CPPFLAGS=$AM_CPPFLAGS])
423AC_MSG_NOTICE([  CXXFLAGS=$CXXFLAGS])
424AC_MSG_NOTICE([  AM_CXXFLAGS=$AM_CXXFLAGS])
425AC_MSG_NOTICE([  LDFLAGS=$LDFLAGS])
426AC_MSG_NOTICE([  AM_LDFLAGS=$AM_LDFLAGS])
427AC_MSG_NOTICE([  LIBS=$LIBS])
428AC_MSG_NOTICE([  YAT_LIBS=$YAT_LIBS])
429AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
430AC_MSG_NOTICE([])
431if test "x$YAT_CBLAS_LIB" = "x-lgslcblas"; then
432AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
433AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
434AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
435AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
436AC_MSG_NOTICE([])
437fi
438AC_MSG_NOTICE([ Now type 'make && make check'.])
Note: See TracBrowser for help on using the repository browser.