File: configure.ac

package info (click to toggle)
mpich 4.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 423,384 kB
  • sloc: ansic: 1,088,434; cpp: 71,364; javascript: 40,763; f90: 22,829; sh: 17,463; perl: 14,773; xml: 14,418; python: 10,265; makefile: 9,246; fortran: 8,008; java: 4,355; asm: 324; ruby: 176; lisp: 19; php: 8; sed: 4
file content (1894 lines) | stat: -rw-r--r-- 62,917 bytes parent folder | download
1
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
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
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
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
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
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
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
984
985
986
987
988
989
990
991
992
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
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
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
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
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
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
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
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
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
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
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
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
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
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
##
## Copyright (C) by Argonne National Laboratory
##     See COPYRIGHT in top-level directory
##

dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.67)
dnl
dnl aclocal_cache.m4, included by sowing/confdb/aclocal.m4, fixes 
dnl bugs in autoconf caching.
dnl
dnl
dnl Environment variables that affect behavior of the test configure
dnl MPICH_FAST 
dnl
dnl The file name here refers to a file in the source being configured
dnl FIXME this is the old style, needs updating to new style
dnl AC_INIT(include/mpitest.h)
m4_include([version.m4])
AC_INIT([mpich-testsuite],
        MPICH_VERSION_m4,
        [discuss@mpich.org],
        [mpich-testsuite],
        [http://www.mpich.org/])

AC_CONFIG_HEADERS([include/mpitestconf.h])
AH_TOP([/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */
#ifndef MPITESTCONF_H_INCLUDED
#define MPITESTCONF_H_INCLUDED
])
AH_BOTTOM([#endif])

VERSION=MPICH_VERSION_m4
AC_SUBST(VERSION)
AC_CONFIG_AUX_DIR([confdb])
AC_CONFIG_MACRO_DIR([confdb])
dnl
echo "RUNNING CONFIGURE FOR MPI TESTS"

AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability-recursive foreign 1.12.3 silent-rules subdir-objects])
AM_MAINTAINER_MODE([enable])

# Non-verbose make by default
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

if test -z "$mpich_top_srcdir" ; then 
    if test -z "$top_srcdir" ; then
       use_top_srcdir=$srcdir   
    else
       use_top_srcdir=$top_srcdir
    fi
    case "$use_top_srcdir" in
    /*) ;;
    *)
        use_top_srcdir=`(cd $use_top_srcdir && pwd)`
        ;;        
    esac
    if test -f $use_top_srcdir/../../maint/version.m4 ; then 
        mpich_top_srcdir=`cd $use_top_srcdir && cd ../.. && pwd`
    fi
fi
AC_SUBST(mpich_top_srcdir)

# these (in particular main_top_srcdir) are needed to regenerate
# the f90 files from the f77 files
AC_ARG_VAR([main_top_builddir],[path to the MPICH top-level build directory (if present)])
AC_ARG_VAR([main_top_srcdir],[path to the MPICH top-level source directory (if present)])

# Ensure that main_top_srcdir is set if maintainer mode for is set,
# since some of the Makefile targets require it.
if test "X$main_top_srcdir" = "X" -a "$USE_MAINTAINER_MODE" = "yes" ; then
    if test -z "$top_srcdir" ; then
       use_top_srcdir=$srcdir   
    else
       use_top_srcdir=$top_srcdir
    fi
    # Make use_top_srcdir absolute
    case "$use_top_srcdir" in
    /*) ;;
    *)
        use_top_srcdir=`(cd $use_top_srcdir && pwd)`
        ;;        
    esac
    # Now, see if we can find the f77tof90 routine
    if test -x $use_top_srcdir/maint/f77tof90 ; then
        main_top_srcdir=$use_top_srcdir
    else 
        AC_MSG_ERROR([Unable to find main source file - reconfigure using --disable-maintainer_mode])
    fi
fi

AC_ARG_ENABLE(echo,
	[AS_HELP_STRING([--enable-echo],[Turn on strong echoing. The default is enable=no.])],
	[set -x])

AC_ARG_ENABLE(fortran,
[  --enable-fortran=option - Control the level of Fortran support in the MPICH implementation.
        yes|all   - Enable all available Fortran implementations (F77, F90, F08)
        f77       - Enable Fortran 77 support
        f90       - Enable Fortran 90 support
        f08       - Enable Fortran 2008 support
        no|none   - No Fortran support
],,[enable_fortran=f77,f90])

save_IFS="$IFS"
IFS=","
enable_f77=no
enable_fc=no
enable_f08=no
for option in $enable_fortran ; do
    case "$option" in
        yes|all)
                enable_f77=yes
                enable_fc=yes
                enable_f08=yes
                ;;
        no|none)
                enable_f77=no
                enable_fc=no
                enable_f08=no
                ;;
        f77)
                enable_f77=yes
                ;;
        f90)
                enable_fc=yes
                ;;
        f08)
                enable_f08=yes
                ;;
        *)
                IFS="$save_IFS"
                AC_MSG_WARN([Unknown value $option for --enable-fortran])
                IFS=","
                ;;
    esac
done
IFS="$save_IFS"

# DTPools switch
AC_ARG_ENABLE([dtpools],
              [AS_HELP_STRING([--disable-dtpools],[Disable dtpools tests])],,
              [enable_dtpools=yes])

if test "x${enable_dtpools}" = "xyes"; then
    DTP_SWITCH="ON"
else
    DTP_SWITCH="OFF"
fi

AC_SUBST(DTP_SWITCH)

AC_ARG_ENABLE(cxx,
	[AS_HELP_STRING([--enable-cxx],[Turn on C++ tests (default)])],,[enable_cxx=yes])

AC_ARG_ENABLE(romio,
	[AS_HELP_STRING([--enable-romio],[Enable ROMIO MPI I/O implementation])],,
	[enable_romio=yes])

AC_ARG_ENABLE(spawn,
	[AS_HELP_STRING([--enable-spawn],
		[Enable tests of the dynamic process parts of MPI-2 (default)])],,
	[enable_spawn=yes])

AC_ARG_ENABLE(rma,
	[AS_HELP_STRING([--enable-rma],[Enable tests of the one sided parts of MPI-2 (default)])],,
	[enable_rma=yes])

AC_ARG_ENABLE(part,
	[AS_HELP_STRING([--enable-part],[Enable tests of partitioned communication of MPI-4 (default)])],,
	[enable_part=yes])

AC_ARG_ENABLE(long-double-complex,
	[AS_HELP_STRING([--enable-long-double-complex],
		[Enable tests involving MPI_LONG_DOUBLE_COMPLEX (default)])],,
	[enable_long_double_complex=yes])
AC_ARG_ENABLE(long-double,
	[AS_HELP_STRING([--enable-long-double-complex],
		[Enable tests involving MPI_LONG_DOUBLE and related types (default)])],,
	[enable_long_double=yes])

AC_ARG_ENABLE(checkerrors,
	[AS_HELP_STRING([--enable-checkerrors],
		[Add some tests for checking for errors in user programs])],,
	[enable_checkerrors=yes])

AC_ARG_ENABLE(perftest,
	[AS_HELP_STRING([--enable-perftest],
		[Include tests for basic performance consistency (default)])],,
	[enable_perftest=yes])

AC_ARG_ENABLE(large-tests,
	[AS_HELP_STRING([--enable-large-tests],
		[Enable tests which require large (>2GB per proc) amount of memory])],,
	[enable_large_tests=no])

AC_ARG_ENABLE(ft-tests,
	[AS_HELP_STRING([--enable-ft-tests],
		[Include tests for fault tolerance (default no)])],,
	[enable_ft_tests=no])

AC_ARG_ENABLE(comm-overlap-tests,
	[AS_HELP_STRING([--enable-comm-overlap-tests],
		[Include tests for communicator overlap (default)])],,
	[enable_comm_overlap_tests=yes])

AC_ARG_ENABLE(checkfaults,
	[AS_HELP_STRING([--enable-checkfaults],
		[Add some tests for checking on handling of faults in user programs])],,
	[enable_checkfaults=no])

AC_ARG_ENABLE(checkpointing,
	[AS_HELP_STRING([--enable-checkpointing],
		[Add some tests for checkpointing])],,
	[enable_checkpointing=no])

AC_ARG_ENABLE(fast,
	[AS_HELP_STRING([--enable-fast],
		[Indicates that the MPI implementation may have been
		built for fastest operation, such as building without
		error checking.  Has the effect of
		--enable-checkerrors=no])],,)

AC_ARG_ENABLE(strictmpi,
	[AS_HELP_STRING([--enable-strictmpi],
		[Only test for operations specifically defined by the
		MPI standard.  This turns off tests for some common
		extensions, including for combinations of predefined
		datatypes and predefined MPI_Op s.])],,
	[enable_strictmpi=no])

AC_ARG_ENABLE(threads,
	[--enable-threads=level - Specify the level of thread support expected from the
				MPI implementation.  The following levels are supported.

	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)

	The default is funneled.  If enabled and no level is
	specified, the level is set to multiple.  If disabled, the
	level is set to single.  If the environment variable
	MPICH_THREAD_LEVEL is set, that thread level is used (this is
	to let MPICH build for the correct thread support without
	requiring a specific --enable-threads argument.],,
	[enable_threads=default])

AC_ARG_ENABLE(xfail,
	[AS_HELP_STRING([--enable-xfail],
		[Run tests marked for expected failure])],,
	[enable_xfail=no])

AC_ARG_ENABLE(collalgo-tests,
        [AS_HELP_STRING([--enable-collalgo-tests],
                [Run extended collective algorithm tests])],,
        [enable_collalgo_tests=yes])

AC_ARG_ENABLE(gpu-tests-only,
        [AS_HELP_STRING([--enable-gpu-tests-only],
                [Run only GPU tests])],,
        [enable_gpu_tests_only=no])

# DTPools test generation
AC_ARG_WITH(dtpools-datatypes,
    [AS_HELP_STRING([--with-dtpools-datatypes=typelist],
        [Comma separated list of MPI datatypes to use for DTPools tests
         generation. Typelist can be of the form: 'MPI_INT,MPI_DOUBLE,...',
         for single element types, 'MPI_INT:4+MPI_DOUBLE:8,...', for multiple
         element types, or a combination of both.])],,[with_dtpools_datatypes=MPI_INT,MPI_INT:4+MPI_DOUBLE:8])

# parse args for typegen.sh script
dtp_args="--with-dtpools-datatypes=${with_dtpools_datatypes}"
AC_CONFIG_COMMANDS([gentests],[$srcdir/maint/gentests_dtp.sh $dtp_args],[dtp_args="$dtp_args"])

if test $enable_collalgo_tests = "yes" ; then
    PAC_CHECK_PYTHON
    #Test collectives algorithms with CVARs
    cmd="$PYTHON $srcdir/maint/gen_coll_cvar.py"
    AC_CONFIG_COMMANDS([collcvartests],[$cmd_gen_coll],[cmd_gen_coll="$cmd"])
fi

AC_ARG_WITH(mpi,
	[AS_HELP_STRING([--with-mpi=dir],
		[Use the selected MPI; compilation scripts for mpicc,
		mpifort and mpicxx should be in dir/bin])],,)

AC_ARG_WITH(pm,
	AS_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:gforker"
                 builds the two process managers hydra and gforker;
                 only the mpiexec from hydra is installed into the bin
                 directory.]),,with_pm=default)

if test "$with_pm" = "none" ; then
    # add "none" as synonym for "no" to agree with older erroneous docs
    with_pm="no"
fi
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
   if test ! -z "$MPID_DEFAULT_PM" ; then
      with_pm=${MPID_DEFAULT_PM}
   else
      with_pm=hydra
   fi
fi

# Get the first pm specified
if test "$with_pm" != "no" ; then
    first_pm="`echo $with_pm | sed -e 's/:.*//' -e 's/,.*//'`"
else
    first_pm=""
fi

AC_ARG_WITH(config-args,
	[AS_HELP_STRING([--with-config-args=filename],
		[Specify configure argument file that contains the
		values of variables that configure reads,
		e.g. CC,CFLAGS,F77,FFLAGS,FC,FCFLAGS....  If the
		filename does not begin with / (absolute path), . or
		.. (relative path), the filename will be assumed to be
		$top_srcdir/configargs/<filename>.cfg.])],,
	[with_config_args=no])

if test "$with_config_args" != "no" ; then
    case "$with_config_args" in 
        /*|../*|./*)
            config_args_file="$with_config_args"
            ;;
        *)
            config_args_file="$srcdir/configargs/$with_config_args.cfg"
            ;;
    esac
    if test -s "$config_args_file" ; then
        AC_MSG_RESULT([Reading the configure arguments in ${config_args_file}.])
        . $config_args_file
        # Export all the variables in $config_args_file
        # i.e. CC,CFLAGS, F77/FFLAGS, FC/FCFLAGS, CXX/CXXFLAGS and friends...
        config_args_vars=`grep -v '^#' $config_args_file | sed -e 's/=.*//g'`
        for var in $config_args_vars ; do
            eval value=\$"$var"
            echo "Exporting $var=$value ..."
            export $var
        done
    else
        AC_MSG_WARN([Non-existent ${config_args_file}.])
    fi
fi

# First, determine whether we are/can support the language bindings
#
# 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.])
fi

# ------------------------------------------------------------------------
dnl use AC_ARG_VAR to mark FROM_MPICH as "precious" to autoconf so that
dnl automatic re-runs of config.status preserve its value correctly
AC_ARG_VAR([FROM_MPICH],[should be set to "yes" if this configure script is being invoked by the main MPICH configure])
AC_ARG_VAR([MPICH_THREAD_LEVEL],
           [the MPI thread level supported by the enclosing MPICH build (when built within MPICH)])
# ------------------------------------------------------------------------

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 -n "$MPICH_THREAD_LEVEL" ; then
        case $MPICH_THREAD_LEVEL in 
            MPI_THREAD_MULTIPLE)
            enable_threads=multiple
            ;;
            MPI_THREAD_SERIALIZED)
            enable_threads=serialized
            ;;
            MPI_THREAD_FUNNELED)
            enable_threads=funneled
            ;;
            MPI_THREAD_SINGLE)
            enable_threads=single
            ;;
        esac
    else
        enable_threads=funneled
    fi
