File: configure.in

package info (click to toggle)
octave2.1 1%3A2.1.73-13
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 37,028 kB
  • ctags: 20,874
  • sloc: cpp: 106,508; fortran: 46,978; ansic: 5,720; sh: 4,800; makefile: 3,186; yacc: 3,132; lex: 2,892; lisp: 1,715; perl: 778; awk: 174; exp: 134
file content (1589 lines) | stat: -rw-r--r-- 43,828 bytes parent folder | download | duplicates (2)
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
dnl configure.in
dnl
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Copyright (C) 1996, 1997 John W. Eaton
### 
### This file is part of Octave.
### 
### Octave is free software; you can redistribute it and/or modify it
### under the terms of the GNU General Public License as published by the
### Free Software Foundation; either version 2, or (at your option) any
### later version.
### 
### Octave is distributed in the hope that it will be useful, but WITHOUT
### ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
### FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
### for more details.
### 
### You should have received a copy of the GNU General Public License
### along with Octave; see the file COPYING.  If not, write to the Free
### Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
### 02110-1301, USA. 

### Preserve CFLAGS and CXXFLAGS from the environment before doing
### anything else because we don't know which macros might call
### AC_PROG_CC or AC_PROG_CXX.

EXTERN_CFLAGS="$CFLAGS"
EXTERN_CXXFLAGS="$CXXFLAGS"

AC_INIT
AC_REVISION($Revision: 1.390 $)
AC_PREREQ(2.57)
AC_CONFIG_SRCDIR([src/octave.cc])
AC_CONFIG_HEADER(config.h)

AC_DEFINE(OCTAVE_SOURCE, 1, [Define if this is Octave.])
  
OCTAVE_HOST_TYPE

AC_GNU_SOURCE

AC_AIX
AC_MINIX
AC_ISC_POSIX

### some defaults

OCTAVE_SET_DEFAULT(man1dir, '$(mandir)/man1')
OCTAVE_SET_DEFAULT(man1ext, '.1')
OCTAVE_SET_DEFAULT(infofile, '$(infodir)/octave.info')
OCTAVE_SET_DEFAULT(octincludedir, '$(includedir)/octave-$(version)')
OCTAVE_SET_DEFAULT(fcnfiledir, '$(datadir)/octave/$(version)/m')
OCTAVE_SET_DEFAULT(localfcnfiledir, '$(datadir)/octave/site/m')
OCTAVE_SET_DEFAULT(localapifcnfiledir,
  '$(datadir)/octave/site/$(apiversion)/m')
OCTAVE_SET_DEFAULT(localverfcnfiledir, '$(datadir)/octave/$(version)/site/m')
OCTAVE_SET_DEFAULT(localfcnfilepath,
  '$(localverfcnfiledir)//:$(localapifcnfiledir)//:$(localfcnfiledir)//')
OCTAVE_SET_DEFAULT(octlibdir, '$(libdir)/octave-$(version)')
OCTAVE_SET_DEFAULT(archlibdir,
  '$(libexecdir)/octave/$(version)/exec/$(canonical_host_type)')
OCTAVE_SET_DEFAULT(localarchlibdir,
  '$(libexecdir)/octave/site/exec/$(canonical_host_type)')
OCTAVE_SET_DEFAULT(localverarchlibdir,
  '$(libexecdir)/octave/$(version)/site/exec/$(canonical_host_type)')
OCTAVE_SET_DEFAULT(octfiledir,
  '$(libexecdir)/octave/$(version)/oct/$(canonical_host_type)')
OCTAVE_SET_DEFAULT(localoctfiledir,
  '$(libexecdir)/octave/site/oct/$(canonical_host_type)')
OCTAVE_SET_DEFAULT(localapioctfiledir,
  '$(libexecdir)/octave/site/oct/$(apiversion)/$(canonical_host_type)')
OCTAVE_SET_DEFAULT(localveroctfiledir,
  '$(libexecdir)/octave/$(version)/site/oct/$(canonical_host_type)')
OCTAVE_SET_DEFAULT(localoctfilepath,
  '$(localveroctfiledir)//:$(localapioctfiledir)//:$(localoctfiledir)//')
OCTAVE_SET_DEFAULT(fcnfilepath,
  '.:$(localoctfilepath):$(localfcnfilepath):$(octfiledir)//:$(fcnfiledir)//')
OCTAVE_SET_DEFAULT(imagedir, '$(datadir)/octave/$(version)/imagelib')
OCTAVE_SET_DEFAULT(imagepath, '.:$(imagedir)//')

### Make configure args available for other uses.

config_opts=$ac_configure_args
AC_SUBST(config_opts)

### Path separator.

AC_DEFINE(SEPCHAR, [':'], Define this to be the path separator for your system, as a character constant.])
AC_DEFINE(SEPCHAR_STR, [":"], [Define this to the path separator, as a string.])

### Allow the user to force us to use f2c.

AC_ARG_WITH(f2c,
  [  --with-f2c              use f2c even if Fortran compiler is available],
  [if test "$withval" = no; then use_f2c=false; else use_f2c=true; fi],
  use_f2c=false)

### Allow the user to force us to use f77.

AC_ARG_WITH(f77,
  [  --with-f77              use f77 to compile Fortran subroutines],
  [if test "$withval" = no; then use_f77=false; else use_f77=true; fi],
  use_f77=false)

### Make sure only one of the above options for Fortran compilers was
### specified (multiple "no" or --without-FOO options are ok).

OCTAVE_CHECK_EXCLUSIVE_WITH_OPTIONS(f77, f2c,
  [warn_f2c_and_f77="--with-f2c and --with-f77 both specified!  Using f77..."
  AC_MSG_WARN($warn_f2c_and_f77)
  use_f2c=false])

dnl ### Allow the user disable support for plplot.
dnl 
dnl # USE_PLPLOT=true
dnl # PLPLOT_DIR=plplot
dnl # LIBPLPLOT='$(TOPDIR)/plplot/libplplot.$(LIBEXT)
USE_PLPLOT=false
PLPLOT_DIR=""
LIBPLPLOT=""
dnl AC_ARG_ENABLE(plplot,
dnl   [  --enable-plplot         use plplot for plotting (default is yes)],
dnl   [if test "$enableval" = no; then
dnl      USE_PLPLOT=false;
dnl      LIBPLPLOT="";
dnl      PLPLOT_DIR="";
dnl    fi], [])
dnl if $USE_PLPLOT; then
dnl   AC_DEFINE(USE_PLPLOT, 1, [Define to use plplot.])
dnl fi
AC_SUBST(LIBPLPLOT)
AC_SUBST(PLPLOT_DIR)

### Make it possible to have Octave's array and matrix classes do bounds
### checking on element references.  This slows some operations down a
### bit, so it is turned off by default.

BOUNDS_CHECKING=false
AC_ARG_ENABLE(bounds-check,
  [  --enable-bounds-check   for internal array classes (default is no)],
  [if test "$enableval" = yes; then BOUNDS_CHECKING=true; fi], [])
if $BOUNDS_CHECKING; then
  AC_DEFINE(BOUNDS_CHECKING, 1, [Define to use internal bounds checking.])
fi

### It seems that there are some broken inline assembly functions in
### the GNU libc.  Since I'm not sure how to test whether we are using
### GNU libc, just disable them for all platforms.

AC_MSG_RESULT([defining __NO_MATH_INLINES avoids buggy GNU libc exp function])
AC_DEFINE(__NO_MATH_INLINES, 1, [Define if your version of GNU libc has buggy inline assembly code for math functions like exp.])

### See which C++ compiler to use (we expect to find g++).

AC_PROG_CXX
AC_PROG_CXXCPP

### Do special things for g++.

gxx_version=`$CXX -v 2>&1 | grep "^.*g.. version" | \
  sed -e 's/^.*g.. version *//' -e 's/cygnus-//' -e 's/egcs-//' -e 's/ .*//'`

