Request for inclusion [was: Re: Autoconf MPI macros]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all again!

After the discussion on the mailing list and the subsequent
modifications I did to the AX_PROG_{CC,FC,F77,CXX}_MPI macros, I want to
suggest that these new macros should be included into the autoconf macro
archive.

You can pull the new macros and the modifications to the documentation
of the older macro AX_MPI from here:
  https://github.com/olenz/autoconf-archive

For reference, I have attached the new macros as well as the modified
ax_mpi.m4 to this mailing.

Olaf

-- 
Dr. rer. nat. Olaf Lenz
Institut fÃr Computerphysik, Pfaffenwaldring 27, D-70569 Stuttgart
Phone: +49-711-685-63607
# ===========================================================================
#          http://www.gnu.org/software/autoconf-archive/ax_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_MPI([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
#   This macro tries to find out how to compile programs that use MPI
#   (Message Passing Interface), a standard API for parallel process
#   communication (see http://www-unix.mcs.anl.gov/mpi/)
#
#   On success, it sets the MPICC, MPICXX, MPIF77, or MPIFC output variable
#   to the name of the MPI compiler, depending upon the current language.
#   (This may just be $CC/$CXX/$F77/$FC, but is more often something like
#   mpicc/mpiCC/mpif77/mpif90.) It also sets MPILIBS to any libraries that
#   are needed for linking MPI (e.g. -lmpi or -lfmpi, if a special
#   MPICC/MPICXX/MPIF77/MPIFC was not found).
#
#   Note that this macro should be used only if you just have a few
#   source files that need to be compiled using MPI. In particular,
#   you should neither overwrite CC/CXX/F77/FC with the values of
#   MPICC/MPICXX/MPIF77/MPIFC, nor assume that you can use the same
#   flags etc. as the standard compilers.
#   If you want to compile a whole program using the MPI compiler
#   commands, use one of the macros AX_PROG_{CC,CXX,FC}_MPI.
#
#   ACTION-IF-FOUND is a list of shell commands to run if an MPI library is
#   found, and ACTION-IF-NOT-FOUND is a list of commands to run if it is not
#   found. If ACTION-IF-FOUND is not specified, the default action will
#   define HAVE_MPI.
#
# LICENSE
#
#   Copyright (c) 2008 Steven G. Johnson <stevenj@xxxxxxxxxxxx>
#   Copyright (c) 2008 Julian C. Cummings <cummings@xxxxxxxxxxxxxxxx>
#
#   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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
#
#   As a special exception, the respective Autoconf Macro's copyright owner
#   gives unlimited permission to copy, distribute and modify the configure
#   scripts that are the output of Autoconf when processing the Macro. You
#   need not follow the terms of the GNU General Public License when using
#   or distributing such scripts, even though portions of the text of the
#   Macro appear in them. The GNU General Public License (GPL) does govern
#   all other use of the material that constitutes the Autoconf Macro.
#
#   This special exception to the GPL applies to versions of the Autoconf
#   Macro released by the Autoconf Archive. When you make and distribute a
#   modified version of the Autoconf Macro, you may extend this special
#   exception to the GPL to apply to your modified version as well.

#serial 7

