source: trunk/configure.ac @ 1348

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

adding a yat-config script (fixes #353)
also fixes ticket #376 by using some magic from apr

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.4 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1348 2008-06-21 04:49:12Z 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")
64
65m4_sinclude(./build_support/apr_common.m4)
66# Save user-defined environment settings for later restoration
67APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
68APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
69APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
70
71# Checks for libraries.
72AC_CHECK_LIB(m,main)
73# searching for cblas. Priority 1) find a cblas library, 2) find ATLAS
74# generated cblas, and 3) fall back to GSL cblas implementation. If
75# partial ATLAS is detected the configure script fails.
76cblas_found="no"  # cblas_found may get values yes or no
77# atlas_found may get values yes, no, or partial. In some cases
78# partial atlas may be installed
79atlas_found="no"
80gslcblas_found="no" # gslcblas_found may get values yes or no
81AC_SEARCH_LIBS(cblas_sdsdot,cblas,cblas_found="yes",
82  AC_SEARCH_LIBS(ATL_sdsdot,atlas,
83    AC_SEARCH_LIBS(cblas_sdsdot,cblas,atlas_found="yes",
84                   atlas_found="partial",-m64),
85      AC_SEARCH_LIBS(cblas_dswap,gslcblas,gslcblas_found="yes"),-m64),)
86if test ${atlas_found} = "yes"; then
87  CXXFLAGS="$CXXFLAGS -m64" LDFLAGS="$LDFLAGS -m64"
88fi
89
90# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
91# Including AX_PATH_GSL macro from gsl.m4 distributed by GSL
92gsl_found="no"
93gsl_version="1.8"
94sinclude(./build_support/gsl.m4)
95AX_PATH_GSL(${gsl_version},gsl_found="yes",gsl_version_check="no")
96if test "$gsl_found" = "yes"; then
97   LIBS="-lgsl $LIBS"
98   # grep words starting with '-L' in other words LDFLAGS
99   for i in $GSL_LIBS; do
100     if test ${i:0:2} = "-L"; then
101       LDFLAGS="$LDFLAGS $i"
102     fi
103   done
104fi
105
106# Boost http://www.boost.org
107m4_sinclude(./build_support/ax_boost.m4)
108AX_BOOST("1.33")
109CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
110
111# Checks for header files.
112AC_CHECK_HEADERS([unistd.h])
113
114# Checks for typedefs, structures, and compiler characteristics.
115AC_HEADER_STDBOOL
116AC_C_CONST
117AC_C_INLINE
118AC_TYPE_SIZE_T
119
120# Checks for library functions.
121AC_PROG_LIBTOOL
122AC_FUNC_ERROR_AT_LINE
123AC_HEADER_STDC
124AC_CHECK_FUNCS([pow sqrt])
125
126CXXFLAGS="$CXXFLAGS -Wall -pedantic"
127CPPFLAGS="$CPPFLAGS -DHAVE_INLINE=1"
128AC_ARG_ENABLE(debug,
129  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
130if test "${enable_debug}" = "yes" ; then
131  CXXFLAGS="$CXXFLAGS -g -O"
132  CPPFLAGS="$CPPFLAGS -DYAT_DEBUG=1"
133else
134  CXXFLAGS="$CXXFLAGS -O3"
135  CPPFLAGS="$CPPFLAGS -DNDEBUG -DGSL_RANGE_CHECK_OFF"
136fi
137
138# check for quiet_NaN support in OS
139# At compile time, but this may not work if quiet_NaN exists and returns
140# an incorrect value
141AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
142AC_COMPILE_IFELSE(
143  [AC_LANG_PROGRAM(
144    [#include <limits>
145     extern void f(double);],
146    [f(std::numeric_limits<double>::quiet_NaN())])],
147  [quiet_nan=yes],
148  [quiet_nan=no])
149AC_MSG_RESULT($quiet_nan)
150# At run-time, but this has the disadvantage that yat cannot be built 
151# for cross-compilation
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  [quiet_nan=no])
159AC_MSG_RESULT($quiet_nan)
160# Check for infinity support for doubles in OS
161# At run-time, but this has the disadvantage that yat cannot be built 
162# for cross-compilation
163AC_MSG_CHECKING([if std::numeric_limits<>::has_infinity is true])
164AC_RUN_IFELSE(
165  [AC_LANG_PROGRAM(
166    [#include <limits>],
167    [return !std::numeric_limits<double>::has_infinity])],
168  [has_infinity=yes],
169  [has_infinity=no])
170AC_MSG_RESULT($has_infinity)
171
172
173# yat specific settings
174YAT_LIBNAME="yat"
175YAT_LIB="libyat.la"
176YAT_LIB_LOCATION="yat"
177AC_SUBST(YAT_LIBNAME)
178AC_SUBST(YAT_LIB)
179AC_SUBST(YAT_LIB_LOCATION)
180
181#doxygen stuff
182DX_HTML_OUTPUT=html
183DX_LATEX_OUTPUT=latex
184AC_SUBST(DX_HTML_OUTPUT)
185AC_SUBST(DX_LATEX_OUTPUT)
186
187
188AC_CONFIG_FILES([Makefile
189     doc/Makefile
190     doc/doxygen.config
191     test/Makefile
192     test/environment.h
193     test/data/Makefile
194     yat/Makefile
195     yat/classifier/Makefile
196     yat/random/Makefile
197     yat/regression/Makefile
198     yat/statistics/Makefile
199     yat/utility/version.h
200     yat/utility/Makefile])
201
202AC_CONFIG_FILES([build_support/yat-config],
203                [chmod +x build_support/yat-config])
204
205# warning about missing doxygen
206if (test "$HAVE_DOXYGEN" != "true") ; then
207  AC_MSG_WARN([
208  Doxygen was not found. Yat will compile and work without doxygen.
209  However, in order to enable generation of documentation, please
210  install Doxygen available at http://www.doxygen.org/
211  ])
212fi
213
214# Print failure status information about selected items, and exit if
215# fatal errors were encountered. No output will be created if
216# configure is halted prematurely.
217
218# used to trigger exit before creation of output
219all_reqs_ok="true"
220
221# No support for quiet NAN is fatal -- sub-sequent compilation, or execution
222# of created binary, will fail.
223if test "${quiet_nan}" = "no" ; then
224  all_reqs_ok="false"
225  AC_MSG_WARN([
226  Support for quiet NAN required.
227  Yat will not work on this system!])
228fi
229
230# No support for infinity is fatal -- sub-sequent compilation, or execution
231# of created binary, will fail.
232if test "${has_infinity}" = "no" ; then
233  all_reqs_ok="false"
234  AC_MSG_WARN([
235  Support for infinity required.
236  Yat will not work on this system!])
237fi
238
239
240# Non-existing BLAS is fatal -- sub-sequent compilation will fail.
241if test "${cblas_found}" = "no" -a "${atlas_found}" = "no" -a "${gslcblas_found}" = "no"; then
242  all_reqs_ok="false"
243  AC_MSG_WARN([
244  cBLAS not found. The C implementation of Basic Linear Algebra
245  Subprograms (cBLAS) library cannot be found. Please make sure
246  cBLAS is installed.])
247fi
248if test "${atlas_found}" = "partial"; then
249  all_reqs_ok="false"
250  AC_MSG_WARN([
251  Partial ATLAS BLAS library found. Please repair your installation.])
252fi
253
254# Non-existing GSL is fatal -- sub-sequent compilation will fail.
255if test "${gsl_found}" = "no" ; then
256  all_reqs_ok="false"
257  if test "${gsl_version_check}" = "no" ; then
258  AC_MSG_WARN([
259  GSL found but not the required version. Please install
260  GSL version ${gsl_version} or later])
261  else
262  AC_MSG_WARN([
263  GSL not found. The GNU Scientific Library (GSL) library cannot be
264  found. Please make sure GSL is installed.])
265  fi
266fi
267
268if (test "$all_reqs_ok" = "false") ; then
269  AC_MSG_FAILURE([
270  Some pre-requisites were not fulfilled, aborting configure.
271  Please consult the 'README' file for more information about what
272  is needed to compile yat and refer to above warning messages.
273  Needed files were NOT created.])
274fi
275
276# Reset flags
277APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
278APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, EXTRA_)
279APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
280
281# Create output.
282AC_OUTPUT
283
284# Some more messages.
285AC_MSG_NOTICE([])
286AC_MSG_NOTICE([ Ready to compile the yat library])
287AC_MSG_NOTICE([ The following flags and libraries will be used:])
288AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
289AC_MSG_NOTICE([  CPPFLAGS=\"$CPPFLAGS\"])
290AC_MSG_NOTICE([  EXTRA_CPPFLAGS=\"$EXTRA_CPPFLAGS\"])
291AC_MSG_NOTICE([  CXXFLAGS=\"$CXXFLAGS\"])
292AC_MSG_NOTICE([  EXTRA_CXXFLAGS=\"$EXTRA_CXXFLAGS\"])
293AC_MSG_NOTICE([  LDFLAGS=\"$LDFLAGS\"])
294AC_MSG_NOTICE([  EXTRA_LDFLAGS=\"$EXTRA_LDFLAGS\"])
295AC_MSG_NOTICE([  LIBS=\"$LIBS\"])
296AC_MSG_NOTICE([ +++++++++++++++++++++++++++++++++++++++++++++++])
297AC_MSG_NOTICE([])
298if test "${gslcblas_found}" = "yes"; then
299AC_MSG_NOTICE([ GSL BLAS found. This is a reference implementation only.])
300AC_MSG_NOTICE([ Consider using hardware optimized BLAS.])
301AC_MSG_NOTICE([ ATLAS (http://math-atlas.sourceforge.net/) provides an])
302AC_MSG_NOTICE([ optimized BLAS library. It is supported by yat!])
303AC_MSG_NOTICE([])
304fi
305AC_MSG_NOTICE([ Now type 'make ; make check'.])
Note: See TracBrowser for help on using the repository browser.