case "$gxx_version" in
  1.* | 2.[[012345678]].*)
    AC_MSG_ERROR([g++ version $gxx_version will probably fail to compile Octave]
)
  ;;
  2.9*)
    warn_gxx_version="g++ version $gxx_version is likely to cause problems"
    AC_MSG_WARN($warn_gxx_version)
  ;;
esac

CXX_VERSION=
if test -n "$gxx_version"; then
  CXX_VERSION="$gxx_version"
fi
AC_SUBST(CXX_VERSION)

OCTAVE_CXX_NEW_FRIEND_TEMPLATE_DECL
OCTAVE_CXX_ISO_COMPLIANT_LIBRARY

# Determine the ABI used the C++ compiler, needed by the dynamic loading
# code. Currently supported ABIs are GNU v2, GNU v3 and Sun Workshop.

OCTAVE_CXX_ABI

### See which C compiler to use (we expect to find gcc).

AC_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL

### Do special things for gcc.

gcc_version=`$CC -v 2>&1 | grep "^.*gcc version" | \
  sed -e 's/^.*g.. version *//' -e 's/cygnus-//' -e 's/egcs-//'`
case "$gcc_version" in
  2.*)
    if test -z "$LDFLAGS"; then
      LDFLAGS="-g"
      AC_MSG_RESULT([defining LDFLAGS to be $LDFLAGS])
    fi
  ;;
  1.*)
    warn_gcc_version="gcc version $gcc_version is likely to cause problems"
    AC_MSG_WARN($warn_gcc_version)
  ;;
esac

CC_VERSION=
if test -n "$gcc_version"; then
  CC_VERSION="$gcc_version"
fi
AC_SUBST(CC_VERSION)

### The flag to create dependency varies depending on the compier.

# Assume GCC.
DEPEND_FLAGS="-M"
DEPEND_EXTRA_SED_PATTERN=""
case "$canonical_host_type" in
  sparc-sun-solaris2* | i386-pc-solaris2*)
    if test "$GCC" = yes; then
      true
    else
      DEPEND_FLAGS="-xM1"
      DEPEND_EXTRA_SED_PATTERN="-e '/\/opt\/SUNWspro/d'"
    fi
  ;;
esac
AC_SUBST(DEPEND_FLAGS)
AC_SUBST(DEPEND_EXTRA_SED_PATTERN)

### On Intel systems with gcc, we may need to compile with -mieee-fp
### and -ffloat-store to get full support for IEEE floating point.
###
### On Alpha/OSF systems, we need -mieee.

ieee_fp_flag=
case "$canonical_host_type" in
  i[[3456789]]86-*-*)
    if test "$GCC" = yes; then
      OCTAVE_CC_FLAG(-mieee-fp, [
        ieee_fp_flag=-mieee-fp
        XTRA_CFLAGS="$XTRA_CFLAGS -mieee-fp"
        AC_MSG_RESULT([adding -mieee-fp to XTRA_CFLAGS])])

###      OCTAVE_CC_FLAG(-ffloat-store, [
###        float_store_flag=-ffloat-store
###        XTRA_CFLAGS="$XTRA_CFLAGS -ffloat-store"
###        AC_MSG_RESULT([adding -ffloat-store to XTRA_CFLAGS])])
    fi
    if test "$GXX" = yes; then
      OCTAVE_CXX_FLAG(-mieee-fp, [
	ieee_fp_flag=-mieee-fp
	XTRA_CXXFLAGS="$XTRA_CXXFLAGS -mieee-fp"
	AC_MSG_RESULT([adding -mieee-fp to XTRA_CXXFLAGS])])

###      OCTAVE_CXX_FLAG(-ffloat-store, [
###        float_store_flag=-ffloat-store
###        XTRA_CXXFLAGS="$XTRA_CXXFLAGS -ffloat-store"
###        AC_MSG_RESULT([adding -ffloat-store to XTRA_CXXFLAGS])])
    fi
  ;;
  alpha*-*-*)
    if test "$GCC" = yes; then
      OCTAVE_CC_FLAG(-mieee, [
	ieee_fp_flag=-mieee
	XTRA_CFLAGS="$XTRA_CFLAGS -mieee"
	AC_MSG_RESULT([adding -mieee to XTRA_CFLAGS])])
    else
      OCTAVE_CC_FLAG(-ieee, [
	ieee_fp_flag=-ieee
	XTRA_CFLAGS="$XTRA_CFLAGS -ieee"
	AC_MSG_RESULT([adding -ieee to XTRA_CFLAGS])])
    fi
    if test "$GXX" = yes; then
      OCTAVE_CXX_FLAG(-mieee, [
	ieee_fp_flag=-mieee
	XTRA_CXXFLAGS="$XTRA_CXXFLAGS -mieee"
	AC_MSG_RESULT([adding -mieee to XTRA_CXXFLAGS])])
    else
      OCTAVE_CXX_FLAG(-ieee, [
	ieee_fp_flag=-ieee
	XTRA_CXXFLAGS="$XTRA_CXXFLAGS -ieee"
	AC_MSG_RESULT([adding -ieee to XTRA_CXXFLAGS])])
    fi
  ;;
  *ibm-aix4*)
    OCTAVE_CC_FLAG(-mminimal-toc, [
      XTRA_CFLAGS="$XTRA_CFLAGS -mminimal-toc"])

    OCTAVE_CXX_FLAG(-mminimal-toc, [
      XTRA_CXXFLAGS="$XTRA_CXXFLAGS -mminimal-toc"])
  ;;
esac

AC_SUBST(XTRA_CFLAGS)
AC_SUBST(XTRA_CXXFLAGS)

### Use -static if compiling on Alpha OSF/1 1.3 systems.

case "$canonical_host_type" in
  alpha*-dec-osf1.3)
    LD_STATIC_FLAG=-static
  ;;
esac
if test -n "$LD_STATIC_FLAG"; then
  AC_MSG_RESULT([defining LD_STATIC_FLAG to be $LD_STATIC_FLAG])
fi
AC_SUBST(LD_STATIC_FLAG)

OCTAVE_CXX_PREPENDS_UNDERSCORE

### Defaults for cross compiling.  BUILD_CC and BUILD_CXX are
### the compilers that we use for building tools on the build system.
### For now, we assume that the only cross compiling we can do is
### with gcc on a Unixy system, but the dedicated hacker can override these.

if test "$cross_compiling" = yes; then
  BUILD_CC="gcc"
  BUILD_CFLAGS="-O2 -g"
  BUILD_CXX="g++"
  BUILD_CXXFLAGS="-O2 -g"
  BUILD_LDFLAGS=""
  BUILD_EXEEXT=""
else
  BUILD_CC='$(CC)'
  BUILD_CFLAGS='$(CFLAGS)'
  BUILD_CXX='$(CXX)'
  BUILD_CXXFLAGS='$(CXXFLAGS)'
  BUILD_LDFLAGS='$(LDFLAGS)'
  case "$canonical_host_type" in
    sparc-sun-solaris2*)
      if test "$GCC" != yes; then
        ## The Sun C++ compiler never seems to complete compiling
	## gendoc.cc unless we reduce the optimization level...
	BUILD_CXXFLAGS="-g -O1"
      fi
    ;;
  esac
  BUILD_EXEEXT='$(EXEEXT)'
fi

AC_ARG_VAR(BUILD_CC, [build system C compiler (used if cross compiling)])
AC_ARG_VAR(BUILD_CFLAGS, [build system C compiler flags (used if cross compiling)])
AC_ARG_VAR(BUILD_CXX, [build system C++ compiler (used if cross compiling)])
AC_ARG_VAR(BUILD_CXXFLAGS, [build system C++ compiler flags (used if cross compiling)])
AC_ARG_VAR(BUILD_LDFLAGS, [build system C++ compiler link flags (used if cross compiling)])
AC_ARG_VAR(BUILD_EXEEXT, [build system executable extension (used if cross compiling)])

