#----------------------------------------------------------------
#
#  configure.ac
#
#  Autoconf source file for Boundary Element MMTL (bem).
#  This file, along with aclocal, autoconf, Makefile.am,
#  and automake can produce a highly functional configuration
#  script and Makefile.
#
#  Sharon Zahn, Bob Techentin
#  October 3, 2002
#
#  Copyright 2002-2004 Mayo Foundation.  All Rights Reserved.
#  $Id: configure.ac,v 1.10 2004/04/22 20:07:12 techenti Exp $
#
#----------------------------------------------------------------


#----------------------------------------------------------------
#  Declare the package name and version.
#  All the bouquets and brickbats go to Sharon. :-)
#----------------------------------------------------------------
AC_INIT(BEM, 1.0, zahn.sharon@mayo.edu)

#----------------------------------------------------------------
#  Give autoconf a point of reference, and tell it that
#  we're going to use automake later.
#----------------------------------------------------------------
AC_CONFIG_SRCDIR(src/nmmtl.cpp)
AM_INIT_AUTOMAKE

#----------------------------------------------------------------
#  Check platform name so we can specify particular
#  compilers and switches that we like.
#----------------------------------------------------------------
AC_CANONICAL_HOST
case "${host}" in
*hpux10*)
	#  On HP-UX 10.0
	#  Choose native compilers aCC, and f90.
	#  Also use the FORTRAN_UNDERBARS mode, to avoid
	#  conflicts with NSWC's FMIN and C runtime fmin().
	#  Undefine "inline" macro, because we will get
	#  thousands of duplicates from math.h on this
	#  older aCC compiler.
	CC=cc
	CXX=aCC
	AM_CXXFLAGS="+O2 -DFORTRAN_UNDERBARS -Uinline"
	F77=f90
	AM_FFLAGS="+ppu -O2"
;;
*hpux11*)
	#  On HP-UX 11.0
	#  Choose native compilers aCC, and f90.
	#  Also use the FORTRAN_UNDERBARS mode, to avoid
	#  conflicts with NSWC's FMIN and C runtime fmin().
	CC=cc
	CXX=aCC
	AM_CXXFLAGS="+O2 -DFORTRAN_UNDERBARS"
	F77=f90
	AM_FFLAGS="+ppu -O2"
;;
*cygwin*)
	#  On Windows using Cygwin
	#  Use the GNU compilers, but not the cygwin.dll,
	#  which would infect our code with the GPL.
	#  Note that we must also specify the gcc compiler,
	#  as the -mno-cygwin switch makes it behave differently
	#  for many of the configure tests.
	CC="gcc -mno-cygwin"
	CXX="g++ -mno-cygwin"
	F77="g77 -mno-cygwin"
	AM_CXXFLAGS="-DFORTRAN_UNDERBARS"
;;
*linux*)
	#  For Linux, all flavors...
	#  Use the GNU compilers for C++ and FORTRAN.
	CXX="g++"
	F77="g77"
	AM_CXXFLAGS="-DFORTRAN_UNDERBARS"
;;
esac
AC_SUBST(AM_CXXFLAGS)
AC_SUBST(AM_FFLAGS)



#----------------------------------------------------------------
#  Portabiliy checks were, for the most part, generated by
#  an initial 'autoscan' of the source code.  The configure
#  script checks the system for features and generates the
#  compile commands with flags like -DHAVE_STDLIB_H=1, but
#  the nmmtl source code does not (as of this writing) take
#  complete advantage of those flags.
#----------------------------------------------------------------

#----------------------------------------------------------------
# Checks for programs.
#----------------------------------------------------------------
AC_PROG_CXX
AC_PROG_F77

#----------------------------------------------------------------
# Checks for header files.
#----------------------------------------------------------------
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h float.h limits.h malloc.h stddef.h stdlib.h string.h unistd.h pwd.h])

#----------------------------------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
#----------------------------------------------------------------
AC_C_CONST
AC_TYPE_UID_T
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_STRUCT_TM

AC_F77_WRAPPERS

#----------------------------------------------------------------
# Checks for library functions.
#----------------------------------------------------------------
AC_F77_LIBRARY_LDFLAGS
AC_FUNC_GETGROUPS
AC_FUNC_MALLOC
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([getcwd getlogin pow rmdir sqrt strchr strdup strrchr strstr])

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