AU_ALIAS([ACX_MPI], [AX_MPI])
AC_DEFUN([AX_MPI], [
AC_PREREQ(2.50) dnl for AC_LANG_CASE

AC_LANG_CASE([C], [
	AC_REQUIRE([AC_PROG_CC])
	AC_ARG_VAR(MPICC,[MPI C compiler command])
	AC_CHECK_PROGS(MPICC, mpicc hcc mpxlc_r mpxlc mpcc cmpicc, $CC)
	ax_mpi_save_CC="$CC"
	CC="$MPICC"
	AC_SUBST(MPICC)
],
[C++], [
	AC_REQUIRE([AC_PROG_CXX])
	AC_ARG_VAR(MPICXX,[MPI C++ compiler command])
	AC_CHECK_PROGS(MPICXX, mpic++ mpicxx mpiCC hcp mpxlC_r mpxlC mpCC cmpic++, $CXX)
	ax_mpi_save_CXX="$CXX"
	CXX="$MPICXX"
	AC_SUBST(MPICXX)
],
[Fortran 77], [
	AC_REQUIRE([AC_PROG_F77])
	AC_ARG_VAR(MPIF77,[MPI Fortran 77 compiler command])
	AC_CHECK_PROGS(MPIF77, mpif77 hf77 mpxlf_r mpxlf mpf77 cmpifc, $F77)
	ax_mpi_save_F77="$F77"
	F77="$MPIF77"
	AC_SUBST(MPIF77)
],
[Fortran], [
	AC_REQUIRE([AC_PROG_FC])
	AC_ARG_VAR(MPIFC,[MPI Fortran compiler command])
	AC_CHECK_PROGS(MPIFC, mpif90 mpxlf95_r mpxlf90_r mpxlf95 mpxlf90 mpf90 cmpif90c, $FC)
	ax_mpi_save_FC="$FC"
	FC="$MPIFC"
	AC_SUBST(MPIFC)
])

if test x = x"$MPILIBS"; then
	AC_LANG_CASE([C], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
		[C++], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
		[Fortran 77], [AC_MSG_CHECKING([for MPI_Init])
			AC_LINK_IFELSE([AC_LANG_PROGRAM([],[      call MPI_Init])],[MPILIBS=" "
				AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])],
		[Fortran], [AC_MSG_CHECKING([for MPI_Init])
			AC_LINK_IFELSE([AC_LANG_PROGRAM([],[      call MPI_Init])],[MPILIBS=" "
				AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])])
fi
AC_LANG_CASE([Fortran 77], [
	if test x = x"$MPILIBS"; then
		AC_CHECK_LIB(fmpi, MPI_Init, [MPILIBS="-lfmpi"])
	fi
	if test x = x"$MPILIBS"; then
		AC_CHECK_LIB(fmpich, MPI_Init, [MPILIBS="-lfmpich"])
	fi
],
[Fortran], [
	if test x = x"$MPILIBS"; then
		AC_CHECK_LIB(fmpi, MPI_Init, [MPILIBS="-lfmpi"])
	fi
	if test x = x"$MPILIBS"; then
		AC_CHECK_LIB(mpichf90, MPI_Init, [MPILIBS="-lmpichf90"])
	fi
])
if test x = x"$MPILIBS"; then
	AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"])
fi
if test x = x"$MPILIBS"; then
	AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"])
fi

dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
dnl latter uses $CPP, not $CC (which may be mpicc).
AC_LANG_CASE([C], [if test x != x"$MPILIBS"; then
	AC_MSG_CHECKING([for mpi.h])
	AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
		AC_MSG_RESULT(no)])
fi],
[C++], [if test x != x"$MPILIBS"; then
	AC_MSG_CHECKING([for mpi.h])
	AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
		AC_MSG_RESULT(no)])
fi],
[Fortran 77], [if test x != x"$MPILIBS"; then
	AC_MSG_CHECKING([for mpif.h])
	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[      include 'mpif.h'])],[AC_MSG_RESULT(yes)], [MPILIBS=""
		AC_MSG_RESULT(no)])
fi],
[Fortran], [if test x != x"$MPILIBS"; then
	AC_MSG_CHECKING([for mpif.h])
	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[      include 'mpif.h'])],[AC_MSG_RESULT(yes)], [MPILIBS=""
		AC_MSG_RESULT(no)])
fi])

AC_LANG_CASE([C], [CC="$ax_mpi_save_CC"],
	[C++], [CXX="$ax_mpi_save_CXX"],
	[Fortran 77], [F77="$ax_mpi_save_F77"],
	[Fortran], [FC="$ax_mpi_save_FC"])

AC_SUBST(MPILIBS)

# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x = x"$MPILIBS"; then
        $2
        :
else
        ifelse([$1],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$1])
        :