dnl This is bogus.  We shouldn't have to explicitly add libc too!

### Look for math library.  If found, this will add -lm to LIBS.

case "$canonical_host_type" in
  *-*-nextstep*)
  ;;  
  *-*-linux*)
    AC_CHECK_LIB(m, sin, , , -lc)
  ;;
  *)
    AC_CHECK_LIB(m, sin)
  ;;
esac

### Check for HDF5 library.

### XXX FIXME XXX -- how can user specify a set of libraries here?

WITH_HDF5=true
AC_ARG_WITH(hdf5,
  [  --without-hdf5          don't use HDF5],
  with_hdf5=$withval, with_hdf5=yes)

hdf5_lib=
if test "$with_hdf5" = yes; then
  hdf5_lib="hdf5"
elif test "$with_hdf5" != no; then
  hdf5_lib="$with_hdf5"
fi

HDF5_LIBS=
WITH_HDF5=false
if test -n "$hdf5_lib"; then
  AC_CHECK_LIB($hdf5_lib, H5Pcreate, [
    AC_CHECK_LIB(z, deflate, [
      AC_CHECK_HEADERS(hdf5.h, [
	WITH_HDF5=true
        HDF5_LIBS="-l$hdf5_lib -lz"
        LIBS="$HDF5_LIBS $LIBS"
        AC_DEFINE(HAVE_HDF5, 1, [Define if HDF5 is available.])
	AC_CHECK_LIB($hdf5_lib, H5Gget_num_objs, [
	  AC_DEFINE(HAVE_H5GGET_NUM_OBJS, 1, [Define if HDF5 has H5Gget_num_objs.])])])])])
fi

# Checks for FFTW header and library.

# subdirectories of libcruft to build if they aren't found on the system:
FFT_DIR="fftpack"
AC_SUBST(FFT_DIR)

# Installed fftw library, if any.
FFTW_LIBS=''
AC_SUBST(FFTW_LIBS)

AC_ARG_WITH(fftw, 
  [  --without-fftw          use included fftpack instead of installed fftw],
  with_fftw=$withval, with_fftw=yes)

if test "$with_fftw" = "yes"; then
  have_fftw3_header=no
  with_fftw3=no
  AC_CHECK_HEADER(fftw3.h, [have_fftw3_header=yes; break])
  if test "$have_fftw3_header" = yes; then
      AC_CHECK_LIB(fftw3, fftw_plan_dft_1d, [FFTW_LIBS="-lfftw3"; with_fftw3=yes])
  fi
fi

if test "$with_fftw" = yes && test "$with_fftw3" = yes; then
  FFT_DIR=''
  AC_DEFINE(HAVE_FFTW3, 1, [Define if the FFTW3 library is used.])
fi

WITH_MPI=true
AC_ARG_WITH(mpi,
  [  --without-mpi           don't use MPI],
  with_mpi=$withval, with_mpi=yes)

mpi_lib=
if test "$with_mpi" = yes; then
  mpi_lib="mpi"
elif test "$with_mpi" != no; then
  mpi_lib="$with_mpi"
fi

MPI_LIBS=
WITH_MPI=false
if test -n "$mpi_lib"; then
  AC_CHECK_LIB($mpi_lib, MPI_Init, [
    AC_CHECK_HEADERS(mpi.h, [
      WITH_MPI=true
      MPI_LIBS="-l$mpi_lib"
      LIBS="$MPI_LIBS $LIBS"
      AC_DEFINE(HAVE_MPI, 1, [Define if MPI is available.])])])
fi

OCTAVE_IEEE754_DATA_FORMAT

# ----------------------------------------------------------------------

### We need these before trying to find libf2c.

OCTAVE_PROG_AR

AC_PROG_RANLIB

### If we haven't been forced to use a particular Fortran compiler,
### try to find one using any one of several common Un*x Fortran
### compiler names using the AC_PROG_F77 macro.
###
### The configure options --with-f77 or --with-f2c
### force f77 or f2c to be used.  It is also possible to use
### these options to specify the name of the compiler.  For example,
### `--with-f77=g77' says that we are using g77 as the Fortran compiler.

if $use_f77; then
  if test "$with_f77" = yes; then
    F77=f77
  else
    F77="$with_f77"
  fi
  AC_MSG_RESULT([defining F77 to be $F77])
elif $use_f2c; then
  F77=
  if test "$with_f2c" = yes; then
    F2C=f2c
  else
    F2C="$with_f2c"
  fi
  AC_MSG_RESULT([defining F2C to be $F2C])
fi

if test "x$FFLAGS" = x; then
  FFLAGS="-O" # override -g -O default by AC_PROG_F77
fi

# the F77 variable, if set, overrides AC_PROG_F77 automatically
AC_PROG_F77

have_fortran_compiler=false
have_f2c=false

if $use_f2c; then
  have_f2c=true
else
  if test -n "$F77"; then
    AC_F77_LIBRARY_LDFLAGS
    AC_F77_DUMMY_MAIN
    AC_F77_WRAPPERS
    case "$canonical_host_type" in
      i[[3456789]]86-*-*)
        if test "$ac_cv_f77_compiler_gnu" = yes; then
	  OCTAVE_F77_FLAG(-mieee-fp)
###          OCTAVE_F77_FLAG(-ffloat-store)
	fi
      ;;
      alpha*-*-*)
        if test "$ac_cv_f77_compiler_gnu" = yes; then
	  OCTAVE_F77_FLAG(-mieee)
	else
	  OCTAVE_F77_FLAG(-ieee)
	  OCTAVE_F77_FLAG(-fpe1)
	fi
      ;;
      powerpc-apple-machten*)
	FFLAGS=
      ;;
    esac
    if test -n "$FFLAGS"; then
      AC_MSG_RESULT([defining FFLAGS to be $FFLAGS])
    fi
    have_fortran_compiler=true
  else
    AC_CHECK_PROG(F2C, f2c, f2c, [])
    AC_ARG_VAR(F2C, [Fortran to C translator command])
    AC_ARG_VAR(F2CFLAGS, [Fortran to C translator flags])
    if test -n "$F2C"; then
      have_f2c=true
    fi
  fi
fi

f77_rules_frag=/dev/null
if $have_fortran_compiler; then
  f77_rules_frag=Makefrag.f77
  cat << \EOF > $f77_rules_frag

%.c : %.f

%.o : %.f
	$(FC) -c $(ALL_FFLAGS) -o $@ $<

pic/%.o : %.f
	$(FC) -c $(FPICFLAG) $(ALL_FFLAGS) $< -o $@

EOF
elif $have_f2c; then
  AC_DEFINE(HAVE_F2C, 1, [Define if we are using f2c.])

### XXX FIMXE XXX -- these shouldn't be fixed names, eh?

  oct_conflib=libconflib.a
  oct_obj_ext=o

  CONFLIB_ARG=
  if AC_TRY_EVAL(ac_compile); then
    $AR $ARFLAGS $oct_conflib conftest.$oct_obj_ext 1>&AS_MESSAGE_LOG_FD()
    if test -n "$RANLIB"; then
      $RANLIB $oct_conflib 1>&AS_MESSAGE_LOG_FD()
    fi
    CONFLIB_ARG="-L. -lconflib"
  fi
  rm -f conftest*
  AC_CHECK_LIB(f2c, f_open, FLIBS=-lf2c, FLIBS=, $CONFLIB_ARG)
  rm -f $oct_conflib

  if test -z "$FLIBS"; then
    AC_CHECK_LIB(F77, d_sin, FLIBS=-lF77, FLIBS=)
    if test -n "$FLIBS"; then
      AC_CHECK_LIB(I77, f_rew, FLIBS="$FLIBS -lI77", FLIBS=, -lF77)
    fi
  fi

  if test -z "$FLIBS"; then
    warn_f2c_no_lib="I found f2c but not libf2c.a, or libF77.a and libI77.a"
    AC_MSG_WARN($warn_f2c_no_lib)
  fi
  f77_rules_frag=Makefrag.f77
  cat << \EOF > $f77_rules_frag

