configure.in 234 KB
Newer Older
1
AC_PREREQ(2.63)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 
# (C) 2006 by Argonne National Laboratory.
#     See COPYRIGHT in top-level directory.
#
dnl Process this file with autoconf to produce a configure script.
dnl
dnl aclocal_cache.m4, included by sowing/confdb/aclocal.m4, fixes 
dnl bugs in autoconf caching.
dnl
dnl This is a large configure script and it is important to keep it
dnl clearly organized.  In addition, this script must coordinate with 
dnl the other modules that can be used to construct MPICH2, such as
dnl the communication device and the process manager.  Each of these
dnl may have special features or limitations that other modules or
dnl this configure may need to take into account.  To handle this, there
dnl are xx major steps in this configure script:
dnl
dnl 1. Identify major modules and source any prerequisite scripts
dnl 2. Determine compiler characteristics 
dnl 3. Setup and configure the other modules
dnl 4. Determine MPI features and characteristics (such as datatype values)
dnl
dnl Each of these is described in more detail below.
dnl
dnl 1. Identify the modules (most are specified by 
dnl --with-<modulename>=instance,
dnl for example, --with-pm=mpd or --with-device=ch3:nemesis).
dnl For each module, source the file mpich2prereq if present (in the
dnl module's top-level directory).  This
dnl must be a bourne (sh) shell script; it can access any of the variables
dnl in the configure script.  In addition, there are a few variables that
dnl are defined and provided to allow the modules to communicate their 
dnl needs or limitations to the other modules.  These are:
dnl    MPID_MAX_THREAD_LEVEL - thread level supported by device.
dnl                            if unset, is MPI_THREAD_FUNNELED
dnl    MPID_NO_LONG_LONG     - if yes, the device does not support the 
dnl                            long long integer type
dnl    MPID_NO_LONG_DOUBLE   - if yes, the device does not support the
dnl                            long double type
dnl    MPID_PM_NAMESERVER    - if set, provides the name of the nameserver
dnl                            that the process manager supports.
dnl                            This name server will be used if the
dnl                            default name server is selected.
dnl    MPID_NO_PM            - If yes, the device does not require any
dnl                            PM implementation.  
dnl    MPID_NO_PMI           - If yes, the device does not require any 
dnl                            PMI implementation.
dnl    EXTRA_STATUS_DECL     - Any extra declarations that the device
dnl                            needs added to the definition of MPI_Status.
dnl    MPID_MAX_PROCESSOR_NAME - The maximum number of character in a processor
dnl                            name.  If not set, 128 will be used.
dnl    PMI_REQUIRES_READABLE_TOKENS - if yes, define the C-preprocessor
dnl                            value USE_HUMAN_READABLE_TOKENS, which is
dnl                            used in src/include/mpimem.h to define token
dnl                            separators used in src/util/mem/argstr.c
dnl    PM_REQUIRES_PMI       - if set, provides the name of the PMI 
dnl                            interface implementation.  If not set,
dnl                            the "simple" PMI implementation is used.
dnl                            A process manager that needs a particular
dnl                            process manager should check that this is
dnl                            not set to an incompatible value.
dnl    MPID_NO_SPAWN         - if yes, the device does not support the
dnl                            dynamic process routines (spawn, connect
dnl                            attach, join, plus port and publish 
dnl                            routines).  The major effect of this
dnl                            is to let the test codes know that
dnl                            spawn is not implemented.
dnl    MPID_NO_RMA           - if yes, the device does not support the
dnl                            MPI RMA routines (MPI_Win_create and 
dnl                            MPI_Put etc.).  The major effect of this
dnl                            is to let the test codes know that 
dnl                            RMA is not implemented.
dnl
dnl Note that the meanings of these variables are defined so that an 
dnl undefined value gives the default.  This makes it easy to expand
dnl the set of such variables, since only modules that need the new
dnl variable will need to be changed.
dnl
dnl 2. Determine compiler characteristics
dnl Here is where features of the compilers are determined, including
dnl support for shared libraries and sizes of the basic datatype types.
dnl
dnl 3. Setup and configure the other modules
dnl Before each module configure is executed, the script setup_<module>
dnl is run if present.  This is a bourne (sh) shell script and may
dnl access configure variables.  It should not make any changes to the
dnl compiler name or flags (e.g., do not add -D_XOPEN_SOURCE to CFLAGS here,
dnl because that may invalidate the determination of the compiler 
dnl characteristics in the prior step).
dnl
dnl 4. Determine MPI features
dnl    
dnl
dnl Special environment variables
dnl To let other scripts and in particular the configure in test/mpi
dnl know that they are being invoked from within the MPICH2 configure,
dnl the following environment variables are set and exported:
dnl    FROM_MPICH2
dnl    MPICH2_ENABLE_F77
101
dnl    MPICH2_ENABLE_FC
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
dnl    MPICH2_ENABLE_CXX
dnl
dnl The file name here refers to a file in the source being configured
dnl In later versions of autoconf, the binding of AC_INIT changed (!!!)
dnl The original version was AC_INIT(a source file)
dnl The later version is AC_INIT(package,version,[bug-report],[tarname])
dnl Here we use the original version
dnl AC_INIT(src/include/mpiimpl.h)
dnl
dnl Note that no executable statements are allowed (and any are silently 
dnl dropped) before AC_INIT.
dnl
dnl AC_INIT requires an explicit version number
dnl Args are package name, version, bug report, and tar file name
dnl All must be literals
dnl Note that AC_PACKAGE_STRING is not a command but must be defined(!)
dnl Unfortunately, setting the PACKAGE names is not compatible with
dnl AC_CONFIG_SUBDIRS, since the resulting values in the generated
dnl conf file will not be consistent.
dnl define([AC_PACKAGE_STRING],[MPICH2 1.0.6])
dnl AC_INIT(mpich2,1.0.6,mpich2-maint@mcs.anl.gov,mpich2-1.0.6)
dnl Use the oldstyle AC_INIT instead
124

125
AC_INIT(src/include/mpichconf.h.in)
126

127
128
129
CONFIGURE_ARGS_CLEAN=`echo $* | tr '"' ' '`
AC_SUBST(CONFIGURE_ARGS_CLEAN)

130
# Try to find the version and release date
131
if test -s "$srcdir/maint/Version" ; then
132
    . $srcdir/maint/Version
133
    export MPICH2_VERSION
134
135
136
else
    AC_MSG_ERROR([Version information not found. Configuration aborted.])
fi
137
AC_SUBST(MPICH2_RELEASE_DATE)
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

# Produce a numeric version assuming the following format:
# Version: [MAJ].[MIN].[REV][EXT][EXT_NUMBER]
# Example: 1.0.7rc1 has
#          MAJ = 1
#          MIN = 0
#          REV = 7
#          EXT = rc
#          EXT_NUMBER = 1
#
# Converting to numeric version will convert EXT to a format number:
#          ALPHA (a) = 0
#          BETA (b)  = 1
#          RC (rc)   = 2
#          PATCH (p) = 3
# Regular releases are treated as patch 0
#
# Numeric version will have 1 digit for MAJ, 2 digits for MIN,
156
# 2 digits for REV, 1 digit for EXT and 2 digits for EXT_NUMBER.
157
changequote(<<,>>)
158
159
160
161
162
V1=`expr $MPICH2_VERSION : '\([0-9]*\)\.[0-9]*\.*[0-9]*[a-zA-Z]*[0-9]*'`
V2=`expr $MPICH2_VERSION : '[0-9]*\.\([0-9]*\)\.*[0-9]*[a-zA-Z]*[0-9]*'`
V3=`expr $MPICH2_VERSION : '[0-9]*\.[0-9]*\.*\([0-9]*\)[a-zA-Z]*[0-9]*'`
V4=`expr $MPICH2_VERSION : '[0-9]*\.[0-9]*\.*[0-9]*\([a-zA-Z]*\)[0-9]*'`
V5=`expr $MPICH2_VERSION : '[0-9]*\.[0-9]*\.*[0-9]*[a-zA-Z]*\([0-9]*\)'`
163
changequote([,])
164

165
if test "$V2" -le 9 ; then V2=0$V2 ; fi
166
if test "$V3" = "" ; then V3=0; fi
167
if test "$V3" -le 9 ; then V3=0$V3 ; fi
168
169
170
171
172
173
174
175
176
177
178
179
if test "$V4" = "a" ; then
    V4=0
elif test "$V4" = "b" ; then
    V4=1
elif test "$V4" = "rc" ; then
    V4=2
elif test "$V4" = "" ; then
    V4=3
    V5=0
elif test "$V4" = "p" ; then
    V4=3
fi
180
if test "$V5" -le 9 ; then V5=0$V5 ; fi
181

182
183
184
MPICH2_NUMVERSION=`expr $V1$V2$V3$V4$V5 + 0`
AC_SUBST(MPICH2_NUMVERSION)
AC_SUBST(MPICH2_VERSION)
185

186
187
188
189
190
# ABIVERSION is the name used by simplemake, so we reassign the
# libmpich_so_version number to it
ABIVERSION=${libmpich_so_version}
export ABIVERSION
export libmpich_so_version
191
AC_SUBST(ABIVERSION)
192

193
# Print out the configure options
194
195
196
CONFIGURE_ARGUMENTS="$ac_configure_args"
AC_SUBST(CONFIGURE_ARGUMENTS)
if test -n "$ac_configure_args" ; then
197
    echo "Configuring MPICH2 version $MPICH2_VERSION with $ac_configure_args"
198
else 
199
    echo "Configuring MPICH2 version $MPICH2_VERSION"
200
fi
201

202
203
# Add the information on the system:
echo "Running on system: `uname -a`"
204

205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
dnl Definitions will be placed in this file rather than in the DEFS variable
AC_CONFIG_HEADER(src/include/mpichconf.h)
AH_TOP([/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*  
 *  (C) 2001 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */
#ifndef MPICHCONF_H_INCLUDED
#define MPICHCONF_H_INCLUDED
])
AH_BOTTOM([#endif])

dnl Set the directory that contains support scripts such as install-sh and
dnl config.guess
AC_CONFIG_AUX_DIR(confdb)
220
221
222
223
224

# Set the FROM_MPICH2 variable to tell subconfigures that they are
# built from within MPICH2
FROM_MPICH2=yes
export FROM_MPICH2
225
226
227
AC_ARG_VAR(FROM_MPICH2,
	AC_HELP_STRING[internally set flag to tell subconfigures that
	they are built from within MPICH2])
228

229
230
231
# Save a copy of precious flags as USER_* before any of these flags
# are being modified by configure tests.
PAC_PREFIX_ALL_FLAGS(USER)
232
233

# WRAPPER_xFLAGS are used by mpicc and friends.
234
235
236
237
238
239
240
241
242
#
# WRAPPER_CFLAGS and other compile flags are used for compile options
# that are added by MPICH2, but should be used by applications (such
# as include paths).
#
# All libraries that are detected by MPICH2 as needed for some of its
# functionality (such as -lpthread) should be added to LIBS so
# autoconf link tests can use them. Libraries that are built by MPICH2
# at make time (and hence are not available for autoconf link tests to
243
# use), such as OPA and MPL, should be added to WRAPPER_LIBS for
244
245
246
# static builds. All libraries in LIBS are added to WRAPPER_LIBS
# (similarly LDFLAGS are added to WRAPPER_LDFLAGS) as well, at the end
# of configure.
247
PAC_PREFIX_ALL_FLAGS(WRAPPER)
248
WRAPPER_CFLAGS="$CFLAGS $MPICH2_MPICC_FLAGS"
249
WRAPPER_CPPFLAGS="$CPPFLAGS $MPICH2_MPICPP_FLAGS"
250
251
WRAPPER_CXXFLAGS="$CXXFLAGS $MPICH2_MPICXX_FLAGS"
WRAPPER_FFLAGS="$FFLAGS $MPICH2_MPIF77_FLAGS"
252
WRAPPER_FCFLAGS="$FCFLAGS $MPICH2_MPIFC_FLAGS"
253
WRAPPER_LDFLAGS="$MPICH2_LDFLAGS"
254
WRAPPER_LIBS="$MPICH2_LIBS"
255
256

# Add MPICH2LIB_* to the appropriate flags
257
258
259
260
261
262
263
264
265
266
267
268
269
270
AC_ARG_VAR(MPICH2LIB_CFLAGS,
	AC_HELP_STRING[extra CFLAGS used in building MPICH2 libraries])
AC_ARG_VAR(MPICH2LIB_CPPFLAGS,
	AC_HELP_STRING[extra CPPFLAGS used in building MPICH2 libraries])
AC_ARG_VAR(MPICH2LIB_CXXFLAGS,
	AC_HELP_STRING[extra CXXFLAGS used in building MPICH2 libraries])
AC_ARG_VAR(MPICH2LIB_FFLAGS,
	AC_HELP_STRING[extra FFLAGS used in building MPICH2 libraries])
AC_ARG_VAR(MPICH2LIB_FCFLAGS,
	AC_HELP_STRING[extra FCFLAGS used in building MPICH2 libraries])
AC_ARG_VAR(MPICH2LIB_LDFLAGS,
	AC_HELP_STRING[extra LDFLAGS used in building MPICH2 libraries])
AC_ARG_VAR(MPICH2LIB_LIBS,
	AC_HELP_STRING[extra LIBS used in building MPICH2 libraries])
271
CFLAGS="$CFLAGS $MPICH2LIB_CFLAGS"
272
CPPFLAGS="$CPPFLAGS $MPICH2LIB_CPPFLAGS"
273
274
CXXFLAGS="$CXXFLAGS $MPICH2LIB_CXXFLAGS"
FFLAGS="$FFLAGS $MPICH2LIB_FFLAGS"
275
FCFLAGS="$FCFLAGS $MPICH2LIB_FCFLAGS"
276
LDFLAGS="$LDFLAGS $MPICH2LIB_LDFLAGS"
277
LIBS="$LIBS $MPICH2LIB_LIBS"
278

279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301

# Find a C compiler.
# We also need to do this before the F77 and FC test to ensure that we
# find the C preprocessor reliably.
PAC_PUSH_FLAG([CFLAGS])
AC_PROG_CC
AC_PROG_CPP
# Bug in autoconf.  Restore cross settings
if test "$pac_cross_compiling" = "yes" -a "$ac_cv_prog_cc_cross" = "no" ; then
    AC_MSG_RESULT([Resetting cross compilation to yes])
    cross_compiling=yes
    ac_cv_prog_cc_cross=yes
    ac_cv_prog_f77_cross=yes
    ac_cv_prog_fc_cross=yes
    ac_cv_prog_cxx_cross=yes
fi
PAC_POP_FLAG([CFLAGS])

# compute canonical system types
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
# TARGET not needed, MPICH2 isn't a compiler

302
# Enable better caching control
303
PAC_ARG_CACHING
304
305
306
307
308

# Set CFLAGS for enable strict if necessary.  Do this *first* because
# it may influence the output of the other tests
PAC_ARG_STRICT

309
310
311
# Check for shared library support
PAC_ARG_SHAREDLIBS

312
AC_ARG_ENABLE(lib-depend,
313
314
	AC_HELP_STRING([--enable-lib-depend], [Turn on library dependencies (experimental)]),,
	[enable_lib_depend=no])
315

316
AC_ARG_ENABLE(echo, 
317
318
319
	AC_HELP_STRING([--enable-echo], [Turn on strong echoing. The default is enable=no.]),
	set -x)

320
AC_ARG_ENABLE(coverage,
321
322
323
	AC_HELP_STRING([--enable-coverage], [Turn on coverage analysis using gcc and gcov]),,
	enable_coverage=no)

324
AC_ARG_ENABLE(dynamiclibs,
325
326
327
	AC_HELP_STRING([--enable-dynamiclibs], [Enable the use of dynamic libraries
                       by the devices that support them]),,enable_dynamiclibs=no)

328
AC_ARG_ENABLE(error-checking,
329
330
331
332
333
334
335
336
[  --enable-error-checking=level
      Control the amount of error checking.  
        no        - no error checking
        runtime   - error checking controllable at runtime through environment 
                    variables
        all       - error checking always enabled
],,enable_error_checking=all)

337
AC_ARG_ENABLE(error-messages,
338
339
340
341
342
343
344
345
[  --enable-error-messages=level - Control the amount of detail in error messages.
        all       - Maximum amount of information
        generic   - Only generic messages (no information about the specific
                    instance)
        class     - One message per MPI error class
        none      - No messages
],,enable_error_messages=all)

346
AC_ARG_ENABLE(timing,
347
348
349
350
351
352
353
[  --enable-timing=level - Control the amount of timing information
                           collected by the MPICH implementation.
        none    - Collect no data (default)
        all     - Collect lots of data
        runtime - Runtime control of data collected
],,enable_timing=default)

354
AC_ARG_ENABLE(g,
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
[  --enable-g=option - Control the level of debugging support in the
                      MPICH implementation.  option is a list of comma
                      separated names including
        none     - No debugging
        handle   - Trace handle operations
        handlealloc - Trace handle allocations
        dbg      - Add compiler flag, -g, to all internal
                   compiler flags, i.e. MPICH2LIB_CFLAGS, MPICH2LIB_CXXFLAGS,
                   MPICH2LIB_FFLAGS, and MPICH2LIB_FCFLAGS.
        debug    - Synonym for dbg
        log      - Enable debug event logging
        mem      - Memory usage tracing
        meminit  - Preinitialize memory associated structures and unions to
                   eliminate access warnings from programs like valgrind
        memarena - Check for overwrite errors in memory allocation arena
        mutex    - Enable error checking on pthread mutexes
        mutexnesting - Check for non-nesting of mutexes
        all      - All of the above choices
],,enable_g=none)

375
376
377
dnl We may want to force MPI_Aint to be the same size as MPI_Offset, 
dnl particularly on 32 bit systems with large (64 bit) file systems.
AC_ARG_WITH(aint-size,
378
379
380
	AC_HELP_STRING([--with-aint-size], [Override the size of MPI_AINT (in bytes)]),,
	with_aint_size=0)

381
AC_ARG_ENABLE(fast,
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
[  --enable-fast=option - Control the level of fast execution in the
                         MPICH implementation.  option is a list of
                         comma separated names including
        defopt   - Default compiler optimization -O2 for all language bindings,
                   i.e. --enable-fast=O2, when neither --enable-fast
                   nor --disable-fast is specified. (default)
        O<n>     - Appends default optimization flags, -O<n>, to all internal
                   compiler flags, i.e. MPICH2LIB_CFLAGS, MPICH2LIB_CXXFLAGS,
                   MPICH2LIB_FFLAGS, and MPICH2LIB_FCFLAGS.
        nochkmsg - No error checking, i.e. --disable-error-checking
        notiming - No timing collection, i.e. --disable-timing.
        ndebug   - Appends -DNDEBUG to MPICH2LIB_CFLAGS.
        all|yes  - "defopt", "nochkmsg", "notiming" and "ndebug" are enabled
                   when --enable-fast is specified without any option.
        none     - None of above options, i.e. --disable-fast. Note that
                   --enable-strict will add the -O2 option even if
                   --enable-fast=none is given.
399
],,enable_fast=defopt)
400

401
AC_ARG_ENABLE(check-compiler-flags,
402
403
404
	AC_HELP_STRING([--enable-check-compiler-flags], [enable the checks for all compiler
                       options, xxxFLAGS, MPICH2_xxxFLAGS. Default is on.]),,
		       enable_check_compiler_flags=yes)
405

406
407
dnl We enable f77 and fc if we can find compilers for them.
dnl In addition, we check whether f77 and fc can work together.
408
AC_ARG_ENABLE(f77,
409
410
411
	AC_HELP_STRING([--enable-f77], [Enable Fortran 77 bindings]),,
	enable_f77=default;enable_f77_wasdefault=yes)

412
AC_ARG_ENABLE(fc,
413
414
	AC_HELP_STRING([--enable-fc], [Enable Fortran 90 bindings]),,enable_fc=default)

415
AC_ARG_ENABLE(cxx,
416
417
	AC_HELP_STRING([--enable-cxx], [Enable C++ bindings]),,enable_cxx=default)

418
AC_ARG_ENABLE(romio,
419
420
421
	AC_HELP_STRING([--enable-romio], [Enable ROMIO MPI I/O implementation]),,
	enable_romio=yes)

422
AC_ARG_ENABLE(debuginfo,
423
424
	AC_HELP_STRING([--enable-debuginfo], [Enable support for debuggers]),,
	enable_debuginfo=no)
425
426

AC_ARG_ENABLE(smpcoll,
427
428
429
	AC_HELP_STRING([--enable-smpcoll],
			[Enable support for SMP/multi-core aware collectives]),
	smpcoll=$enableval,smpcoll=yes)
430
431
432
433
if test $smpcoll = "yes" ; then
   AC_DEFINE(USE_SMP_COLLECTIVES,1,[define to enable SMP/multi-core aware collectives])
fi

434
435
436
dnl The environment variable MPICH_DEBUGLIBNAME may be used to
dnl override the default name of the library that the debugger will
dnl load to access the MPICH2 internal data structures.
437
AC_ARG_ENABLE(nmpi-as-mpi,
438
	AC_HELP_STRING([--enable-nmpi-as-mpi], [Use MPI rather than PMPI routines for MPI
439
                       routines, such as the collectives, that may be
440
441
                       implemented in terms of other MPI routines]),,
	enable_nmpi_as_mpi=no)
442

443
444
dnl "default" is a special device that allows MPICH to choose one
dnl based on the environment.
445
AC_ARG_WITH(device,
446
447
448
449
450
451
452
	AC_HELP_STRING([--with-device=name], [Specify the communication device for MPICH]),,
	with_device=default)

AC_ARG_WITH(pmi,
	AC_HELP_STRING([--with-pmi=name], [Specify the pmi interface for MPICH]),,
	with_pmi=default)

453
AC_ARG_WITH(pm, 
454
455
456
457
458
459
460
461
462
463
	AC_HELP_STRING([--with-pm=name],
		[Specify the process manager for MPICH.  "no" or "none" are
                 valid values.  Multiple process managers may be specified as
                 long as they all use the same pmi interface by separating them
                 with colons.  The mpiexec for the first named process manager
                 will be installed.  Example: "--with-pm=hydra:mpd:gforker"
                 builds the three process managers hydra, mpd and gforker;
                 only the mpiexec from hydra is installed into the bin
                 directory.]),,with_pm=default)

464
AC_ARG_WITH(logging,
465
466
467
	AC_HELP_STRING([--with-logging=name], [Specify the logging library for MPICH]),
	[if test -z "$withval" ; then with_logging=rlog ; fi],with_logging=none)

468
469
470
dnl both --without-mpe and --disable-mpe are supported
dnl AC_ARG_ENABLE(mpe) is used only when --with(out)-mpe is not used.
AC_ARG_WITH(mpe,
471
472
	AC_HELP_STRING([--with-mpe], [Build the MPE (MPI Parallel Environment) routines]),,
	with_mpe=default)
473
474
if test "$with_mpe" = "default" ; then
    AC_ARG_ENABLE(mpe,
475
476
	AC_HELP_STRING([--enable-mpe], [Build the MPE (MPI Parallel Environment) routines]),
	with_mpe=$enableval,with_mpe=default)
477
fi
478

479
AC_ARG_ENABLE(threads,
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
[  --enable-threads=level - Control the level of thread support in the 
                           MPICH implementation.  The following levels
                           are supported.
        default         - Choose thread level at runtime based on parameters 
                          passed to MPI_Init_thread (default)
        single          - No threads (MPI_THREAD_SINGLE)
        funneled        - Only the main thread calls MPI (MPI_THREAD_FUNNELED)
        serialized      - User serializes calls to MPI (MPI_THREAD_SERIALIZED)
        multiple        - Fully multi-threaded (MPI_THREAD_MULTIPLE). DO NOT
                          select this option. The default option is more
                          efficient and also supports thread_multiple.

        See also the --enable-thread-cs option for controlling the granularity of
        the concurrency inside of the library
],,enable_threads=default)
495

496
AC_ARG_ENABLE(thread-cs,
497
498
499
500
501
	AC_HELP_STRING([--enable-thread-cs=type],
			[Choose the method used for critical sections
                         and other atomic updates when multiple
                         threads are present.  Values may be global
                         (default), per-object, lock-free]),,enable_thread_cs=global)
502

503
AC_ARG_ENABLE(refcount,
504
505
506
507
508
509
510
511
512
513
514
515
	AC_HELP_STRING([--enable-refcount=type],
			[Choose the method for ensuring atomic updates
                         to the reference counts for MPI objects.
                         Values may be lock, lock-free, none.  The
                         default depends on the thread-cs choice; for
                         global it is none (because none is required),
                         for per-object it is lock, and for lock-free
                         it is lock-free]),,enable_refcount=default)

AC_ARG_ENABLE(mutex-timing,
	AC_HELP_STRING([--enable-mutex-timing], [calculate the time spent waiting on mutexes]),
	AC_DEFINE(MPIU_MUTEX_WAIT_TIME,1,[Define to enable timing mutexes]))
516

517
AC_ARG_ENABLE(handle-allocation,
518
519
520
521
522
	AC_HELP_STRING([--enable-handle-allocation=type],
			[Choose the method used for allocating MPI
			 object handles.  Values may be 'tls' for
			 thread-local storage or 'mutex' for simple
			 locking.  'mutex' is the default.]),,enable_handle_allocation=default)
523

524
AC_ARG_ENABLE([predefined-refcount],
525
526
527
528
	AS_HELP_STRING([--enable-predefined-refcount],
                       [control whether predefined objects like
		       MPI_COMM_WORLD are reference counted (default
		       depends on --enable-thread-cs choice)]),[],
529
530
              [enable_predefined_refcount=default])

531
AC_ARG_ENABLE(weak-symbols,
532
533
534
535
	AC_HELP_STRING([--enable-weak-symbols],
			[Use weak symbols to implement PMPI routines (default)]),,
		enable_weak_symbols=yes)

Anthony Chan's avatar
Anthony Chan committed
536
AC_ARG_ENABLE(multi-aliases,
537
538
539
540
	AC_HELP_STRING([--enable-multi-aliases],
		[Multiple aliasing to support multiple fortran compilers (default)]),,
		enable_multi_aliases=yes)

541
AC_ARG_WITH(cross,
542
543
544
545
	AC_HELP_STRING([--with-cross=file],
		[Specify the values of variables that configure cannot
                 determine in a cross-compilation environment]),,with_cross=no)

546
AC_ARG_WITH(namepublisher,
547
548
549
550
551
552
553
[  --with-namepublisher=name   Choose the system that will support 
                              MPI_PUBLISH_NAME and MPI_LOOKUP_NAME.  Options
                              include
                                   no (no service available)
                                   mpd
			           file[:directory] (optional directory)
                                   pmi],,with_namepublisher=default)
554
555
556

AC_SUBST(MPIFLIBNAME)
AC_SUBST(PMPIFLIBNAME)
557

558
559
dnl The default is a special wrapper library
AC_ARG_WITH(fwrapname,
560
561
562
	AC_HELP_STRING([--with-fwrapname=name],
		[Specify name of library containing Fortran interface routines]),
	[FWRAPNAME=$withval;set_FWRAPNAME="yes"],FWRAPNAME=fmpich)
563
AC_SUBST(FWRAPNAME)
564

565

566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
# -----------------------------------------------------------------------------
# First check that we have a clean build if we are doing a VPATH build
PAC_VPATH_CHECK(src/include/mpi.h src/env/mpicc src/env/mpicc.conf,lib)

# ----------------------------------------------------------------------------
# This test is complicated by the fact that top_srcdir is not set until
# the very end of configure.  Instead, we get it ourselves
if test -z "$top_srcdir" ; then
   use_top_srcdir=$srcdir   
else
   use_top_srcdir=$top_srcdir
fi
if test -z "$master_top_srcdir" ; then 
    # This needs to be an absolute pathname
    case "$use_top_srcdir" in
    /*) ;;
    *)
        use_top_srcdir=`(cd $use_top_srcdir && pwd)`
	;;	
    esac
    master_top_srcdir=$use_top_srcdir
fi
# Get the directory that we're running in...
if test -z "$master_top_builddir" ; then
   master_top_builddir="`pwd`"
fi
AC_SUBST(master_top_builddir)
AC_SUBST(master_top_srcdir)
export master_top_builddir
export master_top_srcdir
# ----------------------------------------------------------------------------
# We create this file to allow other configures to find the "master" 
# top builddir
rm -f .mpich2
date > .mpich2
# ----------------------------------------------------------------------------
# with-device
if test "$with_device" = "default" ; then
    # Pick the device.  For now, always choose ch3
    with_device=ch3
fi
# Extract the device name from any options
# Allow the device to specify a directory; if no directory, use the
# included directories
# 
DEVICE=$with_device
AC_SUBST(DEVICE)

device_name=`echo $with_device | sed -e 's/:.*$//'`
changequote(<<,>>)
device_args=`echo $with_device | sed -e 's/^[^:]*//' -e 's/^://'`
changequote([,])

devicedir=$use_top_srcdir/src/mpid/$device_name
devicereldir=src/mpid/$device_name
case "$device_name" in
     /*) 
     devicedir=$DEVICE
     # Get the name from the leaf
     device_name=`echo $device_name ~ sed -e 's%.*/%%'`
     # FIXME: should the devicereldir be different (perhaps not -
     # this allows use to build within our tree, even when other data
     # is outside of the tree)
     ;;
     *) 
     ;;
esac
export device_name
export device_args
export devicedir
# Make the device base name and args available to generated files
DEVICE_NAME=$device_name
AC_SUBST(DEVICE_NAME)
DEVICE_ARGS=$device_args
AC_SUBST(DEVICE_ARGS)
#
# Give the device an opportunity to include a header file in mpi.h.  The
# default value of INCLUDE_MPIDDEFS_H is set prior to the inclusion of the
# device's mpich2prereq script.  The device's script may override the value
# if needed.
INCLUDE_MPIDDEFS_H='/* ... no device specific definitions ... */'
AC_SUBST(INCLUDE_MPIDDEFS_H)

#
# See if the device wants to say something about the compilers (for example,
# the globus device may need to do this)
if test -f $devicedir/mpich2prereq ; then
    . $devicedir/mpich2prereq
fi

# ----------------------------------------------------------------------------
# Set default library names if names haven't already been provided
MPILIBNAME=${MPILIBNAME:-"mpich"}
PMPILIBNAME_set=no
if test -n "$PMPILIBNAME" ; then 
   PMPILIBNAME_set=yes
fi
PMPILIBNAME=${PMPILIBNAME:-"p$MPILIBNAME"}
# Note that the name for this library may be updated after we check for 
# enable_shmem
# Fortran names are set later.
# We use a different library for the C++ wrappers to avoid problems when
# creating shared libraries
if test -z "$MPICXXLIBNAME" ; then MPICXXLIBNAME="${MPILIBNAME}cxx" ; fi
export MPIFLIBNAME
export PMPIFLIBNAME
export MPICXXLIBNAME
AC_SUBST(MPICXXLIBNAME)

# We'll set FORTRAN_BINDING to 1 if we support Fortran 
FORTRAN_BINDING=0

678
679
680
681
# Set up default compiler optimization
MPI_DEFAULT_COPTS="-O2"
MPI_DEFAULT_CXXOPTS="-O2"
MPI_DEFAULT_FOPTS="-O2"
682
MPI_DEFAULT_FCOPTS="-O2"
683
684
685
686
687
688
689
690

# enable-fast
# strip off multiple options, separated by commas
save_IFS="$IFS"
IFS=","
for option in $enable_fast ; do
    case "$option" in
        defopt)
691
        enable_default_optimize=yes
692
        ;;
693
694
695
696
697
        nochkmsg)
        enable_fast_nochkmsg=yes
        ;;
        notiming)
        enable_timing=no
