source: trunk/configure.ac @ 1756

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

improved YAT_*_ADD_FLAG - if contains several words, loop over the words and try each one of them rather than try whole sentance in one shot, which implies subset of words might get accepted

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