%.c : %.f
	$(F2C) $(F2CFLAGS) < $< > $(@F)

%.o : %.f

EOF
else
  AC_MSG_WARN([in order to build octave, you must have a compatible])
  AC_MSG_WARN([Fortran compiler or f2c installed and in your path.])
  AC_MSG_ERROR([See the file INSTALL for more information.])
fi

FC=$F77
AC_SUBST(FC)
AC_SUBST_FILE(f77_rules_frag)

### Checks for BLAS and LAPACK libraries:
# (Build subdirectories of libcruft if they aren't found on the system.)

sinclude(acx_blas.m4)
sinclude(acx_lapack.m4)
ACX_BLAS([], [BLAS_DIR="blas"])
ACX_LAPACK([BLAS_LIBS="$LAPACK_LIBS $BLAS_LIBS"], [LAPACK_DIR="lapack"])
AC_SUBST(BLAS_DIR)
AC_SUBST(LAPACK_DIR)

### Handle shared library options.

### Enable creation of static libraries.

AC_ARG_ENABLE(static,
  [  --enable-static         create static libraries],
  [if test "$enableval" = no; then STATIC_LIBS=false;
   else STATIC_LIBS=true; fi],
  STATIC_LIBS=true)
AC_SUBST(STATIC_LIBS)

### Enable creation of shared libraries.  Currently only works with
### gcc on some systems.

AC_ARG_ENABLE(shared,
  [  --enable-shared         create shared libraries (not all systems)],
  [if test "$enableval" = no; then SHARED_LIBS=false;
   else SHARED_LIBS=true; fi],
  SHARED_LIBS=false)
AC_SUBST(SHARED_LIBS)

### Enable dynamic linking.  --enable-shared implies this, so
### --enable-dl is only need if you are only building static libraries
### and want to try dynamic linking too (works on some systems, for
### example, OS X and Windows).

AC_ARG_ENABLE(dl,
  [  --enable-dl             create shared libraries (not all systems)],
  [if test "$enableval" = no; then ENABLE_DYNAMIC_LINKING=false;
   else ENABLE_DYNAMIC_LINKING=true; fi],
  ENABLE_DYNAMIC_LINKING=false)

if $STATIC_LIBS || $SHARED_LIBS; then
  true
else
  AC_MSG_ERROR([You can't disable building static AND shared libraries!])
fi

AC_ARG_ENABLE(rpath,
  [  --enable-rpath          override the default link options for rpath;
                            e.g., --enable-rpath='-rpath $(octlibdir)'],
  [ if test "$enableval" = no; then use_rpath=false;
    else
      use_rpath=true
      if test "$enableval" = yes; then true;
      else enable_rpath_arg="$enableval"; fi
    fi], [use_rpath=true])

DLFCN_DIR=
CPICFLAG=-fPIC
CXXPICFLAG=-fPIC
FPICFLAG=-fPIC
SHLEXT=so
SHLLIB='$(SHLEXT)'
SHLBIN=
SHLEXT_VER='$(SHLEXT).$(version)'
SHLLIB_VER='$(SHLLIB).$(version)'
SHLBIN_VER='$(SHLBIN).$(version)'
SHLLINKEXT=
SH_LD='$(CXX)'
SH_LDFLAGS=-shared
DL_LD='$(SH_LD)'
DL_LDFLAGS='$(SH_LDFLAGS)'
MKOCTFILE_DL_LDFLAGS='$(DL_LDFLAGS)'
SONAME_FLAGS=
RLD_FLAG=
NO_OCT_FILE_STRIP=false
TEMPLATE_AR='$(AR)'
TEMPLATE_ARFLAGS="$ARFLAGS"
library_path_var=LD_LIBRARY_PATH
case "$canonical_host_type" in
  *-*-386bsd* | *-*-openbsd* | *-*-netbsd*)
    SH_LD=ld
    SH_LDFLAGS=-Bshareable
  ;;
  *-*-freebsd*)
    SH_LD='$(CC)'
    SH_LDFLAGS=-shared -Wl,-x
  ;;
  alpha*-dec-osf*)
    CPICFLAG=
    CXXPICFLAG=
    FPICFLAG=
    SH_LDFLAGS="-shared -Wl,-expect_unresolved -Wl,'*'"
    RLD_FLAG='-Wl,-rpath -Wl,$(octlibdir)'
  ;;
  *-*-darwin*)
    DL_LDFLAGS='-bundle -bundle_loader $(TOPDIR)/src/octave $(LDFLAGS)'
    MKOCTFILE_DL_LDFLAGS='-bundle -bundle_loader $(bindir)/octave-$(version)$(EXEEXT)'
    SH_LDFLAGS='-dynamiclib -single_module $(LDFLAGS)'
    CXXPICFLAG=
    CPICFLAG=
    FPICFLAG=
    SHLEXT=dylib 
    SHLLIB='$(SHLEXT)'
    SHLEXT_VER='$(version).$(SHLEXT)'
    SHLLIB_VER='$(version).$(SHLLIB)'
    NO_OCT_FILE_STRIP=true
    SONAME_FLAGS='-install_name $(octlibdir)/$@'
    library_path_var=DYLD_LIBRARY_PATH	
  ;;
  *-*-cygwin* | *-*-mingw*)
    CXXPICFLAG=
    CPICFLAG=
    FPICFLAG=
    SHLEXT=dll
    SHLLIB=dll.a
    SHLBIN=dll
    SH_LDFLAGS="-shared -Wl,--export-all-symbols -Wl,--enable-auto-import"
    SHLLINKEXT=.dll
    SONAME_FLAGS='-Wl,--out-implib=$@.a'
    library_path_var=PATH
  ;;
  *-*-linux* | *-*-gnu*)
    MKOCTFILE_DL_LDFLAGS="-shared -Wl,-Bsymbolic"
    SONAME_FLAGS='-Wl,-soname -Wl,$@'
    RLD_FLAG='-Wl,-rpath -Wl,$(octlibdir)'
  ;;
  i[[3456]]86-*-sco3.2v5*)
    SONAME_FLAGS='-Wl,-h -Wl,$@'
    RLD_FLAG=
    SH_LDFLAGS=-G
  ;;
  rs6000-ibm-aix* | powerpc-ibm-aix*)
    CPICFLAG=
    CXXPICFLAG=
    FPICFLAG=
    DLFCN_DIR=dlfcn
  ;;
  hppa*-hp-hpux*)
    if test "$ac_cv_f77_compiler_gnu" = yes; then
      FPICFLAG=-fPIC
    else
      FPICFLAG=+Z
    fi
    SHLEXT=sl
    SH_LDFLAGS="-shared -fPIC"
    RLD_FLAG='-Wl,+b -Wl,$(octlibdir)'
  ;;
  *-sgi-*)
    CPICFLAG=
    CXXPICFLAG=
    FPICFLAG=
    RLD_FLAG='-rpath $(octlibdir)'
  ;;
  sparc-sun-sunos4*)
    if test "$ac_cv_f77_compiler_gnu" = yes; then
      FPICFLAG=-fPIC
    else
      FPICFLAG=-PIC
    fi
    SH_LD=ld
    SH_LDFLAGS="-assert nodefinitions"
    RLD_FLAG='-L$(octlibdir)'
  ;;
  sparc-sun-solaris2* | i386-pc-solaris2*)
    if test "$ac_cv_f77_compiler_gnu" = yes; then
      FPICFLAG=-fPIC
    else
      FPICFLAG=-KPIC
    fi
    if test "$GCC" = yes; then
      CPICFLAG=-fPIC
    else
      CPICFLAG=-KPIC
    fi
    if test "$GXX" = yes; then
      CXXPICFLAG=-fPIC
      SH_LDFLAGS=-shared
    else
      CXXPICFLAG=-KPIC
      SH_LDFLAGS=-G
    fi
    RLD_FLAG='-R $(octlibdir)'
    # Template closures in archive libraries need a different mechanism.
    if test "$GXX" = yes; then
      true
    else
      TEMPLATE_AR='$(CXX)'
      TEMPLATE_ARFLAGS="-xar -o"
    fi
  ;;