fi
])dnl AX_MPI
dnl -*- mode: autoconf -*-
# ===========================================================================
#       http://www.gnu.org/software/autoconf-archive/ax_prog_cc_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_PROG_CC_MPI([MPI-WANTED-TEST[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
#
# DESCRIPTION
#
#   This macro tries to find out how to compile C programs that use MPI
#   (Message Passing Interface), a standard API for parallel process
#   communication (see http://www-unix.mcs.anl.gov/mpi/).
#   The macro has to be used instead of the standard macro AC_PROG_CC
#   and will replace the standard variable CC with the found compiler.
#
#   MPI-WANTED-TEST is used to test whether MPI is actually wanted by
#   the user. If MPI-WANTED_TEST is omitted or if it succeeds, the
#   macro will try to find out how to use MPI, if it fails, the macro
#   will call AC_PROG_CC to find a standard C compiler instead.
#
#   When MPI is found, ACTION-IF-FOUND will be executed, if MPI is not
#   found (or MPI-WANTED-TEST fails) ACTION-IF-NOT-FOUND is
#   executed. If ACTION-IF-FOUND is not set, the macro will define
#   HAVE_MPI.
#
# EXAMPLE
#
#  # If --with-mpi=auto is used, try to find MPI, but use standard C
#  compiler if it is not found.
#  # If --with-mpi=yes is used, try to find MPI and fail if it isn't
#  # found.
#  # If --with-mpi=no is used, use a standard C compiler instead.
#  AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
#      [compile with MPI (parallelization) support. If none is found,
#      MPI is not used. Default: auto])
#  ],,[with_mpi=auto])
#
#  AX_PROG_CC_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
#    use_mpi=no
#    if test x"$with_mpi" = xyes; then
#      AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
#    else
#      AC_MSG_WARN([No MPI compiler found, won't use MPI.])
#    fi
#  ])
#
# LICENSE
#
#   Copyright (c) 2010,2011 Olaf Lenz <olenz@xxxxxxxxxxxxxxxxxxxx>
#
#   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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
#
#   As a special exception, the respective Autoconf Macro's copyright owner
#   gives unlimited permission to copy, distribute and modify the configure
#   scripts that are the output of Autoconf when processing the Macro. You
#   need not follow the terms of the GNU General Public License when using
#   or distributing such scripts, even though portions of the text of the
#   Macro appear in them. The GNU General Public License (GPL) does govern
#   all other use of the material that constitutes the Autoconf Macro.
#
#   This special exception to the GPL applies to versions of the Autoconf
#   Macro released by the Autoconf Archive. When you make and distribute a
#   modified version of the Autoconf Macro, you may extend this special
#   exception to the GPL to apply to your modified version as well.

#serial 1

AC_DEFUN([AX_PROG_CC_MPI], [
AC_PREREQ(2.50) 

# Check for compiler
# Needs to be split off into an extra macro to ensure right expansion
# order.
AC_REQUIRE([_AX_PROG_CC_MPI],[_AX_PROG_CC_MPI([$1])])

AS_IF([test x"$_ax_prog_cc_mpi_mpi_wanted" = xno], 
  [ _ax_prog_cc_mpi_mpi_found=no ],
  [
    AC_LANG_PUSH([C])
    # test whether MPI_Init is available
    # We do not use AC_SEARCH_LIBS here, as it caches its outcome and
    # thus disallows corresponding calls in the other AX_PROG_*_MPI
    # macros.
    for lib in NONE mpi mpich; do
      save_LIBS=$LIBS
      if test x"$lib" = xNONE; then
        AC_MSG_CHECKING([for function MPI_Init])
      else
        AC_MSG_CHECKING([for function MPI_Init in -l$lib])
        LIBS="-l$lib $LIBS"
      fi
      AC_LINK_IFELSE([AC_LANG_CALL([],[MPI_Init])],
        [ _ax_prog_cc_mpi_mpi_found=yes ],
        [ _ax_prog_cc_mpi_mpi_found=no ])
      AC_MSG_RESULT($_ax_prog_cc_mpi_mpi_found)
      if test "x$_ax_prog_cc_mpi_mpi_found" = "xyes"; then
        break;
      fi
      LIBS=$save_LIBS
    done

    # Check for header
    AS_IF([test x"$_ax_prog_cc_mpi_mpi_found" = xyes], [
      AC_MSG_CHECKING([for mpi.h])
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <mpi.h>])],
        [ AC_MSG_RESULT(yes)], 
        [ AC_MSG_RESULT(no)
         _ax_prog_cc_mpi_mpi_found=no
      ])
    ])
    AC_LANG_POP([C])
])

# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
AS_IF([test x"$_ax_prog_cc_mpi_mpi_found" = xyes], [
        ifelse([$2],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$2])
        :
],[
        $3
        :
])

])dnl AX_PROG_CC_MPI

