source: trunk/configure.ac @ 1692

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

improved quotation in configure.ac

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