fi

# errordir is substituted into the testlist file as errors when the
# tests should check error handling and as a comment (#) otherwise.
errordir="#"
if test "$enable_checkerrors" = "yes" ; then
    errordir=errors
fi
AC_SUBST(errordir)

# The performance tests are not part of the MPI standard
perfdir="perf"
if test "$enable_strictmpi" = "yes" -o "$enable_perftest" = "no" ; then
     perfdir="#"
fi
AC_SUBST(perfdir)

# The ft tests are not part of the MPI standard and some of the netmods can't handle them
ftdir="#ft"
if test "$first_pm" = "hydra" -a  "$enable_strictmpi" = "no" -a "$enable_ft_tests" = "yes" ; then
    ftdir="ft"
fi
AC_SUBST(ftdir)

# Setup "comm_overlap" variable based on whether comm_overlap tests
# are enabled or not
if test "${enable_comm_overlap_tests}" = "yes" ; then
   comm_overlap=""
else
   comm_overlap="#"
fi
AC_SUBST(comm_overlap)

# 
# Only run the threads tests if multiple is specified
if test "$enable_threads" = "multiple" -o "$enable_threads" = "runtime" ; then
    threadsdir="threads"
fi
# 
# Only run the checkpointing tests if enabled
ckpointdir="#ckpoint"
if test "$enable_checkpointing" = "yes" ; then
    ckpointdir="ckpoint"
fi
AC_SUBST(ckpointdir)

#
# Only run xfail tests if enabled
RUN_XFAIL=false
if test "$enable_xfail" = "yes" ; then
    RUN_XFAIL=true
fi
AC_SUBST(RUN_XFAIL)

PAC_LOAD_BASE_CACHE
PAC_VPATH_CHECK()
PAC_PROG_MAKE

MPILIBLOC=""
AC_SUBST(MPILIBLOC)

# more variables that must be marked precious for proper re-configure operation
AC_ARG_VAR([MPICH_ENABLE_FC],["yes" if the enclosing MPICH build supports modern Fortran])
AC_ARG_VAR([MPICH_ENABLE_CXX],["yes" if the enclosing MPICH build supports C++])

# If we're building from MPICH, check the MPICH_ENABLE_xxx environment
# variables for enable defaults
if test "$FROM_MPICH" = yes ; then
    if test -n "$MPICH_ENABLE_FC" ; then
        enable_f77=$MPICH_ENABLE_FC
        enable_fc=$MPICH_ENABLE_FC
    fi
    if test -n "$MPICH_ENABLE_CXX" ; then
        enable_cxx=$MPICH_ENABLE_CXX
    fi
    namepub_tests="#"
    if test -n "$nameserv_name" ; then
        namepub_tests=""
    fi
    AC_SUBST(namepub_tests)
fi

# Some MPI-2 implementations (including some of the MPICH shared-memory
# channels and BG/L) leave out the dynamic process routines.  This
# allows tests to avoid reporting failure for these routines.  
# This can be controlled by either a --disable-spawn argument or by
# setting the environment variable MPI_NO_SPAWN to yes.
AC_ARG_VAR([MPI_NO_SPAWN],[set to "yes" to disable dynamic process tests])
if test "$enable_spawn" = "yes" -a "$MPI_NO_SPAWN" != "yes" ; then
    spawndir=spawn
    AC_DEFINE(HAVE_MPI_SPAWN,1,[Define if Dynamic Process functionality is available])
fi
AC_SUBST(spawndir)

# Also allow rma to be disabled
AC_ARG_VAR([MPI_NO_RMA],[set to "yes" to disable one-sided tests])
rmadir=rma
if test "$enable_rma" != yes ; then
    rmadir="#"
elif test "$MPI_NO_RMA"  = yes ; then
    rmadir="#"
else
    AC_DEFINE(HAVE_MPI_WIN_CREATE,1,[Define if MPI_Win_create is available])
fi
AC_SUBST(rmadir)

