source: trunk/configure.ac @ 1394

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

AX_BOOST_BASE fails if no boost available but only gives a warning when found boost is too old. Added code so configure stops (inline with our other checks) when boost is too old.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.5 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1394 2008-07-29 14:49: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#
10# This file is part of the yat library, http://trac.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 2 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 this program; if not, write to the Free Software
24# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25# 02111-1307, USA.
26#
27# If you grabbed the source from the subversion repository you should,
28# at top-level, execute:
29#     ./bootstrap
30# To push subsequent changes of this file into the build scripts you
31# must issue:
32#     autoreconf
33
34m4_include([./build_support/version.m4])
35AC_INIT([yat],[YAT_VERSION],[jari@thep.lu.se])
36AC_PREREQ(2.60)
37AC_CONFIG_SRCDIR([yat/utility/Matrix.h])
38AC_CONFIG_AUX_DIR([autotools])
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
61AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [true], [false])
62
63AM_CONDITIONAL(HAVE_DOXYGEN, test "$HAVE_DOXYGEN" = "true")
64AC_CONFIG_FILES([test/documentation_test.sh],
65                [chmod +x test/documentation_test.sh])
66
67# Save user-defined environment settings for later restoration
68APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
69APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
70APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
71
72# Checks for libraries.
73AC_CHECK_LIB(m,main)
74# searching for cblas. Priority 1) find a cblas library, 2) find ATLAS
75# generated cblas, and 3) fall back to GSL cblas implementation. If
76# partial ATLAS is detected the configure script fails.
77cblas_found="no"  # cblas_found may get values yes or no
78# atlas_found may get values yes, no, or partial. In some cases
79# partial atlas may be installed
80atlas_found="no"
81gslcblas_found="no" # gslcblas_found may get values yes or no
82AC_SEARCH_LIBS(cblas_sdsdot,cblas,cblas_found="yes",
83  AC_SEARCH_LIBS(ATL_sdsdot,atlas,
84    AC_SEARCH_LIBS(cblas_sdsdot,cblas,atlas_found="yes",
85                   atlas_found="partial",-m64),
86      AC_SEARCH_LIBS(cblas_dswap,gslcblas,gslcblas_found="yes"),-m64),)
87# CBLAS used in test of GSL
88gsl_cblas_lib=-lgslcblas
89if test ${cblas_found} = "yes"; then
90  gsl_cblas_lib=-lcblas
91fi
92if test ${atlas_found} = "yes"; then
93  CXXFLAGS="$CXXFLAGS -m64" LDFLAGS="$LDFLAGS -m64"
94  gsl_cblas_lib=-latlas
95fi
96export GSL_CBLAS_LIB=${gsl_cblas_lib}
97
98# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
99# Including AX_PATH_GSL macro from gsl.m4 distributed by GSL
100gsl_found="no"
101gsl_version="1.8"
102AC_SUBST(gsl_version)
103AX_PATH_GSL(${gsl_version},gsl_found="yes",gsl_version_check="no")
104if test "$gsl_found" = "yes"; then
105   LIBS="-lgsl $LIBS"
106   # grep words starting with '-L' in other words LDFLAGS
107   for i in $GSL_LIBS; do
108     if test ${i:0:2} = "-L"; then
109       LDFLAGS="$LDFLAGS $i"
110     fi
111   done
112fi
113
114# Boost http://www.boost.org
115boost_version=1.33
116AC_SUBST(boost_version)
117AX_BOOST_BASE("$boost_version")
118boost_version_check=$succeeded;
119CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
120
121
122# Checks for header files.
123AC_CHECK_HEADERS([unistd.h])
124
125# Checks for typedefs, structures, and compiler characteristics.
126AC_HEADER_STDBOOL
127AC_C_CONST
128AC_C_INLINE
129AC_TYPE_SIZE_T
130
131# Checks for library functions.
132AC_PROG_LIBTOOL
133AC_FUNC_ERROR_AT_LINE
134AC_HEADER_STDC
135AC_CHECK_FUNCS([pow sqrt])
136
137CXXFLAGS="$CXXFLAGS -Wall -pedantic"
138CPPFLAGS="$CPPFLAGS -DHAVE_INLINE=1"
139AC_ARG_ENABLE(debug,
140  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
141if test "${enable_debug}" = "yes" ; then
142  CXXFLAGS="$CXXFLAGS -g -O"
143  CPPFLAGS="$CPPFLAGS -DYAT_DEBUG=1"
144else
145  CXXFLAGS="$CXXFLAGS -O3"
146  CPPFLAGS="$CPPFLAGS -DNDEBUG -DGSL_RANGE_CHECK_OFF"
147fi
148
149# check for quiet_NaN support in OS
150# Check at run-time, but if we are cross-compiling fall back on a
151# compilation test
152AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
153AC_RUN_IFELSE(
154  [AC_LANG_PROGRAM(
155    [@%:@include <limits>],
156    [return !std::numeric_limits<double>::has_quiet_NaN])],
157  [quiet_nan=yes
158   AC_MSG_RESULT($quiet_nan)],
159  [quiet_nan=no
160   AC_MSG_RESULT($quiet_nan)],
161  # if we are cross-compiling fall back on compilation test
162  [AC_MSG_RESULT(cross-compiling)
163   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
164    AC_COMPILE_IFELSE(
165     [AC_LANG_PROGRAM(
166        [@%:@include <limits>
167         extern void f(double);],
168        [f(std::numeric_limits<double>::quiet_NaN())])],
169     [quiet_nan=yes],
170     [quiet_nan=no])
171   AC_MSG_RESULT($quiet_nan)])
172# Check for infinity support for doubles in OS
173# Check at run-time, but if we are cross-compiling fall back on a
174# compilation test
175AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
176AC_RUN_IFELSE(
177  [AC_LANG_PROGRAM(
178    [@%:@include <limits>],
179    [return !std::numeric_limits<double>::has_infinity])],
180  [has_infinity=yes
181   AC_MSG_RESULT($has_infinity)],
182  [has_infinity=no
183   AC_MSG_RESULT($has_infinity)],
184  # if we are cross-compiling fall back on compilation test
185  [AC_MSG_RESULT(cross-compiling)
186   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
187    AC_COMPILE_IFELSE(
188     [AC_LANG_PROGRAM(
189        [@%:@include <limits>
190         extern void f(double);],
191        [f(std::numeric_limits<double>::infinity())])],
192     [has_infinity=yes],
193     [has_infinity=no])
194   AC_MSG_RESULT($has_infinity)])
195
196
197# yat specific settings
198YAT_LIBNAME="yat"
199YAT_LIB="libyat.la"
200YAT_LIB_LOCATION="yat"
201AC_SUBST(YAT_LIBNAME)
202AC_SUBST(YAT_LIB)
203AC_SUBST(YAT_LIB_LOCATION)
204
205#doxygen stuff
206DX_HTML_OUTPUT=html
207DX_LATEX_OUTPUT=latex
208AC_SUBST(DX_HTML_OUTPUT)
209AC_SUBST(DX_LATEX_OUTPUT)
210
211
212AC_CONFIG_FILES([Makefile
213     build_support/yat.pc
214     doc/Makefile
215     doc/doxygen.config
216     test/Makefile
217     test/environment.h
218     test/data/Makefile
219     yat/Makefile
220     yat/classifier/Makefile
221     yat/random/Makefile
222     yat/regression/Makefile
223     yat/statistics/Makefile
224     yat/utility/version.h
225     yat/utility/Makefile])
226
227AC_CONFIG_FILES([build_support/yat-config],
228                [chmod +x build_support/yat-config])
229
230# warning about missing doxygen
231if (test "$HAVE_DOXYGEN" != "true") ; then
232  AC_MSG_WARN([
233  Doxygen was not found. Yat will compile and work without doxygen.
234  However, in order to enable generation of documentation, please
235  install Doxygen available at http://www.doxygen.org/
236  ])
237fi
238
239# Print failure status information about selected items, and exit if
240# fatal errors were encountered. No output will be created if
241# configure is halted prematurely.
242
243# used to trigger exit before creation of output
244all_reqs_ok="true"
245
246# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
247# of created binary, will fail.
248if test "${quiet_nan}" = "no" ; then
249  all_reqs_ok="false"
250  AC_MSG_WARN([
251  Support for quiet NAN required.
252  Yat will not work on this system!])
253fi
254
255# No support for infinity is fatal -- sub-sequent compilation, or execution
256# of created binary, will fail.
257if test "${has_infinity}" = "no" ; then
258  all_reqs_ok="false"
259  AC_MSG_WARN([
260  Support for infinity required.
261  Yat will not work on this system!])
262fi
263
264
265# Non-existing BLAS is fatal -- sub-sequent compilation will fail.
266if test "${cblas_found}" = "no" -a "${atlas_found}" = "no" -a "${gslcblas_found}" = "no"; then
267  all_reqs_ok="false"
268  AC_MSG_WARN([
269  cBLAS not found. The C implementation of Basic Linear Algebra
270  Subprograms (cBLAS) library cannot be found. Please make sure
271  cBLAS is installed.])
272fi
273if test "${atlas_found}" = "partial"; then
274  all_reqs_ok="false"
275  AC_MSG_WARN([
276  Partial ATLAS BLAS library found. Please repair your installation.])
277fi
278
279# Non-existing GSL is fatal -- sub-sequent compilation will fail.
280if test "${gsl_found}" = "no" ; then
281  all_reqs_ok="false"
282  if test "${gsl_version_check}" = "no" ; then
283  AC_MSG_WARN([
284  GSL found but not the required version. Please install
285  GSL version ${gsl_version} or later])
286  else
287  AC_MSG_WARN([
288  GSL not found. The GNU Scientific Library (GSL) library cannot be
289  found. Please make sure GSL is installed.])
290  fi
291fi
292
293# Too old Boost is fatal -- sub-sequent compilation will fail.
294if test "${boost_version_check}" != "yes" ; then
295  all_reqs_ok="false"
296  AC_MSG_WARN([
297  Boost found but not the required version. Please install
298  Boost version ${boost_version} or later])
299fi
300
301if (test "$all_reqs_ok" = "false") ; then
302  AC_MSG_FAILURE([
303  Some pre-requisites were not fulfilled, aborting configure.
304  Please consult the 'README' file for more information about what
305  is needed to compile yat and refer to above warning messages.
306  Needed files were NOT created.])
307fi
308
309# Reset flags
310APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
311APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, EXTRA_)
312APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
313
314# Create output.
315AC_OUTPUT
316
317# Some more messages.
318AC_MSG_NOTICE([])
319AC_MSG_NOTICE([ Ready to compile the yat library])
320AC_MSG_NOTICE([ The following flags and libraries will be used:])
321AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
322AC_MSG_NOTICE([  CPPFLAGS=\"$CPPFLAGS\"])
323AC_MSG_NOTICE([  EXTRA_CPPFLAGS=\"$EXTRA_CPPFLAGS\"])
324AC_MSG_NOTICE([  CXXFLAGS=\"$CXXFLAGS\"])
325AC_MSG_NOTICE([  EXTRA_CXXFLAGS=\"$EXTRA_CXXFLAGS\"])
326AC_MSG_NOTICE([  LDFLAGS=\"$LDFLAGS\"])
327AC_MSG_NOTICE([  EXTRA_LDFLAGS=\"$EXTRA_LDFLAGS\"])
328AC_MSG_NOTICE([  LIBS=\"$LIBS\"])
329AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
330AC_MSG_NOTICE([])
331if test "${gslcblas_found}" = "yes"; then
332AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
333AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
334AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
335AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
336AC_MSG_NOTICE([])
337fi
338AC_MSG_NOTICE([ Now type 'make ; make check'.])
Note: See TracBrowser for help on using the repository browser.