source: trunk/configure.ac @ 1684

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

simplify syntax of perl modules checks

  • 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 1684 2008-12-30 20:30:31Z 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  svn_error_msg="svn support cannot be enabled:"
204  AC_CHECK_FILE([$srcdir/.svn], ,
205                AC_MSG_ERROR([$svn_error_msg `$srcdir' is not an svn wc.]))
206  AC_PATH_PROG([PERL], [perl], [no])
207  if test "x$PERL" = "xno"; then
208    AC_MSG_ERROR([$svn_error_msg perl executable not found.])
209  fi
210  AC_PROG_PERL_MODULES([strict Cwd File::Path Getopt::Long Pod::Usage], ,
211         [AC_MSG_ERROR([$svn_error_msg missing some perl module.])])
212fi
213AM_CONDITIONAL([ENABLE_SVN_SUPPORT], [test "x$enable_svn_support" = "xyes"])
214
215
216# check for quiet_NaN support in OS
217# Check at run-time, but if we are cross-compiling fall back on a
218# compilation test
219AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
220AC_RUN_IFELSE(
221  [AC_LANG_PROGRAM(
222    [@%:@include <limits>],
223    [return !std::numeric_limits<double>::has_quiet_NaN])],
224  [quiet_nan=yes
225   AC_MSG_RESULT($quiet_nan)],
226  [quiet_nan=no
227   AC_MSG_RESULT($quiet_nan)],
228  # if we are cross-compiling fall back on compilation test
229  [AC_MSG_RESULT(cross-compiling)
230   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
231    AC_COMPILE_IFELSE(
232     [AC_LANG_PROGRAM(
233        [@%:@include <limits>
234         extern void f(double);],
235        [f(std::numeric_limits<double>::quiet_NaN())])],
236     [quiet_nan=yes],
237     [quiet_nan=no])
238   AC_MSG_RESULT($quiet_nan)])
239# Check for infinity support for doubles in OS
240# Check at run-time, but if we are cross-compiling fall back on a
241# compilation test
242AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
243AC_RUN_IFELSE(
244  [AC_LANG_PROGRAM(
245    [@%:@include <limits>],
246    [return !std::numeric_limits<double>::has_infinity])],
247  [has_infinity=yes
248   AC_MSG_RESULT($has_infinity)],
249  [has_infinity=no
250   AC_MSG_RESULT($has_infinity)],
251  # if we are cross-compiling fall back on compilation test
252  [AC_MSG_RESULT(cross-compiling)
253   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
254    AC_COMPILE_IFELSE(
255     [AC_LANG_PROGRAM(
256        [@%:@include <limits>
257         extern void f(double);],
258        [f(std::numeric_limits<double>::infinity())])],
259     [has_infinity=yes],
260     [has_infinity=no])
261   AC_MSG_RESULT($has_infinity)])
262
263AC_MSG_CHECKING([g++ deprecation attribute])
264AC_TRY_COMPILE([void f() __attribute__ ((deprecated));], [],
265               AC_DEFINE([YAT_HAVE_GCC_DEPRECATED], [1],
266          [Define if compiler supports deprecated attribute, as in g++ 4.0])
267               AC_MSG_RESULT([yes]),
268               AC_MSG_RESULT([no]) )
269
270
271# yat specific settings
272YAT_LIBNAME="yat"
273YAT_LIB_LOCATION="yat"
274AC_SUBST(YAT_LIBNAME)
275AC_SUBST(YAT_LIB)
276AC_SUBST(YAT_LIB_LOCATION)
277
278#doxygen stuff
279DX_HTML_OUTPUT=html
280DX_LATEX_OUTPUT=latex
281AC_SUBST(DX_HTML_OUTPUT)
282AC_SUBST(DX_LATEX_OUTPUT)
283
284
285AC_CONFIG_FILES([Makefile
286     build_support/Makefile
287     doc/Makefile
288     doc/doxygen.config
289     doc/first_page.doxygen
290     test/Makefile
291     test/environment.h
292     test/data/Makefile
293     yat/Makefile
294     yat/classifier/Makefile
295     yat/normalizer/Makefile
296     yat/random/Makefile
297     yat/regression/Makefile
298     yat/statistics/Makefile
299     yat/utility/version.h
300     yat/utility/Makefile])
301
302AC_CONFIG_HEADER([yat/utility/config_public.h])
303
304# warning about missing doxygen
305if (test "$have_dox_tools" != "yes") ; then
306  AC_MSG_WARN([
307  Some pre-requisites for generating documentation were not
308  fulfilled. The build will not create any documentation.
309  Please consult the 'README' file for more information about
310  what is needed to generate documentation and refer to above
311  warning messages.
312  ])
313fi
314
315# Print failure status information about selected items, and exit if
316# fatal errors were encountered. No output will be created if
317# configure is halted prematurely.
318
319# used to trigger exit before creation of output
320all_reqs_ok="true"
321
322# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
323# of created binary, will fail.
324if test "${quiet_nan}" = "no" ; then
325  all_reqs_ok="false"
326  AC_MSG_WARN([
327  Support for quiet NAN required.
328  Yat will not work on this system!])
329fi
330
331# No support for infinity is fatal -- sub-sequent compilation, or execution
332# of created binary, will fail.
333if test "${has_infinity}" = "no" ; then
334  all_reqs_ok="false"
335  AC_MSG_WARN([
336  Support for infinity required.
337  Yat will not work on this system!])
338fi
339
340
341# Non-existing BLAS is fatal -- sub-sequent compilation will fail.
342if test "${cblas_found}" = "no" -a "${atlas_found}" = "no" -a "${gslcblas_found}" = "no"; then
343  all_reqs_ok="false"
344  AC_MSG_WARN([
345  cBLAS not found. The C implementation of Basic Linear Algebra
346  Subprograms (cBLAS) library cannot be found. Please make sure
347  cBLAS is installed.])
348fi
349if test "${atlas_found}" = "partial"; then
350  all_reqs_ok="false"
351  AC_MSG_WARN([
352  Partial ATLAS BLAS library found. Please repair your installation.])
353fi
354
355# Non-existing GSL is fatal -- sub-sequent compilation will fail.
356if test "${gsl_found}" = "no" ; then
357  all_reqs_ok="false"
358  if test "${gsl_version_check}" = "no" ; then
359  AC_MSG_WARN([
360  GSL found but not the required version. Please install
361  GSL version ${gsl_version} or later])
362  else
363  AC_MSG_WARN([
364  GSL not found. The GNU Scientific Library (GSL) library cannot be
365  found. Please make sure GSL is installed.])
366  fi
367fi
368
369# Too old Boost is fatal -- sub-sequent compilation will fail.
370if test "${boost_version_check}" != "yes" ; then
371  all_reqs_ok="false"
372  AC_MSG_WARN([
373  Boost found but not the required version. Please install
374  Boost version ${boost_version} or later])
375fi
376
377if (test "$all_reqs_ok" = "false") ; then
378  AC_MSG_FAILURE([
379  Some pre-requisites were not fulfilled, aborting configure.
380  Please consult the 'README' file for more information about what
381  is needed to compile yat and refer to above warning messages.
382  Needed files were NOT created.])
383fi
384
385# Reset flags
386APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
387APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, EXTRA_)
388APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
389
390AM_CPPFLAGS="-I\$(top_srcdir) $AM_CPPFLAGS $EXTRA_CPPFLAGS"
391AM_CXXFLAGS="$AM_CXXFLAGS $EXTRA_CXXFLAGS"
392AM_LDFLAGS="$AM_LDFLAGS $EXTRA_LDFLAGS"
393
394AC_SUBST(AM_CPPFLAGS)
395AC_SUBST(AM_CXXFLAGS)
396AC_SUBST(AM_LDFLAGS)
397
398# Create output.
399AC_OUTPUT
400
401# Some more messages.
402AC_MSG_NOTICE([])
403AC_MSG_NOTICE([ Ready to compile the yat library])
404AC_MSG_NOTICE([ The following flags and libraries will be used:])
405AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
406AC_MSG_NOTICE([  CPPFLAGS=\"$CPPFLAGS\"])
407AC_MSG_NOTICE([  AM_CPPFLAGS=\"$AM_CPPFLAGS\"])
408AC_MSG_NOTICE([  CXXFLAGS=\"$CXXFLAGS\"])
409AC_MSG_NOTICE([  AM_CXXFLAGS=\"$AM_CXXFLAGS\"])
410AC_MSG_NOTICE([  LDFLAGS=\"$LDFLAGS\"])
411AC_MSG_NOTICE([  AM_LDFLAGS=\"$AM_LDFLAGS\"])
412AC_MSG_NOTICE([  LIBS=\"$LIBS\"])
413AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
414AC_MSG_NOTICE([])
415if test "${gslcblas_found}" = "yes"; then
416AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
417AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
418AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
419AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
420AC_MSG_NOTICE([])
421fi
422AC_MSG_NOTICE([ Now type 'make ; make check'.])
Note: See TracBrowser for help on using the repository browser.