# Also allow partitioned communication to be disabled
AC_ARG_VAR([MPI_NO_PART],[set to "yes" to disable partitioned communication tests])
partdir=part
if test "$enable_part" != "yes" -o "$MPI_NO_PART" = "yes" ; then
    partdir="#"
fi
AC_SUBST(partdir)

faultsdir=#
if test "$enable_checkfaults" = "yes" ; then
    faultsdir=faults
fi
AC_SUBST(faultsdir)
#
MPI_IS_STRICT=false
AC_SUBST(MPI_IS_STRICT)
if test "$enable_strictmpi" = "yes" ; then
    MPI_IS_STRICT=true
    AC_DEFINE(USE_STRICT_MPI,1,[Define if only operations defined in MPI should be tested])
fi
#
# At this writing, MPICH has many MPIX routines, and the test suite includes
# them.  As these are not MPI routines (yet), they are invalid and incorrect
# when this test suite is used for other MPI implementations, including those
# based on earlier versions of MPICH.
MPI_HAS_MPIX=no
#
# Hack to detect build from within MPICH.  Ensure strictmpi not selected.
if test "$FROM_MPICH" = "yes" -a "$enable_strictmpi" = "no" ; then
   MPI_HAS_MPIX=yes
fi
AC_SUBST(MPI_HAS_MPIX)

# Prepend @mpix@ to lines of tests in testlist.in which are MPIX tests so that
# we can skip running these tests when we do strict MPI test.
mpix="#"
if test "$enable_strictmpi" = "no"; then
    mpix=""
fi
AC_SUBST(mpix)

# Use the conditional variable BUILD_MPIX_TESTS to conditionally add MPIX tests
# to noninst_PROGRAMS to skip building the tests when we do strict MPI test
AM_CONDITIONAL([BUILD_MPIX_TESTS], [test "$enable_strictmpi" = "no"])

# preserve these values across a reconfigure
AC_ARG_VAR([WRAPPER_CFLAGS],[])
AC_ARG_VAR([WRAPPER_CPPFLAGS],[])
AC_ARG_VAR([WRAPPER_LDFLAGS],[])
AC_ARG_VAR([WRAPPER_LIBS],[])
AC_ARG_VAR([WRAPPER_FFLAGS],[])
AC_ARG_VAR([WRAPPER_FCFLAGS],[])
AC_ARG_VAR([WRAPPER_CXXFLAGS],[])

# Attach program prefix and suffix to executable names
PAC_GET_EXENAME("mpicc", MPICC_NAME)
PAC_GET_EXENAME("mpif77", MPIF77_NAME)
PAC_GET_EXENAME("mpifort", MPIFORT_NAME)
PAC_GET_EXENAME("mpicxx", MPICXX_NAME)
PAC_GET_EXENAME("mpiexec", MPIEXEC_NAME)

if test "$FROM_MPICH" = "yes" ; then
    # perform configure tests with the normal compilers ($CC/$F77/etc), but use
    # the WRAPPER_xFLAGS computed by MPICH as our flags instead.  Then at the
    # end of configure we will empty out these flags and set our compilers to
    # the installed compiler wrappers
    CFLAGS="$WRAPPER_CFLAGS"
    CPPFLAGS="$WRAPPER_CPPFLAGS"
    LDFLAGS="$WRAPPER_LDFLAGS"
    FFLAGS="$WRAPPER_FFLAGS"
    FCFLAGS="$WRAPPER_FCFLAGS"
    CXXFLAGS="$WRAPPER_CXXFLAGS"

    # WRAPPER_LIBS contains currently non-existent libs like "-lopa" and "-lmpl"
    # right now, so set LIBS to the user-specified libs for now.
    # FIXME Does this need to be an AC_ARG_VAR?
    LIBS="$MPICH_LIBS"

elif test -n "$with_mpi" ; then
    if test -z "$MPICC" ; then
        CC=$with_mpi/bin/$MPICC_NAME
    else
        CC=$MPICC
    fi
    if test -z "$MPIF77" ; then
        F77=$with_mpi/bin/$MPIF77_NAME
    else
        F77=$MPIF77
    fi
    if test -z "$MPIFC" ; then
        FC=$with_mpi/bin/$MPIFORT_NAME
    else
        FC=$MPIFC
    fi
    if test -z "$MPICXX" ; then
        CXX=$with_mpi/bin/$MPICXX_NAME
    else
        CXX=$MPICXX
    fi
    if test -z "$MPIEXEC" ; then
        MPIEXEC=$with_mpi/bin/$MPIEXEC_NAME
    fi
else
    # Try to use mpicc etc names
    if test -z "$MPICC" ; then
        AC_PATH_PROG(MPICC,$MPICC_NAME mpcc)
    fi
    if test "x$MPICC" != "x" ; then
        CC=$MPICC
    fi 
    if test -z "$MPIF77" ; then
        AC_PATH_PROG(MPIF77,$MPIF77_NAME mpf77)
    fi
    if test "x$MPIF77" != "x" ; then 
        F77=$MPIF77
    fi
    if test -z "$MPIFC" ; then
        AC_PATH_PROG(MPIFC,$MPIFORT_NAME mpftn)
    fi
    if test "x$MPIFC" != "x" ; then
        FC=$MPIFC
    fi
    if test -z "$MPICXX" ; then
        # We left mpiCC off of this list because mpicc and mpiCC are the 
        # same on Mac OSX systems.
        AC_PATH_PROG(MPICXX,$MPICXX_NAME mpCC)
    fi
    if test "x$MPICXX" != "x" ; then
        CXX=$MPICXX
    fi 
    if test -z "$MPIEXEC" ; then
        AC_PATH_PROG(MPIEXEC,$MPIEXEC_NAME)
    fi
fi
# Make sure we export CC before configuring DTPools, since MPI is
# needed to build the library.
export CC
AC_CONFIG_SUBDIRS([dtpools])

# Running C compiler tests
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O

# Note that some versions of autoconf will insist that the compiler
# produce executables at this point, which is why we must do something
# special for building within MPICH

