1# Configure autoconf for the Adept library 2 3### GENERAL CONFIGURATION ### 4 5AC_PREREQ([2.61]) 6AC_INIT([adept], [2.0.8], [r.j.hogan@ecmwf.int], [adept], [http://www.met.reading.ac.uk/clouds/adept/]) 7AC_LANG([C++]) 8AC_CONFIG_SRCDIR([adept/Stack.cpp]) 9AC_CONFIG_HEADERS([config.h config_platform_independent.h]) 10AM_INIT_AUTOMAKE([-Wall -Werror]) 11AC_CONFIG_MACRO_DIR([m4]) 12 13# Checks for programs 14AC_PROG_CXX 15AC_PROG_F77 16AC_PROG_MAKE_SET 17m4_ifdef([AM_PROG_AR],[AM_PROG_AR]) 18AC_PROG_LIBTOOL 19 20# Check for system features 21AC_CHECK_HEADERS([sys/time.h]) 22AC_CHECK_FUNCS([gettimeofday pow sqrt]) 23 24# Check for OpenMP 25AC_OPENMP 26AC_SUBST(AM_CXXFLAGS,"$OPENMP_CXXFLAGS") 27 28#### LIBRARIES NEEDED BY ADEPT ### 29 30if test "x$F77" = x 31then 32 AC_MSG_NOTICE([Not checking for BLAS and LAPACK because no Fortran compiler found]) 33else 34 # Check for BLAS and LAPACK 35 # First we need this since the libraries are Fortran called from C++ 36 AC_F77_LIBRARY_LDFLAGS 37 # The following tests for both BLAS and LAPACK 38 AX_LAPACK 39fi 40 41# Dependencies dictate the following order of libraries 42LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS" 43# FLIBS should be included in LDADD or LIBADD in the relevant 44# Makefile.am 45 46# If the BLAS library is OpenBLAS then we need to give the user the 47# option to change the number of threads, since OpenBLAS's pthreads 48# can clash with Adept's use of OpenMP, leading to suboptimal 49# performance. 50ac_have_openblas_cblas_header=no 51 52if test "$ax_blas_ok" = yes 53then 54 if test "x$BLAS_LIBS" = "x-lopenblas" 55 then 56 AC_MSG_CHECKING([whether cblas.h is from OpenBLAS]) 57 AC_TRY_LINK([#include <cblas.h>], 58 [openblas_set_num_threads(1)], 59 [ac_have_openblas_cblas_header=yes 60 AC_MSG_RESULT(yes) 61 AC_DEFINE([HAVE_OPENBLAS_CBLAS_HEADER],1,[Is the clbas.h header file from OpenBLAS?])], 62 AC_MSG_RESULT(no)) 63 fi 64fi 65 66### LIBRARIES THAT MAY BE USED BY TEST PROGRAMS ### 67 68# Checks for GNU Scientific Library 69AC_CHECK_LIB([gsl],[gsl_multimin_fdfminimizer_alloc],[AC_MSG_NOTICE([Note that GSL is not used by Adept, just by one of the test programs])]) 70AC_SUBST(USE_GSL, ["$ac_cv_lib_gsl_gsl_multimin_fdfminimizer_alloc"]) 71 72# Check for ADOL-C automatic differentiation library 73AC_CHECK_HEADERS([adolc/adolc.h]) 74AC_CHECK_LIB([adolc],[tapestats]) 75 76# Check for SACADO automatic differentiation library 77ac_have_sacado=no 78save_LIBS=$LIBS 79LIBS="$LIBS -lsacado -lteuchos" 80AC_MSG_CHECKING([whether Sacado is installed]) 81AC_TRY_LINK([#include <Sacado.hpp>], 82[Sacado::ELRFad::DFad<double> v = 1.0], 83[ac_have_sacado=yes 84AC_MSG_RESULT(yes) 85AC_DEFINE([HAVE_SACADO],1,[Is the Sacado library working?])], 86[LIBS=$save_LIBS 87AC_MSG_RESULT(no)]) 88 89# Check for CppAD automatic differentiation library 90AC_CHECK_HEADERS([cppad/cppad.hpp]) 91if test "$ac_cv_header_cppad_cppad_hpp" = yes 92then 93 AC_DEFINE([NDEBUG],1,[If CppAD is being used by the benchmarking program then it is much faster with debugging disabled]) 94fi 95 96 97### CREATE MAKEFILES AND CONFIG HEADER ### 98 99AC_CONFIG_FILES([Makefile makefile_include adept/Makefile include/Makefile benchmark/Makefile]) 100 101AC_DEFINE_UNQUOTED([CXX],["$CXX"],[C++ compiler]) 102AC_DEFINE_UNQUOTED([CXXFLAGS],["$CXXFLAGS"],[Flags passed to C++ compiler]) 103AC_DEFINE_UNQUOTED([BLAS_LIBS],["$BLAS_LIBS"],[BLAS library option]) 104 105AH_BOTTOM([/* Use ADOLC only if both the library and the header files are available */ 106#if defined( HAVE_LIBADOLC ) && defined( HAVE_ADOLC_ADOLC_H ) 107#define HAVE_ADOLC 1 108#endif]) 109AH_BOTTOM([/* Use CPPAD if the header files are available */ 110#if defined( HAVE_CPPAD_CPPAD_HPP ) 111#define HAVE_CPPAD 1 112#endif]) 113 114AC_OUTPUT 115 116 117### REPORT CONFIGURATION TO THE USER ### 118 119AC_MSG_NOTICE([********************* Summary **************************************]) 120AC_MSG_NOTICE([ CXX = $CXX ]) 121AC_MSG_NOTICE([ CPPFLAGS = $CPPFLAGS]) 122AC_MSG_NOTICE([ CXXFLAGS = $CXXFLAGS $OPENMP_CXXFLAGS]) 123AC_MSG_NOTICE([ LDFLAGS = $LDFLAGS]) 124AC_MSG_NOTICE([ LIBS = $LIBS]) 125AC_MSG_NOTICE([Typing "make; make install" will install Adept header files in $includedir]) 126AC_MSG_NOTICE([and the static and shared libraries as $libdir/libadept.*, where]) 127AC_MSG_NOTICE([prefix=$prefix]) 128AC_MSG_NOTICE([********************* Libraries used by Adept **********************]) 129ac_warn_given=no 130if test "$ax_blas_ok" = yes 131then 132 AC_MSG_NOTICE([BLAS (Basic Linear Algebra Subprograms) will be used: BLAS_LIBS = $BLAS_LIBS]) 133 if test "$ac_have_openblas_cblas_header" = yes 134 then 135 AC_MSG_NOTICE([ Number of BLAS threads may be controlled at run time]) 136 fi 137else 138 AC_MSG_NOTICE([BLAS (Basic Linear Algebra Subprograms) will not be used: MATRIX MULTIPLICATION IS UNAVAILABLE]) 139 ac_warn_given=yes 140fi 141if test "$ax_lapack_ok" = yes 142then 143 AC_MSG_NOTICE([LAPACK (Linear Algebra Package) will be used: LAPACK_LIBS = $LAPACK_LIBS]) 144else 145 AC_MSG_NOTICE([LAPACK (Linear Algebra Package) will not be used: LINEAR ALGEBRA ROUTINES ARE UNAVAILABLE]) 146 ac_warn_given=yes 147fi 148 149AC_MSG_NOTICE([********************* Libraries used by test programs **************]) 150 151if test "$ac_cv_lib_gsl_gsl_multimin_fdfminimizer_alloc" = no 152then 153 AC_MSG_NOTICE([GNU Scientific Library (GSL) not found; Adept will compile all the]) 154 AC_MSG_NOTICE([example programs except test/test_gsl_interface.]) 155 ac_warn_given=yes 156else 157 AC_MSG_NOTICE([GNU Scientific Library (GSL) found; Adept will compile all the]) 158 AC_MSG_NOTICE([example programs.]) 159fi 160 161AC_MSG_NOTICE([********************* Benchmark program ****************************]) 162AC_MSG_NOTICE([The benchmarking program, "benchmark/advection_benchmark", will be]) 163AC_MSG_NOTICE([compiled with support for these automatic differentiation libraries:]) 164AC_MSG_NOTICE([ Adept: yes]) 165 166if test "$ac_cv_lib_adolc_tapestats" = yes -a "$ac_cv_header_adolc_adolc_h" = yes 167then 168 AC_MSG_NOTICE([ ADOLC: yes]) 169else 170 AC_MSG_NOTICE([ ADOLC: no]) 171 ac_warn_given=yes 172fi 173 174if test "$ac_cv_header_cppad_cppad_hpp" = yes 175then 176 AC_MSG_NOTICE([ CppAD: yes]) 177else 178 AC_MSG_NOTICE([ CppAD: no]) 179 ac_warn_given=yes 180fi 181 182if test "$ac_have_sacado" = no 183then 184 AC_MSG_NOTICE([ Sacado: no]) 185 ac_warn_given=yes 186else 187 AC_MSG_NOTICE([ Sacado: yes]) 188fi 189 190AC_MSG_NOTICE([********************* Top tips *************************************]) 191AC_MSG_NOTICE([To use a higher than default optimization level, call this configure]) 192AC_MSG_NOTICE([script with something like: ./configure "CXXFLAGS=-g -O3"]) 193AC_MSG_NOTICE([If you have libraries in non-standard locations, specify their location]) 194AC_MSG_NOTICE([by calling this script with something like:]) 195AC_MSG_NOTICE([ ./configure CPPFLAGS=-I/local/include LDFLAGS="-L/local/lib -Wl,-rpath,/local/lib"]) 196AC_MSG_NOTICE([The rpath argument is especially useful for locating the BLAS and LAPACK]) 197AC_MSG_NOTICE([libraries if they are in non-standard locations, so that executables]) 198AC_MSG_NOTICE([built with Adept do not need to use the LD_LIBRARY_PATH environment]) 199AC_MSG_NOTICE([variable to specify their locations at run-time.]) 200AC_MSG_NOTICE([********************************************************************]) 201 202