source: trunk/configure.ac @ 1896

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

prefer using macro when it exists

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.0 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1896 2009-04-15 19:37:07Z 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])
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_MSG_NOTICE(dnl
78[checking whether tools for generating documentation are available])
79
80have_dox_tools="yes"
81AC_PATH_PROG([DOXYGEN], [doxygen], [no])
82if test "$DOXYGEN" = "no"; then
83   AC_MSG_WARN([unable to find doxygen application])
84   have_dox_tools=no
85else
86   doxygen_min_version=1.5
87   AC_MSG_CHECKING([if doxygen is at least $doxygen_min_version])
88   doxygen_version=`$DOXYGEN --version`
89   AX_COMPARE_VERSION([$doxygen_version], [ge], [$doxygen_min_version], ,
90                      [have_dox_tools=no])
91   AC_MSG_RESULT([$doxygen_version])
92fi
93AC_CHECK_PROG([have_epstopdf], [epstopdf], [yes], [no])
94if test "$have_epstopdf" != "yes"; then
95   AC_MSG_WARN([unable to find epstopdf application])
96   have_dox_tools=no
97fi
98AC_CHECK_PROG([have_latex], [latex], [yes], [no])
99if test "$have_latex" != "yes"; then
100   AC_MSG_WARN([unable to find latex application])
101fi
102AC_CHECK_PROG([have_makeindex], [makeindex], [yes], [no])
103if test "$have_makeindex" != "yes"; then
104   AC_MSG_WARN([unable to find makeindex application])
105   have_dox_tools=no
106fi
107AC_CHECK_PROG([have_pdflatex], [pdflatex], [yes], [no])
108if test "$have_pdflatex" != "yes"; then
109   AC_MSG_WARN([unable to find pdflatex application])
110   have_dox_tools=no
111fi
112
113AC_SUBST(have_dox_tools)
114AM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_dox_tools" = "yes"])
115AC_CONFIG_FILES([test/documentation_test.sh],
116                [chmod +x test/documentation_test.sh])
117
118# Save user-defined environment settings for later restoration
119APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
120APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
121APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
122APR_SAVE_THE_ENVIRONMENT(LIBS)
123
124# Checks for libraries.
125AC_MSG_NOTICE([checking for libraries])
126AC_CHECK_LIBM
127AS_IF([test "x$LIBM" != x], [LIBS="$LIBM $LIBS"])
128# searching for cblas. Priority 1) find a cblas library, 2) find ATLAS
129# generated cblas, and 3) fall back to GSL cblas implementation. If
130# partial ATLAS is detected the configure script fails.
131cblas_found="no"  # cblas_found may get values yes or no
132# atlas_found may get values yes, no, or partial. In some cases
133# partial atlas may be installed
134atlas_found="no"
135gslcblas_found="no" # gslcblas_found may get values yes or no
136AC_SEARCH_LIBS(cblas_sdsdot,cblas,cblas_found="yes",
137  AC_SEARCH_LIBS(ATL_sdsdot,atlas,
138    AC_SEARCH_LIBS(cblas_sdsdot,cblas,atlas_found="yes",
139                   atlas_found="partial",-m64),
140      AC_SEARCH_LIBS(cblas_dswap,gslcblas,gslcblas_found="yes"),-m64),)
141
142YAT_CBLAS_LIB=-lgslcblas
143if test ${cblas_found} = "yes"; then
144  YAT_CBLAS_LIB=-lcblas
145fi
146if test ${atlas_found} = "yes"; then
147  YAT_CXX_ADD_FLAG([CXXFLAGS], [-m64])
148  YAT_LD_ADD_FLAG([LDFLAGS], [-m64])
149  YAT_CBLAS_LIB=-latlas
150fi
151# used in test of gsl
152export GSL_CBLAS_LIB=${YAT_CBLAS_LIB}
153AC_SUBST(YAT_CBLAS_LIB)
154
155
156# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
157# Including AX_PATH_GSL macro from gsl.m4 distributed by GSL
158gsl_version="1.8"
159AC_SUBST(gsl_version)
160# sets variable $yat_gsl_status to one of the following
161#   "ok" - everything is fine
162#   "no" - no gsl found
163#   "no-header" - gsl library found but no header files
164#   "old" - gsl older than $gsl_version found
165YAT_CHECK_GSL([$gsl_version])
166
167# Boost http://www.boost.org
168boost_version=1.33
169AC_SUBST(boost_version)
170AX_BOOST_BASE(["$boost_version"])
171boost_version_check=$succeeded;
172YAT_CPP_ADD_FLAG([CPPFLAGS], [$BOOST_CPPFLAGS])
173
174#support for large files
175AC_SYS_LARGEFILE
176if test "$enable_largefile" = "no"; then
177  AC_DEFINE([YAT_LFS_DISABLED], 1,
178            [defined to 1 if large file support is disabled])
179fi
180
181# we use prefix INTERNAL_ for variables that are solely needed for
182# building yat, i.e., they are not needed for a user of yat and are
183# not propagated to yat-config or yat.m4.
184YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wall -pedantic])
185YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DHAVE_INLINE=1])
186AC_ARG_ENABLE([debug],
187  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
188if test "${enable_debug}" = "yes" ; then
189  YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DYAT_DEBUG=1])
190  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-g -O])
191else
192  YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DGSL_RANGE_CHECK_OFF -DNDEBUG])
193  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-O3])
194fi
195
196AC_ARG_ENABLE([svn-support],
197              [AS_HELP_STRING([--enable-svn-support],
198                              [enable svn support - used by yat maintainer])])
199
200if test "x$enable_svn-support" = "xyes"; then
201  svn_error_msg="svn support cannot be enabled:"
202  AC_CHECK_FILE([$srcdir/.svn], ,
203                AC_MSG_ERROR([$svn_error_msg `$srcdir' is not an svn wc.]))
204  AC_PATH_PROG([PERL], [perl], [no])
205  if test "x$PERL" = "xno"; then
206    AC_MSG_ERROR([$svn_error_msg perl executable not found.])
207  fi
208  AC_PROG_PERL_MODULES([strict Cwd File::Path Getopt::Long Pod::Usage], ,
209         [AC_MSG_ERROR([$svn_error_msg missing some perl module.])])
210fi
211AM_CONDITIONAL([ENABLE_SVN_SUPPORT], [test "x$enable_svn_support" = "xyes"])
212
213
214# check for quiet_NaN support in OS
215# Check at run-time, but if we are cross-compiling fall back on a
216# compilation test
217AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
218AC_RUN_IFELSE(
219  [AC_LANG_PROGRAM(
220    [@%:@include <limits>],
221    [return !std::numeric_limits<double>::has_quiet_NaN])],
222  [quiet_nan=yes
223   AC_MSG_RESULT($quiet_nan)],
224  [quiet_nan=no
225   AC_MSG_RESULT($quiet_nan)],
226  # if we are cross-compiling fall back on compilation test
227  [AC_MSG_RESULT(cross-compiling)
228   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
229    AC_COMPILE_IFELSE(
230     [AC_LANG_PROGRAM(
231        [@%:@include <limits>
232         extern void f(double);],
233        [f(std::numeric_limits<double>::quiet_NaN())])],
234     [quiet_nan=yes],
235     [quiet_nan=no])
236   AC_MSG_RESULT($quiet_nan)])
237# Check for infinity support for doubles in OS
238# Check at run-time, but if we are cross-compiling fall back on a
239# compilation test
240AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
241AC_RUN_IFELSE(
242  [AC_LANG_PROGRAM(
243    [@%:@include <limits>],
244    [return !std::numeric_limits<double>::has_infinity])],
245  [has_infinity=yes
246   AC_MSG_RESULT($has_infinity)],
247  [has_infinity=no
248   AC_MSG_RESULT($has_infinity)],
249  # if we are cross-compiling fall back on compilation test
250  [AC_MSG_RESULT(cross-compiling)
251   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
252    AC_COMPILE_IFELSE(
253     [AC_LANG_PROGRAM(
254        [@%:@include <limits>
255         extern void f(double);],
256        [f(std::numeric_limits<double>::infinity())])],
257     [has_infinity=yes],
258     [has_infinity=no])
259   AC_MSG_RESULT($has_infinity)])
260
261AC_MSG_CHECKING([g++ deprecation attribute])
262AC_COMPILE_IFELSE(
263   [AC_LANG_PROGRAM([[void f() __attribute__ ((deprecated));]],)], 
264   [AC_DEFINE([YAT_HAVE_GCC_DEPRECATED], [1],
265              [Define if compiler supports deprecated attribute, as in g++ 4.0])
266    AC_MSG_RESULT([yes])],
267   [AC_MSG_RESULT([no])] )
268
269AC_MSG_CHECKING([if std::multiset::iterator is mutable])
270AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <set>
271                                     @%:@include <vector>]],
272                                   [[std::set<std::vector<double> > s;
273                                     std::vector<double> v;
274                                     s.insert(v);
275                                     s.begin()->reserve(100);
276                                   ]])],
277                  [AC_DEFINE([MULTISET_ITERATOR_IS_MUTABLE], [1],
278                             [Define if std::multiset::iterator is mutable])
279                   AC_MSG_RESULT([yes])
280                  ],
281                  [AC_MSG_RESULT([no])] )
282
283# yat specific settings
284YAT_LIBNAME="yat"
285YAT_LIB_LOCATION="yat"
286AC_SUBST(YAT_LIBNAME)
287AC_SUBST(YAT_LIB_LOCATION)
288
289#doxygen stuff
290DX_HTML_OUTPUT=html
291DX_LATEX_OUTPUT=latex
292AC_SUBST(DX_HTML_OUTPUT)
293AC_SUBST(DX_LATEX_OUTPUT)
294
295
296AC_CONFIG_FILES([test/create_yathello.sh], [chmod +x test/create_yathello.sh])
297AC_CONFIG_FILES([Makefile
298     build_support/Makefile
299     doc/Makefile
300     doc/doxygen.config
301     doc/first_page.doxygen
302     m4/Makefile
303     test/Makefile
304     test/common_defs.sh
305     test/environment.h
306     test/data/Makefile
307     yat/Makefile
308     yat/classifier/Makefile
309     yat/normalizer/Makefile
310     yat/random/Makefile
311     yat/regression/Makefile
312     yat/statistics/Makefile
313     yat/utility/version.h
314     yat/utility/Makefile])
315
316AC_CONFIG_HEADER([yat/utility/config_public.h])
317
318# warning about missing doxygen
319if (test "$have_dox_tools" != "yes") ; then
320  AC_MSG_WARN([
321  Some pre-requisites for generating documentation were not
322  fulfilled. The build will not create any documentation.
323  Please consult the 'README' file for more information about
324  what is needed to generate documentation and refer to above
325  warning messages.
326  ])
327fi
328
329# Print failure status information about selected items, and exit if
330# fatal errors were encountered. No output will be created if
331# configure is halted prematurely.
332
333# used to trigger exit before creation of output
334all_reqs_ok="true"
335
336# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
337# of created binary, will fail.
338if test "${quiet_nan}" = "no" ; then
339  all_reqs_ok="false"
340  AC_MSG_WARN([
341  Support for quiet NAN required.
342  Yat will not work on this system!])
343fi
344
345# No support for infinity is fatal -- sub-sequent compilation, or execution
346# of created binary, will fail.
347if test "${has_infinity}" = "no" ; then
348  all_reqs_ok="false"
349  AC_MSG_WARN([
350  Support for infinity required.
351  Yat will not work on this system!])
352fi
353
354
355# Non-existing BLAS is fatal -- sub-sequent compilation will fail.
356if test "${cblas_found}" = "no" -a "${atlas_found}" = "no" -a "${gslcblas_found}" = "no"; then
357  all_reqs_ok="false"
358  AC_MSG_WARN([
359  cBLAS not found. The C implementation of Basic Linear Algebra
360  Subprograms (cBLAS) library cannot be found. Please make sure
361  cBLAS is installed.])
362fi
363if test "${atlas_found}" = "partial"; then
364  all_reqs_ok="false"
365  AC_MSG_WARN([
366  Partial ATLAS BLAS library found. Please repair your installation.])
367fi
368
369# Non-existing GSL is fatal -- sub-sequent compilation will fail.
370if test "x$yat_gsl_status" != "xok" ; then
371  all_reqs_ok="false"
372  AS_CASE([$yat_gsl_status],
373          [old],
374          [AC_MSG_WARN([
375  GSL found but not the required version. Please install
376  GSL version ${gsl_version} or later])
377          ],
378          [no-header],
379          [AC_MSG_WARN([
380  GSL header files not found. The GNU Scientific Library (GSL)
381  header files cannot be found. Please make sure GSL header
382  files are installed.])
383          ],
384          [AC_MSG_WARN([
385  GSL not found. The GNU Scientific Library (GSL) library cannot be
386  found. Please make sure GSL is installed.])
387          ])
388fi
389
390# Too old Boost is fatal -- sub-sequent compilation will fail.
391if test "${boost_version_check}" != "yes" ; then
392  all_reqs_ok="false"
393  AC_MSG_WARN([
394  Boost found but not the required version. Please install
395  Boost version ${boost_version} or later])
396fi
397
398if (test "$all_reqs_ok" = "false") ; then
399  AC_MSG_FAILURE([
400  Some pre-requisites were not fulfilled, aborting configure.
401  Please consult the 'README' file for more information about what
402  is needed to compile yat and refer to above warning messages.
403  Needed files were NOT created.])
404fi
405
406# Reset flags
407APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, YAT_)
408APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, YAT_)
409APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, YAT_)
410APR_RESTORE_THE_ENVIRONMENT(LIBS, YAT_)
411
412# set and AC_SUBST variables that are interpreted by Automake
413AM_CPPFLAGS="-I\$(top_srcdir) $INTERNAL_CPPFLAGS $YAT_CPPFLAGS"
414AM_CXXFLAGS="$INTERNAL_CXXFLAGS $YAT_CXXFLAGS"
415AM_LDFLAGS="$INTERNAL_LDFLAGS $YAT_LDFLAGS"
416
417AC_SUBST(AM_CPPFLAGS)
418AC_SUBST(AM_CXXFLAGS)
419AC_SUBST(AM_LDFLAGS)
420
421
422YAT_LIBS_WITHOUT_CBLAS=$YAT_LIBS
423APR_REMOVEFROM([YAT_LIBS_WITHOUT_CBLAS], [$YAT_CBLAS_LIB])
424AC_SUBST(YAT_LIBS_WITHOUT_CBLAS)
425
426# Create output.
427AC_OUTPUT
428
429# Some more messages.
430AC_MSG_NOTICE([])
431AC_MSG_NOTICE([ Ready to compile the yat library])
432AC_MSG_NOTICE([ The following flags and libraries will be used:])
433AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
434AC_MSG_NOTICE([  CPPFLAGS=$CPPFLAGS])
435AC_MSG_NOTICE([  AM_CPPFLAGS=$AM_CPPFLAGS])
436AC_MSG_NOTICE([  CXXFLAGS=$CXXFLAGS])
437AC_MSG_NOTICE([  AM_CXXFLAGS=$AM_CXXFLAGS])
438AC_MSG_NOTICE([  LDFLAGS=$LDFLAGS])
439AC_MSG_NOTICE([  AM_LDFLAGS=$AM_LDFLAGS])
440AC_MSG_NOTICE([  LIBS=$LIBS])
441AC_MSG_NOTICE([  YAT_LIBS=$YAT_LIBS])
442AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
443AC_MSG_NOTICE([])
444if test "${gslcblas_found}" = "yes"; then
445AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
446AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
447AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
448AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
449AC_MSG_NOTICE([])
450fi
451AC_MSG_NOTICE([ Now type 'make && make check'.])
Note: See TracBrowser for help on using the repository browser.