esac

if $use_rpath; then
  if test -n "$enable_rpath_arg"; then
    RLD_FLAG="$enable_rpath_arg"
  fi
else
  RLD_FLAG=""
fi

AC_MSG_RESULT([defining FPICFLAG to be $FPICFLAG])
AC_MSG_RESULT([defining CPICFLAG to be $CPICFLAG])
AC_MSG_RESULT([defining CXXPICFLAG to be $CXXPICFLAG])
AC_MSG_RESULT([defining SHLEXT to be $SHLEXT])
AC_MSG_RESULT([defining SHLLIB to be $SHLLIB])
AC_MSG_RESULT([defining SHLBIN to be $SHLBIN])
AC_MSG_RESULT([defining SHLEXT_VER to be $SHLEXT_VER])
AC_MSG_RESULT([defining SHLLIB_VER to be $SHLLIB_VER])
AC_MSG_RESULT([defining SHLBIN_VER to be $SHLBIN_VER])
AC_MSG_RESULT([defining SHLLINKEXT to be $SHLLINKEXT])
AC_MSG_RESULT([defining DLFCN_DIR to be $DLFCN_DIR])
AC_MSG_RESULT([defining SH_LD to be $SH_LD])
AC_MSG_RESULT([defining SH_LDFLAGS to be $SH_LDFLAGS])
AC_MSG_RESULT([defining DL_LD to be $DL_LD])
AC_MSG_RESULT([defining DL_LDFLAGS to be $DL_LDFLAGS])
AC_MSG_RESULT([defining MKOCTFILE_DL_LDFLAGS to be $MKOCTFILE_DL_LDFLAGS])
AC_MSG_RESULT([defining SONAME_FLAGS to be $SONAME_FLAGS])
AC_MSG_RESULT([defining NO_OCT_FILE_STRIP to be $NO_OCT_FILE_STRIP])
AC_MSG_RESULT([defining RLD_FLAG to be $RLD_FLAG])
AC_MSG_RESULT([defining TEMPLATE_AR to be $TEMPLATE_AR])
AC_MSG_RESULT([defining TEMPLATE_ARFLAGS to be $TEMPLATE_ARFLAGS])
AC_MSG_RESULT([defining library_path_var to be $library_path_var])
AC_SUBST(FPICFLAG)
AC_SUBST(CPICFLAG)
AC_SUBST(CXXPICFLAG)
AC_SUBST(SHLEXT)
AC_SUBST(SHLLIB)
AC_SUBST(SHLBIN)
AC_SUBST(SHLEXT_VER)
AC_SUBST(SHLLIB_VER)
AC_SUBST(SHLBIN_VER)
AC_SUBST(SHLLINKEXT)
AC_SUBST(DLFCN_DIR)
AC_SUBST(SH_LD)
AC_SUBST(SH_LDFLAGS)
AC_SUBST(DL_LD)
AC_SUBST(DL_LDFLAGS)
AC_SUBST(MKOCTFILE_DL_LDFLAGS)
AC_SUBST(SONAME_FLAGS)
AC_SUBST(NO_OCT_FILE_STRIP)
AC_SUBST(RLD_FLAG)
AC_SUBST(TEMPLATE_AR)
AC_SUBST(TEMPLATE_ARFLAGS)
AC_SUBST(library_path_var)

### special checks for odd OS specific things.
###
### I am told that on some SCO systems, the only place to find some
### functions like gethostname and gettimeofday is in libsocket.

AC_CHECK_FUNCS(gethostname, [], [AC_CHECK_LIB(socket, gethostname)])
AC_CHECK_FUNCS(getpwnam, [], [AC_CHECK_LIB(sun, getpwnam)])

case "$canonical_host_type" in
  *-*-cygwin* | *-*-mingw*)
   AC_CHECK_LIB(wsock32, gethostname)
  ;;
esac

### Type stuff.

AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPES([dev_t, ino_t, nlink_t, nlink_t])
AC_CHECK_TYPES([long long int, unsigned long long int])
AC_CHECK_TYPES([sigset_t, sig_atomic_t], , , [#include <signal.h>])

### How big are ints and how are they oriented?  These could probably
### be eliminated in favor of run-time checks.

AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)

### Does the C compiler handle alloca() and const correctly?

AC_FUNC_ALLOCA
AC_C_CONST

### See if we should define NPOS.

OCTAVE_STRING_NPOS

### See if we should use placement delete.

OCTAVE_PLACEMENT_DELETE

### See if we can auto allocate variable sized arrays.

OCTAVE_DYNAMIC_AUTO_ARRAYS

### Checks for header files.

AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_HEADER_SYS_WAIT

### C headers

AC_CHECK_HEADERS(assert.h curses.h direct.h dlfcn.h fcntl.h float.h \
  floatingpoint.h grp.h ieeefp.h limits.h memory.h nan.h \
  ncurses.h poll.h pwd.h stdlib.h string.h sys/ioctl.h \
  sys/param.h sys/poll.h sys/resource.h sys/select.h sys/stat.h \
  sys/time.h sys/times.h sys/types.h sys/utsname.h termcap.h \
  unistd.h varargs.h)

### C++ headers

AC_LANG_PUSH(C++)
AC_CHECK_HEADERS(sstream)
AC_LANG_POP(C++)

have_termios_h=no
AC_CHECK_HEADERS($TERMIOS_H, have_termios_h=yes)
AC_CHECK_HEADERS(termio.h, have_termio_h=yes, have_termio_h=no)
AC_CHECK_HEADERS(sgtty.h, have_sgtty_h=yes, have_sgtty_h=no)
AC_CHECK_HEADERS(conio.h, have_conio_h=yes, have_conio_h=no)

### I'm told that termios.h is broken on NeXT systems.

case "$canonical_host_type" in
  *-*-nextstep*)
    if test "$have_termios_h" = yes; then
      AC_MSG_WARN([Ignoring termios.h on NeXT systems.])
      have_termios_h=no
    fi
  ;;
esac

if test "$have_termios_h" = yes \
    || test "$have_termio_h" = yes \
    || test "$have_sgtty_h" = yes; then
  true