dnl _AX_PROG_CC_MPI is an internal macro required by AX_PROG_CC_MPI.
dnl To ensure the right expansion order, the main function AX_PROG_CC_MPI
dnl has to be split into two parts.
dnl
dnl Known MPI C compilers:
dnl  mpicc
dnl  mpixlc_r
dnl  mpixlc
dnl  hcc
dnl  mpxlc_r
dnl  mpxlc
dnl  sxmpicc  NEC SX
dnl  mpifcc   Fujitsu
dnl  mpgcc
dnl  mpcc
dnl  cmpicc
dnl  cc
dnl
AC_DEFUN([_AX_PROG_CC_MPI], [
  AC_ARG_VAR(MPICC,[MPI C compiler command])
  ifelse([$1],,[_ax_prog_cc_mpi_mpi_wanted=yes],[
    AC_MSG_CHECKING([whether to compile using MPI])
    if $1; then
      _ax_prog_cc_mpi_mpi_wanted=yes
    else
      _ax_prog_cc_mpi_mpi_wanted=no
    fi
    AC_MSG_RESULT($_ax_prog_cc_mpi_mpi_wanted)
  ])
  if test x"$_ax_prog_cc_mpi_mpi_wanted" = xyes; then
    if test -z "$CC" && test -n "$MPICC"; then
      CC="$MPICC"
    else
      AC_CHECK_TOOLS([CC], [mpicc mpixlc_r mpixlc hcc mpxlc_r mpxlc sxmpicc mpifcc mpgcc mpcc cmpicc cc gcc])
    fi
  fi
  AC_PROG_CC
])dnl _AX_PROG_CC_MPI
dnl -*- mode: autoconf -*-
# ===========================================================================
#       http://www.gnu.org/software/autoconf-archive/ax_prog_cxx_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_PROG_CXX_MPI([MPI-WANTED-TEST[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
#
# DESCRIPTION
#
#   This macro tries to find out how to compile C++ programs that use
#   MPI (Message Passing Interface), a standard API for parallel
#   process communication (see http://www-unix.mcs.anl.gov/mpi/).  The
#   macro has to be used instead of the standard macro AC_PROG_CXX and
#   will replace the standard variable CXX with the found compiler.
#
#   MPI-WANTED-TEST is used to test whether MPI is actually wanted by
#   the user. If MPI-WANTED_TEST is omitted or if it succeeds, the
#   macro will try to find out how to use MPI, if it fails, the macro
#   will call AC_PROG_CC to find a standard C compiler instead.
#
#   When MPI is found, ACTION-IF-FOUND will be executed, if MPI is not
#   found (or MPI-WANTED-TEST fails) ACTION-IF-NOT-FOUND is
#   executed. If ACTION-IF-FOUND is not set, the macro will define
#   HAVE_MPI.
#
# EXAMPLE
#
#  # If --with-mpi=auto is used, try to find MPI, but use standard C
#  compiler if it is not found.
#  # If --with-mpi=yes is used, try to find MPI and fail if it isn't
#  # found.
#  # If --with-mpi=no is used, use a standard C compiler instead.
#  AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
#      [compile with MPI (parallelization) support. If none is found,
#      MPI is not used. Default: auto])
#  ],,[with_mpi=auto])
#
#  AX_PROG_CXX_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
#    use_mpi=no
#    if test x"$with_mpi" = xyes; then
#      AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
#    else
#      AC_MSG_WARN([No MPI compiler found, won't use MPI.])
#    fi
#  ])
#
# LICENSE
#
#   Copyright (c) 2010,2011 Olaf Lenz <olenz@xxxxxxxxxxxxxxxxxxxx>
#
#   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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
#
#   As a special exception, the respective Autoconf Macro's copyright owner
#   gives unlimited permission to copy, distribute and modify the configure
#   scripts that are the output of Autoconf when processing the Macro. You
#   need not follow the terms of the GNU General Public License when using
#   or distributing such scripts, even though portions of the text of the
#   Macro appear in them. The GNU General Public License (GPL) does govern
#   all other use of the material that constitutes the Autoconf Macro.
#
#   This special exception to the GPL applies to versions of the Autoconf
#   Macro released by the Autoconf Archive. When you make and distribute a
#   modified version of the Autoconf Macro, you may extend this special
#   exception to the GPL to apply to your modified version as well.

#serial 1