# Ensure that we can compile an MPI program before we go any further
# We don't use a cached value here because this is a sanity check
# The exception is if we are executing this configure from within the 
# MPICH configure - in that case, the 
if test "$FROM_MPICH" != "yes" ; then
    AC_MSG_CHECKING([whether we can compile and link MPI programs in C])
    AC_LINK_IFELSE([
AC_LANG_PROGRAM([#include "mpi.h"],[MPI_Init(0,0);MPI_Finalize();])
    ],[mpi_compile_works=yes],[mpi_compile_works=no])
AC_MSG_RESULT($mpi_compile_works)

    if test "$mpi_compile_works" != "yes" ; then
       AC_MSG_ERROR([Unable to compile and/or link an MPI program!  Check config.log])
    fi
fi
dnl We cannot use AC_C_LONG_DOUBLE
dnl because it does not support cross-compilation.  Instead, we use the
dnl same test in the MPICH configure.
# Check on support for long double and long long types.  Do this before the
# structure alignment test because it will test for including those
# types as well
# 
# If --disable-long-double is selected, then bypass this test.
# Some MPI implementations may choose to not support long double because
# their C compilers are inconsistent on the length of long double (this
# is the case on the Cray, with Cray, PGI, and GNU not agreeing on the
# size of long double)
if test "$enable_long_double" = "yes" ; then
    AC_CACHE_CHECK([whether long double is supported],pac_cv_have_long_double,[
    AC_COMPILE_IFELSE([
        AC_LANG_PROGRAM([],[long double a;])
    ],[pac_cv_have_long_double=yes],[pac_cv_have_long_double=no])
])
    if test "$pac_cv_have_long_double" = "yes" ; then
        AC_DEFINE(HAVE_LONG_DOUBLE,1,[Define if long double is supported])
    fi
fi
AC_CACHE_CHECK([whether long long is supported],pac_cv_have_long_long,[
    AC_COMPILE_IFELSE([
        AC_LANG_PROGRAM([],[long long a;])
    ],[pac_cv_have_long_long=yes],[pac_cv_have_long_long=no])
])
if test "$pac_cv_have_long_long" = yes ; then 
    AC_DEFINE(HAVE_LONG_LONG,1,[Define if compiler supports long long])
fi
#
# Check for const and restrict (used in some of the performance tests)
AC_C_CONST
AC_C_RESTRICT

# not using libtool for the test suite, so no LT_INIT.  Instead, test here
# for Library programs
AC_PROG_RANLIB
AM_PROG_AR

# Check for --enable-strict
# NOTE: do this before checking any AC_CHECK_HEADERS, because strict may
# turn on extension macros
PAC_ARG_STRICT

# General headers
dnl AC_CHECK_HEADERS(stdarg.h unistd.h string.h stdlib.h memory.h stdint.h)
dnl unistd.h string.h stdlib.h memory.h stdint.h are checked by AC_PROG_CC.
AC_CHECK_HEADERS(stdarg.h sys/time.h sys/resource.h)

# check if we need declarations
AC_CHECK_FUNCS(strdup)
if test "$ac_cv_func_strdup" = "yes" ; then
   PAC_FUNC_NEEDS_DECL([#include <string.h>],strdup)
fi

AC_CHECK_FUNCS(usleep)
if test "$ac_cv_func_usleep" = "yes" ; then
   PAC_FUNC_NEEDS_DECL([#include <unistd.h>],usleep)
fi

# Check for fixed width types
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T

# Check for availability of C99 types
AC_CHECK_TYPES([_Bool, float _Complex, double _Complex, long double _Complex])
AC_CHECK_SIZEOF(void *,8)

# Start of GPU libs check
have_gpu="no"
PAC_PUSH_FLAG([CPPFLAGS])
PAC_PUSH_FLAG([LDFLAGS])
PAC_PUSH_FLAG([LIBS])

# Check CUDA availability
PAC_CHECK_HEADER_LIB_OPTIONAL([cuda],[cuda_runtime_api.h],[cudart],[cudaStreamSynchronize])
cuda_CPPFLAGS=""
cuda_LDFLAGS=""
cuda_LIBS=""
if test "X${pac_have_cuda}" = "Xyes" ; then
    AC_DEFINE([HAVE_CUDA],[1],[Define if CUDA is available])
    have_gpu="yes"
    if test -n "${with_cuda}" -a "$with_cuda" != "no" ; then
        cuda_CPPFLAGS="-I${with_cuda}/include"
        if test -d ${with_cuda}/lib64 ; then
            cuda_LDFLAGS="-L${with_cuda}/lib64 -L${with_cuda}/lib"
        else
            cuda_LDFLAGS="-L${with_cuda}/lib"
        fi
    fi
    cuda_LIBS="-lcudart"
fi
AM_CONDITIONAL([HAVE_CUDA],[test "X${pac_have_cuda}" = "Xyes"])
AC_SUBST([cuda_CPPFLAGS])
AC_SUBST([cuda_LDFLAGS])
AC_SUBST([cuda_LIBS])

if test "$have_gpu" = "no" ; then
    # Check Level Zero availability when no other GPU library is available
    PAC_CHECK_HEADER_LIB_OPTIONAL([ze],[level_zero/ze_api.h],[ze_loader],[zeInit])
    ze_CPPFLAGS=""
    ze_LDFLAGS=""
    ze_LIBS=""
    if test "X${pac_have_ze}" = "Xyes" ; then
        AC_DEFINE([HAVE_ZE],[1],[Define if ZE is available])
        have_gpu="yes"
        if test -n "${with_ze}" -a "$with_ze" != "no" ; then
            ze_CPPFLAGS="-I${with_ze}/include"
            if test -d ${with_ze}/lib64 ; then
                ze_LDFLAGS="-L${with_ze}/lib64 -L${with_ze}/lib"
            else
                ze_LDFLAGS="-L${with_ze}/lib"
            fi
        fi
        ze_LIBS="-lze_loader"
    fi
    AC_SUBST([ze_CPPFLAGS])
    AC_SUBST([ze_LDFLAGS])
    AC_SUBST([ze_LIBS])
fi
AM_CONDITIONAL([HAVE_ZE],[test "X${pac_have_ze}" = "Xyes"])

# Check HIP availability
if test "$have_gpu" = "no" ; then
    AC_DEFINE([__HIP_PLATFORM_AMD__],[1],[AMD GPU HIP available])
    PAC_CHECK_HEADER_LIB_OPTIONAL([hip],[hip/hip_runtime_api.h],[amdhip64],[hipStreamSynchronize])
    hip_CPPFLAGS=""
    hip_LDFLAGS=""
    hip_LIBS=""
    if test "X$pac_have_hip" = "Xyes" ; then
       AC_DEFINE([HAVE_HIP],[1],[Define if HIP is available])
       have_gpu="yes"
       if test -n "${with_hip}" -a "$with_hip" != "no" ; then
          hip_CPPFLAGS="-I${with_hip}/include"
          if test -d ${with_hip}/lib64 ; then
              hip_LDFLAGS="-L${with_hip}/lib64 -L${with_hip}/lib"
          else
              hip_LDFLAGS="-L${with_hip}/lib"
          fi
       fi
       hip_LIBS="-lamdhip64"
    fi
    AC_SUBST([hip_CPPFLAGS])
    AC_SUBST([hip_LDFLAGS])
    AC_SUBST([hip_LIBS])
fi
AM_CONDITIONAL([HAVE_HIP],[test "X${pac_have_hip}" = "Xyes"])

PAC_POP_FLAG([CPPFLAGS])
PAC_POP_FLAG([LDFLAGS])
PAC_POP_FLAG([LIBS])

AM_CONDITIONAL([HAVE_GPU], [test $have_gpu = "yes"])
# GPU only tests
if test $have_gpu = "no" -a $enable_gpu_tests_only = "yes" ; then
    AC_MSG_ERROR([GPU only test configuration requires GPU library (CUDA or LevelZero)])
fi
AM_CONDITIONAL([GPU_ONLY], [test $enable_gpu_tests_only = "yes"])
# End of GPU libs Check

# for tests that require large mem
largetest="#"
if test "$enable_large_tests" = "yes" -a $ac_cv_sizeof_void_p -ge 8; then
    largetest=""
fi
AC_SUBST(largetest)

# Enable device specific tests in impls/mpich
ch3_tests="#"
ch4_tests="#"
case $with_device in
    ch3*)
        ch3_tests=""
        ;;
    ch4*)
        ch4_tests=""
        ;;
esac
ch4_ucx_tests="#"
ch4_ofi_tests="#"
case $with_device in
    ch4:ucx*)
        ch4_ucx_tests=""
        ;;
    ch4:ofi*)
        ch4_ofi_tests=""
        ;;
esac
AC_SUBST(ch3_tests)
AC_SUBST(ch4_tests)
AC_SUBST(ch4_ucx_tests)
AC_SUBST(ch4_ofi_tests)

# Only run the long double complex tests if that type is available
if test "x$enable_long_double" = "xyes" && \
   test "x$enable_long_double_complex" = "xyes" && \
   test "x$ac_cv_type_long_double__Complex" = "xyes" ; then
   AC_DEFINE(USE_LONG_DOUBLE_COMPLEX,1,[Define if tests with long double complex should be included])
fi

# extra libraries may be necessary on some platforms (solaris) for spawn/join
if test "$spawndir" = "spawn" ; then
    PAC_PUSH_FLAG(LIBS)
    AC_SEARCH_LIBS(socket,socket,socklib=$LIBS)
    PAC_POP_FLAG(LIBS)
    PAC_PUSH_FLAG(LIBS)
    AC_SEARCH_LIBS(gethostbyname,nsl,nslib=$LIBS)
    PAC_POP_FLAG(LIBS)
    AC_SUBST(socklib)
    AC_SUBST(nslib)
fi

PAC_ARG_THREAD_PACKAGE

THREAD_PACKAGE_NAME=THREAD_PACKAGE_INVALID
threadlib=""
case $with_thread_package in
    yes|posix|pthreads|solaris|uti)
        AC_CHECK_HEADERS(pthread.h)
        AC_CHECK_LIB([pthread],[pthread_key_create],[threadlib="-lpthread"])
        THREAD_PACKAGE_NAME=THREAD_PACKAGE_POSIX
        ;;
    win|windows)
        with_thread_package=win
        THREAD_PACKAGE_NAME=THREAD_PACKAGE_WIN
        AC_MSG_ERROR([The 'win' thread package is not supported via autoconf builds at this time.])
        ;;
    abt|argobots)
        with_thread_package=argobots
        PAC_CHECK_HEADER_LIB_FATAL([argobots], [abt.h], [abt], [ABT_key_create])
        threadlib="-labt"
        THREAD_PACKAGE_NAME=THREAD_PACKAGE_ARGOBOTS
        ;;
    no|none)
        with_thread_package=none
        THREAD_PACKAGE_NAME=THREAD_PACKAGE_NONE
        ;;
    *)
	AC_MSG_ERROR([The specified thread package, $with_thread_package, is not supported.])
        ;;
esac

# Define and export the selected thread library so that other packages
# know what's used
AC_DEFINE_UNQUOTED([THREAD_PACKAGE_NAME],[$THREAD_PACKAGE_NAME],[set to the name of the thread package])
AC_SUBST(threadlib)

# Check for h_addr or h_addr_list.  This is needed for the singjoin test
# in manual/singjoin.c
AC_CACHE_CHECK([whether struct hostent contains h_addr_list],
dnl Use Double quote LANG_PROGRAM
dnl so [] in h_addr_list[0] won't be ignored by IFELSE.
pac_cv_have_haddr_list,[
AC_COMPILE_IFELSE([
   AC_LANG_PROGRAM([#include <netdb.h>],[[
      struct hostent hp;
      hp.h_addr_list[0]=0;
   ]])
],[pac_cv_have_haddr_list=yes],[pac_cv_have_haddr_list=no])
])
if test "$pac_cv_have_haddr_list" = "yes" ; then
    AC_DEFINE(HAVE_H_ADDR_LIST,1,[Define if struct hostent contains h_addr_list])
fi

AC_CHECK_FUNCS(getrusage)