698
699
700
701
        ;;
        ndebug)
        enable_append_ndebug=yes
        ;;
702
703
704
705
706
707
708
#
# [BRT] removed the reseting of enable_g so that --with-enable=dbg,meminit
# can be specified with -enable-fast.  This change was largely made for the
# PETSc folks who want to use --enable-fast to eliminate parameter checking
# overhead, but also wish to use meminit to eliminate initialization
# warnings from valgrind.
#
709
        all|yes)
710
711
712
713
        enable_default_optimize=yes
        enable_fast_nochkmsg=yes
        # Disable timing/logging stuffs
        enable_timing=no
714
715
716
        enable_append_ndebug=yes
        ;;
        O*)
717
        # Allows O<n> where <n> can be [0-9] or ' '.
718
719
        opt_flags=`echo $option | sed -e 's%\(O[0-9] \)%\1%g'`
        if test -n "$opt_flags" ; then
720
            enable_default_optimize=yes
721
722
723
            MPI_DEFAULT_COPTS="-$option"
            MPI_DEFAULT_CXXOPTS="-$option"
            MPI_DEFAULT_FOPTS="-$option"
724
            MPI_DEFAULT_FCOPTS="-$option"
725
726
727
728
        else
            AC_MSG_WARN([Unknown value $option for --enable-fast])
        fi
        ;;
