source: trunk/configure.ac @ 1061

Last change on this file since 1061 was 1060, checked in by Jari Häkkinen, 15 years ago

Fixes #280

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.2 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1060 2008-02-08 22:51:34Z jari $
4
5# Copyright (C) 2003 Daniel Dalevi, Jari Häkkinen
6# Copyright (C) 2004 Jari Häkkinen
7# Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
8# Copyright (C) 2008 Jari Häkkinen
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
34AC_INIT([yat],[0.4pre],[jari@thep.lu.se])
35AC_PREREQ(2.60)
36AC_CONFIG_SRCDIR([yat/utility/matrix.h])
37AC_CONFIG_AUX_DIR([autotools])
38AC_PREFIX_DEFAULT([/usr/local])
39
40AM_CONFIG_HEADER([config.h])
41AM_INIT_AUTOMAKE()
42
43# Set default programming language
44AC_LANG(C++)
45# reset CXXFLAGS, it has "-g -O2" as default
46CXXFLAGS=""
47
48# Checks for programs.
49AC_PROG_CXX
50AC_PROG_INSTALL
51AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [true], [false])
52AC_CHECK_PROG([HAVE_DVIPDFM], [dvipdfm], [true], [false])
53AC_CHECK_PROG([HAVE_LATEX], [latex], [true], [false])
54AC_CHECK_PROG([HAVE_LATEX2HTML], [latex2html], [true], [false])
55
56# Checks for libraries.
57AC_CHECK_LIB(m,main)
58# searching for cblas. Priority 1) find a cblas library, 2) find ATLAS
59# generated cblas, and 3) fall back to GSL cblas implementation. If
60# partial ATLAS is detected the configure script fails.
61cblas_found="no"  # cblas_found may get values yes or no
62# atlas_found may get values yes, no, or partial. In some cases
63# partial atlas may be installed
64atlas_found="no"
65gslcblas_found="no" # gslcblas_found may get values yes or no
66AC_SEARCH_LIBS(cblas_sdsdot,cblas,cblas_found="yes",
67  AC_SEARCH_LIBS(ATL_sdsdot,atlas,
68    AC_SEARCH_LIBS(cblas_sdsdot,cblas,atlas_found="yes",
69                   atlas_found="partial",-m64),
70      AC_SEARCH_LIBS(cblas_dswap,gslcblas,gslcblas_found="yes"),-m64),)
71if test ${atlas_found} = "yes"; then
72  CXXFLAGS="$CXXFLAGS -m64" LDFLAGS="$LDFLAGS -m64"
73fi
74
75# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
76# Including AM_PATH_GSL macro from gsl.m4 distributed by GSL
77gsl_found="no"
78gsl_version="1.6"
79sinclude(./build_support/gsl.m4)
80AM_PATH_GSL(${gsl_version},gsl_found="yes",gsl_version_check="no")
81if test "$gsl_found" = "yes"; then
82  # Needed to set -lgsl
83  AC_CHECK_LIB(gsl,main)
84fi
85
86# Checks for header files.
87AC_CHECK_HEADERS([unistd.h])
88
89# Checks for typedefs, structures, and compiler characteristics.
90AC_HEADER_STDBOOL
91AC_C_CONST
92AC_C_INLINE
93AC_TYPE_SIZE_T
94
95# Checks for library functions.
96AC_PROG_LIBTOOL
97AC_FUNC_ERROR_AT_LINE
98AC_HEADER_STDC
99AC_CHECK_FUNCS([pow sqrt])
100
101CXXFLAGS="$CXXFLAGS -Wall -pedantic"
102CPPFLAGS="-DHAVE_INLINE=1"
103AC_ARG_ENABLE(debug,
104  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
105if test "${enable_debug}" = "yes" ; then
106  CXXFLAGS="$CXXFLAGS -g -O"
107  CPPFLAGS="$CPPFLAGS -DYAT_DEBUG=1"
108else
109  CXXFLAGS="$CXXFLAGS -O3"
110  CPPFLAGS="$CPPFLAGS -DNDEBUG -DGSL_RANGE_CHECK_OFF"
111fi
112
113# check for quiet_NaN support in OS
114# At compile time, but this may not work if quiet_NaN exists and returns
115# an incorrect value
116AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
117AC_COMPILE_IFELSE(
118  [AC_LANG_PROGRAM(
119    [#include <limits>
120     extern void f(double);],
121    [f(std::numeric_limits<double>::quiet_NaN())])],
122  [quiet_nan=yes],
123  [quiet_nan=no])
124AC_MSG_RESULT($quiet_nan)
125# At run-time, but this has the disadvantage that yat cannot be built 
126# for cross-compilation
127AC_MSG_CHECKING([if std::numeric_limits<>::has_quiet_NaN is true])
128AC_RUN_IFELSE(
129  [AC_LANG_PROGRAM(
130    [#include <limits>],
131    [return !std::numeric_limits<double>::has_quiet_NaN])],
132  [quiet_nan=yes],
133  [quiet_nan=no])
134AC_MSG_RESULT($quiet_nan)
135
136# yat specific settings
137YAT_LIB="libyat.la"
138YAT_LIB_LOCATION="yat"
139AC_SUBST(YAT_LIB)
140AC_SUBST(YAT_LIB_LOCATION)
141
142AC_CONFIG_FILES([Makefile
143     doc/Makefile
144     test/Makefile
145     test/data/Makefile
146     yat/Makefile
147     yat/classifier/Makefile
148     yat/random/Makefile
149     yat/regression/Makefile
150     yat/statistics/Makefile
151     yat/utility/Makefile])
152
153# Only warning about missing programs (needed for docs generation)
154# when in debug mode
155if (test "$enable_debug" == "yes"); then
156if (test "$HAVE_DOXYGEN" != "true") ; then
157  AC_MSG_WARN([
158  Doxygen was not found. Yat will compile and work without doxygen.
159  However, in order to enable generation of documentation, please
160  install doxygen available at http://www.doxygen.org/
161  ])
162fi
163if (test "$HAVE_LATEX" != "true") ; then
164  AC_MSG_WARN([
165  latex was not found. Yat will compile and work without latex.
166  However, supporting documentation on statistics used in yat
167  cannot be generated without latex.
168  ])
169fi
170if (test "$HAVE_DVIPDFM" != "true") ; then
171  AC_MSG_WARN([
172  dvipdfm was not found. Yat will compile and work without dvipdfm.
173  However, pdf document on statistics used in yat cannot be
174  generated without dvipdfm.
175  ])
176fi
177if (test "$HAVE_LATEX2HTML" != "true") ; then
178  AC_MSG_WARN([
179  latex2html was not found. Yat will compile and work without
180  latex. However, html document on statistics used in yat cannot
181  be generated without latex.
182  ])
183fi
184fi
185
186# Print failure status information about selected items, and exit if
187# fatal errors were encountered. No output will be created if
188# configure is halted prematurely.
189
190# used to trigger exit before creation of output
191all_reqs_ok="true"
192
193# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
194# of created binary, will fail.
195if test "${quiet_nan}" = "no" ; then
196  all_reqs_ok="false"
197  AC_MSG_WARN([
198  Support for quiet NAN required.
199  Yat will not work on this system!])
200fi
201
202# Non-existing BLAS is fatal -- sub-sequent compilation will fail.
203if test "${cblas_found}" = "no" -a "${atlas_found}" = "no" -a "${gslcblas_found}" = "no"; then
204  all_reqs_ok="false"
205  AC_MSG_WARN([
206  cBLAS not found. The C implementation of Basic Linear Algebra
207  Subprograms (cBLAS) library cannot be found. Please make sure
208  cBLAS is installed.])
209fi
210if test "${atlas_found}" = "partial"; then
211  all_reqs_ok="false"
212  AC_MSG_WARN([
213  Partial ATLAS BLAS library found. Please repair your installation.])
214fi
215
216# Non-existing GSL is fatal -- sub-sequent compilation will fail.
217if test "${gsl_found}" = "no" ; then
218  all_reqs_ok="false"
219  if test "${gsl_version_check}" = "no" ; then
220  AC_MSG_WARN([
221  GSL found but not the required version. Please install
222  GSL version ${gsl_version} or later])
223  else
224  AC_MSG_WARN([
225  GSL not found. The GNU Scientific Library (GSL) library cannot be
226  found. Please make sure GSL is installed.])
227  fi
228fi
229
230if (test "$all_reqs_ok" = "false") ; then
231  AC_MSG_FAILURE([
232  Some pre-requisites were not fulfilled, aborting configure.
233  Please consult the 'README' file for more information about what
234  is needed to compile yat and refer to above warning messages.
235  Needed files were NOT created.])
236fi
237
238# Create output.
239AC_OUTPUT
240
241# Some more messages.
242AC_MSG_NOTICE([])
243AC_MSG_NOTICE([ Ready to compile the yat library])
244AC_MSG_NOTICE([ The following flags and libraries will be used:])
245AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
246AC_MSG_NOTICE([  CPPFLAGS=\"$CPPFLAGS\"])
247AC_MSG_NOTICE([  CXXFLAGS=\"$CXXFLAGS\"])
248AC_MSG_NOTICE([  LIBS=\"$LIBS\"])
249AC_MSG_NOTICE([  LDFLAGS=\"$LDFLAGS\"])
250AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
251AC_MSG_NOTICE([])
252if test "${gslcblas_found}" = "yes"; then
253AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
254AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
255AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
256AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
257AC_MSG_NOTICE([])
258fi
259AC_MSG_NOTICE([ Now type 'make ; make check'.])
Note: See TracBrowser for help on using the repository browser.