source: trunk/configure.ac @ 1096

Last change on this file since 1096 was 1096, checked in by Jari Häkkinen, 13 years ago

Avoid resetting compiler/linker flags.

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