comparison src/fftw-3.3.3/m4/acx_mpi.m4 @ 95:89f5e221ed7b

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