source: trunk/configure.ac @ 1440

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

refs #427

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