AC_DEFUN([AX_PROG_CXX_MPI], [
AC_PREREQ(2.50) 

# Check for compiler
# Needs to be split off into an extra macro to ensure right expansion
# order.
AC_REQUIRE([_AX_PROG_CXX_MPI],[_AX_PROG_CXX_MPI([$1])])

AS_IF([test x"$_ax_prog_cxx_mpi_mpi_wanted" = xno], 
  [ _ax_prog_cxx_mpi_mpi_found=no ],
  [
    AC_LANG_PUSH([C++])

    # test whether MPI::Init is available
    # We do not use AC_SEARCH_LIBS here, as it caches its outcome and
    # thus disallows corresponding calls in the other AX_PROG_*_MPI
    # macros.
    for lib in NONE mpi mpich; do
      save_LIBS=$LIBS
      if test x"$lib" = xNONE; then
        AC_MSG_CHECKING([for function MPI::Init])
      else
        AC_MSG_CHECKING([for function MPI::Init in -l$lib])
        LIBS="-l$lib $LIBS"
      fi
      AC_LINK_IFELSE([
        AC_LANG_PROGRAM([
namespace MPI {
char Init();
};
using MPI::Init;],[MPI::Init;])],
        [ _ax_prog_cxx_mpi_mpi_found=yes ],
        [ _ax_prog_cxx_mpi_mpi_found=no ])
      AC_MSG_RESULT($_ax_prog_cxx_mpi_mpi_found)
      if test "x$_ax_prog_cxx_mpi_mpi_found" = "xyes"; then
        break;
      fi
      LIBS=$save_LIBS
    done

    # Check for header
    AS_IF([test x"$_ax_prog_cxx_mpi_mpi_found" = xyes], [
      AC_MSG_CHECKING([for mpi.h])
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <mpi.h>])],
        [ AC_MSG_RESULT(yes)], 
        [ AC_MSG_RESULT(no)
         _ax_prog_cxx_mpi_mpi_found=no
      ])
    ])
    AC_LANG_POP([C++])
])

# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
AS_IF([test x"$_ax_prog_cxx_mpi_mpi_found" = xyes], [
        ifelse([$2],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$2])
        :
],[
        $3
        :
])

])dnl AX_PROG_CXX_MPI

dnl _AX_PROG_CXX_MPI is an internal macro required by AX_PROG_CXX_MPI.
dnl To ensure the right expansion order, the main function AX_PROG_CXX_MPI
dnl has to be split into two parts.
dnl
dnl Known MPI C++ compilers:
dnl  mpic++
dnl  mpicxx
dnl  mpiCC
dnl  sxmpic++     NEC SX
dnl  hcp
dnl  mpxlC_r
dnl  mpxlC
dnl  mpixlcxx_r
dnl  mpixlcxx
dnl  mpg++
dnl  mpc++
dnl  mpCC
dnl  cmpic++
dnl  mpiFCC       Fujitsu
dnl  CC
dnl
AC_DEFUN([_AX_PROG_CXX_MPI], [
  AC_ARG_VAR(MPICXX,[MPI C++ compiler command])
  ifelse([$1],,[_ax_prog_cxx_mpi_mpi_wanted=yes],[
    AC_MSG_CHECKING([whether to compile using MPI])
    if $1; then
      _ax_prog_cxx_mpi_mpi_wanted=yes
    else
      _ax_prog_cxx_mpi_mpi_wanted=no
    fi
    AC_MSG_RESULT($_ax_prog_cxx_mpi_mpi_wanted)
  ])
  if test x"$_ax_prog_cxx_mpi_mpi_wanted" = xyes; then
    if test -z "$CXX" && test -n "$MPICXX"; then
      CXX="$MPICXX"
    else
      AC_CHECK_TOOLS([CXX], [mpic++ mpicxx mpiCC sxmpic++ hcp mpxlC_r mpxlC mpixlcxx_r mpixlcxx mpg++ mpc++ mpCC cmpic++ mpiFCC CCicpc pgCC pathCC sxc++ xlC_r xlC bgxlC_r bgxlC openCC sunCC crayCC g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC])
    fi
  fi
  AC_PROG_CXX
])dnl _AX_PROG_CXX_MPI
dnl -*- mode: autoconf -*-
# ===========================================================================
#       http://www.gnu.org/software/autoconf-archive/ax_prog_f77_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_PROG_F77_MPI([MPI-WANTED-TEST[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
#
# DESCRIPTION
#
#   This macro tries to find out how to compile Fortran77 programs
#   that use MPI (Message Passing Interface), a standard API for
#   parallel process communication (see
#   http://www-unix.mcs.anl.gov/mpi/).  The macro has to be used
#   instead of the standard macro AC_PROG_F77 and will replace the
#   standard variable F77 with the found compiler.
#
#   MPI-WANTED-TEST is used to test whether MPI is actually wanted by
#   the user. If MPI-WANTED_TEST is omitted or if it succeeds, the
#   macro will try to find out how to use MPI, if it fails, the macro
#   will call AC_PROG_CC to find a standard C compiler instead.
#
#   When MPI is found, ACTION-IF-FOUND will be executed, if MPI is not
#   found (or MPI-WANTED-TEST fails) ACTION-IF-NOT-FOUND is
#   executed. If ACTION-IF-FOUND is not set, the macro will define
#   HAVE_MPI.
#
# EXAMPLE
#
#  # If --with-mpi=auto is used, try to find MPI, but use standard F77
#  compiler if it is not found.
#  # If --with-mpi=yes is used, try to find MPI and fail if it isn't
#  # found.
#  # If --with-mpi=no is used, use a standard F77 compiler instead.
#  AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
#      [compile with MPI (parallelization) support. If none is found,
#      MPI is not used. Default: auto])
#  ],,[with_mpi=auto])
#
#  AX_PROG_F77_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
#    use_mpi=no
#    if test x"$with_mpi" = xyes; then
#      AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
#    else
#      AC_MSG_WARN([No MPI compiler found, won't use MPI.])
#    fi
#  ])
#
# LICENSE
#
#   Copyright (c) 2010,2011 Olaf Lenz <olenz@xxxxxxxxxxxxxxxxxxxx>
#
#   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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
#
#   As a special exception, the respective Autoconf Macro's copyright owner
#   gives unlimited permission to copy, distribute and modify the configure
#   scripts that are the output of Autoconf when processing the Macro. You
#   need not follow the terms of the GNU General Public License when using
#   or distributing such scripts, even though portions of the text of the
#   Macro appear in them. The GNU General Public License (GPL) does govern
#   all other use of the material that constitutes the Autoconf Macro.
#
#   This special exception to the GPL applies to versions of the Autoconf
#   Macro released by the Autoconf Archive. When you make and distribute a
#   modified version of the Autoconf Macro, you may extend this special
#   exception to the GPL to apply to your modified version as well.