729
        none|no)
730
731
732
733
        enable_default_optimize=no
        enable_fast_nochkmsg=no
        # Reset timing/logging stuffs to when --enable-timing isn't specified.
        enable_timing=default
734
735
736
737
738
739
740
741
742
        enable_append_ndebug=no
        ;;
        *)
        AC_MSG_WARN([Unknown value $option for --enable-fast])
        ;;
    esac
done
IFS="$save_IFS"

743
744
745
# ----------------------------------------------------------------------------
# Process any enable or with values
# We must do enable-fast first, because it changes the other enable values
746
if test "$enable_fast_nochkmsg" = "yes" ; then
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
    enable_error_checking=no
    # Export a variable that will allow the test suite to detect that
    # MPICH has no error testing
    MPICH_FAST=yes
    export MPICH_FAST
fi

# error-checking
case "$enable_error_checking" in 
    no)
    # if error checking has been diabled, then automatically diable the error
    # checking tests in the test suite
    ac_configure_args="${ac_configure_args} --disable-checkerrors"
    ;;
    all|yes|runtime)
    error_checking_kind=`echo $enable_error_checking | \
    tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
    error_checking_kind=MPID_ERROR_LEVEL_$error_checking_kind
    AC_DEFINE_UNQUOTED(HAVE_ERROR_CHECKING,$error_checking_kind,[Define to enable error checking])
    ;;
    *)
    AC_MSG_WARN([Unknown value $enable_error_checking for enable-error-checking])
    ;;
esac

# error-messages
case "$enable_error_messages" in 
    no|none)
        error_message_kind="MPICH_ERROR_MSG_NONE"
    ;;
    all|yes)
	error_message_kind="MPICH_ERROR_MSG_ALL"
    ;;
    generic)
	error_message_kind="MPICH_ERROR_MSG_GENERIC"
    ;;
    class)
	error_message_kind="MPICH_ERROR_MSG_CLASS"
    ;;
    *)
    AC_MSG_WARN([Unknown value $enable_error_messages for enable-error-messages])
    ;;
esac
AC_DEFINE_UNQUOTED(MPICH_ERROR_MSG_LEVEL,$error_message_kind,[define to enable error messages])

792
# ----------------------------------------------------------------------------
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
#
# enable-timing and with-logging
#
# Still to do: add subsets: e.g., class=pt2pt,class=coll.  See mpich2 doc
#
# Logging and timing are intertwined.  If you select logging, you
# may also need to select a timing level.  If no timing is selected 
# but logging with rlog is selected, make "all" the default timing level.
#
# FIXME: make timing and logging options work more cleanly together,
# particularly when other logging options are selected (e.g., logging is not
# rlog).
# ----------------------------------------------------------------------------
collect_stats=false
logging_required=false
if test "$enable_timing" = "default" ; then
    if test "$with_logging" = "rlog" ; then
        enable_timing=all
    fi
fi
timing_name=$enable_timing
case "$enable_timing" in
    no)
    timing_name=none
    ;;
    time)
    collect_stats=true
    ;;
    log|log_detailed)
    logging_required=true
    ;;
    yes)
    timing_name=all
    collect_stats=true
    logging_required=true
    ;;
    all|runtime)
    collect_stats=true
    logging_required=true
    ;;
    none|default)
    timing_name=none
    ;;
    *)
    AC_MSG_WARN([Unknown value $enable_timing for enable-timing])
    enable_timing=no
    timing_name=none
    ;; 
esac
#
# The default logging package is rlog; you can get it by 
# specifying --with-logging or --with-logging=rlog
#
case $with_logging in 
    yes)
    logging_name=rlog
    ;;
    no|none)
    logging_name=none
    ;;
    default)
    if test "$logging_required" = "true" ; then
        logging_name=rlog
    else
        logging_name=none
    fi
    ;;
    *)
    logging_name=$with_logging
    ;;
esac
# 
# Include the selected logging subsystem
#
# Choices:
# 1) A subdir of src/util/logging
#     This directory must contain a configure which will be executed
#     to build the 
# 2) An external directory
#     This directory must contain 
#          a mpilogging.h file
#     It may contain 
#          a setup_logging script
#          a configure
#     
#   
logging_subsystems=
if test "$logging_name" != "none" ; then
    # Check for an external name (directory containing a /)
    hasSlash=`echo A$logging_name | sed -e 's%[[^/]]%%g'`
    if test -n "$hasSlash" ; then
        # Check that the external logging system is complete.
	# Any failure will cause configure to abort
        if test ! -d $logging_name ; then
	    AC_MSG_ERROR([External logging directory $logging_name not found.  Configure aborted])
	    logging_name=none
        elif test ! -s $logging_name/mpilogging.h ; then
	    AC_MSG_ERROR([External logging header $logging_name/mpilogging.h not found.  Configure aborted])
	    logging_name=none
        fi

        logdir=$logging_name
	# Force the logdir to be absolute
	logdir=`cd $logdir && pwd`
	# Switch name to "external" because that is how the MPICH2
	# code will know it
	logging_name=external
	# Add the dir to the include paths
	#CPPFLAGS="$CPPFLAGS -I$logdir"
902
	CPPFLAGS="$CPPFLAGS -I$logdir"
903
904
905
906
907
908
909
	EXTERNAL_SRC_DIRS="$EXTERNAL_SRC_DIRS $logdir"
	# Add to the list of external modules to setup
	if test -x $logdir/setup_logging ; then
	     EXTERNAL_SETUPS="$EXTERNAL_SETUPS $logdir/setup_logging"
	fi
    else
        logdir=$srcdir/src/util/logging
910
911
        logreldir=src/util/logging/$logging_name
        logging_subsystems="$logging_subsystems $logreldir"
912
913
914
915
916
917
918
919
920
921
922
923
        logging_subdirs=$logging_name
        for dir in $logging_subdirs ; do
            if test ! -d $logdir/$dir ; then
	        AC_MSG_ERROR([$logdir/$dir does not exist.  Configure aborted])
	        logging_name=none
            fi
        done
        for dir in $logging_subsystems ; do
            if test ! -x $srcdir/$dir/configure ; then
	        AC_MSG_ERROR([$logdir/$dir has no configure (required).  Configure aborted])
	        logging_name=none
            fi
924
            other_install_dirs="${other_install_dirs} $logreldir"
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
        done
    fi
fi
#
# FIXME: Logging doesn't necessarily require timing (e.g., simply logging the 
# sequence of routines).  
if test "$logging_name" != "none" ; then
    if test "$enable_timing" != "no" ; then
	if test "$enable_timing" = "default" -o "$enable_timing" = "none" ; then
	    enable_timing=log
	    timing_name=log
    	fi
	logging_dir=logging
	subsystems="$subsystems $logging_subsystems"
    else
	AC_MSG_WARN([Timing was disabled.  Logging has been disabled as well.])
	with_logging=no
	logging_name=none
        logging_dir=
        logging_subdirs=
    fi
else
    if test "$logging_required" = "true" ; then
	AC_MSG_WARN([Timing was enabled with log option but no logging library is available.  Timing has been disabled.])
	enable_timing=no
	timing_name=none
    fi
    logging_dir=
    logging_subdirs=
fi
if test "$timing_name" != "none" ; then
    timing_kind=`echo $timing_name | \
       tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
    timing_kind=MPID_TIMING_KIND_$timing_kind
    AC_DEFINE_UNQUOTED(HAVE_TIMING,$timing_kind,[define to enable timing collection])
    if test "$collect_stats" = "true" ; then
        AC_DEFINE(COLLECT_STATS,1,[define to enable collection of statistics])
    fi