else
  AC_MSG_WARN([I couldn't find termios.h, termio.h, or sgtty.h!])
fi

### Checks for functions and variables.

AC_CHECK_FUNCS(atexit basename bcopy bzero canonicalize_file_name \
  dup2 endgrent endpwent execvp fcntl fork getcwd getegid geteuid \
  getgid getgrent getgrgid getgrnam getpgrp getpid getppid getpwent \
  getpwuid gettimeofday getuid getwd _kbhit kill link localtime_r \
  lstat memmove mkdir mkfifo mkstemp on_exit pipe poll putenv raise \
  readlink rename resolvepath rindex rmdir round select setgrent \
  setpwent setvbuf sigaction siglongjmp sigpending sigprocmask \
  sigsuspend stat strcasecmp strdup strerror strftime stricmp \
  strncasecmp strnicmp strptime symlink tempnam umask unlink usleep \
  vfprintf vsprintf vsnprintf waitpid)

OCTAVE_SMART_PUTENV

### Dynamic linking is now enabled only if we are building shared
### libs and some API for dynamic linking is detected.

LD_CXX='$(CXX)'
LIBDLFCN=
DLFCN_INCFLAGS=
RDYNAMIC_FLAG=
DL_API_MSG=""
dlopen_api=false
shl_load_api=false
loadlibrary_api=false
dyld_api=false

if $SHARED_LIBS || $ENABLE_DYNAMIC_LINKING; then

  ### Check for dyld first since OS X can have a non-standard libdl	

  AC_CHECK_HEADER(mach-o/dyld.h)  
  if test "$ac_cv_header_Mach_O_dyld_h" = yes; then
    dyld_api=true
  else 
    AC_CHECK_LIB(dld, shl_load)
    AC_CHECK_FUNCS(shl_load shl_findsym)
    if test "$ac_cv_func_shl_load" = yes \
      && test "$ac_cv_func_shl_findsym" = yes; then
      shl_load_api=true
    else
      AC_CHECK_LIB(wsock32, LoadLibrary)
      AC_CHECK_FUNCS(LoadLibrary)
      if test "$ac_cv_func_loadlibrary" = yes; then
        loadlibrary_api=true
      else
        AC_CHECK_LIB(dl, dlopen)
        AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose)
        if test "$ac_cv_func_dlclose" = yes \
          && test "$ac_cv_func_dlerror" = yes \
          && test "$ac_cv_func_dlopen" = yes \
          && test "$ac_cv_func_dlsym" = yes; then
          dlopen_api=true
        else
	  case "$canonical_host_type" in
	    rs6000-ibm-aix* | powerpc-ibm-aix*)
	      LIBDLFCN="-ldlfcn -ll -lld"
	      DLFCN_INCFLAGS='-I$(top_srcdir)/dlfcn -I$(TOPDIR)/dlfcn'
	      dlopen_api=true
	    ;;
	    i[[3456]]86-*-sco3.2v5*)
	      LD_CXX='LD_RUN_PATH=$LD_RUN_PATH:$(octlibdir) $(CXX)'
	      dlopen_api=true
	    ;;
	  esac
	fi
      fi
    fi
  fi

  if $dlopen_api; then
    DL_API_MSG="(dlopen)"
    AC_DEFINE(HAVE_DLOPEN_API, 1, [Define if your system has dlopen, dlsym, dlerror, and dlclose for dynamic linking])
    OCTAVE_CXX_FLAG(-rdynamic, [RDYNAMIC_FLAG=-rdynamic])
  elif $shl_load_api; then
    DL_API_MSG="(shl_load)"
    AC_DEFINE(HAVE_SHL_LOAD_API, 1, [Define if your system has shl_load and shl_findsym for dynamic linking])
  elif $loadlibrary_api; then
    DL_API_MSG="(LoadLibrary)"
    AC_DEFINE(HAVE_LOADLIBRARY_API, 1, [Define if your system has LoadLibrary for dynamic linking])
  elif $dyld_api; then
    DL_API_MSG="(dyld)"
    AC_DEFINE(HAVE_DYLD_API, 1, [Define if your system has dyld for dynamic linking])
  fi

  if $dlopen_api || $shl_load_api || $loadlibrary_api || $dyld_api; then
    ENABLE_DYNAMIC_LINKING=true
    AC_DEFINE(ENABLE_DYNAMIC_LINKING, 1, [Define if using dynamic linking])
  fi
fi

if $SHARED_LIBS; then
   LIBOCTINTERP=-loctinterp$SHLLINKEXT
   LIBOCTAVE=-loctave$SHLLINKEXT
   LIBCRUFT=-lcruft$SHLLINKEXT
else
  LIBOCTINTERP='$(TOPDIR)/src/liboctinterp.$(LIBEXT)'
  LIBOCTAVE='$(TOPDIR)/liboctave/liboctave.$(LIBEXT)'
  LIBCRUFT='$(TOPDIR)/libcruft/libcruft.$(LIBEXT)'
fi

AC_SUBST(LD_CXX)
AC_SUBST(LIBDLFCN)
AC_SUBST(DLFCN_INCFLAGS)
AC_SUBST(RDYNAMIC_FLAG)
AC_SUBST(ENABLE_DYNAMIC_LINKING)
AC_SUBST(LIBOCTINTERP)
AC_SUBST(LIBOCTAVE)
AC_SUBST(LIBCRUFT)

### There is more than one possible prototype for gettimeofday.  See
### which one (if any) appears in sys/time.h.  These tests are from
### Emacs 19.

AC_MSG_CHECKING(for struct timeval)
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif], [static struct timeval x; x.tv_sec = x.tv_usec;],
  [AC_MSG_RESULT(yes)
   HAVE_TIMEVAL=yes
   AC_DEFINE(HAVE_TIMEVAL, 1, [Define if struct timeval is defined.])],
  [AC_MSG_RESULT(no)
   HAVE_TIMEVAL=no])

if test "x$HAVE_TIMEVAL" = xyes; then
AC_MSG_CHECKING(whether gettimeofday can't accept two arguments)
AC_TRY_LINK([#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif],[struct timeval time; struct timezone dummy;
  gettimeofday (&time, &dummy);], [AC_MSG_RESULT(no)],
  [AC_MSG_RESULT(yes)
   AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1, [Define if your system has a single-arg prototype for gettimeofday.])])
fi

dnl Would like to get rid of this cruft, and just have
dnl
dnl   AC_CHECK_FUNCS(finite isnan isinf)
dnl
dnl instead, but that used to fail on some systems...
dnl
dnl Also just using AC_CHECK_FUNCS doesn't seem to work to find isinf
dnl and isnan on Linux systems, so we use AC_CHECK_FUNC, and if that
dnl fails, we try again by including math.h and invoking the function
dnl with an argument. 

### I am told that Inf and NaN don't work on m68k HP sytems, and that
### on SCO systems, isnan and isinf don't work, but they can be
### replaced by something that does.

case "$canonical_host_type" in
  m68k-hp-hpux*)
  ;;
  *-*-sco*)
    AC_MSG_RESULT([defining SCO to be 1])
    AC_DEFINE(SCO, 1, [Define if using an SCO system.])
    AC_MSG_RESULT([forcing HAVE_ISINF for SCO])
    AC_DEFINE(HAVE_ISINF, 1, [Define if you have isinf().])
    AC_MSG_RESULT([forcing HAVE_ISNAN for SCO])
    AC_DEFINE(HAVE_ISNAN, 1, [Define if you have isnan().])
  ;;
  *)
    AC_CHECK_FUNCS(finite isnan isinf copysign signbit)
    AC_CHECK_DECLS(signbit, , , [#include <math.h>])
  ;;
esac

### Check for nonstandard but common math functions that we need.

AC_CHECK_FUNCS(acosh asinh atanh erf erfc)

### Checks for OS specific cruft.

AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct stat.st_rdev])

AC_STRUCT_TM
AC_STRUCT_TIMEZONE
AC_FUNC_CLOSEDIR_VOID

AC_CHECK_MEMBERS(struct group.gr_passwd)

# mkdir takes a single argument on some systems.
OCTAVE_MKDIR_TAKES_ONE_ARG

octave_found_termlib=no
for termlib in ncurses curses termcap terminfo termlib; do
  AC_CHECK_LIB(${termlib}, tputs, [TERMLIBS="${TERMLIBS} -l${termlib}"])
  case "${TERMLIBS}" in
    *-l${termlib}*)
      LIBS="$TERMLIBS $LIBS"
      AC_SUBST(TERMLIBS)
      octave_found_termlib=yes
      break
    ;;
  esac
done

