File: configure.in

package info (click to toggle)
lam 6.5.6-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 15,464 kB
  • ctags: 11,670
  • sloc: ansic: 101,210; cpp: 12,146; sh: 10,821; makefile: 4,050; fortran: 218
file content (1760 lines) | stat: -rw-r--r-- 52,463 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
# -*- shell-script -*-
# Process this file with autoconf to produce a configure script.

# This file is part of the University of Notre Dame implementation of
# LAM/MPI.  See the LICENSE file in the top-level directory for
# license and copyright details.

# Disable caching.
define([AC_CACHE_LOAD], )#
define([AC_CACHE_SAVE], )#

# Init autoconf

AC_INIT(./share/mpi/init.c)
AC_CONFIG_AUX_DIR(./config)

# Init automake
# Get the version of LAM that we are installing
get_version="sh $srcdir/config/get_lam_version $srcdir"
LAM_VERSION="`eval $get_version --full`"
LAM_MAJOR_VERSION="`eval $get_version --major`"
LAM_MINOR_VERSION="`eval $get_version --minor`"
LAM_RELEASE_VERSION="`eval $get_version --release`"
LAM_ALPHA_VERSION="`eval $get_version --alpha`"
LAM_BETA_VERSION="`eval $get_version --beta`"
AC_DEFINE_UNQUOTED(LAM_MAJOR_VERSION, $LAM_MAJOR_VERSION)
AC_DEFINE_UNQUOTED(LAM_MINOR_VERSION, $LAM_MINOR_VERSION)
AC_DEFINE_UNQUOTED(LAM_RELEASE_VERSION, $LAM_RELEASE_VERSION)
AC_DEFINE_UNQUOTED(LAM_ALPHA_VERSION, $LAM_ALPHA_VERSION)
AC_DEFINE_UNQUOTED(LAM_BETA_VERSION, $LAM_BETA_VERSION)
AC_DEFINE_UNQUOTED(LAM_VERSION, "$LAM_VERSION")
# Need to also AC_SUBST these for share/include/patchlevel.h and
# share/include/mpif.h
AC_SUBST(LAM_MAJOR_VERSION)
AC_SUBST(LAM_MINOR_VERSION)
AC_SUBST(LAM_RELEASE_VERSION)
AC_SUBST(LAM_ALPHA_VERSION)
AC_SUBST(LAM_BETA_VERSION)
AC_SUBST(LAM_VERSION)

echo "Configuring LAM version $LAM_VERSION"

# The third argument to AM_INIT_AUTOMAKE surpresses the PACKAGE and
# VERSION macors

AM_INIT_AUTOMAKE(lam, $LAM_VERSION, 'no')
AM_CONFIG_HEADER(share/include/lam_config.h)

# Make automake clean emacs ~ files for "make clean"

CLEANFILES="*~"
AC_SUBST(CLEANFILES)

# For debugging

AC_ARG_ENABLE(echo, [  --enable-echo           echo configure script commands],
[set -x])

# This is useful later

AC_CANONICAL_HOST
AC_DEFINE_UNQUOTED(LAM_ARCH,"$host")

# See if we can find an old installation of LAM to overwrite

AC_PREFIX_PROGRAM(lamclean)

# Basic sanity checking; we can't install to a relative path