#serial 1

AC_DEFUN([AX_PROG_F77_MPI], [
AC_PREREQ(2.50) 

# Check for compiler
# Needs to be split off into an extra macro to ensure right expansion
# order.
AC_REQUIRE([_AX_PROG_F77_MPI],[_AX_PROG_F77_MPI([$1])])

AS_IF([test x"$_ax_prog_f77_mpi_mpi_wanted" = xno], 
  [ _ax_prog_f77_mpi_mpi_found=no ],
  [
    AC_LANG_PUSH([Fortran 77])

    # test whether MPI_INIT is available
    # We do not use AC_SEARCH_LIBS here, as it caches its outcome and
    # thus disallows corresponding calls in the other AX_PROG_*_MPI
    # macros.
    for lib in NONE fmpi fmpich; do
      save_LIBS=$LIBS
      if test x"$lib" = xNONE; then
        AC_MSG_CHECKING([for function MPI_INIT])
      else
        AC_MSG_CHECKING([for function MPI_INIT in -l$lib])
        LIBS="-l$lib $LIBS"
      fi
      AC_LINK_IFELSE([AC_LANG_CALL([],[MPI_INIT])],
        [ _ax_prog_f77_mpi_mpi_found=yes ],
        [ _ax_prog_f77_mpi_mpi_found=no ])
      AC_MSG_RESULT($_ax_prog_f77_mpi_mpi_found)
      if test "x$_ax_prog_f77_mpi_mpi_found" = "xyes"; then
        break;
      fi
      LIBS=$save_LIBS
    done

    # Check for header
    AS_IF([test x"$_ax_prog_f77_mpi_mpi_found" = xyes], [
      AC_MSG_CHECKING([for mpi.h])
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[include 'mpif.h'])],
        [ AC_MSG_RESULT(yes)], 
        [ AC_MSG_RESULT(no)
	  _ax_prog_f77_mpi_mpi_found=no
      ])
    ])
    AC_LANG_POP([Fortran 77])
])

# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
AS_IF([test x"$_ax_prog_f77_mpi_mpi_found" = xyes], [
        ifelse([$2],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$2])
        :
],[
        $3
        :
])

])dnl AX_PROG_F77_MPI