if test "$octave_found_termlib" = no; then
  warn_termlibs="I couldn't find -ltermcap, -lterminfo, -lncurses, -lcurses, o\
r -ltermlib!"
  AC_MSG_WARN($warn_termlibs)
fi

OCTAVE_ENABLE_READLINE

AC_MSG_CHECKING([for struct exception in math.h])
AC_TRY_LINK([#include <math.h>],
  [struct exception *x; x->type; x->name;],
  AC_MSG_RESULT(yes)
  AC_DEFINE(EXCEPTION_IN_MATH, 1, [Define if your math.h declares struct exception for matherr().]),
  AC_MSG_RESULT(no))

### Signal stuff.

AC_TYPE_SIGNAL
AC_CHECK_DECL([sys_siglist],
  [AC_DEFINE(SYS_SIGLIST_DECLARED, 1, [Define if your system has a declaration of sys_siglist.])],
  [AC_CHECK_DECLS([sys_siglist])], [#include <signal.h>])
AC_MSG_CHECKING([for sys_siglist variable])
AC_TRY_LINK([#include <stdio.h>],
  [extern char *sys_siglist[]; printf ("%s\n", sys_siglist[1]);],
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if your system has a sys_siglist variable.]),
  AC_MSG_RESULT(no))
OCTAVE_SIGNAL_CHECK
OCTAVE_REINSTALL_SIGHANDLERS

### A system dependent kluge or two.

AC_CHECK_FUNCS(getrusage times)
case "$canonical_host_type" in
  *-*-cygwin*)
    AC_DEFINE(RUSAGE_TIMES_ONLY, 1, [Define if your struct rusage only has time information.])
  ;;
esac

bsd_gcc_kluge_targets_frag=/dev/null
case "$canonical_host_type" in
  *-*-386bsd* | *-*-openbsd* | *-*-netbsd* | *-*-freebsd*)
    bsd_gcc_kluge_targets_frag=Makefrag.bsd
    cat << \EOF > $bsd_gcc_kluge_targets_frag

lex.o: lex.cc 
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS_NO_PT_FLAGS) $<

pt-plot.o: pt-plot.cc
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS_NO_PT_FLAGS) $<

symtab.o: symtab.cc
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS_NO_PT_FLAGS) $<

toplev.o: toplev.cc
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS_NO_PT_FLAGS) $<

unwind-prot.o: unwind-prot.cc 
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS_NO_PT_FLAGS) $<

EOF
  ;;
esac
AC_SUBST_FILE(bsd_gcc_kluge_targets_frag)

### Checks for other programs used for building, testing, installing,
### and running Octave.

AC_PROG_AWK
OCTAVE_PROG_SED

OCTAVE_PROG_FLEX
OCTAVE_PROG_BISON

AC_PROG_LN_S

OCTAVE_PROG_NM
OCTAVE_PROG_RUNTEST

AC_PROG_INSTALL
INSTALL_SCRIPT='${INSTALL}'
AC_SUBST(INSTALL_SCRIPT)

OCTAVE_PROG_GNUPLOT
OCTAVE_PROG_PAGER
OCTAVE_PROG_GPERF

### Even though we include config.h, we need to have the preprocessor
### defines available in a variable for the octave-bug script.  Use
### UGLY_DEFS for that.

AC_OUTPUT_MAKE_DEFS


dnl Maybe this should really be conditional on "broken sed", or
dnl "broken shell backslash quoting" or somesuch.
dnl
case "$canonical_host_type" in
  *-*-darwin*)
    UGLY_DEFS=`echo $DEFS | sed 's,\\",\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\",g'`
  ;;
  *)
    UGLY_DEFS=`echo $DEFS | sed 's,\\",\\\\\\\\\\\\\\\\\\",g'`
  ;;
esac
AC_MSG_RESULT([defining UGLY_DEFS to be $UGLY_DEFS])
AC_SUBST(UGLY_DEFS)

### Maybe add -Wall, -W, and -Wshadow to compiler flags now that we're
### done feature testing. 

if test -z "$EXTERN_CFLAGS"; then
  OCTAVE_CC_FLAG(-Wall, [
	WARN_CFLAGS="$WARN_CFLAGS -Wall";
	AC_MSG_RESULT([adding -Wall to WARN_CFLAGS])])
  OCTAVE_CC_FLAG(-W, [
	WARN_CFLAGS="$WARN_CFLAGS -W";
	AC_MSG_RESULT([adding -W to WARN_CFLAGS])])
  OCTAVE_CC_FLAG(-Wshadow, [
	WARN_CFLAGS="$WARN_CFLAGS -Wshadow";
	AC_MSG_RESULT([adding -Wshadow to WARN_CFLAGS])])
fi

if test -z "$EXTERN_CXXFLAGS"; then
  OCTAVE_CXX_FLAG(-Wall, [
    WARN_CXXFLAGS="$WARN_CXXFLAGS -Wall";
    AC_MSG_RESULT([adding -Wall to WARN_CXXFLAGS])])
  OCTAVE_CXX_FLAG(-W, [
    WARN_CXXFLAGS="$WARN_CXXFLAGS -W";
    AC_MSG_RESULT([adding -W to WARN_CXXFLAGS])])
  OCTAVE_CXX_FLAG(-Wshadow, [
    WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow";
    AC_MSG_RESULT([adding -Wshadow to WARN_CXXFLAGS])])
fi

### Someday, maybe include -ansi and even -pedantic in this list...

GCC_PICKY_FLAGS="-Wcast-align -Wcast-qual -Wmissing-prototypes \
  -Wpointer-arith -Wstrict-prototypes -Wwrite-strings"

GXX_PICKY_FLAGS="-Wcast-align -Wcast-qual -Wpointer-arith \
  -Wwrite-strings -Weffc++ -Wenum-clash"

AC_ARG_ENABLE(picky-flags,
  [  --enable-picky-flags    add picky options to CFLAGS, CXXFLAGS, FFLAGS],
  [if test "$enableval" = no; then
     true
   elif test "$enableval" = yes; then
     if test -z "$EXTERN_CFLAGS"; then
       for flag in $GCC_PICKY_FLAGS; do
	 OCTAVE_CC_FLAG($flag, [
	   WARN_CFLAGS="$WARN_CFLAGS $flag";
	   AC_MSG_RESULT([adding $flag to WARN_CFLAGS])])
       done
     fi
     if test -z "$EXTERN_CXXFLAGS"; then
       for flag in $GXX_PICKY_FLAGS; do
	 OCTAVE_CXX_FLAG($flag, [
	   WARN_CXXFLAGS="$WARN_CXXFLAGS $flag";
	   AC_MSG_RESULT([adding $flag to WARN_CXXFLAGS])])
       done
     fi
   fi], [])

AC_SUBST(WARN_CFLAGS)
AC_SUBST(WARN_CXXFLAGS)

### Run configure in subdirectories.

export CC
export CXX
export F77

AC_CONFIG_SUBDIRS(scripts)

if test "x$PLPLOT_DIR" = xplplot; then
	AC_CONFIG_SUBDIRS(plplot)
fi

### Some things to add to the bottom of config.h.

