source: trunk/configure.ac @ 1767

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

reduce autoconf warnings:

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