fi
#
AC_SUBST(logging_dir)
AC_SUBST(logging_name)
AC_SUBST(logging_subdirs)
use_logging_variable="MPID_LOGGING_`echo $logging_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`"
AC_DEFINE_UNQUOTED(USE_LOGGING,$use_logging_variable,[define to choose logging library])
# ----------------------------------------------------------------------------
# End of logging tests
# ----------------------------------------------------------------------------

# ----------------------------------------------------------------------------
# Check to see if the device does not support spawn.  
# FIXME: This should provide the option of not building the dynamic
# process routines.  It could also allow us to specialize support
# for all processes are members of MPI_COMM_WORLD (only one comm_world).
# ----------------------------------------------------------------------------
if test "$MPID_NO_SPAWN" = yes ; then
    AC_MSG_WARN([The device $with_device does not support MPI dynamic process routines])   
fi

984
# MPL
985
PAC_CONFIG_SUBDIR(src/mpl,,AC_ERROR(MPL configure failed))
986
PAC_PREPEND_FLAG([-lmpl], [WRAPPER_LIBS])
987
988
PAC_APPEND_FLAG([-I${master_top_builddir}/src/mpl/include], [CPPFLAGS])
PAC_APPEND_FLAG([-I${use_top_srcdir}/src/mpl/include], [CPPFLAGS])
989
990
EXTERNAL_SRC_DIRS="$EXTERNAL_SRC_DIRS src/mpl"
other_install_dirs="$other_install_dirs src/mpl"
991

992
# OpenPA
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
AC_ARG_WITH([openpa-prefix],
            [AS_HELP_STRING([[--with-openpa-prefix[=DIR]]],
                            [use the OpenPA atomics library installed in DIR,
                             rather than the one included in src/openpa.  Pass
                             "embedded" to force usage of the OpenPA source
                             distributed with MPICH2.])],
            [],
            [# see if OPA is already installed on the system
             PAC_PUSH_FLAG([LIBS])
             PAC_PREPEND_FLAG([-lopa],[LIBS])
             AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
#include "opa_primitives.h"
],[
OPA_int_t i;
OPA_store_int(i,10);
OPA_fetch_and_incr_int(&i,5);
])dnl
                             ],
                            [with_openpa_prefix=system],[with_openpa_prefix=embedded])
             PAC_POP_FLAG([LIBS])
             ])
# @opadir@ is used in src/Makefile.sm to control whether or not the OPA in
# src/openpa is built and installed
opadir=""
AC_SUBST([opadir])

if test "$with_openpa_prefix" = "embedded" ; then
    if test -e "${use_top_srcdir}/src/openpa" ; then
        opadir="openpa"
        EXTERNAL_SRC_DIRS="$EXTERNAL_SRC_DIRS src/openpa"
        PAC_APPEND_FLAG([-I${use_top_srcdir}/src/openpa/src],[CPPFLAGS])
        PAC_APPEND_FLAG([-I${master_top_builddir}/src/openpa/src],[CPPFLAGS])

        # OPA defaults to "auto", but in MPICH2 we want "auto_allow_emulation" to
        # easily permit using channels like ch3:sock that don't care about atomics
        AC_ARG_WITH([atomic-primitives],
                    [AS_HELP_STRING([--with-atomic-primitives],
                                    [Force OPA to use a specific atomic primitives
                                     implementation.  See the src/openpa directory
                                     for more info.])],
                    [],[with_atomic_primitives=not_specified])
        opa_subdir_args=""
        if test "$with_atomic_primitives" = "not_specified" ; then
            opa_subdir_args="--with-atomic-primitives=auto_allow_emulation"
        fi
        PAC_CONFIG_SUBDIR_ARGS([src/openpa],[$opa_subdir_args],[],[AC_ERROR([OpenPA configure failed])])
        PAC_PREPEND_FLAG([-lopa],[WRAPPER_LIBS])

        other_install_dirs="$other_install_dirs src/openpa"
    else
        AC_MSG_WARN([Attempted to use the embedded OpenPA source tree in "src/openpa", but it is missing.  Configuration or compilation may fail later.])
