Salome HOME
86b891bcb3bc16c5f683d32248679b1124c6f488
[tools/configuration.git] / autotools / m4 / check_mpi.m4
1 dnl Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 dnl
3 dnl Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 dnl
6 dnl This library is free software; you can redistribute it and/or
7 dnl modify it under the terms of the GNU Lesser General Public
8 dnl License as published by the Free Software Foundation; either
9 dnl version 2.1 of the License, or (at your option) any later version.
10 dnl
11 dnl This library is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 dnl Lesser General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU Lesser General Public
17 dnl License along with this library; if not, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 dnl
20 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 dnl
22
23 AC_DEFUN([CHECK_MPI],[
24
25 AC_REQUIRE([AC_PROG_CC])dnl
26
27 AC_ARG_WITH(mpi_lib,
28    [AC_HELP_STRING([--with-mpi_lib=DIR],[directory path of MPICH lib installation])],
29    MPILIBREQUESTED="$withval")
30
31 AC_ARG_WITH(mpi_include,
32    [AC_HELP_STRING([--with-mpi_include=DIR],[directory path of MPICH header file installation])],
33    MPIINCLUDEREQUESTED="$withval")
34
35 AC_ARG_WITH(mpi,
36    [AC_HELP_STRING([--with-mpi=DIR],[root directory path of MPICH installation])],
37    MPIREQUESTED="yes",MPIREQUESTED="no")
38
39 MPI_INCLUDES=""
40 MPI_LIBS=""
41 WITHMPI=no
42 mpi_ok=no
43 if test x"$MPIREQUESTED" = xyes; then
44
45   echo
46   echo ---------------------------------------------
47   echo testing mpi
48   echo ---------------------------------------------
49   echo
50
51   if test "x$withval" != "xyes"; then
52     MPI_HOME=$withval
53     MPI_INCLUDES="-I$MPI_HOME/include"
54     if test "x$MPI_HOME" = "x/usr"
55     then
56       MPI_LIBS=""
57     else
58       MPI_LIBS="-L$MPI_HOME/lib"
59     fi
60   fi
61
62   if test x"$MPILIBREQUESTED" != x; then
63     MPI_LIBS="-L$MPILIBREQUESTED"
64   fi
65
66   if test x"$MPIINCLUDEREQUESTED" != x; then
67     MPI_INCLUDES="-I$MPIINCLUDEREQUESTED"
68   fi
69
70   CPPFLAGS_old="$CPPFLAGS"
71   CPPFLAGS="$MPI_INCLUDES $CPPFLAGS"
72   AC_CHECK_HEADER(mpi.h,WITHMPI="yes",WITHMPI="no")
73   CPPFLAGS="$CPPFLAGS_old"
74
75   if test "$WITHMPI" = "yes";then
76     LIBS_old="$LIBS"
77     LDFLAGS_old="$LDFLAGS"
78     LDFLAGS="$MPI_LIBS $LDFLAGS"
79     AC_CHECK_LIB(elan,elan_init,MPI_LIBS="$MPI_LIBS -lelan")
80     AC_CHECK_LIB(mpi,MPI_Init,WITHMPI="yes",WITHMPI="no")
81     AC_CHECK_LIB(mpi,MPI_Publish_name,WITHMPI2="yes",WITHMPI2="no")
82     LDFLAGS="$LDFLAGS_old"
83     LIBS="$LIBS_old"
84   fi
85
86   if test "$WITHMPI" = "yes";then
87     mpi_ok=yes
88     MPI_LIBS="$MPI_LIBS -lmpi -lmpio -lmpiCC"
89   else
90     mpi_ok=no
91   fi
92
93   if test "$WITHMPI2" = "yes";then
94     mpi2_ok=yes
95   else
96     mpi2_ok=no
97   fi
98
99 fi
100
101 if test "$WITHMPI" = no; then
102 dnl
103 dnl ---------------------------------------------
104 dnl testing MPICH
105 dnl ---------------------------------------------
106 dnl
107
108   CHECK_MPICH
109
110   if test "$WITHMPICH" = no; then
111 dnl
112 dnl ---------------------------------------------
113 dnl testing LAM
114 dnl ---------------------------------------------
115 dnl
116
117     CHECK_LAM
118
119   fi
120
121   if test "$WITHLAM" = no; then
122 dnl
123 dnl ---------------------------------------------
124 dnl testing OPENMPI
125 dnl ---------------------------------------------
126 dnl
127
128     CHECK_OPENMPI
129
130   fi
131
132 fi
133
134 if test x$WITHMPI2 = xyes; then
135   CPPFLAGS="-DHAVE_MPI2 $CPPFLAGS"
136   CORBA_IDLCXXFLAGS="-DHAVE_MPI2 $CORBA_IDLCXXFLAGS"
137   CORBA_IDLPYFLAGS="-DHAVE_MPI2 $CORBA_IDLPYFLAGS"
138 fi
139
140 AC_SUBST(WITHMPI)
141 AC_SUBST(MPI_INCLUDES)
142 AC_SUBST(MPI_LIBS)
143 AC_SUBST(mpi_ok)
144 AC_SUBST(mpi2_ok)
145 AM_CONDITIONAL(MPI_IS_OK, [test x"$mpi_ok" = xyes])
146 AM_CONDITIONAL(MPI2_IS_OK, [test x"$mpi2_ok" = xyes])
147
148 ])dnl