Skip to content
代码片段 群组 项目
configure.ac 10.6 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],[vulgaris],[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

dnl check whether mpi is enabled
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

if test x"$enable_mpi" == x"yes"; then
  octopus_default_cc=mpicc
else
  octopus_default_cc=gcc
fi

AC_PROG_CC($octopus_default_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_SIZEOF(size_t)
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 getopt_long])
dnl ============================================================================
dnl This part of the configuration file tries to sort out what needs to be built.
dnl In particular, the code can be compiled in single-precision, in debug mode,
dnl and with OpenMP threads.
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]))
AC_ARG_ENABLE(opencl, AS_HELP_STRING([--enable-opencl], [OpenCL support (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
if test x"${enable_opencl}" == x"yes" ; then
  AC_DEFINE(HAVE_OPENCL, 1, [defined if opencl support is enabled])
  AC_MSG_WARN([
  
	Experimental OpenCL support enabled.
  ])
fi
AM_CONDITIONAL(COMPILE_OPENCL, test x"${enable_opencl}" == x"yes")

dnl workaround for xlf compilers
ac_enable_f90_forall=yes
AC_ARG_ENABLE(f90-forall, AS_HELP_STRING([--disable-f90-forall], [Workaround for buggy xlf compilers]), 
        [ac_enable_f90_forall=${enableval}])
if test x"${ac_enable_f90_forall}" = x"no"; then
  F90_FORALL=no
else
  F90_FORALL=yes
fi
AC_SUBST(F90_FORALL)

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)

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")
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
	      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])
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 compilers define the sizeof intrinsic
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
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 dimensions 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 ===================================================================
ACX_BLAS([], AC_MSG_ERROR([could not find required BLAS library]))
ACX_LAPACK([], AC_MSG_ERROR([could not find required LAPACK library]))
dnl check for GSL
AC_LANG_PUSH(C)
  AC_MSG_ERROR([could not find required GSL library]))
dnl check for FFT
ACX_FFT
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)
ACX_OCTOPUS_COMPILATION_INFO

  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
  external_libs/slatec/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
  testsuite/components/Makefile 
  testsuite/finite_systems_3d/Makefile
  testsuite/functionals/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