1044
    fi
1045
elif test "$with_openpa_prefix" = "system" ; then
1046
    PAC_PREPEND_FLAG([-lopa],[WRAPPER_LIBS])
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
elif test "$with_openpa_prefix" = "no" ; then
    # The user doesn't want to use OPA.  This may or may not cause MPICH2 to
    # fail to configure/build, depending on many other factors.
    :
else
    # The user specified an already-installed OPA; just sanity check, don't
    # subconfigure it
    AS_IF([test -s "${with_openpa_prefix}/include/opa_primitives.h" -a -s "${with_openpa_prefix}/include/opa_config.h"],
          [:],[AC_MSG_ERROR([the OpenPA installation in "${with_openpa_prefix}" appears broken])])
    PAC_APPEND_FLAG([-I${with_openpa_prefix}/include],[CPPFLAGS])
    PAC_PREPEND_FLAG([-lopa],[WRAPPER_LIBS])
    if test -d ${with_openpa_prefix}/lib64 ; then
        PAC_APPEND_FLAG([-L${with_openpa_prefix}/lib64],[WRAPPER_LDFLAGS])
    fi
    PAC_APPEND_FLAG([-L${with_openpa_prefix}/lib],[WRAPPER_LDFLAGS])
1062
1063
fi

1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# ----------------------------------------------------------------------------
# Threads
# ----------------------------------------------------------------------------
#
# Threads must be supported by the device.  First, set the default to
# be the highest supported by the device
if test "$enable_threads" = default ; then
    if test -n "$MPID_MAX_THREAD_LEVEL" ; then
        case $MPID_MAX_THREAD_LEVEL in
            MPI_THREAD_SINGLE)     enable_threads=single ;;
            MPI_THREAD_FUNNELED)   enable_threads=funneled ;;
            MPI_THREAD_SERIALIZED) enable_threads=serialized ;;
            MPI_THREAD_MULTIPLE)   enable_threads=runtime ;;
            *) AC_MSG_ERROR([Unrecognized thread level from device $MPID_MAX_THREAD_LEVEL])
    	    ;;
        esac
    else
        enable_threads=single
    fi
fi

if test "$enable_threads" = "yes" ; then 
    enable_threads=multiple
elif test "$enable_threads" = "no" ; then
    enable_threads=single
elif test "$enable_threads" = "default"; then
    if test "$with_device" = "default" -o "$with_device" = "ch3:sock" ; then
        enable_threads=runtime
    fi
fi
# Runtime is an alias for multiple with an additional value
if test "$enable_threads" = "runtime" ; then
    AC_DEFINE(HAVE_RUNTIME_THREADCHECK,1,[Define if MPI supports MPI_THREAD_MULTIPLE with a runtime check for thread level])
    enable_threads=multiple
fi

MPICH_THREAD_LEVEL=MPI_THREAD_FUNNELED
case "$enable_threads" in 
    single)
    thread_pkg_required=no
    MPICH_THREAD_LEVEL=MPI_THREAD_SINGLE
    ;;
    funneled)
    thread_pkg_required=no
    MPICH_THREAD_LEVEL=MPI_THREAD_FUNNELED
    ;;
    serialized)
    # FIXME: Why does serialized require a thread package?
    thread_pkg_required=yes
    MPICH_THREAD_LEVEL=MPI_THREAD_SERIALIZED
    ;;
    multiple)
    thread_pkg_required=yes
    MPICH_THREAD_LEVEL=MPI_THREAD_MULTIPLE
    ;;
    *)
    AC_MSG_ERROR(["$enable_threads" is not a valid value for --enable-threads])     
    ;;
esac
# Check that the requested thread level is available.
threadLevelOK=yes
if test -z "$MPID_MAX_THREAD_LEVEL" ; then
    if test "$MPICH_THREAD_LEVEL" = "MPI_THREAD_MULTIPLE" -o "$MPICH_THREAD_LEVEL" = "MPI_THREAD_SERIALIZED" ; then
        threadLevelOK=no
    fi
else
    # Check that MPID_MAX_THREAD_LEVEL is at least as large as the
    # selected MPICH_THREAD_LEVEL
    case $MPICH_THREAD_LEVEL in 
        MPI_THREAD_MULTIPLE)
	if test "$MPID_MAX_THREAD_LEVEL" != "MPI_THREAD_MULTIPLE" ; then
	    threadLevelOK=no
        fi
	;;
	MPI_THREAD_SERIALIZED)
	if test "$MPID_MAX_THREAD_LEVEL" != "MPI_THREAD_MULTIPLE" -a \
	        "$MPID_MAX_THREAD_LEVEL" != "MPI_THREAD_SERIALIZED" ; then
            threadLevelOK=no
        fi
	;;
	MPI_THREAD_FUNNELED)
        if test "$MPID_MAX_THREAD_LEVEL" = "MPI_THREAD_SINGLE" ; then
            threadLevelOK=no
        fi
	;;
	MPI_THREAD_SINGLE)
	;;
    esac
fi
if test "$threadLevelOK" != yes ; then
   AC_MSG_ERROR([The device $with_device does not support $MPICH_THREAD_LEVEL])
fi

export MPICH_THREAD_LEVEL
AC_DEFINE_UNQUOTED(MPICH_THREAD_LEVEL,$MPICH_THREAD_LEVEL,[Level of thread support selected at compile time])

if test "$thread_pkg_required" = "no" ; then
1161
    MPIU_THREAD_DEFAULT=${MPIU_THREAD_DEFAULT:-none}
1162
fi
1163
export MPIU_THREAD_DEFAULT
1164

1165
# Check for value thread_cs choice; set the refcount default if necessary
1166
1167
thread_granularity=MPIU_THREAD_GRANULARITY_SINGLE
thread_refcount=MPIU_REFCOUNT_NONE
1168
1169
1170
1171
1172
1173
1174
if test "$enable_threads" = "multiple" ; then
    case $enable_thread_cs in 
    global)
    thread_granularity=MPIU_THREAD_GRANULARITY_GLOBAL
    if test "$enable_refcount" = "default" ; then enable_refcount=none ; fi
    ;;
    brief-global|brief_global)
1175
    AC_MSG_ERROR([--enable-thread-cs=brief-global is no longer supported, please select a different granularity])
1176
1177
1178
1179
1180
1181
1182
1183
    ;;
    per-object|per_object)
    thread_granularity=MPIU_THREAD_GRANULARITY_PER_OBJECT
    if test "$enable_refcount" = "default" ; then enable_refcount=lock ; fi
    ;;
    lock-free|lock_free|lockfree)
    thread_granularity=MPIU_THREAD_GRANULARITY_LOCK_FREE
    if test "$enable_refcount" = "default" ; then enable_refcount=lock-free ; fi
1184
    if test "$enable_predefined_refcount" = "default" ; then enable_predefined_refcount=no ; fi
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
    ;;
    *)
    AC_MSG_ERROR([Unrecognized value $enable_thread_cs for --enable-thread-cs])
    ;;
    esac

    case $enable_refcount in
    lock)
    thread_refcount=MPIU_REFCOUNT_LOCK
    ;;
    lock-free|lock_free|lockfree)
    thread_refcount=MPIU_REFCOUNT_LOCKFREE
    ;;
    none)
    thread_refcount=MPIU_REFCOUNT_NONE
    ;;
    *)
    AC_MSG_ERROR([Unrecognized value $enable_refcount for --enable-refcount])
    ;;
    esac
fi
AC_DEFINE_UNQUOTED([MPIU_THREAD_GRANULARITY],$thread_granularity,[Method used to implement atomic updates and access])

1208
1209
1210
1211
if test "$enable_predefined_refcount" = "no" ; then
    AC_DEFINE([MPIU_THREAD_SUPPRESS_PREDEFINED_REFCOUNTS],[1],[define to disable reference counting predefined objects like MPI_COMM_WORLD])
fi

1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
case $enable_handle_allocation in
    mutex|default)
        handle_allocation_method=MPIU_HANDLE_ALLOCATION_MUTEX
    ;;
    tls)
        handle_allocation_method=MPIU_HANDLE_ALLOCATION_THREAD_LOCAL
    ;;
    *)
        AC_MSG_ERROR([Unrecognized value $enable_handle_allocation for --enable-handle-allocation])
    ;;
esac
AC_DEFINE_UNQUOTED([MPIU_HANDLE_ALLOCATION_METHOD],$handle_allocation_method,[Method used to allocate MPI object handles])


AC_DEFINE_UNQUOTED([MPIU_THREAD_REFCOUNT],$thread_refcount,[Method used to implement refcount updates])

1228
1229
1230
1231
1232
1233
1234
# enable-g
# strip off multiple options, separated by commas
save_IFS="$IFS"
IFS=","
for option in $enable_g ; do
    case "$option" in 
        debug|dbg)
1235
        enable_append_g=yes
1236
1237
1238
	;;
        no|none)
	;;
1239
1240
1241
	handlealloc)
	perform_handlealloc=yes
	;;
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
	handle)
	AC_DEFINE(MPICH_DEBUG_HANDLES,1,[Define to enable handle checking])
	;;
	meminit)
	perform_meminit=yes
	;;
	memarena)
	perform_memarena=yes
	perform_memtracing=yes
	;;
	mem)
	perform_memtracing=yes
	;;
	log)
	perform_dbglog=yes
	;;
	mutex)
	perform_dbgmutex=yes
	;;
1261
1262
1263
	mutexnesting)
	perform_mutexnesting=yes
	;;
1264
1265
1266
	all|yes)
	perform_memtracing=yes
	perform_dbglog=yes
1267
	enable_append_g=yes
1268
1269
	perform_meminit=yes
	perform_dbgmutex=yes
1270
	perform_mutexnesting=yes
1271
	perform_handlealloc=yes
1272
1273
1274
1275
1276
1277
1278
	;;
	*)
	AC_MSG_WARN([Unknown value $enable_g for enable-g])
	;;
    esac
done
IFS="$save_IFS"
1279
1280
1281
1282
1283

if test "$enable_append_g" = "yes" ; then
    CFLAGS="$CFLAGS -g"
    CXXFLAGS="$CXXFLAGS -g"
    FFLAGS="$FFLAGS -g"
1284
    FCFLAGS="$FCFLAGS -g"
