Skip to content
代码片段 群组 项目
configure.ac 9.8 KB
Newer Older
## Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
##
AC_INIT([Octopus],[3.2.0pre1],[octopus-devel@tddft.org],[octopus])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])

# Installation prefix by default
# who am i
AC_CANONICAL_HOST

# Checks for programs.
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_YACC
AC_PROG_CC

# optimizations extensions supported by the compiler
AC_C_INLINE
AC_C_RESTRICT
ACX_C_BUILTIN_PREFETCH

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([signal.h errno.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_CHECK_TYPES([uint32_t, uint64_t])
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned long long)

# Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_STAT
AC_CHECK_FUNCS([gettimeofday \
strndup tcgetpgrp scandir alphasort \
sigaction readdir closedir strchr strtod \
perror strcasestr sbrk])
dnl ============================================================================
dnl This part of the configuration file tries to sort out what needs to be built.
dnl In particular, the code can be compile in single precision, mpi, using
dnl complex wave-functions in the ground-state, and in debug mode.

dnl these are the --enable/--disable possible in octopus
AC_ARG_ENABLE(single, AS_HELP_STRING([--enable-single], [octopus in single precision]))
AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug], [debug mode]), [DEBUG=${enableval}])
AC_ARG_ENABLE(openmp, AS_HELP_STRING([--enable-openmp], [Multi-threaded parallel version using OpenMP (experimental)]))

if test -n "${enable_single}" -a x"${enable_single}" != x"no"; then
  SINGLE_PRECISION=1
fi

if test -n "${enable_openmp}" -a x"${enable_openmp}" != x"no"; then
  USE_OMP=1
