ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/ac-tools/ACX_MPI.m4
Revision: 1225
Committed: Fri Feb 8 21:33:46 2008 UTC (17 years, 5 months ago) by gezelter
File size: 9775 byte(s)
Log Message:
updating configure process

File Contents

# Content
1 dnl ACX_MPI_GET_PROG(IF-FOUND, IF-NOT-FOUND)
2 AC_DEFUN([ACX_MPI_GET_PROG],[
3 dnl
4 dnl check for MPI C-compiler first
5 dnl
6 AC_CHECK_PROGS(acx_mpi_mpicc,[$CC openmpicc mpicc],[no])
7 AS_IF([test AS_VAR_GET([acx_mpi_mpicc]) != no],[
8 AC_PATH_PROG(acx_mpi_mpicc_path,[$acx_mpi_mpicc],[no])])
9 dnl
10 dnl then check for MPI f90 compiler (f77 will not be sufficient)
11 dnl
12 AC_CHECK_PROGS(acx_mpi_mpif90,[$FC openmpif90 mpif90],[no])
13 AS_IF([test AS_VAR_GET([acx_mpi_mpif90]) != no],[
14 AC_PATH_PROG(acx_mpi_mpif90_path,[$acx_mpi_mpif90],[no])])
15 dnl
16 dnl last, check for MPI c++ compiler
17 dnl
18 AC_CHECK_PROGS(acx_mpi_mpicxx,[$CXX openmpicxx openmpiCC openmpic++ mpicxx mpiCC mpic++],[no])
19 AS_IF([test AS_VAR_GET([acx_mpi_mpicxx]) != no],[
20 AC_PATH_PROG(acx_mpi_mpicxx_path,[$acx_mpi_mpicxx],[no])])
21 dnl
22 dnl should we substitute MPI c++ compiler for C code? Or vice versa?
23 dnl
24 AS_IF([test AS_VAR_GET([acx_mpi_mpicc]) = no],[
25 AS_IF([test AS_VAR_GET([acx_mpi_mpicxx]) = no],[
26 AS_VAR_SET([acx_mpi_compiler],[no])
27 ],[
28 AS_VAR_SET([acx_mpi_compiler],[AS_VAR_GET([acx_mpi_mpicxx])])
29 AS_VAR_SET([acx_mpi_compiler_path],[AS_VAR_GET([acx_mpi_mpicxx_path])])])
30 ],[
31 AS_IF([test AS_VAR_GET([acx_mpi_mpicxx]) = no],[
32 AS_VAR_SET([acx_mpi_compiler],[AS_VAR_GET([acx_mpi_mpicc])])
33 AS_VAR_SET([acx_mpi_compiler_path],[AS_VAR_GET([acx_mpi_mpicc_path])])
34 ],[
35 AC_MSG_CHECKING([whether to use AS_VAR_GET([acx_mpi_mpicc]) or AS_VAR_GET([acx_mpi_mpicxx])])
36 AC_LANG_PUSH(C++)
37 AC_LANG_CONFTEST([AC_LANG_PROGRAM([
38 #include <mpi.h>
39 ],[
40 MPI_Finalize();
41 ])])
42 AS_IF([_AC_DO_STDERR($acx_mpi_mpicxx_path -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD) && {
43 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
44 test ! -s conftest.err
45 } && test -s conftest.$ac_objext],[
46 AS_VAR_SET([acx_mpi_compiler],[AS_VAR_GET([acx_mpi_mpicxx])])
47 AS_VAR_SET([acx_mpi_compiler_path],[AS_VAR_GET([acx_mpi_mpicxx_path])])
48 ],[
49 AS_VAR_SET([acx_mpi_compiler],[AS_VAR_GET([acx_mpi_mpicc])])
50 AS_VAR_SET([acx_mpi_compiler_path],[AS_VAR_GET([acx_mpi_mpicc_path])])])
51 AC_LANG_POP
52 AC_MSG_RESULT([AS_VAR_GET([acx_mpi_compiler])])])])
53 dnl
54 dnl let's check to see if the fortran compiler works
55 dnl
56 AC_MSG_CHECKING([whether mpif.h is usable])
57 AC_LANG_PUSH(Fortran)
58 ac_save_ext=$ac_ext
59 ac_ext=F90
60 rm -f conftest*
61 cat >conftest.$ac_ext <<EOF
62 program main
63 include 'mpif.h'
64 call MPI_Init
65 end
66 EOF
67 if $acx_mpi_mpif90_path -c conftest.$ac_ext > conftest.out 2>&1 ; then
68 AS_VAR_SET([acx_mpi_f90_compiler],[yes])
69 AC_MSG_RESULT([yes])
70 else
71 if test -s conftest.out ; then
72 cat conftest.out >> config.log
73 fi
74 AS_VAR_SET([acx_mpi_f90_compiler],[no])
75 AC_MSG_RESULT([no! Check MPI fortran include paths])
76 fi
77 rm -f conftest*
78 ac_ext=$ac_save_ext
79 AC_LANG_POP
80 AS_IF([test AS_VAR_GET([acx_mpi_compiler]) = no || test AS_VAR_GET([acx_mpi_f90_compiler]) = no],[$2],[$1])])# ACX_MPI_GET_PROG
81
82 dnl ACX_DETECT_MPI_IMPLEMENTATION(DEFAULT-IMPL, IF-FOUND, IF-NOT-FOUND)
83 AC_DEFUN([ACX_DETECT_MPI_IMPLEMENTATION],[
84 ACX_MPI_GET_PROG([dnl
85 AS_VAR_PUSHDEF([ac_var],[acx_cv_mpi_implementation])dnl
86 AC_CACHE_CHECK([for the MPI implementation flavor], [ac_var],
87 [dnl
88 AS_VAR_SET([ac_var],[no])
89 AS_IF([_AC_DO_STDERR(grep -q LAM $acx_mpi_compiler_path)],[
90 AS_VAR_SET([ac_var],[lammpi])
91 ],[
92 AS_IF([_AC_DO_STDERR(grep -q showme $acx_mpi_compiler_path)],[
93 AS_VAR_SET([ac_var],[openmpi])
94 ],[
95 AS_IF([_AC_DO_STDERR(grep -q MPICH $acx_mpi_compiler_path)],[
96 AS_VAR_SET([ac_var],[mpich])
97 ],[AS_VAR_SET([ac_var],[$1])])])])])
98 AS_VAR_POPDEF([ac_var])],[
99 AS_VAR_SET([acx_cv_mpi_implementation],[no])])dnl
100 case AS_VAR_GET([acx_cv_mpi_implementation]) in
101 (lammpi)
102 AC_DEFINE(MPI_IS_LAMMPI,[1],[Indicate that MPI implementation is LAMMPI])
103 ;;
104 (openmpi)
105 AC_DEFINE(MPI_IS_OPENMPI,[1],[Indicate that MPI implementation is OPEN-MPI])
106 ;;
107 (mpich)
108 AC_DEFINE(MPI_IS_MPICH,[1],[Indicate that MPI implementation is MPICH])
109 ;;
110 esac
111 AS_IF([test AS_VAR_GET([acx_cv_mpi_implementation]) = no],[$3],[$2])
112 ])# ACX_DETECT_MPI_IMPLEMENTATION
113
114
115 AC_DEFUN([ACX_MPI_FILTER_CFLAGS],
116 acx_mpi_tmp_mode="normal"
117 acx_mpi_tmp_prefix=""
118 AS_VAR_SET([$1],[""])
119 for acx_mpi_tmp in $2; do
120 case "$acx_mpi_tmp_mode" in
121 (normal)
122 case "$acx_mpi_tmp" in
123 (-I|-D)
124 acx_mpi_tmp_prefix="$acx_mpi_tmp"
125 acx_mpi_tmp_mode="accept"
126 ;;
127 (-I*|-D*)
128 AS_VAR_SET([$1],["AS_VAR_GET([$1]) $acx_mpi_tmp"])
129 ;;
130 (-L|-l)
131 acx_mpi_tmp_mode="skip"
132 ;;
133 (*)
134 ;;
135 esac
136 ;;
137 (accept)
138 AS_VAR_SET([$1],["AS_VAR_GET([$1]) $acx_mpi_tmp_prefix $acx_mpi_tmp"])
139 ;;
140 (skip)
141 ;;
142 esac
143 done
144 )
145
146
147 dnl ACX_MPI(DEFAULT-IMPL, IF-FOUND, IF-NOT-FOUND)
148 AC_DEFUN([ACX_MPI],[
149 AC_ARG_WITH(mpi,
150 AS_HELP_STRING([--with-mpi=auto|mpich|lam|openmpi|no],
151 [Indicates which kind of MPI implementation to use @<:@default=auto@:>@]),
152 [],
153 [with_mpi="auto"])
154 if test "x$with_mpi" != "xno"; then
155 ACX_DETECT_MPI_IMPLEMENTATION(AS_VAR_GET([with_mpi]),[
156 dnl
157 AS_VAR_PUSHDEF([ac_var],[acx_mpi_cflags])
158 AC_CACHE_CHECK([how to compile MPI-C code],[ac_var],[
159 case AS_VAR_GET([acx_cv_mpi_implementation]) in
160 (lammpi)
161 cfo="--showme:compile"
162 ;;
163 (openmpi)
164 cfo="--showme:compile"
165 ;;
166 (mpich)
167 case "$acx_mpi_compiler_path" in
168 (*mpiCC)
169 sc_cv_cn="-CC="
170 ;;
171 (*mpicxx)
172 sc_cv_cn="-cxx="
173 ;;
174 (*mpicc)
175 sc_cv_cn="-cc="
176 ;;
177 (*)
178 sc_cv_cn=""
179 ;;
180 esac
181 cfo="-compile_info $sc_cv_cn"
182 ;;
183 esac
184 _AS_ECHO_LOG([mpi_pre_cflags="`$acx_mpi_compiler_path $cfo || echo ' no'`"])
185 mpi_pre_cflags="`$acx_mpi_compiler_path $cfo 2>conftest.er1 || echo ' no'`"
186 grep -v '^ *+' conftest.er1 >conftest.err
187 rm -f conftest.er1
188 cat conftest.err >&AS_MESSAGE_LOG_FD
189 _AS_ECHO_LOG([mpi_pre_cflags = $mpi_pre_cflags])
190 case "$mpi_pre_cflags" in
191 (*no)
192 AS_VAR_SET([ac_var],[no])
193 ac_var="no"
194 ;;
195 (*)
196 ACX_MPI_FILTER_CFLAGS([ac_var],[$mpi_pre_cflags])
197 ;;
198 esac
199 ])
200 AS_VAR_POPDEF([ac_var])
201 dnl
202 AS_VAR_PUSHDEF([ac_var],[acx_mpi_libs])
203 AC_CACHE_CHECK([how to link MPI-C code],[ac_var],[
204 case AS_VAR_GET([acx_cv_mpi_implementation]) in
205 (lammpi)
206 lfo="--showme:compile --showme:link"
207 ;;
208 (openmpi)
209 lfo="--showme:link"
210 ;;
211 (mpich)
212 case "$acx_mpi_compiler_path" in
213 (*mpiCC)
214 sc_cv_cn="-CC="
215 ;;
216 (*mpicxx)
217 sc_cv_cn="-cxx="
218 ;;
219 (*mpicc)
220 sc_cv_cn="-cc="
221 ;;
222 (*)
223 sc_cv_cn=""
224 ;;
225 esac
226 lfo="-link_info $sc_cv_cn"
227 ;;
228 esac
229 dnl
230 _AS_ECHO_LOG([mpi_pre_libs="`$acx_mpi_compiler_path $lfo || echo ' no'`"])
231 mpi_pre_libs="`$acx_mpi_compiler_path $lfo 2>conftest.er1 || echo ' no'`"
232 grep -v '^ *+' conftest.er1 >conftest.err
233 rm -f conftest.er1
234 cat conftest.err >&AS_MESSAGE_LOG_FD
235 _AS_ECHO_LOG([mpi_pre_libs = $mpi_pre_libs])
236 case "$mpi_pre_libs" in
237 (*no)
238 AS_VAR_SET([ac_var],[no])
239 ;;
240 (*)
241 AS_VAR_SET([ac_var],["$mpi_pre_libs"])
242 ;;
243 esac
244 ])
245 AS_VAR_POPDEF([ac_var])
246 dnl
247 AS_IF([test AS_VAR_GET([acx_mpi_mpif90_path]) != no],[
248 AS_VAR_PUSHDEF([ac_var],[acx_mpi90_libs])
249 AC_CACHE_CHECK([how to link MPI-Fortran code],[ac_var],[
250 _AS_ECHO_LOG([mpi_pre_libs="`$acx_mpi_mpif90_path $lfo || echo " no"`"])
251 mpi_pre_libs="`$acx_mpi_mpif90_path $lfo 2>conftest.er1 || echo " no"`"
252 grep -v '^ *+' conftest.er1 >conftest.err
253 rm -f conftest.er1
254 cat conftest.err >&AS_MESSAGE_LOG_FD
255 _AS_ECHO_LOG([mpi_pre_libs = $mpi_pre_libs])
256 case "$mpi_pre_libs" in
257 (*no)
258 AS_VAR_SET([ac_var],[no])
259 ;;
260 (*)
261 AS_VAR_SET([ac_var],["$mpi_pre_libs"])
262 ;;
263 esac
264 ])
265 AS_VAR_POPDEF([ac_var])
266 ])
267 dnl
268 AS_IF([test "AS_VAR_GET([acx_mpi_cflags])" = no -o "AS_VAR_GET([acx_mpi_libs])" = no],[
269 AS_VAR_SET([acx_mpi_cflags],[""])
270 AS_VAR_SET([acx_mpi_libs],[""])
271 $2],[
272 AC_SUBST(MPI_CPPFLAGS,AS_VAR_GET([acx_mpi_cflags]))
273 AC_SUBST(MPI_LIBS,AS_VAR_GET([acx_mpi_libs]))
274 AS_IF([test "AS_VAR_GET([acx_mpi90_libs])" != no],[AC_SUBST([MPI90_LIBS],[AS_VAR_GET([acx_mpi90_libs])])])
275 $1])
276 ],[
277 AS_VAR_SET([acx_mpi_cflags],[""])
278 AS_VAR_SET([acx_mpi_libs],[""])
279 $2])
280 fi
281 ])# ACX_MPI
282
283 dnl ACX_MPI2([IF-FOUND],[IF-NOT-FOUND])
284 AC_DEFUN([ACX_MPI2],[dnl
285 AC_REQUIRE([ACX_MPI])
286 AS_IF([test AS_VAR_GET([acx_cv_mpi_implementation]) = no],[$2],[dnl
287 sc_cv_oldCPPFLAGS="$CPPFLAGS"
288 CPPFLAGS="$CPPFLAGS $MPI_CPPFLAGS"
289 AC_CHECK_DECLS([MPI_Comm_spawn],[
290 sc_cv_oldLIBS="$LIBS"
291 LIBS="$LIBS $MPI_LIBS"
292 AC_CHECK_FUNCS([MPI_Init_thread MPI_Comm_disconnect MPI_Comm_get_parent MPI_Finalized MPI_Comm_spawn],
293 [acx_cv_mpi_is_mpi2=yes],
294 [acx_cv_mpi_is_mpi2=no])
295 LIBS="$sc_cv_oldLIBS"
296 ],[acx_cv_mpi_is_mpi2=no],
297 [
298 #include <mpi.h>
299 ])
300 CPPFLAGS="$sc_cv_oldCPPFLAGS"
301 AS_IF([test AS_VAR_GET([acx_cv_mpi_is_mpi2]) = yes],[$1],[$2])
302 ])])
303
304 dnl ACX_MPI_SEEK([IF-OK],[IF-NOT-OK])
305 AC_DEFUN([ACX_MPI_SEEK],[dnl
306 AC_REQUIRE([ACX_MPI])
307 AS_IF([test AS_VAR_GET([acx_cv_mpi_implementation]) = no],[$2],[dnl
308 AS_VAR_PUSHDEF([ac_var],[acx_mpi_seek_ok])
309 AC_CACHE_CHECK([whether MPI accepts stdio SEEK_* to be defined],[ac_var],[dnl
310 acx_mpi_old_cppflags="$CPPFLAGS"
311 CPPFLAGS="$CPPFLAGS $MPI_CPPFLAGS"
312 AC_PREPROC_IFELSE(AC_LANG_SOURCE([[
313 #define SEEK_SET 0
314 #define SEEK_CUR 1
315 #define SEEK_END 2
316
317 #include <mpi.h>
318 ]]),[AS_VAR_SET([ac_var],[yes])],[AS_VAR_SET([ac_var],[no])])
319 CPPFLAGS="$acx_mpi_old_cppflags"
320 ])
321 AS_IF([test AS_VAR_GET([ac_var]) = yes],[
322 AC_DEFINE([MPI_ACCEPTS_SEEK],[1],[Indicates whether MPI accepts stdio SEEK_* to be defined])
323 $1
324 ],[
325 AC_DEFINE([MPI_REFUSES_SEEK],[1],[Indicates whether MPI accepts stdio SEEK_* to be defined])
326 $2])
327 AS_VAR_POPDEF([ac_var])
328 ])])