1285
1286
fi
if test "$enable_append_ndebug" = "yes" ; then
1287
1288
1289
1290
    CFLAGS="$CFLAGS -DNDEBUG -DNVALGRIND"
    CXXFLAGS="$CXXFLAGS -DNDEBUG -DNVALGRIND"
    FFLAGS="$FFLAGS -DNDEBUG -DNVALGRIND"
    FCFLAGS="$FCFLAGS -DNDEBUG -DNVALGRIND"
1291
fi
1292
1293
1294
if test -n "$perform_meminit" ; then
    AC_DEFINE(MPICH_DEBUG_MEMINIT,1,[Define to enable preinitialization of memory used by structures and unions])
fi
1295
1296
1297
1298
if test "$perform_handlealloc" = yes ; then
   AC_DEFINE(MPICH_DEBUG_HANDLEALLOC,1,[Define to enable checking of handles still allocated at MPI_Finalize])
fi

1299
1300
1301
1302
1303
1304
1305
if test -n "$perform_memtracing" ; then
    enable_g_mem=yes
    AC_DEFINE(USE_MEMORY_TRACING,1,[Define to enable memory tracing])
    if test -n "$perform_memarena" ; then
        AC_DEFINE(MPICH_DEBUG_MEMARENA,1,[Define if each function exit should confirm memory arena correctness])
    fi
fi
1306
1307
1308
if test -n "$perform_mutexnesting" ; then 
    AC_DEFINE(MPICH_DEBUG_MUTEXNESTING,1,[Define to check nesting in mutexes])
fi
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
if test -n "$perform_dbglog" ; then
   if test "$with_logging" != "none" ; then
       AC_MSG_WARN([--with-logging overrides --enable-g=log])
   else
       AC_DEFINE(USE_DBG_LOGGING,1,[Define to enable logging macros])
   fi
fi

if test -n "$perform_dbgmutex" ; then 
   AC_DEFINE(MPICH_DEBUG_MUTEX,1,[Define to enable mutex debugging])
fi

pac_cross_compiling=no
if test "$with_cross" != "no" ; then
    if test -s "$with_cross" ; then
        AC_MSG_RESULT([Reading values from cross-compilation file $with_cross])
        . $with_cross
	# Autoconf 2.52 no longer sets cross_compiling except with the
	# awkward "targethost" options.
	pac_cross_compiling=yes
	cross_compiling=yes
	ac_cv_prog_cc_cross=yes
	ac_cv_prog_f77_cross=yes
1332
 	ac_cv_prog_fc_cross=yes
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
        ac_cv_prog_cxx_cross=yes
        export cross_compiling
	# Export all cross variables.  Any subsidiary configure should also
        # export CROSS_xxx
	rm -f confcross
	(set) 2>&1 | grep CROSS_ | \
	      sed -e 's/^/export /g' -e 's/=.*//g' > confcross
	. confcross
	rm -f confcross      
    fi
fi

if test "$enable_nmpi_as_mpi" = yes ; then
   AC_DEFINE(USE_MPI_FOR_NMPI,1,[Define if the NMPI names should use MPI instead of PMPI])
fi

# This goes here because we need the top_srcdir
if test "$enable_romio" = "yes" ; then
   if test -d $use_top_srcdir/src/mpi/romio ; then
       subsystems="$subsystems src/mpi/romio"
       AC_DEFINE(HAVE_ROMIO,1,[Define if ROMIO is enabled])
       # Set environment variables that the romio configure expects
       romio_dir=romio
       AC_SUBST(romio_dir)
       export use_top_srcdir
       top_build_dir=`pwd`
       export top_build_dir
       # if there is no $top_build_dir/lib, romio puts lib in wrong place
       # This test used -e under Linux, but not all test programs understand
       # -e
       if test ! -d lib ; then mkdir lib ; fi
       # tell mpi.h to include mpio.h
       PAC_HAVE_ROMIO
   else
       AC_MSG_WARN([ROMIO src directory is not available])
   fi
fi
#
# FIXME: If an external device, don't necessarily complain (e.g.,
# if the device is already built)
if test ! -d $devicedir ; then
dnl     WAIT UNTIL WE INCLUDE A DEVICE
dnl     AC_MSG_ERROR([Device $device_name is unknown)]
    AC_MSG_WARN([Device $device_name is unknown])
elif test ! -x $devicedir/configure ; then
    if test -s $devicedir/configure ; then
        AC_MSG_WARN([The configure in $devicedir exists but is not executable])
    else
        AC_MSG_WARN([Device $device_name has no configure])
    fi
    device_name=""
else 
    # Add the device to the configure list
    devsubsystems="$devsubsystems $devicereldir"
    # Make device_name available to subdirs
fi
1389
1390
1391
1392
1393
1394
#
# Allow the device to request that the install step invoke the install 
# target in the device's Makefile.
if test -n "$device_name" -a "$INSTALL_FROM_DEVICE" = yes ; then
    other_install_dirs="${other_install_dirs} $devicereldir"
fi
1395
1396
1397
AC_SUBST(device_name)
#
# with-pm
1398
1399
1400
1401
if test "$with_pm" = "none" ; then
    # add "none" as synonym for "no" to agree with older erroneous docs
    with_pm="no"
fi
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
if test "$MPID_NO_PM" = yes ; then
    if test "$with_pm" != "default" -a "$with_pm" != no ; then
        AC_MSG_ERROR([The PM chosen ($with_pm) is is not valid for the selected device ($with_device)])
    fi
    # This is used to change with_pm=default to with_pm=no in the case
    # where the device does not want a PM
    with_pm=no
fi
if test -z "$with_pm" ; then
    with_pm="no"
fi
if test "$with_pmi" = "uni" -a "$with_pm" = "default" ; then
    with_pm="no"
fi
if test "$with_pm" = "default" -o "$with_pm" = "yes" ; then
1417
    with_pm=hydra
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
fi

# We allow multiple pm names, separated by : or ,
# If multiple PMs are provided, we set the value MANY_PM to yes
MANY_PM=no
AC_SUBST(MANY_PM)
if test "$with_pm" != "no" ; then
    pm_names="`echo $with_pm | sed -e 's/:/ /g' -e 's/,/ /g'`"
else
    pm_names=""
fi
#
hasError=no
# We need to be careful about PM's that have either conflicting 
# requirements (e.g., different PMI implementations) or different
# optional features (e.g., MPID_PM_NAMESERVER).
# In addition, we need to interleave the setup of the PMI and PM
# modules.  The order is as follows:
#
# For each PM, execute the mpich2prereq script for that pm (if present).  
# This script provides information about the PM, including which PMI
# implementations are supported.
# 
# Then, for the selected PMI, the setup script (if any) is run.  This is
# necessary because the setup of the PM may require information discovered
# or provided duing the PMI setup step (e.g., smpd requires this)
#
# Finally, for each PM, the setup script is executed.
# 
# Step 1: invoke the mpich2prereq for each PM
for pm_name in $pm_names ; do
    if test -z "$first_pm_name" ; then
       first_pm_name=$pm_name
    else 
       # Only add to other_pm_names if the directory exists,
       # since the Makefile in src/pm/Makefile will try to cd to
       # that directory
       if test -d $use_top_srcdir/src/pm/$pm_name ; then
           other_pm_names="$other_pm_names $pm_name"
       fi
    fi
    if test ! -d $use_top_srcdir/src/pm/$pm_name ; then
        AC_MSG_WARN([$use_top_srcdir/src/pm/$pm_name does not exist. PM is unknown])
	hasError=yes
    elif test ! -x $use_top_srcdir/src/pm/$pm_name/configure ; then
        if test -s $use_top_srcdir/src/pm/$pm_name/configure ; then
	    AC_MSG_WARN([The configure in $use_top_srcdir/src/pm/$pm_name exists but is not executable])
        else
            AC_MSG_WARN([pm $pm_name has no configure])
        fi
        pm_name=""
	hasError=yes
    else
	nameserver=$MPID_PM_NAMESERVER
        if test -f $use_top_srcdir/src/pm/$pm_name/mpich2prereq ; then 
	    echo sourcing $use_top_srcdir/src/pm/$pm_name/mpich2prereq
	    . $use_top_srcdir/src/pm/$pm_name/mpich2prereq
	fi
	# Check for a change; if found, we'll take the default
	if test "$MPID_PM_NAMESERVER" != "$nameserver" ; then
            if test "$first_pm_name" != "$pm_name" ; then
	        # Reject suggestion (use the default, common mode)
		MPID_PM_NAMESERVER=""
	    fi
	fi
    fi
done
if test "$hasError" != no ; then
    AC_MSG_ERROR([Aborting configure because an error was seen in the selection of process managers])
fi
#
# pm_name is the *primary* pm
pm_name=$first_pm_name
AC_SUBST(pm_name)
AC_SUBST(other_pm_names)