dnl _AX_PROG_F77_MPI is an internal macro required by AX_PROG_F77_MPI.
dnl To ensure the right expansion order, the main function AX_PROG_F77_MPI
dnl has to be split into two parts. This part looks for the MPI
dnl compiler, while the other one tests whether an MPI program can be
dnl compiled.
dnl
dnl Known Fortran 77 compilers:
dnl  af77         Apogee F77 compiler for Intergraph hardware running CLIX
dnl  blrts_xlf    IBM BlueGene/L F77 cross-compiler
dnl  cf77         native F77 compiler under older Crays (prefer over fort77)
dnl  f77          generic compiler names
dnl  fl32         Microsoft Fortran 77 "PowerStation" compiler
dnl  fort77       native F77 compiler under HP-UX (and some older Crays)
dnl  frt          Fujitsu F77 compiler
dnl  g77          GNU Fortran 77 compiler
dnl  pgf77        Portland Group F77 compiler
dnl  xlf          IBM (AIX) F77 compiler
dnl  pathf77      PathScale
dnl
AC_DEFUN([_AX_PROG_F77_MPI], [
  AC_ARG_VAR(MPIF77,[MPI Fortran77 compiler command])
  ifelse([$1],,[_ax_prog_f77_mpi_mpi_wanted=yes],[
    AC_MSG_CHECKING([whether to compile using MPI])
    if $1; then
      _ax_prog_f77_mpi_mpi_wanted=yes
    else
      _ax_prog_f77_mpi_mpi_wanted=no
    fi
    AC_MSG_RESULT($_ax_prog_f77_mpi_mpi_wanted)
  ])
  if test x"$_ax_prog_f77_mpi_mpi_wanted" = xyes; then
    if test -z "$F77" && test -n "$MPIF77"; then
      F77="$MPIF77"
    else
      AC_CHECK_TOOLS([F77], [mpif77 hf77 mpxlf_r mpxlf mpifrt mpf77 cmpifc xlf f77 frt pgf77 pathf77 g77 cf77 fort77 fl32 af77])
    fi
  fi
  AC_PROG_F77
])dnl _AX_PROG_F77_MPI
dnl -*- mode: autoconf -*-
# ===========================================================================
#       http://www.gnu.org/software/autoconf-archive/ax_prog_fc_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_PROG_FC_MPI([MPI-WANTED-TEST[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
#
# DESCRIPTION
#
#   This macro tries to find out how to compile Fortran77 programs
#   that use MPI (Message Passing Interface), a standard API for
#   parallel process communication (see
#   http://www-unix.mcs.anl.gov/mpi/).  The macro has to be used
#   instead of the standard macro AC_PROG_FC and will replace the
#   standard variable FC with the found compiler.
#
#   MPI-WANTED-TEST is used to test whether MPI is actually wanted by
#   the user. If MPI-WANTED_TEST is omitted or if it succeeds, the
#   macro will try to find out how to use MPI, if it fails, the macro
#   will call AC_PROG_CC to find a standard C compiler instead.
#
#   When MPI is found, ACTION-IF-FOUND will be executed, if MPI is not
#   found (or MPI-WANTED-TEST fails) ACTION-IF-NOT-FOUND is
#   executed. If ACTION-IF-FOUND is not set, the macro will define
#   HAVE_MPI.
#
# EXAMPLE
#
#  # If --with-mpi=auto is used, try to find MPI, but use standard FC
#  compiler if it is not found.
#  # If --with-mpi=yes is used, try to find MPI and fail if it isn't
#  # found.
#  # If --with-mpi=no is used, use a standard FC compiler instead.
#  AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
#      [compile with MPI (parallelization) support. If none is found,
#      MPI is not used. Default: auto])
#  ],,[with_mpi=auto])
#
#  AX_PROG_FC_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
#    use_mpi=no
#    if test x"$with_mpi" = xyes; then
#      AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
#    else
#      AC_MSG_WARN([No MPI compiler found, won't use MPI.])
#    fi
#  ])
#
# LICENSE
#
#   Copyright (c) 2010,2011 Olaf Lenz <olenz@xxxxxxxxxxxxxxxxxxxx>
#
#   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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
#
#   As a special exception, the respective Autoconf Macro's copyright owner
#   gives unlimited permission to copy, distribute and modify the configure
#   scripts that are the output of Autoconf when processing the Macro. You
#   need not follow the terms of the GNU General Public License when using
#   or distributing such scripts, even though portions of the text of the
#   Macro appear in them. The GNU General Public License (GPL) does govern
#   all other use of the material that constitutes the Autoconf Macro.
#
#   This special exception to the GPL applies to versions of the Autoconf
#   Macro released by the Autoconf Archive. When you make and distribute a
#   modified version of the Autoconf Macro, you may extend this special
#   exception to the GPL to apply to your modified version as well.

#serial 1