case "$prefix" in
  /*/bin)
    prefix="`dirname $prefix`"
    echo installing to directory \"$prefix\" 
    ;;
  /*) 
    echo installing to directory \"$prefix\" 
    ;;
  NONE)
    echo installing to directory \"$ac_default_prefix\" 
    ;;
  *) 
    AC_MSG_ERROR(prefix \"$prefix\" must be an absolute directory path) 
    ;;
esac

# check for specification of C compiler
AC_ARG_WITH(cc, [  --with-cc=CC            use C compiler CC])

if test -n "$with_cc"; then
    if test $with_cc = yes; then
	AC_MSG_ERROR(the --with-cc option requires the compiler name)
    fi
    CC=$with_cc;
fi

# check for specification of C compiler flags
AC_ARG_WITH(cflags, [  --with-cflags=CFLAGS    use C compiler flags CFLAGS])

if test -n "$with_cflags"; then
    CFLAGS=$with_cflags;
fi
lam_cflags_save="$CFLAGS"

#
# Part one of libtool magic
# Check all the way up here so that we can complain if shared was
# selected with mpi2c++ or ROMIO
#

AM_DISABLE_SHARED

#
# ROMIO is now enabled by default
#

AC_MSG_CHECKING([if want ROMIO support])
ROMIO_BUILD_TARGET=
ROMIO_INSTALL_TARGET=
ROMIO_EXAMPLES=
ROMIO_EXTRALIBS=
WANT_ROMIO=yes
AC_ARG_WITH(romio,
[  --without-romio         disable ROMIO support in LAM/MPI],
[WANT_ROMIO=$withval])
AC_MSG_RESULT([$WANT_ROMIO])
if test "$WANT_ROMIO" = "yes"; then
    ROMIO_BUILD_TARGET=romio-all
    ROMIO_INSTALL_TARGET=romio-install
    ROMIO_EXAMPLES=romio
    AC_DEFINE(LAM_WANT_ROMIO, 1)
    libs_SAVE="$LIBS"
    AC_CHECK_LIB(aio, main, ROMIO_EXTRALIBS="-laio")
    LIBS="$libs_SAVE"
else
    AC_DEFINE(LAM_WANT_ROMIO, 0)
    AC_DEFINE(HAVE_LIBAIO, 0)
fi
AC_SUBST(ROMIO_BUILD_TARGET)
AC_SUBST(ROMIO_INSTALL_TARGET)
AC_SUBST(ROMIO_EXAMPLES)

# If we want ROMIO, see if there are any flags to pass through to its
# configure script

ROMIO_USER_FLAGS=
AC_ARG_WITH(romio-flags,
[  --with-romio-flags=FLAGS pass FLAGS to ROMIO's configure script],
[ROMIO_USER_FLAGS=$withval])
# Stoopid emacs mode: '
if test "$WANT_ROMIO" = "yes"; then
    AC_MSG_CHECKING([for user ROMIO flags])
    if test "$ROMIO_USER_FLAGS" = ""; then
	AC_MSG_RESULT([none])
    else
	AC_MSG_RESULT([$ROMIO_USER_FLAGS])
    fi
fi
AC_SUBST(ROMIO_USER_FLAGS)

# See if we want the C++ bindings
# If we do not want the C++ bindings, skip all other C++ tests
# (compiler, flags, etc.)
AC_MSG_CHECKING([if want MPI 2 C++ support])
MPI2CPP_BUILD_TARGET=
MPI2CPP_INSTALL_TARGET=
MPI2CPP_EXAMPLES=
WANT_MPI2CPP=yes
WANT_CPP_EXCEPTIONS=no
MPI2CPP_CONFIGURE_EXFLAGS="--without-exflags"
AC_ARG_WITH(mpi2cpp,
[  --without-mpi2cpp       build LAM without MPI 2 C++ bindings support],
[WANT_MPI2CPP=$withval])
AC_MSG_RESULT([$WANT_MPI2CPP])

# check for specification of C++ compiler and C++ compiler flags
# Have to do things a little out of order here; may seem a little strange
AC_ARG_WITH(cxx, [  --with-cxx=CXX          use C++ compiler CXX])
AC_ARG_WITH(cxxflags, [  --with-cxxflags=CXXFLAGS use C++ compiler flags CXXFLAGS])
AC_ARG_WITH(exceptions, [  --with-exceptions       enable support for C++ exceptions])

if test "$with_mpi2cpp" = "" -o "$with_mpi2cpp" = "yes"; then
    AC_DEFINE(LAM_WANT_MPI2CPP, 1)
else
    AC_DEFINE(LAM_WANT_MPI2CPP, 0)
fi

#
# Now that we know if we want MPI2C++ and/or ROMIO, check if the user
# asked for shared libraries.
#

if test "$WANT_ROMIO" = "yes" -o "$WANT_MPI2CPP" = "yes"; then
    # Ick -- we had to dive into AC_DISABLE_SHARED to figure this out :-(
    if test "$enable_shared" = "yes"; then
	AC_MSG_WARN([*** Unfortunately, the MPI 2 C++ bindings and ROMIO cannot])
	AC_MSG_WARN([*** cannot be built with shared memory support.  :-(])
	AC_MSG_WARN([*** You must select to only build static libraries,])
	AC_MSG_WARN([*** or disable ROMIO and the MPI 2 C++ bindings.])
	AC_MSG_WARN([*** See the INSTALL file for details.])
	AC_MSG_ERROR([*** Cannot continue.])
    fi
fi

# Check if we want IMPI support
# Default: no

WANT_IMPI=no
AC_MSG_CHECKING([if want IMPI support])
AC_ARG_WITH(impi, 
[  --with-impi             compile with IMPI support (6.4.x only)], [WANT_IMPI=$withval])
AM_CONDITIONAL(WANT_IMPI_BUILD, test "$WANT_IMPI" = "yes")
if test "$WANT_IMPI" = "yes"; then
    IMPI_LIB="impi/liblamimpi.la"
    IMPI_DIR="impi"
    IMPID_DIR="impid"
    AC_DEFINE(LAM_WANT_IMPI, 1)
else
    IMPI_LIB=""
    IMPI_DIR=""
    IMPID_DIR=""
    AC_DEFINE(LAM_WANT_IMPI, 0)
fi
AC_SUBST(IMPI_LIB)
AC_SUBST(IMPI_DIR)
AC_SUBST(IMPID_DIR)
AC_SUBST(IMPI_OBJS)
AC_MSG_RESULT([$WANT_IMPI])


# Now that we have established whether we want IMPI and/or MPI 2
# C++, we can decide if we want to check for the C++ compiler or not

if test "$WANT_MPI2CPP" = "yes" -o "$WANT_IMPI" = "yes"; then
    if test -n "$with_cxx"; then
	if test $with_cxx = yes; then
	    AC_MSG_ERROR(the --with-cxx option requires the compiler name)
	fi
	CXX="$with_cxx"
    fi

    if test -n "$with_cxxflags"; then
	CXXFLAGS="$with_cxxflags"
    fi
fi
lam_cxxflags_save="$CXXFLAGS"


# Check for compilers
# #$%@#%@# autoconf!!!
lam_cflags_save="$CFLAGS"
AC_PROG_CC
BASECC="`basename $CC`"
# Still check for a C++ compiler even if we aren't building the C++
# bindings or IMPI, 'cause we want something to put in hcp.
if test "$CXX" = no; then
    WANT_MPI2CPP=no
    WANT_IMPI=no
    AC_MSG_WARN([*** C++ compiler is disabled.  Automatically disabling])
    AC_MSG_WARN([*** IMPI and the MPI 2 C++ bindings.])
else
    AC_PROG_CXX
fi
BASECXX="`basename $CXX`"
AC_PROG_GCC_TRADITIONAL
CFLAGS="$lam_cflags_save"
CXXFLAGS="$lam_cxxflags_save"

# Check for C++ things
EXTRA_MPICC_FLAGS=
EXTRA_MPIF77_FLAGS=
EXTRA_MPICPP_FLAGS=
if test "$WANT_MPI2CPP" = "yes" -o "$WANT_IMPI" = "yes"; then
    if test "$CXX" = "no"; then
	AC_MSG_ERROR([Cannot install MPI 2 C++ bindings without a C++ compiler])
    else
	if test "$WANT_MPI2CPP" = "yes"; then
	    MPI2CPP_BUILD_TARGET=mpi2c++-all
	    MPI2CPP_INSTALL_TARGET=mpi2c++-install
	    MPI2CPP_EXAMPLES=mpi2c++
	fi
    fi

    if test "$WANT_IMPI" = "yes"; then
	LSC_CXX_HAVE_NOTHROW_NEW(LAM)
    fi

    # Both IMPI and the C++ bindings require proper exception handling
    if test "$with_exceptions" = "yes"; then
	WANT_CPPEXCEPTIONS=1
    else
	WANT_CPPEXCEPTIONS=0
    fi

    if test "$WANT_CPPEXCEPTIONS" = "1"; then
	LSC_CXX_HAVE_EXCEPTIONS(LAM)
	if test "$LAM_CXX_HAS_EXCEPTIONS" = "1"; then
	    LSC_CXX_FIND_EXCEPTION_FLAGS(LAM)
	    CFLAGS="$CFLAGS $LAM_CXX_EXCEPTION_CXXFLAGS"
	    FFLAGS="$FFLAGS $LAM_CXX_EXCEPTION_CFLAGS"
	    CXXFLAGS="$CXXFLAGS $LAM_CXX_EXCEPTION_CXXFLAGS"
	    MPI2CPP_CONFIGURE_EXFLAGS="--with-exflags=\"$LAM_CXX_EXCEPTION_CXXFLAGS\""
	    LDFLAGS="$LDFLAGS $LAM_CXX_EXCEPTION_LDFLAGS"

	    EXTRA_MPICC_FLAGS="$LAM_CXX_EXCEPTION_CXXFLAGS"
	    EXTRA_MPIF77_FLAGS="$LAM_CXX_EXCEPTION_CXXFLAGS"
	    EXTRA_MPICPP_FLAGS="$LAM_CXX_EXCEPTION_CXXFLAGS"
	fi
    fi
    AC_PROG_CXXCPP
    if test "$WANT_IMPI" = "yes"; then
	LSC_CXX_HAVE_STL(LAM)
	if test "$LAM_CXX_STL" = "0"; then
	    AC_MSG_WARN([*** Your C++ compiler does not seem to support the STL.])
	    AC_MSG_WARN([*** STL support is necessary to compile the IMPI extensions])
	    AC_MSG_WARN([*** to LAM/MPI.  Either choose a C++ compiler that supports])
	    AC_MSG_WARN([*** STL, or configure --without-impi.])
	    AC_MSG_ERROR([cannot continue])
	fi
	LSC_CXX_FIND_TEMPLATE_REPOSITORY(LAM)
	LSC_CXX_HAVE_BOOL(LAM)
	LSC_CXX_HAVE_TRUE_FALSE(LAM)
    fi

    case "$host" in
    *hpux*)
	if test "$BASECXX" = "CC"; then
	    AC_MSG_WARN([*** You will probably have problems compiling the MPI 2])
	    AC_MSG_WARN([*** C++ bindings with the CC compiler.  You should probably])
	    AC_MSG_WARN([*** be using the aCC compiler.  Set the CXX environment])
	    AC_MSG_WARN([*** variable to "aCC" and run ./configure again.])
	fi
	;;
    esac
fi
AC_SUBST(CXX)
AC_SUBST(CXXCPP)
AC_SUBST(MPI2CPP_BUILD_TARGET)
AC_SUBST(MPI2CPP_INSTALL_TARGET)
AC_SUBST(MPI2CPP_EXAMPLES)
AC_SUBST(MPI2CPP_CONFIGURE_EXFLAGS)
AC_SUBST(EXTRA_MPICC_FLAGS)
AC_SUBST(EXTRA_MPIF77_FLAGS)
AC_SUBST(EXTRA_MPICPP_FLAGS)
AC_SUBST(LAM_CXX_TEMPLATE_REPOSITORY)
AC_DEFINE_UNQUOTED(LAM_CC, "$CC")

#
# If we are building IMPI, look for "impi-server" in the path so that
# we can build it into mpirun
#

if test "$WANT_IMPI" = "yes"; then
    AC_CHECK_PROG(IMPI_SERVER, impi-server, impi-server, not found)
    if test "$IMPI_SERVER" = "not found"; then
	AC_MSG_WARN([*** Not able to find the executable 'impi-server' in])
	AC_MSG_WARN([*** your path.  The '-server' option will be disabled])
	AC_MSG_WARN([*** in mpirun.  To run IMPI jobs, you will need to run])
	AC_MSG_WARN([*** the IMPI server independantly of LAM's mpirun.])
	# Stoopid emacs mode: '
	AC_DEFINE(LAM_WANT_IMPI_SERVER, 0)
	AC_DEFINE(LAM_IMPI_SERVER, "")
    else
	AC_DEFINE(LAM_WANT_IMPI_SERVER, 1)
	AC_DEFINE_UNQUOTED(LAM_IMPI_SERVER, "$IMPI_SERVER")
    fi
fi

#
# Do we want the profiling interface?  The default is now yes.  Woof!
#

WANT_PROFILE=yes
AC_ARG_WITH(profiling, [  --without-profiling     disable the MPI profiling interface])
if test -n "$with_profiling"; then
    WANT_PROFILE="$with_profiling"
fi
AC_MSG_CHECKING([if want profiling interface])
AM_CONDITIONAL(WANT_PROFILE_BUILD, test "$WANT_PROFILE" = "yes")
AC_MSG_RESULT([$WANT_PROFILE])
if test "$WANT_ROMIO" = "yes" -a "$WANT_PROFILE" = "no"; then
    AC_MSG_WARN([*** You have selected to build ROMIO and not use the])
    AC_MSG_WARN([*** MPI profiling interface.  This is not currently])
    AC_MSG_WARN([*** supported.  You can either select --without-romio,])
    AC_MSG_WARN([*** or build the profiling interface.  Sorry.])
    AC_MSG_ERROR([Cannot continue])
fi
if test "$WANT_PROFILE" = "yes"; then
    AC_DEFINE(LAM_WANT_PROFILE, 1)
else
    AC_DEFINE(LAM_WANT_PROFILE, 0)
fi

# check if we want all the trillium header files and man pages installed
WANT_TRILLIUM=no
AC_ARG_WITH(trillium, 
[  --with-trillium         enable installation of Trillium header/man/binary
                          files (not required for MPI)])
if test -n "$with_trillium"; then
    WANT_TRILLIUM="$with_trillium"
fi
AC_MSG_CHECKING([if want full installation of Trillium files])
AM_CONDITIONAL(WANT_TRILLIUM_INSTALL, test "$WANT_TRILLIUM" = "yes")
AC_MSG_RESULT([$WANT_TRILLIUM])

# check for specification of LD linker flags
AC_ARG_WITH(ldflags, [  --with-ldflags=LDFLAGS  use LD linker flags LDFLAGS])

if test -n "$with_ldflags"; then
    USER_LDFLAGS="$with_ldflags"
else
    USER_LDFLAGS="$CFLAGS"
fi

# check for specification of C++ LD linker flags
AC_ARG_WITH(ldflags, [  --with-cxxldflags=CXXLDFLAGS  use C++ LD linker flags CXXLDFLAGS])

if test -n "$with_cxxldflags"; then
    USER_CXXLDFLAGS="$with_cxxldflags"
else
    USER_CXXLDFLAGS="$CXXFLAGS"
fi

# check for specification of fortran compiler
AC_ARG_WITH(fc, [  --with-fc=FC            use Fortran compiler FC,
                          specify no to disable Fortran support])

if test -n "$with_fc"; then
    if test "$with_fc" != no; then
	FC="$with_fc"
    fi
fi

# check for specification of Fortran compiler flags
AC_ARG_WITH(fflags, [  --with-fflags=FFLAGS    use Fortran compiler flags FFLAGS])

if test -n "$with_fflags"; then
    FFLAGS="$with_fflags"
fi

#
# Check for "makedepend".  Not everyone has this.
#

AC_CHECK_PROGS(MAKEDEPEND, makedepend, no)

#
# If they have makedepend, find some additional dependency directories
#

LAM_DEPDIRS=
if test "$MAKEDEPEND" != "no"; then
    if test "$WANT_IMPI" = "yes"; then
	LSC_CXX_FIND_DEPDIRS(LAM)
    fi

    # Because linux tends to put stddef.h in weird places
    STDDEF=
    AC_CHECK_HEADERS(stddef.h, STDDEF=stddef.h)
    AC_MSG_CHECKING([for non-standard include directories])

    # Ensure that we have what we need for the normals, just in case...
    LSC_OS_FIND_DEPDIRS(stdio.h stdlib.h $STDDEF, LAM)
    AC_MSG_RESULT([$LAM_OS_DEPDIRS])
    LAM_DEPDIRS="$LAM_CXX_DEPDIRS $LAM_OS_DEPDIRS"
fi
AC_SUBST(LAM_DEPDIRS)

# determine RPI to use
AC_ARG_WITH(rpi, [  --with-rpi=RPI          build with RPI comm layer RPI
                          (where RPI=tcp|sysv|usysv|myri|via -- default is tcp)])

SYSLIBS="$ROMIO_EXTRALIBS"

# Check for -lsocket -lnsl

libs_SAVE="$LIBS"
AC_CHECK_LIB(socket, socket, SYSLIBS="$SYSLIBS -lsocket")
AC_CHECK_LIB(nsl, gethostbyname, SYSLIBS="$SYSLIBS -lnsl")
LIBS="$libs_SAVE"

# OS particular things

case $host in
*irix*) 
    if test "$ac_cv_prog_gcc" = no; then
	LIBBIND="$USER_LDFLAGS -Wl,-woff,84"
	HBIND="$USER_LDFLAGS -Wl,-woff,84"
    fi	
    ;;
*sco-sysv*)
    # This seems to be necessary on SCO unix to get sendmsg and others
    # to compile/link/run properly.  There's a note in
    # /usr/include/socket.h on SCO about this.  Weird.
    CFLAGS="-DSVR4 $CFLAGS"
esac

#
# See if we have SysV semaphores (not all Unixes do *cough* MacOS X
# *cough*).  This must be before the RPI selection logic, as we need to
# abort if the user chooses rpi=SYSV and we don't have SysV semaphores.
#

LAM_HAVE_SYSV_SEMAPHORES=0
AC_CHECK_HEADERS(sys/sem.h, 
  [LAM_HAVE_SYSV_SEMAPHORES=1], [LAM_HAVE_SYSV_SEMAPHORES=0])
AC_DEFINE_UNQUOTED(LAM_HAVE_SYSV_SEMAPHORES, $LAM_HAVE_SYSV_SEMAPHORES)

# Determine the RPI to use
LAM_RPI_REAL_CFLAGS="\"\""
LAM_RPI_REAL_LDFLAGS="\"\""
LAM_RPI_FAKE_CFLAGS=
LAM_RPI_FAKE_LDFLAGS=
AC_MSG_CHECKING([which RPI to use])
if test -z "$with_rpi"; then
  AC_MSG_RESULT([tcp (default)])
  rpi=tcp
else
  if test "$with_rpi" = yes; then
    AC_MSG_RESULT([tcp (default)])
    rpi=tcp
  else
    rpi=$with_rpi

    if test "$LAM_HAVE_SYSV_SEMAPHORES" = "0"; then
	if test "rpi" = "sysv" -o "rpi" = "usysv"; then
	    AC_MSG_WARN([*** SYSV or USYSV rpi selected on a machine without])
	    AC_MSG_WARN([*** SysV semaphores.  Please select another RPI.])
	    AC_MSG_ERROR([*** Cannot continue.])
	fi
    fi

    if test "$rpi" = "sysv" -o "$rpi" = "usysv" -o "$rpi" = "tcp"; then
      AC_MSG_RESULT([$rpi])

    # Put some cleverness here so that we can work on the myri and VIA
    # RPIs in the development tree, but make it unavailable in the
    # distribution 'till we're ready.

    # BE SURE TO UPDATE THE distscript.csh WHEN THESE RPI's ARE READY!!

    elif test "$rpi" = "myri"; then
      if test -f $srcdir/share/rpi/myri/myri.c; then
        AC_MSG_RESULT([$rpi])
      else
	AC_MSG_RESULT([Doh!])
        AC_MSG_ERROR([Sorry, the $rpi RPI is Not Yet Ready for Prime Time.])
      fi
    elif test "$rpi" = "via"; then
      if test -f $srcdir/share/rpi/via/Makefile.am; then
        AC_MSG_RESULT([$rpi])
      else
	AC_MSG_RESULT([Doh!])
        AC_MSG_ERROR([Sorry, the $rpi RPI is Not Yet Ready for Prime Time.])
      fi
    else
      AC_MSG_RESULT([RPI $rpi does not exist.])
      AC_MSG_ERROR([See the INSTALL and RELEASE_NOTES files for details.])
    fi
  fi
fi
AC_SUBST(rpi)

# Check that the RPI is valid and set RPI type definition.
RPI_HAS_MPI_MALLOC=no
WANT_MYRINET=
WANT_VIA=
case $rpi in
  tcp)
    RPI_SUBDIRS="tcp"
    RPI_LIBS="tcp/liblamrpitcp.la"

    RPILIB="liblamrpitcp.la"
    RPILIBMASK="liblamrpitcp.*"
    AC_DEFINE(LAM_RPI_TCP, 1)
  ;;
  sysv) 
    RPI_SUBDIRS="shmem sysv tcp"
    # Note: the rpitcp.la lib will have the same RPI API in it as the
    # rpisysv.la -- so it is important to list the sysv library
    # *first* to take advantage of unix linker semantics
    RPI_LIBS="shmem/liblamrpishmem.la sysv/liblamrpisysv.la tcp/liblamrpitcp.la"

    RPILIB="liblamrpisysv.la"
    RPILIBMASK="liblamrpisysv.*"
    AC_DEFINE(LAM_RPI_SHM_SYSV, 1)
    ;;
  usysv) 
    RPI_SUBDIRS="shmem usysv tcp"
    # Note: the rpitcp.la lib will have the same RPI API in it as the
    # rpiusysv.la -- so it is important to list the usysv library
    # *first* to take advantage of unix linker semantics
    RPI_LIBS="shmem/liblamrpishmem.la usysv/liblamrpiusysv.la tcp/liblamrpitcp.la"

    RPILIB="liblamrpiusysv.la"
    RPILIBMASK="liblamrpiusysv.*"
    AC_DEFINE(LAM_RPI_SHM_USYSV, 1)
    ;;
  myri)
    RPI_SUBDIRS="myri"
    RPI_LIBS="myri/liblamrpimyri.la"

    RPILIB="liblamrpimyri.la libfakegm.la"
    RPILIBMASK="liblamrpimyri.* libfakegm.*"
    RPI_HAS_MPI_MALLOC=yes
    WANT_MYRINET=yes
    AC_DEFINE(LAM_RPI_MYRI, 1)
    ;;
  via)
    RPI_SUBDIRS="via"
    RPI_LIBS="via/liblamrpivia.la"

    RPILIB="liblamrpivia.la"
    RPILIBMASK="liblamrpivia.*"
    RPI_HAS_MPI_MALLOC=yes
    WANT_VIA=yes
    AC_DEFINE(LAM_RPI_VIA, 1)
    ;;
  *) 
    AC_MSG_ERROR(unknown RPI \"$rpi\")
    ;;
esac
AC_DEFINE_UNQUOTED(LAM_RPI,"$rpi")
AM_CONDITIONAL(WANT_DEFAULT_MPI_MALLOC, test "$RPI_HAS_MPI_MALLOC" = "no")
AC_SUBST(RPI_SUBDIRS)
AC_SUBST(RPI_LIBS)

AC_SUBST(RPILIB)
AC_SUBST(RPILIBMASK)

RPIFLAGS=
# check if not shortcircuiting
AC_ARG_WITH(shortcircuit, [  --without-shortcircuit  do not short circuit send/receives],[],[
case "$rpi" in
    tcp|sysv|usysv) AC_DEFINE(SHORTCIRCUIT, 1)
    ;; 
    myri|via) AC_DEFINE(SHORTCIRCUIT, 1)
    ;;
    *) AC_DEFINE(SHORTCIRCUIT, 0)
    ;; 
esac])

AC_SUBST(RPIFLAGS)

#AFR: add myrinet flags and such
AC_ARG_WITH(gm, [  --with-gm=DIR           directory where the gm myrinet was installed])
if test -n "$with_gm"; then
    GMDIR=$with_gm;
fi

#AFR:  and VIA flags as well
AC_ARG_WITH(vialib, [  --with-vialib=LIB       name of the VIPL library to use])
if test -n "$with_vialib"; then
    VIALIB=$with_vialib;
fi

AC_ARG_WITH(vialibdir, [  --with-vialibdir=DIR    directory of the VIPL library])
if test -n "$with_vialibdir"; then
    VIALIBDIR=$with_vialibdir;
fi

AC_ARG_WITH(viahdir, [  --with-viahdir=DIR      directory of the vipl.h headerfile])
if test -n "$with_viahdir"; then
    VIAHDIR=$with_viahdir;
fi

AC_ARG_WITH(viadev, [  --with-viadev=DEV       device for VIA to use (eg: /dev/clanvi0)])
if test -n "$with_viadev"; then
    VIA_DEVICE=$with_viadev;
    AC_SUBST(VIA_DEVICE)
fi

#test Myrinet libraries and such
if test -n "$WANT_MYRINET"; then
    if test -n "$GMDIR"; then
	OLDLDFLAGS="$LDFLAGS"
	OLDLIBS="$LIBS"
	LDFLAGS="$LDFLAGS -L$GMDIR/binary/lib"
	CPPFLAGS="$CPPFLAGS -I$GMDIR/include"
	CFLAGS="$CFLAGS -I$GMDIR/include"
	found=no
	AC_CHECK_LIB(gm,main,found=yes)
	if test "$found" = "no"; then
	    LDFLAGS="$OLDLDFLAGS -L$GMDIR/lib"
	    # Force it to look again
	    unset ac_cv_lib_gm_main
	    AC_CHECK_LIB(gm,main,,AC_MSG_ERROR(*** Cannot find working libgm.))
	    LAM_RPI_REAL_LDFLAGS="\"-L$GMDIR/lib -lgm\""
	else
	    LAM_RPI_REAL_LDFLAGS="\"-L$GMDIR/binary/lib -lgm\""
	fi
	AC_CHECK_HEADERS(gm.h,,AC_MSG_ERROR(*** Cannot find working gm.h.))
	
	LAM_RPI_REAL_CFLAGS="\"-I$GMDIR/include\""
	LAM_RPI_FAKE_CFLAGS="-I$GMDIR/include"
	LAM_RPI_FAKE_LDFLAGS="-L\$(top_srcdir)/share/rpi/myri/fakegm/.libs -lfakegm"

	LDFLAGS="$OLDLDFLAGS"
	LIBS="$OLDLIBS"
    else	
	AC_CHECK_LIB(gm,main,,AC_MSG_ERROR(*** Cannot find working libgm.))
	AC_CHECK_HEADERS(gm.h,,AC_MSG_ERROR(*** Cannot find working gm.h))

	LAM_RPI_REAL_CFLAGS="\"\""
	LAM_RPI_REAL_LDFLAGS="\"-lgm\""
	LAM_RPI_FAKE_CFLAGS=
	LAM_RPI_FAKE_LDFLAGS="-lfakegm"
    fi

    # Check for which API constant to use:
    # GM_API_VERSION_1_2
    # GM_API_VERSION_1_1
    # GM_API_VERSION_1_0

check_gm_api_version() {
    gmver="$1"
    AC_TRY_COMPILE([#include <gm.h>
], [int foo = GM_API_VERSION_1_$gmver;],
	GM_API_VER="$gmver", GM_API_VER="")
    unset gmver
}

    AC_MSG_CHECKING(GM API version)
    check_gm_api_version 2
    if test "$GM_API_VER" = ""; then
	check_gm_api_version 1
	if test "$GM_API_VER" = ""; then
	    check_gm_api_version 0
	    if test "$GM_API_VER" = ""; then
		AC_MSG_RESULT([not found!])
		AC_MSG_WARN([*** Could not determine the version of your GM library.])
		AC_MSG_ERROR([*** Cannot continue])
	    fi
	fi
    fi
    GM_API_VERSION="-DLAM_GM_API_VERSION=GM_API_VERSION_1_$GM_API_VER"
    AC_SUBST(GM_API_VERSION)
    AC_MSG_RESULT([GM_API_VERSION_1_$GM_API_VER])

    AC_DEFINE_UNQUOTED(LAM_RPI_REAL_CFLAGS,$LAM_RPI_REAL_CFLAGS)
    AC_DEFINE_UNQUOTED(LAM_RPI_REAL_LDFLAGS,$LAM_RPI_REAL_LDFLAGS)
    AC_DEFINE_UNQUOTED(LAM_RPI_FAKE_CFLAGS,$LAM_RPI_FAKE_CFLAGS)
    AC_DEFINE_UNQUOTED(LAM_RPI_FAKE_LDFLAGS,$LAM_RPI_FAKE_LDFLAGS)
fi

#
# Test VIA libraries
#

if test -n "$WANT_VIA"; then
    AC_CHECK_LIB(pthread,main,,AC_MSG_ERROR(*** pthread library which is needed for vipl not found.))
    CFLAGS="$CFLAGS -D_REENTRANT "
    CPPFLAGS="$CPPFLAGS -D_REENTRANT "

    #check headers (vipl.h)
    if test -n "$VIAHDIR"; then  #if special header dir
	CPPFLAGS="$CPPFLAGS -I$VIAHDIR"
	CFLAGS="$CFLAGS -I$VIAHDIR/include"
	LAM_RPI_REAL_CFLAGS="\"-I$VIAHDIR\""
    fi

    AC_CHECK_HEADERS(vipl.h,,AC_MSG_ERROR(*** Cannot find working vipl.h.))

    if test -n "$VIALIB"; then #special libname (not libvipl)
	if test -n "$VIALIBDIR"; then #special directory
	    OLDLDFLAGS="$LDFLAGS"
	    OLDLIBS="$LIBS"
	    LDFLAGS="$LDFLAGS -L$VIALIBDIR"
	    AC_CHECK_LIB($VIALIB,main,,AC_MSG_ERROR(*** Cannot find working vipl library.))
	
	    LAM_RPI_REAL_LDFLAGS="\"-L$VIALIBDIR -lvipl\""

	    LDFLAGS="$OLDLDFLAGS"
	    LIBS="$OLDLIBS"
	else #special libname, standard direcories
	    OLDLDFLAGS="$LDFLAGS"
	    OLDLIBS="$LIBS"
	    AC_CHECK_LIB($VIALIB,main,,AC_MSG_ERROR(*** Cannot find working vipl library.))
	    LAM_RPI_REAL_LDFLAGS="\"-l$VIALIB\""
	    LDFLAGS="$OLDLDFLAGS"
	    LIBS="$OLDLIBS"
	fi
    else #standard name (libvipl)
	if test -n "$VIALIBDIR"; then #special directory
	    OLDLDFLAGS="$LDFLAGS"
	    OLDLIBS="$LIBS"
	    LDFLAGS="$LDFLAGS -L$VIALIBDIR"
	    AC_CHECK_LIB(vipl,main,,AC_MSG_ERROR(*** Cannot find working libvipl.))
	    LAM_RPI_REAL_LDFLAGS="\"-L$VIALIBDIR -lvipl\""
	    LDFLAGS="$OLDLDFLAGS"
	    LIBS="$OLDLIBS"
	else #std name, std dir
	    OLDLDFLAGS="$LDFLAGS"
	    OLDLIBS="$LIBS"
	    AC_CHECK_LIB(vipl,main,,AC_MSG_ERROR(*** Cannot find working libvipl.))
	    LAM_RPI_REAL_LDFLAGS="\"-lvipl\""
	    LDFLAGS="$OLDLDFLAGS"
	    LIBS="$OLDLIBS"
	fi
    fi

    AC_SUBST(LAM_RPI_REAL_CFLAGS)
    AC_SUBST(LAM_RPI_REAL_LDFLAGS)
    AC_DEFINE_UNQUOTED(LAM_RPI_REAL_CFLAGS, "$LAM_RPI_REAL_CFLAGS")
    AC_DEFINE_UNQUOTED(LAM_RPI_REAL_LDFLAGS, "$LAM_RPI_REAL_LDFLAGS")
fi

# use select to deschedule even when yield is available
AC_ARG_WITH(select_yield, [  --with-select-yield     use select to yield])
if test "$with_select_yield" = yes; then
    AC_DEFINE(LAM_USE_SELECT_YIELD)
fi

# change internal signal
AC_ARG_WITH(signal, [  --with-signal=SIGNAL    use internal signal SIGNAL])
if test -n "$with_signal"; then
    case "$with_signal" in
	SIG*) AC_DEFINE_UNQUOTED(LAM_SIGUSR,$with_signal);;
	yes) ;;
	*) AC_MSG_ERROR(invalid signal $with_signal);;
    esac
fi

# See where we can plug the opt flags in
check_opt() {
    arg="$1"
    bad=0
    for word in $arg; do
	case $word in
	-g)    bad=1 ;;
	+K0)   bad=1 ;;
	+K1)   bad=1 ;;
	+K2)   bad=1 ;;
	+K3)   bad=1 ;;
	+K4)   bad=1 ;;
	+K5)   bad=1 ;;
	-O)    bad=1 ;;
	-O0)   bad=1 ;;
	-O1)   bad=1 ;;
	-O2)   bad=1 ;;
	-O3)   bad=1 ;;
	-O4)   bad=1 ;;
	-O5)   bad=1 ;; 
	-O6)   bad=1 ;;
	-O7)   bad=1 ;;
	-O8)   bad=1 ;;
	-O9)   bad=1 ;;
	-xO)   bad=1 ;;
	-xO0)  bad=1 ;;
	-xO1)  bad=1 ;;
	-xO2)  bad=1 ;;
	-xO3)  bad=1 ;;
	-xO4)  bad=1 ;;
	-xO5)  bad=1 ;; 
	-xO6)  bad=1 ;;
	-xO7)  bad=1 ;;
	-xO8)  bad=1 ;;
	-xO9)  bad=1 ;;
	-fast) bad=1 ;;
	esac
    done
    if test "$bad" = "0"; then
	result="$OPTFLAGS $arg"
    else
	result="$arg"
    fi
}

OPTFLAGS="-O"
check_opt "$CFLAGS"
CFLAGS="$result"
check_opt "$CXXFLAGS"
CXXFLAGS="$result"
check_opt "$FFLAGS"
FFLAGS="$result"
# Since we're not doing -fast for Solaris anymore, we don't need to
# add -O to the LDFLAGS (checked the man pages on a couple of
# architectures, and this seems to be true).  So we'll just leave
# those alone.
#check_opt "$USER_LDFLAGS"
#USER_LDFLAGS=$result
#check_opt "$USER_CXXLDFLAGS"
#USER_CXXLDFLAGS=$result

# Take care of some specific compiler options. 
# Force use of ANSI C under HP-UX.
ROMIO_FLAGS=
if test "$ac_cv_prog_gcc" = no; then
    us=`(uname -s) 2>/dev/null` || us=unknown
    case "$us" in
        HP-UX)	CPPFLAGS="$CPPFLAGS -Ae"
		ROMIO_FLAGS="+U77"
		if test "$lam_cflags_save" = set; then
			CFLAGS="-Ae"
		else
			CFLAGS="$CFLAGS -Ae"
		fi ;;
	*)	;;
    esac
fi

# Delay the substitution of CFLAGS and CXXFLAGS until later, mainly
# for aesthetic reasons (so that the ugly '-I$(top_srcdir)' doesn't
# show up in the configure tests.

AC_SUBST(FFLAGS)
AC_SUBST(ROMIO_FLAGS)
AC_SUBST(USER_LDFLAGS)
AC_SUBST(USER_CXXLDFLAGS)

LAM_ANSI_PROTOS
if test "$lam_ac_ansi_protos" = no; then
    AC_MSG_ERROR(LAM requires a compiler which understands ANSI C prototypes)
fi

# Is this even used anymore?
# How to specify a directory for the library archive search path.
us=`(uname -s) 2>/dev/null` || us=unknown
case "$us" in
    HP-UX) FLIBPATH="\"-Wl,-L\"" ;;
	*) FLIBPATH="\"-L\"" ;;
esac
AC_DEFINE_UNQUOTED(LAM_FLIBPATH, $FLIBPATH)

# check for specification of FORTRAN compiler
# define WAVE1D_EXAMPLE (a FORTRAN example) to be "wave1d" if were
# building FORTRAN support, or empty if not
F77=
F77_BUILD_DIR=
F77_LTPLIB=
ROMIO_NOF77=
FPI_EXAMPLE=
WAVE1D_EXAMPLE=
TRIVIALF_EXAMPLE=
AC_MSG_CHECKING([if want FORTRAN support])
if test "$with_fc" = no; then
  F77=false
  LAM_F77="false"
  ROMIO_NOF77="-nof77"
  AC_MSG_RESULT([no])
  AC_DEFINE(LAM_WANT_FORTRAN, 0)
else
  AC_MSG_RESULT([yes])
  if test -n "$FC"; then
# AC_CHECK_PROG* only checks for the user specified compiler in the
# users $PATH.  Arrgh!
# It does not address the case where the user specifies an absolute
# filename that is *not* in their $PATH.
    FC0="`echo $FC | awk '{ print $1 }'`"
    ISABS=`echo $FC0 | cut -c1`
    if test "$ISABS" = "/" -a -x "$FC0"; then
      F77="$FC"
      AC_MSG_CHECKING([for FORTRAN compiler $FC0])
      AC_MSG_RESULT([found])
    else
      AC_CHECK_PROGS(F77, $FC0)
    fi
    if test -z "$F77"; then
      AC_DEFINE(LAM_WANT_FORTRAN, 0)
      AC_MSG_ERROR(could not find FORTRAN compiler $FC0)
    else
      AC_DEFINE(LAM_WANT_FORTRAN, 1)
    fi
  else
# If the user did not specify one, look for all the common names
    AC_CHECK_PROGS(F77, [f77 fort77 g77 f90], no)
    if test -z "$F77" -o "$F77" = "no"; then
      AC_DEFINE(LAM_WANT_FORTRAN, 0)
      AC_MSG_WARN([*** Could not find FORTRAN compiler.  Either use])
      AC_MSG_WARN([*** --with-fc to specify the FORTRAN compiler, or])
      AC_MSG_WARN([*** --without-fc to specify no FORTRAN support])
      AC_MSG_ERROR([cannot continue current configuration without FORTRAN compiler])
    else
      AC_DEFINE(LAM_WANT_FORTRAN, 1)
    fi
  fi
  LAM_F77="$F77"
  F77_BUILD_DIR=f77
  F77_LTPLIB=f77/liblamf77pmpi.la
  FPI_EXAMPLE=fpi
  WAVE1D_EXAMPLE=wave1d
  TRIVIALF_EXAMPLE=trivialf
fi
AC_DEFINE_UNQUOTED(LAM_F77, "$LAM_F77")
AC_SUBST(F77_BUILD_DIR)
AC_SUBST(F77_LTPLIB)
AC_SUBST(ROMIO_NOF77)
AC_SUBST(FPI_EXAMPLE)
AC_SUBST(WAVE1D_EXAMPLE)
AC_SUBST(TRIVIALF_EXAMPLE)

# check for threads
THREADCFLAGS=
THREADLDFLAGS=
THREADCXXFLAGS=
THREADCXXLDFLAGS=
WANT_MT=no
AC_MSG_CHECKING([if want multithreaded support]);
AC_ARG_WITH(threads, 
[  --with-thread           enable thread support in LAM (still experimental)],[WANT_MT=$withval])
AC_MSG_RESULT([$WANT_MT])
if test "$WANT_MT" = "yes"; then
    # If were in solaris, check for Solaris threads
    case "$host" in
	*solaris*)
	    libs_SAVE="$LIBS"
	    AC_CHECK_LIB(thread, thr_create, HAVE_SOL_THREADS=1, HAVE_SOL_THREADS=0)
	    LIBS="$libs_SAVE"
	    ;;
    esac
    if test "$HAVE_SOL_THREADS" = "1"; then
	if test "$BASECC" = "cc"; then
	    THREADCFLAGS="-mt"
	    THREADCXXFLAGS="$THREADCFLAGS"
	    THREADLDFLAGS="-mt"
	    THREADCXXLDFLAGS="$THREADLDFLAGS"
	else
	    THREADCFLAGS="-D_REENTRANT"
	    THREADCXXFLAGS="$THREADCFLAGS"
	    THREADLDFLAGS="-lthread"
	    THREADCXXLDFLAGS="$THREADLDFLAGS"
	fi

	if test "$BASECXX" = "CC"; then
	    THREADCFLAGS="-mt"
	    THREADCXXFLAGS="$THREADCFLAGS"
	    THREADLDFLAGS="-mt"
	    THREADCXXLDFLAGS="$THREADLDFLAGS"
	elif test "$BASECXX" = "KCC"; then
	    THREADCFLAGS="--backend -mt"
	    THREADCXXFLAGS="$THREADCFLAGS"
	    THREADLDFLAGS="--backend -mt"
	    THREADCXXLDFLAGS="$THREADLDFLAGS"
	else
	    THREADCFLAGS="-D_REENTRANT"
	    THREADCXXFLAGS="$THREADCFLAGS"
	    THREADLDFLAGS="-lthread"
	    THREADCXXLDFLAGS="$THREADLDFLAGS"
	fi
	AC_DEFINE(LAM_HAVE_SOL_THREADS, 1)
	AC_DEFINE(LAM_HAVE_PTHREADS, 0)
    else
	AC_DEFINE(LAM_HAVE_SOL_THREADS, 0)
	libs_SAVE="$LIBS"
	AC_CHECK_LIB(pthread, pthread_create, HAVE_PTHREADS=1, HAVE_PTHREADS=0)
	LIBS="$libs_SAVE"
	if test "$HAVE_PTHREADS" = "1"; then
	    AC_DEFINE(LAM_HAVE_PTHREADS, 1)
	    THREADCFLAGS="-D_REENTRANT"
	    THREADLDFLAGS="-lpthread"
	    THREADCXXCFLAGS="$THREADCFLAGS"
	    THREADCXXLDFLAGS="$THREADCXXLDFLAGS"
	else
	    AC_DEFINE(LAM_HAVE_PTHREADS, 0)
	fi
    fi
else
    # No thread support
    AC_DEFINE(LAM_HAVE_PTHREADS, 0)
    AC_DEFINE(LAM_HAVE_SOL_THREADS, 0)
fi
AC_SUBST(THREADCFLAGS)
AC_SUBST(THREADLDFLAGS)
AC_SUBST(THREADCXXFLAGS)
AC_SUBST(THREADCXXLDFLAGS)

# we have waited until all the compiler checking is done before checking this
RPISYSLIBS=
# check if using pthread lock
AC_ARG_WITH(pthread_lock, [  --with-pthread-lock     use pthread mutex lock for shared memory pool])
if test "$with_pthread_lock" = yes; then
    case "$rpi" in
	usysv) LAM_MUTEX_PSHARED
	       if test "$lam_ac_mutex_pshared" = no; then
		    echo 'ignoring --with-pthread-lock'
		else
		    RPIFLAGS="$RPIFLAGS -DPTHREAD_FREELOCK"
		    RPISYSLIBS="$RPISYSLIBS -lpthread"
		fi ;;
	*) AC_MSG_WARN(use of pthread mutex lock not supported in RPI $rpi) ;;
     esac
fi

AC_SUBST(RPISYSLIBS)

#
# This is in share/boot/inetexec.c -- looks like a remnant of some old
# flavors of rsh, but we'll keep the code anyway, just in case...
#

AC_DEFINE(LAM_RSH_NEED_MINUSMINUS, 0)

# Check for programs.
# Abort if we cannot find one of them

AC_PROG_CPP
if test "$CPP" = ""; then
    AC_MSG_ERROR([Could not find C preprocessor.  Cannot continue.])
fi

AC_PROG_LN_S
if test "$LN_S" = ""; then
    AC_MSG_ERROR([Could not find command for symbolic links (ln).  Cannot continue.])
fi

AC_PATH_PROG(CP,cp)
if test "$CP" = ""; then
    AC_MSG_ERROR([Could not find cp.  Cannot continue.])
fi

AC_PATH_PROG(RM,rm)
if test "$RM" = ""; then
    AC_MSG_ERROR([Could not find rm.  Cannot continue.])
fi
AC_DEFINE_UNQUOTED(LAM_RM, "$RM -f")

AC_PATH_PROG(SED,sed)
if test "$SED" = ""; then
    AC_MSG_ERROR([Could not find sed.  Cannot continue.])
fi

AC_PATH_PROG(SHELL_CMD,sh)
if test "$SHELL_CMD" = ""; then
    AC_MSG_ERROR([Could not find Bourne shell.  Cannot continue.])
fi

# figure out the remote shell command
# if not explicitly specified by the user then
# remsh as remote shell on HP-UX and rsh on all others
RSH0=
RSH=
AC_ARG_WITH(rsh, 
[  --with-rsh=RSH          use RSH for the remote shell command], [
case "$withval" in
    /*) RSH0=$withval
	;;
# We can do this set stuff here because we're long past command line
# parsing
    *)  set $withval
	RSH0="$1"
	shift
	RSH="$*"
        AC_PATH_PROG(RSH0, $withval)
	;;
esac], [
us=`(uname -s) 2>/dev/null` || us=unknown
case "$us" in
    HP-UX) AC_PATH_PROG(RSH0, remsh) 
	;;
    *) AC_PATH_PROG(RSH0, rsh) 
	;;
esac])

# make sure we have a remote shell command
AC_MSG_CHECKING([for remote shell command])
if test -z "$RSH0"; then
    AC_MSG_ERROR(could not find remote shell command)
fi
AC_MSG_RESULT([$RSH0 $RSH])
RSH="\"$RSH0 $RSH\""
AC_DEFINE_UNQUOTED(LAM_RSH, $RSH)


# do we have a broken compiler that does not defined __STDC__ even
# though it really is?  Hard coded for the moment for Solaris cc.  
# can extend the hard coding or make a real test
# Does not hurt here to AC_DEFINE LAM_CONFIG_FORCE_PROTOS to 0, because 
# LAM_CONFIG_FORCE_PROTOS is only one of multiple constants checked to see if
# we want prototypes.
if test "`echo $host | grep solaris2`" != "" -a "$BASECC" = "cc"; then
    AC_DEFINE(LAM_CONFIG_FORCE_PROTOS, 1)
elif test "$ac_cv_prog_gcc" = "yes"; then
    AC_DEFINE(LAM_CONFIG_FORCE_PROTOS, 1)
else
    # At least some compilers don't want to be forced -- e.g., HP-UX 10.20
    # which is not ANSI by default
    AC_DEFINE(LAM_CONFIG_FORCE_PROTOS, 0)
    LAM_CHECK_STDC
fi

# If we want things to be purify/bcheck/general-memory-checking-debugger
# clean, set this flag so that LAM will always zero memory in known
# trouble spots.  May cause slight overhead in sending/receiving, since
# buffers are zeroed before using, hence, it is an option
AC_MSG_CHECKING([if want purify clean])
WANT_PURIFY=no
AC_ARG_WITH(purify,
[  --with-purify           ensure to zero memory before using (see docs)],
[WANT_PURIFY=$withval])
if test "$WANT_PURIFY" = "yes"; then
    AC_DEFINE(LAM_DISINFECT, 1)
else
    AC_DEFINE(LAM_DISINFECT, 0)
fi
AC_MSG_RESULT([$WANT_PURIFY])

# transport tunable defaults
TCPSHORT=65536
SHMSHORT=8192
SHMPOOL=0
SHMALLOC=0

# transport 
AC_ARG_WITH(tcpshort, 
[  --with-tcp-short=BYTES  use BYTES as the size of the longest TCP short 
                          message])
if test -n "$with_tcp_short"; then
    TCPSHORT=$with_tcp_short
fi
AC_MSG_CHECKING([for TCP short message length])
AC_MSG_RESULT([$TCPSHORT bytes])

case "$rpi" in 
  *sysv)
    AC_ARG_WITH(shmshort, 
[  --with-shm-short=BYTES  use BYTES as the size of the longest shared 
                          memory short message])
    if test -n "$with_shm_short"; then
	SHMSHORT=$with_shm_short
    fi

    echo using shared memory short message length of $SHMSHORT bytes

    AC_ARG_WITH(shm-poolsize, 
[  --with-shm-poolsize=BYTES  make the shared memory pool BYTES in size])
    if test -n "$with_shm_poolsize"; then
	SHMPOOL=$with_shm_poolsize
        echo using shared memory pool of $SHMPOOL bytes
    fi

    AC_ARG_WITH(shm-maxalloc, 
[  --with-shm-maxalloc=BYTES  make BYTES the maximum allocation from the 
                             shared pool])
    if test -n "$with_shm_maxalloc"; then
	SHMALLOC=$with_shm_maxalloc
        echo using maximum shared memory allocation of $SHMALLOC bytes
    fi

    if test -z "$with_shm_poolsize"; then
	if test -z "$with_shm_maxalloc"; then
	    AC_MSG_CHECKING(["shared memory poolsize"])
	    LAM_GET_SHMMAX($SHMSHORT,SHMPOOL,SHMALLOC)
	    AC_MSG_RESULT([$SHMPOOL bytes])
	    AC_MSG_CHECKING(["shared memory maxalloc"])
	    AC_MSG_RESULT([$SHMALLOC bytes])
	else
	    AC_MSG_CHECKING(["shared memory poolsize"])
	    LAM_GET_SHMMAX($SHMSHORT,SHMPOOL,SHMALLOC)
	    AC_MSG_RESULT([$SHMPOOL bytes])
	fi
    else
	if test -z "$with_shm_maxalloc"; then
	    AC_MSG_CHECKING(["shared memory maxalloc"])
	    LAM_GET_SHMMAX($SHMSHORT,SHMPOOL,SHMALLOC)
	    AC_MSG_RESULT([$SHMALLOC bytes])
	fi
    fi

    if test \( $SHMPOOL -eq 0 \) -o \( $SHMALLOC -eq 0 \); then
	AC_MSG_ERROR([determining shared memory parameters
Please check that your system supports SYSV shared 
memory segments of 1MB or more.
You can also try explicitly setting both the poolsize and 
maxalloc parameters.])
    fi ;;
esac

AC_DEFINE_UNQUOTED(LAM_TCPSHORTMSGLEN, $TCPSHORT)
AC_DEFINE_UNQUOTED(LAM_SHMSHORTMSGLEN, $SHMSHORT)
AC_DEFINE_UNQUOTED(LAM_MPI_SHMPOOLSIZE, $SHMPOOL)
AC_DEFINE_UNQUOTED(LAM_MPI_SHMMAXALLOC, $SHMALLOC)

# lamd defaults
# used to be in config.mk (Makefile include), but now have to be here
# since we switched to automake

TO_BOOT=60
TO_DLO_ACK=1
TO_DLO_IDLE=120
AC_ARG_WITH(lamd-boot,     [  --with-lamd-boot=SEC    timeout (seconds) for booted node], TO_BOOT=$withval)
AC_ARG_WITH(lamd-ack,      [  --with-lamd-ack=SEC     seconds until a packet is resent], TO_DLO_ACK=$withval)
AC_ARG_WITH(lamd-hb,       [  --with-lamd-hb=SEC      seconds until heartbeat send to remote lamd], TO_DLO_IDLE=$withval)

# Just for cosmetics
AC_MSG_CHECKING(["for desired boot timeout"])
AC_MSG_RESULT(["$TO_BOOT seconds"])
AC_MSG_CHECKING(["for desired lamd packet resend time"])
AC_MSG_RESULT(["$TO_DLO_ACK seconds"])
AC_MSG_CHECKING(["for desired lamd heartbeat time"])
AC_MSG_RESULT(["$TO_DLO_IDLE seconds"])
AC_DEFINE_UNQUOTED(LAM_TO_BOOT, $TO_BOOT)
AC_DEFINE_UNQUOTED(LAM_TO_DLO_ACK, $TO_DLO_ACK)
AC_DEFINE_UNQUOTED(LAM_TO_DLO_IDLE, $TO_DLO_IDLE)

# Checks for typedefs, structures, and compiler characteristics.
AC_C_BIGENDIAN
# AC_C_CHAR_UNSIGNED
# AC_C_CONST
# AC_C_LONG_DOUBLE
# AC_TYPE_OFF_T
# AC_TYPE_PID_T
# AC_TYPE_SIZE_T
# AC_HEADER_TIME

# Check for library functions.
AC_CHECK_FUNCS(atexit getcwd yield snprintf atoll strtoll)

# Really crude checks for prototypes
LAM_CHECK_PROTOTYPE(snprintf)
LAM_CHECK_PROTOTYPE(gethostname)

# JMS Take out the solaris one right now in favor of normal "yield"
# (checked for above), because until minutes ago, this test was broken
# and sched_yield was not found on Solaris.  However, I don't want to
# investigate the possibility of including -lposix4 on Solaris right
# now -- the next release of LAM is immanent.  Perhaps later...
case $host in
#    *solaris*) LAM_CHECK_FUNC(sched_yield, HAVE_SCHED_YIELD, -lposix4)
#	;;
    *) AC_CHECK_FUNCS(sched_yield)
	;;
esac

# #$%^#$%^$#%^ IRIX 7.3 MIPSpro compilers...
have_sys_types=1
if test "`grep sys/types.h confdefs.h`" = ""; then
    echo "#include <sys/types.h>" >> confdefs.h
    have_sys_types=0
fi
AC_CHECK_HEADERS([stropts.h grp.h netinet/tcp.h rpc/types.h rpc/xdr.h pty.h])
if test "$have_sys_types" = "0"; then
    rm -f confdefs.h.new
    grep -v sys/types.h confdefs.h > confdefs.h.new
    mv confdefs.h.new confdefs.h
fi
AC_CACHE_CHECK([if SA_RESTART defined in signal.h],
lam_cv_def_sa_restart,
[AC_EGREP_CPP(yes, [
#include <signal.h>
#ifdef SA_RESTART
    yes
#endif ],lam_cv_def_sa_restart=yes,lam_cv_def_sa_restart=no)
])
if test $lam_cv_def_sa_restart = yes; then
    AC_DEFINE(LAM_HAVE_SA_RESTART, 1)
else
    AC_DEFINE(LAM_HAVE_SA_RESTART, 0)
fi

AC_CACHE_CHECK([for sa_len in struct sockaddr],
lam_cv_struct_sa_len,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>], [struct sockaddr s; s.sa_len;],
lam_cv_struct_sa_len=yes, lam_cv_struct_sa_len=no)])
if test $lam_cv_struct_sa_len = yes; then
  AC_DEFINE(LAM_HAVE_SA_LEN, 1)
else
  AC_DEFINE(LAM_HAVE_SA_LEN, 0)
fi

AC_CACHE_CHECK([for union semun in sys/sem.h],
lam_cv_union_semun,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/sem.h>], [union semun s; s.val;],
lam_cv_union_semun=yes, lam_cv_union_semun=no)])
if test $lam_cv_union_semun = yes; then
  AC_DEFINE(LAM_HAVE_UNION_SEMUN)
fi

# This is complicated enough to warrant a long explanation.
#
# So apparently, in 64 bit mode on AIX 4.3.3, fcntl(F_SETFL,
# O_NONBLOCK) (you get the idea) is broken.  Sometimes.  i.e.,
# sometimes, setting a socket to go into blocking mode just doesn't
# work.  When it doesn't work, read() will return -1 and set errno to
# EAGAIN, which is nonblocking behavior.  But when the socket is
# supposed to be in blocking mode, LAM doesn't look at errno -- it
# just sees the -1 and decides that "a process in the local group is
# dead".  
#
# So we originally put in a test to check for FIONBIO and to use
# ioctl(FIONBIO) instead of fcntl() wherever FIONBIO exists.  However,
# at least on one system (HP-UX 10.20), FIONBIO is broken, and fcntl()
# works.  The argument was made that we *know* that fcntl() works
# everywhere except AIX 4.3.3 (since LAM has always only had fcntl(),
# not ioctl()).  Plus, Stevens (the networking book) says that POSIX
# says use fcntl().  
#
# Hence, we are now special-casing AIX 4.3.3 -- if we are on AIX, look
# for FIONBIO.  If it's there, use ioctl.  Otherwise, always use
# fcntl().  Yet another reason that AIX absolutely sucks.

case "$host" in
*aix*)
    AC_CACHE_CHECK([if FIONBIO defined in sys/ioctl.h], lam_cv_def_fionbio,
	[AC_EGREP_CPP(yes, [
#include <sys/ioctl.h>
#ifdef FIONBIO
    yes
#endif ],lam_cv_def_fionbio=yes,lam_cv_def_fionbio=no)])
    if test $lam_cv_def_fionbio = yes; then
	AC_DEFINE(LAM_HAVE_FIONBIO, 1)
    else
	AC_DEFINE(LAM_HAVE_FIONBIO, 0)
    fi
    ;;
*)
    # If we're not on AIX, just use fcntl
    AC_MSG_CHECKING([if FIONBIO defined in sys/ioctl.h])
    AC_DEFINE(LAM_HAVE_FIONBIO, 0)
    AC_MSG_RESULT([not on AIX 4.3.3, so who cares?])
    ;;
esac

AC_CACHE_CHECK([if need to include sys/select.h],
lam_cv_need_sys_select_h,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>], [fd_set s; FD_ZERO(&s);],
lam_cv_need_sys_select_h=no, lam_cv_need_sys_select_h=yes)])
if test $lam_cv_need_sys_select_h = yes; then
  AC_DEFINE(LAM_NEED_SYS_SELECT_H)
fi

AC_CACHE_CHECK([for BSD43 style file descriptor passing],
lam_cv_have_bsd43_fd_passing,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>], [struct msghdr m; m.msg_accrights = 0;],
lam_cv_have_bsd43_fd_passing=yes, lam_cv_have_bsd43_fd_passing=no)])
if test $lam_cv_have_bsd43_fd_passing = yes; then
  AC_DEFINE(LAM_HAVE_BSD43_FD_PASSING)
fi

AC_CACHE_CHECK([for BSD44 style file descriptor passing],
lam_cv_have_bsd44_fd_passing,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>],
[struct cmsghdr c; 
struct msghdr m; 
c.cmsg_type = 0;
m.msg_control = 0;],
lam_cv_have_bsd44_fd_passing=yes, lam_cv_have_bsd44_fd_passing=no)])
if test $lam_cv_have_bsd44_fd_passing = yes; then
  AC_DEFINE(LAM_HAVE_BSD44_FD_PASSING)
fi

if test "$lam_cv_have_bsd44_fd_passing" = "yes"; then
    LAM_CHECK_IF_BSD44_CMSG_DATA_BROKEN
fi

AC_CACHE_CHECK([for SYSV style file descriptor passing],
lam_cv_have_sysv_fd_passing,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stropts.h>], [struct strrecvfd c; c.fd = 0;],
lam_cv_have_sysv_fd_passing=yes, lam_cv_have_sysv_fd_passing=no)])
if test $lam_cv_have_sysv_fd_passing = yes; then
  AC_DEFINE(LAM_HAVE_SVR4_FD_PASSING)
fi

#
# Do we have openpty()?
# In Linux, openpty is in -lutil -- it is VERY IMPORTANT TO ADD -lutil
# TO LIBS SO THAT LAM_CHECK_FUNC WORKS PROPERLY!
#
configure_libs_SAVE="$LIBS"
AC_CHECK_LIB(util, login, SYSLIBS="$SYSLIBS -lutil" LIBS="$LIBS -lutil")
LAM_CHECK_FUNC(openpty, LAM_HAVE_OPENPTY)
LIBS="$configure_libs_SAVE"

#
# How about other PTY things?
#
AC_CACHE_CHECK([for BSD ptys],
lam_cv_have_bsd_ptys,
if test -r /dev/ptyp0 -a -w /dev/ptyp0; then
lam_cv_have_bsd_ptys=yes
else
lam_cv_have_bsd_ptys=no
fi)
if test $lam_cv_have_bsd_ptys = yes; then
  AC_DEFINE(LAM_HAVE_BSD_PTYS)
fi

AC_CACHE_CHECK([for SYSV ptys],
lam_cv_have_sysv_ptys,
if test -r /dev/ptmx -a -w /dev/ptmx; then
lam_cv_have_sysv_ptys=yes
else
lam_cv_have_sysv_ptys=no
fi)
if test $lam_cv_have_sysv_ptys = yes; then
  AC_DEFINE(LAM_HAVE_SYSV_PTYS)
fi

if test $lam_cv_have_sysv_ptys = no -a $lam_cv_have_bsd_ptys = no; then
   AC_MSG_WARN(neither BSD or SYSV ptys are available)
fi

# 
# We delayed substituting in SYSLIBS and HBIND until now because the
# pty tests may change those values.
#

AC_SUBST(SYSLIBS)
AC_DEFINE_UNQUOTED(LAM_SYSLIBS, "$SYSLIBS")
AC_DEFINE_UNQUOTED(LAM_HBIND, "$HBIND")

# check for <sched.h>
AC_CHECK_HEADERS(sched.h)
# check for <strings.h>
AC_CHECK_HEADERS(strings.h)

if test ! -d romio; then
    mkdir romio
    mkdir romio/lib
fi

# At least AIX 4.3 has things like int8 already defined
LAM_CHECK_TYPE(int2)
LAM_CHECK_TYPE(uint2)
LAM_CHECK_TYPE(int4)
LAM_CHECK_TYPE(uint4)
LAM_CHECK_TYPE(int8)
LAM_CHECK_TYPE(uint8)
LAM_CHECK_TYPE(float4)
LAM_CHECK_TYPE(float8)

# Type sizes
LAM_GET_SIZEOF(short, LAM_SIZEOF_SHORT)
LAM_GET_SIZEOF(wchar_t, LAM_SIZEOF_WCHAR)
LAM_GET_SIZEOF(int, LAM_SIZEOF_INT)
LAM_GET_SIZEOF(long, LAM_SIZEOF_LONG)
LAM_GET_SIZEOF(long long, LAM_SIZEOF_LONG_LONG)
LAM_GET_SIZEOF(float, LAM_SIZEOF_FLOAT)
LAM_GET_SIZEOF(double, LAM_SIZEOF_DOUBLE)
LAM_GET_SIZEOF(long double, LAM_SIZEOF_LONG_DOUBLE)
LAM_GET_SIZEOF(void *, LAM_SIZEOF_VOID_P)
LAM_CHECK_SIZEOF_STRUCT_STAT_MEMBERS
LAM_CHECK_TYPEOF_GETSOCKOPT_OPTLEN
LAM_CHECK_TYPEOF_RECVFROM_LEN

LAM_GET_ALIGNMENT_CACHE(short,lam_cv_align_short,LAM_ALIGNMENT_SHORT)
LAM_GET_ALIGNMENT_CACHE(wchar_t,lam_cv_align_wchar,LAM_ALIGNMENT_WCHAR)
LAM_GET_ALIGNMENT_CACHE(int,lam_cv_align_int,LAM_ALIGNMENT_INT)
LAM_GET_ALIGNMENT_CACHE(long,lam_cv_align_long,LAM_ALIGNMENT_LONG)
LAM_GET_ALIGNMENT_CACHE(long long,lam_cv_align_longlong,LAM_ALIGNMENT_LONG_LONG)
LAM_GET_ALIGNMENT_CACHE(float,lam_cv_align_float,LAM_ALIGNMENT_FLOAT)
LAM_GET_ALIGNMENT_CACHE(double,lam_cv_align_double,LAM_ALIGNMENT_DOUBLE)
LAM_GET_ALIGNMENT_CACHE(long double,lam_cv_align_longdbl,LAM_ALIGNMENT_LONG_DOUBLE)
LAM_GET_ALIGNMENT_CACHE(void *,lam_cv_align_voidp,LAM_ALIGNMENT_VOID_P)

if test "$with_fc" != no; then
    LAM_GET_FORTRAN_EXT_NAME_CONVENTION($F77)

    LAM_GET_SIZEOF_FORTRAN_TYPE_CACHE(INTEGER,lam_cv_size_fint,
	LAM_SIZEOF_FORTRAN_INT)
    LAM_GET_SIZEOF_FORTRAN_TYPE_CACHE(REAL,lam_cv_size_freal,
	LAM_SIZEOF_FORTRAN_REAL)
    LAM_GET_SIZEOF_FORTRAN_TYPE_CACHE(DOUBLE PRECISION,lam_cv_size_fdprec,
	LAM_SIZEOF_FORTRAN_DBLPREC)
    LAM_GET_SIZEOF_FORTRAN_TYPE_CACHE(COMPLEX,lam_cv_size_fcomplex,
	LAM_SIZEOF_FORTRAN_COMPLEX)
    LAM_GET_SIZEOF_FORTRAN_TYPE_CACHE(DOUBLE COMPLEX,lam_cv_size_fdcomplex,
	LAM_SIZEOF_FORTRAN_DBLCOMPLEX)

    LAM_GET_FORTRAN_ALIGNMENT_CACHE(INTEGER,lam_cv_align_fint,
	LAM_ALIGNMENT_FORTRAN_INT)
    LAM_GET_FORTRAN_ALIGNMENT_CACHE(REAL,lam_cv_align_freal,
	LAM_ALIGNMENT_FORTRAN_REAL)
    LAM_GET_FORTRAN_ALIGNMENT_CACHE(DOUBLE PRECISION,lam_cv_align_fdprec,
	LAM_ALIGNMENT_FORTRAN_COMPLEX)
    LAM_GET_FORTRAN_ALIGNMENT_CACHE(COMPLEX,lam_cv_align_fcomplex,
	LAM_ALIGNMENT_FORTRAN_DBLPREC)
    LAM_GET_FORTRAN_ALIGNMENT_CACHE(DOUBLE COMPLEX,lam_cv_align_fdcomplex,
	LAM_ALIGNMENT_FORTRAN_DBLCOMPLEX)

# check that alignment of double precsion and corresponding C type are same
    if test "$lam_cv_size_fdprec" = "$ac_cv_sizeof_double"; then
       if test "$lam_cv_align_fdprec" != "$lam_cv_align_double"; then
	  AC_MSG_WARN([alignment of Fortran double precsion and C double
    are not the same])
       fi
    elif test "$lam_cv_size_fdprec" = "$ac_cv_sizeof_long_double"; then
       if test "$lam_cv_align_fdprec" != "$lam_cv_align_longdbl"; then
	  AC_MSG_WARN([alignment of Fortran double precsion and C long double
    are not the same])
       fi
    fi
fi

# Finally, make an "INSTALL_HOME" available for the example proc schemas
INSTALL_HOME=`pwd`
AC_SUBST(INSTALL_HOME)

# This is needed for VPATH builds, so that it will -I the appropriate
# include directory (don't know why automake doesn't do this
# automatically).  We delayed doing it until now just so that
# '-I$(top_srcdir)' doesn't show up in any of the configure output --
# purely aesthetic.

dir="$srcdir";
if test "$srcdir" = "."; then
    dir="`pwd`"
fi
CFLAGS='-I$(top_srcdir)/share/include'" $CFLAGS"
CXXFLAGS='-I$(top_srcdir)/share/include'" $CXXFLAGS"
AC_SUBST(CXXFLAGS)
AC_SUBST(CFLAGS)


#
# libtool magic
#

AM_PROG_LIBTOOL


#
# If we're doing a vpath build, mkdir romio because AC_OUTPUT puts out
# a file in romio/util.  Also make the lib directories, because ROMIO
# isn't smart enough to make them during its build process.  :-(
#

if test ! -d romio; then
    mkdir romio
    mkdir romio/lib
fi

#
# Party on
#

AC_OUTPUT([
    Makefile
    config/Makefile
    etc/Makefile
    examples/Makefile
    examples/alltoall/Makefile
    examples/fault/Makefile
    examples/mandelbrot/Makefile
    examples/mandelbrot/myapp
    examples/mpi2c++/Makefile
    examples/pi/Makefile
    examples/ring/Makefile
    examples/romio/Makefile
    examples/trivial/Makefile
    examples/trivial/myapp
    examples/wave1d/Makefile
    examples/wave1d/myapp
    man/Makefile
    man/man1/Makefile
    man/man2/Makefile
    man/man3/Makefile
    man/man5/Makefile
    man/man7/Makefile
    man/mans/Makefile
    otb/Makefile
    otb/bfctl/Makefile
    otb/bfstate/Makefile
    otb/doom/Makefile
    otb/fctl/Makefile
    otb/filedr/Makefile
    otb/fstate/Makefile
    otb/ipcdr/Makefile
    otb/kdump/Makefile
    otb/lamclean/Makefile
    otb/lamexec/Makefile
    otb/lamgrow/Makefile
    otb/lamshrink/Makefile
    otb/lamtrace/Makefile
    otb/loadgo/Makefile
    otb/mpimsg/Makefile
    otb/mpirun/Makefile
    otb/mpitask/Makefile
    otb/state/Makefile
    otb/sys/Makefile
    otb/sys/bforward/Makefile
    otb/sys/bufferd/Makefile
    otb/sys/dli_inet/Makefile
    otb/sys/dlo_inet/Makefile
    otb/sys/echod/Makefile
    otb/sys/filed/Makefile
    otb/sys/flatd/Makefile
    otb/sys/iod/Makefile
    otb/sys/haltd/Makefile
    otb/sys/kenyad/Makefile
    otb/sys/kernel/Makefile
    otb/sys/loadd/Makefile
    otb/sys/router/Makefile
    otb/sys/traced/Makefile
    otb/sys/lamd/Makefile
    otb/sys/impid/Makefile
    otb/tping/Makefile
    share/Makefile
    share/args/Makefile
    share/boot/Makefile
    share/etc/Makefile
    share/freq/Makefile
    share/impi/Makefile
    share/kreq/Makefile
    share/include/Makefile
    share/include/mpif.h
    share/include/patchlevel.h
    share/mpi/Makefile
    share/mpi/f77/Makefile
    share/nreq/Makefile
    share/pmpi/Makefile
    share/pmpi/f77/Makefile
    share/rpi/Makefile
    share/rpi/c2c/Makefile
    share/rpi/lamd/Makefile
    share/rpi/myri/Makefile
    share/rpi/via/Makefile
    share/rpi/shmem/Makefile
    share/rpi/sysv/Makefile
    share/rpi/tcp/Makefile
    share/rpi/usysv/Makefile
    share/rreq/Makefile
    share/trillium/Makefile
    share/tstdio/Makefile
    tools/Makefile
    tools/hboot/Makefile
    tools/hcc/Makefile
    tools/hcc/hcp
    tools/hf77/Makefile
    tools/lamboot/Makefile
    tools/lamhalt/Makefile
    tools/lamnodes/Makefile
    tools/recon/Makefile
    tools/tkill/Makefile
    tools/wipe/Makefile
    romio/util/lam-configure-values
], [chmod a+x tools/hcc/hcp romio/util/lam-configure-values])

# ARRGGGHHH!!!  #$%@#$%@#$% IRIX.  It seems that their "make" either
# has date analysis precision of less than 1 second, or it rules that
# files of the same timestamp (according to ls -l, anyway) are out of
# date w.r.t. each other.  

# For an example of what I mean, go to share/include and do "make".
# Then do "make" again.  Try it on some other operating system (e.g.,
# Solaris, Linux).  Why does IRIX fire the same rule twice in a row?  

# The result of this is that config.status is run for *every*
# invocation of "make" on IRIX systems, which, if the "rm" statement
# below was included in the AC_OUTPUT macro (as it really should be),
# would remove the sentinel files in ROMIO and the C++ bindings,
# resulting in ROMIO and the C++ bindings being built *every* time.
# ARRGHHH!!!

# The only real solution that we can come up with (without being
# overly complicated; this just isn't worth it) is to move this rm
# statement out of the AC_OUTPUT macro.  Hence, they'll only be
# deleted via respective "*clean" targets and when configure is run.
# This *shouldn't* be too much of a problem, because the "rebuilt
# share/include/lam_config.h" mechanism built in to config.status will
# really only be effective for those who run "make depend", which is
# generally only the developers.  Ugh!!!

rm -f .lam_built romio/.lam_built mpi2c++/.lam_built