annotate src/fftw-3.3.8/m4/acx_mpi.m4 @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents d0c2a83c1364
children
rev   line source
Chris@82 1 dnl @synopsis ACX_MPI([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
Chris@82 2 dnl @summary figure out how to compile/link code with MPI
Chris@82 3 dnl @category InstalledPackages
Chris@82 4 dnl
Chris@82 5 dnl This macro tries to find out how to compile programs that
Chris@82 6 dnl use MPI (Message Passing Interface), a standard API for
Chris@82 7 dnl parallel process communication (see http://www-unix.mcs.anl.gov/mpi/)
Chris@82 8 dnl
Chris@82 9 dnl On success, it sets the MPICC, MPICXX, or MPIF77 output variable to
Chris@82 10 dnl the name of the MPI compiler, depending upon the current language.
Chris@82 11 dnl (This may just be $CC/$CXX/$F77, but is more often something like
Chris@82 12 dnl mpicc/mpiCC/mpif77.) It also sets MPILIBS to any libraries that are
Chris@82 13 dnl needed for linking MPI (e.g. -lmpi, if a special MPICC/MPICXX/MPIF77
Chris@82 14 dnl was not found).
Chris@82 15 dnl
Chris@82 16 dnl If you want to compile everything with MPI, you should set:
Chris@82 17 dnl
Chris@82 18 dnl CC="$MPICC" #OR# CXX="$MPICXX" #OR# F77="$MPIF77"
Chris@82 19 dnl LIBS="$MPILIBS $LIBS"
Chris@82 20 dnl
Chris@82 21 dnl NOTE: The above assumes that you will use $CC (or whatever)
Chris@82 22 dnl for linking as well as for compiling. (This is the
Chris@82 23 dnl default for automake and most Makefiles.)
Chris@82 24 dnl
Chris@82 25 dnl The user can force a particular library/compiler by setting the
Chris@82 26 dnl MPICC/MPICXX/MPIF77 and/or MPILIBS environment variables.
Chris@82 27 dnl
Chris@82 28 dnl ACTION-IF-FOUND is a list of shell commands to run if an MPI
Chris@82 29 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands
Chris@82 30 dnl to run it if it is not found. If ACTION-IF-FOUND is not specified,
Chris@82 31 dnl the default action will define HAVE_MPI.
Chris@82 32 dnl
Chris@82 33 dnl @version 2005-09-02
Chris@82 34 dnl @license GPLWithACException
Chris@82 35 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
Chris@82 36
Chris@82 37 AC_DEFUN([ACX_MPI], [
Chris@82 38 AC_PREREQ(2.50) dnl for AC_LANG_CASE
Chris@82 39
Chris@82 40 AC_LANG_CASE([C], [
Chris@82 41 AC_REQUIRE([AC_PROG_CC])
Chris@82 42 AC_ARG_VAR(MPICC,[MPI C compiler command])
Chris@82 43 AC_CHECK_PROGS(MPICC, mpicc hcc mpcc mpcc_r mpxlc cmpicc, $CC)
Chris@82 44 acx_mpi_save_CC="$CC"
Chris@82 45 CC="$MPICC"
Chris@82 46 AC_SUBST(MPICC)
Chris@82 47 ],
Chris@82 48 [C++], [
Chris@82 49 AC_REQUIRE([AC_PROG_CXX])
Chris@82 50 AC_ARG_VAR(MPICXX,[MPI C++ compiler command])
Chris@82 51 AC_CHECK_PROGS(MPICXX, mpic++ mpiCC mpicxx mpCC hcp mpxlC mpxlC_r cmpic++, $CXX)
Chris@82 52 acx_mpi_save_CXX="$CXX"
Chris@82 53 CXX="$MPICXX"
Chris@82 54 AC_SUBST(MPICXX)
Chris@82 55 ],
Chris@82 56 [Fortran 77], [
Chris@82 57 AC_REQUIRE([AC_PROG_F77])
Chris@82 58 AC_ARG_VAR(MPIF77,[MPI Fortran compiler command])
Chris@82 59 AC_CHECK_PROGS(MPIF77, mpif77 hf77 mpxlf mpf77 mpif90 mpf90 mpxlf90 mpxlf95 mpxlf_r cmpifc cmpif90c, $F77)
Chris@82 60 acx_mpi_save_F77="$F77"
Chris@82 61 F77="$MPIF77"
Chris@82 62 AC_SUBST(MPIF77)
Chris@82 63 ])
Chris@82 64
Chris@82 65 if test x = x"$MPILIBS"; then
Chris@82 66 AC_LANG_CASE([C], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
Chris@82 67 [C++], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
Chris@82 68 [Fortran 77], [AC_MSG_CHECKING([for MPI_Init])
Chris@82 69 AC_TRY_LINK([],[ call MPI_Init], [MPILIBS=" "
Chris@82 70 AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])])
Chris@82 71 fi
Chris@82 72 if test x = x"$MPILIBS"; then
Chris@82 73 AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"])
Chris@82 74 fi
Chris@82 75 if test x = x"$MPILIBS"; then
Chris@82 76 AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"])
Chris@82 77 fi
Chris@82 78
Chris@82 79 dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
Chris@82 80 dnl latter uses $CPP, not $CC (which may be mpicc).
Chris@82 81 AC_LANG_CASE([C], [if test x != x"$MPILIBS"; then
Chris@82 82 AC_MSG_CHECKING([for mpi.h])
Chris@82 83 AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
Chris@82 84 AC_MSG_RESULT(no)])
Chris@82 85 fi],
Chris@82 86 [C++], [if test x != x"$MPILIBS"; then
Chris@82 87 AC_MSG_CHECKING([for mpi.h])
Chris@82 88 AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
Chris@82 89 AC_MSG_RESULT(no)])
Chris@82 90 fi])
Chris@82 91
Chris@82 92 AC_LANG_CASE([C], [CC="$acx_mpi_save_CC"],
Chris@82 93 [C++], [CXX="$acx_mpi_save_CXX"],
Chris@82 94 [Fortran 77], [F77="$acx_mpi_save_F77"])
Chris@82 95
Chris@82 96 AC_SUBST(MPILIBS)
Chris@82 97
Chris@82 98 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
Chris@82 99 if test x = x"$MPILIBS"; then
Chris@82 100 $2
Chris@82 101 :
Chris@82 102 else
Chris@82 103 ifelse([$1],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$1])
Chris@82 104 :
Chris@82 105 fi
Chris@82 106 ])dnl ACX_MPI