# Some versions of PM and PMI require a special definition (currently, only
# smpd requires this)
if test "$PMI_REQUIRES_READABLE_TOKENS" = "yes" ; then
    AC_DEFINE(USE_HUMAN_READABLE_TOKENS,1,[Define to use ='s and spaces in the string utilities.])
fi

if test -n "$first_pm_name" ; then
    other_install_dirs="${other_install_dirs} src/pm/$first_pm_name"
fi
# Step 2:
# Once we've selected the process manager (or managers), we can
# check that we have a compatible PMI implemenatation.
# with-pmi
if test "$MPID_NO_PMI" = yes ; then
    if test "$with_pmi" != "default" -a "$with_pmi" != no ; then
        AC_MSG_ERROR([The PMI chosen ($with_pmi) is is not valid for the selected device ($with_device)])
    fi
    # This is used to change with_pmi=default to with_pmi=no in the case
    # where the device does not want a PMI
    with_pmi=no
elif test "$with_pmi" != "no" ; then
    if test "$with_pmi" = "default" -o "$with_pmi" = "yes" ; then
        if test -n "$PM_REQUIRES_PMI" ; then
	    with_pmi=$PM_REQUIRES_PMI
        else
            with_pmi=simple
        fi
    elif test -n "$PM_REQUIRES_PMI" ; then
        # Test for compatibility between pm and pmi choices
        if test "$PM_REQUIRES_PMI" != "$with_pmi" ; then
	    AC_MSG_ERROR([The PM chosen ($with_pm) requires the PMI implementation $PM_REQUIRES_PMI but $with_pmi was selected as the PMI implementation.])
        fi
    fi
    pmi_name=$with_pmi
    
    if test ! -d $use_top_srcdir/src/pmi/$pmi_name ; then
        AC_MSG_WARN([$use_top_srcdir/src/pmi/$pmi_name does not exist. PMI is unknown])
    elif test ! -x $use_top_srcdir/src/pmi/$pmi_name/configure ; then
        AC_MSG_WARN([pmi $pmi_name has no configure or Makefile])
        pmi_name=""
    else
        subsystems="$subsystems src/pmi/$pmi_name"
    fi
else
    AC_MSG_ERROR([A PMI implementation must be selected or the default used.])
fi
AC_SUBST(pmi_name)

# Step 3: complete pm setup.
# Note that checks for errors have already been performed, so this
# loop does not need to perform any extra error checks.
# Note that this uses this_pm_name because pm_name must be the *first*
# of the PM names
for this_pm_name in $pm_names ; do
    subsystems="$subsystems src/pm/$this_pm_name"
    if test -f $use_top_srcdir/src/pm/$this_pm_name/setup_pm ; then 
	echo sourcing $use_top_srcdir/src/pm/$this_pm_name/setup_pm
	. $use_top_srcdir/src/pm/$this_pm_name/setup_pm
    fi
done

# ----------------------------------------------------------------------------
if test $with_mpe != no ; then
    if test ! -d $use_top_srcdir/src/mpe2 ; then
        if test $with_mpe = yes ; then
	    # No warning message on the default
            AC_MSG_WARN([No MPE directory available])
        fi
    elif test ! -x $use_top_srcdir/src/mpe2/configure ; then
        if test $with_mpe = yes ; then
	    # No warning message on the default
            AC_MSG_WARN([No configure available for MPE])
        fi
    else
        subsystems="$subsystems src/mpe2"
	other_install_dirs="$other_install_dirs src/mpe2"
	mpe_dir=mpe2
	# Temporarily replace the default NONE value for exec_prefix
	# and prefix with the actual, default values.
	savePrefix=$prefix
	saveExecprefix=$exec_prefix
	test "x$prefix" = xNONE && prefix=$ac_default_prefix
	test "x$exec_prefix" = xNONE && exec_prefix=$prefix
	eval actualbindir=$bindir
	# MPI_CC and MPIF77 must use the local (build) bin dir, not
	# the installation bin dir
	#MPI_CC=$actualbindir/mpicc
	#MPI_F77=$actualbindir/mpif77
	#eval actuallibdir=$libdir
	#MPI_LIBS="-L$actuallibdir -lmpich -lpmpich"
	buildbindir=`pwd`/bin
	MPI_CC=$buildbindir/mpicc
	MPI_F77=$buildbindir/mpif77
	prefix=$savePrefix
	exec_prefix=$saveExecprefix
	# NOTE: You must append LIBS to MPI_LIBS before invoking the mpe
	# configure
	export MPI_CC
	export MPI_F77
	#export MPI_LIBS
        export use_top_srcdir
        top_build_dir=`pwd`
        export top_build_dir
    fi
fi
AC_SUBST(mpe_dir)
AC_SUBST(other_install_dirs)

# Check whether shared libraries are enabled.  We need to know this
# before we start chosing the Fortran, Fortran 90, and C++ compilers
ENABLE_SHLIB=$enable_sharedlibs
if test -z "$ENABLE_SHLIB" -o "$ENABLE_SHLIB" = "no" ; then
    ENABLE_SHLIB=none
fi
# We need the script that is used to create shared libraries if either
# we are creating shared libraries for MPICH2 or we are creating the
# dynamically loadable library for the debugger interface
CREATESHLIB=false
if test "$ENABLE_SHLIB" != "none" -o "$enable_debuginfo" != "no" ; then
   CREATESHLIB=`pwd`/src/util/createshlib
fi
AC_SUBST(CREATESHLIB)
1616

1617
1618
1619
1620
1621
1622
1623
1624
# Check for whether the compiler defines a symbol that contains the 
# function name.  The MPICH2 code, for greater portability, defines
# its own symbols, FCNAME (a string) and FUNCNAME (a token that is not a 
# string).  Code should use these symbols where possible.  However, 
# some debugging macros may want to use a compiler-provided symbol
# for the function name, and this check makes it possible to 
# define such macros in a way that is always correct.
PAC_CC_FUNCTION_NAME_SYMBOL
1625
1626
1627
1628

# Check if $MPI_DEFAULT_COPTS is valid with $CC
if test "$enable_default_optimize" = "yes" \
     -a -n "$MPI_DEFAULT_COPTS" ; then
1629
1630
    if test "$enable_check_compiler_flags" = "yes" ; then
        PAC_C_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_COPTS], [
1631
        CFLAGS="$CFLAGS $MPI_DEFAULT_COPTS"
1632
1633
1634
1635
                                   ] )
    else
        CFLAGS="$CFLAGS $MPI_DEFAULT_COPTS"
    fi
1636
1637
fi

1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
# Check for support for weak symbols.  If not found, set NO_WEAK_SYM
# to the Make target name understood by simplemake.
# Set NEEDSPLIB to yes if link commands need both -l$MPILIBNAME
# and -lp$MPILIBNAME.
NEEDSPLIB=yes
NO_WEAK_SYM_TARGET=build_proflib
if test $enable_weak_symbols = yes ; then
    # Turn off weak symbols if they aren't available
    PAC_PROG_C_WEAK_SYMBOLS(,enable_weak_symbols=no)
fi
if test $enable_weak_symbols = "yes" ; then
    AC_DEFINE(USE_WEAK_SYMBOLS,1,[Define if weak symbols should be used])
    NEEDSPLIB=no
    # Check for the ability to support multiple weak symbols
    if test "$pac_cv_prog_c_weak_symbols" = "pragma weak" ; then
       PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS(AC_DEFINE(HAVE_MULTIPLE_PRAGMA_WEAK,1,[Define if multiple weak symbols may be defined]))
    fi
else
    NO_WEAK_SYM=build_proflib
    PROFILE_DEF_MPI="-DMPICH_MPI_FROM_PMPI"
fi
export NEEDSPLIB
export NO_WEAK_SYM
export NO_WEAK_SYM_TARGET
export PROFILE_DEF_MPI
AC_SUBST(NEEDSPLIB)
AC_SUBST(NO_WEAK_SYM)
AC_SUBST(NO_WEAK_SYM_TARGET)
AC_SUBST(PROFILE_DEF_MPI)

1668
# ---------------------------------------------------------------------------
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
# Support for the language bindings: Fortran 77, Fortran 90, and C++
#
# First, we handle the case of no explicit enable/disable option.  In that
# case, we look for a usable compiler.  We cannot use the ac macros for this
# because they abort the configure step if they fail to find a compiler 
# (earlier versions of autoconf did not have this behavior!).
#
# Second, we perform the langugage-specific tests, if necessary.  This may
# be relatively simple (C++) or complex (Fortran 77, including formation of 
# the encoded MPI handles).
#
# Note that the bindings support needs to know some of the properties of
# the C compiler, so those tests (particularly for weak symbols)
# must come first.
# ----------------------------------------------------------------------------

#
# First, determine whether we are/can support the language bindings
#
1688
1689
1690
1691
1692
1693
# Since F90/F90FLAGS are replaced by FC/FCFLAGS, rather than silently
# substituting them, i.e. FC=$F90 and FCFLAGS=$F90FLAGS, we choose to emit
# an error message and abort to avoid any ambiguous/hidden bug in choosing
# Fortran90 compilers.
if test -n "$F90" -o -n "$F90FLAGS" ; then
    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.])
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
fi
# ----------------------------------------------------------------------------
# Handle default choices for the Fortran compilers
if test "$enable_f77" = "default" ; then
    enable_f77=no
    # Check for a Fortran compiler
    # Warning: the PROG_F77 command aborts if it fails to 
    # find a compiler.  We should first try to find a compiler, then
    # check to see if it works (which the PROG_F77 command does as well)
    # It also prefers g77 to f77, and doesn't know about other compilers
    # Also handle the bug that autoconf sets FFLAGS for you
    saveFFLAGS=$FFLAGS
    AC_PROG_F77
    FFLAGS=$saveFFLAGS
    if test -n "$F77" ; then 
        enable_f77_wasdefault=yes
        enable_f77=yes
    fi
elif test "$enable_f77" = "yes" ; then
    saveFFLAGS=$FFLAGS
    AC_PROG_F77
    FFLAGS=$saveFFLAGS
fi

if test "$enable_f77" = yes ; then
1719
1720
1721
    # Check if $MPI_DEFAULT_FOPTS is valid with $F77
    if test "$enable_default_optimize" = "yes" \
         -a -n "$MPI_DEFAULT_FOPTS" ; then
1722
1723
        if test "$enable_check_compiler_flags" = "yes" ; then
            PAC_F77_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_FOPTS], [
1724
            FFLAGS="$FFLAGS $MPI_DEFAULT_FOPTS"
1725
1726
1727
1728
                                         ] )
        else
            FFLAGS="$FFLAGS $MPI_DEFAULT_FOPTS"
        fi
1729
1730
1731
1732
    fi
fi

#
1733
# We need to know the name mangling for Fortran before testing for FC
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
# compatibility (we need this because of the way we decide to generate
# the Fortran 77 bindings)
if test "$enable_f77" = yes ; then
    FLIBS_save="$FLIBS"
    FLIBS=""
    AC_F77_LIBRARY_LDFLAGS
    # The autoconf macro for finding FLIBS sometimes makes mistakes
    # (particularly with the Fujitsu frt compiler).  This next step
    # first sees if the FLIBS is valid with the Fortran compiler
    PAC_PROG_F77_FLIBS_VALID
    # Now see if FLIBS works with the C compiler
    PAC_PROG_F77_CHECK_FLIBS

    PAC_PROG_F77_LINKER_WITH_C
1748
    PAC_PROG_F77_OBJ_LINKS_WITH_C
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
    # For name mangle, we need the library flags
    PAC_PROG_F77_NAME_MANGLE
    # Check whether additional libraries are needed when linking with C
    PAC_PROG_F77_AND_C_STDIO_LIBS
    AC_SUBST(F77_OTHER_LIBS)

    # Warn about mixed name mangling, since many of the tests will fail
    if test "$pac_cv_prog_f77_name_mangle" = "mixed" ; then
        AC_MSG_WARN([The compiler $F77 uses mixed case names.  Fortran is monocase
and many Fortran programs may use either upper or lower case names for MPI
calls.  Consider specifying a particular parameter to your Fortran compiler
to select either upper or lower case names.  For the Absoft compiler, 
-f selects lower case and -N109 selects upper case (if you use -f, also use 
-B108 to enable the iargc and getarg routines, which are needed for some
tests and by many user programs).  Specify new command
line options by setting the environment variable FFLAGS to include
the options (e.g., setenv FFLAGS "-f -B108").  In addition, make sure that your
Fortran 90 compiler uses a compatible naming choice.  For the 
Absoft Fortran 90, -YALL_NAMES=LCS selects lower case names and -B108 
adds underscores to names, as required for iargc and getarg.  Pass this
1769
information to configure with the FCFLAGS environment variable.])
1770
1771
1772
1773
1774
1775
        # If Fortran implicitly enabled, disable it now.  Otherwise,
	# abort the configure since warning messages are often lost in
	# the output.
	if test "$enable_f77_wasdefault" = yes ; then
	    AC_MSG_WARN([Turning off Fortran support because of mixed case names])
	    enable_f77=no
1776
	    enable_fc=no