# Check for the MPI Version.  This test assumes at least MPI 2.0.  For
# some tests, we need to know if we are MPI 2.1 or MPI 2.2,
# particularly for new routines in Fortran
if test "$FROM_MPICH" != "yes" ; then
    AC_CACHE_CHECK([that MPI program can be compiled],pac_cv_mpi_compile_ok,[
AC_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)])
    if test "$pac_cv_mpi_compile_ok" != yes ; then
        AC_MSG_ERROR([Unable to compile an MPI program containing mpi.h!])
    fi
    AC_CACHE_CHECK([for major version of MPI],pac_cv_mpi_major_version,[
for pac_cv_mpi_major_version in 3 2 1 unknown ; do
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "mpi.h"],[
#if MPI_VERSION == $pac_cv_mpi_major_version 
    ''' force failure '''
#endif])],,break)
done
])

    AC_CACHE_CHECK([for minor version of MPI],pac_cv_mpi_minor_version,[
for pac_cv_mpi_minor_version in 4 3 2 1 0 unknown ; do
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "mpi.h"],[
#if MPI_SUBVERSION == $pac_cv_mpi_minor_version 
    ''' force failure '''
#endif])],,break)
done
])
MPI_VERSION=$pac_cv_mpi_major_version
MPI_SUBVERSION=$pac_cv_mpi_minor_version
else
    # We are within the MPICH build.  Extract the MPI versions from 
    # mpi.h.in	
    if test ! -f $mpich_top_srcdir/src/include/mpi.h.in ; then
        AC_MSG_ERROR([Could not find the required mpi.h.in file!])
    fi
    MPI_VERSION=`grep MPI_VERSION $mpich_top_srcdir/src/include/mpi.h.in | \
    		      sed -e 's/#define *MPI_VERSION *\([0-4]\).*/\1/g'`
    MPI_SUBVERSION=`grep MPI_SUBVERSION $mpich_top_srcdir/src/include/mpi.h.in | \
    		      sed -e 's/#define *MPI_SUBVERSION *\([0-9]\).*/\1/g'`
fi

AC_SUBST(MPI_VERSION)
AC_SUBST(MPI_SUBVERSION)

# Running Fortran 77 compiler tests
AC_PROG_F77
if test "$enable_f77" = yes ; then
    # If there is no working F77, then set enable_f77 to no
    if test -z "$F77" ; then
        enable_f77=no
    fi    
fi
# Simple tests for which other languages we can handle.  
# Use these only when configuring separate from an MPICH build
f77dir="#"
AC_SUBST(f77dir)
buildingF77=no
if test "$FROM_MPICH" = yes ; then
    if test "$enable_f77" = yes ; then
       # Assume success
        otherlangs="$otherlangs f77"
        f77dir=f77
        buildingF77=yes
    fi
elif test "$enable_f77" = yes ; then
    AC_MSG_CHECKING([that we can build MPI programs with Fortran 77])
    AC_LANG_PUSH([Fortran 77])
    AC_LINK_IFELSE([
        AC_LANG_SOURCE([
            program main
            include 'mpif.h'
            integer ierr
            call mpi_init(ierr)
            call mpi_finalize(ierr)
            end
        ])
    ],[
        AC_MSG_RESULT(yes)
        otherlangs="$otherlangs f77"
        f77dir=f77
        buildingF77=yes
    ],[
        AC_MSG_RESULT(no)
    ])
    AC_LANG_POP([Fortran 77])
fi
#
# At least one test (C++ test of C and Fortran datatypes) needs to 
# know if Fortran is supported
if test "$f77dir" = "f77" ; then
    AC_DEFINE(HAVE_FORTRAN_BINDING,1,[Define if Fortran is supported])
fi


AC_ARG_VAR([MPI_SIZEOF_AINT],[if set, force MPI_Aint to a width of this many bytes])
AC_ARG_VAR([MPI_SIZEOF_OFFSET],[if set, force MPI_Offset to a width of this many bytes])

# Common tests for F77
if test "$buildingF77" = "yes" ; then
    # Match integer types to the MPI types for MPI_Aint and MPI_Offset

    # FIXME: Add a test to see if the environment is importing the
    # necessary information.

    # Get the sizes of the MPI types.  We use the following:
    # MPI_SIZEOF_OFFSET and MPI_SIZEOF_AINT
    if test -z "$MPI_SIZEOF_AINT" ; then
        # Aint should be an address-sized integer, the same as void*
        # We use a test on the size of void * to avoid any complications
        # in dealing with running programs containing MPI headers (e.g.,
        # the IBM MPI changes the main entry point so that MPI 
        # programs cannot be run on the host node)
        AC_CHECK_SIZEOF(void *)
        MPI_SIZEOF_AINT=$ac_cv_sizeof_void_p
    fi
    if test -z "$MPI_SIZEOF_OFFSET" ; then
        # We have to try and get the size of offset anyway, since 
        # it is not the same as void * (it depends on the available
        # file systems).  Since we want to avoid using the MPI linker,
        # we could do the following:
        #    Use the mpi compiler to compile the file, using the mpi 
        #    header but no MPI calls
        #    Use the regular C linker to link the program
        # However, we do this only if the environment variable BASECC
        # has been provided.  Else we can try the following:
        # use
        #    sed -n 's/typedef \(.*\) MPI_Offset *;/\1/p' mpi.h
        # to extract the type corresponding to MPI_Offset and then
        # just use that.
dnl         AC_CACHE_CHECK([the sizeof MPI_Offset],ac_cv_sizeof_MPI_Offset,[
dnl              ac_cv_sizeof_MPI_Offset=unknown
dnl              rm -f conftest*
dnl              cat >>conftest.c <<EOF
dnl #include "mpi.h"
dnl #include <stdio.h>
dnl int main( int argc, char **argv )
dnl {
dnl     MPI_Offset a;
dnl     FILE *f = fopen("conftestval", "w" );
dnl     if (! f) exit(1);
dnl     fprintf( f, "%ld\n", (long)sizeof(MPI_Offset) );
dnl     fclose(f);
dnl     return 0;
dnl }
dnl EOF
dnl             # FIXME.  Check for BASECC
dnl             # Note: This assumes that CC has been set to the C compiler for
dnl             # MPI Programs, and that either any necessary include paths are 
dnl             # already set or they are in CPPFLAGS (preferred) or CFLAGS.
dnl             if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext ; then
dnl                 if ./conftest$ac_exeext ; then
dnl                     #success
dnl                     ac_cv_sizeof_MPI_Offset=`cat conftestval`
dnl                 else
dnl                     # failure
dnl                     AC_MSG_WARN([Unable to run the program to determine the size of MPI_Offset])
dnl                     echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
dnl                     cat conftest.c >&AS_MESSAGE_LOG_FD
dnl                 fi
dnl             else
dnl                 # failure
dnl                 AC_MSG_WARN([Unable to build the program to determine the size of MPI_Offset])
dnl                 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
dnl                 cat conftest.c >&AS_MESSAGE_LOG_FD
dnl             fi
dnl             rm -f conftest*
dnl         ])
        AC_CHECK_SIZEOF([MPI_Offset],[],[#include "mpi.h"])
        if test "$ac_cv_sizeof_MPI_Offset" = "unknown" \
             -o "$ac_cv_sizeof_MPI_Offset" -eq 0 ; then
             AC_MSG_WARN([Using 8 for the size of MPI_Offset])
             MPI_SIZEOF_OFFSET=8
        else
             MPI_SIZEOF_OFFSET=$ac_cv_sizeof_MPI_Offset
        fi
    fi
    
    AC_LANG_PUSH([Fortran 77])
    AC_CACHE_CHECK([whether integer*4 is supported],pac_cv_fort_integer4,[
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[      integer*4 i])],
        pac_cv_fort_integer4=yes,
        pac_cv_fort_integer4=no)])
    AC_CACHE_CHECK([whether integer*8 is supported],pac_cv_fort_integer8,[
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[      integer*8 i])],
        pac_cv_fort_integer8=yes,
        pac_cv_fort_integer8=no)])
    AC_CACHE_CHECK([whether integer*16 is supported],pac_cv_fort_integer16,[
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[      integer*16 i])],
        pac_cv_fort_integer16=yes,
        pac_cv_fort_integer16=no)])
    AC_LANG_POP([Fortran 77])

    # Determine Aint and Offset
    for len in 4 8 16 ; do
        eval testval=\$"pac_cv_fort_integer$len"
        if test "$testval" = no ; then continue ; fi
        testval=$len
        if test $len = "$MPI_SIZEOF_AINT" ; then
            F77_MPI_ADDRESS="integer*$len"
        fi
        if test $len = "$MPI_SIZEOF_OFFSET" ; then
            F77_MPI_OFFSET="integer*$len"
        fi
    done
    # At this point, we could create a test program that would confirm that
    # the values in Fortran matched the values in C.
    # Note that we must make this an MPI program because the compiler for
    # MPI programs may require that the programs be run with mpiexec or
    # something similar (this is true for the IBM MPI, for example).
    rm -f f77/init/checksizes.c
    # If it is a VPATH build, f77/init may not be there.
    if test ! -d f77/init ; then
        mkdir f77
        mkdir f77/init
    fi
    cat > f77/init/checksizes.c <<EOF
