| 1 | dnl -*- mode: autoconf -*-
|
|---|
| 2 | # ===========================================================================
|
|---|
| 3 | # http://www.gnu.org/software/autoconf-archive/ax_prog_cc_mpi.html
|
|---|
| 4 | # ===========================================================================
|
|---|
| 5 | #
|
|---|
| 6 | # SYNOPSIS
|
|---|
| 7 | #
|
|---|
| 8 | # AX_PROG_CC_MPI([MPI-WANTED-TEST[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
|
|---|
| 9 | #
|
|---|
| 10 | # DESCRIPTION
|
|---|
| 11 | #
|
|---|
| 12 | # This macro tries to find out how to compile C programs that use MPI
|
|---|
| 13 | # (Message Passing Interface), a standard API for parallel process
|
|---|
| 14 | # communication (see http://www-unix.mcs.anl.gov/mpi/).
|
|---|
| 15 | # The macro has to be used instead of the standard macro AC_PROG_CC
|
|---|
| 16 | # and will replace the standard variable CC with the found compiler.
|
|---|
| 17 | #
|
|---|
| 18 | # MPI-WANTED-TEST is used to test whether MPI is actually wanted by
|
|---|
| 19 | # the user. If MPI-WANTED_TEST is omitted or if it succeeds, the
|
|---|
| 20 | # macro will try to find out how to use MPI, if it fails, the macro
|
|---|
| 21 | # will call AC_PROG_CC to find a standard C compiler instead.
|
|---|
| 22 | #
|
|---|
| 23 | # When MPI is found, ACTION-IF-FOUND will be executed, if MPI is not
|
|---|
| 24 | # found (or MPI-WANTED-TEST fails) ACTION-IF-NOT-FOUND is
|
|---|
| 25 | # executed. If ACTION-IF-FOUND is not set, the macro will define
|
|---|
| 26 | # HAVE_MPI.
|
|---|
| 27 | #
|
|---|
| 28 | # EXAMPLE
|
|---|
| 29 | #
|
|---|
| 30 | # # If --with-mpi=auto is used, try to find MPI, but use standard C
|
|---|
| 31 | # compiler if it is not found.
|
|---|
| 32 | # # If --with-mpi=yes is used, try to find MPI and fail if it isn't
|
|---|
| 33 | # # found.
|
|---|
| 34 | # # If --with-mpi=no is used, use a standard C compiler instead.
|
|---|
| 35 | # AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
|
|---|
| 36 | # [compile with MPI (parallelization) support. If none is found,
|
|---|
| 37 | # MPI is not used. Default: auto])
|
|---|
| 38 | # ],,[with_mpi=auto])
|
|---|
| 39 | #
|
|---|
| 40 | # AX_PROG_CC_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
|
|---|
| 41 | # use_mpi=no
|
|---|
| 42 | # if test x"$with_mpi" = xyes; then
|
|---|
| 43 | # AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
|
|---|
| 44 | # else
|
|---|
| 45 | # AC_MSG_WARN([No MPI compiler found, won't use MPI.])
|
|---|
| 46 | # fi
|
|---|
| 47 | # ])
|
|---|
| 48 | #
|
|---|
| 49 | # LICENSE
|
|---|
| 50 | #
|
|---|
| 51 | # Copyright (c) 2010,2011 Olaf Lenz <olenz@icp.uni-stuttgart.de>
|
|---|
| 52 | #
|
|---|
| 53 | # This program is free software: you can redistribute it and/or modify it
|
|---|
| 54 | # under the terms of the GNU General Public License as published by the
|
|---|
| 55 | # Free Software Foundation, either version 3 of the License, or (at your
|
|---|
| 56 | # option) any later version.
|
|---|
| 57 | #
|
|---|
| 58 | # This program is distributed in the hope that it will be useful, but
|
|---|
| 59 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 60 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|---|
| 61 | # Public License for more details.
|
|---|
| 62 | #
|
|---|
| 63 | # You should have received a copy of the GNU General Public License along
|
|---|
| 64 | # with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 65 | #
|
|---|
| 66 | # As a special exception, the respective Autoconf Macro's copyright owner
|
|---|
| 67 | # gives unlimited permission to copy, distribute and modify the configure
|
|---|
| 68 | # scripts that are the output of Autoconf when processing the Macro. You
|
|---|
| 69 | # need not follow the terms of the GNU General Public License when using
|
|---|
| 70 | # or distributing such scripts, even though portions of the text of the
|
|---|
| 71 | # Macro appear in them. The GNU General Public License (GPL) does govern
|
|---|
| 72 | # all other use of the material that constitutes the Autoconf Macro.
|
|---|
| 73 | #
|
|---|
| 74 | # This special exception to the GPL applies to versions of the Autoconf
|
|---|
| 75 | # Macro released by the Autoconf Archive. When you make and distribute a
|
|---|
| 76 | # modified version of the Autoconf Macro, you may extend this special
|
|---|
| 77 | # exception to the GPL to apply to your modified version as well.
|
|---|
| 78 |
|
|---|
| 79 | #serial 1
|
|---|
| 80 |
|
|---|
| 81 | AC_DEFUN([AX_PROG_CC_MPI], [
|
|---|
| 82 | AC_PREREQ(2.50)
|
|---|
| 83 |
|
|---|
| 84 | # Check for compiler
|
|---|
| 85 | # Needs to be split off into an extra macro to ensure right expansion
|
|---|
| 86 | # order.
|
|---|
| 87 | AC_REQUIRE([_AX_PROG_CC_MPI],[_AX_PROG_CC_MPI([$1])])
|
|---|
| 88 |
|
|---|
| 89 | AS_IF([test x"$_ax_prog_cc_mpi_mpi_wanted" = xno],
|
|---|
| 90 | [ _ax_prog_cc_mpi_mpi_found=no ],
|
|---|
| 91 | [
|
|---|
| 92 | AC_LANG_PUSH([C])
|
|---|
| 93 | # test whether MPI_Init is available
|
|---|
| 94 | # We do not use AC_SEARCH_LIBS here, as it caches its outcome and
|
|---|
| 95 | # thus disallows corresponding calls in the other AX_PROG_*_MPI
|
|---|
| 96 | # macros.
|
|---|
| 97 | for lib in NONE mpi mpich; do
|
|---|
| 98 | save_LIBS=$LIBS
|
|---|
| 99 | if test x"$lib" = xNONE; then
|
|---|
| 100 | AC_MSG_CHECKING([for function MPI_Init])
|
|---|
| 101 | else
|
|---|
| 102 | AC_MSG_CHECKING([for function MPI_Init in -l$lib])
|
|---|
| 103 | LIBS="-l$lib $LIBS"
|
|---|
| 104 | fi
|
|---|
| 105 | AC_LINK_IFELSE([AC_LANG_CALL([],[MPI_Init])],
|
|---|
| 106 | [ _ax_prog_cc_mpi_mpi_found=yes ],
|
|---|
| 107 | [ _ax_prog_cc_mpi_mpi_found=no ])
|
|---|
| 108 | AC_MSG_RESULT($_ax_prog_cc_mpi_mpi_found)
|
|---|
| 109 | if test "x$_ax_prog_cc_mpi_mpi_found" = "xyes"; then
|
|---|
| 110 | break;
|
|---|
| 111 | fi
|
|---|
| 112 | LIBS=$save_LIBS
|
|---|
| 113 | done
|
|---|
| 114 |
|
|---|
| 115 | # Check for header
|
|---|
| 116 | AS_IF([test x"$_ax_prog_cc_mpi_mpi_found" = xyes], [
|
|---|
| 117 | AC_MSG_CHECKING([for mpi.h])
|
|---|
| 118 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <mpi.h>])],
|
|---|
| 119 | [ AC_MSG_RESULT(yes)],
|
|---|
| 120 | [ AC_MSG_RESULT(no)
|
|---|
| 121 | _ax_prog_cc_mpi_mpi_found=no
|
|---|
| 122 | ])
|
|---|
| 123 | ])
|
|---|
| 124 | AC_LANG_POP([C])
|
|---|
| 125 | ])
|
|---|
| 126 |
|
|---|
| 127 | # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
|---|
| 128 | AS_IF([test x"$_ax_prog_cc_mpi_mpi_found" = xyes], [
|
|---|
| 129 | ifelse([$2],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$2])
|
|---|
| 130 | :
|
|---|
| 131 | ],[
|
|---|
| 132 | $3
|
|---|
| 133 | :
|
|---|
| 134 | ])
|
|---|
| 135 |
|
|---|
| 136 | ])dnl AX_PROG_CC_MPI
|
|---|
| 137 |
|
|---|
| 138 | dnl _AX_PROG_CC_MPI is an internal macro required by AX_PROG_CC_MPI.
|
|---|
| 139 | dnl To ensure the right expansion order, the main function AX_PROG_CC_MPI
|
|---|
| 140 | dnl has to be split into two parts.
|
|---|
| 141 | dnl
|
|---|
| 142 | dnl Known MPI C compilers:
|
|---|
| 143 | dnl mpicc
|
|---|
| 144 | dnl mpixlc_r
|
|---|
| 145 | dnl mpixlc
|
|---|
| 146 | dnl hcc
|
|---|
| 147 | dnl mpxlc_r
|
|---|
| 148 | dnl mpxlc
|
|---|
| 149 | dnl sxmpicc NEC SX
|
|---|
| 150 | dnl mpifcc Fujitsu
|
|---|
| 151 | dnl mpgcc
|
|---|
| 152 | dnl mpcc
|
|---|
| 153 | dnl cmpicc
|
|---|
| 154 | dnl cc
|
|---|
| 155 | dnl
|
|---|
| 156 | AC_DEFUN([_AX_PROG_CC_MPI], [
|
|---|
| 157 | AC_ARG_VAR(MPICC,[MPI C compiler command])
|
|---|
| 158 | ifelse([$1],,[_ax_prog_cc_mpi_mpi_wanted=yes],[
|
|---|
| 159 | AC_MSG_CHECKING([whether to compile using MPI])
|
|---|
| 160 | if $1; then
|
|---|
| 161 | _ax_prog_cc_mpi_mpi_wanted=yes
|
|---|
| 162 | else
|
|---|
| 163 | _ax_prog_cc_mpi_mpi_wanted=no
|
|---|
| 164 | fi
|
|---|
| 165 | AC_MSG_RESULT($_ax_prog_cc_mpi_mpi_wanted)
|
|---|
| 166 | ])
|
|---|
| 167 | if test x"$_ax_prog_cc_mpi_mpi_wanted" = xyes; then
|
|---|
| 168 | if test -z "$CC" && test -n "$MPICC"; then
|
|---|
| 169 | CC="$MPICC"
|
|---|
| 170 | else
|
|---|
| 171 | AC_CHECK_TOOLS([CC], [mpicc mpixlc_r mpixlc hcc mpxlc_r mpxlc sxmpicc mpifcc mpgcc mpcc cmpicc cc gcc])
|
|---|
| 172 | fi
|
|---|
| 173 | fi
|
|---|
| 174 | AC_PROG_CC
|
|---|
| 175 | ])dnl _AX_PROG_CC_MPI
|
|---|