source: pcp/m4/acx_mpi.m4@ 9a2c8c

Last change on this file since 9a2c8c was a0bcf1, checked in by Frederik Heber <heber@…>, 17 years ago

-initial commit
-Minimum set of files needed from ESPACK SVN repository
-Switch to three tantamount package parts instead of all relating to pcp (as at some time Ralf's might find inclusion as well)

  • Property mode set to 100644
File size: 3.4 KB
Line 
1dnl @synopsis ACX_MPI([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
2dnl
3dnl This macro tries to find out how to compile programs that
4dnl use MPI (Message Passing Interface), a standard API for
5dnl parallel process communication (see http://www-unix.mcs.anl.gov/mpi/)
6dnl
7dnl On success, it sets the MPICC, MPICXX, or MPIF77 output variable to
8dnl the name of the MPI compiler, depending upon the current language.
9dnl (This may just be $CC/$CXX/$F77, but is more often something like
10dnl mpicc/mpiCC/mpif77.) It also sets MPILIBS to any libraries that are
11dnl needed for linking MPI (e.g. -lmpi, if a special MPICC/MPICXX/MPIF77
12dnl was not found).
13dnl
14dnl If you want to compile everything with MPI, you should set:
15dnl
16dnl CC="$MPICC" #OR# CXX="$MPICXX" #OR# F77="$MPIF77"
17dnl LIBS="$MPILIBS $LIBS"
18dnl
19dnl The user can force a particular library/compiler by setting the
20dnl MPICC/MPICXX/MPIF77 and/or MPILIBS environment variables.
21dnl
22dnl ACTION-IF-FOUND is a list of shell commands to run if an MPI
23dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands
24dnl to run it if it is not found. If ACTION-IF-FOUND is not specified,
25dnl the default action will define HAVE_MPI.
26dnl
27dnl @version $Id: acx_mpi.m4,v 1.1.1.1 2007-09-03 16:17:11 heber Exp $
28dnl @author Steven G. Johnson <address@hidden>
29
30AC_DEFUN([ACX_MPI], [
31AC_PREREQ(2.50) dnl for AC_LANG_CASE
32
33AC_LANG_CASE([C], [
34 AC_REQUIRE([AC_PROG_CC])
35 AC_ARG_VAR(MPICC,[MPI C compiler command])
36 AC_CHECK_PROGS(MPICC, mpicc hcc mpcc mpcc_r mpxlc cmpicc, $CC)
37 acx_mpi_save_CC="$CC"
38 CC="$MPICC"
39 AC_SUBST(MPICC)
40],
41[C++], [
42 AC_REQUIRE([AC_PROG_CXX])
43 AC_ARG_VAR(MPICXX,[MPI C++ compiler command])
44 AC_CHECK_PROGS(MPICXX, mpic++ mpiCC mpCC hcp mpxlC mpxlC_r cmpic++, $CXX)
45 acx_mpi_save_CXX="$CXX"
46 CXX="$MPICXX"
47 AC_SUBST(MPICXX)
48],
49[Fortran 77], [
50 AC_REQUIRE([AC_PROG_F77])
51 AC_ARG_VAR(MPIF77,[MPI Fortran compiler command])
52 AC_CHECK_PROGS(MPIF77, mpif77 hf77 mpxlf mpf77 mpif90 mpf90 mpxlf90 mpxlf95 mpxlf_r cmpifc cmpif90c, $F77)
53 acx_mpi_save_F77="$F77"
54 F77="$MPIF77"
55 AC_SUBST(MPIF77)
56])
57
58if test x = x"$MPILIBS"; then
59 AC_LANG_CASE([C], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
60 [C++], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
61 [Fortran 77], [AC_MSG_CHECKING([for MPI_Init])
62 AC_TRY_LINK([],[ call MPI_Init], [MPILIBS=" "
63 AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])])
64fi
65if test x = x"$MPILIBS"; then
66 AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"])
67fi
68if test x = x"$MPILIBS"; then
69 AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"])
70fi
71
72dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
73dnl latter uses $CPP, not $CC (which may be mpicc).
74AC_LANG_CASE([C], [if test x != x"$MPILIBS"; then
75 AC_MSG_CHECKING([for mpi.h])
76 AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
77 AC_MSG_RESULT(no)])
78fi],
79[C++], [if test x != x"$MPILIBS"; then
80 AC_MSG_CHECKING([for mpi.h])
81 AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
82 AC_MSG_RESULT(no)])
83fi])
84
85AC_LANG_CASE([C], [CC="$acx_mpi_save_CC"],
86 [C++], [CXX="$acx_mpi_save_CXX"],
87 [Fortran 77], [F77="$acx_mpi_save_F77"])
88
89AC_SUBST(MPILIBS)
90
91# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
92if test x = x"$MPILIBS"; then
93 $2
94 :
95else
96 ifelse([$1],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$1])
97 :
98fi
99])dnl ACX_MPI
Note: See TracBrowser for help on using the repository browser.