#include "mpi.h"
#include <stdio.h>
int main( int argc, char **argv ) 
{
  int fsizeof_aint   = $MPI_SIZEOF_AINT;
  int fsizeof_offset = $MPI_SIZEOF_OFFSET;
  int err = 0, rc = 0;
  
  MPI_Init( &argc, &argv );
  if (sizeof(MPI_Aint) != fsizeof_aint) {
     printf( "Sizeof MPI_Aint is %d but Fortran thinks it is %d\n", 
             (int)sizeof(MPI_Aint), fsizeof_aint );
     err++;
  }
  if (sizeof(MPI_Offset) != fsizeof_offset) {
     printf( "Sizeof MPI_Offset is %d but Fortran thinks it is %d\n", 
             (int)sizeof(MPI_Offset), fsizeof_offset );
     err++;
  }
  MPI_Finalize( );
  if (err > 0) rc = 1;
  return rc;
}
EOF

    # Check for name mapping so that we can do the handle conversion tests
    # This test needs both the base c and fortran compilers
    AC_LANG_FORTRAN77
    PAC_PROG_F77_NAME_MANGLE

    # Check that the Fortran compiler will allow us to pass arguments
    # of different types (e.g., for MPI_Send)
    # Any strict Fortran compiler will require that the arguments be 
    # the same type - currently, the NAG Fortran compiler (nagfor) is known
    # to enforce this.
    # We could set the FFLAGS/FCFLAGS values with the option that disables
    # this check (if we found one), but because that may affect other tests,
    # instead we tell the user and exit.
    PAC_PROG_F77_MISMATCHED_ARGS(addarg,yes)
    if test "X$addarg" != "X" ; then
        # We could add the names of all of the MPI routines that 
        # accept different types.  Instead, we fail cleanly.  
        # Some Fortran compilers allow you to turn off checking for 
        # mismatched arguments for *all* routines.  Adding an argument
	# that turns off checking for *everything* is not something that 
	# configure should do - if the user wants this, they can follow
	# the instructions in the following error message.
	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])
    fi

    # Check whether we need -lU77 to get iargc and getarg, which 
    # are used for a few of the tests in spawn (U77 was needed with
    # the native compilers on HPUX.  See the aclocal_f77(old).m4 file, 
    # which has a much more complete set of tests.
    #
    # FIXME: if we can't figure out how to get iargc/getarg, then 
    # we should really turn off those spawn tests
    # Even better is to limit this to the F200x version, where there is
    # an interface to the command line.
    F77SPAWNARGTEST=""
    AC_MSG_CHECKING([for Fortran libraries needed for getarg])
    AC_LANG_CONFTEST([
        AC_LANG_PROGRAM([],[
            character*64 s
            integer i
            i = iargc()
            call getarg(i,s)
        ])
    ])
    AC_LINK_IFELSE([],[
        pac_cv_getarg_needs_u77=no
    ],[
        pac_cv_getarg_needs_u77=unknown
    ])
    if test "$pac_cv_getarg_needs_u77" != "no" ; then
        # Try again with -lU77
        saveLIBS="$LIBS"
        LIBS="$LIBS -lU77"
        AC_LINK_IFELSE([],[
            pac_cv_getarg_needs_u77=yes
        ],[
            pac_cv_getarg_needs_u77=unavailable
        ])
        LIBS="$saveLIBS"
        if test "$pac_cv_getarg_needs_u77" = "yes" ; then
            F77_GETARG_LIBS=-lU77
        fi
    fi
    rm -f conftest$ac_exeext
    if test -n "$F77_GETARG_LIBS" ; then
        AC_MSG_RESULT($F77_GETARG_LIBS)
    else
        if test "$pac_cv_getarg_needs_u77" = "unavailable" ; then 
            AC_MSG_RESULT([getarg and/or iargc are not available.  Some spawn tests will fail to link])
	    F77SPAWNARGTEST="#"
        else 
            AC_MSG_RESULT([none needed])
        fi
    fi
    AC_SUBST(F77_GETARG_LIBS)
    # FIXME: Currently, we hope that FC accepts the same library
    FC_GETARG_LIBS="$F77_GETARG_LIBS"
    AC_SUBST(FC_GETARG_LIBS)
    # F77SPAWNARGTEST is set to "#" to comment out tests in 
    # f77/spawn/testlist.in that require non-standard extensions to 
    # access the commandline
    AC_SUBST(F77SPAWNARGTEST)

    # ALLOCMEMF is set in f77/ext/testlist if we can try this
    # Fortran extension
    ALLOCMEMF=""
    PAC_PROG_F77_CRAY_POINTER([
        ALLOCMEMF="allocmemf 1"
        FFLAGS="$FFLAGS $CRAYPTR_FFLAGS"
    ])
    AC_SUBST(ALLOCMEMF)
    # See the f90 block of code for the Fortran 90 version of ALLOCMEMF,
    # i.e. ALLOCMEMFC.

fi
# Set a default for the Fortran 77 version of MPI_Offset.
if test -z "$F77_MPI_OFFSET" ; then
    F77_MPI_OFFSET="integer*8"
    AC_MSG_WARN([Selecting integer*8 as the Fortran type for MPI_Offset])
fi
AC_SUBST(F77_MPI_OFFSET)
# FIXME: Find a way to get the correct value
if test -z "$F77_MPI_ADDRESS" ; then
    F77_MPI_ADDRESS="integer"
    AC_MSG_WARN([Selecting integer as the Fortran type for MPI_Aint])
fi
AC_SUBST(F77_MPI_ADDRESS)

# Running Fortran 90+ compiler tests
AC_PROG_FC
if test "$enable_fc" = yes ; then
    # Work around feature in autoconf that adds -g -O2 to FCFLAGS
    saveFCFLAGS="$FCFLAGS"
    FCFLAGS="$saveFCFLAGS"
    # If there is no working FC, then set enable_fc to no
    if test -z "$FC" ; then
        enable_fc=no
    fi
fi
f90dir="#"
AC_SUBST(f90dir)
# First, see if we have an f90 compiler.  This uses code similar to that
# in the MPICH top-level configure
if test "$enable_fc" = yes -a "$enable_f77" = yes ; then
    PAC_PROG_FC_WORKS
    if test -z "$FC" -o "$pac_cv_prog_fc_works" != yes ; then
        enable_fc=no
    fi
fi

dnl If enable_fc=yes up to this point then enable_f77=yes also
dnl PAC_PROG_FC and PAC_PROG_FC_WORKS return OK
if test "$enable_fc" = yes ; then
    # Make sure that the compilers are compatible.  This 
    # will also make sure that the program named in FC is
    # a working Fortran 90 compiler
    # Only check if we're *not* building within MPICH 
    # (MPICH will have made the test)
    # FIXME: Do we want to check only simple routine names 
    # (those without an underscore?)
    if test "$FROM_MPICH" != yes ; then
        PAC_FC_AND_F77_COMPATIBLE(enable_fc=yes,enable_fc=no)
    fi
fi

if test "$enable_fc" = yes ; then
    if test "$ac_fc_srcext" != "f90" ; then
        AC_LANG_PUSH([Fortran])
        AC_FC_SRCEXT([f90],[
            FCFLAGS="$FCFLAGS $FCFLAGS_f90"
        ],[
            AC_MSG_WARN([Fortran 90 test being disabled because the $FC compiler does not accept a .f90 extension])
            f90dir=#
            enable_fc=no
        ])
        AC_LANG_POP([Fortran])
    fi

    # The Fortran90 tests rely on free-form input which needs to be tested
    # before any test that may modify FCFLAGS, e.g. the cray-pointer test.
    # The order of the tests is important in compiler like g95.
    # Recent experience showed that the IBM xlf compiler, at least on 
    # some systems, requires -qfree=f90 instead of -qfree .  At this
    # writing (11/27/12), this Autoconf macro still uses -qfree and has
    # no mechanism for extension.  This test may fail in that case; if
    # you encounter a problem, document it and submit it to the autoconf
    # bug list, not the MPICH bug list.
    AC_FC_FREEFORM

    # See if the compiler supports the Cray-style pointers
    ALLOCMEMFC=""
    PAC_PROG_FC_CRAY_POINTER([
        ALLOCMEMFC="allocmemf90 1"
        FCFLAGS="$FCFLAGS $CRAYPTR_FCFLAGS"
    ])
    AC_SUBST(ALLOCMEMFC)

    # Check for the new command line routines used in one of the spawn tests
    AC_LANG_PUSH([Fortran])
    F03SPAWNARGTEST=""
    AC_MSG_CHECKING([whether $FC supports the Fortran 2003 routines to access the commandline])
    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[
            character*64 s
            integer i
            i = command_argument_count()
            call get_command_argument(i,s)
        ])],[pac_cv_fc_has_args=yes],[pac_cv_fc_has_args=no])
    AC_MSG_RESULT($pac_cv_fc_has_args)
    if test "$pac_cv_fc_has_args" != "yes" ; then
        F03SPAWNARGTEST="#"
    fi      
    # F03SPAWNARGTEST is set to "#" to comment out tests in 
    # f90/spawn/testlist.in that require Fortran 2003 features to 
    # access the commandline
    AC_SUBST(F03SPAWNARGTEST)
    AC_LANG_POP([Fortran])

    if test -f f77/init/checksizes.c ; then
        # If it is a VPATH build, f90/init may not be there.
        if test ! -d f90/init ; then
            mkdir f90
            mkdir f90/init
        fi
        cp f77/init/checksizes.c f90/init
    fi
    # At least one of the Fortran 90 tests makes use of a module; this
    # allows us to find it to delete the created object file
    PAC_FC_MODULE
