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
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1662 2008-12-18 16:31:29Z 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#
10# This file is part of the yat library, http://dev.thep.lu.se/yat
11#
12# The yat library is free software; you can redistribute it
13# and/or modify it under the terms of the GNU General Public License as
14# published by the Free Software Foundation; either version 3 of the
15# License, or (at your option) any later version.
16#
17# The yat library is distributed in the hope that it will be useful,
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
23# along with yat. If not, see <http://www.gnu.org/licenses/>.
24#
25# If you grabbed the source from the subversion repository you should,
26# at top-level, execute:
27#     ./bootstrap
28# To push subsequent changes of this file into the build scripts you
29# must issue:
30#     autoreconf
31
32m4_include([build_support/version.m4])
33AC_INIT([yat],[YAT_VERSION],[jari@thep.lu.se])
34AC_PREREQ(2.60)
35AC_CONFIG_SRCDIR([yat/utility/Matrix.h])
36AC_CONFIG_AUX_DIR([autotools])
37dnl arg below should be the same as in Makefile.am
38AC_CONFIG_MACRO_DIR([build_support])
39AC_PREFIX_DEFAULT([/usr/local])
40
41AC_SUBST([YAT_LT_VERSION], [YAT_LT_VERSION_INFO])
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])
46
47AC_CONFIG_HEADER([config.h])
48AM_INIT_AUTOMAKE([1.10 std-options])
49
50# Set default programming language
51AC_LANG(C++)
52
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
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
67# Checks for programs.
68AC_PROG_CXX
69AC_PROG_INSTALL
70AC_PROG_SED
71
72AC_MSG_NOTICE(dnl
73[checking whether tools for generating documentation are available])
74
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
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])
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
108AC_SUBST(have_dox_tools)
109AM_CONDITIONAL(HAVE_DOXYGEN, test "$have_dox_tools" = "yes")
110AC_CONFIG_FILES([test/documentation_test.sh],
111                [chmod +x test/documentation_test.sh])
112
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
118# Checks for libraries.
119AC_MSG_NOTICE([checking for libraries])
120AC_CHECK_LIB(m,main)
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.
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),)
134# CBLAS used in test of GSL
135gsl_cblas_lib=-lgslcblas
136if test ${cblas_found} = "yes"; then
137  gsl_cblas_lib=-lcblas
138fi
139if test ${atlas_found} = "yes"; then
140  YAT_CXX_ADD_FLAG([CXXFLAGS], [-m64])
141  YAT_LD_ADD_FLAG([LDFLAGS], [-m64])
142  gsl_cblas_lib=-latlas
143fi
144export GSL_CBLAS_LIB=${gsl_cblas_lib}
145
146# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
147# Including AX_PATH_GSL macro from gsl.m4 distributed by GSL
148gsl_found="no"
149gsl_version="1.8"
150AC_SUBST(gsl_version)
151AX_PATH_GSL(${gsl_version},gsl_found="yes",gsl_version_check="no")
152if test "$gsl_found" = "yes"; then
153   LIBS="-lgsl $LIBS"
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
157       YAT_LD_ADD_FLAG([LDFLAGS], [$i])
158     fi
159   done
160fi
161
162# Boost http://www.boost.org
163boost_version=1.33
164AC_SUBST(boost_version)
165AX_BOOST_BASE("$boost_version")
166boost_version_check=$succeeded;
167YAT_CPP_ADD_FLAG([CPPFLAGS], [$BOOST_CPPFLAGS])
168
169# Checks for library functions.
170AC_PROG_LIBTOOL
171
172#support for large files
173AC_SYS_LARGEFILE
174if test "$enable_largefile" = "no"; then
175  AC_DEFINE([YAT_LFS_DISABLED], 1,
176            [defined to 1 if large file support is disabled])
177fi
178
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.
182YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-Wall])
183YAT_CXX_ADD_FLAG([AM_CXXFLAGS], [-pedantic])
184YAT_CPP_ADD_FLAG([CPPFLAGS], [-DHAVE_INLINE=1])
185AC_ARG_ENABLE([debug],
186  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
187if test "${enable_debug}" = "yes" ; then
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])
191else
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])
195fi
196
197# enable target svn-clean
198AC_ARG_ENABLE([svn-support],
199   [AS_HELP_STRING([--enable-svn-support],
200                   [enable svn support - used by yat maintainer])],
201   [enable_svn_support=yes])
202if test "x$enable_svn_support" = "xyes"; then
203  AC_CHECK_FILE([$srcdir/.svn], ,
204                AC_MSG_ERROR([$svn_error_msg `$srcdir' is not an svn wc.]))
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
224# check for quiet_NaN support in OS
225# Check at run-time, but if we are cross-compiling fall back on a
226# compilation test
227AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
228AC_RUN_IFELSE(
229  [AC_LANG_PROGRAM(
230    [@%:@include <limits>],
231    [return !std::numeric_limits<double>::has_quiet_NaN])],
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(
241        [@%:@include <limits>
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)])
247# Check for infinity support for doubles in OS
248# Check at run-time, but if we are cross-compiling fall back on a
249# compilation test
250AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
251AC_RUN_IFELSE(
252  [AC_LANG_PROGRAM(
253    [@%:@include <limits>],
254    [return !std::numeric_limits<double>::has_infinity])],
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(
264        [@%:@include <limits>
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)])
270
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]) )
277
278
279# yat specific settings
280YAT_LIBNAME="yat"
281YAT_LIB_LOCATION="yat"
282AC_SUBST(YAT_LIBNAME)
283AC_SUBST(YAT_LIB)
284AC_SUBST(YAT_LIB_LOCATION)
285
286#doxygen stuff
287DX_HTML_OUTPUT=html
288DX_LATEX_OUTPUT=latex
289AC_SUBST(DX_HTML_OUTPUT)
290AC_SUBST(DX_LATEX_OUTPUT)
291
292
293AC_CONFIG_FILES([Makefile
294     build_support/Makefile
295     doc/Makefile
296     doc/doxygen.config
297     doc/first_page.doxygen
298     test/Makefile
299     test/environment.h
300     test/data/Makefile
301     yat/Makefile
302     yat/classifier/Makefile
303     yat/normalizer/Makefile
304     yat/random/Makefile
305     yat/regression/Makefile
306     yat/statistics/Makefile
307     yat/utility/version.h
308     yat/utility/Makefile])
309
310AC_CONFIG_HEADER([yat/utility/config_public.h])
311
312# warning about missing doxygen
313if (test "$have_dox_tools" != "yes") ; then
314  AC_MSG_WARN([
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.
320  ])
321fi
322
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
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
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
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
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
393# Reset flags
394APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
395APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, EXTRA_)
396APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
397
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
406# Create output.
407AC_OUTPUT
408
409# Some more messages.
410AC_MSG_NOTICE([])
411AC_MSG_NOTICE([ Ready to compile the yat library])
412AC_MSG_NOTICE([ The following flags and libraries will be used:])
413AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
414AC_MSG_NOTICE([  CPPFLAGS=\"$CPPFLAGS\"])
415AC_MSG_NOTICE([  AM_CPPFLAGS=\"$AM_CPPFLAGS\"])
416AC_MSG_NOTICE([  CXXFLAGS=\"$CXXFLAGS\"])
417AC_MSG_NOTICE([  AM_CXXFLAGS=\"$AM_CXXFLAGS\"])
418AC_MSG_NOTICE([  LDFLAGS=\"$LDFLAGS\"])
419AC_MSG_NOTICE([  AM_LDFLAGS=\"$AM_LDFLAGS\"])
420AC_MSG_NOTICE([  LIBS=\"$LIBS\"])
421AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
422AC_MSG_NOTICE([])
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
430AC_MSG_NOTICE([ Now type 'make ; make check'.])
Note: See TracBrowser for help on using the repository browser.