1dnl $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/configure.ac,v 1.326 2017/07/29 08:05:06 masarati Exp $
2dnl Process this file with autoconf to produce a configure script.
3dnl
4dnl MBDyn (C) is a multibody analysis code.
5dnl http://www.mbdyn.org
6dnl
7dnl Copyright (C) 1996-2017
8dnl
9dnl Pierangelo Masarati     <masarati@aero.polimi.it>
10dnl Paolo Mantegazza        <mantegazza@aero.polimi.it>
11dnl
12dnl Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
13dnl via La Masa, 34 - 20156 Milano, Italy
14dnl http://www.aero.polimi.it
15dnl
16dnl Changing this copyright notice is forbidden.
17dnl
18dnl This program is free software; you can redistribute it and/or modify
19dnl it under the terms of the GNU General Public License as published by
20dnl the Free Software Foundation (version 2 of the License).
21dnl
22dnl
23dnl This program is distributed in the hope that it will be useful,
24dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
25dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26dnl GNU General Public License for more details.
27dnl
28dnl You should have received a copy of the GNU General Public License
29dnl along with this program; if not, write to the Free Software
30dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31dnl
32dnl ----------------------------------------------------------------
33dnl Redefine AC_INIT_BINSH to provide copyright notice at top
34dnl of generated configure script.  Prints simple copyright.
35define([AC_INIT_BINSH],
36[[#! /bin/sh
37] ] [
38
39#
40# MBDyn (C) is a multibody analysis code.
41# http://www.mbdyn.org
42#
43# Copyright (C) 1996-2017
44#
45# Pierangelo Masarati     <masarati@aero.polimi.it>
46# Paolo Mantegazza        <mantegazza@aero.polimi.it>
47#
48# Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
49# via La Masa, 34 - 20156 Milano, Italy
50# http://www.aero.polimi.it
51#
52# Changing this copyright notice is forbidden.
53#
54# This program is free software; you can redistribute it and/or modify
55# it under the terms of the GNU General Public License as published by
56# the Free Software Foundation (version 2 of the License).
57#
58#
59echo ""
60echo "	Copyright (C) 1996-2017"
61echo "	"
62echo "	Pierangelo Masarati     <masarati@aero.polimi.it>"
63echo "	Paolo Mantegazza        <mantegazza@aero.polimi.it>"
64echo "	"
65echo "	Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano"
66echo "	via La Masa, 34 - 20156 Milano, Italy"
67echo "	http://www.aero.polimi.it"
68echo "	"
69echo "	Restrictions apply, see COPYRIGHT and LICENSE files."
70echo ""
71])dnl
72dnl ----------------------------------------------------------------
73dnl Disable config.cache!
74define([AC_CACHE_LOAD], )dnl
75define([AC_CACHE_SAVE], )dnl
76
77dnl ================================================================
78dnl configure.in for MBDyn
79
80DATE=`date "+%B %e, %Y"`
81
82# set unset (borrowed from autoconf 2.14a)
83if (unset FOO) >/dev/null 2>&1; then
84	ol_unset=unset
85else
86	ol_unset=false
87fi
88# unset CDPATH
89$ol_unset CDPATH || test "${CDPATH:+set}" != set || CDPATH=: && export CDPATH
90
91AC_INIT(mbdyn, m4_esyscmd([tr -d '\n' < build/version]))
92AC_CONFIG_AUX_DIR(build)dnl
93AC_CONFIG_SRCDIR([build/version])
94
95MBDYN_DEVEL=no
96if test -f "$ac_aux_dir/DEVEL" ; then
97	MBDYN_DEVEL=yes
98	AC_DEFINE(MBDYN_DEVEL,1,[define to enable features under development])
99	MB_VERSION="Devel"
100else
101	MB_VERSION=`cat $ac_aux_dir/version`
102fi
103
104if test -z "$MB_VERSION"; then
105	AC_MSG_ERROR([could not determine version])
106fi
107echo "Configuring MBDyn $MB_VERSION ..."
108
109dnl Determine host platform
110dnl             we try not to use this for much
111AC_CANONICAL_SYSTEM
112
113AM_INIT_AUTOMAKE
114
115dnl We use autoconf features new to 2.13.
116dnl aclocal.m4 should be built using aclocal from automake 1.4
117dnl libtool 1.3.3 should be installed.
118AC_PREREQ(2.13)dnl Required Autoconf version
119
120AC_CONFIG_HEADERS([include/mbconfig.h])
121AH_TOP([
122/*
123 * MBDyn (C) is a multibody analysis code.
124 * http://www.mbdyn.org
125 *
126 * Copyright (C) 1996-2017
127 *
128 * Pierangelo Masarati  <masarati@aero.polimi.it>
129 * Paolo Mantegazza     <mantegazza@aero.polimi.it>
130 *
131 * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
132 * via La Masa, 34 - 20156 Milano, Italy
133 * http://www.aero.polimi.it
134 *
135 * Changing this copyright notice is forbidden.
136 *
137 * This program is free software; you can redistribute it and/or modify
138 * it under the terms of the GNU General Public License as published by
139 * the Free Software Foundation (version 2 of the License).
140 *
141 *
142 * This program is distributed in the hope that it will be useful,
143 * but WITHOUT ANY WARRANTY; without even the implied warranty of
144 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
145 * GNU General Public License for more details.
146 *
147 * You should have received a copy of the GNU General Public License
148 * along with this program; if not, write to the Free Software
149 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
150 */
151])
152AH_BOTTOM([
153/* this file must be included by every .c/.cc file */
154#include "mbdyn.h"
155])
156
157top_builddir=`pwd`
158dnl AC_SUBST(top_builddir)dnl
159
160dnl ----------------------------------------------------------------
161dnl Checks for args.
162dnl
163AC_MSG_CHECKING(configure arguments)
164AC_PREFIX_DEFAULT(/usr/local/mbdyn)
165
166dnl ----------------------------------------------------------------
167dnl --with-subdir
168mbdyn_subdir="/mbdyn"
169
170AC_ARG_WITH(subdir,
171[  --with-subdir=DIR       change default subdirectory used for installs],
172[case "$withval" in
173	no)
174		mbdyn_subdir=""
175		;;
176	yes)
177		;;
178	/*|\\*)
179		mbdyn_subdir="$withval"
180		;;
181	*)
182		mbdyn_subdir="/$withval"
183		;;
184esac
185])dnl
186AC_SUBST(mbdyn_subdir)dnl
187
188dnl ----------------------------------------------------------------
189dnl General "enable" options
190OL_ARG_ENABLE(debug,[  --enable-debug          enable debugging], no)dnl
191OL_ARG_WITH(debug_mode,[  --with-debug-mode[={none|mem}] with debug mode {none|mem}],none,[none mem])
192OL_ARG_ENABLE(runtime_loading,[  --enable-runtime-loading    enable runtime loading], auto)dnl
193OL_ARG_WITH(static_modules,[  --with-static-modules   build (known) modules as static],auto,[no yes auto])
194OL_ARG_ENABLE(crypt,[  --enable-crypt          enable crypt (deprecated)], no)dnl
195OL_ARG_ENABLE(eig,[  --enable-eig            enable direct eigensolution
196                          (needs one of LAPACK, ARPACK or JDQZ)],auto,[auto yes no])dnl needs LAPACK, ARPACK or JDQZ
197OL_ARG_ENABLE(schur,[  --enable-schur          enable Schur parallel solver
198                          (needs MPI and either Metis or Chaco)],auto,[auto yes no])dnl needs MPI and Metis or Chaco
199OL_ARG_ENABLE(multithread,[  --enable-multithread    enable multithread assembly],no,[auto yes no force])dnl
200OL_ARG_ENABLE(multithread_naive,[  --enable-multithread-naive    enable multithread naive solver],no,[auto yes no force])dnl
201OL_ARG_ENABLE(mbc,[  --enable-mbc            enable MBC - multibody communication library],yes)dnl
202OL_ARG_ENABLE(netcdf,[  --enable-netcdf         enable NetCDF based binary output],auto)dnl
203OL_ARG_ENABLE(python,[  --enable-python         enable Python support],no)dnl
204OL_ARG_ENABLE(octave,[  --enable-octave         enable Octave support],no)dnl
205OL_ARG_ENABLE(autodiff,[--enable-autodiff       enable automatic differentiation in order to compute the Jacobian matrix],no)dnl
206OL_ARG_ENABLE(autodiff_vect, [  --enable-autodiff_vect={0|16|32|64}     enable vectorization for automatic differentiation],0,[0 16 32 64])dnl
207dnl ----------------------------------------------------------------
208dnl General "with" options
209OL_ARG_WITH(g2c,[  --with-g2c              with g2c header],no,[auto yes no])
210OL_ARG_WITH(mpi,[  --with-mpi              with MPI support (=pmpi for profiling)],auto,[auto yes pmpi no])
211OL_ARG_ENABLE(debug_mpi,[  --enable-debug-mpi      enable MPI debugging], no)dnl
212OL_ARG_WITH(metis,[  --with-metis            with Metis model partitioning support],auto,[auto yes no])
213
214dnl temporarily disabled until we figure out how to make chaco work...
215OL_ARG_WITH(chaco,[  --with-chaco            with Chaco model partitioning support],no,[auto yes no])
216dnl ol_with_chaco=no
217
218OL_ARG_WITH(threads,[  --with-threads          with threads],auto,[auto yes no])
219OL_ARG_WITH(rt,[  --with-rt               with POSIX realtime support],auto,[auto yes no])
220OL_ARG_WITH(rtai,[  --with-rtai             with RTAI support],no,[auto yes no])
221OL_ARG_WITH(boost,[  --with-boost            with BOOST support],no,[auto yes no])
222OL_ARG_WITH(ann,[  --with-ann              with ANN support],no,[auto yes no])
223OL_ARG_WITH(bullet,[  --with-bullet           with bullet support],no,[auto yes no])
224OL_ARG_WITH(blas,[
225       math libraries:
226  --with-blas[={auto|goto|atlas|cblas|blas|openblas}]
227                          with (C)BLAS math library],auto,[auto goto atlas cblas blas openblas])
228AC_ARG_WITH(goto,[  --with-goto=lib(s)      with Goto BLAS implementation],[
229	ol_with_goto_lib="$withval"
230],[ol_with_goto_lib=])
231AC_ARG_WITH(openblas,[  --with-openblas=lib(s)      with OpenBLAS implementation],[
232	ol_with_openblas_lib="$withval"
233],[ol_with_openblas_lib=])
234OL_ARG_WITH(ginac,[  --with-ginac            with GiNaC support
235                          (ginac-config must be in $PATH)],auto,[auto yes no])
236OL_ARG_WITH(y12,[
237       optional linear algebra solvers (naive is enabled by default):
238  --with-y12              with Y12 sparse math library],yes,[auto yes no])
239OL_ARG_WITH(umfpack,[  --with-umfpack          with Umfpack math library],auto,[auto yes no])
240OL_ARG_WITH(klu,[  --with-klu          with KLU math library],auto,[auto yes no])
241OL_ARG_WITH(lapack,[  --with-lapack           with LAPACK math library],auto,[auto yes no])
242OL_ARG_WITH(harwell,[  --with-hsl              with HSL (Harwell) sparse math library - historical],no,[auto yes no])
243OL_ARG_WITH(meschach,[  --with-meschach         with Meschach math library - historical],no,[auto yes no])
244OL_ARG_WITH(superlu,[  --with-superlu          with SuperLU math library - eXperimental],no,[auto yes no])
245OL_ARG_WITH(wsmp,[  --with-wsmp             with Watson library - eXperimental],no,[auto yes no])
246dnl temporarily disabled until we find out how to make it work...
247dnl OL_ARG_WITH(taucs,[  --with-taucs            with TAUCS math library - eXperimental],auto,[auto yes no])
248ol_with_taucs=no
249OL_ARG_WITH(arpack,[  --with-arpack           with ARPACK math library],auto,[auto yes no])
250OL_ARG_WITH(jdqz,[  --with-jdqz             with JDQZ math library],auto,[auto yes no])
251
252OL_ARG_WITH(pam,[
253       misc security libraries:
254  --with-pam              with PAM support],no,[auto yes no])
255OL_ARG_WITH(sasl2,[  --with-sasl2            with Cyrus SASL2 support],no,[auto yes no])
256
257dnl module with's
258AC_ARG_WITH(module,[
259  --with-module=<list>    build listed modules (see modules/)
260],[
261	ol_arg=
262	for ol_val in $withval ; do
263		ol_arg="$ol_arg module-$ol_val"
264	done
265	if test "${ol_arg:-set}" = set ; then
266		AC_MSG_ERROR(bad value $withval for --with-module)
267	fi
268	MODULES_DIRS=$ol_arg
269],[MODULES_DIRS=])dnl
270
271OL_ARG_WITH(charm,[  --with-charm            with CHARM WP module],no,[auto yes no])
272
273fool_libtool=yes
274case "$host" in
275	*-apple-*)
276		fool_libtool=no
277		;;
278	*)
279		;;
280esac
281
282dnl ----------------------------------------------------------------
283dnl
284dnl Checks for programs.
285dnl
286AC_PROG_CC
287if test "x$CC" = "x" ; then
288	AC_MSG_ERROR([Need a working C compiler])
289fi
290AC_PROG_CXX
291if test "x$CXX" = "x" ; then
292	AC_MSG_ERROR([Need a working C++ compiler])
293fi
294AC_PROG_FC
295AC_FC_DUMMY_MAIN
296AC_FC_LIBRARY_LDFLAGS
297if test "x$FC" = "x" ; then
298	AC_PROG_F77
299	if test "x$F77" = "x" ; then
300		AC_MSG_ERROR([Need a working Fortran compiler])
301	fi
302	AC_F77_LIBRARY_LDFLAGS
303	LIBS="$LIBS $F77LIBS"
304else
305	F77="$FC"
306	F77LIBS="$FCLIBS"
307	LIBS="$LIBS $FCLIBS"
308fi
309
310if test "$GCC" = "yes" ; then
311	dnl check for 3.3
312	AC_MSG_CHECKING(for gcc version = 3.3)
313	AC_CACHE_VAL(ac_cv_gcc33,
314	AC_LANG_SAVE
315	AC_LANG_CPLUSPLUS
316	[AC_TRY_COMPILE(
317	[#if !(__GNUC__ == 3 && __GNUC_MINOR__ == 3)
318	#error GCC is not 3.3 (good news ;)
319	#endif],
320	[return 0;],
321	[ac_cv_gcc33=yes],
322	[ac_cv_gcc33=no])]
323	AC_LANG_RESTORE)
324	if [[ $ac_cv_gcc33 = no ]]; then
325		AC_MSG_RESULT([no])
326
327		dnl then check for 3.2
328		AC_MSG_CHECKING(for gcc version = 3.2)
329		AC_CACHE_VAL(ac_cv_gcc32,
330		AC_LANG_SAVE
331		AC_LANG_CPLUSPLUS
332		[AC_TRY_COMPILE(
333		[#if !(__GNUC__ == 3 && __GNUC_MINOR__ == 2)
334		#error GCC is not 3.2 (good news ;)
335		#endif],
336		[return 0;],
337		[ac_cv_gcc32=yes],
338		[ac_cv_gcc32=no])]
339		AC_LANG_RESTORE)
340		if [[ $ac_cv_gcc32 = no ]]; then
341			AC_MSG_RESULT([no])
342		else
343			AC_DEFINE(MBDYN_X_WORKAROUND_GCC_3_2,1,[define to workaround known GCC 3.2 bug])
344			AC_MSG_RESULT([ok])
345		fi
346	else
347		AC_DEFINE(MBDYN_X_WORKAROUND_GCC_3_3,1,[define to workaround known GCC 3.3 bug])
348		AC_MSG_RESULT([ok])
349	fi
350fi
351
352dnl AM_DISABLE_SHARED dnl Remove when you want to build shared libs also
353AM_PROG_LIBTOOL
354
355dnl ----------------------------------------------------------------
356dnl
357dnl Initialize vars
358dnl
359MPI_LIBS=
360METIS_LIBS=
361CHACO_LIBS=
362Y12_LIBS=
363UMFPACK_LIBS=
364KLU_LIBS=
365BLAS_LIBS=
366THREAD_LIBS=
367ATOMIC_OPS_LIBS=
368MESCHACH_LIBS=
369SUPERLU_LIBS=
370WSMP_LIBS=
371HARWELL_LIBS=
372LAPACK_LIBS=
373TAUCS_LIBS=
374ARPACK_LIBS=
375JDQZ_LIBS=
376SECURITY_LIBS=
377NETCDF_LIBS=
378UDUNITS_LIBS=
379RTAI_LDFLAGS=
380RT_LIBS=
381ANN_LIBS=
382BULLET_LIBS=
383PYTHON_NUMPY_HEADERS=
384OCTAVE_LIBS=
385OCTAVE_INCLUDE=
386dnl GINACLIB_CONFIG=
387GINACLIB_LIBS=
388GINACLIB_CPPFLAGS=
389wl=
390EXPORT_DYNAMIC_FLAG_SPEC=
391
392dnl MODULES_DIRS=
393MODULE_LOADPATH=
394
395dnl ----------------------------------------------------------------
396dnl
397dnl MBDyn requires STDC features
398dnl
399AM_PROG_CC_STDC
400if test "X${am_cv_prog_cc_stdc}" = "Xno" ; then
401	AC_MSG_ERROR([I'm afraid MBDyn requires compiler to support STDC constructs.])
402fi
403
404dnl ----------------------------------------------------------------
405dnl
406dnl Checks for header files.
407dnl
408AC_STDC_HEADERS
409AC_CHECK_HEADERS(arpa/inet.h)
410AC_CHECK_HEADERS(atomic_ops.h)
411AC_CHECK_HEADERS(cxxabi.h)
412AC_CHECK_HEADERS(fenv.h)
413AC_CHECK_HEADERS(getopt.h)
414AC_CHECK_HEADERS(netdb.h)
415AC_CHECK_HEADERS(netinet/in.h)
416AC_CHECK_HEADERS(pwd.h)
417AC_CHECK_HEADERS(pthread.h)
418AC_CHECK_HEADERS(sched.h)
419AC_CHECK_HEADERS(semaphore.h)
420AC_CHECK_HEADERS(signal.h)
421AC_CHECK_HEADERS(stdint.h)
422AC_CHECK_HEADERS(stdio.h)
423AC_CHECK_HEADERS(stdlib.h)
424AC_CHECK_HEADERS(string.h)
425AC_CHECK_HEADERS(sys/ipc.h)
426AC_CHECK_HEADERS(sys/mman.h)
427AC_CHECK_HEADERS(sys/param.h)
428AC_CHECK_HEADERS(sys/poll.h)
429AC_CHECK_HEADERS(sys/pstat.h)
430AC_CHECK_HEADERS(sys/select.h)
431AC_CHECK_HEADERS(sys/shm.h)
432AC_CHECK_HEADERS(sys/socket.h)
433AC_CHECK_HEADERS(sys/sysinfo.h)
434AC_CHECK_HEADERS(sys/times.h)
435AC_CHECK_HEADERS(sys/types.h)
436AC_CHECK_HEADERS(sys/ioctl.h)
437AC_CHECK_HEADERS(time.h)
438AC_CHECK_HEADERS(unistd.h)
439AC_CHECK_HEADERS(values.h)
440
441
442dnl ----------------------------------------------------------------
443dnl
444dnl Checks for C++ header files (takes care of ANSI/pre-ANSI naming)
445dnl
446AC_LANG_CPLUSPLUS
447
448AC_CHECK_HEADERS(exception)
449AC_CHECK_HEADERS(stdexcept)
450AC_LANG_C
451
452dnl ----------------------------------------------------------------
453dnl
454dnl Typedefs
455dnl
456
457dnl ----------------------------------------------------------------
458dnl
459dnl Set symbol table for Math Parser
460dnl
461AC_DEFINE(USE_TABLE,1,[define this to use external symbol table (default)])
462
463dnl ----------------------------------------------------------------
464dnl
465dnl Set inter-language naming convention for calling Fortran routines
466dnl
467AC_DEFINE(USE_UNDERSCORE,1,[append underscore to fortran calls])
468
469dnl ----------------------------------------------------------------
470dnl
471dnl Check for DEBUG
472dnl
473if test "$ol_enable_debug_mpi" != no ; then
474	AC_DEFINE(DEBUG_MPI,1,[define this to add MPI debugging code])
475fi
476if test "$ol_enable_debug" != no -o "$ol_enable_debug_mpi" != no ; then
477	AC_DEFINE(DEBUG,1,[define this to add debugging code])
478	if test "$ol_with_debug_mode" = "mem" ; then
479		AC_DEFINE(DEBUG_MEMMANAGER,1,[define this to add memory debugging code])
480	fi
481fi
482
483have_environ=no
484AC_TRY_COMPILE([
485],[
486	environ;
487], [have_environ=yes], [have_environ=no])
488if test $have_environ != yes ; then
489	AC_TRY_COMPILE([
490#include <unistd.h>
491	],[
492	environ;
493	], [have_environ=yes], [have_environ=no])
494	if test $have_environ = yes ; then
495		AC_DEFINE(ENVIRON_NEEDS_UNISTD_H,1,[define if variable environ needs unistd.h])
496	fi
497fi
498if test $have_environ != yes ; then
499	AC_TRY_COMPILE([
500#define _GNU_SOURCE
501#include <unistd.h>
502	],[
503	environ;
504	], [have_environ=yes], [have_environ=no])
505	if test $have_environ = yes ; then
506		AC_DEFINE(ENVIRON_NEEDS_GNU_SOURCE_AND_UNISTD_H,1,[define if variable environ needs _GNU_SOURCE and unistd.h])
507	fi
508fi
509if test $have_environ != yes ; then
510	AC_TRY_LINK([
511extern char **environ;
512	],[
513	environ;
514	],[have_environ=yes],[have_environ=no])
515	if test $have_environ = yes ; then
516		AC_DEFINE(ENVIRON_NEEDS_DECLARATION,1,[define if variable environ needs to be declared])
517	fi
518fi
519if test $have_environ = yes; then
520	AC_DEFINE(HAVE_ENVIRON,1,[define if variable environ is declared])
521fi
522
523dnl try to detect MPI and either Metis or Chaco
524use_schur=no
525if test "$ol_enable_schur" = yes ; then
526	case "$ol_with_mpi" in
527	no)
528		AC_MSG_ERROR([Schur parallel solver needs MPI])
529		;;
530
531	auto)
532		ol_with_mpi=yes
533		;;
534	esac
535
536	dnl add further partitioning package detection code here
537	if test "$ol_with_metis" = no \
538		-a "$ol_with_chaco" = no \
539	; then
540		AC_MSG_WARN([No partitioning library available; Schur parallel solver will only allow manual partitioning.])
541	fi
542fi
543
544dnl ----------------------------------------------------------------
545dnl
546dnl Enable NetCDF binary output
547dnl
548if test "$ol_enable_netcdf" != no ; then
549	have_netcdf=no
550	have_libnetcdf=no
551	AC_LANG_CPLUSPLUS
552	AC_CHECK_HEADER(netcdfcpp.h,[have_netcdfcpp_h=yes],[have_netcdfcpp_h=no])
553	AC_LANG_C
554	if test $have_netcdfcpp_h = "yes" ; then
555		AC_DEFINE(HAVE_NETCDFCPP_H,1,[must include <netcdfcpp.h> to use NetCDF C++ support])
556		save_LIBS="$LIBS"
557		try_NETCDF_LIBS="-lnetcdf_c++ -lnetcdf"
558		LIBS="$try_NETCDF_LIBS $LIBS"
559		AC_LANG_CPLUSPLUS
560		AC_TRY_LINK([
561#include <netcdfcpp.h>
562			],[
563	/* test for netcdf */
564	NcFile nc("foobar", NcFile::Replace); // Create and leave in define mode
565			],[
566				have_libnetcdf=yes
567				NETCDF_LIBS="$try_NETCDF_LIBS"
568			])
569		AC_LANG_C
570		LIBS="$save_LIBS"
571	else
572		dnl apparently, NetCDF 4 only needs header <netcdf.h>
573		dnl and thus does not provide <netcdfcpp.h> any longer
574		AC_LANG_CPLUSPLUS
575		AC_CHECK_HEADER(netcdf.h,[have_netcdf_h=yes],[have_netcdf_h=no])
576		AC_LANG_C
577		if test $have_netcdf_h = "yes" ; then
578			AC_DEFINE(HAVE_NETCDF_H,1,[<netcdf.h> suffices to use NetCDF C++ support])
579			save_LIBS="$LIBS"
580			try_NETCDF_LIBS="-lnetcdf_c++4 -lnetcdf"
581			LIBS="$try_NETCDF_LIBS $LIBS"
582			AC_LANG_CPLUSPLUS
583			AC_TRY_LINK([
584#include <netcdf.h>
585				],[
586		/* test for netcdf */
587		NcFile nc("foobar", NcFile::Replace); // Create and leave in define mode
588				],[
589					have_libnetcdf=yes
590					NETCDF_LIBS="$try_NETCDF_LIBS"
591				])
592			AC_LANG_C
593			LIBS="$save_LIBS"
594		fi
595	fi
596
597	if test $have_libnetcdf = yes ; then
598		AC_DEFINE(USE_NETCDF,1,[define this to enable NetCDF based output])
599	elif test $ol_enable_netcdf != auto ; then
600		AC_MSG_ERROR([Could not locate netcdfcpp.h/netcdf.h header])
601	fi
602
603	have_udunits=no
604	have_libudunits=no
605	AC_CHECK_HEADER(udunits.h,[have_udunits_h=yes],[have_udunits_h=no])
606	if test $have_udunits_h = "yes" ; then
607		save_LIBS="$LIBS"
608		try_UDUNITS_LIBS="-ludunits"
609		LIBS="$try_UDUNITS_LIBS $LIBS"
610		AC_CHECK_LIB(udunits,utInit,[
611			have_libudunits=yes
612			UDUNITS_LIBS="$try_UDUNITS_LIBS"
613		],[have_libudunits=no],[-lm])
614		LIBS="$save_LIBS"
615	fi
616
617	if test $have_libudunits = yes ; then
618		AC_DEFINE(USE_UDUNITS,1,[define this to enable udunits in NetCDF based output])
619	fi
620fi
621
622dnl ----------------------------------------------------------------
623dnl
624dnl Enable Python support
625dnl
626use_python=no
627if test "$ol_enable_python" != no ; then
628	AX_PYTHON_DEVEL
629	dnl ----------------------------------------------------------------
630	dnl
631	dnl detect and configure swig for python bindings
632	dnl
633	dnl AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG required]) ])
634	AX_PKG_SWIG
635
636	if test x"$SWIG" = x -a "$ol_enable_python" = yes ; then
637		AC_MSG_ERROR([python needs swig])
638	fi
639	if test "$ol_enable_python" = yes ; then
640	        PYTHON_NUMPY_HEADERS=`$PYTHON -c "import numpy; print numpy.get_include()" 2>/dev/null`
641		if test x"$PYTHON_NUMPY_HEADERS" = x ; then
642			AC_MSG_ERROR([python needs numpy - including its development packages])
643		else
644			PYTHON_NUMPY_HEADERS="-I$PYTHON_NUMPY_HEADERS"
645		fi
646	fi
647
648	AX_SWIG_ENABLE_CXX
649	AX_SWIG_MULTI_MODULE_SUPPORT
650	AX_SWIG_PYTHON
651
652	use_python=yes
653fi
654
655dnl ----------------------------------------------------------------
656dnl
657dnl Enable Octave support <http://www.octave.org/>
658dnl
659use_octave=no
660if test "$ol_enable_octave" != no ; then
661	have_mkoctfile=no
662	which mkoctfile > /dev/null 2>&1
663	RC=$?
664	if test "$RC" = 0 ; then
665		have_mkoctfile=yes
666     	try_OCTAVE_LIBS="`mkoctfile -p OCTAVE_LIBS` `mkoctfile -p LFLAGS`"
667     	try_OCTAVE_INCLUDE="`mkoctfile -p INCFLAGS`"
668       export LD_LIBRARY_PATH="`mkoctfile -p OCTLIBDIR`:${LD_LIBRARY_PATH}"
669    else
670    	try_OCTAVE_LIBS="-loctinterp -loctave -lcruft"
671    	try_OCTAVE_INCLUDE=
672	fi
673
674	AC_LANG_CPLUSPLUS
675	save_CXXFLAGS="$CXXFLAGS"
676	CXXFLAGS="$CXXFLAGS $try_OCTAVE_INCLUDE"
677	AC_CHECK_HEADER(octave/oct.h,[have_octave_oct_h=yes],[have_octave_oct_h=no])
678	AC_CHECK_HEADER(octave/parse.h,[have_octave_parse_h=yes],[have_octave_parse_h=no],[
679#include <octave/oct.h>
680		])
681	AC_CHECK_HEADER(octave/toplev.h,[have_octave_toplev_h=yes],[have_octave_toplev_h=no],[
682#include <octave/oct.h>
683		])
684	AC_CHECK_HEADER(octave/octave.h,[have_octave_octave_h=yes],[have_octave_octave_h=no],[
685#include <octave/oct.h>
686		])
687	CXXFLAGS="$save_CXXFLAGS"
688	AC_LANG_C
689
690	link_octave="no"
691	if test "$have_octave_oct_h" = "yes" \
692		-a "$have_octave_parse_h" = "yes" \
693		-a "$have_octave_toplev_h" = "yes" \
694		-a "$have_octave_octave_h" = "yes" \
695		-a "$have_mkoctfile" = "yes" ; \
696	then
697		OCTAVE_INCLUDE="$try_OCTAVE_INCLUDE"
698		save_CXXFLAGS="$CXXFLAGS"
699		save_LIBS="$LIBS"
700		try_LIBS="$try_OCTAVE_LIBS"
701		LIBS="$try_LIBS $LIBS"
702		CXXFLAGS="$CXXFLAGS $OCTAVE_INCLUDE"
703		AC_LANG_CPLUSPLUS
704		AC_TRY_LINK([
705#include <octave/oct.h>
706#include <octave/parse.h>
707#include <octave/toplev.h>
708#include <octave/octave.h>
709			],[
710		octave_main(0, NULL, 1);
711			],[link_octave="yes"])
712		AC_LANG_CPLUSPLUS
713		AC_TRY_LINK([
714#include <octave/oct.h>
715#include <octave/parse.h>
716#include <octave/toplev.h>
717#include <octave/octave.h>
718			],[
719		do_octave_atexit();
720			],[have_do_octave_atexit="yes"])
721		AC_LANG_CPLUSPLUS
722		AC_TRY_LINK([
723#include <octave/oct.h>
724#include <octave/parse.h>
725#include <octave/toplev.h>
726#include <octave/octave.h>
727			],[
728		clean_up_and_exit(0, true);
729			],[have_clean_up_and_exit="yes"])
730		AC_LANG_C
731		LIBS="$save_LIBS"
732		CXXFLAGS="$save_CXXFLAGS"
733		OCTAVE_LIBS="$try_LIBS"
734	fi
735
736	if test "$link_octave" = yes ; then
737		if test "$have_do_octave_atexit" = yes; then
738			AC_DEFINE(HAVE_DO_OCTAVE_ATEXIT, 1, [define if do_octave_atexit can be used])
739		fi
740		if test "$have_clean_up_and_exit" = yes; then
741			AC_DEFINE(HAVE_CLEAN_UP_AND_EXIT, 1, [define if clean_up_and_exit can be used])
742		fi
743		use_octave=yes
744		AC_DEFINE(USE_OCTAVE, 1, [define if octave can be used])
745	else
746		if test "$ol_enable_octave" = "yes" ; then
747			AC_MSG_ERROR([octave support not available])
748		fi
749	fi
750fi
751
752if test "$ol_enable_autodiff" != no ; then
753	AC_DEFINE(USE_AUTODIFF, 1, [define if automatic differentiation can be used in order to compute the Jacobian matrix])
754
755	AC_MSG_CHECKING([for posix_memalign])
756	AC_TRY_LINK([
757#include <stdlib.h>
758				],[
759void *p;
760posix_memalign(&p, 32, 1024);
761			],[have_posix_memalign="yes"])
762
763	if test "$have_posix_memalign" == "yes"; then
764		AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, [define if posix_memalign can be used])
765		AC_MSG_RESULT([yes])
766	else
767		AC_MSG_RESULT([no])
768	fi
769
770	AC_MSG_CHECKING([for memalign])
771	AC_TRY_LINK([
772#include <stdlib.h>
773				],[
774void* p = memalign(32, 1024);
775				],[have_memalign="yes"])
776
777	if test "$have_memalign" == "yes"; then
778		AC_DEFINE(HAVE_MEMALIGN, 1, [define if memalign can be used])
779		AC_MSG_RESULT([yes])
780	else
781		AC_MSG_RESULT([no])
782	fi
783
784	AC_MSG_CHECKING([for _aligned_malloc and _aligned_free])
785	AC_TRY_LINK([
786#include <stdlib.h>
787				],[
788void* p = _aligned_malloc(1024, 32);
789_aligned_free(p);
790				],[have_aligned_malloc="yes"])
791
792	if test "$have_aligned_malloc" == "yes"; then
793		AC_DEFINE(HAVE_ALIGNED_MALLOC, 1, [define if _aligned_malloc and _aligned_free can be used])
794		AC_MSG_RESULT([yes])
795	else
796		AC_MSG_RESULT([no])
797	fi
798
799	if test "$ol_enable_autodiff_vect" == 0 ; then
800		save_CXXFLAGS="$CXXFLAGS"
801		vector_flags="-O3 -march=native -mtune=native"
802		CXXFLAGS="$CXXFLAGS $vector_flags"
803
804		AC_LANG_CPLUSPLUS
805		AC_TRY_RUN([
806#include <ctime>
807#include <cassert>
808#include <cstdlib>
809#include <iostream>
810#include <limits>
811#include <new>
812#include <iomanip>
813#include <fstream>
814using namespace std;
815
816template <typename scalar_type, int VECTOR_SIZE>
817class vector
818{
819public:
820    static const int vec_size = VECTOR_SIZE / sizeof(scalar_type);
821    typedef scalar_type __attribute__((vector_size(VECTOR_SIZE))) vector_type;
822
823    vector(int n)
824    {
825        N = n / vec_size;
826
827        if (n % vec_size != 0)
828        {
829            ++N;
830        }
831
832        void* p;
833
834#if HAVE_POSIX_MEMALIGN == 1
835    	if (0 != posix_memalign(&p, sizeof(vector_type), vector_size() * sizeof(vector_type)))
836    	{
837    		p = 0;
838    	}
839#elif HAVE_ALIGNED_MALLOC == 1
840        p = _aligned_malloc(vector_size() * sizeof(vector_type), sizeof(vector_type));
841#elif HAVE_MEMALIGN == 1
842    	p = memalign(sizeof(vector_type), vector_size() * sizeof(vector_type));
843#else
844		p = malloc(vector_size() * sizeof(vector_type));
845#endif
846
847        v = reinterpret_cast<vector_type*>(p);
848
849        if (v == 0)
850            throw std::bad_alloc();
851    }
852
853    ~vector()
854    {
855#if HAVE_ALIGNED_MALLOC == 1
856        _aligned_free(v);
857#else
858    	free(v);
859#endif
860    }
861
862    int size() const { return N * vec_size; }
863
864    int vector_size() const { return N; }
865
866    vector_type& operator[](int i)
867    {
868        return v[i];
869    }
870
871    const vector_type& operator[](int i) const
872    {
873        return v[i];
874    }
875
876    scalar_type& operator()(int i)
877    {
878        return s[i];
879    }
880
881    const scalar_type& operator()(int i) const
882    {
883        return s[i];
884    }
885private:
886    union {
887        scalar_type* s;
888        vector_type* v;
889    };
890    int N;
891};
892
893template <typename T, int VECTOR_SIZE>
894T func_vec(const T a, const T b, const vector<T,VECTOR_SIZE>& ad, const vector<T,VECTOR_SIZE>& bd,  vector<T,VECTOR_SIZE>& cd)
895{
896    for (int i = 0; i < ad.vector_size(); ++i)
897    {
898        cd[i] = ad[i] * b + a * bd[i];
899    }
900
901    return a * b;
902}
903
904template<typename T, int VECTOR_SIZE>
905clock_t testVector(int N, int M)
906{
907    T a, b, c;
908
909    a = 10;
910    b = 5;
911    vector<T,VECTOR_SIZE> ad(N), bd(N), cd(N);
912
913    for (int i = 0; i < ad.size(); ++i)
914    {
915        ad(i) = i + 1;
916        bd(i) = 10 * (i + 1);
917    }
918
919    const clock_t start = clock();
920
921    for (int i = 0; i < M; ++i)
922        c = func_vec(a, b, ad, bd, cd);
923
924    const clock_t dt = clock() - start;
925
926    assert(c == a * b);
927    for (int i = 0; i < ad.size(); ++i)
928    {
929        assert(cd(i) == ad(i) * b + bd(i) * a);
930    }
931
932    return dt;
933}
934
935int vec_size = 0;
936clock_t tmin = std::numeric_limits<clock_t>::max();
937
938template <int i>
939void runTest(int N, int M, clock_t t[])
940{
941    const int iprev = i - 1;
942    runTest<iprev>(N, M, t);
943    const int K = 1 << (i + 3);
944
945    cout << "checking for vector_size=" << setw(3) << K << " ... ";
946
947    t[i] = testVector<double, K>(N, M);
948
949    cout << "[OK] t=" << setw(5) << t[i] << endl;
950
951    if (t[i] < tmin)
952    {
953        tmin = t[i];
954        vec_size = K;
955        ofstream("grad_vector_size.dat") << K;
956    }
957}
958
959template <>
960void runTest<-1>(int N, int M, clock_t t[])
961{
962}
963
964int main(int argc, char* argv[])
965{
966    int N = 1024;
967    int M = 1000000;
968
969    if (argc > 1)
970        N = atoi(argv[1]);
971
972    if (argc > 2)
973        M = atoi(argv[2]);
974
975    const int K = 3;
976    clock_t t[K];
977
978    ofstream("grad_vector_size.dat") << 0;
979
980    runTest<K>(N, M, t);
981
982    cout << "result: optimum(vector_size)=" << vec_size << endl;
983    return 0;
984}					],
985					[],
986					[printf "[FAILED]\n"])
987
988		if test -f grad_vector_size.dat; then
989			ol_enable_autodiff_vect=`cat grad_vector_size.dat`
990
991			if test -z "$ol_enable_autodiff_vect"; then
992				ol_enable_autodiff_vect=0
993			fi
994
995			rm grad_vector_size.dat
996		fi
997
998		CXXFLAGS="$save_CXXFLAGS"
999		AC_LANG_C
1000	fi
1001
1002	case "$ol_enable_autodiff_vect" in
1003	16)
1004		AC_DEFINE(GRADIENT_VECTOR_REGISTER_SIZE, 16, [the number of bytes of an avx or sse register])
1005		AC_MSG_RESULT([vectorization of derivatives will use 16 byte vectors])
1006		;;
1007	32)
1008		AC_DEFINE(GRADIENT_VECTOR_REGISTER_SIZE, 32, [the number of bytes of an avx or sse register])
1009		AC_MSG_RESULT([vectorization of derivatives will use 32 byte vectors])
1010		;;
1011	64)
1012		AC_DEFINE(GRADIENT_VECTOR_REGISTER_SIZE, 64, [the number of bytes of an avx or sse register])
1013		AC_MSG_RESULT([vectorization of derivatives will use 64 byte vectors])
1014		;;
1015	*)
1016		AC_DEFINE(GRADIENT_VECTOR_REGISTER_SIZE, 0, [the number of bytes of an avx or sse register])
1017		AC_MSG_WARN([vectorization of derivatives is not possible])
1018	esac
1019fi
1020
1021dnl ----------------------------------------------------------------
1022dnl
1023dnl Enable blitz++ support <http://oonumerics.org/blitz/>
1024dnl
1025AC_LANG_CPLUSPLUS
1026AC_CHECK_HEADER(blitz/blitz.h,[have_blitz_blitz_h=yes],[have_blitz_blitz_h=no])
1027AC_CHECK_HEADER(blitz/array.h,[have_blitz_array_h=yes],[have_blitz_array_h=no])
1028AC_CHECK_HEADER(blitz/tinyvec.h,[have_blitz_tinyvec_h=yes],[have_blitz_tinyvec_h=no])
1029AC_CHECK_HEADER(blitz/tinyvec-et.h,[have_blitz_tinyvecet_h=yes],[have_blitz_tinyvecet_h=no])
1030AC_CHECK_HEADER(blitz/tinymat.h,[have_blitz_tinymat_h=yes],[have_blitz_tinymat_h=no])
1031AC_CHECK_HEADER(blitz/matrix.h,[have_blitz_matrix_h=yes],[have_blitz_matrix_h=no])
1032AC_LANG_C
1033
1034if test "$have_blitz_blitz_h" = "yes" \
1035	-a "$have_blitz_array_h" = "yes" \
1036	-a "$have_blitz_tinyvec_h" = "yes" \
1037	-a "$have_blitz_tinyvecet_h" = "yes" \
1038	-a "$have_blitz_tinymat_h" = "yes" \
1039	-a "$have_blitz_matrix_h" = "yes"; \
1040then
1041	AC_DEFINE(HAVE_BLITZ, 1, [define if blitz++ can be used])
1042fi
1043
1044dnl ----------------------------------------------------------------
1045dnl
1046dnl Check for POSIX realtime
1047dnl
1048if test $ol_with_rt != no ; then
1049	save_LIBS="$LIBS"
1050	try_RT_LIBS="-lrt"
1051	LIBS="$try_RT_LIBS $LIBS"
1052	AC_CHECK_LIB(rt,clock_nanosleep,[
1053		have_librt=yes
1054		RT_LIBS="$try_RT_LIBS"
1055	],[have_librt=no])
1056
1057	if test "$have_librt" = "yes" ; then
1058		AC_DEFINE(USE_RT,1,[define to use POSIX realtime])
1059
1060        dnl ----------------------------------------------------------------
1061        dnl
1062        dnl Check for clock_gettime()
1063        dnl
1064        AC_TRY_LINK([
1065        #include <time.h>
1066                    ],[
1067            struct timespec tp;
1068            clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp);
1069                    ],[use_clock_gettime=yes],[use_clock_gettime=no])
1070
1071        if test $use_clock_gettime = yes; then
1072            AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [define if clock_gettime can be used])
1073        fi
1074	elif test "$ol_with_rt" = "yes" ; then
1075		AC_MSG_ERROR([POSIX realtime is not available])
1076	fi
1077
1078    LIBS="$save_LIBS"
1079fi
1080
1081dnl ----------------------------------------------------------------
1082dnl
1083dnl Check for RTAI
1084dnl
1085use_rtai=no
1086if test $ol_with_rtai != no ; then
1087
1088	dnl RTAI >= 3.0
1089	AC_CHECK_HEADERS(rtai_lxrt.h)
1090	AC_CHECK_HEADERS(rtai_netrpc.h)
1091
1092	if test "$ac_cv_header_rtai_lxrt_h" = "yes" -a \
1093			"$ac_cv_header_rtai_netrpc_h" = "yes" ; then
1094		use_rtai=yes
1095	else
1096		dnl RTAI ~ 2.4.13
1097		AC_CHECK_HEADERS(rtai_lxrt_user.h)
1098		AC_CHECK_HEADERS(net_rpc.h)
1099		if test "$ac_cv_header_rtai_lxrt_user_h" = "yes" -a \
1100				"$ac_cv_header_net_rpc_h" = "yes" ; then
1101			use_rtai=yes
1102		else
1103			rtai_mismatch=no
1104			if test "$ac_cv_header_rtai_lxrt_h" = "yes" -a \
1105					"$ac_cv_header_rtai_netrpc_h" = "no" ; then
1106				rtai_mismatch=yes
1107			elif test "$ac_cv_header_rtai_lxrt_user_h" = "yes" -a \
1108					"$ac_cv_header_net_rpc_h" = "no" ; then
1109				rtai_mismatch=yes
1110			fi
1111
1112			if test "$rtai_mismatch" = "yes" ; then
1113				AC_MSG_WARN([possible RTAI version mismatch; YMMV])
1114			fi
1115
1116		fi
1117	fi
1118
1119	dnl FIXME: no longer used
1120	dnl FIXME: is this correct for >= 3.0 as well?
1121	dnl AC_CHECK_HEADERS(rtai_usp_posix.h)
1122	dnl AC_CHECK_HEADERS(rtai_posix.h)
1123	dnl if test "$ac_cv_header_rtai_usp_posix_h" = "no" -o \
1124	dnl 		"$ac_cv_header_rtai_posix_h" = "no" ; then
1125	dnl 	use_rtai=no
1126	dnl fi
1127	if test "$use_rtai" = "yes" ; then
1128		AC_DEFINE(USE_RTAI,1,[define to use RTAI])
1129	elif test "$ol_with_rtai" = "yes" ; then
1130		AC_MSG_ERROR([RTAI is not available])
1131	fi
1132
1133	RTAI_CONFIG=`which rtai-config`
1134	RC=$?
1135	if test $RC = 0 ; then
1136		RTAI_LDFLAGS=`$RTAI_CONFIG --lxrt-ldflags`
1137	fi
1138fi
1139
1140dnl ----------------------------------------------------------------
1141dnl
1142dnl Checks for working offsetof
1143dnl
1144have_offsetof=no
1145AC_MSG_CHECKING([for offsetof])
1146AC_TRY_COMPILE([#include <stddef.h>],[
1147	struct dummy_t { int dummy; };
1148	(void)offsetof(struct dummy_t, dummy);
1149],[have_offsetof=yes],[have_offsetof=no])
1150if test $have_offsetof != no ; then
1151	AC_DEFINE(HAVE_OFFSETOF,1, [define if offsetof() works])
1152	AC_MSG_RESULT([yes])
1153else
1154	AC_MSG_RESULT([no])
1155fi
1156
1157dnl ----------------------------------------------------------------
1158dnl
1159dnl Checks for socket
1160dnl
1161AC_CHECK_FUNC(socket,[have_socket=yes],[have_socket=no])
1162use_socket=no
1163if test "$have_socket" = "yes" ; then
1164	AC_DEFINE(HAVE_SOCKET,1,[define if socket() is available])
1165	AC_DEFINE(USE_SOCKET,1,[define if socket() can be used])
1166	use_socket=yes
1167
1168	if test $have_socket != no ; then
1169		AC_MSG_CHECKING([for socklen_t])
1170		AC_TRY_COMPILE([#include <sys/socket.h>],[
1171			socklen_t l;
1172		],[have_socklen_t=yes],[have_socklen_t=no])
1173		if test $have_socklen_t != no ; then
1174			AC_DEFINE(HAVE_SOCKLEN_T,1,
1175				[define if typedef socklen_t is defined])
1176			AC_MSG_RESULT([yes])
1177		else
1178			AC_MSG_RESULT([no])
1179		fi
1180	fi
1181fi
1182
1183dnl ----------------------------------------------------------------
1184dnl
1185dnl Check for sig_atomic_t
1186dnl
1187AC_MSG_CHECKING([for sig_atomic_t])
1188AC_TRY_COMPILE([#include <signal.h>],[
1189	sig_atomic_t	atom;
1190	],[
1191		AC_DEFINE(HAVE_SIG_ATOMIC_T,1,[define if sig_atomic_t is available])
1192		AC_MSG_RESULT([yes])
1193	],[
1194		AC_MSG_RESULT([no])
1195	])
1196
1197dnl ----------------------------------------------------------------
1198dnl
1199dnl Check for bool
1200dnl
1201AC_LANG_CPLUSPLUS
1202AC_MSG_CHECKING([whether bool is defined])
1203AC_TRY_COMPILE([],[
1204	bool b;
1205],[have_bool=yes],[have_bool=no])
1206if test $have_bool != no ; then
1207	AC_DEFINE(HAVE_BOOL,1,[define if bool is defined])
1208	AC_MSG_RESULT([yes])
1209else
1210	AC_MSG_RESULT([no])
1211	AC_MSG_CHECKING([whether bool needs bool.h])
1212	AC_TRY_COMPILE([],[
1213	#include <bool.h>
1214	bool b;
1215	],[need_bool_h=yes],[need_bool_h=no])
1216	if test $need_bool_h != no ; then
1217	        AC_DEFINE(NEED_BOOL_H,1,[define if bool needs bool.h])
1218		AC_MSG_RESULT([yes])
1219	else
1220	        AC_MSG_RESULT([no])
1221	fi
1222fi
1223AC_LANG_C
1224
1225dnl ----------------------------------------------------------------
1226dnl
1227dnl Check for exceptions
1228dnl
1229AC_LANG_CPLUSPLUS
1230AC_MSG_CHECKING([whether the C++ compiler handles exceptions])
1231AC_TRY_COMPILE([],[
1232	try {
1233		(void *)0;
1234	}
1235	catch (...) {
1236		(void *)0;
1237	}
1238],[have_exceptions=yes],[have_exceptions=no])
1239if test "$have_exceptions" = "yes" ; then
1240	AC_MSG_RESULT([yes])
1241else
1242	AC_MSG_ERROR([C++ compiler does not handle exceptions])
1243fi
1244AC_LANG_C
1245
1246dnl ----------------------------------------------------------------
1247dnl
1248dnl Check for std namespace
1249dnl
1250
1251AC_LANG_CPLUSPLUS
1252AC_MSG_CHECKING([whether the C++ compiler allows to use namespace std])
1253AC_TRY_COMPILE([
1254	#include <math.h>
1255	using namespace std;
1256],[
1257	sqrt(2.);
1258],[allow_std=yes],[allow_std=no])
1259if test $allow_std != no ; then
1260	AC_DEFINE(USING_STD,1,[define if C++ compiler allows namespace std])
1261	AC_MSG_RESULT([yes])
1262else
1263	AC_MSG_RESULT([no])
1264fi
1265AC_LANG_C
1266
1267dnl ----------------------------------------------------------------
1268dnl
1269dnl Check for threads (check anyway...)
1270dnl
1271have_threads="no"
1272if test "$ol_with_threads" != "no" ; then
1273	AX_PTHREAD([have_threads="yes"],[have_threads="no"])
1274	if test "$ol_with_threads" = "yes" ; then
1275		if test "$have_thread" = "no" ; then
1276			AC_MSG_ERROR([no pthread thread capability detected])
1277		fi
1278	fi
1279	if test "$have_threads" = "yes" ; then
1280		save_LIBS="$LIBS"
1281		save_CXXFLAGS="$CXXFLAGS"
1282		save_CFLAGS="$CFLAGS"
1283		save_CC="$CC"
1284		LIBS="$LIBS $PTHREAD_LIBS"
1285		CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
1286		CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1287		LDFLAGS="$LDFLAGS  $PTHREAD_CFLAGS"
1288		CC="$PTHREAD_CC"
1289		AC_TRY_LINK([
1290				/* Check whether threads really works */
1291				#include <pthread.h>
1292			],[
1293			return pthread_create(0, 0, 0, 0);
1294			],[
1295			],[
1296				LIBS="$save_LIBS"
1297				CXXFLAGS="$save_CXXFLAGS"
1298				CFLAGS="$save_CFLAGS"
1299				CC="$save_CC"
1300				have_threads = "no"
1301				if test "$ol_with_threads" = "yes" ; then
1302					AC_MSG_ERROR([no pthread thread linking capability detected])
1303				fi
1304		])
1305		if test "$have_threads" = "yes" ; then
1306			AC_DEFINE(HAVE_THREADS,1,[define if usable threads are available])
1307			AC_MSG_RESULT([yes])
1308		fi
1309
1310		AC_MSG_CHECKING([for usable pthread_setaffinity_np])
1311		AC_TRY_LINK([
1312				#define _GNU_SOURCE
1313				#include <pthread.h>
1314				#include <sched.h>
1315			],[
1316				cpu_set_t cpuset;
1317				pthread_attr_t attr;
1318
1319				CPU_ZERO(&cpuset);
1320				CPU_SET(0, &cpuset);
1321
1322				pthread_getattr_np(pthread_self(), &attr);
1323				pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
1324				return pthread_getaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
1325			],[
1326				AC_DEFINE(USE_PTHREAD_SETAFFINITY_NP,1,[define to use pthread_setaffinity_np])
1327				AC_MSG_RESULT([yes])
1328			],[
1329				AC_MSG_RESULT([no])
1330		])
1331
1332		AC_MSG_CHECKING([for usable pthread_sigmask])
1333		AC_TRY_LINK([
1334				#include <pthread.h>
1335				#include <signal.h>
1336			],[
1337				sigset_t newset;
1338				sigemptyset(&newset);
1339				sigaddset(&newset, SIGTERM);
1340				pthread_sigmask(SIG_BLOCK, &newset, NULL);
1341			],[
1342				AC_DEFINE(HAVE_PTHREAD_SIGMASK,1,[define to use pthread_sigmask])
1343				AC_MSG_RESULT([yes])
1344			],[
1345				AC_MSG_RESULT([no])
1346		])
1347	fi
1348fi
1349
1350dnl ----------------------------------------------------------------
1351dnl
1352dnl Check for loadable
1353dnl
1354have_runtime_loading=no
1355if test "$ol_enable_runtime_loading" != "no" ; then
1356	AC_CHECK_HEADER(ltdl.h,[have_ltdl_h=yes],[have_ltdl_h=no])
1357	if test $have_ltdl_h = "yes" ; then
1358		AC_DEFINE(HAVE_LTDL_H,1,[define if you have <ltdl.h>])
1359		AC_CHECK_LIB(ltdl, lt_dlinit,[have_lt_dlinit=yes],[have_lt_dlinit=no])
1360		if test $have_lt_dlinit = "yes" ; then
1361			eval `libtool --tag=CC --config|grep '^wl='`
1362			LIBS="$LIBS -lltdl"
1363			EXPORT_DYNAMIC_FLAG_SPEC=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
1364			have_runtime_loading=yes
1365			MODULE_LOADPATH=$libexecdir
1366		fi
1367	fi
1368
1369	if test "$have_runtime_loading" = "yes" ; then
1370		AC_DEFINE(USE_RUNTIME_LOADING,1,[define if you want to load runtime])
1371	else
1372		if test "$ol_enable_runtime_loading" = "yes" ; then
1373			AC_MSG_ERROR([no dynamic linking capability detected])
1374		else
1375			AC_MSG_WARN([no dynamic linking capability detected; runtime loading disabled])
1376		fi
1377	fi
1378fi
1379
1380dnl ----------------------------------------------------------------
1381dnl
1382dnl static modules...
1383dnl
1384build_static_modules=no
1385case "$ol_with_static_modules" in
1386	no)
1387		if test "$have_runtime_loading" != "yes" -a "x$MODULES_DIRS" != "x" ; then
1388			dnl ?!? check
1389			AC_MSG_ERROR([modules cannot be built as dynamic because no runtime loading capability is available])
1390		fi
1391		;;
1392	auto)
1393		if test "$have_runtime_loading" != "yes" ; then
1394			build_static_modules=yes
1395		fi
1396		;;
1397	yes)
1398		build_static_modules=yes
1399		;;
1400	*)
1401		;;
1402esac
1403if test "$build_static_modules" = "yes" ; then
1404	AC_DEFINE(STATIC_MODULES,1,[define to statically build modules])
1405fi
1406
1407build_charm=no
1408if test "$ol_with_charm" != "no" ; then
1409	build_charm=yes
1410	AC_DEFINE(HAVE_CHARM,1,[define to build CHARM WP module])
1411	dnl add test
1412	if test 1 = 1 ; then
1413		AC_DEFINE(NEED_CHARM_SHIPWAKE,1,[define if CHARM WP module needs shipwake])
1414	fi
1415fi
1416
1417dnl ----------------------------------------------------------------
1418dnl
1419dnl Check for build mbc library
1420dnl
1421dnl do not build libmbm if sockets are not available (fixes issue in MinGW)
1422AM_CONDITIONAL(BUILD_MBC,[test "$ol_enable_mbc" = "yes" -a "$have_socket" = "yes"])
1423
1424dnl ----------------------------------------------------------------
1425dnl
1426dnl Check for multithread assembly (use previous checks)
1427dnl
1428ol_link_multithread=no
1429if test "$ol_enable_multithread" != no ; then
1430	if test "$ol_enable_multithread" = "yes" -a "$ol_with_thread" = "no" ; then
1431		AC_MSG_ERROR([Can't enable multithread --without-threads])
1432	fi
1433	AC_MSG_CHECKING([whether to enable multithread])
1434
1435	if test "$ac_cv_header_pthread_h" != "yes" ; then
1436		AC_MSG_ERROR([need pthreads.h])
1437	fi
1438
1439	if test "$ac_cv_header_atomic_ops_h" != "yes" ; then
1440		AC_MSG_ERROR([need atomic_ops.h (from HP's atomic_ops project)])
1441	fi
1442
1443	if test "$have_threads" = no ; then
1444		case "$ol_enable_multithread" in
1445		yes)
1446			AC_MSG_ERROR([No threads available])
1447			;;
1448
1449		force)
1450			have_threads=yes
1451			;;
1452
1453		*)
1454			;; dnl do nothing ...
1455		esac
1456	fi
1457
1458	if test "$have_threads" = no ; then
1459		AC_MSG_RESULT([no])
1460	else
1461		ol_link_multithread=yes
1462		AC_DEFINE(USE_MULTITHREAD,1,[define to enable multithread assembly])
1463		AC_MSG_RESULT([yes])
1464	fi
1465fi
1466
1467dnl ----------------------------------------------------------------
1468dnl
1469dnl Check for multithread naive solver (use previous checks)
1470dnl
1471ol_link_multithread_naive=no
1472if test "$ol_enable_multithread_naive" != no ; then
1473	if test "$ol_enable_multithread_naive" = "yes" -a "$ol_with_thread" = "no" ; then
1474		AC_MSG_ERROR([Can't enable multithread naive solver --without-threads])
1475	fi
1476	AC_MSG_CHECKING([whether to enable multithread naive solver])
1477
1478	if test "$ac_cv_header_pthread_h" != "yes" ; then
1479		AC_MSG_ERROR([need pthreads.h])
1480	fi
1481
1482	if test "$ac_cv_header_atomic_ops_h" != "yes" ; then
1483		AC_MSG_ERROR([need atomic_ops.h (from HP's atomic_ops project)])
1484	fi
1485
1486	if test "$have_threads" = no ; then
1487		case "$ol_enable_multithread_naive" in
1488		yes)
1489			AC_MSG_ERROR([No threads available])
1490			;;
1491
1492		force)
1493			have_threads=yes
1494			;;
1495
1496		*)
1497			;; dnl do nothing ...
1498		esac
1499	fi
1500
1501	if test "$have_threads" = no ; then
1502		AC_MSG_RESULT([no])
1503	else
1504		if test "$ac_cv_header_asm_atomic_h" = no \
1505				-o "$ac_cv_header_asm_bitops_h" = no \
1506				-o "$ac_cv_header_asm_system_h" = no \
1507				; then
1508			AC_MSG_ERROR([missing required system headers])
1509		fi
1510		ol_link_multithread_naive=yes
1511		AC_DEFINE(USE_NAIVE_MULTITHREAD,1,[define to enable multithread naive solver])
1512		AC_MSG_RESULT([yes])
1513	fi
1514fi
1515
1516ol_link_multithread=no
1517if test "$ol_enable_multithread" != no ; then
1518	AC_MSG_CHECKING([for usable threads])
1519
1520	if test "$ac_cv_header_pthread_h" != "yes" ; then
1521		AC_MSG_ERROR([need pthreads.h])
1522	fi
1523
1524	if test "$ac_cv_header_atomic_ops_h" != "yes" ; then
1525		AC_MSG_ERROR([need atomic_ops.h (from HP's atomic_ops project)])
1526	fi
1527
1528	if test "$have_threads" = no ; then
1529		AC_MSG_RESULT([no])
1530		case "$ol_enable_multithread" in
1531		yes)
1532			AC_MSG_ERROR([No threads available])
1533			;;
1534
1535		force)
1536			have_threads=yes
1537			;;
1538
1539		*)
1540			;; dnl do nothing ...
1541		esac
1542	fi
1543
1544	if test "$have_threads" != no ; then
1545		ol_link_multithread=yes
1546		AC_DEFINE(USE_MULTITHREAD,1,[define to enable multithreaded solution])
1547		AC_MSG_RESULT([yes])
1548	fi
1549fi
1550
1551if test "$ol_link_multithread" = "yes" -o "$ol_link_multithread_naive" = "yes" ; then
1552	SAVE_LIBS="$LIBS"
1553	LIBS="$LIBS -latomic_ops_gpl -latomic_ops"
1554	AC_TRY_LINK([#include <atomic_ops.h>], [AO_t t; AO_TS_t tt; AO_compare_and_swap_full(&t, t, t); AO_test_and_set_full(&tt)],[have_atomic_ops=yes],[have_atomic_ops=no],[-latomic_ops])	LIBS="$SAVE_LIBS"
1555	if test $have_atomic_ops = "yes" ; then
1556		AC_DEFINE(HAVE_ATOMIC_OPS,1,[define to use HP's atomic_ops library])
1557	else
1558		AC_MSG_ERROR([Need HP's atomic_ops library for multithreaded features])
1559		ATOMIC_OPS_LIBS="-latomic_ops_gpl -latomic_ops"
1560	fi
1561fi
1562
1563
1564
1565dnl ----------------------------------------------------------------
1566dnl
1567dnl Check for /dev/TASK2CPU
1568dnl
1569AC_MSG_CHECKING([for /dev/TASK2CPU])
1570if test -e "/dev/TASK2CPU" ; then
1571	AC_DEFINE(HAVE_TASK2CPU,1,[define if /dev/TASK2CPU is available])
1572	AC_MSG_RESULT(yes)
1573else
1574	AC_MSG_RESULT(no)
1575fi
1576
1577dnl ----------------------------------------------------------------
1578dnl
1579dnl Check for BOOST
1580dnl
1581ol_link_boost=no
1582if test $ol_with_boost != no ; then
1583	AC_LANG_CPLUSPLUS
1584	AC_CHECK_HEADERS(boost/config.hpp)
1585	if test "$ac_cv_header_boost_config_hpp" = "yes" ; then
1586		AC_DEFINE(USE_BOOST,1,[define to use BOOST])
1587		AC_CHECK_HEADERS(boost/graph/adjacency_list.hpp)
1588		AC_CHECK_HEADERS(boost/graph/cuthill_mckee_ordering.hpp)
1589		AC_CHECK_HEADERS(boost/graph/king_ordering.hpp)
1590		AC_CHECK_HEADERS(boost/graph/sloan_ordering.hpp)
1591		AC_CHECK_HEADERS(boost/graph/properties.hpp)
1592		AC_CHECK_HEADERS(boost/graph/bandwidth.hpp)
1593		AC_CHECK_HEADERS(boost/graph/wavefront.hpp)
1594		AC_CHECK_HEADERS(boost/graph/minimum_degree_ordering.hpp)
1595	else
1596		if test $ol_with_boost != auto ; then
1597			AC_MSG_ERROR([BOOST library headers not available])
1598		fi
1599	fi
1600	AC_LANG_C
1601fi
1602
1603dnl ----------------------------------------------------------------
1604dnl
1605dnl Check for bullet <http://bulletphysics.com>
1606dnl
1607ol_link_bullet=no
1608if test "$ol_with_bullet" != "no" ; then
1609	AC_LANG_CPLUSPLUS
1610	have_libbullet=no
1611	AC_CHECK_HEADER(BulletCollision/CollisionShapes/btCollisionShape.h,[have_bullet_h=yes],[have_bullet_h=no])
1612	if test "$have_bullet_h" = "yes" ; then
1613		SAVE_LIBS="$LIBS"
1614		try_BULLET_LIBS="-lbulletcollision -lbulletmath"
1615		LIBS="$try_BULLET_LIBS $LIBS"
1616		AC_CHECK_LIB(bulletcollision,btBulletCollisionProbe,[
1617			have_libbullet=yes
1618			BULLET_LIBS="$try_BULLET_LIBS"
1619		],[have_libbullet=no],[-lbulletmath])
1620		LIBS="$save_LIBS"
1621	fi
1622
1623	if test $have_libbullet = yes ; then
1624		AC_DEFINE(USE_BULLET,1,[define this to enable bullet <http://bulletphysics.com>])
1625	else
1626		if test "$ol_with_bullet" = "yes" ; then
1627			AC_MSG_ERROR([bullet not available])
1628		fi
1629	fi
1630	AC_LANG_C
1631fi
1632
1633dnl ----------------------------------------------------------------
1634dnl
1635dnl Check for BLAS
1636dnl
1637ol_link_blas=no
1638if test $ol_with_blas != no ; then
1639	dnl FIXME: any standard BLAS headers?
1640	AC_MSG_CHECKING([for BLAS library])
1641
1642	save_LIBS="$LIBS"
1643	have_blas="no"
1644
1645	if test "${ol_with_goto_lib:-set}" = set ; then
1646		dnl in case one relies on a symbolic link named libgoto.{a,so}
1647		ol_with_goto_lib="goto"
1648	fi
1649
1650	try_blas_LIBS=
1651	if test "$have_blas" = "no" ; then
1652		try_blas_LIBS="-l$ol_with_goto_lib -lxerbla $FCLIBS $F77LIBS -lm"
1653		if test "$ol_with_blas" = "auto" -o "$ol_with_blas" = "goto" ; then
1654			LIBS="$try_blas_LIBS $LIBS"
1655
1656			AC_TRY_LINK([
1657	/* FIXME: some architectures might use different
1658	 * naming conventions, e.g. uppercase, no underscore
1659	 */
1660	extern int dgemm_(void);
1661			],[
1662	/* test for blas */
1663	return dgemm_();
1664			],[have_blas="goto"],[
1665				have_blas="no"
1666				if test "$ol_with_blas" = "goto" ; then
1667					AC_MSG_ERROR([Goto blas implementation not available])
1668				fi
1669			])
1670			LIBS="$save_LIBS"
1671		fi
1672	fi
1673
1674	if test "${ol_with_openblas_lib:-set}" = set ; then
1675		dnl in case one relies on a symbolic link named libopenblas.{a,so}
1676		ol_with_openblas_lib="openblas"
1677	fi
1678
1679	try_blas_LIBS=
1680	if test "$have_blas" = "no" ; then
1681		try_blas_LIBS="-l$ol_with_openblas_lib $FCLIBS $F77LIBS -lm"
1682		if test "$ol_with_blas" = "auto" -o "$ol_with_blas" = "openblas" ; then
1683			LIBS="$try_blas_LIBS $LIBS"
1684
1685			AC_TRY_LINK([
1686	/* FIXME: some architectures might use different
1687	 * naming conventions, e.g. uppercase, no underscore
1688	 */
1689	extern int dgemm_(void);
1690			],[
1691	/* test for blas */
1692	return dgemm_();
1693			],[have_blas="openblas"],[
1694				have_blas="no"
1695				if test "$ol_with_blas" = "openblas" ; then
1696					AC_MSG_ERROR([OpenBLAS implementation not available])
1697				fi
1698			])
1699			LIBS="$save_LIBS"
1700		fi
1701	fi
1702
1703	if test "$have_blas" = "no" ; then
1704		try_blas_LIBS="-lcblas -latlas -lm"
1705		if test "$ol_with_blas" = "auto" -o "$ol_with_blas" = "atlas" ; then
1706			LIBS="$try_blas_LIBS $LIBS"
1707
1708			AC_TRY_LINK([
1709	extern int cblas_dgemm(void);
1710			],[
1711	/* test for blas */
1712	return cblas_dgemm();
1713			],[have_blas="atlas"
1714				LIBS="-lcblas -lf77blas -latlas $FCLIBS $F77LIBS -lm $LIBS"
1715				AC_TRY_LINK([
1716					/* FIXME: some architectures might use different
1717					 * naming conventions, e.g. uppercase, no underscore
1718					 */
1719					extern int dgemm_(void);],[return dgemm_();
1720				],[try_blas_LIBS="-lcblas -lf77blas -latlas $FCLIBS $F77LIBS -lm"],[])
1721			],[
1722				have_blas="no"
1723				if test "$ol_with_blas" = "atlas" ; then
1724					AC_MSG_ERROR([Atlas blas implementation not available])
1725				fi
1726			])
1727			LIBS="$save_LIBS"
1728		fi
1729	fi
1730
1731	if test "$have_blas" = "no" ; then
1732		try_blas_LIBS="-lcblas -lm"
1733		if test "$ol_with_blas" = "auto" -o "$ol_with_blas" = "cblas" ; then
1734			LIBS="$try_blas_LIBS $LIBS"
1735
1736			AC_TRY_LINK([
1737	extern int cblas_dgemm(void);
1738			],[
1739	/* test for blas */
1740	return cblas_dgemm();
1741			],[have_blas="cblas"],[
1742				have_blas="no"
1743				if test "$ol_with_blas" = "cblas" ; then
1744					AC_MSG_ERROR([CBLAS not available])
1745				fi
1746			])
1747			LIBS="$save_LIBS"
1748		fi
1749	fi
1750
1751	if test "$have_blas" = "no" ; then
1752		try_blas_LIBS="-lblas $FCLIBS $F77LIBS -lm"
1753		if test "$ol_with_blas" = "auto" -o "$ol_with_blas" = "blas" ; then
1754			LIBS="$try_blas_LIBS $LIBS"
1755
1756			AC_TRY_LINK([
1757	/* FIXME: some architectures might use different
1758	 * naming conventions, e.g. uppercase, no underscore
1759	 */
1760	extern int dgemm_(void);
1761			],[
1762	/* test for blas */
1763	return dgemm_();
1764			],[have_blas="blas"],[
1765				have_blas="no"
1766				if test "$ol_with_blas" = "blas" ; then
1767					AC_MSG_ERROR([BLAS not available])
1768				fi
1769			])
1770			LIBS="$save_LIBS"
1771		fi
1772	fi
1773
1774	dnl revert to original libraries; the BLAS libraries
1775	dnl will be explicitly added by those libraries that require them
1776	if test "$have_blas" != "no" ; then
1777		ol_link_blas="yes"
1778		BLAS_LIBS="$try_blas_LIBS"
1779		AC_DEFINE(HAVE_BLAS,1,[define if BLAS are available])
1780	fi
1781
1782	dnl from now on, add $BLAS_LIBS to libraries that (may) depend on them
1783	AC_MSG_RESULT([$have_blas])
1784fi
1785
1786
1787dnl ----------------------------------------------------------------
1788dnl
1789dnl Need either Metis or Chaco with MPI and Taucs
1790dnl
1791dnl First we check for Metis
1792ol_link_metis=no
1793if test "$ol_with_metis" != "no" ; then
1794	AC_CHECK_LIB(metis, METIS_PartGraphVKway,
1795		[ol_link_metis=yes],[ol_link_metis=no],[-lm])
1796	if test "ol_link_metis" != "yes" ; then
1797		AC_CHECK_LIB(metis, METIS_PartGraphKway,
1798			[ol_link_metis=yes],[ol_link_metis=no],[-lm])
1799	fi
1800
1801	AC_CHECK_HEADERS(metis.h)
1802
1803	if test "$ac_cv_header_metis_h" = "yes" ; then
1804		if test "$ol_link_metis" != "no" ; then
1805			AC_DEFINE(USE_METIS,1,
1806				[define if you want to use Metis])
1807		fi
1808	fi
1809
1810	if test "$ol_link_metis" = "no" -o "$ac_cv_header_metis_h" != "yes" ; then
1811		if test "$ol_with_metis" != "auto" ; then
1812			AC_MSG_ERROR([Could not locate Metis])
1813		else
1814			AC_MSG_WARN([Metis not supported])
1815			dnl set to "no" because we cannot link metis
1816			dnl without header file
1817			ol_link_metis="no"
1818		fi
1819	else
1820		METIS_LIBS="-lmetis -lm"
1821	fi
1822fi
1823
1824dnl ----------------------------------------------------------------
1825dnl
1826dnl Now we check for Chaco.
1827dnl
1828ol_link_chaco=no
1829if test "$ol_with_chaco" != no ; then
1830	AC_CHECK_LIB(chaco,interface,[have_chaco=yes],[have_chaco=no],[-lm])
1831
1832	if test $have_chaco != no ; then
1833		CHACO_LIBS="-lchaco -lm"
1834		AC_DEFINE(USE_CHACO,1,[define if you want to use Chaco])
1835		ol_link_chaco=yes
1836	fi
1837
1838	if test "$ol_link_chaco" = no ; then
1839                if test $ol_with_chaco != auto ; then
1840                        AC_MSG_ERROR([Could not locate Chaco])
1841                else
1842                        AC_MSG_WARN([Chaco not supported])
1843                fi
1844        fi
1845fi
1846
1847dnl ----------------------------------------------------------------
1848dnl
1849dnl Check for LAPACK
1850dnl
1851ol_link_lapack=no
1852if test $ol_with_lapack != no ; then
1853	AC_MSG_CHECKING([for lapack])
1854
1855	save_LIBS="$LIBS"
1856	try_lapack_LIBS="-llapack"
1857	LIBS="$try_lapack_LIBS $BLAS_LIBS $FCLIBS $F77LIBS $save_LIBS"
1858	AC_TRY_LINK([
1859	extern double dgesvd(double *);
1860		],[
1861	double i = 1., o;
1862	o = dgesvd(&i);
1863		],[have_lapack=yes
1864		   have_lapack_=no],[
1865		AC_TRY_LINK([
1866	extern double dgesvd_(double *);
1867			],[
1868	double i = 1., o;
1869	o = dgesvd_(&i);
1870		],[have_lapack=yes
1871		   have_lapack_=yes],[have_lapack=no
1872				      have_lapack_=no])])
1873	LIBS=$save_LIBS
1874
1875	if test "$have_lapack" == "no"; then
1876        if test "$have_lapack_" == "no"; then
1877            save_LIBS="$LIBS"
1878            try_lapack_LIBS="-lopenblas"
1879            LIBS="$try_lapack_LIBS $BLAS_LIBS $FCLIBS $F77LIBS $save_LIBS"
1880            AC_TRY_LINK([
1881            extern double dgesvd(double *);
1882                ],[
1883            double i = 1., o;
1884            o = dgesvd(&i);
1885                ],[have_lapack=yes
1886                   have_lapack_=no],[
1887                AC_TRY_LINK([
1888            extern double dgesvd_(double *);
1889                    ],[
1890            double i = 1., o;
1891            o = dgesvd_(&i);
1892                ],[have_lapack=yes
1893                   have_lapack_=yes],[have_lapack=no
1894                              have_lapack_=no])])
1895            LIBS=$save_LIBS
1896        fi
1897	fi
1898
1899    if test "$have_lapack" != "no" ; then
1900    	AC_DEFINE(USE_LAPACK,1,[define to use LAPACK libraries])
1901		AC_DEFINE(HAVE_DGESVD,1,[define to use LAPACK's dgesvd in GPC])
1902		LAPACK_LIBS="$try_lapack_LIBS"
1903    fi
1904
1905	if test "$have_lapack_" = "yes" ; then
1906		AC_TRY_LINK([
1907	extern double dggev_(double *);
1908			],[
1909	double i = 1., o;
1910	o = dggev_(&i);
1911			],[AC_DEFINE(HAVE_DGGEV,1,[define to use LAPACK's dggev in Eig])])
1912	elif test "$have_lapack" = "yes" ; then
1913		AC_TRY_LINK([
1914	extern double dggev(double *);
1915			],[
1916	double i = 1., o;
1917	o = dggev(&i);
1918			],[AC_DEFINE(HAVE_DGGEV_,1,[define to use LAPACK's dggev in Eig])])
1919	fi
1920
1921	if test "$have_lapack_" = "yes" ; then
1922		AC_TRY_LINK([
1923	extern double dgecon_(double *);
1924			],[
1925	double i = 1., o;
1926	o = dgecon_(&i);
1927			],[AC_DEFINE(HAVE_DGECON_,1,[define to use LAPACK's dgecon in newton raphson solver])])
1928	elif test "$have_lapack" = "yes" ; then
1929		AC_TRY_LINK([
1930	extern double dgecon(double *);
1931			],[
1932	double i = 1., o;
1933	o = dgecon(&i);
1934			],[AC_DEFINE(HAVE_DGECON,1,[define to use LAPACK's dgecon in newton raphson solver])])
1935	fi
1936
1937	if test "$have_lapack_" = "yes" ; then
1938		AC_TRY_LINK([
1939	extern double dlamch_(const char *);
1940			],[
1941	double o;
1942	o = dlamch_("S");
1943			],[AC_DEFINE(HAVE_DLAMCH_,1,[define to use LAPACK's dlamch in dgeequ])])
1944	elif test "$have_lapack" = "yes" ; then
1945		AC_TRY_LINK([
1946	extern double dlamch(const char *);
1947			],[
1948	double o;
1949	o = dlamch("S");
1950			],[AC_DEFINE(HAVE_DLAMCH,1,[define to use LAPACK's dlamch in dgeequ])])
1951	fi
1952
1953	if test "$have_lapack_" = "yes" ; then
1954		AC_TRY_LINK([
1955	extern double dgetrf_(double *);
1956			],[
1957	double i = 1., o;
1958	o = dgetrf_(&i);
1959			],[AC_DEFINE(HAVE_DGETRF_,1,[define to use LAPACK's dgetrf in newton raphson solver])])
1960	elif test "$have_lapack" = "yes" ; then
1961		AC_TRY_LINK([
1962	extern double dgetrf(double *);
1963			],[
1964	double i = 1., o;
1965	o = dgetrf(&i);
1966			],[AC_DEFINE(HAVE_DGETRF,1,[define to use LAPACK's dgetrf in newton raphson solver])])
1967	fi
1968
1969	if test "$have_lapack_" = "yes" ; then
1970		AC_TRY_LINK([
1971	extern double dgegv_(double *);
1972			],[
1973	double i = 1., o;
1974	o = dgegv_(&i);
1975			],[AC_DEFINE(HAVE_DGEGV,1,[define to use LAPACK's dgegv in Eig])])
1976	elif test "$have_lapack" = "yes" ; then
1977		AC_TRY_LINK([
1978	extern double dgegv(double *);
1979			],[
1980	double i = 1., o;
1981	o = dgegv(&i);
1982			],[AC_DEFINE(HAVE_DGEGV_,1,[define to use LAPACK's dgegv in Eig])])
1983	fi
1984
1985	if test "$have_lapack" = "yes" ; then
1986		ol_link_lapack=yes
1987		AC_MSG_RESULT([yes])
1988	else
1989		AC_MSG_RESULT([no])
1990	fi
1991	LIBS="$save_LIBS"
1992fi
1993
1994dnl ----------------------------------------------------------------
1995dnl
1996dnl Check for Umfpack
1997dnl
1998ol_link_umfpack=no
1999if test "$ol_with_umfpack" != "no" ; then
2000	AC_CHECK_HEADERS(umfpack.h)
2001
2002	have_suitesparseconfig="no"
2003	if test "$ac_cv_header_umfpack_h" = "yes" ; then
2004
2005		dnl check for SuiteSparseConfig
2006		AC_MSG_CHECKING([for SuiteSparse_config library])
2007		save_LIBS="$LIBS"
2008		try_suitesparseconfig_LIBS="-lsuitesparseconfig -lm $RT_LIBS"
2009		LIBS="$try_suitesparseconfig_LIBS $LIBS"
2010
2011		AC_TRY_LINK([
2012	/* no test: the library must exist, then we trust it */
2013		],[
2014	/* test for suitesparseconfig */
2015	return 0;
2016		],[have_suitesparseconfig="yes"],[have_suitesparseconfig="no"])
2017		if test "$have_suitesparseconfig" = "yes" ; then
2018			try_umfpack_LIBS="$try_suitesparseconfig_LIBS"
2019			AC_MSG_RESULT([yes])
2020		else
2021			try_umfpack_LIBS=
2022			LIBS="$save_LIBS"
2023			AC_MSG_RESULT([no])
2024		fi
2025
2026		dnl check for AMD
2027		AC_MSG_CHECKING([for AMD library])
2028		save_LIBS="$LIBS"
2029		try_amd_LIBS="-lamd -lm"
2030		LIBS="$try_amd_LIBS $LIBS"
2031
2032		AC_TRY_LINK([
2033	/* no test: the library must exist, then we trust it */
2034		],[
2035	/* test for amd */
2036	return 0;
2037		],[have_amd="yes"],[have_amd="no"])
2038		if test "$have_amd" = "yes" ; then
2039			try_umfpack_LIBS="$try_amd_LIBS"
2040			AC_MSG_RESULT([yes])
2041		else
2042			try_umfpack_LIBS=
2043			LIBS="$save_LIBS"
2044			AC_MSG_RESULT([no])
2045		fi
2046
2047
2048		dnl check for COLAMD
2049		AC_MSG_CHECKING([for COLAMD library])
2050		try_colamd_LIBS="-lcolamd -lm"
2051		LIBS="$try_colamd_LIBS $LIBS"
2052
2053		AC_TRY_LINK([
2054	/* no test: the library must exist, then we trust it */
2055		],[
2056	/* test for colamd */
2057	return 0;
2058		],[have_colamd="yes"],[have_colamd="no"])
2059		if test "$have_colamd" = "yes" ; then
2060			try_umfpack_LIBS="$try_colamd_LIBS $try_umfpack_LIBS"
2061			AC_MSG_RESULT([yes])
2062		else
2063			LIBS="$save_LIBS"
2064			AC_MSG_RESULT([no])
2065		fi
2066
2067
2068		dnl check for CCOLAMD
2069		AC_MSG_CHECKING([for CCOLAMD library])
2070		try_ccolamd_LIBS="-lccolamd -lm"
2071		LIBS="$try_ccolamd_LIBS $LIBS"
2072
2073		AC_TRY_LINK([
2074	/* no test: the library must exist, then we trust it */
2075		],[
2076	/* test for ccolamd */
2077	return 0;
2078		],[have_ccolamd="yes"],[have_ccolamd="no"])
2079		if test "$have_ccolamd" = "yes" ; then
2080			try_umfpack_LIBS="$try_ccolamd_LIBS $try_umfpack_LIBS"
2081			AC_MSG_RESULT([yes])
2082		else
2083			LIBS="$save_LIBS"
2084			AC_MSG_RESULT([no])
2085		fi
2086
2087
2088		dnl check for CAMD
2089		AC_MSG_CHECKING([for CAMD library])
2090		try_camd_LIBS="-lcamd -lm"
2091		LIBS="$try_camd_LIBS $LIBS"
2092
2093		AC_TRY_LINK([
2094	/* no test: the library must exist, then we trust it */
2095		],[
2096	/* test for camd */
2097	return 0;
2098		],[have_camd="yes"],[have_camd="no"])
2099		if test "$have_camd" = "yes" ; then
2100			try_umfpack_LIBS="$try_camd_LIBS $try_umfpack_LIBS"
2101			AC_MSG_RESULT([yes])
2102		else
2103			LIBS="$save_LIBS"
2104			AC_MSG_RESULT([no])
2105		fi
2106
2107
2108		dnl check for CHOLMOD
2109		AC_MSG_CHECKING([for CHOLMOD library])
2110		try_cholmod_LIBS="-lcholmod $METIS_LIBS -lm"
2111		LIBS="$try_cholmod_LIBS $LIBS"
2112
2113		AC_TRY_LINK([
2114	/* no test: the library must exist, then we trust it */
2115		],[
2116	/* test for cholmod */
2117	return 0;
2118		],[have_cholmod="yes"],[have_cholmod="no"])
2119		if test "$have_cholmod" = "yes" ; then
2120			try_umfpack_LIBS="$try_cholmod_LIBS $try_umfpack_LIBS"
2121			AC_MSG_RESULT([yes])
2122		else
2123			LIBS="$save_LIBS"
2124			AC_MSG_RESULT([no])
2125		fi
2126
2127		have_umfpack_version="no"
2128		have_umfpack="no"
2129		AC_MSG_CHECKING([for umfpack library version])
2130		AC_TRY_COMPILE([
2131#if defined(HAVE_STDINT_H)
2132#include <stdint.h>
2133#elif defined(HAVE_SYS_TYPES_H)
2134#include <sys/types.h>
2135#else
2136#error "need int32_t"
2137#endif
2138#include <umfpack.h>
2139		],[
2140#ifndef UMFPACK_MAIN_VERSION
2141#error "UMFPACK_MAIN_VERSION not defined (less than 5?)"
2142#endif // UMFPACK_MAIN_VERSION
2143#if UMFPACK_MAIN_VERSION < 5
2144#error "UMFPACK_MAIN_VERSION less than 5?"
2145#endif // UMFPACK_MAIN_VERSION
2146		],[
2147			have_umfpack_version="yes"
2148			AC_MSG_RESULT([5 or greater])
2149		],[
2150			AC_MSG_RESULT([less than 5?])
2151		])
2152
2153		if test "$have_umfpack_version" = "yes" ; then
2154			umfpack_use_long="no"
2155			AC_MSG_CHECKING([if umfpack library needs long])
2156			AC_LANG_CPLUSPLUS
2157			AC_TRY_COMPILE([
2158#if defined(HAVE_STDINT_H)
2159#include <stdint.h>
2160#elif defined(HAVE_SYS_TYPES_H)
2161#include <sys/types.h>
2162#endif
2163#include <umfpack.h>
2164			],[
2165#define SIZE 2
2166	int32_t sys;
2167	int32_t Ap[SIZE], Ai[SIZE];
2168	double Ax[SIZE], X[SIZE], B[SIZE];
2169	void *Numeric;
2170	double Control[UMFPACK_CONTROL];
2171	double Info[UMFPACK_INFO];
2172	umfpack_di_solve(sys, Ap, Ai, Ax, X, B, &Numeric, Control, Info);
2173			],[],[
2174				AC_TRY_COMPILE([
2175#if defined(HAVE_STDINT_H)
2176#include <stdint.h>
2177#elif defined(HAVE_SYS_TYPES_H)
2178#include <sys/types.h>
2179#endif
2180#include <umfpack.h>
2181				],[
2182#define SIZE 2
2183	int32_t sys;
2184	int32_t Ap[SIZE], Ai[SIZE];
2185	double Ax[SIZE], X[SIZE], B[SIZE];
2186	void *Numeric;
2187	double Control[UMFPACK_CONTROL];
2188	double Info[UMFPACK_INFO];
2189	umfpack_dl_solve(sys, Ap, Ai, Ax, X, B, &Numeric, Control, Info);
2190				],[
2191					AC_DEFINE(USE_UMFPACK_LONG,1,[define if need to use umfpack_dl_* calls])
2192					umfpack_use_long="yes"
2193				],[
2194					AC_MSG_ERROR([umfpack might be broken])
2195				])
2196			])
2197			AC_LANG_C
2198
2199			AC_MSG_RESULT([$umfpack_use_long])
2200
2201			try_umfpack_LIBS="-lumfpack $try_umfpack_LIBS"
2202			LIBS="$try_umfpack_LIBS $BLAS_LIBS $save_LIBS"
2203			AC_MSG_CHECKING([for umfpack library])
2204			AC_TRY_LINK([
2205#include <umfpack.h>
2206			],[
2207	double t;
2208	t = umfpack_timer();
2209			],[
2210				have_umfpack="yes"
2211				AC_MSG_RESULT([yes])
2212			],[
2213				AC_MSG_RESULT([no])
2214			])
2215		fi
2216
2217		if test "$have_umfpack" = "yes" ; then
2218			ol_link_umfpack=yes
2219			UMFPACK_LIBS="$try_umfpack_LIBS"
2220			if test "${BLAS_LIBS:-set}" = "set" ; then
2221				AC_DEFINE(NBLAS,1,[define if BLAS/ATLAS are not available to Umfpack])
2222				AC_MSG_WARN([Umfpack will be used without cblas/atlas])
2223			fi
2224		fi
2225		LIBS="$save_LIBS"
2226	fi
2227fi
2228
2229if test $ol_link_umfpack = no ; then
2230	case "$ol_with_umfpack" in
2231	yes)
2232		AC_MSG_ERROR([Could not locate Umfpack])
2233		;;
2234	auto)
2235		AC_MSG_WARN([Umfpack not supported])
2236		;;
2237	*)
2238		;;
2239	esac
2240else
2241	AC_DEFINE(USE_UMFPACK,1,[define if you want to use Umfpack])
2242fi
2243
2244dnl ----------------------------------------------------------------
2245dnl
2246dnl Check for KLU
2247dnl
2248ol_link_klu=no
2249if test "$ol_with_klu" != "no" ; then
2250	dnl OL_ADD_DIRS(klu)
2251
2252	AC_CHECK_HEADERS(klu.h)
2253
2254	have_suitesparseconfig="no"
2255	if test "$ac_cv_header_klu_h" = "yes" ; then
2256
2257		dnl check for SuiteSparseConfig
2258		AC_MSG_CHECKING([for SuiteSparse_config library])
2259		save_LIBS="$LIBS"
2260		try_suitesparseconfig_LIBS="-lsuitesparseconfig $RT_LIBS -lm"
2261		LIBS="$try_suitesparseconfig_LIBS $LIBS"
2262
2263		AC_TRY_LINK([
2264	/* no test: the library must exist, then we trust it */
2265		],[
2266	/* test for suitesparseconfig */
2267	return 0;
2268		],[have_suitesparseconfig="yes"],[have_suitesparseconfig="no"])
2269		if test "$have_suitesparseconfig" = "yes" ; then
2270			try_umfpack_LIBS="$try_suitesparseconfig_LIBS"
2271			AC_MSG_RESULT([yes])
2272		else
2273			try_umfpack_LIBS=
2274			LIBS="$save_LIBS"
2275			AC_MSG_RESULT([no])
2276		fi
2277
2278		dnl check for AMD
2279		AC_MSG_CHECKING([for AMD library])
2280		save_LIBS="$LIBS"
2281		try_amd_LIBS="-lamd"
2282		LIBS="$try_amd_LIBS $LIBS"
2283
2284		AC_TRY_LINK([
2285	/* no test: the library must exist, then we trust it */
2286		],[
2287	/* test for amd */
2288	return 0;
2289		],[have_amd="yes"],[have_amd="no"])
2290		if test "$have_amd" = "yes" ; then
2291			try_klu_LIBS="$try_amd_LIBS"
2292			AC_MSG_RESULT([yes])
2293		else
2294			try_klu_LIBS=
2295			LIBS="$save_LIBS"
2296			AC_MSG_RESULT([no])
2297		fi
2298
2299		dnl check for COLAMD
2300		AC_MSG_CHECKING([for COLAMD library])
2301		try_colamd_LIBS="-lcolamd"
2302		LIBS="$try_colamd_LIBS $save_LIBS"
2303
2304		AC_TRY_LINK([
2305	/* no test: the library must exist, then we trust it */
2306		],[
2307	/* test for colamd */
2308	return 0;
2309		],[have_colamd="yes"],[have_colamd="no"])
2310		if test "$have_colamd" = "yes" ; then
2311			try_klu_LIBS="$try_klu_LIBS $try_colamd_LIBS"
2312			AC_MSG_RESULT([yes])
2313		else
2314			try_klu_LIBS=
2315			LIBS="$save_LIBS"
2316			AC_MSG_RESULT([no])
2317		fi
2318
2319		dnl check for BTF
2320		AC_MSG_CHECKING([for BTF library])
2321		try_btf_LIBS="-lbtf"
2322		LIBS="$try_btf_LIBS $save_LIBS"
2323
2324		AC_TRY_LINK([
2325	/* no test: the library must exist, then we trust it */
2326		],[
2327	/* test for btf */
2328	return 0;
2329		],[have_btf="yes"],[have_btf="no"])
2330		if test "$have_btf" = "yes" ; then
2331			try_klu_LIBS="$try_klu_LIBS $try_btf_LIBS"
2332			AC_MSG_RESULT([yes])
2333		else
2334			try_klu_LIBS=
2335			LIBS="$save_LIBS"
2336			AC_MSG_RESULT([no])
2337		fi
2338
2339		dnl check for KLU
2340		AC_MSG_CHECKING([for KLU library])
2341		try_klu_LIBS="-lklu $try_klu_LIBS"
2342		LIBS="$try_klu_LIBS $save_LIBS"
2343
2344		AC_TRY_LINK([
2345	/* no test: the library must exist, then we trust it */
2346		],[
2347	/* test for klu */
2348	return 0;
2349		],[have_klu="yes"],[have_klu="no"])
2350		if test "$have_klu" = "yes" ; then
2351			AC_MSG_RESULT([yes])
2352		else
2353			try_klu_LIBS=
2354			LIBS="$save_LIBS"
2355			AC_MSG_RESULT([no])
2356		fi
2357
2358		if test "$have_klu" = "yes" ; then
2359			ol_link_klu=yes
2360			KLU_LIBS="$try_klu_LIBS"
2361			if test "${BLAS_LIBS:-set}" = "set" ; then
2362				AC_DEFINE(NBLAS,1,[define if BLAS/ATLAS are not available to KLU])
2363				AC_MSG_WARN([KLU will be used without cblas/atlas])
2364			fi
2365		fi
2366		LIBS="$save_LIBS"
2367
2368	fi
2369fi
2370
2371
2372if test $ol_link_klu = no ; then
2373	case "$ol_with_klu" in
2374	yes)
2375		AC_MSG_ERROR([Could not locate KLU])
2376		;;
2377	auto)
2378		AC_MSG_WARN([KLU not supported])
2379		;;
2380	*)
2381		;;
2382	esac
2383else
2384	AC_DEFINE(USE_KLU,1,[define if you want to use KLU])
2385fi
2386
2387dnl ----------------------------------------------------------------
2388dnl
2389dnl Check for Meschach
2390dnl
2391ol_link_meschach=no
2392if test $ol_with_meschach != no ; then
2393	AC_CHECK_HEADERS(meschach/sparse2.h)
2394
2395	if test "$ac_cv_header_meschach_sparse2_h" = "yes" ; then
2396
2397		AC_MSG_CHECKING([for meschach library])
2398		try_meschach_LIBS="-lmeschach"
2399		save_LIBS=$LIBS
2400		LIBS="$LIBS $try_meschach_LIBS"
2401		AC_TRY_LINK([
2402#include <meschach/sparse2.h>
2403],[
2404	SPMAT* mat;
2405	mat = sp_get(10, 20, 10);
2406		],[have_meschach=yes],[have_meschach=no])
2407		LIBS=$save_LIBS
2408
2409		if test $have_meschach != no ; then
2410			MESCHACH_LIBS=$try_meschach_LIBS
2411			AC_DEFINE(USE_MESCHACH,1,[define if you want to use Meschach])
2412			ol_link_meschach=yes
2413			AC_MSG_RESULT([yes])
2414		else
2415			AC_MSG_RESULT([no])
2416		fi
2417	fi
2418
2419	if test $ol_link_meschach = no ; then
2420		if test $ol_with_meschach != auto ; then
2421			AC_MSG_ERROR([Could not locate Meschach])
2422		else
2423			AC_MSG_WARN([Meschach not supported])
2424		fi
2425	fi
2426fi
2427
2428dnl ----------------------------------------------------------------
2429dnl
2430dnl Check for SuperLU
2431dnl
2432ol_link_superlu=no
2433if test $ol_with_superlu != no ; then
2434	AC_CHECK_HEADERS(dsp_defs.h)
2435	AC_CHECK_HEADERS(pdsp_defs.h)
2436	AC_CHECK_HEADERS(util.h)
2437
2438	if test "$ac_cv_header_util_h" = "yes" ; then
2439		AC_MSG_CHECKING([for SuperLU library])
2440		try_superlu_LIBS="-lsuperlu"
2441		save_LIBS="$LIBS"
2442		have_superlu_mt="no"
2443		if test "$ac_cv_header_pdsp_defs_h" = "yes" ; then
2444			LIBS="$try_superlu_LIBS $save_LIBS $BLAS_LIBS $THREAD_LIBS -lm"
2445			AC_TRY_LINK([
2446#include <pdsp_defs.h>
2447#include <util.h>
2448],[
2449	SuperMatrix	AC, L, U;
2450	(void)pdgstrf_thread_init(&AC, &L, &U,
2451			(void *)0, (void *)0, (void *)0, (void *)0);
2452			],[have_superlu_mt="yes"])
2453		fi
2454		have_superlu="no"
2455		if test "$ac_cv_header_dsp_defs_h" = "yes" ; then
2456			LIBS="$try_superlu_LIBS $save_LIBS $BLAS_LIBS -lm"
2457			AC_TRY_LINK([
2458#include <dsp_defs.h>
2459#include <util.h>
2460],[
2461	SuperMatrix	B;
2462	dCreate_Dense_Matrix(&B, 1, 1, (void *)0, 0,
2463			SLU_DN, SLU_D, SLU_GE);
2464			],[have_superlu="yes"])
2465		fi
2466		LIBS="$save_LIBS"
2467
2468		if test "$have_superlu_mt" != "no" -o \
2469				"$have_superlu" != "no" ; then
2470			SUPERLU_LIBS=$try_superlu_LIBS
2471			ol_link_superlu=yes
2472			if test "$have_superlu_mt" != "no" ; then
2473				AC_DEFINE(USE_SUPERLU_MT,1,[define if you want to use multithreaded SuperLU])
2474			fi
2475			AC_DEFINE(USE_SUPERLU,1,[define if you want to use SuperLU])
2476
2477			AC_MSG_RESULT([yes])
2478		else
2479			AC_MSG_RESULT([no])
2480		fi
2481	fi
2482
2483	if test $ol_link_superlu = no ; then
2484		if test $ol_with_superlu != auto ; then
2485			AC_MSG_ERROR([Could not locate SuperLU])
2486		else
2487			AC_MSG_WARN([SuperLU not supported])
2488		fi
2489	fi
2490fi
2491
2492dnl ----------------------------------------------------------------
2493dnl
2494dnl Check for Watson wsmp
2495dnl
2496ol_link_wsmp=no
2497if test $ol_with_wsmp != no ; then
2498	try_wsmp_LIBS="-lwsmp"
2499	AC_CHECK_LIB(wsmp,wgsmp_,[have_wsmp=yes],[have_wsmp=no],[$try_wsmp_LIBS])
2500	if test "$have_wsmp" = "yes" ; then
2501		AC_DEFINE(HAVE_WSMP,1,[define to use Watson wsmp library])
2502		WSMP_LIBS="$try_wsmp_LIBS"
2503	else
2504		if test "$ol_with_wsmp" = "yes" ; then
2505			AC_MSG_ERROR([wsmp library not available])
2506		fi
2507	fi
2508fi
2509
2510dnl ----------------------------------------------------------------
2511dnl
2512dnl Check for Y12
2513dnl
2514ol_link_y12=no
2515if test $ol_with_y12 != no ; then
2516	if test "x$F77" = "x" ; then
2517		if test $ol_with_y12 = yes ; then
2518			AC_MSG_ERROR([Y12 sparse LU library needs Fortran compiler])
2519		fi
2520	else
2521		ol_link_y12=yes
2522		AC_DEFINE(USE_Y12,1,[define to use Y12 sparse LU library])
2523		Y12_LIBS="${top_builddir}/libraries/liby12/liby12.la -lm"
2524	fi
2525fi
2526
2527dnl ----------------------------------------------------------------
2528dnl
2529dnl Check for Harwell
2530dnl
2531ol_link_harwell=no
2532if test $ol_with_harwell != no ; then
2533	AC_CHECK_LIB(hsl,ma28ad,[have_libhsl=yes],[have_libhsl=no],["$FCLIBS $F77LIBS -lm"])
2534	if test $have_libhsl = no ; then
2535		AC_CHECK_LIB(hsl,ma28ad_,[have_libhsl=yes],[have_libhsl=no],["$FCLIBS $F77LIBS -lm"])
2536	fi
2537	if test $have_libhsl = yes ; then
2538		ol_link_harwell=yes
2539		AC_DEFINE(USE_HARWELL,1,[define to use Harwell sparse LU library])
2540		HARWELL_LIBS=-lhsl
2541	else
2542		if test $ol_with_harwell != auto ; then
2543			AC_MSG_ERROR([Could not locate Harwell lib (-lhsl)])
2544		else
2545			AC_MSG_WARN([Harwell lib (-lhsl) not supported])
2546		fi
2547	fi
2548fi
2549
2550dnl ----------------------------------------------------------------
2551dnl
2552dnl Check for ARPACK
2553dnl
2554ol_link_arpack=no
2555if test $ol_with_arpack != no ; then
2556	AC_MSG_CHECKING([for arpack])
2557
2558	save_LIBS="$LIBS"
2559	try_arpack_LIBS="-larpack"
2560	LIBS="$try_arpack_LIBS $LAPACK_LIBS $BLAS_LIBS $FCLIBS $F77LIBS $save_LIBS"
2561	AC_TRY_LINK([
2562	extern double dnaupd(double *);
2563		],[
2564	double i = 1., o;
2565	o = dnaupd(&i);
2566		],[have_arpack=yes
2567		   have_arpack_=no],[
2568		AC_TRY_LINK([
2569	extern double dnaupd_(double *);
2570			],[
2571	double i = 1., o;
2572	o = dnaupd_(&i);
2573		],[have_arpack=yes
2574		   have_arpack_=yes],[have_arpack=no
2575				      have_arpack_=no])])
2576
2577	if test $have_arpack != no ; then
2578		AC_DEFINE(USE_ARPACK,1,[define to use ARPACK libraries])
2579		ARPACK_LIBS="$try_arpack_LIBS"
2580	fi
2581
2582	if test "$have_arpack" = "yes" ; then
2583		ol_link_arpack=yes
2584		AC_MSG_RESULT([yes])
2585	else
2586		if test "$ol_with_arpack" = "yes" ; then
2587			AC_MSG_ERROR([Could not locate arpack])
2588		fi
2589		AC_MSG_RESULT([no])
2590	fi
2591	LIBS="$save_LIBS"
2592fi
2593
2594dnl ----------------------------------------------------------------
2595dnl
2596dnl Check for JDQZ
2597dnl
2598ol_link_jdqz=no
2599if test $ol_with_jdqz != no ; then
2600	AC_MSG_CHECKING([for jdqz])
2601
2602	save_LIBS="$LIBS"
2603	try_jdqz_LIBS="-ljdqz"
2604	LIBS="$try_jdqz_LIBS $LAPACK_LIBS $BLAS_LIBS $FCLIBS $F77LIBS $save_LIBS"
2605	AC_TRY_LINK([
2606	double amul(double *x) { return 0.; }
2607	double bmul(double *x) { return 0.; }
2608	double precon(double *x) { return 0.; }
2609	extern double jdqz(double *);
2610		],[
2611	double i = 1., o;
2612	o = jdqz(&i);
2613		],[have_jdqz=yes
2614		   have_jdqz_=no],[
2615		AC_TRY_LINK([
2616	double amul_(double *x) { return 0.; }
2617	double bmul_(double *x) { return 0.; }
2618	double precon_(double *x) { return 0.; }
2619	extern double jdqz_(double *);
2620			],[
2621	double i = 1., o;
2622	o = jdqz_(&i);
2623		],[have_jdqz=yes
2624		   have_jdqz_=yes],[have_jdqz=no
2625				      have_jdqz_=no])])
2626
2627	if test $have_jdqz != no ; then
2628		AC_DEFINE(USE_JDQZ,1,[define to use JDQZ library])
2629		JDQZ_LIBS="$try_jdqz_LIBS"
2630	fi
2631
2632	if test "$have_jdqz" = "yes" ; then
2633		ol_link_jdqz=yes
2634		AC_MSG_RESULT([yes])
2635	else
2636		if test "$ol_with_jdqz" = "yes" ; then
2637			AC_MSG_ERROR([Could not locate jdqz])
2638		fi
2639		AC_MSG_RESULT([no])
2640	fi
2641	LIBS="$save_LIBS"
2642fi
2643
2644dnl ----------------------------------------------------------------
2645dnl
2646dnl Check for eig
2647dnl
2648if test $ol_enable_eig != no ; then
2649	if test $ol_link_arpack = yes -o $ol_link_lapack = yes -o $ol_link_jdqz = yes ; then
2650		AC_DEFINE(USE_EIG,1,[define if you want to enable direct eigensolution])
2651	else
2652		if test $ol_enable_eig = yes ; then
2653			AC_MSG_ERROR([Need either LAPACK, ARPACK or JDQZ to enable direct eigenanalysis])
2654		fi
2655	fi
2656fi
2657
2658dnl ----------------------------------------------------------------
2659dnl
2660dnl Check for ANN
2661dnl
2662ol_link_ann=no
2663if test "$ol_with_ann" != "no" ; then
2664	ol_have_ann=no
2665	AC_LANG_CPLUSPLUS
2666	ANN_H=
2667	ANN_ANN_H=
2668	AC_CHECK_HEADERS(ANN.h, [ANN_H="ANN.h"])
2669	AC_CHECK_HEADERS(ANN/ANN.h, [ANN_H="ANN/ANN.h"])
2670	if test "$ac_cv_header_ANN_h" = "yes" -o "$ac_cv_header_ANN_ANN_h" = "yes" ; then
2671		SAVE_LIBS="$LIBS"
2672		LIBS="$LIBS -lann"
2673		AC_TRY_LINK(
2674	#include <$ANN_H>
2675			,[
2676	ANNkd_tree x(0,0);
2677			],[have_ann=yes],[have_ann=no])
2678		LIBS="$save_LIBS"
2679		if test "$have_ann" != "no" ; then
2680			ANN_LIBS="-lann"
2681			AC_DEFINE(HAVE_ANN,1,[define to use ANN])
2682			ol_have_ann="yes"
2683		fi
2684	fi
2685
2686	if test "$ol_have_ann" != "yes" ; then
2687		if test "$ol_with_ann" = "yes" ; then
2688			AC_MSG_ERROR([ANN library headers not available])
2689		fi
2690	else
2691		if test "$ol_link_lapack" != "yes" ; then
2692			AC_MSG_ERROR([ANN library needs LAPACK])
2693		fi
2694		LIBS="$SAVE_LIBS"
2695	fi
2696	AC_LANG_C
2697
2698	if test "$ol_have_ann" = "yes" ; then
2699		ol_link_ann="yes"
2700		AC_DEFINE(USE_ANN,1,[define to use ANN])
2701	fi
2702fi
2703
2704dnl ----------------------------------------------------------------
2705dnl
2706dnl Check for SASL2
2707dnl
2708ol_link_sasl2="no"
2709if test "$ol_with_sasl2" != "no" ; then
2710	AC_CHECK_HEADERS(sasl.h sasl/sasl.h)
2711
2712	have_sasl_h="no"
2713	if test "$ac_cv_header_sasl_h" = "yes" ; then
2714		have_sasl_h="yes"
2715	elif test "$ac_cv_header_sasl_sasl_h" = "yes" ; then
2716		have_sasl_h="yes"
2717	fi
2718	if test "$have_sasl_h" = "yes" ; then
2719		AC_CHECK_LIB(sasl2,sasl_client_start,[have_sasl2=yes],[have_sasl2=no])
2720		if test "$have_sasl2" != "no" ; then
2721			SECURITY_LIBS="$SECURITY_LIBS -lsasl2"
2722			AC_DEFINE(HAVE_SASL2,1,[define to use Cyrus SASL2])
2723			ol_link_sasl2="yes"
2724		fi
2725	fi
2726
2727	if test "$ol_link_sasl2" = "no" ; then
2728		if test "$ol_with_sasl2" != "auto" ; then
2729			AC_MSG_ERROR([Could not locate SASL2])
2730		else
2731			AC_MSG_WARN([SASL2 not supported])
2732		fi
2733	fi
2734fi
2735
2736dnl ----------------------------------------------------------------
2737dnl
2738dnl Check for PAM
2739dnl
2740ol_link_pam=no
2741if test $ol_with_pam != no ; then
2742	AC_CHECK_HEADERS(security/pam_appl.h pam_misc.h security/pam_misc.h)
2743
2744	if test "$ac_cv_header_security_pam_appl_h" = "yes" ; then
2745		if test "$ac_cv_header_pam_misc_h" = "yes" \
2746				-o "$ac_cv_header_security_pam_misc_h" = "yes" ; then
2747			AC_CHECK_LIB(pam,pam_start,
2748				[have_pam=yes],[have_pam=no],
2749				[-lcrypt -lpam_misc -ldl])
2750
2751			if test $have_pam != no ; then
2752				SECURITY_LIBS="$SECURITY_LIBS -lcrypt -lpam -lpam_misc -ldl"
2753				AC_DEFINE(USE_PAM,1,
2754					[define if you want to use PAM])
2755				ol_link_pam=yes
2756			fi
2757		fi
2758	fi
2759
2760	if test $ol_link_pam = no ; then
2761		if test $ol_with_pam != auto ; then
2762			AC_MSG_ERROR([Could not locate PAM])
2763		else
2764			AC_MSG_WARN([PAM not supported])
2765		fi
2766	fi
2767fi
2768
2769dnl ----------------------------------------------------------------
2770dnl
2771dnl Check if crypt needs libcrypt
2772dnl
2773ol_link_crypt=no
2774if test "$ol_enable_crypt" != no ; then
2775	AC_MSG_CHECKING([how to link crypt])
2776	crypt_pool="\"\" -lcrypt -lcrypto"
2777	for i in $crypt_pool ; do
2778		save_LIBS=$LIBS
2779		LIBS="$LIBS $i"
2780		AC_TRY_LINK([
2781#include <unistd.h>
2782#include <pwd.h>
2783		],[
2784	crypt(NULL,NULL);
2785		],[crypt_ok=yes],[crypt_ok=no])
2786		LIBS=$save_LIBS
2787
2788		if test $crypt_ok = yes ; then
2789			if test "x$i" = "x" ; then
2790				AC_MSG_RESULT([automatically linked])
2791			else
2792				AC_MSG_RESULT([with $i])
2793				SECURITY_LIBS="$SECURITY_LIBS $i"
2794			fi
2795			AC_DEFINE(HAVE_CRYPT,1,[define if crypt(3) can be linked])
2796			break
2797		fi
2798	done
2799
2800	if test $crypt_ok != yes ; then
2801		AC_MSG_RESULT([no])
2802		if test "$ol_enable_crypt" = "yes" ; then
2803			AC_MSG_ERROR([don't know how to link crypt])
2804		else
2805			AC_MSG_WARN([don't know how to link crypt...])
2806		fi
2807	fi
2808fi
2809
2810dnl ----------------------------------------------------------------
2811dnl
2812dnl Check for MPI & MPI++
2813dnl
2814dnl FIXME: needs to be reworked for MPI2
2815dnl
2816ol_link_mpi=no
2817if test $ol_with_mpi != no ; then
2818	AC_CHECK_HEADERS(mpi.h)
2819	AC_LANG_CPLUSPLUS
2820	AC_CHECK_HEADERS(mpi++.h)
2821	AC_CHECK_HEADERS(mpicxx.h)
2822	AC_LANG_C
2823
2824	have_mpi_cxx_header=no
2825	if test $ac_cv_header_mpipp_h = yes ; then
2826		dnl mpich
2827		have_mpi_cxx_header=yes
2828		mpi_cxx_header="mpi++.h"
2829		if test "$ol_with_mpi" = "pmpi" ; then
2830        		try_mpi_LIBS="-lpmpich++ -lmpich -lpmpich -lnsl"
2831		else
2832        		try_mpi_LIBS="-lmpich++ -lmpich -lnsl"
2833		fi
2834	elif test $ac_cv_header_mpicxx_h = yes ; then
2835		dnl openmpi
2836		have_mpi_cxx_header=yes
2837		mpi_cxx_header="mpicxx.h"
2838		try_mpi_LIBS="-lmpi -lmpi_cxx"
2839	fi
2840
2841	if test $ac_cv_header_mpi_h = yes -a $have_mpi_cxx_header = yes ; then
2842		AC_MSG_CHECKING([for mpi libraries])
2843		AC_LANG_CPLUSPLUS
2844		try_mpi_LIBS=
2845		save_LIBS=$LIBS
2846 		AC_TRY_LINK([
2847#include <$mpi_cxx_header>
2848		],[
2849 	int argc = 0;
2850 	char **argv = 0;
2851 	MPI::Init(argc, argv);
2852 		],[have_mpi=yes],[have_mpi=no])
2853                if test $have_mpi = no ; then
2854		        LIBS="$LIBS $try_mpi_LIBS"
2855		        AC_TRY_LINK([
2856#include <$mpi_cxx_header>
2857			],[
2858	int argc = 0;
2859	char **argv = 0;
2860	MPI::Init(argc, argv);
2861        		],[have_mpi=yes],[have_mpi=no])
2862	        	LIBS=$save_LIBS
2863                fi
2864		AC_LANG_C
2865
2866		if test $have_mpi != no ; then
2867			MPI_LIBS=$try_mpi_LIBS
2868			AC_DEFINE(USE_MPI,1,[define if you want to use MPI])
2869			ol_link_mpi=yes
2870			AC_MSG_RESULT([yes])
2871		else
2872			AC_MSG_RESULT([no])
2873		fi
2874	fi
2875
2876	if test $ol_link_mpi = no ; then
2877		if test $ol_with_mpi != auto ; then
2878			AC_MSG_ERROR([Could not locate MPI])
2879		else
2880			AC_MSG_WARN([MPI not supported])
2881		fi
2882	fi
2883fi
2884
2885dnl ----------------------------------------------------------------
2886dnl
2887dnl Need Schur parallel solver with MPI
2888dnl
2889if test $ol_enable_schur != no ; then
2890	if test $ol_link_mpi = yes ; then
2891		if test $ol_link_metis = yes -o $ol_link_chaco = yes ; then
2892			use_schur=yes
2893			AC_DEFINE(USE_SCHUR,1,[define if you want to use Schur parallel solver])
2894		else
2895			if test $ol_enable_schur = yes ; then
2896				AC_MSG_ERROR([Need either Metis or Chaco for Schur parallel solver])
2897			fi
2898		fi
2899	else
2900		if test $ol_enable_schur = yes ; then
2901			AC_MSG_ERROR([Need MPI for Schur parallel solver])
2902		fi
2903	fi
2904fi
2905
2906dnl ----------------------------------------------------------------
2907dnl
2908dnl Check for TAUCS
2909dnl
2910ol_link_taucs=no
2911if test $ol_with_taucs != no ; then
2912	AC_MSG_CHECKING([for taucs])
2913
2914	if test $ol_link_metis = no ; then
2915		have_taucs=no
2916		if test $ol_with_taucs != auto ; then
2917			AC_MSG_ERROR([Need Metis library for Taucs solver])
2918		else
2919                        AC_MSG_WARN([Taucs needs Metis; not supported])
2920		fi
2921	elif test $have_lapack = no ; then
2922		have_taucs=no
2923		if test $ol_with_taucs != auto ; then
2924			AC_MSG_ERROR([Need Lapack library for Taucs solver])
2925		else
2926                        AC_MSG_WARN([Taucs needs Lapack; not supported])
2927		fi
2928	elif test $have_blas = no ; then
2929		have_taucs=no
2930		if test $ol_with_taucs != auto ; then
2931			AC_MSG_ERROR([Need Blas library for Taucs solver])
2932		else
2933                        AC_MSG_WARN([Taucs needs BLAS; not supported])
2934		fi
2935	else
2936		save_LIBS="$LIBS"
2937		try_taucs_LIBS="-ltaucs"
2938		LIBS="$try_taucs_LIBS $METIS_LIBS $LAPACK_LIBS $BLAS_LIBS $LIBS"
2939		AC_TRY_LINK([#include "taucs.h"
2940			],[
2941			taucs_ccs_matrix* A;
2942			void**            F;
2943			int		  nrhs;
2944			void*		  X;
2945			void*		  B;
2946			char**		  options;
2947			void**		  opt_arg;
2948			int taucs_linsolve(A, F, nrhs, X, B, options, opt_arg);
2949		],[have_taucs=yes],[have_taucs=no])
2950		LIBS="$save_LIBS"
2951	fi
2952	if test $have_taucs != no ; then
2953		AC_DEFINE(USE_TAUCS,1,[define to use Taucs libraries])
2954		TAUCS_LIBS="$try_taucs_LIBS"
2955	fi
2956	if test "$have_taucs" = "yes" ; then
2957		AC_MSG_RESULT([yes])
2958	else
2959		AC_MSG_RESULT([no])
2960	fi
2961fi
2962
2963dnl ----------------------------------------------------------------
2964dnl
2965dnl Checks id DeadBeat can be built
2966dnl
2967if test $ol_link_lapack != no -o $ol_link_meschach != no ; then
2968	AC_DEFINE(USE_DBC,1,[define if you want to use GPC/DeadBeat control])
2969else
2970	dnl Required for GPC/Deadbeat (should be able to work it 'round...)
2971	AC_MSG_WARN([GPC/Deadbeat not allowed])
2972fi
2973
2974dnl ----------------------------------------------------------------
2975dnl
2976dnl Use GiNaC?
2977dnl
2978ol_link_ginac=no
2979if test $ol_with_ginac != no ; then
2980	AC_LANG_CPLUSPLUS
2981	AC_LANG_C
2982	AC_MSG_CHECKING([for GiNaC library])
2983	have_ginac=no
2984
2985	ginac-config --version >/dev/null 2>&1
2986	if test $? = 0 ; then
2987		GINACLIB_LIBS=`ginac-config --libs`
2988		GINACLIB_CPPFLAGS=`ginac-config --cppflags`
2989		have_ginac=yes
2990	else
2991		pkg-config ginac
2992		if test $? = 0; then
2993			GINACLIB_LIBS=`pkg-config --libs ginac`
2994			GINACLIB_CPPFLAGS=`pkg-config --cflags ginac`
2995			have_ginac=yes
2996		fi
2997	fi
2998
2999	if test $have_ginac = yes ; then
3000		ol_link_ginac=yes
3001		AC_DEFINE(USE_GINAC,1,[define if GiNaC is available])
3002		AC_MSG_RESULT([yes])
3003	else
3004		AC_MSG_RESULT([no])
3005		if test $ol_with_ginac != auto; then
3006			AC_MSG_ERROR([GiNaC not available])
3007		else
3008			AC_MSG_WARN([GiNaC not available])
3009		fi
3010	fi
3011fi
3012
3013dnl ----------------------------------------------------------------
3014dnl
3015dnl Checks for library functions.
3016dnl
3017AC_CHECK_FUNCS([ \
3018	atoi \
3019	atol \
3020	chdir \
3021	copysign \
3022	feenableexcept \
3023	finite \
3024	get_ncpus \
3025	get_nprocs \
3026	get_nprocs_conf \
3027	getaddrinfo \
3028	getcwd \
3029	gethostbyname \
3030	gethostbyname2 \
3031	getopt \
3032	getopt_long \
3033	getpid \
3034	inet_aton \
3035	localtime \
3036	memset \
3037	memmove \
3038	mkstemp \
3039	mlockall \
3040	nanosleep \
3041	pstat_getdynamic \
3042	pstat_getprocessor \
3043	putenv \
3044	sched_setaffinity \
3045	setenv \
3046	shmget \
3047	signal \
3048	sleep \
3049	strftime \
3050	strtod \
3051	strtol \
3052	strtoul \
3053	time \
3054	times \
3055	unsetenv \
3056	usleep \
3057])
3058
3059dnl ----------------------------------------------------------------
3060dnl
3061dnl Checks if we can detect how many processors can be used on smp arch
3062dnl
3063if test "$ac_cv_func_get_nprocs" = "no" ; then
3064	if test "$ac_cv_header_sys_sysinfo_h" = "yes" ; then
3065	        AC_TRY_LINK([
3066#include <sys/sysinfo.h>
3067       		],[
3068        return get_nprocs();
3069       		],[have_get_nprocs=yes],[have_get_nprocs=no])
3070	else
3071	        AC_TRY_LINK([
3072       		],[
3073        return get_nprocs();
3074       		],[have_get_nprocs=yes],[have_get_nprocs=no])
3075	fi
3076
3077	if test "$have_get_nprocs" = "yes" ; then
3078		AC_DEFINE(HAVE_GET_NPROCS,1,[define if get_nprocs is available])
3079	fi
3080fi
3081
3082dnl ----------------------------------------------------------------
3083dnl
3084dnl Make sure we can use sleep with C++
3085dnl
3086if test "$ac_cv_func_sleep" = "yes" ; then
3087	AC_LANG_CPLUSPLUS
3088	AC_TRY_LINK([
3089#include <unistd.h>
3090       	],[
3091        sleep(1);
3092       	],[use_sleep=yes],[use_sleep=no])
3093	if test "$use_sleep" = "yes" ; then
3094		AC_DEFINE(USE_SLEEP,1,[define if sleep is usable with C++ (issue with MinGW)])
3095	fi
3096	AC_LANG_C
3097fi
3098
3099dnl ----------------------------------------------------------------
3100dnl
3101dnl Checks whether ios has fmtflags type
3102dnl
3103
3104AC_LANG_CPLUSPLUS
3105AC_MSG_CHECKING([whether class ios has fmtflags type])
3106AC_TRY_COMPILE([#include <iostream>],[
3107	std::ios::fmtflags f;
3108],[have_fmtflags=yes],[have_fmtflags=no])
3109
3110if test $have_fmtflags != no ; then
3111	AC_DEFINE(HAVE_FMTFLAGS_IN_IOS,1,
3112		[define if class ios has 'fmtflags' type])
3113	AC_MSG_RESULT([yes])
3114else
3115	AC_TRY_COMPILE([#include <iostream.h>],[
3116		std::ios::fmtflags f;
3117],[have_fmtflags=yes],[have_fmtflags=no])
3118
3119	if test $have_fmtflags != no ; then
3120		AC_DEFINE(HAVE_FMTFLAGS_IN_IOS,1,
3121			[define if class ios has 'fmtflags' type])
3122		AC_MSG_RESULT([yes])
3123	else
3124		AC_MSG_RESULT([no])
3125	fi
3126fi
3127AC_LANG_C
3128
3129dnl ----------------------------------------------------------------
3130dnl Add EXPORT_DYNAMIC_FLAG_SPEC to LDFLAGS immediately before exit
3131dnl otherwise all the tests during configure would fail
3132
3133LDFLAGS="$LDFLAGS $EXPORT_DYNAMIC_FLAG_SPEC"
3134
3135
3136dnl ----------------------------------------------------------------
3137dnl TODO: add a check about whether a fortran (F77, F95) compiler is
3138dnl needed, and bail out if not available
3139
3140dnl ----------------------------------------------------------------
3141dnl
3142dnl Variable substituion
3143dnl
3144AC_SUBST(MPI_LIBS)
3145AC_SUBST(CHACO_LIBS)
3146AC_SUBST(METIS_LIBS)
3147AC_SUBST(UMFPACK_LIBS)
3148AC_SUBST(KLU_LIBS)
3149AC_SUBST(Y12_LIBS)
3150AC_SUBST(SUPERLU_LIBS)
3151AC_SUBST(WSMP_LIBS)
3152AC_SUBST(HARWELL_LIBS)
3153AC_SUBST(MESCHACH_LIBS)
3154AC_SUBST(LAPACK_LIBS)
3155AC_SUBST(BLAS_LIBS)
3156AC_SUBST(TAUCS_LIBS)
3157AC_SUBST(ARPACK_LIBS)
3158AC_SUBST(JDQZ_LIBS)
3159AC_SUBST(THREAD_LIBS)
3160AC_SUBST(ATOMIC_OPS_LIBS)
3161AC_SUBST(SECURITY_LIBS)
3162AC_SUBST(NETCDF_LIBS)
3163AC_SUBST(UDUNITS_LIBS)
3164AC_SUBST(RT_LIBS)
3165AC_SUBST(RTAI_LDFLAGS)
3166AC_SUBST(ANN_LIBS)
3167AC_SUBST(BULLET_LIBS)
3168AC_SUBST(PYTHON_NUMPY_HEADERS)
3169AC_SUBST(OCTAVE_LIBS)
3170AC_SUBST(OCTAVE_INCLUDE)
3171AC_SUBST(MODULES_DIRS)
3172AC_SUBST(MODULE_LOADPATH)
3173AC_SUBST(wl)
3174
3175dnl AC_SUBST(GINACLIB_CONFIG)
3176AC_SUBST(GINACLIB_CPPFLAGS)
3177AC_SUBST(GINACLIB_LIBS)
3178
3179AC_SUBST(DATE)
3180
3181dnl conditional build declarations
3182AM_CONDITIONAL(MBDYN_DEVEL,[test "$MBDYN_DEVEL" = "yes"])
3183
3184AM_CONDITIONAL(USE_ARPACK,[test "$ol_link_arpack" = yes])
3185AM_CONDITIONAL(USE_CHACO,[test "$ol_link_chaco" = yes])
3186AM_CONDITIONAL(USE_GINAC,[test "$ol_link_ginac" = yes])
3187AM_CONDITIONAL(USE_JDQZ,[test "$ol_link_jdqz" = yes])
3188AM_CONDITIONAL(USE_METIS,[test "$ol_link_metis" = yes])
3189AM_CONDITIONAL(USE_OCTAVE,[test "$use_octave" = yes])
3190AM_CONDITIONAL(USE_PYTHON,[test "$use_python" = yes])
3191AM_CONDITIONAL(USE_RTAI,[test "$use_rtai" = yes])
3192AM_CONDITIONAL(USE_SCHUR,[test "$use_schur" = yes])
3193AM_CONDITIONAL(USE_SOCKET,[test "$use_socket" = yes])
3194AM_CONDITIONAL(USE_ANN,[test "$ol_link_ann" = yes])
3195AM_CONDITIONAL(USE_AUTODIFF,[test "$ol_enable_autodiff" = yes])
3196
3197AM_CONDITIONAL(FOOL_LIBTOOL,[test "$fool_libtool" = yes])
3198AM_CONDITIONAL(BUILD_Y12,[test "$ol_link_y12" = yes])
3199
3200AM_CONDITIONAL(BUILD_STATIC_MODULES,[test "$build_static_modules" = yes])
3201AM_CONDITIONAL(BUILD_CHARM,[test "$build_charm" = yes])
3202
3203dnl ----------------------------------------------------------------
3204dnl
3205dnl Prepare for libtool output:
3206dnl
3207
3208dnl LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/\.lo/g'`
3209dnl AC_SUBST(LTLIBOBJS)
3210dnl LTALLOCA=`echo "$ALLOCA" | sed 's/\.o/\.lo/g'`
3211dnl AC_SUBST(LTALLOCA)
3212
3213dnl ----------------------------------------------------------------
3214dnl
3215dnl final output
3216dnl
3217AC_CONFIG_FILES([Makefile \
3218 	libraries/Makefile \
3219 	libraries/libmbutil/Makefile \
3220 	libraries/libobjs/Makefile \
3221 	libraries/libcolamd/Makefile \
3222 	libraries/libnaive/Makefile \
3223 	libraries/liby12/Makefile \
3224 	libraries/libmbmath/Makefile \
3225 	libraries/libmbwrap/Makefile \
3226 	libraries/libann/Makefile \
3227 	libraries/libmbc/Makefile \
3228 	mbdyn/Makefile \
3229 	mbdyn/base/Makefile \
3230 	mbdyn/aero/Makefile \
3231 	mbdyn/elec/Makefile \
3232 	mbdyn/thermo/Makefile \
3233 	mbdyn/hydr/Makefile \
3234 	mbdyn/struct/Makefile \
3235 	modules/Makefile \
3236 	utils/Makefile \
3237 	etc/Makefile \
3238 	etc/modal.d/Makefile \
3239 	etc/pam.d/Makefile \
3240 	var/Makefile \
3241 	manual/Makefile \
3242 	manual/femgen.1 \
3243 	manual/mbdyn.1 \
3244 	include/Makefile \
3245 	include/ac/Makefile
3246 	build/Makefile])
3247AC_OUTPUT
3248