source: trunk/configure.ac @ 1389

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

removed includes since aclocal now looks in build_support for macros.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.2 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1389 2008-07-25 17:12:34Z 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("$boost_version")
118CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
119
120
121# Checks for header files.
122AC_CHECK_HEADERS([unistd.h])
123
124# Checks for typedefs, structures, and compiler characteristics.
125AC_HEADER_STDBOOL
126AC_C_CONST
127AC_C_INLINE
128AC_TYPE_SIZE_T
129
130# Checks for library functions.
131AC_PROG_LIBTOOL
132AC_FUNC_ERROR_AT_LINE
133AC_HEADER_STDC
134AC_CHECK_FUNCS([pow sqrt])
135
136CXXFLAGS="$CXXFLAGS -Wall -pedantic"
137CPPFLAGS="$CPPFLAGS -DHAVE_INLINE=1"
138AC_ARG_ENABLE(debug,
139  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
140if test "${enable_debug}" = "yes" ; then
141  CXXFLAGS="$CXXFLAGS -g -O"
142  CPPFLAGS="$CPPFLAGS -DYAT_DEBUG=1"
143else
144  CXXFLAGS="$CXXFLAGS -O3"
145  CPPFLAGS="$CPPFLAGS -DNDEBUG -DGSL_RANGE_CHECK_OFF"
146fi
147
148# check for quiet_NaN support in OS
149# Check at run-time, but if we are cross-compiling fall back on a
150# compilation test
151AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
152AC_RUN_IFELSE(
153  [AC_LANG_PROGRAM(
154    [@%:@include <limits>],
155    [return !std::numeric_limits<double>::has_quiet_NaN])],
156  [quiet_nan=yes
157   AC_MSG_RESULT($quiet_nan)],
158  [quiet_nan=no
159   AC_MSG_RESULT($quiet_nan)],
160  # if we are cross-compiling fall back on compilation test
161  [AC_MSG_RESULT(cross-compiling)
162   AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
163    AC_COMPILE_IFELSE(
164     [AC_LANG_PROGRAM(
165        [@%:@include <limits>
166         extern void f(double);],
167        [f(std::numeric_limits<double>::quiet_NaN())])],
168     [quiet_nan=yes],
169     [quiet_nan=no])
170   AC_MSG_RESULT($quiet_nan)])
171# Check for infinity support for doubles in OS
172# Check at run-time, but if we are cross-compiling fall back on a
173# compilation test
174AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
175AC_RUN_IFELSE(
176  [AC_LANG_PROGRAM(
177    [@%:@include <limits>],
178    [return !std::numeric_limits<double>::has_infinity])],
179  [has_infinity=yes
180   AC_MSG_RESULT($has_infinity)],
181  [has_infinity=no
182   AC_MSG_RESULT($has_infinity)],
183  # if we are cross-compiling fall back on compilation test
184  [AC_MSG_RESULT(cross-compiling)
185   AC_MSG_CHECKING([for std::numeric_limits<>::infinity()])
186    AC_COMPILE_IFELSE(
187     [AC_LANG_PROGRAM(
188        [@%:@include <limits>
189         extern void f(double);],
190        [f(std::numeric_limits<double>::infinity())])],
191     [has_infinity=yes],
192     [has_infinity=no])
193   AC_MSG_RESULT($has_infinity)])
194
195
196# yat specific settings
197YAT_LIBNAME="yat"
198YAT_LIB="libyat.la"
199YAT_LIB_LOCATION="yat"
200AC_SUBST(YAT_LIBNAME)
201AC_SUBST(YAT_LIB)
202AC_SUBST(YAT_LIB_LOCATION)
203
204#doxygen stuff
205DX_HTML_OUTPUT=html
206DX_LATEX_OUTPUT=latex
207AC_SUBST(DX_HTML_OUTPUT)
208AC_SUBST(DX_LATEX_OUTPUT)
209
210
211AC_CONFIG_FILES([Makefile
212     build_support/yat.pc
213     doc/Makefile
214     doc/doxygen.config
215     test/Makefile
216     test/environment.h
217     test/data/Makefile
218     yat/Makefile
219     yat/classifier/Makefile
220     yat/random/Makefile
221     yat/regression/Makefile
222     yat/statistics/Makefile
223     yat/utility/version.h
224     yat/utility/Makefile])
225
226AC_CONFIG_FILES([build_support/yat-config],
227                [chmod +x build_support/yat-config])
228
229# warning about missing doxygen
230if (test "$HAVE_DOXYGEN" != "true") ; then
231  AC_MSG_WARN([
232  Doxygen was not found. Yat will compile and work without doxygen.
233  However, in order to enable generation of documentation, please
234  install Doxygen available at http://www.doxygen.org/
235  ])
236fi
237
238# Print failure status information about selected items, and exit if
239# fatal errors were encountered. No output will be created if
240# configure is halted prematurely.
241
242# used to trigger exit before creation of output
243all_reqs_ok="true"
244
245# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
246# of created binary, will fail.
247if test "${quiet_nan}" = "no" ; then
248  all_reqs_ok="false"
249  AC_MSG_WARN([
250  Support for quiet NAN required.
251  Yat will not work on this system!])
252fi
253
254# No support for infinity is fatal -- sub-sequent compilation, or execution
255# of created binary, will fail.
256if test "${has_infinity}" = "no" ; then
257  all_reqs_ok="false"
258  AC_MSG_WARN([
259  Support for infinity required.
260  Yat will not work on this system!])
261fi
262
263
264# Non-existing BLAS is fatal -- sub-sequent compilation will fail.
265if test "${cblas_found}" = "no" -a "${atlas_found}" = "no" -a "${gslcblas_found}" = "no"; then
266  all_reqs_ok="false"
267  AC_MSG_WARN([
268  cBLAS not found. The C implementation of Basic Linear Algebra
269  Subprograms (cBLAS) library cannot be found. Please make sure
270  cBLAS is installed.])
271fi
272if test "${atlas_found}" = "partial"; then
273  all_reqs_ok="false"
274  AC_MSG_WARN([
275  Partial ATLAS BLAS library found. Please repair your installation.])
276fi
277
278# Non-existing GSL is fatal -- sub-sequent compilation will fail.
279if test "${gsl_found}" = "no" ; then
280  all_reqs_ok="false"
281  if test "${gsl_version_check}" = "no" ; then
282  AC_MSG_WARN([
283  GSL found but not the required version. Please install
284  GSL version ${gsl_version} or later])
285  else
286  AC_MSG_WARN([
287  GSL not found. The GNU Scientific Library (GSL) library cannot be
288  found. Please make sure GSL is installed.])
289  fi
290fi
291
292if (test "$all_reqs_ok" = "false") ; then
293  AC_MSG_FAILURE([
294  Some pre-requisites were not fulfilled, aborting configure.
295  Please consult the 'README' file for more information about what
296  is needed to compile yat and refer to above warning messages.
297  Needed files were NOT created.])
298fi
299
300# Reset flags
301APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
302APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, EXTRA_)
303APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
304
305# Create output.
306AC_OUTPUT
307
308# Some more messages.
309AC_MSG_NOTICE([])
310AC_MSG_NOTICE([ Ready to compile the yat library])
311AC_MSG_NOTICE([ The following flags and libraries will be used:])
312AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
313AC_MSG_NOTICE([  CPPFLAGS=\"$CPPFLAGS\"])
314AC_MSG_NOTICE([  EXTRA_CPPFLAGS=\"$EXTRA_CPPFLAGS\"])
315AC_MSG_NOTICE([  CXXFLAGS=\"$CXXFLAGS\"])
316AC_MSG_NOTICE([  EXTRA_CXXFLAGS=\"$EXTRA_CXXFLAGS\"])
317AC_MSG_NOTICE([  LDFLAGS=\"$LDFLAGS\"])
318AC_MSG_NOTICE([  EXTRA_LDFLAGS=\"$EXTRA_LDFLAGS\"])
319AC_MSG_NOTICE([  LIBS=\"$LIBS\"])
320AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
321AC_MSG_NOTICE([])
322if test "${gslcblas_found}" = "yes"; then
323AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
324AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
325AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
326AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
327AC_MSG_NOTICE([])
328fi
329AC_MSG_NOTICE([ Now type 'make ; make check'.])
Note: See TracBrowser for help on using the repository browser.