1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ(2.67)
3dnl
4dnl aclocal_cache.m4, included by sowing/confdb/aclocal.m4, fixes
5dnl bugs in autoconf caching.
6dnl
7dnl
8dnl Environment variables that affect behavior of the test configure
9dnl MPICH_FAST
10dnl
11dnl The file name here refers to a file in the source being configured
12dnl FIXME this is the old style, needs updating to new style
13dnl AC_INIT(include/mpitest.h)
14dnl FIXME duplication with VERSION variable below
15AC_INIT([mpich2-testsuite],[1.2])
16AC_CONFIG_HEADER(include/mpitestconf.h)
17AH_TOP([/* -*- Mode: C; c-basic-offset:4 ; -*- */
18/*
19 *  (C) 2001 by Argonne National Laboratory.
20 *      See COPYRIGHT in top-level directory.
21 */
22#ifndef MPITESTCONF_H_INCLUDED
23#define MPITESTCONF_H_INCLUDED
24])
25AH_BOTTOM([#endif])
26# This version is the version of the test suite.
27# 1.0: Initial version (all versions) before independent release
28# 1.1: Initial version that is independent of MPICH2  11/08
29# 1.2: Automake replaces simplemake
30VERSION=1.2
31AC_SUBST(VERSION)
32AC_CONFIG_AUX_DIR([confdb])
33AC_CONFIG_MACRO_DIR([confdb])
34dnl
35echo "RUNNING CONFIGURE FOR MPI TESTS"
36
37AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.12.3 silent-rules subdir-objects])
38AM_MAINTAINER_MODE([enable])
39# not using libtool for the test suite, so no LT_INIT
40AC_PROG_RANLIB
41AM_PROG_AR
42
43# Non-verbose make by default
44m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
45
46if test -z "$mpich2_top_srcdir" ; then
47    if test -z "$top_srcdir" ; then
48       use_top_srcdir=$srcdir
49    else
50       use_top_srcdir=$top_srcdir
51    fi
52    case "$use_top_srcdir" in
53    /*) ;;
54    *)
55        use_top_srcdir=`(cd $use_top_srcdir && pwd)`
56        ;;
57    esac
58    if test -f $use_top_srcdir/../../maint/version.m4 ; then
59        mpich2_top_srcdir=`cd $use_top_srcdir && cd ../.. && pwd`
60    fi
61fi
62AC_SUBST(mpich2_top_srcdir)
63
64# these (in particular master_top_srcdir) are needed to regenerate
65# the f90 files from the f77 files
66AC_ARG_VAR([master_top_builddir],[path to the MPICH2 top-level build directory (if present)])
67AC_ARG_VAR([master_top_srcdir],[path to the MPICH2 top-level source directory (if present)])
68
69# Ensure that master_top_srcdir is set if maintainer mode for is set,
70# since some of the Makefile targets require it.
71if test "X$master_top_srcdir" = "X" -a "$USE_MAINTAINER_MODE" = "yes" ; then
72    if test -z "$top_srcdir" ; then
73       use_top_srcdir=$srcdir
74    else
75       use_top_srcdir=$top_srcdir
76    fi
77    # Make use_top_srcdir absolute
78    case "$use_top_srcdir" in
79    /*) ;;
80    *)
81        use_top_srcdir=`(cd $use_top_srcdir && pwd)`
82        ;;
83    esac
84    # Now, see if we can find the f77tof90 routine
85    if test -x $use_top_srcdir/../../maint/f77tof90 ; then
86        master_top_srcdir=`cd $use_top_srcdir && cd ../.. && pwd`
87    else
88        AC_MSG_ERROR([Unable to find master source file - reconfigure using --disable-maintainer_mode])
89    fi
90fi
91
92AC_ARG_ENABLE(echo,
93	[AC_HELP_STRING([--enable-echo],[Turn on strong echoing. The default is enable=no.])],
94	[set -x])
95
96AC_ARG_ENABLE(f77,
97	[AC_HELP_STRING([--enable-f77],[Turn on Fortran 77 tests (default)])],,[enable_f77=yes])
98AC_ARG_ENABLE(fc,
99	[AC_HELP_STRING([--enable-fc],[Turn on Fortran 90 tests (if f90 available)])],,
100	[enable_fc=yes])
101AC_ARG_ENABLE(cxx,
102	[AC_HELP_STRING([--enable-cxx],[Turn on C++ tests (default)])],,[enable_cxx=yes])
103
104AC_ARG_ENABLE(romio,
105	[AC_HELP_STRING([--enable-romio],[Enable ROMIO MPI I/O implementation])],,
106	[enable_romio=yes])
107
108AC_ARG_ENABLE(spawn,
109	[AC_HELP_STRING([--enable-spawn],
110		[Enable tests of the dynamic process parts of MPI-2 (default)])],,
111	[enable_spawn=yes])
112
113AC_ARG_ENABLE(rma,
114	[AC_HELP_STRING([--enable-rma],[Enable tests of the one sided parts of MPI-2 (default)])],,
115	[enable_rma=yes])
116
117AC_ARG_ENABLE(long-double-complex,
118	[AC_HELP_STRING([--enable-long-double-complex],
119		[Enable tests involving MPI_LONG_DOUBLE_COMPLEX (default)])],,
120	[enable_long_double_complex=yes])
121AC_ARG_ENABLE(long-double,
122	[AC_HELP_STRING([--enable-long-double-complex],
123		[Enable tests involving MPI_LONG_DOUBLE and related types (default)])],,
124	[enable_long_double=yes])
125
126AC_ARG_ENABLE(checkerrors,
127	[AC_HELP_STRING([--enable-checkerrors],
128		[Add some tests for checking for errors in user programs])],,
129	[enable_checkerrors=default])
130
131AC_ARG_ENABLE(perftest,
132	[AC_HELP_STRING([--enable-perftest],
133		[Include tests for basic performance consistency (default)])],,
134	[enable_perftest=yes])
135
136AC_ARG_ENABLE(checkfaults,
137	[AC_HELP_STRING([--enable-checkfaults],
138		[Add some tests for checking on handling of faults in user programs])],,
139	[enable_checkfaults=no])
140
141AC_ARG_ENABLE(fast,
142	[AC_HELP_STRING([--enable-fast],
143		[Indicates that the MPI implementation may have been
144		built for fastest operation, such as building without
145		error checking.  Has the effect of
146		--enable-checkerrors=no])],,)
147
148AC_ARG_ENABLE(strictmpi,
149	[AC_HELP_STRING([--enable-strictmpi],
150		[Only test for operations specifically defined by the
151		MPI standard.  This turns off tests for some common
152		extensions, including for combinations of predefined
153		datatypes and predefined MPI_Op s.])],,
154	[enable_strictmpi=no])
155
156AC_ARG_ENABLE(threads,
157	[--enable-threads=level - Specify the level of thread support expected from the
158				MPI implementation.  The following levels are supported.
159
160	single - No threads (MPI_THREAD_SINGLE)
161	funneled - Only the main thread calls MPI (MPI_THREAD_FUNNELED)
162	serialized - User serializes calls to MPI (MPI_THREAD_SERIALIZED)
163	multiple - Fully multi-threaded (MPI_THREAD_MULTIPLE)
164
165	The default is funneled.  If enabled and no level is
166	specified, the level is set to multiple.  If disabled, the
167	level is set to single.  If the environment variable
168	MPICH_THREAD_LEVEL is set, that thread level is used (this is
169	to let MPICH2 build for the correct thread support without
170	requiring a specific --enable-threads argument.],,
171	[enable_threads=default])
172
173AC_ARG_WITH(mpi,
174	[AC_HELP_STRING([--with-mpi=dir],
175		[Use the selected MPI; compilation scripts for mpicc,
176		mpif77 and mpicxx should be in dir/bin])],,)
177
178AC_ARG_WITH(config-args,
179	[AC_HELP_STRING([--with-config-args=filename],
180		[Specify configure argument file that contains the
181		values of variables that configure reads,
182		e.g. CC,CFLAGS,F77,FFLAGS,FC,FCFLAGS....  If the
183		filename does not begin with / (absolute path), . or
184		.. (relative path), the filename will be assumed to be
185		$top_srcdir/configargs/<filename>.cfg.])],,
186	[with_config_args=no])
187
188if test "$with_config_args" != "no" ; then
189    case "$with_config_args" in
190        /*|../*|./*)
191            config_args_file="$with_config_args"
192            ;;
193        *)
194            config_args_file="$srcdir/configargs/$with_config_args.cfg"
195            ;;
196    esac
197    if test -s "$config_args_file" ; then
198        AC_MSG_RESULT([Reading the configure arguments in ${config_args_file}.])
199        . $config_args_file
200        # Export all the variables in $config_args_file
201        # i.e. CC,CFLAGS, F77/FFLAGS, FC/FCFLAGS, CXX/CXXFLAGS and friends...
202        config_args_vars=`grep -v '^#' $config_args_file | sed -e 's/=.*//g'`
203        for var in $config_args_vars ; do
204            eval value=\$"$var"
205            echo "Exporting $var=$value ..."
206            export $var
207        done
208    else
209        AC_MSG_WARN([Non-existent ${config_args_file}.])
210    fi
211fi
212
213# First, determine whether we are/can support the language bindings
214#
215# Since F90/F90FLAGS are replaced by FC/FCFLAGS, rather than silently
216# substituting them, i.e. FC=$F90 and FCFLAGS=$F90FLAGS, we choose to emit
217# an error message and abort to avoid any ambiguous/hidden bug in choosing
218# Fortran90 compilers.
219if test -n "$F90" -o -n "$F90FLAGS" ; then
220    AC_MSG_ERROR([F90 and F90FLAGS are replaced by FC and FCFLAGS respectively in this configure, please unset F90/F90FLAGS and set FC/FCFLAGS instead and rerun configure again.])
221fi
222
223# ------------------------------------------------------------------------
224dnl use AC_ARG_VAR to mark FROM_MPICH2 as "precious" to autoconf so that
225dnl automatic re-runs of config.status preserve its value correctly
226AC_ARG_VAR([FROM_MPICH2],[should be set to "yes" if this configure script is being invoked by the main MPICH2 configure])
227AC_ARG_VAR([MPICH_THREAD_LEVEL],
228           [the MPI thread level supported by the enclosing MPICH2 build (when built within MPICH2)])
229# ------------------------------------------------------------------------
230
231if test "$enable_threads" = "yes" ; then
232    enable_threads=multiple
233elif test "$enable_threads" = "no" ; then
234    enable_threads=single
235elif test "$enable_threads" = default ; then
236    if test -n "$MPICH_THREAD_LEVEL" ; then
237        case $MPICH_THREAD_LEVEL in
238            MPI_THREAD_MULTIPLE)
239            enable_threads=multiple
240            ;;
241            MPI_THREAD_SERIALIZED)
242            enable_threads=serialized
243            ;;
244            MPI_THREAD_FUNNELED)
245            enable_threads=funneled
246            ;;
247            MPI_THREAD_SINGLE)
248            enable_threads=single
249            ;;
250        esac
251    else
252        enable_threads=funneled
253    fi
254fi
255
256if test "$enable_fast" = "yes" ; then
257    if test "$enable_checkerrors" = "default" ; then
258        enable_checkerrors=no
259    fi
260fi
261# default for MPICH2 is to check error handling; for other cases it
262# is to only check correct programs.
263if test "$FROM_MPICH2" = "yes" ; then
264    if test "$enable_checkerrors" = "default" -a "$MPICH_FAST" != "YES" ; then
265         enable_checkerrors=yes
266    else
267         enable_checkerrors=no
268    fi
269else
270    if test "$enable_checkerrors" = "default" ; then
271         enable_checkerrors=no
272    fi
273fi
274# errordir is substituted into the testlist file as errors when the
275# tests should check error handling and as a comment (#) otherwise.
276errordir="#"
277if test "$enable_checkerrors" = "yes" ; then
278    errordir=errors
279fi
280AC_SUBST(errordir)
281
282# The performance tests are not part of the MPI standard
283perfdir="perf"
284if test "$enable_strictmpi" = "yes" -o "$enable_perftest" = "no" ; then
285     perfdir="#"
286fi
287AC_SUBST(perfdir)
288#
289# Only run the threads tests if multiple is specified
290if test "$enable_threads" = "multiple" -o "$enable_threads" = "runtime" ; then
291    threadsdir="threads"
292fi
293
294PAC_LOAD_BASE_CACHE
295PAC_VPATH_CHECK()
296PAC_PROG_MAKE
297
298MPILIBLOC=""
299AC_SUBST(MPILIBLOC)
300
301# more variables that must be marked precious for proper re-configure operation
302AC_ARG_VAR([MPICH2_ENABLE_F77],["yes" if the enclosing MPICH2 build supports Fortran 77])
303AC_ARG_VAR([MPICH2_ENABLE_FC],["yes" if the enclosing MPICH2 build supports modern Fortran])
304AC_ARG_VAR([MPICH2_ENABLE_CXX],["yes" if the enclosing MPICH2 build supports C++])
305
306# If we're building from MPICH2, check the MPICH2_ENABLE_xxx environment
307# variables for enable defaults
308if test "$FROM_MPICH2" = yes ; then
309    if test -n "$MPICH2_ENABLE_F77" ; then
310        enable_f77=$MPICH2_ENABLE_F77
311    fi
312    if test -n "$MPICH2_ENABLE_FC" ; then
313        enable_fc=$MPICH2_ENABLE_FC
314    fi
315    if test -n "$MPICH2_ENABLE_CXX" ; then
316        enable_cxx=$MPICH2_ENABLE_CXX
317    fi
318fi
319
320# Some MPI-2 implementations (including some of the MPICH2 shared-memory
321# channels and BG/L) leave out the dynamic process routines.  This
322# allows tests to avoid reporting failure for these routines.
323# This can be controlled by either a --disable-spawn argument or by
324# setting the environment variable MPI_NO_SPAWN to yes.
325AC_ARG_VAR([MPI_NO_SPAWN],[set to "yes" to disable dynamic process tests])
326if test "$enable_spawn" = "yes" -a "$MPI_NO_SPAWN" != "yes" ; then
327    spawndir=spawn
328    AC_DEFINE(HAVE_MPI_SPAWN,1,[Define if Dynamic Process functionality is available])
329fi
330AC_SUBST(spawndir)
331
332# Also allow rma to be disabled
333AC_ARG_VAR([MPI_NO_RMA],[set to "yes" to disable one-sided tests])
334rmadir=rma
335if test "$enable_rma" != yes ; then
336    rmadir="#"
337elif test "$MPI_NO_RMA"  = yes ; then
338    rmadir="#"
339else
340    AC_DEFINE(HAVE_MPI_WIN_CREATE,1,[Define if MPI_Win_create is available])
341fi
342AC_SUBST(rmadir)
343
344faultsdir=#
345if test "$enable_checkfaults" = "yes" ; then
346    faultsdir=faults
347fi
348AC_SUBST(faultsdir)
349#
350MPI_IS_STRICT=false
351AC_SUBST(MPI_IS_STRICT)
352if test "$enable_strictmpi" = "yes" ; then
353    MPI_IS_STRICT=true
354    AC_DEFINE(USE_STRICT_MPI,1,[Define if only operations defined in MPI should be tested])
355fi
356#
357# At this writing, MPICH2 has many MPIX routines, and the test suite includes
358# them.  As these are not MPI routines (yet), they are invalid and incorrect
359# when this test suite is used for other MPI implementations, including those
360# based on earlier versions of MPICH2.
361MPI_HAS_MPIX=no
362#
363# Hack to detect build from within MPICH2.  Ensure strictmpi not selected.
364if test "$FROM_MPICH2" = "yes" -a "$enable_strictmpi" = "no" ; then
365   MPI_HAS_MPIX=yes
366fi
367AC_SUBST(MPI_HAS_MPIX)
368
369# preserve these values across a reconfigure
370AC_ARG_VAR([WRAPPER_CFLAGS],[])
371AC_ARG_VAR([WRAPPER_CPPFLAGS],[])
372AC_ARG_VAR([WRAPPER_LDFLAGS],[])
373AC_ARG_VAR([WRAPPER_LIBS],[])
374AC_ARG_VAR([WRAPPER_FFLAGS],[])
375AC_ARG_VAR([WRAPPER_FCFLAGS],[])
376AC_ARG_VAR([WRAPPER_CXXFLAGS],[])
377
378if test "$FROM_MPICH2" = "yes" ; then
379    # perform configure tests with the normal compilers ($CC/$F77/etc), but use
380    # the WRAPPER_xFLAGS computed by MPICH2 as our flags instead.  Then at the
381    # end of configure we will empty out these flags and set our compilers to
382    # the installed compiler wrappers
383    CFLAGS="$WRAPPER_CFLAGS"
384    CPPFLAGS="$WRAPPER_CPPFLAGS"
385    LDFLAGS="$WRAPPER_LDFLAGS"
386    FFLAGS="$WRAPPER_FFLAGS"
387    FCFLAGS="$WRAPPER_FCFLAGS"
388    CXXFLAGS="$WRAPPER_CXXFLAGS"
389
390    # WRAPPER_LIBS contains currently non-existent libs like "-lopa" and "-lmpl"
391    # right now, so set LIBS to the user-specified libs for now.
392    # FIXME Does this need to be an AC_ARG_VAR?
393    LIBS="$MPICH2_LIBS"
394
395elif test -n "$with_mpi" ; then
396    if test -z "$MPICC" ; then
397        CC=$with_mpi/bin/mpicc
398    else
399        CC=$MPICC
400    fi
401    if test -z "$MPIF77" ; then
402        F77=$with_mpi/bin/mpif77
403    else
404        F77=$MPIF77
405    fi
406    if test -z "$MPIFC" ; then
407        FC=$with_mpi/bin/mpif90
408    else
409        FC=$MPIFC
410    fi
411    if test -z "$MPICXX" ; then
412        CXX=$with_mpi/bin/mpicxx
413    else
414        CXX=$MPICXX
415    fi
416    if test -z "$MPIEXEC" ; then
417        MPIEXEC=$with_mpi/bin/mpiexec
418    fi
419else
420    # Try to use mpicc etc names
421    if test -z "$MPICC" ; then
422        AC_PATH_PROG(MPICC,mpicc mpcc)
423    fi
424    if test "x$MPICC" != "x" ; then
425        CC=$MPICC
426    fi
427    if test -z "$MPIF77" ; then
428        AC_PATH_PROG(MPIF77,mpif77 mpf77)
429    fi
430    if test "x$MPIF77" != "x" ; then
431        F77=$MPIF77
432    fi
433    if test -z "$MPIFC" ; then
434        AC_PATH_PROG(MPIFC,mpif90 mpftn)
435    fi
436    if test "x$MPIFC" != "x" ; then
437        FC=$MPIFC
438    fi
439    if test -z "$MPICXX" ; then
440        # We left mpiCC off of this list because mpicc and mpiCC are the
441        # same on Mac OSX systems.
442        AC_PATH_PROG(MPICXX,mpicxx mpCC)
443    fi
444    if test "x$MPICXX" != "x" ; then
445        CXX=$MPICXX
446    fi
447    if test -z "$MPIEXEC" ; then
448        AC_PATH_PROG(MPIEXEC,mpiexec)
449    fi
450fi
451
452# Running C compiler tests
453PAC_PROG_CC
454
455# Note that some versions of autoconf will insist that the compiler
456# produce executables at this point, which is why we must do something
457# special for building within MPICH2
458
459# Ensure that we can compile an MPI program before we go any further
460# We don't use a cached value here because this is a sanity check
461# The exception is if we are executing this configure from within the
462# MPICH2 configure - in that case, the
463if test "$FROM_MPICH2" != "yes" ; then
464    AC_MSG_CHECKING([whether we can compile and link MPI programs in C])
465    AC_LINK_IFELSE([
466AC_LANG_PROGRAM([#include "mpi.h"],[MPI_Init(0,0);MPI_Finalize();])
467    ],[mpi_compile_works=yes],[mpi_compile_works=no])
468AC_MSG_RESULT($mpi_compile_works)
469
470    if test "$mpi_compile_works" != "yes" ; then
471       AC_MSG_ERROR([Unable to compile and/or link an MPI program!  Check config.log])
472    fi
473fi
474dnl We cannot use AC_C_LONG_DOUBLE
475dnl because it does not support cross-compilation.  Instead, we use the
476dnl same test in the MPICH2 configure.
477# Check on support for long double and long long types.  Do this before the
478# structure alignment test because it will test for including those
479# types as well
480#
481# If --disable-long-double is selected, then bypass this test.
482# Some MPI implementations may choose to not support long double because
483# their C compilers are inconsistent on the length of long double (this
484# is the case on the Cray, with Cray, PGI, and GNU not agreeing on the
485# size of long double)
486if test "$enable_long_double" = "yes" ; then
487    AC_CACHE_CHECK([whether long double is supported],pac_cv_have_long_double,[
488    AC_COMPILE_IFELSE([
489        AC_LANG_PROGRAM([],[long double a;])
490    ],[pac_cv_have_long_double=yes],[pac_cv_have_long_double=no])
491])
492    if test "$pac_cv_have_long_double" = "yes" ; then
493        AC_DEFINE(HAVE_LONG_DOUBLE,1,[Define if long double is supported])
494    fi
495fi
496AC_CACHE_CHECK([whether long long is supported],pac_cv_have_long_long,[
497    AC_COMPILE_IFELSE([
498        AC_LANG_PROGRAM([],[long long a;])
499    ],[pac_cv_have_long_long=yes],[pac_cv_have_long_long=no])
500])
501if test "$pac_cv_have_long_long" = yes ; then
502    AC_DEFINE(HAVE_LONG_LONG,1,[Define if compiler supports long long])
503fi
504#
505# Check for const and restrict (used in some of the performance tests)
506AC_C_CONST
507AC_C_RESTRICT
508
509# Enable STRICT CFLAGS
510AC_ARG_ENABLE(stricttest,
511AC_HELP_STRING([--enable-stricttest], [Turn on strict GCC compilation]))
512dnl Initialize enable_strict_done so PAC_CC_STRICT won't exit right away
513dnl When it is configuring from within MPICH2, because enable_strict_done=yes
514dnl is set in the environment by MPICH2.
515enable_strict_done=no
516PAC_CC_STRICT($enable_stricttest)
517# -Wfloat-equal isn't meaningful in testsuite,
518# remove it if it is in strict flags.
519pac_cc_strict_flags="`echo $pac_cc_strict_flags | sed -e 's|-Wfloat-equal||g'`"
520CFLAGS="$CFLAGS $pac_cc_strict_flags"
521
522# General headers
523AC_HEADER_STDC
524dnl AC_CHECK_HEADERS(stdarg.h unistd.h string.h stdlib.h memory.h stdint.h)
525dnl unistd.h string.h stdlib.h memory.h stdint.h are checked by AC_PROG_CC.
526AC_CHECK_HEADERS(stdarg.h sys/time.h sys/resource.h)
527
528# Check for fixed width types
529AC_TYPE_INT8_T
530AC_TYPE_INT16_T
531AC_TYPE_INT32_T
532AC_TYPE_INT64_T
533AC_TYPE_UINT8_T
534AC_TYPE_UINT16_T
535AC_TYPE_UINT32_T
536AC_TYPE_UINT64_T
537
538# Check for availability of C99 types
539AC_CHECK_TYPES([_Bool, float _Complex, double _Complex, long double _Complex])
540
541# Only run the long double complex tests if that type is available
542if test "$enable_long_double_complex" != "no" -a \
543   "x$ac_cv_type_long_double__Complex" = "xyes" ; then
544   AC_DEFINE(USE_LONG_DOUBLE_COMPLEX,1,[Define if tests with long double complex should be included])
545fi
546
547# Headers needed for threads tests
548if test "$threadsdir" = "threads" ; then
549    # Check for needed threads headers and needed and optional routines
550    AC_CHECK_HEADERS(pthread.h)
551
552    # we shouldn't actually need to do this, but we are dodging the chicken/egg
553    # problem b/c we don't have a working mpicc yet and we temporarily discarded
554    # the MPICH2-set LIBS (probably the wrong thing to do)
555    AC_SEARCH_LIBS([pthread_create],[pthread])
556    AC_SEARCH_LIBS([pthread_barrier_init],[pthread])
557
558    AC_CHECK_FUNCS(pthread_create pthread_yield pthread_barrier_init pthread_barrier_wait)
559    if test "$FROM_MPICH2" != yes ; then
560        AC_CHECK_FUNCS(MPI_Init_thread)
561    fi
562fi
563
564# Check for h_addr or h_addr_list.  This is needed for the singjoin test
565# in manual/singjoin.c
566AC_CACHE_CHECK([whether struct hostent contains h_addr_list],
567dnl Use Double quote LANG_PROGRAM
568dnl so [] in h_addr_list[0] won't be ignored by IFELSE.
569pac_cv_have_haddr_list,[
570AC_COMPILE_IFELSE([
571   AC_LANG_PROGRAM([#include <netdb.h>],[[
572      struct hostent hp;
573      hp.h_addr_list[0]=0;
574   ]])
575],[pac_cv_have_haddr_list=yes],[pac_cv_have_haddr_list=no])
576])
577if test "$pac_cv_have_haddr_list" = "yes" ; then
578    AC_DEFINE(HAVE_H_ADDR_LIST,1,[Define if struct hostent contains h_addr_list])
579fi
580
581AC_CHECK_FUNCS(getrusage)
582
583# Check for the MPI Version.  This test assumes at least MPI 2.0.  For
584# some tests, we need to know if we are MPI 2.1 or MPI 2.2,
585# particularly for new routines in Fortran
586if test "$FROM_MPICH2" != "yes" ; then
587    AC_CACHE_CHECK([that MPI program can be compiled],pac_cv_mpi_compile_ok,[
588AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "mpi.h"],[MPI_Init(0,0);MPI_Finalize();])],pac_cv_mpi_compile_ok=yes,pac_cv_mpi_compile_ok=no)])
589    if test "$pac_cv_mpi_compile_ok" != yes ; then
590        AC_MSG_ERROR([Unable to compile an MPI program containing mpi.h!])
591    fi
592    AC_CACHE_CHECK([for major version of MPI],pac_cv_mpi_major_version,[
593for pac_cv_mpi_major_version in 3 2 1 unknown ; do
594    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "mpi.h"],[
595#if MPI_VERSION == $pac_cv_mpi_major_version
596    ''' force failure '''
597#endif])],,break)
598done
599])
600
601    AC_CACHE_CHECK([for minor version of MPI],pac_cv_mpi_minor_version,[
602for pac_cv_mpi_minor_version in 4 3 2 1 0 unknown ; do
603    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "mpi.h"],[
604#if MPI_SUBVERSION == $pac_cv_mpi_minor_version
605    ''' force failure '''
606#endif])],,break)
607done
608])
609MPI_VERSION=$pac_cv_mpi_major_version
610MPI_SUBVERSION=$pac_cv_mpi_minor_version
611else
612    # We are within the MPICH2 build.  Extract the MPI versions from
613    # mpi.h.in
614    if test ! -f $mpich2_top_srcdir/src/include/mpi.h.in ; then
615        AC_MSG_ERROR([Could not find the required mpi.h.in file!])
616    fi
617    MPI_VERSION=`grep MPI_VERSION $mpich2_top_srcdir/src/include/mpi.h.in | \
618    		      sed -e 's/#define *MPI_VERSION *\([0-4]\).*/\1/g'`
619    MPI_SUBVERSION=`grep MPI_SUBVERSION $mpich2_top_srcdir/src/include/mpi.h.in | \
620    		      sed -e 's/#define *MPI_SUBVERSION *\([0-9]\).*/\1/g'`
621fi
622
623AC_SUBST(MPI_VERSION)
624AC_SUBST(MPI_SUBVERSION)
625
626# Running Fortran 77 compiler tests
627PAC_PROG_F77
628if test "$enable_f77" = yes ; then
629    # If there is no working F77, then set enable_f77 to no
630    if test -z "$F77" ; then
631        enable_f77=no
632    fi
633fi
634# Simple tests for which other languages we can handle.
635# Use these only when configuring separate from an MPICH2 build
636f77dir="#"
637AC_SUBST(f77dir)
638buildingF77=no
639if test "$FROM_MPICH2" = yes ; then
640    if test "$enable_f77" = yes ; then
641       # Assume success
642        otherlangs="$otherlangs f77"
643        f77dir=f77
644        buildingF77=yes
645    fi
646elif test "$enable_f77" = yes ; then
647    AC_MSG_CHECKING([that we can build MPI programs with Fortran 77])
648    AC_LANG_PUSH([Fortran 77])
649    AC_LINK_IFELSE([
650        AC_LANG_SOURCE([
651            program main
652            include 'mpif.h'
653            integer ierr
654            call mpi_init(ierr)
655            call mpi_finalize(ierr)
656            end
657        ])
658    ],[
659        AC_MSG_RESULT(yes)
660        otherlangs="$otherlangs f77"
661        f77dir=f77
662        buildingF77=yes
663    ],[
664        AC_MSG_RESULT(no)
665    ])
666    AC_LANG_POP([Fortran 77])
667fi
668#
669# At least one test (C++ test of C and Fortran datatypes) needs to
670# know if Fortran is supported
671if test "$f77dir" = "f77" ; then
672    AC_DEFINE(HAVE_FORTRAN_BINDING,1,[Define if Fortran is supported])
673fi
674
675AM_CONDITIONAL([BUILD_F77_TESTS],[test "X$f77dir" = "f77"])
676
677AC_ARG_VAR([MPI_SIZEOF_AINT],[if set, force MPI_Aint to a width of this many bytes])
678AC_ARG_VAR([MPI_SIZEOF_OFFSET],[if set, force MPI_Offset to a width of this many bytes])
679
680# Common tests for F77
681if test "$buildingF77" = "yes" ; then
682    # Match integer types to the MPI types for MPI_Aint and MPI_Offset
683
684    # FIXME: Add a test to see if the environment is importing the
685    # necessary information.
686
687    # Get the sizes of the MPI types.  We use the following:
688    # MPI_SIZEOF_OFFSET and MPI_SIZEOF_AINT
689    if test -z "$MPI_SIZEOF_AINT" ; then
690        # Aint should be an address-sized integer, the same as void*
691        # We use a test on the size of void * to avoid any complications
692        # in dealing with running programs containing MPI headers (e.g.,
693        # the IBM MPI changes the main entry point so that MPI
694        # programs cannot be run on the host node)
695        AC_CHECK_SIZEOF(void *)
696        MPI_SIZEOF_AINT=$ac_cv_sizeof_void_p
697    fi
698    if test -z "$MPI_SIZEOF_OFFSET" ; then
699        # We have to try and get the size of offset anyway, since
700        # it is not the same as void * (it depends on the available
701        # file systems).  Since we want to avoid using the MPI linker,
702        # we could do the following:
703        #    Use the mpi compiler to compile the file, using the mpi
704        #    header but no MPI calls
705        #    Use the regular C linker to link the program
706        # However, we do this only if the environment variable BASECC
707        # has been provided.  Else we can try the following:
708        # use
709        #    sed -n 's/typedef \(.*\) MPI_Offset *;/\1/p' mpi.h
710        # to extract the type corresponding to MPI_Offset and then
711        # just use that.
712dnl         AC_CACHE_CHECK([the sizeof MPI_Offset],ac_cv_sizeof_MPI_Offset,[
713dnl              ac_cv_sizeof_MPI_Offset=unknown
714dnl              rm -f conftest*
715dnl              cat >>conftest.c <<EOF
716dnl #include "mpi.h"
717dnl #include <stdio.h>
718dnl int main( int argc, char **argv )
719dnl {
720dnl     MPI_Offset a;
721dnl     FILE *f = fopen("conftestval", "w" );
722dnl     if (! f) exit(1);
723dnl     fprintf( f, "%ld\n", (long)sizeof(MPI_Offset) );
724dnl     fclose(f);
725dnl     return 0;
726dnl }
727dnl EOF
728dnl             # FIXME.  Check for BASECC
729dnl             # Note: This assumes that CC has been set to the C compiler for
730dnl             # MPI Programs, and that either any necessary include paths are
731dnl             # already set or they are in CPPFLAGS (prefered) or CFLAGS.
732dnl             if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext ; then
733dnl                 if ./conftest$ac_exeext ; then
734dnl                     #success
735dnl                     ac_cv_sizeof_MPI_Offset=`cat conftestval`
736dnl                 else
737dnl                     # failure
738dnl                     AC_MSG_WARN([Unable to run the program to determine the size of MPI_Offset])
739dnl                     echo "configure: failed program was:" >&AC_FD_CC
740dnl                     cat conftest.c >&AC_FD_CC
741dnl                 fi
742dnl             else
743dnl                 # failure
744dnl                 AC_MSG_WARN([Unable to build the program to determine the size of MPI_Offset])
745dnl                 echo "configure: failed program was:" >&AC_FD_CC
746dnl                 cat conftest.c >&AC_FD_CC
747dnl             fi
748dnl             rm -f conftest*
749dnl         ])
750        AC_CHECK_SIZEOF([MPI_Offset],[],[#include "mpi.h"])
751        if test "$ac_cv_sizeof_MPI_Offset" = "unknown" \
752             -o "$ac_cv_sizeof_MPI_Offset" -eq 0 ; then
753             AC_MSG_WARN([Using 8 for the size of MPI_Offset])
754             MPI_SIZEOF_OFFSET=8
755        else
756             MPI_SIZEOF_OFFSET=$ac_cv_sizeof_MPI_Offset
757        fi
758    fi
759
760    AC_LANG_PUSH([Fortran 77])
761    AC_CACHE_CHECK([whether integer*4 is supported],pac_cv_fort_integer4,[
762    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[      integer*4 i])],
763        pac_cv_fort_integer4=yes,
764        pac_cv_fort_integer4=no)])
765    AC_CACHE_CHECK([whether integer*8 is supported],pac_cv_fort_integer8,[
766    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[      integer*8 i])],
767        pac_cv_fort_integer8=yes,
768        pac_cv_fort_integer8=no)])
769    AC_CACHE_CHECK([whether integer*16 is supported],pac_cv_fort_integer16,[
770    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[      integer*16 i])],
771        pac_cv_fort_integer16=yes,
772        pac_cv_fort_integer16=no)])
773    AC_LANG_POP([Fortran 77])
774
775    # Determine Aint and Offset
776    for len in 4 8 16 ; do
777        eval testval=\$"pac_cv_fort_integer$len"
778        if test "$testval" = no ; then continue ; fi
779        testval=$len
780        if test $len = "$MPI_SIZEOF_AINT" ; then
781            F77_MPI_ADDRESS="integer*$len"
782        fi
783        if test $len = "$MPI_SIZEOF_OFFSET" ; then
784            F77_MPI_OFFSET="integer*$len"
785        fi
786    done
787    # At this point, we could create a test program that would confirm that
788    # the values in Fortran matched the values in C.
789    # Note that we must make this an MPI program because the compiler for
790    # MPI programs may require that the programs be run with mpiexec or
791    # something similar (this is true for the IBM MPI, for example).
792    rm -f f77/init/checksizes.c
793    # If it is a VPATH build, f77/init may not be there.
794    if test ! -d f77/init ; then
795        mkdir f77
796        mkdir f77/init
797    fi
798    cat > f77/init/checksizes.c <<EOF
799#include "mpi.h"
800#include <stdio.h>
801int main( int argc, char **argv )
802{
803  int fsizeof_aint   = $MPI_SIZEOF_AINT;
804  int fsizeof_offset = $MPI_SIZEOF_OFFSET;
805  int err = 0, rc = 0;
806
807  MPI_Init( &argc, &argv );
808  if (sizeof(MPI_Aint) != fsizeof_aint) {
809     printf( "Sizeof MPI_Aint is %d but Fortran thinks it is %d\n",
810             (int)sizeof(MPI_Aint), fsizeof_aint );
811     err++;
812  }
813  if (sizeof(MPI_Offset) != fsizeof_offset) {
814     printf( "Sizeof MPI_Offset is %d but Fortran thinks it is %d\n",
815             (int)sizeof(MPI_Offset), fsizeof_offset );
816     err++;
817  }
818  MPI_Finalize( );
819  if (err > 0) rc = 1;
820  return rc;
821}
822EOF
823
824    # Check for name mapping so that we can do the handle conversion tests
825    # This test needs both the base c and fortran compilers
826    AC_LANG_FORTRAN77
827    PAC_PROG_F77_NAME_MANGLE
828
829    # Check that the Fortran compiler will allow us to pass arguments
830    # of different types (e.g., for MPI_Send)
831    # Any strict Fortran compiler will require that the arguments be
832    # the same type - currently, the NAG Fortran compiler (nagfor) is known
833    # to enforce this.
834    # We could set the FFLAGS/FCFLAGS values with the option that disables
835    # this check (if we found one), but because that may affect other tests,
836    # instead we tell the user and exit.
837    PAC_PROG_F77_MISMATCHED_ARGS(addarg,yes)
838    if test "X$addarg" != "X" ; then
839        # We could add the names of all of the MPI routines that
840        # accept different types.  Instead, we fail cleanly.
841        # Some Fortran compilers allow you to turn off checking for
842        # mismatched arguments for *all* routines.  Adding an argument
843	# that turns off checking for *everything* is not something that
844	# configure should do - if the user wants this, they can follow
845	# the instructions in the following error message.
846	AC_MSG_ERROR([The Fortran compiler $F77 does not accept programs that call the same routine with arguments of different types without the option $addarg.  Rerun configure with FFLAGS=$addarg])
847    fi
848
849    # Check whether we need -lU77 to get iargc and getarg, which
850    # are used for a few of the tests in spawn (U77 was needed with
851    # the native compilers on HPUX.  See the aclocal_f77(old).m4 file,
852    # which has a much more complete set of tests.
853    #
854    # FIXME: if we can't figure out how to get iargc/getarg, then
855    # we should really turn off those spawn tests
856    # Even better is to limit this to the F200x version, where there is
857    # an interface to the command line.
858    F77SPAWNARGTEST=""
859    AC_MSG_CHECKING([for Fortran libraries needed for getarg])
860    AC_LANG_CONFTEST([
861        AC_LANG_PROGRAM([],[
862            character*64 s
863            integer i
864            i = iargc()
865            call getarg(i,s)
866        ])
867    ])
868    AC_LINK_IFELSE([],[
869        pac_cv_getarg_needs_u77=no
870    ],[
871        pac_cv_getarg_needs_u77=unknown
872    ])
873    if test "$pac_cv_getarg_needs_u77" != "no" ; then
874        # Try again with -lU77
875        saveLIBS="$LIBS"
876        LIBS="$LIBS -lU77"
877        AC_LINK_IFELSE([],[
878            pac_cv_getarg_needs_u77=yes
879        ],[
880            pac_cv_getarg_needs_u77=unavailable
881        ])
882        LIBS="$saveLIBS"
883        if test "$pac_cv_getarg_needs_u77" = "yes" ; then
884            F77_GETARG_LIBS=-lU77
885        fi
886    fi
887    rm -f conftest$ac_exeext
888    if test -n "$F77_GETARG_LIBS" ; then
889        AC_MSG_RESULT($F77_GETARG_LIBS)
890    else
891        if test "$pac_cv_getarg_needs_u77" = "unavailable" ; then
892            AC_MSG_RESULT([getarg and/or iargc are not available.  Some spawn tests will fail to link])
893	    F77SPAWNARGTEST="#"
894        else
895            AC_MSG_RESULT([none needed])
896        fi
897    fi
898    AC_SUBST(F77_GETARG_LIBS)
899    # FIXME: Currently, we hope that FC accepts the same library
900    FC_GETARG_LIBS="$F77_GETARG_LIBS"
901    AC_SUBST(FC_GETARG_LIBS)
902    # F77SPAWNARGTEST is set to "#" to comment out tests in
903    # f77/spawn/testlist.in that require non-standard extensions to
904    # access the commandline
905    AC_SUBST(F77SPAWNARGTEST)
906
907    # ALLOCMEMF is set in f77/ext/testlist if we can try this
908    # Fortran extension
909    ALLOCMEMF=""
910    PAC_PROG_F77_CRAY_POINTER([
911        ALLOCMEMF="allocmemf 1"
912        FFLAGS="$FFLAGS $CRAYPTR_FFLAGS"
913    ])
914    AC_SUBST(ALLOCMEMF)
915    # See the f90 block of code for the Fortran 90 version of ALLOCMEMF,
916    # i.e. ALLOCMEMFC.
917
918fi
919# Set a default for the Fortran 77 version of MPI_Offset.
920if test -z "$F77_MPI_OFFSET" ; then
921    F77_MPI_OFFSET="integer*8"
922    AC_MSG_WARN([Selecting integer*8 as the Fortran type for MPI_Offset])
923fi
924AC_SUBST(F77_MPI_OFFSET)
925# FIXME: Find a way to get the correct value
926if test -z "$F77_MPI_ADDRESS" ; then
927    F77_MPI_ADDRESS="integer"
928    AC_MSG_WARN([Selecting integer as the Fortran type for MPI_Aint])
929fi
930AC_SUBST(F77_MPI_ADDRESS)
931
932# Running Fortran 90+ compiler tests
933PAC_PROG_FC
934if test "$enable_fc" = yes ; then
935    # Work around feature in autoconf that adds -g -O2 to FCFLAGS
936    saveFCFLAGS="$FCFLAGS"
937    FCFLAGS="$saveFCFLAGS"
938    # If there is no working FC, then set enable_fc to no
939    if test -z "$FC" ; then
940        enable_fc=no
941    fi
942fi
943f90dir="#"
944AC_SUBST(f90dir)
945# First, see if we have an f90 compiler.  This uses code similar to that
946# in the MPICH2 top-level configure
947if test "$enable_fc" = yes -a "$enable_f77" = yes ; then
948    PAC_PROG_FC_WORKS
949    if test -z "$FC" -o "$pac_cv_prog_fc_works" != yes ; then
950        enable_fc=no
951    fi
952fi
953
954dnl If enable_fc=yes up to this point then enable_f77=yes also
955dnl PAC_PROG_FC and PAC_PROG_FC_WORKS return OK
956if test "$enable_fc" = yes ; then
957    # Make sure that the compilers are compatible.  This
958    # will also make sure that the program named in FC is
959    # a working Fortran 90 compiler
960    # Only check if we're *not* building within MPICH2
961    # (MPICH2 will have made the test)
962    # FIXME: Do we want to check only simple routine names
963    # (those without an underscore?)
964    if test "$FROM_MPICH2" != yes ; then
965        PAC_FC_AND_F77_COMPATIBLE(enable_fc=yes,enable_fc=no)
966    fi
967fi
968
969if test "$enable_fc" = yes ; then
970    if test "$ac_fc_srcext" != "f90" ; then
971        AC_LANG_PUSH([Fortran])
972        AC_FC_SRCEXT([f90],[
973            FCFLAGS="$FCFLAGS $FCFLAGS_f90"
974        ],[
975            AC_MSG_WARN([Fortran 90 test being disabled because the $FC compiler does not accept a .f90 extension])
976            f90dir=#
977            enable_fc=no
978        ])
979        AC_LANG_POP([Fortran])
980    fi
981
982    # The Fortran90 tests rely on free-form input which needs to be tested
983    # before any test that may modify FCFLAGS, e.g. the cray-pointer test.
984    # The order of the tests is important in compiler like g95.
985    AC_FC_FREEFORM
986
987    # See if the compiler supports the Cray-style pointers
988    ALLOCMEMFC=""
989    PAC_PROG_FC_CRAY_POINTER([
990        ALLOCMEMFC="allocmemf90 1"
991        FCFLAGS="$FCFLAGS $CRAYPTR_FCFLAGS"
992    ])
993    AC_SUBST(ALLOCMEMFC)
994
995    # Check for the new command line routines used in one of the spawn tests
996    AC_LANG_PUSH([Fortran])
997    F03SPAWNARGTEST=""
998    AC_MSG_CHECKING([whether $FC supports the Fortran 2003 routines to access the commandline])
999    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[
1000            character*64 s
1001            integer i
1002            i = command_argument_count()
1003            call get_command_argument(i,s)
1004        ])],[pac_cv_fc_has_args=yes],[pac_cv_fc_has_args=no])
1005    AC_MSG_RESULT($pac_cv_fc_has_args)
1006    if test "$pac_cv_fc_has_args" != "yes" ; then
1007        F03SPAWNARGTEST="#"
1008    fi
1009    # F03SPAWNARGTEST is set to "#" to comment out tests in
1010    # f90/spawn/testlist.in that require Fortran 2003 features to
1011    # access the commandline
1012    AC_SUBST(F03SPAWNARGTEST)
1013    AC_LANG_POP([Fortran])
1014
1015    if test -f f77/init/checksizes.c ; then
1016        # If it is a VPATH build, f90/init may not be there.
1017        if test ! -d f90/init ; then
1018            mkdir f90
1019            mkdir f90/init
1020        fi
1021        cp f77/init/checksizes.c f90/init
1022    fi
1023fi
1024#
1025if test "$FROM_MPICH2" = yes ; then
1026    if test "$enable_fc" = yes ; then
1027        otherlangs="$otherlangs f90"
1028        f90dir=f90
1029    fi
1030elif test "$enable_fc" = yes ; then
1031    AC_MSG_CHECKING([that we can build MPI programs with Fortran 90])
1032    AC_LANG_PUSH([Fortran])
1033    AC_LINK_IFELSE([
1034        AC_LANG_SOURCE([
1035            program main
1036            use mpi
1037            integer ierr
1038            call mpi_init(ierr)
1039            call mpi_finalize(ierr)
1040            end
1041        ])
1042    ],[
1043        AC_MSG_RESULT(yes)
1044        otherlangs="$otherlangs f90"
1045        f90dir=f90
1046    ],[
1047        AC_MSG_RESULT(no)
1048    ])
1049    AC_LANG_POP([Fortran])
1050fi
1051AM_CONDITIONAL([BUILD_F90_TESTS],[test "X$f90dir" = "f90"])
1052
1053# Running C++ compiler tests
1054PAC_PROG_CXX
1055if test "$enable_cxx" = yes ; then
1056    if test -z "$CXX" ; then
1057        enable_cxx=no
1058    fi
1059fi
1060# Simple tests for which other languages we can handle
1061cxxdir="#"
1062AC_SUBST(cxxdir)
1063if test "$FROM_MPICH2" = yes ; then
1064    if test "$enable_cxx" = yes ; then
1065        otherlangs="$otherlangs cxx"
1066        cxxdir=cxx
1067    fi
1068elif test "$enable_cxx" = yes ; then
1069    AC_MSG_CHECKING([that we can build MPI programs with C++])
1070    AC_LANG_PUSH([C++])
1071    AC_LINK_IFELSE([
1072        AC_LANG_PROGRAM([
1073#include "mpi.h"
1074        ],[
1075    MPI::Init();
1076    MPI::Finalize();
1077        ])
1078    ],[
1079        AC_MSG_RESULT(yes)
1080        otherlangs="$otherlangs cxx"
1081        cxxdir=cxx
1082    ],[
1083        AC_MSG_RESULT(no)
1084    ])
1085    AC_LANG_POP([C++])
1086fi
1087if test "$enable_cxx" = yes ; then
1088    AC_CACHE_CHECK([whether <iostream> available],pac_cv_cxx_has_iostream,[
1089    AC_LANG_PUSH([C++])
1090    AC_COMPILE_IFELSE([
1091        AC_LANG_PROGRAM([#include <iostream>],[using namespace std;])
1092    ],[pac_cv_cxx_has_iostream=yes],[pac_cv_cxx_has_iostream=no])
1093    ])
1094
1095    if test "$pac_cv_cxx_has_iostream" = yes ; then
1096        AC_DEFINE(HAVE_IOSTREAM,1,[Define if iostream is available])
1097    else
1098        # Look for iostream.h (in C++ mode, we need the full name)
1099        AC_CHECK_HEADERS(iostream.h)
1100        if test "$ac_cv_header_iostream_h" != yes ; then
1101            AC_MSG_ERROR([C++ compiler $CXX $CXXFLAGS has neither iostream nor iostream.h.])
1102        fi
1103        # Warning: the autoconf macros will fall back onto /lib/cpp for
1104        # C and C++ preprocessing *without* checking that /lib/cpp even
1105        # exists.
1106        if test "$CXXCPP" = "/lib/cpp" ; then
1107            if test ! -x "/lib/cpp" ; then
1108                AC_MSG_WARN([Warning: Autoconf error, could not find a C++ Preprocessor.  Using false for the preprocessor so that tests will continue.])
1109                CXXCPP=false
1110            fi
1111        fi
1112    fi
1113
1114    AX_CXX_NAMESPACE_STD
1115
1116    if test "$ac_cv_cxx_namespaces" != yes ; then
1117        AC_MSG_WARN([The compiler $CXX does not support C++ namespaces.  This may cause problems for the tests])
1118    fi
1119    AC_LANG_POP([C++])
1120fi
1121AM_CONDITIONAL([BUILD_CXX_TESTS],[test "X$cxxdir" = "cxx"])
1122
1123AC_LANG_C
1124# IO
1125iodir="#"
1126if test "$enable_romio" != no ; then
1127    iodir=io
1128    AC_DEFINE(HAVE_MPI_IO,1,[Define if MPI-IO (really ROMIO) is included])
1129    if test "$FROM_MPICH2" = yes ; then
1130        # MPICH2 no longer uses and MPIO_Request
1131        pac_cv_have_mpio_request=no
1132    else
1133        AC_CACHE_CHECK([whether MPIO_Request is defined for MPI IO],
1134        pac_cv_have_mpio_request,[
1135            AC_COMPILE_IFELSE([
1136                AC_LANG_PROGRAM([#include "mpi.h"],[MPIO_Request r;])
1137            ],[pac_cv_have_mpio_request=yes],[pac_cv_have_mpio_request=no])
1138        ])
1139    fi
1140    if test "$pac_cv_have_mpio_request" = no ; then
1141        AC_DEFINE(MPIO_USES_MPI_REQUEST,,[Define if MPI IO uses MPI_Request])
1142    fi
1143fi
1144AC_SUBST(iodir)
1145
1146#
1147# MPI_INTEGER16 is mentioned in only one place in MPI 2.1, and some
1148# implementations may have missed it.  Check to see if it is available in
1149# C.
1150if test "$FROM_MPICH2" = yes ; then
1151   # MPICH2 correctly includes this type.
1152   pac_cv_have_mpi_integer16=yes
1153else
1154    AC_CACHE_CHECK([whether MPI_INTEGER16 is available],
1155    pac_cv_have_mpi_integer16,[
1156        AC_COMPILE_IFELSE([
1157            AC_LANG_PROGRAM([#include "mpi.h"],[
1158                MPI_Datatype t = MPI_INTEGER16;
1159            ])
1160        ],[pac_cv_have_mpi_integer16=yes],[pac_cv_have_mpi_integer16=no])
1161    ])
1162fi
1163if test "$pac_cv_have_mpi_integer16" = yes ; then
1164    AC_DEFINE(HAVE_MPI_INTEGER16,1,[Define if MPI_INTEGER16 is available])
1165fi
1166AC_CACHE_CHECK([whether MPI_2DOUBLE_COMPLEX is available],
1167pac_cv_have_mpi_2double_complex,[
1168    AC_COMPILE_IFELSE([
1169        AC_LANG_PROGRAM([#include "mpi.h"],[
1170            MPI_Datatype t = MPI_2DOUBLE_COMPLEX;
1171        ])
1172    ],[
1173        pac_cv_have_mpi_2double_complex=yes
1174    ],[
1175        pac_cv_have_mpi_2double_complex=no
1176    ])
1177])
1178if test "$pac_cv_have_mpi_2double_complex" = yes ; then
1179    AC_DEFINE(HAVE_MPI_2DOUBLE_COMPLEX,1,[Define if MPI_2DOUBLE_COMPLEX is available])
1180fi
1181# 2COMPLEX was in MPI 1.0 and removed after that.  This allows us to
1182# test 2COMPLEX if it is present
1183AC_CACHE_CHECK([whether MPI_2COMPLEX is available],
1184pac_cv_have_mpi_2complex,[
1185    AC_COMPILE_IFELSE([
1186        AC_LANG_PROGRAM([#include "mpi.h"],[
1187            MPI_Datatype t = MPI_2COMPLEX;
1188        ])
1189    ],[
1190        pac_cv_have_mpi_2complex=yes
1191    ],[
1192        pac_cv_have_mpi_2complex=no
1193    ])
1194])
1195if test "$pac_cv_have_mpi_2complex" = yes ; then
1196    AC_DEFINE(HAVE_MPI_2COMPLEX,1,[Define if MPI_2COMPLEX is available])
1197fi
1198
1199# MPI_Aint was intended as an address-sized int.  However, MPI didn't
1200# specify this - MPI_Aint must be large enough to hold an address-sized
1201# integer, but it can be larger.  To get clean compilation in some places,
1202# we need a pointer-sized integer.  The following code looks for one.
1203
1204# Make sure we are using the local C compiler (if the local
1205# machine is different that the system that MPICC is for, then
1206# set the cross-compilation feature)
1207AC_CHECK_SIZEOF(void *)
1208AC_CHECK_SIZEOF(int)
1209AC_CHECK_SIZEOF(long)
1210AC_CHECK_SIZEOF(long long)
1211AC_CHECK_SIZEOF(short)
1212POINTERINT=MPI_Aint
1213AC_MSG_CHECKING([for C integer type of address size])
1214for type in int long long_long short ; do
1215    eval len=\$ac_cv_sizeof_$type
1216    if test "$len" = "$ac_cv_sizeof_void_p" ; then
1217        POINTERINT=`echo $type | sed -e 's/_/ /'`
1218        break
1219    fi
1220done
1221AC_MSG_RESULT($POINTERINT)
1222AC_DEFINE_UNQUOTED(POINTERINT_t,$POINTERINT,[POINTERINT_t is a pointer-sized integer])
1223
1224# Find perl; used to create some of the tests from template and
1225# defintion files
1226AC_PATH_PROG(PERL,perl)
1227AC_SUBST(PERL)
1228AC_SUBST(otherlangs)
1229AC_SUBST(threadsdir)
1230AC_SUBST(MPIEXEC)
1231AC_SUBST(MAKE)
1232if test -z "$MPILIBNAME" ; then MPILIBNAME=mpich ; fi
1233AC_SUBST(MPILIBNAME)
1234dnl MPI_SOURCE may be set as an environment variable giving the location
1235dnl of the MPI implementation.  This is used only in runtests to include
1236dnl the location of the source of the MPI implementation into the XML
1237dnl summary file
1238AC_SUBST(MPI_SOURCE)
1239
1240if test "$FROM_MPICH2" = yes ; then
1241    # Set compilers/flags to be substituted in output files, e.g. Makefiles.
1242    LDFLAGS="$saveLDFLAGS"
1243    # note that the default definition of bindir is
1244    #    '${exec_prefix}/bin'
1245    # so even if prefix is set, exec prefix is not until
1246    # the very last moment (i.e., not here).
1247    if test "X$exec_prefix" = "XNONE" ; then
1248        saveExec_prefix=$exec_prefix
1249        if test "X$prefix" = "XNONE" ; then
1250            # Use the default
1251            exec_prefix=$ac_default_prefix
1252        else
1253            exec_prefix=$prefix
1254        fi
1255        # Evaluate with the current setting of exec_prefix
1256        eval mpibindir=${bindir}
1257        exec_prefix=$saveExec_prefix
1258    else
1259        eval mpibindir=${bindir}
1260    fi
1261
1262    # we did our tests with the base compilers, now point the make system at the
1263    # installed compiler wrappers for actually building the tests
1264    CC=$mpibindir/mpicc
1265    F77=$mpibindir/mpif77
1266    FC=$mpibindir/mpif90
1267    CXX=$mpibindir/mpicxx
1268    MPIEXEC=$mpibindir/mpiexec
1269
1270    # Zero out the flags, since they are already contained in the compiler
1271    # wrapper scripts.  Note that this will kill any flags that have been added
1272    # to the xFLAGS only in this script.
1273    #
1274    # The only real flags we seem to add in this script relate to cray
1275    # pointer support in Fortran, so we include that var here where
1276    # appropriate.
1277    #
1278    # The other case are the performance tests - for datatype performance,
1279    # compiling with optimization is important.
1280    CFLAGS=""
1281    CPPFLAGS=""
1282    LDFLAGS=""
1283    LIBS=""
1284    FFLAGS="$CRAYPTR_FFLAGS"
1285    FCFLAGS="$CRAYPTR_FCFLAGS"
1286    CXXFLAGS=""
1287else
1288    # We need either mpiexec or mpirun.  If we don't find them,
1289    # the user will need to determine how to run a program
1290    AC_PATH_PROG(MPIEXEC,mpiexec)
1291fi
1292
1293AC_OUTPUT_COMMANDS([chmod a+x maint/testmerge])
1294AC_OUTPUT_COMMANDS([chmod a+x runtests checktests])
1295AC_OUTPUT_COMMANDS([chmod a+x manual/manyconnect])
1296dnl Note that this format for AC_OUTPUT can cause problems for autoconf
1297dnl run under cygwin
1298AC_OUTPUT(maint/testmerge \
1299          runtests \
1300          checktests \
1301          Makefile \
1302          basic/Makefile \
1303          attr/Makefile \
1304          util/Makefile \
1305          coll/Makefile \
1306          comm/Makefile \
1307          datatype/Makefile \
1308          errhan/Makefile \
1309          group/Makefile \
1310          info/Makefile \
1311          init/Makefile \
1312          pt2pt/Makefile \
1313          rma/Makefile \
1314          spawn/Makefile \
1315          topo/Makefile \
1316          io/Makefile \
1317          f77/Makefile \
1318          f77/attr/Makefile \
1319          f77/attr/attraints.h \
1320          f77/pt2pt/attr1aints.h \
1321          f77/ext/add1size.h \
1322          f77/datatype/Makefile \
1323          f77/datatype/typeaints.h \
1324          f77/util/Makefile \
1325          f77/coll/Makefile \
1326          f77/comm/Makefile \
1327          f77/topo/Makefile \
1328          f77/init/Makefile \
1329          f77/rma/addsize.h \
1330          f77/pt2pt/Makefile \
1331          f77/info/Makefile \
1332          f77/spawn/Makefile \
1333	  f77/spawn/testlist \
1334          f77/spawn/type1aint.h \
1335          f77/rma/Makefile \
1336          f77/ext/Makefile \
1337          f77/ext/testlist \
1338          f77/io/Makefile \
1339          f77/io/iooffset.h \
1340          f77/io/iodisp.h \
1341          f77/io/ioaint.h \
1342          f90/Makefile \
1343          f90/attr/Makefile \
1344          f90/datatype/Makefile \
1345          f90/f90types/Makefile \
1346          f90/util/Makefile \
1347          f90/coll/Makefile \
1348          f90/comm/Makefile \
1349          f90/topo/Makefile \
1350          f90/init/Makefile \
1351          f90/pt2pt/Makefile \
1352          f90/rma/Makefile \
1353          f90/info/Makefile \
1354          f90/spawn/Makefile \
1355	  f90/spawn/testlist \
1356          f90/timer/Makefile \
1357          f90/ext/Makefile \
1358          f90/ext/testlist \
1359          f90/io/Makefile \
1360          f90/misc/Makefile \
1361          cxx/Makefile \
1362          cxx/util/Makefile \
1363          cxx/attr/Makefile \
1364          cxx/pt2pt/Makefile \
1365          cxx/comm/Makefile \
1366          cxx/coll/Makefile \
1367	  cxx/errhan/Makefile \
1368          cxx/info/Makefile \
1369          cxx/datatype/Makefile \
1370          cxx/io/Makefile \
1371          cxx/init/Makefile \
1372          cxx/rma/Makefile \
1373          cxx/spawn/Makefile \
1374          threads/Makefile \
1375          threads/pt2pt/Makefile \
1376          threads/util/Makefile \
1377          threads/comm/Makefile \
1378          threads/init/Makefile \
1379          threads/spawn/Makefile \
1380          errors/Makefile \
1381          errors/attr/Makefile \
1382          errors/basic/Makefile \
1383          errors/coll/Makefile \
1384          errors/comm/Makefile \
1385          errors/datatype/Makefile \
1386          errors/faults/Makefile \
1387          errors/group/Makefile \
1388          errors/pt2pt/Makefile \
1389          errors/rma/Makefile \
1390          errors/spawn/Makefile \
1391          errors/topo/Makefile \
1392          errors/io/Makefile \
1393          errors/cxx/Makefile \
1394          errors/cxx/errhan/Makefile \
1395          errors/cxx/io/Makefile \
1396          errors/f77/Makefile \
1397          errors/f90/Makefile \
1398          manual/Makefile \
1399          manual/manyconnect \
1400          perf/Makefile \
1401          testlist \
1402          cxx/testlist \
1403          f77/testlist \
1404          f90/testlist \
1405          threads/testlist \
1406          errors/testlist \
1407          errors/cxx/testlist \
1408          )
1409
1410