root/mpich2/branches/dev/kumudb/confdb/aclocal_mpi.m4 @ 4870

Revision 4870, 11.4 KB (checked in by kumudb, 5 months ago)

Merge from trunk to kumudb r4748:r4869

Line 
1dnl
2dnl/*D
3dnl PAC_LIB_MPI - Check for MPI library
4dnl
5dnl Synopsis:
6dnl PAC_LIB_MPI([action if found],[action if not found])
7dnl
8dnl Output Effect:
9dnl
10dnl Notes:
11dnl Currently, only checks for lib mpi and mpi.h.  Later, we will add
12dnl MPI_Pcontrol prototype (const int or not?). 
13dnl
14dnl If PAC_ARG_MPICH_BUILDING is included, this will work correctly
15dnl when MPICH is being built.
16dnl
17dnl Prerequisites:
18dnl autoconf version 2.13 (for AC_SEARCH_LIBS)
19dnl D*/
20dnl Other tests to add:
21dnl Version of MPI
22dnl MPI-2 I/O?
23dnl MPI-2 Spawn?
24dnl MPI-2 RMA?
25dnl PAC_LIB_MPI([found text],[not found text])
26AC_DEFUN([PAC_LIB_MPI],[
27dnl Set the prereq to 2.50 to avoid having
28AC_PREREQ(2.50)
29if test "X$pac_lib_mpi_is_building" != "Xyes" ; then
30  # Use CC if TESTCC is defined
31  if test "X$pac_save_level" != "X" ; then
32     pac_save_TESTCC="${TESTCC}"
33     pac_save_TESTCPP="${TESTCPP}"
34     CC="$pac_save_CC"
35     if test "X$pac_save_CPP" != "X" ; then
36         CPP="$pac_save_CPP"
37     fi
38  fi
39  # Look for MPILIB first if it is defined
40  AC_SEARCH_LIBS(MPI_Init,$MPILIB mpi mpich mpich2)
41  if test "$ac_cv_search_MPI_Init" = "no" ; then
42    ifelse($2,,
43    AC_MSG_ERROR([Could not find MPI library]),[$2])
44  fi
45  AC_CHECK_HEADER(mpi.h,pac_have_mpi_h="yes",pac_have_mpi_h="no")
46  if test $pac_have_mpi_h = "no" ; then
47    ifelse($2,,
48    AC_MSG_ERROR([Could not find mpi.h include file]),[$2])
49  fi
50  if test "X$pac_save_level" != "X" ; then
51     CC="$pac_save_TESTCC"
52     CPP="$pac_save_TESTCPP"
53  fi
54fi
55ifelse($1,,,[$1])
56])
57dnl
58dnl
59dnl/*D
60dnl PAC_ARG_MPICH_BUILDING - Add configure command-line argument to indicated
61dnl that MPICH is being built
62dnl
63dnl Output Effect:
64dnl Adds the command-line switch '--with-mpichbuilding' that may be used to
65dnl indicate that MPICH is building.  This allows a configure to work-around
66dnl the fact that during a build of MPICH, certain commands, particularly the
67dnl compilation commands such as 'mpicc', are not yet functional.  The
68dnl variable 'pac_lib_mpi_is_building' is set to 'yes' if in an MPICH build,
69dnl 'no' otherwise.
70dnl
71dnl See Also:
72dnl PAC_LIB_MPI
73dnl D*/
74AC_DEFUN([PAC_ARG_MPICH_BUILDING],[
75AC_ARG_WITH(mpichbuilding,
76[--with-mpichbuilding - Assume that MPICH is being built],
77pac_lib_mpi_is_building=$withval,pac_lib_mpi_is_building="no")
78])
79dnl
80dnl
81dnl This should also set MPIRUN.
82dnl
83dnl/*D
84dnl PAC_ARG_MPI_TYPES - Add command-line switches for different MPI
85dnl environments
86dnl
87dnl Synopsis:
88dnl PAC_ARG_MPI_TYPES([default])
89dnl
90dnl Output Effects:
91dnl Adds the following command line options to configure
92dnl+ \-\-with\-mpich[=path] - MPICH.  'path' is the location of MPICH commands
93dnl. \-\-with\-ibmmpi - IBM MPI
94dnl. \-\-with\-lammpi[=path] - LAM/MPI
95dnl. \-\-with\-mpichnt - MPICH NT
96dnl- \-\-with\-sgimpi - SGI MPI
97dnl If no type is selected, and a default ("mpich", "ibmmpi", or "sgimpi")
98dnl is given, that type is used as if '--with-<default>' was given.
99dnl
100dnl Sets 'CC', 'F77', 'TESTCC', 'TESTF77', and 'MPILIBNAME'.  Does `not`
101dnl perform an AC_SUBST for these values.
102dnl Also sets 'MPIBOOT' and 'MPIUNBOOT'.  These are used to specify
103dnl programs that may need to be run before and after running MPI programs.
104dnl For example, 'MPIBOOT' may start demons necessary to run MPI programs and
105dnl 'MPIUNBOOT' will stop those demons.
106dnl
107dnl The two forms of the compilers are to allow for tests of the compiler
108dnl when the MPI version of the compiler creates executables that cannot
109dnl be run on the local system (for example, the IBM SP, where executables
110dnl created with mpcc will not run locally, but executables created
111dnl with xlc may be used to discover properties of the compiler, such as
112dnl the size of data types).
113dnl
114dnl See also:
115dnl PAC_LANG_PUSH_COMPILERS, PAC_LIB_MPI
116dnl D*/
117AC_DEFUN([PAC_ARG_MPI_TYPES],[
118AC_PROVIDE([AC_PROG_CC])
119AC_SUBST(CC)
120AC_SUBST(CXX)
121AC_SUBST(F77)
122AC_SUBST(F90)
123AC_ARG_WITH(mpich,
124[--with-mpich=path  - Assume that we are building with MPICH],
125ac_mpi_type=mpich)
126# Allow MPICH2 as well as MPICH
127AC_ARG_WITH(mpich2,
128[--with-mpich=path  - Assume that we are building with MPICH],
129ac_mpi_type=mpich)
130AC_ARG_WITH(lammpi,
131[--with-lammpi=path  - Assume that we are building with LAM/MPI],
132ac_mpi_type=lammpi)
133AC_ARG_WITH(ibmmpi,
134[--with-ibmmpi    - Use the IBM SP implementation of MPI],
135ac_mpi_type=ibmmpi)
136AC_ARG_WITH(sgimpi,
137[--with-sgimpi    - Use the SGI implementation of MPI],
138ac_mpi_type=sgimpi)
139AC_ARG_WITH(mpichnt,
140[--with-mpichnt - Use MPICH for Windows NT ],
141ac_mpi_type=mpichnt)
142AC_ARG_WITH(mpi,
143[--with-mpi=path    - Use an MPI implementation with compile scripts mpicc
144                     and mpif77 in path/bin],ac_mpi_type=generic)
145
146if test "X$ac_mpi_type" = "X" ; then
147    if test "X$1" != "X" ; then
148        ac_mpi_type=$1
149    else
150        ac_mpi_type=unknown
151    fi
152fi
153if test "$ac_mpi_type" = "unknown" -a "$pac_lib_mpi_is_building" = "yes" ; then
154    ac_mpi_type="mpich"
155fi
156# Set defaults
157MPIRUN_NP="-np "
158MPIEXEC_N="-n "
159AC_SUBST(MPIRUN_NP)
160AC_SUBST(MPIEXEC_N)
161case $ac_mpi_type in
162        mpich)
163        dnl
164        dnl This isn't correct.  It should try to get the underlying compiler
165        dnl from the mpicc and mpif77 scripts or mpireconfig
166        if test "X$pac_lib_mpi_is_building" != "Xyes" ; then
167            save_PATH="$PATH"
168            if test "$with_mpich" != "yes" -a "$with_mpich" != "no" ; then
169                # Look for commands; if not found, try adding bin to the
170                # path
171                if test ! -x $with_mpich/mpicc -a -x $with_mpich/bin/mpicc ; then
172                        with_mpich="$with_mpich/bin"
173                fi
174                PATH=$with_mpich:${PATH}
175            fi
176            AC_PATH_PROG(MPICC,mpicc)
177            TESTCC=${CC-cc}
178            CC="$MPICC"
179            ac_cv_prog_CC=$CC
180            AC_PATH_PROG(MPIF77,mpif77)
181            TESTF77=${F77-f77}
182            F77="$MPIF77"
183            ac_cv_prog_F77=$F77
184            AC_PATH_PROG(MPIF90,mpif90)
185            TESTF90=${F90-f90}
186            F90="$MPIF90"
187            ac_cv_prog_F90=$F90
188            AC_PATH_PROG(MPICXX,mpiCC)
189            TESTCXX=${CXX-CC}
190            CXX="$MPICXX"
191            ac_cv_prog_CXX=$CXX
192            # We may want to restrict this to the path containing mpirun
193            AC_PATH_PROG(MPIEXEC,mpiexec)
194            AC_PATH_PROG(MPIRUN,mpirun)
195            AC_PATH_PROG(MPIBOOT,mpichboot)
196            AC_PATH_PROG(MPIUNBOOT,mpichstop)
197            PATH="$save_PATH"
198            MPILIBNAME="mpich"
199        else
200            # All of the above should have been passed in the environment!
201            :
202        fi
203        ;;
204
205        mpichnt)
206        dnl
207        dnl This isn't adequate, but it helps with using MPICH-NT/SDK.gcc
208        save_CFLAGS="$CFLAGS"
209        CFLAGS="$save_CFLAGS -I$with_mpichnt/include"
210        save_CPPFLAGS="$CPPFLAGS"
211        CPPFLAGS="$save_CPPFLAGS -I$with_mpichnt/include"
212        save_LDFLAGS="$LDFLAGS"
213        LDFLAGS="$save_LDFLAGS -L$with_mpichnt/lib"
214        AC_CHECK_LIB(mpich,MPI_Init,found="yes",found="no")
215        if test "$found" = "no" ; then
216          AC_CHECK_LIB(mpich2,MPI_Init,found="yes",found="no")
217        fi
218        if test "$found" = "no" ; then
219          CFLAGS=$save_CFLAGS
220          CPPFLAGS=$save_CPPFLAGS
221          LDFLAGS=$save_LDFLAGS
222        fi
223        ;;
224
225        lammpi)
226        dnl
227        dnl This isn't correct.  It should try to get the underlying compiler
228        dnl from the mpicc and mpif77 scripts or mpireconfig
229        save_PATH="$PATH"
230        if test "$with_mpich" != "yes" -a "$with_mpich" != "no" ; then
231            # Look for commands; if not found, try adding bin to the path
232                if test ! -x $with_lammpi/mpicc -a -x $with_lammpi/bin/mpicc ; then
233                        with_lammpi="$with_lammpi/bin"
234                fi
235                PATH=$with_lammpi:${PATH}
236        fi
237        AC_PATH_PROG(MPICC,mpicc)
238        TESTCC=${CC-cc}
239        CC="$MPICC"
240        ac_cv_prog_CC=$CC
241        AC_PATH_PROG(MPIF77,mpif77)
242        TESTF77=${F77-f77}
243        F77="$MPIF77"
244        ac_cv_prog_F77=$F77
245        AC_PATH_PROG(MPIF90,mpif90)
246        TESTF90=${F90-f90}
247        F90="$MPIF90"
248        ac_cv_prog_F90=$F90
249        AC_PATH_PROG(MPICXX,mpiCC)
250        TESTCXX=${CXX-CC}
251        CXX="$MPICXX"
252        ac_cv_prog_CXX=$CXX
253        PATH="$save_PATH"
254        MPILIBNAME="lammpi"
255        MPIBOOT="lamboot"
256        MPIUNBOOT="wipe"
257        MPIRUN="mpirun"
258        ;;
259
260        ibmmpi)
261        AC_CHECK_PROGS(MPCC,mpcc)
262        AC_CHECK_PROGS(MPXLF,mpxlf)
263        if test -z "$MPCC" -o -z "$MPXLF" ; then
264            AC_MSG_ERROR([Could not find IBM MPI compilation scripts.  Either mpcc or mpxlf is missing])
265        fi
266        TESTCC=${CC-xlC}; TESTF77=${F77-xlf}; CC=mpcc; F77=mpxlf
267        ac_cv_prog_CC=$CC
268        ac_cv_prog_F77=$F77
269        # There is no mpxlf90, but the options langlvl and free can
270        # select the F90 version of xlf
271        TESTF90=${F90-xlf90}; F90="mpxlf -qlanglvl=90ext -qfree=f90"
272        MPILIBNAME=""
273        ;;
274
275        sgimpi)
276        TESTCC=${CC:=cc}; TESTF77=${F77:=f77};
277        TESTCXX=${CXX:=CC}; TESTF90=${F90:=f90}
278        AC_CHECK_LIB(mpi,MPI_Init)
279        if test "$ac_cv_lib_mpi_MPI_Init" = "yes" ; then
280            MPILIBNAME="mpi"
281        fi     
282        MPIRUN=mpirun
283        MPIBOOT=""
284        MPIUNBOOT=""
285        ;;
286
287        generic)
288        # Find the compilers.  Expect the compilers to be mpicc and mpif77
289        # in $with_mpi/bin
290        PAC_PROG_CC
291        # We only look for the other compilers if there is no
292        # disable for them
293        if test "$enable_f77" != no -a "$enable_fortran" != no ; then
294            AC_PROG_F77
295        fi
296        if test "$enable_cxx" != no ; then
297            AC_PROG_CXX
298        fi
299        if test "$enable_f90" != no ; then
300            PAC_PROG_F90
301        fi
302        # Set defaults for the TEST versions if not already set
303        if test -z "$TESTCC" ; then
304            TESTCC=${CC:=cc}
305        fi
306        if test -z "$TESTF77" ; then
307            TESTF77=${F77:=f77}
308        fi
309        if test -z "$TESTCXX" ; then
310            TESTCXX=${CXX:=CC}
311        fi
312        if test -z "$TESTF90" ; then
313            TESTF90=${F90:=f90}
314        fi
315        if test "X$MPICC" = "X" ; then
316            if test -x "$with_mpi/bin/mpicc" ; then
317                MPICC=$with_mpi/bin/mpicc
318            fi
319        fi
320        if test "X$MPIF77" = "X" ; then
321            if test -x "$with_mpi/bin/mpif77" ; then
322                MPIF77=$with_mpi/bin/mpif77
323            fi
324        fi
325        if test "X$MPIEXEC" = "X" ; then
326            if test -x "$with_mpi/bin/mpiexec" ; then
327                MPIEXEC=$with_mpi/bin/mpiexec
328            fi
329        fi
330        CC=$MPICC
331        F77=$MPIF77
332        ac_cv_prog_CC=$CC
333        ac_cv_prog_F77=$F77
334        ;;
335
336        *)
337        # Find the compilers
338        PAC_PROG_CC
339        # We only look for the other compilers if there is no
340        # disable for them
341        if test "$enable_f77" != no -a "$enable_fortran" != no ; then
342            AC_PROG_F77
343        fi
344        if test "$enable_cxx" != no ; then
345            AC_PROG_CXX
346        fi
347        if test "$enable_f90" != no ; then
348            PAC_PROG_F90
349        fi
350        # Set defaults for the TEST versions if not already set
351        if test -z "$TESTCC" ; then
352            TESTCC=${CC:=cc}
353        fi
354        if test -z "$TESTF77" ; then
355            TESTF77=${F77:=f77}
356        fi
357        if test -z "$TESTCXX" ; then
358            TESTCXX=${CXX:=CC}
359        fi
360        if test -z "$TESTF90" ; then
361            TESTF90=${F90:=f90}
362        fi
363        ;;
364esac
365])
366dnl
367dnl/*D
368dnl PAC_MPI_F2C - Determine if MPI has the MPI-2 functions MPI_xxx_f2c and
369dnl   MPI_xxx_c2f
370dnl
371dnl Output Effect:
372dnl Define 'HAVE_MPI_F2C' if the routines are found.
373dnl
374dnl Notes:
375dnl Looks only for 'MPI_Request_c2f'.
376dnl D*/
377AC_DEFUN([PAC_MPI_F2C],[
378AC_CACHE_CHECK([for MPI F2C and C2F routines],
379pac_cv_mpi_f2c,
380[
381AC_TRY_LINK([#include "mpi.h"],
382[MPI_Request request;MPI_Fint a;a = MPI_Request_c2f(request);],
383pac_cv_mpi_f2c="yes",pac_cv_mpi_f2c="no")
384])
385if test "$pac_cv_mpi_f2c" = "yes" ; then
386    AC_DEFINE(HAVE_MPI_F2C,1,[Define if MPI has F2C])
387fi
388])
389dnl
390dnl/*D
391dnl PAC_HAVE_ROMIO - make mpi.h include mpio.h if romio enabled
392dnl
393dnl Output Effect:
394dnl expands @HAVE_ROMIO@ in mpi.h into #include "mpio.h"
395dnl D*/
396AC_DEFUN([PAC_HAVE_ROMIO],[
397if test "$enable_romio" = "yes" ; then HAVE_ROMIO='#include "mpio.h"'; fi
398AC_SUBST(HAVE_ROMIO)
399])
Note: See TracBrowser for help on using the browser.