fi
#
if test "$FROM_MPICH" = yes ; then
    if test "$enable_fc" = yes ; then
        otherlangs="$otherlangs f90"
        f90dir=f90
    fi
elif test "$enable_fc" = yes ; then
    AC_MSG_CHECKING([that we can build MPI programs with Fortran 90])
    AC_LANG_PUSH([Fortran])
    AC_LINK_IFELSE([
        AC_LANG_SOURCE([
            program main
            use mpi
            integer ierr
            call mpi_init(ierr)
            call mpi_finalize(ierr)
            end
        ])
    ],[
        AC_MSG_RESULT(yes)
        otherlangs="$otherlangs f90"
        f90dir=f90
    ],[
        AC_MSG_RESULT(no)
    ])
    AC_LANG_POP([Fortran])
fi

if test "$enable_f08" = "yes" ; then
    PAC_FC_2008_SUPPORT([enable_f08=yes],[enable_f08=no])
fi

f08dir="#"
AC_SUBST(f08dir)
# FIXME if $FROM_MPICH is no, we should test build an MPI F08 program
if test "$enable_f08" = "yes" -a "$FROM_MPICH" = "yes" ; then
   f08dir=f08
fi

# Running C++ compiler tests
AC_PROG_CXX
if test "$enable_cxx" = yes ; then
    if test -z "$CXX" ; then
        enable_cxx=no
    fi
fi
# Simple tests for which other languages we can handle
cxxdir="#"
# The C++ interface added support for the Distgraph routines in MPI-2.2,
# but not all MPI implementations support that.  nocxxdistgraph allows
# us to detect that and to skip the test when it is not supported.
nocxxdistgraph="#"
AC_SUBST(cxxdir)
if test "$FROM_MPICH" = yes ; then
    if test "$enable_cxx" = yes ; then
        otherlangs="$otherlangs cxx"
        cxxdir=cxx
        # MPICH ABI removed support for MPI::Distgraphcomm, so
	# nocxxdistgraph is left as #, which comments out the test
	# in cxx/topol/testlist.in
    fi
elif test "$enable_cxx" = yes ; then
    AC_MSG_CHECKING([that we can build MPI programs with C++])
    AC_LANG_PUSH([C++])
    AC_LINK_IFELSE([
        AC_LANG_PROGRAM([
#include "mpi.h"
        ],[
    MPI::Init();
    MPI::Finalize();
        ])
    ],[
        AC_MSG_RESULT(yes)
        otherlangs="$otherlangs cxx"
        cxxdir=cxx
    ],[
        AC_MSG_RESULT(no)
    ])
    # Check for support of the Distgraphcomm, added in MPI 2.2.
    # Some MPI implementations may support MPI 2.2 or MPI 3.x, but not
    # support the Distgraphcomm C++ interface
    AC_MSG_CHECKING([whether MPI C++ includes Distgraphcomm])
    AC_COMPILE_IFELSE([
        AC_LANG_PROGRAM([
#include "mpi.h"
        ],[
    MPI::Distgraphcomm dcomm;
    MPI::Init();
    MPI::Finalize();
        ])
    ],[
        AC_MSG_RESULT(yes)
        nocxxdistgraph=""
    ],[
        AC_MSG_RESULT(no)
    ])

    AC_LANG_POP([C++])
fi
AC_SUBST(nocxxdistgraph)