AH_BOTTOM([
#if defined (__GNUC__)
#define GCC_ATTR_NORETURN __attribute__ ((__noreturn__))
#define GCC_ATTR_UNUSED __attribute__ ((__unused__))
#else
#define GCC_ATTR_NORETURN
#define GCC_ATTR_UNUSED
#endif

#define CONST_CAST(T, E) (T) (E)

#define DYNAMIC_CAST(T, E) (T) (E)

#define REINTERPRET_CAST(T, E) (T) (E)

#define STATIC_CAST(T, E) (T) (E)

#define X_CAST(T, E) (T) (E)

#if defined(HAVE_F2C) && !defined(F77_FUNC)
#  define F77_FUNC(x,X) x ## _
#  define F77_FUNC_(x,X) x ## __
#endif

#if !defined(HAVE_DEV_T)
typedef short dev_t;
#endif

#if !defined(HAVE_INO_T)
typedef unsigned long ino_t;
#endif

#if !defined(HAVE_NLINK_T)
typedef short nlink_t;
#endif

#if !defined(HAVE_SIGSET_T)
typedef int sigset_t;
#endif

#if !defined(HAVE_SIG_ATOMIC_T)
typedef int sig_atomic_t;
#endif

#define OCTAVE_HAVE_POSIX_FILESYSTEM 1

#if defined (__WIN32__) && ! defined (__CYGWIN__)
#define OCTAVE_HAVE_WINDOWS_FILESYSTEM 1
#undef OCTAVE_HAVE_POSIX_FILESYSTEM
#endif

#if defined (__CYGWIN__)
#define OCTAVE_HAVE_WINDOWS_FILESYSTEM 1
#define OCTAVE_HAVE_POSIX_FILESYSTEM 1
#endif

/* Define if we expect to have <windows.h>, Sleep, etc. */
#if defined (__WIN32__) && ! defined (__CYGWIN__)
#define OCTAVE_USE_WINDOWS_API 1
#endif

/* sigsetjmp is a macro, not a function. */
#if defined (sigsetjmp) && defined (HAVE_SIGLONGJMP)
#define OCTAVE_HAVE_SIG_JUMP
#endif

/* Always use vector<T>, since we sometimes allocate large chunks
   of memory and that can cause trouble due to stack size limits.

   Note that using auto_ptr is not appropriate because it uses delete,
   not delete[] and we need the latter to properly handle arrays
   allocated with new[size].

   Use < T > instead of <T> to avoid problems if T is a template type
   (say, foo<int>) and the preprocessor fails to insert a space and
   generates <foo<int>>.

#if defined (HAVE_DYNAMIC_AUTO_ARRAYS)

#define OCTAVE_LOCAL_BUFFER(T, buf, size) \
  T buf[size]

#else

*/

#define OCTAVE_LOCAL_BUFFER(T, buf, size) \
  std::vector< T > buf ## _vector (size); \
  T *buf = &(buf ## _vector[0])

/* #endif */

#if defined (__DECCXX)
#define __USE_STD_IOSTREAM
#endif

#if defined (_UNICOS)
#define F77_USES_CRAY_CALLING_CONVENTION
#endif

#if 0
#define F77_USES_VISUAL_FORTRAN_CALLING_CONVENTION
#endif
])

### Do the substitutions in all the Makefiles.

AC_CONFIG_FILES([Makefile octMakefile Makeconf install-octave \
  test/Makefile dlfcn/Makefile \
  doc/Makefile doc/faq/Makefile doc/interpreter/Makefile \
  doc/liboctave/Makefile doc/refcard/Makefile emacs/Makefile \
  examples/Makefile liboctave/Makefile src/Makefile \
  libcruft/Makefile libcruft/Makerules libcruft/amos/Makefile \
  libcruft/blas/Makefile libcruft/daspk/Makefile \
  libcruft/dasrt/Makefile libcruft/dassl/Makefile \
  libcruft/fftpack/Makefile libcruft/lapack/Makefile \
  libcruft/minpack/Makefile libcruft/misc/Makefile \
  libcruft/odepack/Makefile \
  libcruft/ordered-qz/Makefile libcruft/quadpack/Makefile \
  libcruft/ranlib/Makefile libcruft/slatec-fn/Makefile \
  libcruft/slatec-err/Makefile libcruft/villad/Makefile \
  libcruft/blas-xtra/Makefile libcruft/lapack-xtra/Makefile])
AC_OUTPUT

AC_CONFIG_COMMANDS([default-1],[[chmod +x install-octave]],[[]])

### Print a summary so that important information isn't missed.

if test -z "$F77"; then
  FORT="$F2C $F2CFLAGS"
else
  FORT="$F77 $FFLAGS"
fi

AC_MSG_RESULT([

Octave is now configured for $canonical_host_type

  Source directory:     $srcdir
  Installation prefix:  $prefix
  C compiler:           $CC $XTRA_CFLAGS $WARN_CFLAGS $CFLAGS
  C++ compiler:         $CXX $XTRA_CXXFLAGS $WARN_CXXFLAGS $CXXFLAGS
  Fortran compiler:     $FORT
  Fortran libraries:    $FLIBS
  BLAS libraries:       $BLAS_LIBS
  FFTW libraries:       $FFTW_LIBS
  HDF5 libraries:       $HDF5_LIBS
  MPI libraries:        $MPI_LIBS
  LIBS:                 $LIBS
  Default pager:        $DEFAULT_PAGER
  gnuplot:              $GNUPLOT_BINARY

  Do internal array bounds checking:  $BOUNDS_CHECKING
  Build static libraries:             $STATIC_LIBS
  Build shared libraries:             $SHARED_LIBS
  Dynamic Linking:                    $ENABLE_DYNAMIC_LINKING $DL_API_MSG
  Include support for GNU readline:   $USE_READLINE
])

warn_msg_printed=false

if $ENABLE_DYNAMIC_LINKING; then
  if $SHARED_LIBS; then
    true
  else
    AC_MSG_WARN([You used --enable-dl but not --enable-shared.])
    AC_MSG_WARN([Are you sure that is what you want to do?])
    warn_msg_printed=true
  fi
fi

if test -n "$warn_f2c_and_f77"; then
  AC_MSG_WARN($warn_f2c_and_f77)
  warn_msg_printed=true
fi

if test -n "$gxx_only"; then
  AC_MSG_WARN($gxx_only)
  warn_msg_printed=true
fi

if test -n "$warn_gcc_version"; then
  AC_MSG_WARN($warn_gcc_version)
  warn_msg_printed=true
fi

if test -n "$warn_gcc_only"; then
  AC_MSG_WARN($warn_gcc_only)
  warn_msg_printed=true
fi

if test -n "$warn_f2c_no_lib"; then
  AC_MSG_WARN($warn_f2c_no_lib)
  warn_msg_printed=true
fi

if test -n "$warn_readline"; then
  AC_MSG_WARN($warn_readline)
  warn_msg_printed=true
fi

if test -n "$warn_termlibs"; then
  AC_MSG_WARN($warn_termlibs)
  warn_msg_printed=true
fi

if test -n "$warn_gperf"; then
  AC_MSG_WARN($warn_gperf)
  warn_msg_printed=true
fi

if test -n "$warn_flex"; then
  AC_MSG_WARN($warn_flex)
  warn_msg_printed=true
fi

if test -n "$warn_bison"; then
  AC_MSG_WARN($warn_bison)
  warn_msg_printed=true
fi

if test -n "$warn_less"; then
  AC_MSG_WARN($warn_less)
  warn_msg_printed=true
fi

if test -n "$warn_runtest"; then
  AC_MSG_WARN($warn_runtest)
  warn_msg_printed=true
fi

if test -n "$warn_gnuplot"; then

  ## If you change this text, be sure to also change the corresponding
  ## set of warnings above.

  AC_MSG_WARN([I didn't find gnuplot.  It isn't necessary to have gnuplot])
  AC_MSG_WARN([installed, but you won't be able to use any of Octave's])
  AC_MSG_WARN([plotting commands without it.])
  AC_MSG_WARN([])
  AC_MSG_WARN([If gnuplot is installed but it isn't in your path, you can])
  AC_MSG_WARN([tell Octave where to find it by typing the command])
  AC_MSG_WARN([])
  AC_MSG_WARN([gnuplot_binary = "/full/path/to/gnuplot/binary"])
  AC_MSG_WARN([])
  AC_MSG_WARN([at the Octave prompt.])
  warn_msg_printed=true
fi

if $warn_msg_printed; then
  AC_MSG_RESULT([])
fi

### End of configure.