AC_DEFUN([AX_PROG_FC_MPI], [
AC_PREREQ(2.50) 

# Check for compiler
# Needs to be split off into an extra macro to ensure right expansion
# order.
AC_REQUIRE([_AX_PROG_FC_MPI],[_AX_PROG_FC_MPI([$1])])

AS_IF([test x"$_ax_prog_fc_mpi_mpi_wanted" = xno], 
  [ _ax_prog_fc_mpi_mpi_found=no ],
  [
    AC_LANG_PUSH([Fortran])

    # test whether MPI_INIT is available
    # We do not use AC_SEARCH_LIBS here, as it caches its outcome and
    # thus disallows corresponding calls in the other AX_PROG_*_MPI
    # macros.
    for lib in NONE mpichf90 fmpi fmpich; do
      save_LIBS=$LIBS
      if test x"$lib" = xNONE; then
        AC_MSG_CHECKING([for function MPI_INIT])
      else
        AC_MSG_CHECKING([for function MPI_INIT in -l$lib])
        LIBS="-l$lib $LIBS"
      fi
      AC_LINK_IFELSE([AC_LANG_CALL([],[MPI_INIT])],
        [ _ax_prog_fc_mpi_mpi_found=yes ],
        [ _ax_prog_fc_mpi_mpi_found=no ])
      AC_MSG_RESULT($_ax_prog_fc_mpi_mpi_found)
      if test "x$_ax_prog_fc_mpi_mpi_found" = "xyes"; then
        break;
      fi
      LIBS=$save_LIBS
    done

    # Check for header
    AS_IF([test x"$_ax_prog_fc_mpi_mpi_found" = xyes], [
      AC_MSG_CHECKING([for fmpi.h])
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[include 'mpif.h'])],
        [ AC_MSG_RESULT(yes)], 
        [ AC_MSG_RESULT(no)
	  _ax_prog_fc_mpi_mpi_found=no
      ])
    ])
    AC_LANG_POP([Fortran])
])

# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
AS_IF([test x"$_ax_prog_fc_mpi_mpi_found" = xyes], [
        ifelse([$2],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$2])
        :
],[
        $3
        :
])

])dnl AX_PROG_FC_MPI

dnl _AX_PROG_FC_MPI is an internal macro required by AX_PROG_FC_MPI.
dnl To ensure the right expansion order, the main function AX_PROG_FC_MPI
dnl has to be split into two parts. This part looks for the MPI
dnl compiler, while the other one tests whether an MPI program can be
dnl compiled.
dnl
AC_DEFUN([_AX_PROG_FC_MPI], [
  AC_ARG_VAR(MPIFC,[MPI Fortran compiler command])
  ifelse([$1],,[_ax_prog_fc_mpi_mpi_wanted=yes],[
    AC_MSG_CHECKING([whether to compile using MPI])
    if $1; then
      _ax_prog_fc_mpi_mpi_wanted=yes
    else
      _ax_prog_fc_mpi_mpi_wanted=no
    fi
    AC_MSG_RESULT($_ax_prog_fc_mpi_mpi_wanted)
  ])
  if test x"$_ax_prog_fc_mpi_mpi_wanted" = xyes; then
    if test -z "$FC" && test -n "$MPIFC"; then
      FC="$MPIFC"
    else
      AC_CHECK_TOOLS([FC], [mpif95 mpxlf95_r mpxlf95 ftn mpif90 mpxlf90_r mpxlf90 mpf90 cmpif90c sxmpif90 mpif77 hf77 mpxlf_r mpxlf mpifrt mpf77 cmpifc xlf95 pgf95 pathf95 ifort g95 f95 fort ifc efc openf95 sunf95 crayftn gfortran lf95 ftn xlf90 f90 pgf90 pghpf pathf90 epcf90 sxf90 openf90 sunf90 xlf f77 frt pgf77 pathf77 g77 cf77 fort77 fl32 af77])
    fi
  fi
  AC_PROG_FC
])dnl _AX_PROG_FC_MPI
begin:vcard
fn:Olaf Lenz
n:Lenz;Olaf
org;quoted-printable;quoted-printable:Universit=C3=A4t Stuttgart;Institut f=C3=BCr Computerphysik
adr:;;Pfaffenwaldring 27;Stuttgart;;70569;Germany
email;internet:olenz@xxxxxxxxxxxxxxxxxxxx
title:Dr. rer. nat.
tel;work:+49.711.685.63607
tel;fax:+49.711.685.63658 
url:http://www.icp.uni-stuttgart.de/~icp/Olaf_Lenz
version:2.1
end:vcard

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux