source: trunk/configure.ac @ 2083

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

Let user override the -D* flags that are set in configure. User can,
e.g, issue ./configure -DGSL_RANGE_CHECK=1 if he wants range check in
gsl but doesn't want the whole package that comes with --enable-debug.

serial in yat_add_flag.m4 is not updated because no point updating
serial multiple times between releases.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.6 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 2083 2009-10-19 22:33:30Z 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.61)
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  ]
116)
117
118AC_SUBST(have_doxygen)
119AM_CONDITIONAL([DX_ENABLE_HTML], [test x$have_doxygen = xyes])
120AM_CONDITIONAL([DX_ENABLE_LATEX], [test x$dx_enable_latex = xyes])
121AM_CONDITIONAL([DX_ENABLE_DVI], [test x$dx_enable_dvi = xyes])
122AM_CONDITIONAL([DX_ENABLE_PS], [test x$dx_enable_ps = xyes])
123AM_CONDITIONAL([DX_ENABLE_PDF], [test x$dx_enable_pdf = xyes])
124AC_CONFIG_FILES([test/documentation_test.sh],
125                [chmod +x test/documentation_test.sh])
126
127# Save user-defined environment settings for later restoration
128APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
129APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
130APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
131APR_SAVE_THE_ENVIRONMENT(LIBS)
132
133# Checks for libraries.
134AC_MSG_NOTICE([checking for libraries])
135AC_CHECK_LIBM
136
137# find library implementing BLAS C API, or use gslcblas
138YAT_LIB_CBLAS([YAT_CBLAS_LIB=$CBLAS_LIB], [YAT_CBLAS_LIB=-lgslcblas])
139
140# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
141# Including AX_PATH_GSL macro from gsl.m4 distributed by GSL
142gsl_version="1.8"
143AC_SUBST(gsl_version)
144gsl_ok=yes
145YAT_CHECK_GSL([$gsl_version],[gsl_ok=yes],[gsl_ok=no])
146
147# Boost http://www.boost.org
148boost_version=1.33
149AC_SUBST(boost_version)
150AX_BOOST_BASE(["$boost_version"])
151boost_version_check=$succeeded;
152YAT_CPP_ADD_FLAG([CPPFLAGS], [$BOOST_CPPFLAGS])
153
154#support for large files
155AC_SYS_LARGEFILE
156if test "$enable_largefile" = "no"; then
157  AC_DEFINE([YAT_LFS_DISABLED], 1,
158            [defined to 1 if large file support is disabled])
159fi
160
161# we use prefix INTERNAL_ for variables that are solely needed for
162# building yat, i.e., they are not needed for a user of yat and are
163# not propagated to yat-config or yat.m4.
164YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wall -pedantic])
165YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DHAVE_INLINE=1])
166AC_ARG_ENABLE([debug],
167  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
168if test "${enable_debug}" = "yes" ; then
169  YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DYAT_DEBUG=1])
170  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-g -O])
171else
172  # avoid defining GSL_RANGE_CHECK_OFF if GSL_RANGE_CHECK is already defined
173  AX_C_IFDEF([GSL_RANGE_CHECK],[],
174             [YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DGSL_RANGE_CHECK_OFF])
175  YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DNDEBUG])
176  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-O3])
177fi
178
179AC_ARG_ENABLE([svn-support],
180              [AS_HELP_STRING([--enable-svn-support],
181                              [enable svn support - used by yat maintainer])])
182
183if test "x$enable_svn-support" = "xyes"; then
184  svn_error_msg="svn support cannot be enabled:"
185  AS_IF([test "x$MD5" = "xno"],
186        [AC_MSG_ERROR([$svn_error_msg tool to create md5 file not found])])
187
188  AC_CHECK_FILE([$srcdir/.svn], ,
189                AC_MSG_ERROR([$svn_error_msg `$srcdir' is not an svn wc.]))
190fi
191AM_CONDITIONAL([ENABLE_SVN_SUPPORT], [test "x$enable_svn_support" = "xyes"])
192
193
194# check for quiet_NaN support in OS
195# Check at run-time, but if we are cross-compiling fall back on a
196# compilation test
197AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
198AC_RUN_IFELSE(
199  [AC_LANG_PROGRAM(
200    [@%:@include <limits>],
201    [return !std::numeric_limits<double>::has_quiet_NaN])],
202  [quiet_nan=yes
203   AC_MSG_RESULT($quiet_nan)],
204  [quiet_nan=no
205   AC_MSG_RESULT($quiet_nan)],
206  # if we are cross-compiling fall back on compilation test
207  [AC_MSG_RESULT(cross-compiling)
208   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
209    AC_COMPILE_IFELSE(
210     [AC_LANG_PROGRAM(
211        [@%:@include <limits>
212         extern void f(double);],
213        [f(std::numeric_limits<double>::quiet_NaN())])],
214     [quiet_nan=yes],
215     [quiet_nan=no])
216   AC_MSG_RESULT($quiet_nan)])
217# Check for infinity support for doubles in OS
218# Check at run-time, but if we are cross-compiling fall back on a
219# compilation test
220AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
221AC_RUN_IFELSE(
222  [AC_LANG_PROGRAM(
223    [@%:@include <limits>],
224    [return !std::numeric_limits<double>::has_infinity])],
225  [has_infinity=yes
226   AC_MSG_RESULT($has_infinity)],
227  [has_infinity=no
228   AC_MSG_RESULT($has_infinity)],
229  # if we are cross-compiling fall back on compilation test
230  [AC_MSG_RESULT(cross-compiling)
231   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
232    AC_COMPILE_IFELSE(
233     [AC_LANG_PROGRAM(
234        [@%:@include <limits>
235         extern void f(double);],
236        [f(std::numeric_limits<double>::infinity())])],
237     [has_infinity=yes],
238     [has_infinity=no])
239   AC_MSG_RESULT($has_infinity)])
240
241AC_MSG_CHECKING([g++ deprecation attribute])
242AC_COMPILE_IFELSE(
243   [AC_LANG_PROGRAM([[void f() __attribute__ ((deprecated));]],)], 
244   [AC_DEFINE([YAT_HAVE_GCC_DEPRECATED], [1],
245              [Define if compiler supports deprecated attribute, as in g++ 4.0])
246    AC_MSG_RESULT([yes])],
247   [AC_MSG_RESULT([no])] )
248
249AC_MSG_CHECKING([if std::multiset::iterator is mutable])
250AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <set>
251                                     @%:@include <vector>]],
252                                   [[std::set<std::vector<double> > s;
253                                     std::vector<double> v;
254                                     s.insert(v);
255                                     s.begin()->reserve(100);
256                                   ]])],
257                  [AC_DEFINE([MULTISET_ITERATOR_IS_MUTABLE], [1],
258                             [Define if std::multiset::iterator is mutable])
259                   AC_MSG_RESULT([yes])
260                  ],
261                  [AC_MSG_RESULT([no])] )
262
263# yat specific settings
264YAT_LIBNAME="yat"
265YAT_LIB_LOCATION="yat"
266AC_SUBST(YAT_LIBNAME)
267AC_SUBST(YAT_LIB_LOCATION)
268
269#doxygen stuff
270DX_HTML_OUTPUT=html
271DX_LATEX_OUTPUT=latex
272AC_SUBST(DX_HTML_OUTPUT)
273AC_SUBST(DX_LATEX_OUTPUT)
274
275
276AC_CONFIG_FILES([test/create_yathello.sh], [chmod +x test/create_yathello.sh])
277AC_CONFIG_FILES([Makefile
278     build_support/Makefile
279     doc/Makefile
280     doc/doxygen.config
281     doc/first_page.doxygen
282     m4/Makefile
283     test/Makefile
284     test/common_defs.sh
285     test/environment.h
286     test/data/Makefile
287     yat/Makefile
288     yat/classifier/Makefile
289     yat/normalizer/Makefile
290     yat/random/Makefile
291     yat/regression/Makefile
292     yat/statistics/Makefile
293     yat/utility/version.h
294     yat/utility/Makefile])
295
296AC_CONFIG_HEADER([yat/utility/config_public.h])
297
298# Print failure status information about selected items, and exit if
299# fatal errors were encountered. No output will be created if
300# configure is halted prematurely.
301
302# used to trigger exit before creation of output
303all_reqs_ok="true"
304
305# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
306# of created binary, will fail.
307if test "${quiet_nan}" = "no" ; then
308  all_reqs_ok="false"
309  AC_MSG_WARN([
310  Support for quiet NAN required.
311  Yat will not work on this system!])
312fi
313
314# No support for infinity is fatal -- sub-sequent compilation, or execution
315# of created binary, will fail.
316if test "${has_infinity}" = "no" ; then
317  all_reqs_ok="false"
318  AC_MSG_WARN([
319  Support for infinity required.
320  Yat will not work on this system!])
321fi
322
323
324# Non-existing GSL is fatal -- sub-sequent compilation will fail.
325if test "x$gsl_ok" != "xyes" ; then
326  all_reqs_ok="false"
327  AC_MSG_WARN([
328  GSL $gsl_version (or newer) not found. The GNU Scientific Library
329  (GSL) library cannot be found. Please make sure GSL is
330  installed. Please refer to warnings above for more details])
331fi
332
333if test "x$want_boost" = "xyes"; then
334# Too old Boost is fatal -- sub-sequent compilation will fail.
335if test "${boost_version_check}" != "yes" ; then
336  all_reqs_ok="false"
337  AC_MSG_WARN([
338  Boost found but not the required version. Please install
339  Boost version ${boost_version} or later])
340fi
341fi
342
343if (test "$all_reqs_ok" = "false") ; then
344  AC_MSG_FAILURE([
345  Some pre-requisites were not fulfilled, aborting configure.
346  Please consult the 'README' file for more information about what
347  is needed to compile yat and refer to above warning messages.
348  Needed files were NOT created.])
349fi
350
351# Reset flags
352APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, YAT_)
353APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, YAT_)
354APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, YAT_)
355APR_RESTORE_THE_ENVIRONMENT(LIBS, YAT_)
356
357YAT_PRIMARY_LIBS=-lgsl
358YAT_LIBS="$YAT_PRIMARY_LIBS $YAT_CBLAS_LIB $LIBM"
359AC_SUBST(YAT_PRIMARY_LIBS)
360AC_SUBST(YAT_LIBS)
361AC_SUBST(YAT_CBLAS_LIB)
362
363# set and AC_SUBST variables that are interpreted by Automake
364AM_CPPFLAGS="-I\$(top_srcdir) $INTERNAL_CPPFLAGS $YAT_CPPFLAGS"
365AM_CXXFLAGS="$INTERNAL_CXXFLAGS $YAT_CXXFLAGS"
366AM_LDFLAGS="$INTERNAL_LDFLAGS $YAT_LDFLAGS"
367
368AC_SUBST(AM_CPPFLAGS)
369AC_SUBST(AM_CXXFLAGS)
370AC_SUBST(AM_LDFLAGS)
371
372
373# Create output.
374AC_OUTPUT
375
376# Some more messages.
377AC_MSG_NOTICE([])
378AC_MSG_NOTICE([ Ready to compile the yat library])
379AS_IF([test x$have_doxygen = xyes],
380  [AC_MSG_NOTICE([ Documentation will be generated in the following formats:])
381   dox_formats="   html";
382   AS_IF([test x$dx_enable_pdf = xyes], [dox_formats="$dox_formats pdf"])
383   AS_IF([test x$dx_enable_ps = xyes],  [dox_formats="$dox_formats ps"])
384   AS_IF([test x$dx_enable_dvi = xyes], [dox_formats="$dox_formats dvi"])
385   AC_MSG_NOTICE([$dox_formats])
386  ],
387  [AC_MSG_NOTICE([Generation of documentation is disabled])
388   AC_MSG_NOTICE([doxygen could not be found])
389  ])
390AC_MSG_NOTICE()
391AC_MSG_NOTICE([ The following flags and libraries will be used:])
392AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
393AC_MSG_NOTICE([  CPPFLAGS=$CPPFLAGS])
394AC_MSG_NOTICE([  AM_CPPFLAGS=$AM_CPPFLAGS])
395AC_MSG_NOTICE([  CXXFLAGS=$CXXFLAGS])
396AC_MSG_NOTICE([  AM_CXXFLAGS=$AM_CXXFLAGS])
397AC_MSG_NOTICE([  LDFLAGS=$LDFLAGS])
398AC_MSG_NOTICE([  AM_LDFLAGS=$AM_LDFLAGS])
399AC_MSG_NOTICE([  LIBS=$LIBS])
400AC_MSG_NOTICE([  YAT_LIBS=$YAT_LIBS])
401AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
402AC_MSG_NOTICE([])
403if test "x$YAT_CBLAS_LIB" = "x-lgslcblas"; then
404AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
405AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
406AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
407AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
408AC_MSG_NOTICE([])
409fi
410AC_MSG_NOTICE([ Now type 'make && make check'.])
Note: See TracBrowser for help on using the repository browser.