source: trunk/configure.ac @ 1662

Last change on this file since 1662 was 1662, checked in by Peter, 13 years ago

fixing #468: propagate selected configure options to DISTCHECK_CONFIGURE_FLAGS

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.0 KB
RevLine 
[71]1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1662 2008-12-18 16:31:29Z peter $
[2]4
[831]5# Copyright (C) 2003 Daniel Dalevi, Jari Häkkinen
6# Copyright (C) 2004 Jari Häkkinen
[1275]7# Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson
8# Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
[572]9#
[1437]10# This file is part of the yat library, http://dev.thep.lu.se/yat
[572]11#
[675]12# The yat library is free software; you can redistribute it
[572]13# and/or modify it under the terms of the GNU General Public License as
[1486]14# published by the Free Software Foundation; either version 3 of the
[572]15# License, or (at your option) any later version.
16#
[675]17# The yat library is distributed in the hope that it will be useful,
[572]18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20# General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
[1487]23# along with yat. If not, see <http://www.gnu.org/licenses/>.
[572]24#
[923]25# If you grabbed the source from the subversion repository you should,
26# at top-level, execute:
27#     ./bootstrap
[954]28# To push subsequent changes of this file into the build scripts you
29# must issue:
30#     autoreconf
[572]31
[1636]32m4_include([build_support/version.m4])
[1321]33AC_INIT([yat],[YAT_VERSION],[jari@thep.lu.se])
[976]34AC_PREREQ(2.60)
[1128]35AC_CONFIG_SRCDIR([yat/utility/Matrix.h])
[71]36AC_CONFIG_AUX_DIR([autotools])
[1439]37dnl arg below should be the same as in Makefile.am
38AC_CONFIG_MACRO_DIR([build_support])
[71]39AC_PREFIX_DEFAULT([/usr/local])
[2]40
[1606]41AC_SUBST([YAT_LT_VERSION], [YAT_LT_VERSION_INFO])
[1321]42AC_SUBST([YAT_MAJOR_VERSION], [MAJOR_VERSION])
43AC_SUBST([YAT_MINOR_VERSION], [MINOR_VERSION])
44AC_SUBST([YAT_PATCH_VERSION], [PATCH_VERSION])
45AC_SUBST([YAT_DEV_BUILD], [DEV_BUILD])
[1097]46
[1225]47AC_CONFIG_HEADER([config.h])
[1637]48AM_INIT_AUTOMAKE([1.10 std-options])
[2]49
[952]50# Set default programming language
51AC_LANG(C++)
52
[1662]53# propagate selected configure variables to DISTCHECK_CONFIGURE_FLAGS
54for var in CPPFLAGS CXX CXXFLAGS CXXCPP LDFLAGS LIBS; do
55  eval isset=\${$var+set}
56  if test "$isset" = 'set' ; then
57    eval val=$`echo $var`
58    DISTCHECK_CONFIGURE_FLAGS="${DISTCHECK_CONFIGURE_FLAGS}'${var}=${val}' "
59  fi
60done
61AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
62
[1213]63# Let user overide default CXXFLAGS
64if test "${CXXFLAGS+set}" != set; then
65  CXXFLAGS=""  # Setting CXXFLAGS here to prevent expansion in AC_PROG_CXX
66fi
[2]67# Checks for programs.
68AC_PROG_CXX
69AC_PROG_INSTALL
[1077]70AC_PROG_SED
[2]71
[1440]72AC_MSG_NOTICE(dnl
73[checking whether tools for generating documentation are available])
74
[1397]75have_dox_tools="yes"
76AC_PATH_PROG([DOXYGEN], [doxygen], [no])
77if test "$DOXYGEN" = "no"; then
78   AC_MSG_WARN([unable to find doxygen application])
79   have_dox_tools=no
[1440]80else
81   doxygen_min_version=1.5
82   AC_MSG_CHECKING([if doxygen is at least $doxygen_min_version])
83   doxygen_version=`$DOXYGEN --version`
84   AX_COMPARE_VERSION([$doxygen_version], [ge], [$doxygen_min_version], ,
85                      [have_dox_tools=no])
86   AC_MSG_RESULT([$doxygen_version])
[1397]87fi
88AC_CHECK_PROG([have_epstopdf], [epstopdf], [yes], [no])
89if test "$have_epstopdf" != "yes"; then
90   AC_MSG_WARN([unable to find epstopdf application])
91   have_dox_tools=no
92fi
93AC_CHECK_PROG([have_latex], [latex], [yes], [no])
94if test "$have_latex" != "yes"; then
95   AC_MSG_WARN([unable to find latex application])
96fi
97AC_CHECK_PROG([have_makeindex], [makeindex], [yes], [no])
98if test "$have_makeindex" != "yes"; then
99   AC_MSG_WARN([unable to find makeindex application])
100   have_dox_tools=no
101fi
102AC_CHECK_PROG([have_pdflatex], [pdflatex], [yes], [no])
103if test "$have_pdflatex" != "yes"; then
104   AC_MSG_WARN([unable to find pdflatex application])
105   have_dox_tools=no
106fi
107
[1542]108AC_SUBST(have_dox_tools)
[1397]109AM_CONDITIONAL(HAVE_DOXYGEN, test "$have_dox_tools" = "yes")
[1367]110AC_CONFIG_FILES([test/documentation_test.sh],
111                [chmod +x test/documentation_test.sh])
[1209]112
[1348]113# Save user-defined environment settings for later restoration
114APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
115APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
116APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
117
[71]118# Checks for libraries.
[1444]119AC_MSG_NOTICE([checking for libraries])
[941]120AC_CHECK_LIB(m,main)
[969]121# searching for cblas. Priority 1) find a cblas library, 2) find ATLAS
122# generated cblas, and 3) fall back to GSL cblas implementation. If
123# partial ATLAS is detected the configure script fails.
[1060]124cblas_found="no"  # cblas_found may get values yes or no
125# atlas_found may get values yes, no, or partial. In some cases
126# partial atlas may be installed
127atlas_found="no"
128gslcblas_found="no" # gslcblas_found may get values yes or no
129AC_SEARCH_LIBS(cblas_sdsdot,cblas,cblas_found="yes",
130  AC_SEARCH_LIBS(ATL_sdsdot,atlas,
131    AC_SEARCH_LIBS(cblas_sdsdot,cblas,atlas_found="yes",
132                   atlas_found="partial",-m64),
133      AC_SEARCH_LIBS(cblas_dswap,gslcblas,gslcblas_found="yes"),-m64),)
[1349]134# CBLAS used in test of GSL
135gsl_cblas_lib=-lgslcblas
136if test ${cblas_found} = "yes"; then
137  gsl_cblas_lib=-lcblas
138fi
[1060]139if test ${atlas_found} = "yes"; then
[1503]140  YAT_CXX_ADD_FLAG([CXXFLAGS], [-m64])
141  YAT_LD_ADD_FLAG([LDFLAGS], [-m64])
[1349]142  gsl_cblas_lib=-latlas
[1060]143fi
[1349]144export GSL_CBLAS_LIB=${gsl_cblas_lib}
[2]145
[951]146# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
[1327]147# Including AX_PATH_GSL macro from gsl.m4 distributed by GSL
[1060]148gsl_found="no"
[1287]149gsl_version="1.8"
[1356]150AC_SUBST(gsl_version)
[1223]151AX_PATH_GSL(${gsl_version},gsl_found="yes",gsl_version_check="no")
[1060]152if test "$gsl_found" = "yes"; then
[1212]153   LIBS="-lgsl $LIBS"
[1348]154   # grep words starting with '-L' in other words LDFLAGS
155   for i in $GSL_LIBS; do
156     if test ${i:0:2} = "-L"; then
[1503]157       YAT_LD_ADD_FLAG([LDFLAGS], [$i])
[1348]158     fi
159   done
[1060]160fi
[942]161
[1324]162# Boost http://www.boost.org
[1356]163boost_version=1.33
164AC_SUBST(boost_version)
[1391]165AX_BOOST_BASE("$boost_version")
[1394]166boost_version_check=$succeeded;
[1503]167YAT_CPP_ADD_FLAG([CPPFLAGS], [$BOOST_CPPFLAGS])
[1324]168
[71]169# Checks for library functions.
[296]170AC_PROG_LIBTOOL
[71]171
[1455]172#support for large files
173AC_SYS_LARGEFILE
[1457]174if test "$enable_largefile" = "no"; then
175  AC_DEFINE([YAT_LFS_DISABLED], 1,
176            [defined to 1 if large file support is disabled])
177fi
[1455]178
[1479]179# we use AM_* for variables that are solely needed for building yat,
180# i.e., they are not needed for a user of yat and are not propagated
181# to yat-config or yat.m4.
[1503]182YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-Wall])
183YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-pedantic])
184YAT_CPP_ADD_FLAG([CPPFLAGS], [-DHAVE_INLINE=1])
[1558]185AC_ARG_ENABLE([debug],
[694]186  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
187if test "${enable_debug}" = "yes" ; then
[1503]188  YAT_CPP_ADD_FLAG([AM_CPPFLAGS], [-DYAT_DEBUG=1])
189  YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-g])
190  YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-O])
[694]191else
[1503]192  YAT_CPP_ADD_FLAG([CPPFLAGS], [-DGSL_RANGE_CHECK_OFF])
193  YAT_CPP_ADD_FLAG([AM_CPPFLAGS], [-DNDEBUG])
194  YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-O3])
[694]195fi
[2]196
[1558]197# enable target svn-clean
198AC_ARG_ENABLE([svn-support],
199   [AS_HELP_STRING([--enable-svn-support],
[1635]200                   [enable svn support - used by yat maintainer])],
[1558]201   [enable_svn_support=yes])
202if test "x$enable_svn_support" = "xyes"; then
[1657]203  AC_CHECK_FILE([$srcdir/.svn], ,
204                AC_MSG_ERROR([$svn_error_msg `$srcdir' is not an svn wc.]))
[1558]205  AC_PATH_PROG([PERL], [perl], [no])
206  if test "x$PERL" = "xno"; then
207    AC_MSG_ERROR([$svn_error_msg perl executable not found.])
208  fi
209  AC_PROG_PERL_MODULES([strict], ,
210         [AC_MSG_ERROR([$svn_error_msg missing some perl module.])])
211  AC_PROG_PERL_MODULES([Cwd], ,
212         [AC_MSG_ERROR([$svn_error_msg missing some perl module.])])
213  AC_PROG_PERL_MODULES([File::Path], ,
214         [AC_MSG_ERROR([$svn_error_msg missing some perl module.])])
215  AC_PROG_PERL_MODULES([Getopt::Long], ,
216         [AC_MSG_ERROR([$svn_error_msg missing some perl module.])])
217  AC_PROG_PERL_MODULES([Pod::Usage], ,
218         [AC_MSG_ERROR([$svn_error_msg missing some perl module.])])
219
220fi
221AM_CONDITIONAL([ENABLE_SVN_SUPPORT], [test "x$enable_svn_support" = "xyes"])
222
223
[922]224# check for quiet_NaN support in OS
[1358]225# Check at run-time, but if we are cross-compiling fall back on a
226# compilation test
[924]227AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
228AC_RUN_IFELSE(
229  [AC_LANG_PROGRAM(
[1359]230    [@%:@include <limits>],
[924]231    [return !std::numeric_limits<double>::has_quiet_NaN])],
[1358]232  [quiet_nan=yes
233   AC_MSG_RESULT($quiet_nan)],
234  [quiet_nan=no
235   AC_MSG_RESULT($quiet_nan)],
236  # if we are cross-compiling fall back on compilation test
237  [AC_MSG_RESULT(cross-compiling)
238   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
239    AC_COMPILE_IFELSE(
240     [AC_LANG_PROGRAM(
[1359]241        [@%:@include <limits>
[1358]242         extern void f(double);],
243        [f(std::numeric_limits<double>::quiet_NaN())])],
244     [quiet_nan=yes],
245     [quiet_nan=no])
246   AC_MSG_RESULT($quiet_nan)])
[1156]247# Check for infinity support for doubles in OS
[1358]248# Check at run-time, but if we are cross-compiling fall back on a
249# compilation test
[1156]250AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
251AC_RUN_IFELSE(
252  [AC_LANG_PROGRAM(
[1359]253    [@%:@include <limits>],
[1156]254    [return !std::numeric_limits<double>::has_infinity])],
[1358]255  [has_infinity=yes
256   AC_MSG_RESULT($has_infinity)],
257  [has_infinity=no
258   AC_MSG_RESULT($has_infinity)],
259  # if we are cross-compiling fall back on compilation test
260  [AC_MSG_RESULT(cross-compiling)
261   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
262    AC_COMPILE_IFELSE(
263     [AC_LANG_PROGRAM(
[1359]264        [@%:@include <limits>
[1358]265         extern void f(double);],
266        [f(std::numeric_limits<double>::infinity())])],
267     [has_infinity=yes],
268     [has_infinity=no])
269   AC_MSG_RESULT($has_infinity)])
[922]270
[1500]271AC_MSG_CHECKING([g++ deprecation attribute])
272AC_TRY_COMPILE([void f() __attribute__ ((deprecated));], [],
273               AC_DEFINE([YAT_HAVE_GCC_DEPRECATED], [1],
274          [Define if compiler supports deprecated attribute, as in g++ 4.0])
275               AC_MSG_RESULT([yes]),
276               AC_MSG_RESULT([no]) )
[1156]277
[1500]278
[675]279# yat specific settings
[1348]280YAT_LIBNAME="yat"
[675]281YAT_LIB_LOCATION="yat"
[1348]282AC_SUBST(YAT_LIBNAME)
[675]283AC_SUBST(YAT_LIB)
284AC_SUBST(YAT_LIB_LOCATION)
[2]285
[1265]286#doxygen stuff
287DX_HTML_OUTPUT=html
288DX_LATEX_OUTPUT=latex
289AC_SUBST(DX_HTML_OUTPUT)
290AC_SUBST(DX_LATEX_OUTPUT)
[1216]291
292
[945]293AC_CONFIG_FILES([Makefile
[1504]294     build_support/Makefile
[945]295     doc/Makefile
[1225]296     doc/doxygen.config
[1438]297     doc/first_page.doxygen
[945]298     test/Makefile
[1249]299     test/environment.h
[945]300     test/data/Makefile
301     yat/Makefile
302     yat/classifier/Makefile
[1497]303     yat/normalizer/Makefile
[945]304     yat/random/Makefile
305     yat/regression/Makefile
306     yat/statistics/Makefile
[1321]307     yat/utility/version.h
[945]308     yat/utility/Makefile])
309
[1500]310AC_CONFIG_HEADER([yat/utility/config_public.h])
311
[1303]312# warning about missing doxygen
[1398]313if (test "$have_dox_tools" != "yes") ; then
[1060]314  AC_MSG_WARN([
[1397]315  Some pre-requisites for generating documentation were not
316  fulfilled. The build will not create any documentation.
317  Please consult the 'README' file for more information about
318  what is needed to generate documentation and refer to above
319  warning messages.
[1060]320  ])
[944]321fi
322
[1060]323# Print failure status information about selected items, and exit if
324# fatal errors were encountered. No output will be created if
325# configure is halted prematurely.
326
327# used to trigger exit before creation of output
328all_reqs_ok="true"
329
330# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
331# of created binary, will fail.
332if test "${quiet_nan}" = "no" ; then
333  all_reqs_ok="false"
334  AC_MSG_WARN([
335  Support for quiet NAN required.
336  Yat will not work on this system!])
337fi
338
[1156]339# No support for infinity is fatal -- sub-sequent compilation, or execution
340# of created binary, will fail.
341if test "${has_infinity}" = "no" ; then
342  all_reqs_ok="false"
343  AC_MSG_WARN([
344  Support for infinity required.
345  Yat will not work on this system!])
346fi
347
348
[1060]349# Non-existing BLAS is fatal -- sub-sequent compilation will fail.
350if test "${cblas_found}" = "no" -a "${atlas_found}" = "no" -a "${gslcblas_found}" = "no"; then
351  all_reqs_ok="false"
352  AC_MSG_WARN([
353  cBLAS not found. The C implementation of Basic Linear Algebra
354  Subprograms (cBLAS) library cannot be found. Please make sure
355  cBLAS is installed.])
356fi
357if test "${atlas_found}" = "partial"; then
358  all_reqs_ok="false"
359  AC_MSG_WARN([
360  Partial ATLAS BLAS library found. Please repair your installation.])
361fi
362
363# Non-existing GSL is fatal -- sub-sequent compilation will fail.
364if test "${gsl_found}" = "no" ; then
365  all_reqs_ok="false"
366  if test "${gsl_version_check}" = "no" ; then
367  AC_MSG_WARN([
368  GSL found but not the required version. Please install
369  GSL version ${gsl_version} or later])
370  else
371  AC_MSG_WARN([
372  GSL not found. The GNU Scientific Library (GSL) library cannot be
373  found. Please make sure GSL is installed.])
374  fi
375fi
376
[1394]377# Too old Boost is fatal -- sub-sequent compilation will fail.
378if test "${boost_version_check}" != "yes" ; then
379  all_reqs_ok="false"
380  AC_MSG_WARN([
381  Boost found but not the required version. Please install
382  Boost version ${boost_version} or later])
383fi
384
[1060]385if (test "$all_reqs_ok" = "false") ; then
386  AC_MSG_FAILURE([
387  Some pre-requisites were not fulfilled, aborting configure.
388  Please consult the 'README' file for more information about what
389  is needed to compile yat and refer to above warning messages.
390  Needed files were NOT created.])
391fi
392
[1348]393# Reset flags
394APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
395APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, EXTRA_)
396APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
397
[1479]398AM_CPPFLAGS="-I\$(top_srcdir) $AM_CPPFLAGS $EXTRA_CPPFLAGS"
399AM_CXXFLAGS="$AM_CXXFLAGS $EXTRA_CXXFLAGS"
400AM_LDFLAGS="$AM_LDFLAGS $EXTRA_LDFLAGS"
401
402AC_SUBST(AM_CPPFLAGS)
403AC_SUBST(AM_CXXFLAGS)
404AC_SUBST(AM_LDFLAGS)
405
[1060]406# Create output.
407AC_OUTPUT
408
[694]409# Some more messages.
410AC_MSG_NOTICE([])
411AC_MSG_NOTICE([ Ready to compile the yat library])
[943]412AC_MSG_NOTICE([ The following flags and libraries will be used:])
[694]413AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
414AC_MSG_NOTICE([  CPPFLAGS=\"$CPPFLAGS\"])
[1479]415AC_MSG_NOTICE([  AM_CPPFLAGS=\"$AM_CPPFLAGS\"])
[694]416AC_MSG_NOTICE([  CXXFLAGS=\"$CXXFLAGS\"])
[1479]417AC_MSG_NOTICE([  AM_CXXFLAGS=\"$AM_CXXFLAGS\"])
[1348]418AC_MSG_NOTICE([  LDFLAGS=\"$LDFLAGS\"])
[1479]419AC_MSG_NOTICE([  AM_LDFLAGS=\"$AM_LDFLAGS\"])
[694]420AC_MSG_NOTICE([  LIBS=\"$LIBS\"])
421AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
422AC_MSG_NOTICE([])
[1060]423if test "${gslcblas_found}" = "yes"; 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
[694]430AC_MSG_NOTICE([ Now type 'make ; make check'.])
Note: See TracBrowser for help on using the repository browser.