1777
1778
1779
1780
	else
	    AC_MSG_ERROR([Aborting configure because of mixed case names in Fortran.  Either select --disable-f77 or set FFLAGS to force the compiler to select monocase names])
	fi
    fi
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849

    # The MPI standard requires that MPI_Init in any language initialize
    # MPI in all languages.  This can be a problem when objects produced 
    # by the Fortran compiler require symbols from the Fortran runtime
    # (making linking C-only programs unnecessarily difficult).  What we test 
    # here is whether the much more restricted needs of the Fortran 
    # initialize can be met with no special use of the Fortran runtime
    pac_f_init_works_with_c=unknown
    AC_MSG_CHECKING([whether Fortran init will work with C])
    rm -f conftest*
    cat > conftestc.c <<EOF
#include <stdio.h>
#include "confdefs.h"
#ifdef F77_NAME_UPPER
#define minit_ MINIT
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
#define minit_ minit
#endif
int main( int argc, char *argv )
{
    minit_();
    return 0;
}
char *v1 = 0;
char *vc2 = 0;
int  v2 = 0;
minitc_( char *dv1, int d, char *dv2, int d2, int dv3 )
{
v1 = dv1;
v2 = dv3;
vc2 = dv2;
*vc2 = ' ';
}
EOF
    cat > conftestf.f <<EOF
       subroutine minit()
       common /m1/ vc, vc2
       character *1 vc(1,1), vc2(1)
       common /m2/ vd
       integer vd
       save /m1/, /m2/
       call minitc( vc, vc2, vd )
       end
EOF
   myfcompile='${F77-f77} -c $FFLAGS conftestf.f 1>&AC_FD_CC'
   myccompile='${CC-cc} -c $CFLAGS conftestc.c 1>&AC_FD_CC'
   if AC_TRY_EVAL(myfcompile) && test -s conftestf.o ; then
       :
   else 
	echo "configure: failed program was:" >&AC_FD_CC
        cat conftestf.f >&AC_FD_CC
   fi
   if AC_TRY_EVAL(myccompile) && test -s conftestc.o ; then
       :
   else 
	echo "configure: failed program was:" >&AC_FD_CC
        cat conftestc.c >&AC_FD_CC
   fi
   # Now try the link step
   myclink='${CC-cc} $CFLAGS -o conftest conftestc.o conftestf.o $LDFLAGS >conftest.out 2>&1'
   if AC_TRY_EVAL(myclink) && test -x conftest${ac_exeext} ; then
      pac_f_init_works_with_c=yes
   else
      pac_f_init_works_with_c=no
   fi
   AC_MSG_RESULT($pac_f_init_works_with_c)
   if test "$pac_f_init_works_with_c" = "yes" ; then
       AC_DEFINE(HAVE_MPI_F_INIT_WORKS_WITH_C,1,[Define if the Fortran init code for MPI works from C programs without special libraries])
   fi
1850
1851
fi

1852
# FC requires F77 as well.  If the user disabled f77, do not run the
1853
# next test; instead, drop into the warning message
1854
1855
1856
1857
1858
# Set a default value for fc works with f77.  This value is
# set to no *only* if fc was selected but was not compatible with f77
fc_with_f77=yes
if test "$enable_fc" = "default" -a "$enable_f77" = yes ; then
    enable_fc=no
1859
    # Check for a Fortran compiler.  Work around bug in autoconf that 
1860
1861
1862
1863
1864
    # adds -g to FCFLAGS
    saveFCFLAGS="$FCFLAGS"
    PAC_PROG_FC
    FCFLAGS=$saveFCFLAGS
    if test -n "$FC" ; then 
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
        if test -z "$F77" ; then
	    saveFFLAGS=$FFLAGS
	    AC_PROG_F77
	    FFLAGS=$saveFFLAGS
	fi
	#
	# If we allow multiple weak symbols, we should test a name
	# that does not contain an underscore.  The Fortran binding uses
	# this rule for enabling multiple weak symbols:
	# if defined(USE_WEAK_SYMBOLS) && !defined(USE_ONLY_MPI_NAMES) &&
	#    defined(HAVE_MULTIPLE_PRAGMA_WEAK) && 
	#    defined(F77_NAME_LOWER_2USCORE)
	# 
	testRoutine="t1_2"
	if test "$pac_cv_prog_c_multiple_weak_symbols" = "yes" -a \
               "$enable_weak_symbols" = "yes" -a \
	       "$pac_cv_prog_f77_name_mangle" = "lower doubleunderscore" ; then
	    testRoutine="t12"
        fi
1884
1885
1886
1887
1888
        PAC_FC_AND_F77_COMPATIBLE(fc_with_f77=yes,fc_with_f77=no,$testRoutine)
        if test "$fc_with_f77" != yes ; then
	    enable_fc=no
	    AC_MSG_WARN([The selected Fortran 90 compiler $FC does not work with the selected Fortran 77 compiler $F77.  Use the environment variables FC and F77 respectively to select compatible Fortran compilers.  The check here tests to see if a main program compiled with the Fortran 90 compiler can link with a subroutine compiled with the Fortran 77 compiler.])
        elif test "$fc_with_f77" = "yes" ; then
1889
            # If we got here, there is a Fortran 90 compiler that we can use
1890
            enable_fc=yes
1891
        fi
1892
1893
    elif test "$pac_cv_prog_fc_works" = no; then
        AC_MSG_WARN([Use --disable-fc to keep configure from searching for a Fortran 90 compiler])
1894
1895
    fi
fi
1896
if test "$enable_fc" = "yes" -a "$enable_f77" != "yes" ; then
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
   # Fortran 90 support requires compatible Fortran 77 support
   AC_MSG_WARN([Fortran 90 support requires compatible Fortran 77 support.  To force the use of the Fortran 90 compiler for Fortran 77, set the environment variable F77 to the name of the Fortran 90 compiler.])
   # We should probably do the compatibility test as well
   enable_f77=yes
fi

# ----------------------------------------------------------------------------
# Now test for Fortran compiler characteristics
# ----------------------------------------------------------------------------
if test "$enable_f77" = "yes" ; then
    AC_LANG_FORTRAN77
    PAC_PROG_F77_EXCLAIM_COMMENTS(has_exclaim="yes",has_exclaim="no")
    PAC_PROG_F77_HAS_INCDIR(src)
    if test -n "$F77_INCDIR" ; then
        # For building the Fortran files, add the directory where we are building 
        # the object to the include list.  This is needed for g77, which makes
        # includes relative to the source directory of the file, not the 
        # directory that the command is executed in
        FINCLUDES="$F77_INCDIR`pwd`/src"
    fi
    AC_SUBST(FINCLUDES)
    #
    PAC_PROG_F77_LIBRARY_DIR_FLAG

    AC_SUBST(MPIFPMPI)
    if test "$MPI_WITH_PMPI" = "no" ; then
        # If the PMPI routines are not in the same library with the MPI
        # routines, we may need to remove the pmpi declarations
        PAC_PROG_F77_ALLOWS_UNUSED_EXTERNALS([MPIFPMPI=",PMPI_WTIME,PMPI_WTICK"],[
        MPIFPMPI=""; 
        AC_MSG_WARN([Removed PMPI_WTIME and PMPI_WTICK from mpif.h])])
    else
        MPIFPMPI=",PMPI_WTIME,PMPI_WTICK"
    fi

    # Once we have name mangle, we can try to limit the number of needed libs
    PAC_PROG_F77_IN_C_LIBS
    AC_SUBST(F77_IN_C_LIBS)

    # ------------------------------------------------
    # Shared library support
    # ------------------------------------------------
# Note that USE_GCC_G77_DECLS is not used anywhere within the code, so
# this check has been commented out.
dnl    # If both C and Fortran are gnu, define the following to simplify 
dnl    # shared library support.  
dnl    AC_MSG_CHECKING([whether using gcc and g77 together])
dnl    if test "$ac_cv_prog_gcc" = "yes" -a "$ac_cv_prog_g77" = "yes" ; then
dnl        # FIXME: Who uses this definition?
dnl        AC_DEFINE(USE_GCC_G77_DECLS,1,[Define if using gcc and g77 together])
dnl        AC_MSG_RESULT(yes)
dnl    else 
dnl        AC_MSG_RESULT(no)
dnl    fi
1951
1952
    AC_SUBST(F77_SHL)
    AC_SUBST(F77_LINKPATH_SHL)
1953
1954
    case "$ENABLE_SHLIB" in
	 gcc-osx|osx-gcc)
1955
1956
	 F77_SHL="$F77 -fPIC"
	 F77_LINKPATH_SHL=""
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
	 ;;
	 gcc)
	 # Assume that the compiler is g77 if gcc style shared libraries chosen
	 # (unfortunately, the name may be g77 or f77)
	 # To make this a little more robust, only add the -shared
	 # if the compiler allows it (e.g., building with gcc but
	 # a different Fortran compiler. Another option is to
	 # *require* g77.
	 rm -f conftest.f
	 cat > conftest.f <<EOF
       program main
       end
EOF
1970
         F77_SHL=false
1971
         for sh_arg in "-shared -fPIC" "-fPIC" "-shared -fpic" "-fpic" "-KPIC" ; do
1972
1973
 	     AC_MSG_CHECKING([whether $F77 allows $sh_arg])
             if $F77 $sh_arg -o conftest conftest.f >/dev/null 2>&1 ; then
1974
	         F77_SHL="$F77 $sh_arg"
1975
                 AC_MSG_RESULT(yes)
1976
	         break
1977
1978
1979
             else
                 AC_MSG_RESULT(no)
             fi
1980
	 done
1981
	 if test "$F77_SHL" = "false" ; then
1982
	     AC_ERROR([Cannot build shared libraries for Fortran with this compiler])
1983
         fi
1984
1985
	 # This is needed for Mac OSX 10.5
	 rm -rf conftest.dSYM
1986
         rm -f conftest*
1987
1988
1989
	 if test "$enable_rpath" = yes ; then 
	      F77_LINKPATH_SHL="-Wl,-rpath -Wl,"
	 fi
1990
	 ;;
1991

1992
	 cygwin|cygwin-gcc)
1993
1994
	 F77_SHL="$F77 -shared"
	 F77_LINKPATH_SHL=""
1995
1996
1997
	 ;;

	 solaris|solaris-cc)
1998
	 F77_SHL="$F77 -xcode=pic32"
1999
2000
2001
	 if test "$enable_rpath" = yes ; then 
             F77_LINKPATH_SHL=-R
         fi
2002
2003
2004
2005
2006
	 ;;

	 # Do we need a solaris-64 with -xcode=pic64?

	 libtool)
2007
	 F77_SHL='${LIBTOOL} --mode=compile ${F77}'
2008
2009
2010
	 if test "$enable_rpath" = yes ; then 
             F77_LINKPATH_SHL="-rpath "
         fi
2011
2012
2013
	 ;;

	 *)
2014
	 F77_SHL=false
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
	 ;;
    esac
    # ------------------------------------------------

    #
    # Most systems allow the Fortran compiler to process .F and .F90 files
    # using the C preprocessor.  However, some systems either do not
    # allow this or have serious bugs (OSF Fortran compilers have a bug
    # that generates an error message from cpp).  The following test
    # checks to see if .F works, and if not, whether "cpp -P -C" can be used
2025
    # This is needed for Mac OSX 10.5
2026
    PAC_F77_WORKS_WITH_CPP([F77CPP])
2027
2028
2029
2030
2031
2032