fi
AC_ARG_ENABLE(mpi, AS_HELP_STRING([--enable-mpi(=PATH)], [Parallel version]))
case $enable_mpi in
  yes) ;;
  no | "") enable_mpi=no ;;
  -* | */* | *.a | *.so | *.so.* | *.o)
    LIBS_MPI="$enable_mpi"
    enable_mpi=yes
    ;;
  *) 
    LIBS_MPI="-l$enable_mpi"
    enable_mpi=yes
    ;;
esac

dnl check for METIS
if test x"$enable_mpi" != x"no"; then
  ACX_METIS
fi
AM_CONDITIONAL(COMPILE_METIS, test x${HAVE_METIS} = x1)
  
dnl check for LibNBC
if test x"$enable_mpi" != x"no"; then
 ACX_LIBNBC
fi
AM_CONDITIONAL(COMPILE_LIBNBC, test x${HAVE_LIBNBC} = x1)

dnl check for newuoa
ACX_NEWUOA
AM_CONDITIONAL(COMPILE_NEWUOA, test x${HAVE_NEWUOA} = x1)

dnl If in parallel, enable zoltan compilation
AM_CONDITIONAL(COMPILE_ZOLTAN, test x"$enable_mpi" != x"no")
dnl if libnbc is enabled, check for C MPI
if test x"$enable_mpi" == x"yes"; then
  AC_CHECK_HEADER(mpi.h,,AC_MSG_ERROR([cannot find mpi.h]))
  ACX_MPI([], AC_MSG_ERROR([cannot call MPI from C]))
dnl build/install perl bits unless --disable-perl is used
AC_ARG_ENABLE([perl],
	      AS_HELP_STRING([--disable-perl], [don't build/install perl components]),
	      [ac_cv_build_perl=$enableval],
	      [ac_cv_build_perl=yes])
if test "x$ac_cv_build_perl" = "xyes"; then
  AC_PATH_PROG([PERL], [perl], [], [])
  if test -z "$PERL" ; then
     AC_MSG_WARN([perl not found. Disabling perl parts])
     ac_cv_build_perl="no"
  fi
fi
AM_CONDITIONAL([ENABLE_PERL], [test x"$ac_cv_build_perl" = x"yes"])
dnl try to find out what is the default FORTRAN 90 compiler
dnl note that this has to be done after the AC_ARG_ENABLE(mpi...)
  AC_PROG_FC([mpif90 mpf90 mpxlf90 mpxlf95 mpxlf_r], [Fortran 90])
  AC_PROG_FC([], Fortran 90)
fi
if test x"$FC" = x; then
  AC_MSG_ERROR([could not find Fortran 90 compiler])
FCFLAGS="${acx_save_fcflags}"

ACX_FCFLAGS

dnl octopus needs the preprocessor. The result goes to FCCPP
dnl this is a hack, and should be changed in the future
AC_LANG_PREPROC

dnl how Fortran mangles function names
acx_save_libs="${LIBS}"
LIBS="${FCEXTRALIBS} $FCLIBS"

dnl Sometimes Fortran may use the flush function, sometimes not.
dnl Some compiler define the sizeof intrinsic
ACX_FC_SIZEOF

dnl check whether we have or not a compiler that allows for very long lines...
dnl check whether the Fortran 90 compiler accepts line markers cast by the preprocessor.
ACX_F90_ACCEPTS_LINE_NUMBERS

dnl check whether the Fortran compiler supports command line arguments
ACX_FC_COMMAND_LINE_ARGUMENTS
dnl check whether the Fortran compiler supports Fortran 2003's c_ptr type
ACX_FC_F2003_C_PTR

dnl check flag to include module path
AX_F90_MODULE_FLAG
F90_MODULE_FLAG=$ax_cv_f90_modflag
if test "${USE_OMP}"; then
  AC_DEFINE(USE_OMP, 1, [enable OpenMP support])
  AX_OPENMP(,AC_MSG_ERROR([Fortran compiler does not support OpenMP]))
  FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
fi

dnl ============================================================================
dnl find what is the extension of the programs supposed to be
dnl mpi
AS_IF([test x"$enable_mpi" != x"no"], [MYEXT="${MYEXT}_mpi"])

dnl debug mode
if test "${SINGLE_PRECISION}"; then
  AC_DEFINE(SINGLE_PRECISION, 1, [octopus compiled in single precision])
  MYEXT="${MYEXT}_single"
fi

dnl debug mode
if test x"${DEBUG}" = x"no" ; then
  AC_DEFINE(NDEBUG, yes, [octopus compiled without debug mode])

dnl set the default extension for the programs
EXEEXT="${MYEXT}${EXEEXT}"

dnl we only generate the utilities if single precision and mpi are off
if test x"$enable_mpi" = x"no" -a -z "${SINGLE_PRECISION}"; then
AC_ARG_WITH(max-dim, [  --with-max-dim=NDIM     maximum number of dimension Octopus can use,
                          the default is 3 (other values are experimental)],
  [maxdim=$withval], [maxdim=3])

AC_DEFINE_UNQUOTED(MAX_DIM, $maxdim, [the maximum dimension of the space])
dnl tell the user what we will be compiling
echo "**********************************************"
echo "***   octopus${EXEEXT} $msg will be generated "
echo "**********************************************"

dnl ===================================================================
dnl check for BLAS
ACX_BLAS([], AC_MSG_ERROR([could not find required blas library]))
dnl check for LAPACK
ACX_LAPACK([], AC_MSG_ERROR([could not find required lapack library]))
dnl check for GSL
AC_LANG_PUSH(C)
  [CFLAGS="$CFLAGS $GSL_CFLAGS"], 
  AC_MSG_ERROR([could not find required gsl library]))
dnl check for FFT
ACX_FFT
dnl check for SPARSKIT
ACX_SPARSKIT([], AC_MSG_WARN([SPARSKIT library not found. Will not use it]))
dnl check for Fortran MPI support
  ACX_MPI([], AC_MSG_ERROR([could not compile an mpi test program]))
  ACX_MPI_FC_MODULE
dnl now I run configure for the internal libraries
AC_CONFIG_SUBDIRS([external_libs/spglibs])

# This is certainly wrong, but I don't know
# how to do it right
LINK="$FC $FCFLAGS $LDFLAGS -o \$@"
AC_SUBST(LINK)
  external_libs/Makefile
  external_libs/metis-4.0/Makefile
  external_libs/qshep/Makefile
  external_libs/spglib/Makefile
  external_libs/spglib/src/Makefile
  external_libs/zoltan/Makefile
  src/math/Makefile
  src/ions/Makefile
  src/poisson/Makefile
  src/states/Makefile
  src/system/Makefile
  src/scf/Makefile
  src/td/Makefile
  src/opt_control/Makefile
  src/sternheimer/Makefile
  src/main/Makefile
  src/utils/Makefile
  doc/html/icons/Makefile
  doc/html/js/Makefile
  doc/html/vars/Makefile
  share/recipes/Makefile
  share/recipes/en/Makefile
  share/recipes/it/Makefile
  share/util/Makefile
  share/samples/Makefile
  build/octopus.spec
  testsuite/Makefile
  testsuite/finite_systems_1d/Makefile 
  testsuite/finite_systems_3d/Makefile
  testsuite/linear_response/Makefile
  testsuite/optimal_control/Makefile
  testsuite/open_systems/Makefile
  testsuite/periodic_systems/Makefile])
AC_CONFIG_FILES([testsuite/oct-run_testsuite], [chmod +x testsuite/oct-run_testsuite])
AC_OUTPUT