source: trunk/configure.ac @ 1548

Last change on this file since 1548 was 1542, checked in by Peter, 13 years ago

fixes #446

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