if test "$enable_cxx" = yes ; then
    AC_CACHE_CHECK([whether <iostream> available],pac_cv_cxx_has_iostream,[
    AC_LANG_PUSH([C++])
    AC_COMPILE_IFELSE([
        AC_LANG_PROGRAM([#include <iostream>],[using namespace std;])
    ],[pac_cv_cxx_has_iostream=yes],[pac_cv_cxx_has_iostream=no])
    ])

    if test "$pac_cv_cxx_has_iostream" = yes ; then
        AC_DEFINE(HAVE_IOSTREAM,1,[Define if iostream is available])
    else
        # Look for iostream.h (in C++ mode, we need the full name)
        AC_CHECK_HEADERS(iostream.h)
        if test "$ac_cv_header_iostream_h" != yes ; then
            AC_MSG_ERROR([C++ compiler $CXX $CXXFLAGS has neither iostream nor iostream.h.])
        fi
        # Warning: the autoconf macros will fall back onto /lib/cpp for
        # C and C++ preprocessing *without* checking that /lib/cpp even
        # exists.  
        if test "$CXXCPP" = "/lib/cpp" ; then
            if test ! -x "/lib/cpp" ; then
                AC_MSG_WARN([Warning: Autoconf error, could not find a C++ Preprocessor.  Using false for the preprocessor so that tests will continue.])
                CXXCPP=false
            fi
        fi
    fi

    AX_CXX_NAMESPACE_STD
   
    if test "$ac_cv_cxx_namespaces" != yes ; then 
        AC_MSG_WARN([The compiler $CXX does not support C++ namespaces.  This may cause problems for the tests])
    fi
    AC_LANG_POP([C++])
fi

AC_LANG_C

LT_INIT()

# IO
iodir="#"
if test "$enable_romio" != no ; then
    iodir=io
    AC_DEFINE(HAVE_MPI_IO,1,[Define if MPI-IO (really ROMIO) is included])
    if test "$FROM_MPICH" = yes ; then
        # MPICH no longer uses and MPIO_Request
        pac_cv_have_mpio_request=no
    else 
        AC_CACHE_CHECK([whether MPIO_Request is defined for MPI IO],
        pac_cv_have_mpio_request,[
            AC_COMPILE_IFELSE([
                AC_LANG_PROGRAM([#include "mpi.h"],[MPIO_Request r;])
            ],[pac_cv_have_mpio_request=yes],[pac_cv_have_mpio_request=no])
        ])
    fi
    if test "$pac_cv_have_mpio_request" = no ; then
        AC_DEFINE(MPIO_USES_MPI_REQUEST,,[Define if MPI IO uses MPI_Request])
    fi
fi
AC_SUBST(iodir)

impldir="#"
#
# Check for implementation to enable implementation-specific options
if test $enable_strictmpi != "yes" ; then
   # Is this MPICH?
   if test "$FROM_MPICH" = yes ; then
      impldir="mpich"
   else
       AC_CACHE_CHECK([Is the MPI derived from MPICH],
       pac_cv_ismpich,[
           AC_COMPILE_IFELSE([
               AC_LANG_PROGRAM([#include "mpi.h"],[return 1 + MPICH;])
           ],[pac_cv_ismpich=yes],[pac_cv_ismpich=no])
       ])
       if test "$pac_cv_ismpich" = "yes" ; then
           impldir="mpich"
       fi
   fi
fi
AC_SUBST(impldir)
#
# MPI_INTEGER16 is mentioned in only one place in MPI 2.1, and some
# implementations may have missed it.  Check to see if it is available in 
# C.
if test "$FROM_MPICH" = yes ; then
   # MPICH correctly includes this type.
   pac_cv_have_mpi_integer16=yes
else
    AC_CACHE_CHECK([whether MPI_INTEGER16 is available],
    pac_cv_have_mpi_integer16,[
        AC_COMPILE_IFELSE([
            AC_LANG_PROGRAM([#include "mpi.h"],[
                MPI_Datatype t = MPI_INTEGER16;
            ])
        ],[pac_cv_have_mpi_integer16=yes],[pac_cv_have_mpi_integer16=no])
    ])
fi
if test "$pac_cv_have_mpi_integer16" = yes ; then 
    AC_DEFINE(HAVE_MPI_INTEGER16,1,[Define if MPI_INTEGER16 is available])
fi

# MPI_Aint was intended as an address-sized int.  However, MPI didn't 
# specify this - MPI_Aint must be large enough to hold an address-sized
# integer, but it can be larger.  To get clean compilation in some places,
# we need a pointer-sized integer.  The following code looks for one.

# Make sure we are using the local C compiler (if the local
# machine is different that the system that MPICC is for, then
# set the cross-compilation feature)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(short)
POINTERINT=MPI_Aint
AC_MSG_CHECKING([for C integer type of address size])
for type in int long long_long short ; do
    eval len=\$ac_cv_sizeof_$type
    if test "$len" = "$ac_cv_sizeof_void_p" ; then
        POINTERINT=`echo $type | sed -e 's/_/ /'`
        break
    fi
done
AC_MSG_RESULT($POINTERINT)
AC_DEFINE_UNQUOTED(POINTERINT_t,$POINTERINT,[POINTERINT_t is a pointer-sized integer])

# Find perl; used to create some of the tests from template and 
# definition files
AC_PATH_PROG(PERL,perl)
AC_SUBST(PERL)
AC_SUBST(otherlangs)
AC_SUBST(threadsdir)
AC_SUBST(MPIEXEC)
AC_SUBST(MAKE)
if test -z "$MPILIBNAME" ; then MPILIBNAME=mpich ; fi
AC_SUBST(MPILIBNAME)
dnl MPI_SOURCE may be set as an environment variable giving the location
dnl of the MPI implementation.  This is used only in runtests to include
dnl the location of the source of the MPI implementation into the XML
dnl summary file
AC_SUBST(MPI_SOURCE)

if test "$FROM_MPICH" = yes ; then
    # Set compilers/flags to be substituted in output files, e.g. Makefiles.
    LDFLAGS="$saveLDFLAGS"
    # note that the default definition of bindir is 
    #    '${exec_prefix}/bin'
    # so even if prefix is set, exec prefix is not until
    # the very last moment (i.e., not here). 
    if test "X$exec_prefix" = "XNONE" ; then
        saveExec_prefix=$exec_prefix
        if test "X$prefix" = "XNONE" ; then
            # Use the default
            exec_prefix=$ac_default_prefix
        else
            exec_prefix=$prefix
        fi
        # Evaluate with the current setting of exec_prefix
        eval mpibindir=${bindir}
        exec_prefix=$saveExec_prefix
    else
        eval mpibindir=${bindir}
    fi

    # we did our tests with the base compilers, now point the make system at the
    # installed compiler wrappers for actually building the tests
    CC=$mpibindir/$MPICC_NAME
    F77=$mpibindir/$MPIF77_NAME
    FC=$mpibindir/$MPIFORT_NAME
    CXX=$mpibindir/$MPICXX_NAME
    if test -z "$MPIEXEC" ; then
        MPIEXEC=$mpibindir/$MPIEXEC_NAME
    fi

    # Zero out the flags, since they are already contained in the compiler
    # wrapper scripts.  Note that this will kill any flags that have been added
    # to the xFLAGS only in this script.
    #
    # The only real flags we seem to add in this script relate to cray
    # pointer support in Fortran, so we include that var here where
    # appropriate.
    #
    # The other case are the performance tests - for datatype performance,
    # compiling with optimization is important.
    CFLAGS=""
    CPPFLAGS=""
    LDFLAGS=""
    LIBS=""
    FFLAGS="$CRAYPTR_FFLAGS"
    FCFLAGS="$CRAYPTR_FCFLAGS"
    CXXFLAGS=""
else
    # We need either mpiexec or mpirun.  If we don't find them,
    # the user will need to determine how to run a program
    AC_PATH_PROG(MPIEXEC,$MPIEXEC_NAME)
fi

# TODO: use variables such as has_f77 etc. instead of double use $f77dir etc.
AM_CONDITIONAL([HAS_F77], [test $f77dir = f77])
AM_CONDITIONAL([HAS_F90], [test $f90dir = f90])
AM_CONDITIONAL([HAS_F08], [test $f08dir = f08])
AM_CONDITIONAL([HAS_CXX], [test $cxxdir = cxx])

AC_CONFIG_COMMANDS([chmod],[
    chmod a+x maint/testmerge
    chmod a+x runtests checktests
    chmod a+x manual/manyconnect
    chmod a+x impls/hydra/proc_binding.sh
])
dnl Note that this format for AC_OUTPUT can cause problems for autoconf
dnl run under cygwin
AC_OUTPUT(maint/testmerge \
          runtests \
          checktests \
          Makefile \
          basic/Makefile \
          attr/Makefile \
          attr/testlist \
          util/Makefile \
          coll/Makefile \
	  coll/testlist \
          comm/Makefile \
          comm/testlist \
          datatype/Makefile \
          datatype/testlist \
          errhan/Makefile \
          group/Makefile \
          info/Makefile \
          init/Makefile \
          pt2pt/Makefile \
          pt2pt/testlist \
          part/Makefile  \
          mpi_t/Makefile \
          rma/Makefile \
          rma/testlist \
          spawn/Makefile \
          spawn/testlist \
          topo/Makefile \
          io/Makefile \
          io/testlist \
          f77/Makefile \
          f77/attr/Makefile \
          f77/attr/attraints.h \
          f77/pt2pt/attr1aints.h \
          f77/ext/add1size.h \
          f77/datatype/Makefile \
          f77/datatype/typeaints.h \
          f77/coll/Makefile \
          f77/comm/Makefile \
          f77/topo/Makefile \
          f77/init/Makefile \
          f77/rma/addsize.h \
          f77/pt2pt/Makefile \
          f77/info/Makefile \
          f77/spawn/Makefile \
	  f77/spawn/testlist \
          f77/spawn/type1aint.h \
          f77/rma/Makefile \
          f77/ext/Makefile \
          f77/ext/testlist \
          f77/io/Makefile \
          f77/io/iooffset.h \
          f77/io/iodisp.h \
          f77/io/ioaint.h \
          f77/io/testlist \
	  f77/profile/Makefile \
          f90/Makefile \
          f90/attr/Makefile \
          f90/datatype/Makefile \
          f90/f90types/Makefile \
          f90/coll/Makefile \
          f90/comm/Makefile \
          f90/topo/Makefile \
          f90/init/Makefile \
          f90/pt2pt/Makefile \
          f90/rma/Makefile \
          f90/info/Makefile \
          f90/spawn/Makefile \
	  f90/spawn/testlist \
          f90/timer/Makefile \
          f90/ext/Makefile \
          f90/ext/testlist \
          f90/io/Makefile \
          f90/io/testlist \
          f90/misc/Makefile \
	      f90/profile/Makefile \
	  f08/Makefile \
	      f08/attr/Makefile \
	      f08/datatype/Makefile \
	      f08/coll/Makefile \
	      f08/comm/Makefile \
	      f08/pt2pt/Makefile \
	      f08/rma/Makefile \
	      f08/subarray/Makefile \
	      f08/topo/Makefile \
	      f08/io/Makefile \
	      f08/io/testlist \
          f08/init/Makefile \
          f08/info/Makefile \
          f08/spawn/Makefile \
          f08/spawn/testlist \
          f08/timer/Makefile \
          f08/ext/Makefile \
          f08/misc/Makefile \
          f08/profile/Makefile \
     cxx/Makefile \
          cxx/attr/Makefile \
          cxx/attr/testlist \
          cxx/pt2pt/Makefile \
          cxx/comm/Makefile \
          cxx/coll/Makefile \
	  cxx/errhan/Makefile \
          cxx/info/Makefile \
          cxx/datatype/Makefile \
          cxx/datatype/testlist \
          cxx/io/Makefile \
          cxx/init/Makefile \
          cxx/rma/Makefile \
          cxx/spawn/Makefile \
          cxx/spawn/testlist \
	  cxx/topo/Makefile \
          threads/Makefile \
          threads/pt2pt/Makefile \
          threads/comm/Makefile \
          threads/comm/testlist \
          threads/init/Makefile \
          threads/mpi_t/Makefile \
          threads/spawn/Makefile \
          threads/rma/Makefile \
          threads/coll/Makefile \
          threads/coll/testlist \
          threads/perf/Makefile \
          threads/part/Makefile  \
          errors/Makefile \
          errors/attr/Makefile \
          errors/basic/Makefile \
          errors/coll/Makefile \
          errors/comm/Makefile \
          errors/datatype/Makefile \
          errors/faults/Makefile \
          errors/group/Makefile \
          errors/pt2pt/Makefile \
          errors/rma/Makefile \
          errors/spawn/Makefile \
          errors/spawn/testlist \
          errors/topo/Makefile \
          errors/io/Makefile \
          errors/cxx/Makefile \
          errors/cxx/errhan/Makefile \
          errors/cxx/io/Makefile \
          errors/f77/Makefile \
          errors/f77/io/Makefile \
          errors/f77/io/addsize.h \
          errors/f77/io/iooffset.h \
          errors/f90/Makefile \
	  errors/f90/io/Makefile \
          errors/f08/Makefile \
	  errors/f08/io/Makefile \
	  ckpoint/Makefile \
	  ft/Makefile \
          manual/Makefile \
          manual/manyconnect \
          manual/mpi_t/Makefile \
          perf/Makefile \
          testlist \
          cxx/testlist \
	  cxx/topo/testlist \
          f77/testlist \
          f90/testlist \
          f08/testlist \
          threads/testlist \
          errors/testlist \
          errors/cxx/testlist \
          errors/f77/testlist \
          errors/f90/testlist \
          impls/testlist \
          f77/rma/testlist \
          f90/rma/testlist \
          f08/rma/testlist \
          impls/Makefile \
          impls/hydra/Makefile \
          impls/hydra/proc_binding.sh \
          impls/mpich/Makefile \
          impls/mpich/testlist \
          impls/mpich/mpi_t/Makefile \
          impls/mpich/comm/Makefile \
          impls/mpich/comm/testlist \
          impls/mpich/threads/Makefile \
          impls/mpich/threads/pt2pt/Makefile \
          )