File: configure.ac

package info (click to toggle)
octave 4.4.1-4~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 114,692 kB
  • sloc: cpp: 310,009; ansic: 54,616; fortran: 22,631; yacc: 8,706; sh: 8,231; objc: 7,972; lex: 3,897; perl: 1,540; java: 1,309; awk: 1,070; makefile: 415; xml: 59
file content (3219 lines) | stat: -rw-r--r-- 108,177 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Copyright (C) 1993-2018 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 3 of the License, 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, see
### <https://www.gnu.org/licenses/>.

### Initialize Autoconf
AC_PREREQ([2.65])
AC_INIT([GNU Octave], [4.4.1], [https://octave.org/bugs.html], [octave],
        [https://www.gnu.org/software/octave/])

### Declare version numbers

dnl Note that the version number is duplicated here and in AC_INIT because
dnl AC_INIT requires it to be static, not computed from shell variables.

OCTAVE_MAJOR_VERSION=4
OCTAVE_MINOR_VERSION=4
OCTAVE_PATCH_VERSION=1

dnl PACKAGE_VERSION is set by the AC_INIT VERSION argument.
OCTAVE_VERSION="$PACKAGE_VERSION"

OCTAVE_COPYRIGHT="Copyright (C) 2018 John W. Eaton and others."

OCTAVE_RELEASE_DATE="2018-08-09"

## The "API version" is used as a way of checking that interfaces in the
## liboctave and libinterp libraries haven't changed in a backwardly
## incompatible way when loading .oct files.  A better way to do this is with
## library versioning, but not all systems support it.
##
## NOTE: This macro will be removed in a future version of Octave!
## If you insist on checking for features using a version number, use the
## OCTAVE_MAJOR_VERSION, OCTAVE_MINOR_VERSION, and OCTAVE_PATCH_VERSION
## macros instead.
dnl
dnl FIXME: Since we also set libtool versions for liboctave and libinterp,
dnl perhaps we should be computing the "api version" from those versions numbers
dnl in some way instead of setting it independently here.
OCTAVE_API_VERSION="api-v52"

AC_SUBST(OCTAVE_MAJOR_VERSION)
AC_SUBST(OCTAVE_MINOR_VERSION)
AC_SUBST(OCTAVE_PATCH_VERSION)
AC_SUBST(OCTAVE_VERSION)
AC_SUBST(OCTAVE_COPYRIGHT)
AC_SUBST(OCTAVE_RELEASE_DATE)
AC_SUBST(OCTAVE_API_VERSION)

dnl FIXME: We should auto-insert the Mercurial changeset ID into the
dnl        AC_REVISION field whenever configure.ac is modified.
dnl AC_REVISION($Revision: 1.603 $)
AC_CONFIG_SRCDIR([libinterp/octave.cc])
AC_CONFIG_HEADERS([config.h:config.in.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])

### Initialize Automake
AM_INIT_AUTOMAKE([1.14 -Wno-portability -Wno-override tar-ustar subdir-objects dist-lzip dist-xz])

## Add option to enable silent rules and make silent the default behavior.
AM_SILENT_RULES([yes])

OCTAVE_CANONICAL_HOST

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

AC_USE_SYSTEM_EXTENSIONS

### Make configure args available in variable form for other uses.

config_opts=$ac_configure_args
AC_SUBST(config_opts)

### Set default file locations.

## Where to install libraries like liboctave.a, liboctinterp.a, and other
## architecture-dependent binaries.
OCTAVE_SET_DEFAULT([octlibdir], '${libdir}/octave/${version}')

## Where to put executables to be run by Octave, rather than the user.
## This path usually includes the Octave version and configuration name, so
## that configurations for multiple versions of Octave may be installed at once.
OCTAVE_SET_DEFAULT([archlibdir],
  '${libexecdir}/octave/${version}/exec/${canonical_host_type}')

## Where to put executables to be run by Octave, rather than the user, that
## are specific to this site.
OCTAVE_SET_DEFAULT([localarchlibdir],
  '${libexecdir}/octave/site/exec/${canonical_host_type}')

OCTAVE_SET_DEFAULT([localapiarchlibdir],
  '${libexecdir}/octave/${api_version}/site/exec/${canonical_host_type}')

OCTAVE_SET_DEFAULT([localverarchlibdir],
  '${libexecdir}/octave/${version}/site/exec/${canonical_host_type}')

## Where to put object files that will by dynamically loaded.
## This path includes the Octave version and configuration name, so that
## configurations for multiple versions of Octave may be installed at once.
OCTAVE_SET_DEFAULT([octfiledir],
  '${libdir}/octave/${version}/oct/${canonical_host_type}')

## Directories that Octave should search for object files that will be
## dynamically loaded and that are specific to this site (i.e. customizations),
## before consulting ${octfiledir}.  This should be a colon-separated list of
## directories.
OCTAVE_SET_DEFAULT([localoctfiledir],
  '${libdir}/octave/site/oct/${canonical_host_type}')

OCTAVE_SET_DEFAULT([localapioctfiledir],
  '${libdir}/octave/site/oct/${api_version}/${canonical_host_type}')

OCTAVE_SET_DEFAULT([localveroctfiledir],
  '${libdir}/octave/${version}/site/oct/${canonical_host_type}')

## Where to install Octave's include files.
OCTAVE_SET_DEFAULT([octincludedir], '${includedir}/octave-${version}/octave')

## Where to install the function files distributed with Octave.
## This includes the Octave version, so that the function files for different
## versions of Octave will be installed in separate directories.
OCTAVE_SET_DEFAULT([fcnfiledir], '${datadir}/octave/${version}/m')

## Directories that Octave should search for function files specific to this
## site (i.e. customizations), before consulting ${fcnfiledir}.
## This should be a colon-separated list of directories.
OCTAVE_SET_DEFAULT([localfcnfiledir], '${datadir}/octave/site/m')

OCTAVE_SET_DEFAULT([localapifcnfiledir],
  '${datadir}/octave/site/${api_version}/m')

OCTAVE_SET_DEFAULT([localverfcnfiledir], '${datadir}/octave/${version}/site/m')

## Where to install extra files like NEWS and doc-cache.
OCTAVE_SET_DEFAULT([octetcdir], '${datadir}/octave/${version}/etc')

## Where to install the language files for the GUI.
OCTAVE_SET_DEFAULT([octlocaledir], '${datadir}/octave/${version}/locale')

## The full path to the default doc-cache file.
OCTAVE_SET_DEFAULT([doc_cache_file], '${octetcdir}/doc-cache')

## Where to install test files.
OCTAVE_SET_DEFAULT([octtestsdir], '${octetcdir}/tests')

## The full path to the default texi macros file.
OCTAVE_SET_DEFAULT([texi_macros_file], '${octetcdir}/macros.texi')

## Where Octave will search to find image files.
OCTAVE_SET_DEFAULT([imagedir], '${datadir}/octave/${version}/imagelib')

## Where Octave will search for example data files shipped with distribution.
OCTAVE_SET_DEFAULT([octdatadir], '${datadir}/octave/${version}/data')

## Where Octave will search for Qt help files shipped with distribution.
OCTAVE_SET_DEFAULT([octdocdir], '${datadir}/octave/${version}/doc')

## Where Octave will search for fallback font files shipped with distribution.
OCTAVE_SET_DEFAULT([octfontsdir], '${datadir}/octave/${version}/fonts')

## Where Octave will look for startup files.
OCTAVE_SET_DEFAULT([startupfiledir], '${fcnfiledir}/startup')
OCTAVE_SET_DEFAULT([localstartupfiledir], '${localfcnfiledir}/startup')

## Where Octave will look for man and info files.
OCTAVE_SET_DEFAULT([man1dir], '${mandir}/man1')
OCTAVE_SET_DEFAULT([man1ext], '.1')
OCTAVE_SET_DEFAULT([infofile], '${infodir}/octave.info')

### Check for programs used in building, installing, and running Octave.

## Programs used in configuring Octave.
dnl Find pkg-config executable (sets $PKG_CONFIG)
PKG_PROG_PKG_CONFIG

## Programs used in Makefiles.
AC_PROG_AWK
AC_PROG_GREP
OCTAVE_PROG_FIND
OCTAVE_PROG_SED
OCTAVE_PROG_PERL

## Programs used to build parts of Octave.
OCTAVE_PROG_GPERF

OCTAVE_PROG_FLEX
AC_SUBST([LEX_OUTPUT_ROOT], [lex.octave_])

OCTAVE_PROG_BISON

OCTAVE_PROG_MAKEINFO
OCTAVE_PROG_TEXI2DVI
OCTAVE_PROG_TEXI2PDF

OCTAVE_PROG_TAR_REPRODUCIBLE

## Programs used when installing Octave.
AC_PROG_LN_S
AC_PROG_MKDIR_P

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

## Programs used when running Octave.
OCTAVE_PROG_GHOSTSCRIPT
OCTAVE_PROG_GNUPLOT
OCTAVE_PROG_PAGER
OCTAVE_PROG_PYTHON

## Programs used to generate icons file formats.
OCTAVE_PROG_ICOTOOL
OCTAVE_PROG_RSVG_CONVERT
AM_CONDITIONAL([AMCOND_HAVE_ICON_TOOLS],
  [test -n "$ICOTOOL" && test -n "$RSVG_CONVERT"])

### Path separator.

sepchar=':'
AC_ARG_WITH([sepchar],
  [AS_HELP_STRING([--with-sepchar=<char>],
    [use <char> as the path separation character])])
case $with_sepchar in
  yes | "")
    case $host_os in
      mingw* | msdosmsvc)
        sepchar=';' ;;
    esac
  ;;
  no)
    AC_MSG_ERROR([You are required to define a path separation character])
    ;;
  *)
    sepchar=$with_sepchar
  ;;
esac
AC_SUBST(sepchar)
AC_DEFINE_UNQUOTED(SEPCHAR, ['$sepchar'],
  [Define this to be the path separator for your system, as a character constant.])
AC_DEFINE_UNQUOTED(SEPCHAR_STR, ["$sepchar"],
  [Define this to be the path separator for your system, as a string.])

### Define the path to the shell on the host system.
### Most systems will ensure /bin/sh is the default shell so this can be safely
### ignored by almost everyone.  However, when building for Android, for
### example, this will need to be set.
SHELL_PATH=/bin/sh
AC_ARG_WITH([shell],
  [AS_HELP_STRING([--with-shell=SHELL],
    [use SHELL as the shell interpreter (default: /bin/sh)])])
case $with_shell in
  no)
    AC_MSG_ERROR([A shell interpreter is required])
  ;;
  yes | "")
  ;;
  *)
    SHELL_PATH=$with_shell
  ;;
esac
AC_DEFINE_UNQUOTED([SHELL_PATH], ["$SHELL_PATH"],
  [Define this to be the path to the shell command interpreter.])

### Use the system-wide installation of GNU FreeFont if the user requests it.
### By default, Octave includes its own copy of the FreeSans font, which it
### installs in its own directory for use as a fallback default font.  If this
### configuration option is used, then do not install our own copy of the fonts
### and assume they can be found in the provided system directory.
SYSTEM_FREEFONT_DIR=
AC_ARG_WITH([system-freefont],
  [AS_HELP_STRING([--with-system-freefont=DIR],
    [use FreeSans fonts in DIR (default: install and use internal copy)])])
case $with_system_freefont in
  no | "")
    SYSTEM_FREEFONT_DIR=
    ;;
  yes)
    AC_MSG_ERROR([directory argument required for --with-system-freefont])
    ;;
  *)
    SYSTEM_FREEFONT_DIR=$with_system_freefont
    ;;
esac
if test -n "$SYSTEM_FREEFONT_DIR"; then
  AC_MSG_NOTICE([configuring Octave to use system fonts in $SYSTEM_FREEFONT_DIR])
  AC_DEFINE_UNQUOTED([SYSTEM_FREEFONT_DIR], ["$SYSTEM_FREEFONT_DIR"],
    [Define this to be the system directory containing the GNU FreeFont fonts.])
fi
AM_CONDITIONAL([AMCOND_INSTALL_INTERNAL_FONT_FILES],
  [test -z "$SYSTEM_FREEFONT_DIR"])

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

AC_PROG_CXX
AC_PROG_CXXCPP

## Ensure that the C++ compiler fully supports C++11.
dnl Test must occur after calling AC_PROG_CXX, which tests for language
dnl features and sets the shell variable ac_cv_prog_cxx_cxx11 appropriately.

if test x"$ac_cv_prog_cxx_cxx11" = xno; then
  AC_MSG_ERROR([a compiler that fully supports C++11 is required to build Octave])
fi

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

AC_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL

## Save and restore CFLAGS and CXXFLAGS globally.
dnl These variables are for users, so we shouldn't be touching them.
dnl Instead, we should set the corresponding AM_ flags (currently by way of the
dnl XTRA_ variables).  However, for the duration of the configure script, we
dnl may set CFLAGS and CXXFLAGS so that subsequent tests succeed.  Temporary
dnl settings like this are currently done for pthreads and openmp, for example.
original_octave_configure_CFLAGS="$CFLAGS"
original_octave_configure_CXXFLAGS="$CXXFLAGS"

## Check for MSVC
have_msvc=no
case $host_os in
  msdosmsvc)
    have_msvc=yes
  ;;
  mingw*)
    AC_MSG_CHECKING([for MSVC compiler])
    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
        #if ! defined (_MSC_VER)
        #error "Not MSVC compiler"
        #endif
        ]])],
      have_msvc=yes, have_msvc=no)
    AC_MSG_RESULT([$have_msvc])
  ;;
esac

### gnulib initialization: part 1
dnl Must take place immediately after a compiler is determined

gl_EARLY

### Check version number when using g++.

GXX_VERSION=
if test "$GXX" = yes; then
  AC_MSG_CHECKING([C++ compiler version number])
  gxx_version=`$CXX -v 2>&1 | $GREP "^.*g.. version" | \
    $SED -e 's/^.*g.. version *//' -e 's/cygnus-//' -e 's/egcs-//' -e 's/ .*//'`

  AX_COMPARE_VERSION([$gxx_version], [lt], [4.1],
    [warn_gxx_version="g++ version $gxx_version is likely to cause problems"
     OCTAVE_CONFIGURE_WARNING([warn_gxx_version])])

  GXX_VERSION=$gxx_version
  AC_MSG_RESULT([$GXX_VERSION])
fi
AC_SUBST(GXX_VERSION)

## Workaround for broken STL algorithm library.
OCTAVE_CHECK_BROKEN_STL_ALGO_H
AM_CONDITIONAL([AMCOND_HAVE_BROKEN_STL_ALGO_H],
  [test $octave_cv_broken_stl_algo_h = yes])

if test $octave_cv_broken_stl_algo_h = yes; then
  warn_stl_algo_h="Found nth_element broken in g++ $GXX_VERSION.  Attempting to repair by using local patched version of bits/stl_algo.h."
  OCTAVE_CONFIGURE_WARNING([warn_stl_algo_h])
fi

### Check version number when using gcc.
dnl It might be different from the g++ version number.

GCC_VERSION=
if test "$GCC" = yes; then
  AC_MSG_CHECKING([C compiler version number])
  gcc_version=`$CC -v 2>&1 | $GREP "^.*gcc version" | \
    $SED -e 's/^.*g.. version *//' -e 's/cygnus-//' -e 's/egcs-//' -e 's/ .*//'`

  AX_COMPARE_VERSION([$gcc_version], [lt], [3],
    [warn_gcc_version="gcc version $gcc_version is likely to cause problems"
     OCTAVE_CONFIGURE_WARNING([warn_gcc_version])])

  GCC_VERSION=$gcc_version
  AC_MSG_RESULT([$GCC_VERSION])
fi
AC_SUBST(GCC_VERSION)

## It seems that there are some broken inline assembly functions in GNU libc.
## Since it is uncertain how to test whether Octave is linked against GNU libc,
## just disable them for all platforms.

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

### Determine the compiler flag necessary to create dependencies.

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

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

dnl Keep this check before the check for the Fortran compiler,
dnl in case -lm is needed to compile Fortran programs.
AC_CHECK_LIB(m, sin)

### Determine the Fortran compiler and how to invoke it

## Prefer gfortran, but the user's F77 environment variable will override.
AC_PROG_F77([gfortran])
if test -z "$F77"; then
  ## No gfortran found, search for any other installed compiler.
  AC_PROG_F77
fi
if test "$F77" = g77; then
  AC_MSG_ERROR([g77 is not a supported Fortran compiler.  Select another compiler by setting the environment variable F77 and re-running configure.])
fi

AC_MSG_CHECKING([whether a usable Fortran compiler was found])
if test -n "$F77"; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_MSG_ERROR([a Fortran compiler is required to build Octave])
fi

AC_F77_LIBRARY_LDFLAGS
AC_F77_DUMMY_MAIN
AC_F77_WRAPPERS

### Must appear after checks for Fortran compiler.
OCTAVE_CHECK_FORTRAN_SYMBOL_AND_CALLING_CONVENTIONS

### Must appear after checks for compilers.
OCTAVE_DEFINE_MKOCTFILE_DYNAMIC_LINK_OPTIONS

### Use a 64-bit integer type for array dimensions and indexing, if possible.

AC_CHECK_SIZEOF([void *])
if test $ac_cv_sizeof_void_p -ge 8; then
  ENABLE_64=yes
else
  ENABLE_64=no
fi

AC_ARG_ENABLE(64,
  [AS_HELP_STRING([--disable-64],
    [don't use 64-bit integers for array dimensions and indexing])],
  [case $enableval in
     yes) ENABLE_64=yes ;;
     no) ENABLE_64=no ;;
     *) AC_MSG_ERROR([bad value $enableval for --enable-64]) ;;
   esac])

if test $ENABLE_64 = yes; then
  if test $ac_cv_sizeof_void_p -ge 8; then
    OCTAVE_IDX_TYPE=int64_t
  else
    warn_64_bit="--enable-64 option given but pointers are less than 64-bits wide; disabling 64-bit indexing"
    OCTAVE_CONFIGURE_WARNING([warn_64_bit])
    OCTAVE_IDX_TYPE=int32_t
    ENABLE_64=no
  fi
else
  OCTAVE_IDX_TYPE=int32_t
fi

AC_SUBST(ENABLE_64)
if test $ENABLE_64 = yes; then
  octave_sizeof_octave_idx_type=8
  AC_DEFINE(OCTAVE_ENABLE_64, 1,
    [Define to 1 to use 64-bit integers for array dimensions and indexing.])
else
  octave_sizeof_octave_idx_type=4
fi

AC_DEFINE_UNQUOTED(OCTAVE_SIZEOF_IDX_TYPE, [$octave_sizeof_octave_idx_type],
  [Define to the size of the octave_idx_type (8 or 4).])

AC_SUBST(OCTAVE_IDX_TYPE)
AC_DEFINE_UNQUOTED(OCTAVE_IDX_TYPE, [$OCTAVE_IDX_TYPE],
  [Define to the type of octave_idx_type (64 or 32 bit signed integer).])

### Enable bounds checking on element references within Octave's array and
### matrix classes.
dnl This slows down some operations a bit, so it is turned off by default.

ENABLE_BOUNDS_CHECK=no
AC_ARG_ENABLE([bounds-check],
  [AS_HELP_STRING([--enable-bounds-check],
    [OBSOLETE: use --enable-address-sanitizer-flags instead])],
  [if test "$enableval" = yes; then ENABLE_BOUNDS_CHECK=yes; fi], [])
if test $ENABLE_BOUNDS_CHECK = yes; then
  warn_bounds_check="--enable-bounds-check is obsolete; use --enable-address-sanitizer-flags instead"
  OCTAVE_CONFIGURE_WARNING([warn_bounds_check])
fi

### Use atomic operations for internal reference counting.
### This is required for thread-safe behavior (Qt Handles) but incurs a
### significant slowdown.  Enabled by default until a higher performing
### solution can be found.

ENABLE_ATOMIC_REFCOUNT=yes
AC_ARG_ENABLE([atomic-refcount],
  [AS_HELP_STRING([--disable-atomic-refcount],
    [Do not use atomic operations for internal reference counting.  This option is required for thread-safe behavior as used in the GUI's Qt plotting toolkit.  Performance for CLI-only builds is improved by disabling this feature.])],
  [if test "$enableval" = no; then ENABLE_ATOMIC_REFCOUNT=no; fi], [])
if test $ENABLE_ATOMIC_REFCOUNT = yes; then
  AC_DEFINE(OCTAVE_ENABLE_ATOMIC_REFCOUNT, 1,
    [Define to 1 to use atomic operations for reference counting.])
fi

### Check for pthread library

AX_PTHREAD
dnl Include pthread libs and flags early in case other config tests need them.
dnl They seem to be required for the OpenGL tests on Debian systems.
LIBS="$PTHREAD_LIBS $LIBS"
XTRA_CFLAGS="$XTRA_CFLAGS $PTHREAD_CFLAGS"
XTRA_CXXFLAGS="$XTRA_CXXFLAGS $PTHREAD_CFLAGS"
dnl Set these for any other tests that may require them.
dnl They will be reset before output files are generated.
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"

### Test whether the compiler supports OpenMP.
dnl This is enabled by default to allow the option of using OpenMP in
dnl loadable modules.

ENABLE_OPENMP=no
check_for_openmp=yes
AC_ARG_ENABLE([openmp],
  [AS_HELP_STRING([--disable-openmp],
    [disable OpenMP SMP multi-threading])],
  [if test "$enableval" = no; then check_for_openmp=no; fi], [])
if test $check_for_openmp = yes; then
  AC_LANG_PUSH(C)
  AX_OPENMP([XTRA_CFLAGS="$XTRA_CFLAGS $OPENMP_CFLAGS"; ENABLE_OPENMP=yes], [])
  AC_LANG_POP(C)
  AC_LANG_PUSH(C++)
  AX_OPENMP([XTRA_CXXFLAGS="$XTRA_CXXFLAGS $OPENMP_CXXFLAGS"; ENABLE_OPENMP=yes], [])
  AC_LANG_POP(C++)
fi

dnl Set these for any other tests that may require them.
dnl They will be reset before output files are generated.
CFLAGS="$CFLAGS $OPENMP_CFLAGS"
CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"

dnl Define here since it is skipped if the first argument to AX_OPENMP
dnl is not empty.
if test $ENABLE_OPENMP = yes; then
  AC_CHECK_HEADERS([omp.h])
  AC_CHECK_FUNCS([omp_get_num_threads])
  AC_DEFINE(OCTAVE_ENABLE_OPENMP, 1, [Define to 1 if OpenMP is enabled])
fi

### Start determination of shared vs. static libraries

## 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_NOTICE([defining LD_STATIC_FLAG to be $LD_STATIC_FLAG])
fi
AC_SUBST(LD_STATIC_FLAG)

## Check for programs necessary for shared libraries (ar, libtool)
OCTAVE_PROG_AR

ifdef([LT_INIT], [], [
  errprint([error: you must have libtool 2.2.2 or a more recent version
])
  m4exit([1])])

LT_PREREQ([2.2.2])
LT_INIT([disable-static dlopen win32-dll])

if test $enable_shared = yes; then
  SHARED_LIBS=yes
else
  SHARED_LIBS=no
fi
AC_SUBST(SHARED_LIBS)

if test $enable_static = yes; then
  STATIC_LIBS=yes
else
  STATIC_LIBS=no
fi
AC_SUBST(STATIC_LIBS)

XTRA_EXTERNAL_SH_LDFLAGS=
if test $have_msvc = yes; then
  FLIBS="$FLIBS -lkernel32"
  XTRA_EXTERNAL_SH_LDFLAGS="-Wl,external/external.def"
fi
AC_SUBST(XTRA_EXTERNAL_SH_LDFLAGS)

### Enable dynamic linking.
### --enable-shared implies this, thus --enable-dl is only needed 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],
  [AS_HELP_STRING([--disable-dl],
    [disable loading of dynamically linked modules])],
  [case $enableval in
     yes) ENABLE_DYNAMIC_LINKING=yes ;;
     no) ENABLE_DYNAMIC_LINKING=no ;;
     *) AC_MSG_ERROR([bad value $enableval for --enable-dl]) ;;
   esac],
  [ENABLE_DYNAMIC_LINKING=no])

if test $STATIC_LIBS = no && test $SHARED_LIBS = no; then
  AC_MSG_ERROR([You can't disable building both static AND shared libraries!])
fi


### More configure argument checking related to linking

AC_ARG_ENABLE([no-undefined],
  [AS_HELP_STRING([--disable-no-undefined],
    [don't pass -no-undefined to libtool when linking Octave and its shared libraries])],
  [case $enableval in
     yes) NO_UNDEFINED_LDFLAG="-no-undefined" ;;
     no)  NO_UNDEFINED_LDFLAG="" ;;
     *) AC_MSG_ERROR([bad value $enableval for --disable-no-undefined]) ;;
   esac],
  [NO_UNDEFINED_LDFLAG="-no-undefined"])
AC_SUBST(NO_UNDEFINED_LDFLAG)

AC_ARG_ENABLE([link-all-dependencies],
  [AS_HELP_STRING([--enable-link-all-dependencies],
    [link Octave and its shared libraries with all dependencies, not just those immediately referenced (should not be needed on most systems)])],
  [case $enableval in
     yes) link_all_deps=yes ;;
     no)  link_all_deps=no ;;
     *) AC_MSG_ERROR([bad value $enableval for --enable-link-all-depenencies])
     ;;
   esac],
  [link_all_deps=no])
AM_CONDITIONAL([AMCOND_LINK_ALL_DEPS], [test $link_all_deps = yes])

### Check for BLAS and LAPACK libraries:

## Need to adjust FFLAGS to include correct integer size.
save_FFLAGS="$FFLAGS"
FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"

OCTAVE_BLAS_WITH_F77_FUNC([:], [:],
  [ax_blas_ok=yes
  AC_MSG_CHECKING([BLAS can be called from Fortran])
  AC_MSG_RESULT([yes assumed for cross compilation])])
AX_LAPACK([:], [:])

## Restore FFLAGS.
FFLAGS="$save_FFLAGS"

## If necessary, try again with -ff2c in FFLAGS
if test $ax_blas_ok = no; then
  save_FFLAGS="$FFLAGS"
  FFLAGS="-ff2c $FFLAGS $F77_INTEGER_8_FLAG"

  OCTAVE_BLAS_WITH_F77_FUNC([:], [:])
  AX_LAPACK([:], [:])

  ## Restore FFLAGS, with -ff2c if that was helpful
  if test $ax_blas_ok = yes; then
    FFLAGS="-ff2c $save_FFLAGS"
  else
    FFLAGS="$save_FFLAGS"
  fi
fi

## On OSX, try again with a wrapper library (without -ff2c!)
if test $ax_blas_ok = no; then
  case $host_os in
    darwin*)
      ## test if wrapper functions help
      octave_blaswrap_save_CFLAGS="$CFLAGS"
      CFLAGS="$CFLAGS -DUSE_BLASWRAP"
      AC_LANG_PUSH(C)
      AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
          #include "liboctave/util/blaswrap.c"
        ]])],
        [mv conftest.$ac_objext blaswrap.$ac_objext
         octave_blaswrap_save_BLAS_LIBS="$BLAS_LIBS"
         BLAS_LIBS="blaswrap.$ac_objext -framework vecLib"

         save_FFLAGS="$FFLAGS"
         FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"

         OCTAVE_BLAS_WITH_F77_FUNC([:], [:])
         AX_LAPACK([:], [:])

         ## Restore FFLAGS.
         FFLAGS="$save_FFLAGS"

         dnl remove temp file
         rm -f blaswrap.$ac_objext],
        [AC_MSG_FAILURE([cannot compile liboctave/util/blaswrap.c])])
      AC_LANG_POP(C)
      CFLAGS="$octave_blaswrap_save_CFLAGS"

      if test $ax_blas_ok = no; then
        BLAS_LIBS="$octave_blaswrap_save_BLAS_LIBS"
      else
        ## wrapper in liboctave/util, remove from BLAS_LIBS
        BLAS_LIBS=`echo $BLAS_LIBS | $SED -e 's/blaswrap.[[^ ]]* //g'`
        AC_DEFINE(USE_BLASWRAP, 1,
          [Define to 1 if BLAS functions need to be wrapped (potentially needed for 64-bit OSX only).])
      fi
    ;;
  esac
fi

if test $ax_blas_ok = no || test $ax_lapack_ok = no; then
  AC_MSG_ERROR([BLAS and LAPACK libraries are required])
fi

case $ax_blas_integer_size in
  4)
    HAVE_64_BIT_BLAS=no
  ;;
  8)
    HAVE_64_BIT_BLAS=yes
  ;;
  *)
    AC_MSG_ERROR([unrecognized BLAS library integer size])
  ;;
esac

OCTAVE_CHECK_SIZEOF_FORTRAN_INTEGER
if test $octave_cv_sizeof_fortran_integer -ne $ax_blas_integer_size; then
  if test $ax_blas_integer_size -eq 8; then
    case $F77 in
      *gfortran*)
        case $F77_INTEGER_8_FLAG in
          *-fdefault-integer-8*)
          ;;
          *)
            case $FFLAGS in
              *-fdefault-integer-8*)
                AC_MSG_NOTICE([setting -fdefault-integer-8 in F77_INTEGER_8_FLAG instead of FFLAGS])
                FFLAGS=`echo $FFLAGS | $SED 's/-fdefault-integer-8//g'`
                F77_INTEGER_8_FLAG="-fdefault-integer-8"
              ;;
              *)
                AC_MSG_NOTICE([adding -fdefault-integer-8 to F77_INTEGER_8_FLAG])
                F77_INTEGER_8_FLAG="-fdefault-integer-8"
                ## Invalidate the cache and try again.
                $as_unset octave_cv_sizeof_fortran_integer
              ;;
            esac
          ;;
        esac
      ;;
    esac
    if test -z "$octave_cv_sizeof_fortran_integer"; then
      OCTAVE_CHECK_SIZEOF_FORTRAN_INTEGER
    fi
  fi
  ## We intentionally don't attempt to fix things up if the default
  ## Fortran integer size is 8 but BLAS appears to use 4-byte integers.
  if test $octave_cv_sizeof_fortran_integer -ne $ax_blas_integer_size; then
    AC_MSG_ERROR([your Fortran compiler must have an option for setting the default integer size to be the same size as your BLAS library uses ($ax_blas_integer_size bytes).  See the file INSTALL for more information.])
  fi
fi
AC_SUBST(F77_INTEGER_8_FLAG)

case $octave_cv_sizeof_fortran_integer in
  8)
    OCTAVE_F77_INT_TYPE=int64_t
  ;;
  4)
    OCTAVE_F77_INT_TYPE=int32_t
  ;;
esac
AC_SUBST(OCTAVE_F77_INT_TYPE)
AC_DEFINE_UNQUOTED(OCTAVE_F77_INT_TYPE, [$OCTAVE_F77_INT_TYPE],
  [Define to the type of octave_f77_int_type (64 or 32 bit signed integer).])
AC_DEFINE_UNQUOTED(OCTAVE_SIZEOF_F77_INT_TYPE,
  [$octave_cv_sizeof_fortran_integer],
  [Define to the size of the octave_f77_int_type (8 or 4).])

OCTAVE_F77_FLAG([-ffloat-store], [
  AC_MSG_RESULT([setting F77_FLOAT_STORE_FLAG to -ffloat-store])
  F77_FLOAT_STORE_FLAG=-ffloat-store
  AC_SUBST(F77_FLOAT_STORE_FLAG)
])

BUILD_EXTERNAL_LIBXERBLA=
case $host_os in
  msdosmsvc | mingw*)
    BUILD_EXTERNAL_LIBXERBLA=ues
  ;;
esac

AM_CONDITIONAL([AMCOND_BUILD_EXTERNAL_LIBXERBLA],
  [test -n "$BUILD_EXTERNAL_LIBXERBLA"])

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

dnl FIXME: A lot of the following duplicates the functionality of
dnl code generated by the dlopen option for LT_INIT.

LD_CXX="${CXX}"
RDYNAMIC_FLAG=
DL_API_MSG=""
dlopen_api=no
shl_load_api=no
loadlibrary_api=no
dyld_api=no

if test $SHARED_LIBS = yes || test $ENABLE_DYNAMIC_LINKING = yes; then

  case $lt_cv_dlopen in
    dlopen)
      dlopen_api=yes
      DL_API_MSG="(dlopen)"
      AC_DEFINE(HAVE_DLOPEN_API, 1,
        [Define to 1 if system has dlopen, dlsym, dlerror, and dlclose for dynamic linking.])
      OCTAVE_CXX_FLAG([-rdynamic], [RDYNAMIC_FLAG=-rdynamic])
    ;;
    shl_load)
      shl_load_api=yes
      DL_API_MSG="(shl_load)"
      AC_DEFINE(HAVE_SHL_LOAD_API, 1,
        [Define to 1 if system has shl_load and shl_findsym for dynamic linking.])
    ;;
    LoadLibrary)
      loadlibrary_api=yes
      DL_API_MSG="(LoadLibrary)"
      AC_DEFINE(HAVE_LOADLIBRARY_API, 1,
        [Define to 1 if system has LoadLibrary for dynamic linking.])
    ;;
    dyld)
      dyld_api=yes
      DL_API_MSG="(dyld)"
      AC_DEFINE(HAVE_DYLD_API, 1,
        [Define to 1 if system has dyld for dynamic linking.])
    ;;
  esac

  DL_LIBS="$lt_cv_dlopen_libs"
  AC_SUBST(DL_LIBS)

  ## Disable dynamic linking if capability is not present.
  if test $dlopen_api = yes \
      || test $shl_load_api = yes \
      || test $loadlibrary_api = yes \
      || test $dyld_api = yes; then
    ## some form of dynamic linking present
    ENABLE_DYNAMIC_LINKING=yes
  else
    ENABLE_DYNAMIC_LINKING=no
  fi
fi

if test $ENABLE_DYNAMIC_LINKING = yes; then
  AC_DEFINE(ENABLE_DYNAMIC_LINKING, 1, [Define to 1 if using dynamic linking.])
fi

AM_CONDITIONAL([AMCOND_ENABLE_DYNAMIC_LINKING],
  [test $ENABLE_DYNAMIC_LINKING = yes])

if test $SHARED_LIBS = yes; then
  LIBOCTINTERP="-loctinterp"
  LIBOCTAVE="-loctave"
else
  LIBOCTINTERP="${top_builddir}/libinterp/liboctinterp.a"
  LIBOCTAVE="${top_builddir}/liboctave/liboctave.a"
fi

AC_SUBST(LD_CXX)
AC_SUBST(RDYNAMIC_FLAG)
AC_SUBST(ENABLE_DYNAMIC_LINKING)
AC_SUBST(LIBOCTINTERP)
AC_SUBST(LIBOCTAVE)

if test "$cross_compiling" = yes && test -n "$ac_tool_prefix"; then
  CROSS_TOOL_PREFIX="$ac_tool_prefix"
  MKOCTFILE_AR=`echo "$AR" | $SED "s,$CROSS_TOOL_PREFIX,,"`
  MKOCTFILE_CC=`echo "$CC" | $SED "s,$CROSS_TOOL_PREFIX,,"`
  MKOCTFILE_CXX=`echo "$CXX" | $SED "s,$CROSS_TOOL_PREFIX,,"`
  MKOCTFILE_DL_LD=`echo "$DL_LD" | $SED "s,$CROSS_TOOL_PREFIX,,"`
  MKOCTFILE_F77=`echo "$F77" | $SED "s,$CROSS_TOOL_PREFIX,,"`
  MKOCTFILE_LD_CXX=`echo "$LD_CXX" | $SED "s,$CROSS_TOOL_PREFIX,,"`
  MKOCTFILE_RANLIB=`echo "$RANLIB" | $SED "s,$CROSS_TOOL_PREFIX,,"`
else
  MKOCTFILE_AR="$AR"
  MKOCTFILE_CC="$CC"
  MKOCTFILE_CXX="$CXX"
  MKOCTFILE_DL_LD="$DL_LD"
  MKOCTFILE_F77="$F77"
  MKOCTFILE_LD_CXX="$LD_CXX"
  MKOCTFILE_RANLIB="$RANLIB"
fi
AC_MSG_NOTICE([defining CROSS_TOOL_PREFIX to be $CROSS_TOOL_PREFIX])
AC_MSG_NOTICE([defining MKOCTFILE_AR to be $MKOCTFILE_AR])
AC_MSG_NOTICE([defining MKOCTFILE_CC to be $MKOCTFILE_CC])
AC_MSG_NOTICE([defining MKOCTFILE_CXX to be $MKOCTFILE_CXX])
AC_MSG_NOTICE([defining MKOCTFILE_DL_LD to be $MKOCTFILE_DL_LD])
AC_MSG_NOTICE([defining MKOCTFILE_F77 to be $MKOCTFILE_F77])
AC_MSG_NOTICE([defining MKOCTFILE_LD_CXX to be $MKOCTFILE_LD_CXX])
AC_MSG_NOTICE([defining MKOCTFILE_RANLIB to be $MKOCTFILE_RANLIB])
AC_SUBST(CROSS_TOOL_PREFIX)
AC_SUBST(MKOCTFILE_AR)
AC_SUBST(MKOCTFILE_CC)
AC_SUBST(MKOCTFILE_CXX)
AC_SUBST(MKOCTFILE_DL_LD)
AC_SUBST(MKOCTFILE_F77)
AC_SUBST(MKOCTFILE_LD_CXX)
AC_SUBST(MKOCTFILE_RANLIB)

### Enable float truncation to work around issues with x87 co-processors

dnl When compiling math for x87, problems may arise in some code comparing
dnl floating-point intermediate results.  The root cause is the extra precision
dnl (~80 bits) of x87 co-processor registers versus the IEEE standard 64 bits.
dnl Generally, storing the result in a local volatile variable forces a
dnl truncation back to 64 bits, but it also degrades performance.
dnl However, this performance degradation is very minimal, if indeed measurable.
dnl Therefore, it has been enabled for all platforms and compilers.
dnl Reported bugs indicate that --enable-float-truncate is required for MinGW
dnl and Cygwin platforms and for GCC compilers >= 5.0.  It should not be
dnl necessary for non-x87 targets or when using modern SSE math.
ENABLE_FLOAT_TRUNCATE=yes
AC_ARG_ENABLE([float-truncate],
  [AS_HELP_STRING([--disable-float-truncate],
    [truncate intermediate FP results])],
  [if test "$enableval" = no; then ENABLE_FLOAT_TRUNCATE=no; fi], [])
if test $ENABLE_FLOAT_TRUNCATE = yes; then
  AC_DEFINE(OCTAVE_ENABLE_FLOAT_TRUNCATE, 1,
    [Define to 1 to truncate intermediate FP results.])
fi

### Determine extra CFLAGS, CXXFLAGS that may be necessary for Octave.

## On Intel systems with gcc, we need to compile with -mieee-fp to get full
## support for IEEE floating point.
##
## On Alpha/OSF systems, we require -mieee or -ieee for full support.

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_NOTICE([adding -mieee-fp 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_NOTICE([adding -mieee-fp 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_NOTICE([adding -mieee to XTRA_CFLAGS])])
    else
      OCTAVE_CC_FLAG([-ieee], [
        ieee_fp_flag=-ieee
        XTRA_CFLAGS="$XTRA_CFLAGS -ieee"
        AC_MSG_NOTICE([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_NOTICE([adding -mieee to XTRA_CXXFLAGS])])
    else
      OCTAVE_CXX_FLAG([-ieee], [
        ieee_fp_flag=-ieee
        XTRA_CXXFLAGS="$XTRA_CXXFLAGS -ieee"
        AC_MSG_NOTICE([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)

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

if test "$cross_compiling" = yes; then
  BUILD_CC="gcc"
  BUILD_CFLAGS="-O2 -g"
  BUILD_CXX="g++"
  BUILD_CXXFLAGS="-O2 -g -std=c++11"
  BUILD_LDFLAGS=""
  BUILD_EXEEXT=""
else
  BUILD_CC="${CC}"
  BUILD_CFLAGS="${CFLAGS}"
  BUILD_CXX="${CXX}"
  BUILD_CXXFLAGS="${CXXFLAGS}"
  BUILD_LDFLAGS="${LDFLAGS}"
  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)])

### Determine whether to create cross-mkoctfile and other cross-tools.

cross_tools=no
AC_ARG_ENABLE([cross-tools],
  [AS_HELP_STRING([--enable-cross-tools],
    [build cross tools (mkoctfile, octave-config) if cross compiling])],
  [if test "$enableval" = yes; then cross_tools=yes; fi])

if test "$cross_tools" = yes; then
  if test "$cross_compiling" = no; then
    AC_MSG_WARN([ignoring --enable-cross-tools when not cross compiling])
    cross_tools=no
  fi
fi
AM_CONDITIONAL([AMCOND_CROSS_TOOLS], [test $cross_tools = yes])

### Check compiler characteristics.
dnl FIXME: How many of these are necessary now that C++11 is required?

## Check if C++ compiler can auto allocate variable sized arrays.
OCTAVE_CXX_DYNAMIC_AUTO_ARRAYS

## Check that C compiler and libraries support IEEE754 data format.
OCTAVE_IEEE754_DATA_FORMAT

## Are bit_and, bit_or, and bit_xor defined as templated operators?
OCTAVE_CXX_BITWISE_OP_TEMPLATES

## Can complex class set components independently?
OCTAVE_CXX_COMPLEX_SETTERS

## Are there functions to access real/imag parts of numbers via references?
OCTAVE_CXX_COMPLEX_REFERENCE_ACCESSORS

## Check if fast integer arithmetics based on bit tricks is available.
OCTAVE_FAST_INT_OPS

## Does the C compiler handle alloca and const correctly?
AC_FUNC_ALLOCA

## Does the C compiler support Automake subdir-objects option?
AM_PROG_CC_C_O

### gnulib initialization: part 2
dnl Must take place after part 1, and after standard compiler options and
dnl search paths have been established, and at the same priority level as
dnl system library function and header checks, but before checks for all
dnl external library dependencies.

gl_INIT

### Checks for header files.

AC_HEADER_SYS_WAIT

## C headers

dnl Use multiple AC_CHECKs to avoid line continuations '\' in list.
AC_CHECK_HEADERS([dlfcn.h floatingpoint.h fpu_control.h grp.h])
AC_CHECK_HEADERS([ieeefp.h pthread.h pwd.h sys/ioctl.h])

## Find a termio header to include.

AC_CHECK_HEADERS([termios.h], have_termios_h=yes, have_termios_h=no)
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)

if test $have_termios_h != yes \
    && test $have_termio_h != yes \
    && test $have_sgtty_h != yes; then
  AC_MSG_WARN([couldn't find one of termios.h, termio.h, or sgtty.h!])
fi

## For MSVC compilers, avoid #define of min/max from windows.h header.
if test $have_msvc = yes; then
  AC_DEFINE(NOMINMAX, 1, [Define to 1 to avoid min/max macro definition in Windows headers.])
fi

### Determine types and size of types.

AC_TYPE_INT64_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UID_T
AC_TYPE_UINT64_T
AC_CHECK_TYPES([dev_t, ino_t])
AC_CHECK_TYPES([ptrdiff_t])

AC_CHECK_TYPES([long long int])
if test $ac_cv_type_long_long_int = yes; then
  AC_DEFINE(OCTAVE_HAVE_LONG_LONG_INT, 1,
    [Define to 1 if the system has the type 'long long int'.])
fi

AC_CHECK_TYPES([unsigned long long int])
if test $ac_cv_type_unsigned_long_long_int = yes; then
  AC_DEFINE(OCTAVE_HAVE_UNSIGNED_LONG_LONG_INT, 1,
    [Define to 1 if the system has the type 'unsigned long long int'.])
fi

## Check for long double type (may be used for 64-bit integer computations).
AC_CHECK_SIZEOF([long double])

### Check structures and existence of necessary members.

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

AC_STRUCT_TIMEZONE

## Check if C++ compiler allows overload of char, int8_t, and uint8_t.
AC_CACHE_CHECK([whether ${CXX-g++} allows overload of char, int8_t, and uint8_t],
  [octave_cv_overload_char_int8_t],
  [AC_LANG_PUSH(C++)
  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
    #include <stdint.h>
    void somefunc(char x) {};
    void somefunc(int8_t x) {};
    void somefunc(uint8_t x) {};
    ]])],
    octave_cv_overload_char_int8_t=yes,
    octave_cv_overload_char_int8_t=no)
  AC_LANG_POP(C++)
  ])
if test $octave_cv_overload_char_int8_t = yes; then
  AC_DEFINE(OCTAVE_HAVE_OVERLOAD_CHAR_INT8_TYPES, 1,
    [Define to 1 if C++ allows overload of char, int8_t, and uint8_t types.])
fi

### Checks for functions and variables.

dnl The list of functions is short because we use gnulib to guarantee
dnl valid implementations for many common problematic functions.

dnl These checks define/undefine HAVE_FUNCNAME in config.h.
dnl Code tests HAVE_FUNCNAME and either uses function or provides workaround.
dnl Use multiple AC_CHECKs to avoid line continuations '\' in list
AC_CHECK_FUNCS([ctermid dup2])
AC_CHECK_FUNCS([endgrent endpwent execvp fork])
AC_CHECK_FUNCS([getegid geteuid getgid getgrent getgrgid getgrnam])
AC_CHECK_FUNCS([getpgrp getpid getppid getpwent getpwuid getuid])
AC_CHECK_FUNCS([isascii kill])
AC_CHECK_FUNCS([lgamma_r lgammaf_r])
AC_CHECK_FUNCS([realpath resolvepath])
AC_CHECK_FUNCS([select setgrent setpwent setsid siglongjmp strsignal])
AC_CHECK_FUNCS([tcgetattr tcsetattr toascii])
AC_CHECK_FUNCS([umask waitpid])
AC_CHECK_FUNCS([_getch _kbhit])

## Check for math defines such as M_LN2 in math.h
AC_CACHE_CHECK([for MATH DEFINES in math.h],
  [octave_cv_header_math_defines],
  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    #include <math.h>
    ]], [[
    double x = M_LN2;]])],
    octave_cv_header_math_defines=yes,
    octave_cv_header_math_defines=no)
  ])

if test $octave_cv_header_math_defines = no; then
  ## Check again and try defining _USE_MATH_DEFINES
  AC_CACHE_CHECK([whether _USE_MATH_DEFINES needs to be defined],
    [octave_cv_header__use_math_defines],
    [save_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS -D_USE_MATH_DEFINES"
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
      #include <math.h>
      ]], [[
      double x = M_LN2;]])],
      octave_cv_header__use_math_defines=yes,
      octave_cv_header__use_math_defines=no)
    CPPFLAGS="$save_CPPFLAGS"
    ])
  if test $octave_cv_header__use_math_defines = yes; then
    octave_cv_header_math_defines=yes
    AC_DEFINE(_USE_MATH_DEFINES, 1,
      [Define to 1 if _USE_MATH_DEFINES is required to get math constants like M_LN2.])
    CPPFLAGS="$CPPFLAGS -D_USE_MATH_DEFINES"
  fi
fi

if test $octave_cv_header_math_defines = yes; then
  AC_DEFINE(HAVE_MATH_DEFINES, 1,
    [Define to 1 if defines such as M_PI are available in math.h])
else
  AC_MSG_ERROR([MATH DEFINES in math.h such as M_PI are required to build Octave])
fi

## Windows-specific tests for extra #defines
case $host_os in
  msdosmsvc | mingw*)
    AC_MSG_CHECKING([for required _WIN32_WINNT])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
        #include <windows.h>
        #if _WIN32_WINNT < 0x0403
        #error "Wrong version"
        #endif
        ]], [])],
      [AC_MSG_RESULT([none])],
      [AC_DEFINE(_WIN32_WINNT, 0x0403,
        [Define to 0x0403 to access InitializeCriticalSectionAndSpinCount.])
       AC_MSG_RESULT([0x0403])])
  ;;
esac

## Windows-specific use of functions
case $host_os in
  msdosmsvc | mingw*)
    AC_CHECK_FUNCS([setvbuf], [],
                   [AC_MSG_ERROR([Missing function required to build Octave])])

    ## We need this for GetDeviceCaps.  Should we actually check for
    ## the function and library?
    LIBS="-lgdi32 $LIBS"
  ;;
esac

## Windows-specific module used for winqueryreg function
case $host_os in
  msdosmsvc | mingw*)
    AC_CHECK_HEADERS([psapi.h],
      [LIBS="-lpsapi $LIBS"],
      [AC_MSG_ERROR([Missing PSAPI required to build for Windows target.])],
      [#include <windows.h>])
  ;;
esac

## Cygwin kluge for getrusage.
AC_CHECK_FUNCS([getrusage])
case $host_os in
  cygwin*)
    AC_DEFINE(RUSAGE_TIMES_ONLY, 1,
      [Define to 1 if the struct rusage only has time information.])
  ;;
esac

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

AC_FUNC_CLOSEDIR_VOID

## Check return type of matherr
AC_CACHE_CHECK([for struct exception in math.h],
  [octave_cv_func_matherr_type],
  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
      #include <math.h>
      ]], [[
      struct exception *x;
      x->type;
      x->name;
      ]])],
    octave_cv_func_matherr_type=yes,
    octave_cv_func_matherr_type=no)
  ])
if test $octave_cv_func_matherr_type = yes; then
  AC_DEFINE(EXCEPTION_IN_MATH, 1,
    [Define to 1 if math.h declares struct exception for matherr.])
fi

## Signal stuff.

AC_CHECK_DECLS([sys_siglist], [], [],
[[#include <signal.h>
/* NetBSD declares sys_siglist in unistd.h.  */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
]])

### Check for the Qhull library.

OCTAVE_CHECK_LIB(qhull, QHull,
  [Qhull library not found.  This will result in loss of functionality for some geometry functions.],
  [libqhull/libqhull.h qhull/libqhull.h libqhull.h qhull/qhull.h qhull.h],
  [qh_qhull], [], [],
  [warn_qhull=
  OCTAVE_CHECK_QHULL_VERSION
  OCTAVE_CHECK_LIB_QHULL_OK(
    [AC_DEFINE(HAVE_QHULL, 1, [Define to 1 if Qhull is available.])],
    [warn_qhull="Qhull library found, but does not seem to work properly.  This will result in loss of functionality for some geometry functions.  Please try recompiling the library with -fno-strict-aliasing."])])

### Check for PCRE regex library.

OCTAVE_CHECK_LIB(pcre, PCRE,
  [], [pcre.h pcre/pcre.h], [pcre_compile], [], [], [],
  [libpcre], [REQUIRED])

### Check for readline library.

OCTAVE_ENABLE_READLINE

## Find a termlib to use.
OCTAVE_CHECK_LIB_TERMLIB

### Check for ZLIB library.

OCTAVE_CHECK_LIB(z, ZLIB,
  [ZLIB library not found.  Octave will not be able to load or save compressed data files or HDF5 files.],
  [zlib.h], [gzclearerr])

## Also define HAVE_ZLIB if libz is found.
if test -z "$warn_z"; then
  AC_DEFINE(HAVE_ZLIB, 1, [Define to 1 if ZLIB is available.])
fi

### Check for BZIP2 library.

OCTAVE_CHECK_LIB(bz2, BZIP2,
  [BZIP2 library not found.  Octave will not be able to compress or decompress bzip2 files.],
  [bzlib.h], [BZ2_bzCompressInit])

### Check for the LLVM library (JIT compiler).

ENABLE_JIT=no
AC_ARG_ENABLE([jit],
  [AS_HELP_STRING([--enable-jit],
    [(EXPERIMENTAL) enable JIT compiler])],
  [if test "$enableval" = yes; then ENABLE_JIT=yes; fi], [])

LLVM_CXXFLAGS=
LLVM_CPPFLAGS=
LLVM_LDFLAGS=
LLVM_LIBS=

if test $ENABLE_JIT = yes; then

  ## Find llvm-config program from environment variable or by searching
  AC_ARG_VAR([LLVM_CONFIG], [path to llvm-config utility])
  AC_CHECK_PROG([LLVM_CONFIG], llvm-config, llvm-config, [])

  if test -z "$LLVM_CONFIG"; then
    warn_llvm="llvm-config utility not found.  JIT compiler is disabled."
  else
    dnl Preset warning message in case compile fails
    warn_llvm="LLVM was not found or is to old.  JIT compiler is disabled."

    save_CPPFLAGS="$CPPFLAGS"
    save_CXXFLAGS="$CXXFLAGS"
    save_LDFLAGS="$LDFLAGS"

    dnl Use -isystem if available because we don't want to see warnings in LLVM
    LLVM_INCLUDE_FLAG=-I
    OCTAVE_CC_FLAG([-isystem .], [
      LLVM_INCLUDE_FLAG=-isystem
      AC_MSG_NOTICE([using -isystem for LLVM headers])])

    dnl Use -isystem so we don't get warnings from llvm headers
    LLVM_CPPFLAGS="$LLVM_INCLUDE_FLAG `$LLVM_CONFIG --includedir`"
    LLVM_CXXFLAGS=
    LLVM_LDFLAGS="-L`$LLVM_CONFIG --libdir`"

    LDFLAGS="$LDFLAGS $LLVM_LDFLAGS"
    LLVM_SO=LLVM-`$LLVM_CONFIG --version`
    AC_CHECK_LIB([$LLVM_SO], [LLVMBuildAdd], [LLVM_LIBS="-l$LLVM_SO"],
                 [LLVM_LIBS="`$LLVM_CONFIG --libs` `$LLVM_CONFIG --system-libs`"])

    dnl Define some extra flags that LLVM requires in order to include headers.
    dnl Ideally we should get these from llvm-config, but llvm-config isn't
    dnl very helpful.
    CPPFLAGS="-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS $LLVM_CPPFLAGS $CPPFLAGS"
    CXXFLAGS="$LLVM_CXXFLAGS $CXXFLAGS"
    AC_LANG_PUSH(C++)
    AC_CHECK_HEADER([llvm/Support/TargetSelect.h], [warn_llvm=""])

    have_function_h=no
    AC_CHECK_HEADERS([llvm/IR/Function.h llvm/Function.h],
                     [have_function_h=yes; break])
    if test $have_function_h = no; then
      warn_llvm="Missing LLVM file Function.h.  JIT compiler is disabled."
    fi
    have_irbuilder_h=no
    AC_CHECK_HEADERS([llvm/Support/IRBuilder.h llvm/IR/IRBuilder.h \
                      llvm/IRBuilder.h], [have_irbuilder_h=yes; break])
    if test $have_irbuilder_h = no; then
      warn_llvm="Missing LLVM file IRBuilder.h.  JIT compiler is disabled."
    fi
    have_llvm_data_h=no
    AC_CHECK_HEADERS([llvm/Target/TargetData.h llvm/IR/DataLayout.h \
                      llvm/DataLayout.h], [have_llvm_data_h=yes; break])
    if test $have_llvm_data_h = no; then
      warn_llvm="Missing LLVM file TargetData.h.  JIT compiler is disabled."
    fi

    AC_CHECK_HEADERS([llvm/IR/Verifier.h])
    AC_CHECK_HEADERS([llvm/Analysis/BasicAliasAnalysis.h])

    OCTAVE_LLVM_FUNCTION_ADDATTRIBUTE_API
    OCTAVE_LLVM_FUNCTION_ADDFNATTR_API
    OCTAVE_LLVM_CALLINST_ADDATTRIBUTE_API
    OCTAVE_LLVM_RAW_FD_OSTREAM_API
    OCTAVE_LLVM_LEGACY_PASSMANAGER_API
    AC_LANG_POP(C++)
    CPPFLAGS="$save_CPPFLAGS"
    CXXFLAGS="$save_CXXFLAGS"
    LDFLAGS="$save_LDFLAGS"
  fi

  if test -z "$warn_llvm"; then
    AC_DEFINE(HAVE_LLVM, 1, [Define to 1 if LLVM is available.])
  else
    ENABLE_JIT=no
    LLVM_CPPFLAGS=
    LLVM_CXXFLAGS=
    LLVM_LDFLAGS=
    LLVM_LIBS=
    OCTAVE_CONFIGURE_WARNING([warn_llvm])
  fi
dnl FIXME: Re-instate when JIT is enabled by default
dnl else
dnl   ## JIT build disabled
dnl   warn_llvm="JIT compiler disabled, some performance loss for loops"
dnl   OCTAVE_CONFIGURE_WARNING([warn_llvm])
fi
if test $ENABLE_JIT = yes; then
  AC_DEFINE(ENABLE_JIT, 1, [Define to 1 to enable JIT compiler.])
fi

AC_SUBST(LLVM_CPPFLAGS)
AC_SUBST(LLVM_CXXFLAGS)
AC_SUBST(LLVM_LDFLAGS)
AC_SUBST(LLVM_LIBS)
AM_CONDITIONAL([AMCOND_HAVE_LLVM], [test -z "$warn_llvm"])

### Check for HDF5 library.

save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
CPPFLAGS="$Z_CPPFLAGS $CPPFLAGS"
LIBS="$Z_LDFLAGS $Z_LIBS $LIBS"
OCTAVE_CHECK_LIB(hdf5, HDF5,
  [HDF5 library not found.  Octave will not be able to load or save HDF5 data files.],
  [hdf5.h], [H5Gget_num_objs], [], [],
  [warn_hdf5=
   OCTAVE_CHECK_HDF5_HAS_VER_16_API
   AC_DEFINE(HAVE_HDF5, 1,
     [Define to 1 if HDF5 is available and newer than version 1.6.])
   if test $have_msvc = yes; then
     OCTAVE_CHECK_LIB_HDF5_DLL
   fi
  ])
CPPFLAGS="$save_CPPFLAGS"
LIBS="$save_LIBS"

dnl FIXME: Should we check for this now, or wait until some version of HDF5
dnl actually supports this feature?
have_hdf5_int2float_conversions=no
if test $have_hdf5_int2float_conversions = yes; then
  AC_DEFINE(HAVE_HDF5_INT2FLOAT_CONVERSIONS, 1,
    [Define to 1 if/when HDF5 supports automatic conversion between integer and floating-point binary data.])
fi

### Check for FFTW library.
### Default to Fortran FFTPACK if it is not available.

## Check for FFTW header and library.
OCTAVE_CHECK_LIB(fftw3, FFTW3,
  [FFTW3 library not found.  The slower FFTPACK library will be used instead.],
  [fftw3.h], [fftw_plan_dft_1d])

OCTAVE_CHECK_LIB(fftw3f, FFTW3F,
  [FFTW3F library not found.  The slower FFTPACK library will be used instead.],
  [fftw3.h], [fftwf_plan_dft_1d])

## Check command line for the option to disable multi-threaded FFTW.
build_fftw_threads=yes
AC_ARG_ENABLE([fftw-threads],
  [AS_HELP_STRING([--disable-fftw-threads],
    [disable Multi-threaded FFTW])],
  [if test "$enableval" = no; then
     build_fftw_threads=no
   fi],
  [])

dnl Octave is currently unable to use FFTW unless both float and double
dnl versions are available.

AM_CONDITIONAL([AMCOND_HAVE_FFTW],
  [test -n "$FFTW3_LIBS" && test -n "$FFTW3F_LIBS"])

if test -n "$FFTW3_LIBS" && test -n "$FFTW3F_LIBS"; then
  AC_DEFINE(HAVE_FFTW, 1, [Define to 1 if both FFTW3 and FFTW3F libraries are available.])
else
  dnl --without-fftw3 given, or one of the FFTW3 libs not installed.
  dnl Don't check for FFTW threads as this is now pointless.
  build_fftw_threads=no
fi

## Check for the multithreaded FFTW library.
## Fallback to singlethreaded if not found or disabled.
if test $build_fftw_threads = yes; then
  OCTAVE_CHECK_FFTW_THREADS(fftw3, fftw_plan_with_nthreads)
  OCTAVE_CHECK_FFTW_THREADS(fftw3f, fftwf_plan_with_nthreads)
fi

## Collections of flags.
dnl These are here instead of just in the Makefile.am file because we
dnl substitute some of them into other source files like mkoctfile.

## Order matters, at least on some systems (Cygwin, for example).

FFTW_XCPPFLAGS="$FFTW3_CPPFLAGS $FFTW3F_CPPFLAGS"

FFTW_XLDFLAGS="$FFTW3_LDFLAGS $FFTW3F_LDFLAGS"

FFTW_XLIBS="$FFTW3_LIBS $FFTW3F_LIBS"

AC_SUBST(FFTW_XCPPFLAGS)
AC_SUBST(FFTW_XLDFLAGS)
AC_SUBST(FFTW_XLIBS)

## Subdirectory of liboctave/external to build if FFTW is not found.
FFT_DIR="fftpack"
AC_SUBST(FFT_DIR)

### Check for GLPK library and header.

save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
CPPFLAGS="$Z_CPPFLAGS $CPPFLAGS"
LIBS="$Z_LDFLAGS $Z_LIBS $LIBS"
OCTAVE_CHECK_LIB(glpk, GLPK,
  [GLPK library not found.  The glpk function for solving linear programs will be disabled.],
  [glpk/glpk.h glpk.h], [glp_simplex], [], [],
  [warn_glpk=
   OCTAVE_CHECK_LIB_GLPK_OK(
    [AC_DEFINE(HAVE_GLPK, 1, [Define to 1 if GLPK is available.])],
    [warn_glpk="GLPK library found, but does not seem to work properly; disabling glpk function"])])
LIBS="$save_LIBS"
CPPFLAGS="$save_CPPFLAGS"

### Checks for cURL header and library.

save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
CPPFLAGS="$Z_CPPFLAGS $CPPFLAGS"
LIBS="$Z_LDFLAGS $Z_LIBS $LIBS"
OCTAVE_CHECK_LIB(curl, cURL,
  [cURL library not found.  The ftp objects, urlread, and urlwrite functions will be disabled.],
  [curl/curl.h], [curl_easy_escape])
if test -z "$warn_curl"; then
  ## Additional check on cURL library that was found
  AC_CACHE_CHECK([for CURLOPT_DIRLISTONLY in curl/curl.h],
    [octave_cv_curl_has_curlopt_dirlistonly],
    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
      #include <curl/curl.h>
      ]], [[
      curl_easy_setopt ((CURL*)NULL, CURLOPT_DIRLISTONLY, 0);
      ]])],
      [octave_cv_curl_has_curlopt_dirlistonly=yes],
      [octave_cv_curl_has_curlopt_dirlistonly=no])
    ])
  if test $octave_cv_curl_has_curlopt_dirlistonly = no; then
    AC_DEFINE(CURLOPT_DIRLISTONLY, CURLOPT_FTPLISTONLY,
      [Define to the legacy option name if using an older version of cURL.])
  fi
fi
LIBS="$save_LIBS"
CPPFLAGS="$save_CPPFLAGS"

### Check for sndfile library.

OCTAVE_CHECK_LIB(sndfile, sndfile,
  [sndfile library not found.  The audioinfo, audioread, and audiowrite functions will be disabled.],
  [sndfile.h], [sf_open],
  [], [don't use sndfile library, disable audio file I/O],
  [warn_sndfile=
   OCTAVE_CHECK_LIB_SNDFILE_OK(
    [AC_DEFINE(HAVE_SNDFILE, 1, [Define to 1 if sndfile is available.])],
    [warn_sndfile="sndfile library found, but does not seem to work properly; disabling audio file I/O functions"])])

### Check for PortAudio

OCTAVE_CHECK_LIB(portaudio, PortAudio,
  [PortAudio library not found.  The audioplayer, audiorecorder, and audiodevinfo functions will be disabled.],
  [portaudio.h], [Pa_GetDeviceCount],
  [], [don't use PortAudio library, disable audio playback and recording],
  [], [portaudio-2.0])

### Check for either of Graphics/ImageMagick++ libraries.

check_magick=yes
use_magick=no
AC_ARG_WITH([magick],
  [AS_HELP_STRING([--with-magick=LIB],
    [select library to use for image I/O (options: GraphicsMagick(default) or ImageMagick)])],
  [if test x"$withval" = xno; then
     check_magick=no
     warn_magick_disabled="--without-magick specified.  The imread, imwrite, and imfinfo functions for reading and writing image files will not be fully functional."
     OCTAVE_CONFIGURE_WARNING([warn_magick_disabled])
   else
     magick="$withval"
   fi], [magick="GraphicsMagick"])

if test $check_magick = yes; then

  MAGICK_CPPFLAGS=
  MAGICK_LDFLAGS=
  MAGICK_LIBS=

  PKG_CHECK_EXISTS([$magick++], [
    dnl Make sure we only get -I, -L, and -l flags.
    dnl Some Graphics/ImageMagick++ dnl packages add extra flags that are
    dnl useful when building Graphics/ImageMagick++ extentions.  These extra
    dnl flags break the Octave build.
    MAGICK_CPPFLAGS="$($PKG_CONFIG --cflags-only-I $magick++ | $SED -e 's/^ *$//')"
    MAGICK_LDFLAGS="$($PKG_CONFIG --libs-only-L $magick++ | $SED -e 's/^ *$//')"
    MAGICK_LIBS="$($PKG_CONFIG --libs-only-l $magick++ | $SED -e 's/^ *$//')"

    warn_magick="$magick++ library fails tests.  The imread, imwrite, and imfinfo functions for reading and writing image files will not be fully functional."

    save_CPPFLAGS="$CPPFLAGS"
    save_LIBS="$LIBS"
    CPPFLAGS="$MAGICK_CPPFLAGS $CPPFLAGS"
    LIBS="$MAGICK_LDFLAGS $MAGICK_LIBS $LIBS"
    AC_LANG_PUSH(C++)
    AC_CHECK_HEADER([Magick++.h], [
      AC_CACHE_CHECK([for Magick::ColorRGB in Magick++.h],
        [octave_cv_func_magick_colorrgb],
        [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
          #include <Magick++.h>
          ]], [[
          Magick::ColorRGB c;
          ]])],
          octave_cv_func_magick_colorrgb=yes,
          octave_cv_func_magick_colorrgb=no)
        ])
      if test $octave_cv_func_magick_colorrgb = yes; then
        use_magick=yes
        warn_magick=
      fi
    ])
    AC_LANG_POP(C++)
    CPPFLAGS="$save_CPPFLAGS"
    LIBS="$save_LIBS"

    AC_CHECK_FUNCS([setlocale], [],
      [use_magick=no
       warn_magick="$magick++ requires setlocale function.  The imread, imwrite, and imfinfo functions for reading and writing image files will not be fully functional."])
  ],
  [use_magick=no
   warn_magick="$magick++ library not found.  The imread, imwrite, and imfinfo functions for reading and writing image files will not be fully functional."])
fi

if test $use_magick = yes; then
  AC_DEFINE(HAVE_MAGICK, 1,
    [Define to 1 if Graphics/ImageMagick++ is available.])
else
  if test -n "$warn_magick"; then
    OCTAVE_CONFIGURE_WARNING([warn_magick])
  fi
  MAGICK_CPPFLAGS=
  MAGICK_LDFLAGS=
  MAGICK_LIBS=
fi
AC_SUBST(MAGICK_CPPFLAGS)
AC_SUBST(MAGICK_LDFLAGS)
AC_SUBST(MAGICK_LIBS)

### Check for X11 libraries

AC_PATH_X
if test "$have_x" = yes; then
  AC_DEFINE(HAVE_X_WINDOWS, 1, [Define to 1 if X11 is available.])

  if test "$x_includes" != "NONE"; then
    X11_INCFLAGS="$x_includes"
  fi
  AC_SUBST(X11_INCFLAGS)

  if test -z "$x_libraries"; then
    AC_CHECK_LIB([X11], XrmInitialize, [X11_LIBS="-lX11"], [X11_LIBS=])
  elif test "$x_libraries" != "NONE"; then
    AC_CHECK_LIB([X11], XrmInitialize,
      [X11_LIBS="-L$x_libraries -lX11"], [X11_LIBS=], "-L$x_libraries")
  fi
  AC_SUBST(X11_LIBS)
fi

### Check for the Carbon framework on macOS systems.

OCTAVE_HAVE_FRAMEWORK([Carbon],
  [[#include <Carbon/Carbon.h>]], [[CGMainDisplayID ()]],
  [have_framework_carbon=yes], [have_framework_carbon=no])
if test $have_framework_carbon = yes; then
  AC_DEFINE(HAVE_FRAMEWORK_CARBON, 1,
    [Define to 1 if framework CARBON is available.])
  CARBON_LIBS="-framework Carbon"
  AC_MSG_NOTICE([adding -framework Carbon to CARBON_LIBS])
  AC_SUBST(CARBON_LIBS)
fi

## Check for the CGDisplayBitsPerPixel function.
if test $have_framework_carbon = yes; then
  OCTAVE_CARBON_CGDISPLAYBITSPERPIXEL
fi

### Check for OpenGL and helper libraries used by OpenGL graphics renderer.

check_opengl=yes
AC_ARG_WITH([opengl],
  [AS_HELP_STRING([--without-opengl],
    [don't use OpenGL libraries, disable OpenGL graphics])],
  [if test x"$withval" = xno; then
     check_opengl=no
     warn_opengl_disabled="--without-opengl specified.  OpenGL graphics will be disabled."
     OCTAVE_CONFIGURE_WARNING([warn_opengl_disabled])
   fi])

## Check for OpenGL library
if test $check_opengl = yes; then
  OCTAVE_CHECK_LIB_OPENGL
  if test -z "$OPENGL_LIBS"; then
    warn_opengl_libs="OpenGL libs (GL and GLU) not found.  OpenGL graphics will be disabled."
    OCTAVE_CONFIGURE_WARNING([warn_opengl_libs])
  fi
fi

## Check for FreeType 2 library

check_freetype=yes
warn_freetype=
AC_ARG_WITH([freetype],
  [AS_HELP_STRING([--without-freetype],
    [don't use FreeType library, OpenGL graphics will not be fully functional])],
  [if test x"$withval" = xno; then
     check_freetype=no
     warn_freetype="--without-freetype specified.  OpenGL graphics will not be fully functional."
   fi])

if test $check_freetype = yes; then
  PKG_CHECK_MODULES([FT2], [freetype2], [
    min_ft2_version=9.03
    AC_MSG_CHECKING([for FreeType2 version >= $min_ft2_version])
    $PKG_CONFIG freetype2 --atleast-version=$min_ft2_version
    ac_status=$?
    if test "$ac_status" = 0; then
      AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_FREETYPE, 1, [Define to 1 if Freetype is available.])
      save_LIBS="$LIBS"
      LIBS="$FT2_LIBS $LIBS"
      AC_CHECK_FUNCS([FT_Reference_Face])
      LIBS="$save_LIBS"
    else
      AC_MSG_RESULT(no)
      warn_freetype="FreeType library >= 9.03 not found.  OpenGL graphics will not be fully functional."
    fi],
    [warn_freetype="FreeType library not found.  OpenGL graphics will not be fully functional."])
fi

if test -n "$warn_freetype"; then
  FT2_CFLAGS=
  FT2_LIBS=
  OCTAVE_CONFIGURE_WARNING([warn_freetype])
else
  dnl Alias CPPFLAGS to CFLAGS.  This is closer to the true meaning
  dnl of `pkg-config --cflags` output.
  FT2_CPPFLAGS="$FT2_CFLAGS"
  AC_SUBST(FT2_CPPFLAGS)
fi

## Check for fontconfig library

OCTAVE_CHECK_LIB(fontconfig, fontconfig,
  [Fontconfig library not found.  OpenGL graphics will not be fully functional.],
  [fontconfig.h fontconfig/fontconfig.h], [FcInit],
  [], [don't use fontconfig library, OpenGL graphics will not be fully functional])

## Check for gl2ps which is required for printing with OpenGL graphics.

AC_CHECK_HEADERS([gl2ps.h],
  [GL2PS_LIBS="-lgl2ps"],
  [warn_gl2ps="gl2ps library not found.  Printing of OpenGL graphics will be disabled."])

if test -n "$warn_gl2ps"; then
  OCTAVE_CONFIGURE_WARNING([warn_gl2ps])
else
  save_LIBS="$LIBS"
  LIBS="$GL2PS_LIBS $LIBS"
  AC_CHECK_FUNCS([gl2psLineJoin])
  LIBS="$save_LIBS"
fi

AC_SUBST(GL2PS_LIBS)

### GUI/Qt related tests.

QT_VERSIONS="5 4"

AC_ARG_WITH([qt],
  [AS_HELP_STRING([--with-qt=VER], [use the Qt major version VER])
dnl Second help string must not be indented for correct alignment
AS_HELP_STRING([--without-qt], [don't use Qt libraries, disable Qt GUI])],
  [case $withval in
     yes | "")
     ;;
     no)
       QT_VERSIONS=
       warn_qt_disabled="--without-qt specified.  The Qt GUI will be disabled."
       OCTAVE_CONFIGURE_WARNING([warn_qt_disabled])
     ;;
     *)
       QT_VERSIONS="$withval"
     ;;
   esac])

check_qscintilla=yes
AC_ARG_WITH([qscintilla],
  [AS_HELP_STRING([--without-qscintilla], [disable QScintilla editor])],
  [if test x"$withval" = xno; then
     check_qscintilla=no
     warn_qscintilla_disabled="--without-qscintilla specified.  The GUI editor will be disabled."
     OCTAVE_CONFIGURE_WARNING([warn_qscintilla_disabled])
   fi])

OCTAVE_CHECK_QT([$QT_VERSIONS])

## Default terminal font for the GUI.

case $host_os in
  mingw* | msdosmsvc)
    DEFAULT_TERMINAL_FONT="Lucida Console"
  ;;
  *)
    DEFAULT_TERMINAL_FONT="Courier"
  ;;
esac
DEFAULT_TERMINAL_FONT_SIZE=10
AC_SUBST(DEFAULT_TERMINAL_FONT)
AC_SUBST(DEFAULT_TERMINAL_FONT_SIZE)

### Check for OSMesa.
## Library is needed for offscreen rendering with Qt < 5.1 or FLTK.
use_osmesa=auto
AC_ARG_WITH([osmesa],
  [AS_HELP_STRING([--with-osmesa],
    [use OSMesa library for offscreen rendering of invisible figures])],
  [if test x"$withval" = xyes; then
     use_osmesa=yes
   else
     use_osmesa=no
   fi])

dnl If no argument given, only use OSMesa when Qt is too old
if test $use_osmesa = auto; then
  ## Quote $octave_cv_qt_opengl_os_ok because it will only be set if
  ## Qt is found.
  if test "$octave_cv_qt_opengl_os_ok" = yes; then
    use_osmesa=no
  else
    use_osmesa=yes
  fi
fi

if test $use_osmesa = yes; then
  dnl Pre-declare warning message, and unset if library is found
  ## Quote $octave_cv_qt_opengl_os_ok because it will only be set if
  ## Qt is found.
  if test "$octave_cv_qt_opengl_os_ok" = no; then
    warn_osmesa="OSMesa library not found and Qt < 5.1.  Offscreen rendering with OpenGL will be disabled."
  else
    warn_osmesa="OSMesa library not found.  Offscreen rendering with FLTK will be disabled."
  fi

  OSMESA_LIBS="-lOSMesa"
  save_CPPFLAGS="$CPPFLAGS"
  save_LDFLAGS="$LDFLAGS"
  save_LIBS="$LIBS"
  CPPFLAGS="$OSMESA_CPPFLAGS $CPPFLAGS"
  LDFLAGS="$OSMESA_LDFLAGS $LDFLAGS"
  LIBS="$OSMESA_LIBS $LIBS"
  AC_LANG_PUSH(C++)
  ac_octave_osmesa_check_for_lib=no
  AC_CHECK_HEADERS([osmesa.h GL/osmesa.h],
                   [ac_octave_osmesa_check_for_lib=yes; break])
  if test $ac_octave_osmesa_check_for_lib = yes; then
    AC_CACHE_CHECK([for OSMesaCreateContext in OSMesa],
      octave_cv_lib_osmesa,
      [AC_LINK_IFELSE([AC_LANG_CALL([], [OSMesaCreateContext])],
        [octave_cv_lib_osmesa=yes], [octave_cv_lib_osmesa=no])
    ])
    if test $octave_cv_lib_osmesa = yes; then
      warn_osmesa=
      AC_DEFINE(HAVE_OSMESA, 1, [Define to 1 if OSMesa is available.])
    fi
  fi
  AC_LANG_POP(C++)
  CPPFLAGS="$save_CPPFLAGS"
  LDFLAGS="$save_LDFLAGS"
  LIBS="$save_LIBS"

  if test -n "$warn_osmesa"; then
    OCTAVE_CONFIGURE_WARNING([warn_osmesa])
    OSMESA_LIBS=
  fi
fi

AC_SUBST(OSMESA_CPPFLAGS)
AC_SUBST(OSMESA_LDFLAGS)
AC_SUBST(OSMESA_LIBS)

### Check for FLTK library

check_fltk=yes
build_fltk_graphics=no

AC_ARG_WITH([fltk],
  [AS_HELP_STRING([--without-fltk],
    [don't use FLTK libraries, disable OpenGL graphics with FLTK widgets])],
  [if test x"$withval" = xno; then
     check_fltk=no
     warn_fltk="--without-fltk specified.  FLTK widgets will be disabled."
     OCTAVE_CONFIGURE_WARNING([warn_fltk])
   fi])

FLTK_CPPFLAGS=
FLTK_LDFLAGS=
FLTK_LIBS=

if test $check_fltk = yes; then
  AC_ARG_WITH([fltk-prefix],
    [AS_HELP_STRING([--with-fltk-prefix=PFX],
      [prefix where FLTK is installed (optional)])],
    [fltk_prefix="$withval"],
    [fltk_prefix=""])

  AC_ARG_WITH([fltk-exec-prefix],
    [AS_HELP_STRING([--with-fltk-exec-prefix=PFX],
      [exec prefix where FLTK is installed (optional)])],
    [fltk_exec_prefix="$withval"],
    [fltk_exec_prefix=""])

  if test "x$fltk_exec_prefix" != x; then
    fltk_args="$fltk_args --exec-prefix=$fltk_exec_prefix"
    if test "x${FLTK_CONFIG+set}" != xset ; then
      FLTK_CONFIG="$fltk_exec_prefix/bin/fltk-config"
    fi
  fi

  if test "x$fltk_prefix" != x; then
    fltk_args="$fltk_args --prefix=$fltk_prefix"
    if test x${FLTK_CONFIG+set} != xset ; then
      FLTK_CONFIG="$fltk_prefix/bin/fltk-config"
    fi
  fi

  AC_PATH_PROG([FLTK_CONFIG], [fltk-config], [no])

  warn_fltk_config=
  warn_fltk_opengl=

  if test "$FLTK_CONFIG" = no; then
    warn_fltk_config="FLTK config script not found.  FLTK toolkit will be disabled."
    OCTAVE_CONFIGURE_WARNING([warn_fltk_config])
  else
    ## Only include -I options in FLTK_CPPFLAGS
    fltk_cflags=`$FLTK_CONFIG $fltkconf_args --use-gl --cflags`
    for fltk_option in $fltk_cflags; do
      case $fltk_option in
        -I*)
          FLTK_CPPFLAGS="$FLTK_CPPFLAGS $fltk_option"
        ;;
      esac
    done
    FLTK_CPPFLAGS=`echo "$FLTK_CPPFLAGS" | $SED -e 's/^ \+//'`

    ## Split -L and -l options into FLTK_LDFLAGS and FLTK_LIBS
    fltk_ldflags=`$FLTK_CONFIG $fltkconf_args --use-gl --ldflags`
    for fltk_option in $fltk_ldflags; do
      case $fltk_option in
        -l*)
          FLTK_LIBS="$FLTK_LIBS $fltk_option"
        ;;
        *)
          FLTK_LDFLAGS="$FLTK_LDFLAGS $fltk_option"
        ;;
      esac
    done
    FLTK_LIBS=`echo "$FLTK_LIBS" | $SED -e 's/^ \+//'`
    FLTK_LDFLAGS=`echo "$FLTK_LDFLAGS" | $SED -e 's/^ \+//'`

    case $host_os in
      mingw*)
        FLTK_LDFLAGS=`echo $FLTK_LDFLAGS | $SED -e 's/-mwindows//g'`
      ;;
    esac
    AC_LANG_PUSH(C++)
    AC_CACHE_CHECK([for OpenGL support in FLTK],
      [octave_cv_fltk_opengl_support],
      [save_CPPFLAGS="$CPPFLAGS"
      CPPFLAGS="$CFLAGS $FLTK_CPPFLAGS"
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
        #include <FL/gl.h>
        ]], [[
        int nothing = 0;
        ]])],
        octave_cv_fltk_opengl_support=yes,
        octave_cv_fltk_opengl_support=no)
      CPPFLAGS="$save_CPPFLAGS"
      ])
    if test $octave_cv_fltk_opengl_support = no; then
      warn_fltk_opengl="FLTK does not have OpenGL support.  OpenGL graphics with FLTK widgets will be disabled."
    else
      build_fltk_graphics=yes
      AC_DEFINE(HAVE_FLTK, 1, [Define to 1 if FLTK is available.])
    fi
    AC_LANG_POP(C++)

    if test -n "$warn_fltk_opengl"; then
      OCTAVE_CONFIGURE_WARNING([warn_fltk_opengl])
    fi
  fi
fi

AC_SUBST(FLTK_CPPFLAGS)
AC_SUBST(FLTK_LDFLAGS)
AC_SUBST(FLTK_LIBS)

### Final determination of whether OpenGL graphics can be built
if test $build_qt_graphics = no && test $build_fltk_graphics = no; then
  opengl_graphics=no
else
  opengl_graphics=yes
fi

### Check for the qrupdate library

dnl No need to adjust FFLAGS because only link is attempted.
dnl Must supply proper LIBS, however.
save_LIBS="$LIBS"
LIBS="$LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS"
OCTAVE_CHECK_LIB(qrupdate, qrupdate,
  [qrupdate not found.  The QR & Cholesky updating functions will be slow.],
  [],
  [sqr1up],
  [Fortran 77], [don't use qrupdate, disable QR & Cholesky updating functions])

## Additional check to see if qrupdate lib found supports LU updates
if test -z "$warn_qrupdate"; then
  AC_CACHE_CHECK([for slup1up in $QRUPDATE_LIBS],
    [octave_cv_func_slup1up],
    [LIBS="$LIBS $QRUPDATE_LIBS"
    AC_LANG_PUSH([Fortran 77])
    AC_LINK_IFELSE([AC_LANG_CALL([], [slup1up])],
      octave_cv_func_slup1up=yes, octave_cv_func_slup1up=no)
    AC_LANG_POP([Fortran 77])
  ])
  if test $octave_cv_func_slup1up = yes; then
    AC_DEFINE(HAVE_QRUPDATE_LUU, 1, [Define to 1 if qrupdate supports LU updates.])
  fi
fi
LIBS="$save_LIBS"

if test $ENABLE_64 = yes; then
  CHOLMOD_TAG="_l_"
  CXSPARSE_TAG="_dl_"
  UMFPACK_TAG="_zl_"
else
  CHOLMOD_TAG="_"
  CXSPARSE_TAG="_di_"
  UMFPACK_TAG="_zi_"
fi

## On some systems, explicitly linking with -lsuitesparseconfig is needed
## when using SuiteSparse libraries.  If so, the checks below for specific
## SuiteSparse libraries may fail without it.  Include LIB_CLOCK_GETTIME (from
## gnulib) on systems where needed.

save_LIBS="$LIBS"
LIBS="$LIB_CLOCK_GETTIME $LIBS"
OCTAVE_CHECK_LIB(suitesparseconfig, SUITESPARSECONFIG,
  [], [], [SuiteSparse_time], [],
  [don't link directly with suitesparseconfig library])
LIBS="$save_LIBS"

if test -n "$SUITESPARSECONFIG_LIBS" && test -n "$LIB_CLOCK_GETTIME"; then
  SUITESPARSECONFIG_LIBS="$SUITESPARSECONFIG_LIBS $LIB_CLOCK_GETTIME"
fi

### Reset below, after all checks for SuiteSparse libraries.
suitesparse_save_LIBS="$LIBS"
LIBS="$SUITESPARSECONFIG_LIBS $LIBS"

### Check for AMD library

OCTAVE_CHECK_LIB(amd, AMD,
  [AMD library not found.  This will result in some lack of functionality for sparse matrices.],
  [suitesparse/amd.h ufsparse/amd.h amd/amd.h amd.h],
  [amd_postorder],
  [], [don't use AMD library, disable some sparse matrix functionality])

### Check for CAMD library

OCTAVE_CHECK_LIB(camd, CAMD,
  [CAMD library not found.  This will result in some lack of functionality for sparse matrices.],
  [suitesparse/camd.h ufsparse/camd.h camd/camd.h camd.h],
  [camd_postorder],
  [], [don't use CAMD library, disable some sparse matrix functionality])

### Check for COLAMD library

OCTAVE_CHECK_LIB(colamd, COLAMD,
  [COLAMD library not found.  This will result in some lack of functionality for sparse matrices.],
  [suitesparse/colamd.h ufsparse/colamd.h colamd/colamd.h colamd.h],
  [colamd],
  [], [don't use COLAMD library, disable some sparse matrix functionality])

### Check for CCOLAMD library

OCTAVE_CHECK_LIB(ccolamd, CCOLAMD,
  [CCOLAMD library not found.  This will result in some lack of functionality for sparse matrices.],
  [suitesparse/ccolamd.h ufsparse/ccolamd.h ccolamd/ccolamd.h ccolamd.h],
  [ccolamd],
  [], [don't use CCOLAMD library, disable some sparse matrix functionality])

### Check for CHOLMOD library.
### If your cholmod library requires cblas, then you will need to configure
### with --with-cholmod="-lcholmod -lcblas".

save_LIBS="$LIBS"
LIBS="$COLAMD_LDFLAGS $COLAMD_LIBS $AMD_LDFLAGS $AMD_LIBS $LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS"
OCTAVE_CHECK_LIB(cholmod, CHOLMOD,
  [CHOLMOD library not found.  This will result in some lack of functionality for sparse matrices.],
  [suitesparse/cholmod.h ufsparse/cholmod.h cholmod/cholmod.h cholmod.h],
  [cholmod${CHOLMOD_TAG}start],
  [], [don't use CHOLMOD library, disable some sparse matrix functionality])
LIBS="$save_LIBS"

### Check for CXSparse library

OCTAVE_CHECK_LIB(cxsparse, CXSparse,
  [CXSparse library not found.  This will result in some lack of functionality for sparse matrices.],
  [suitesparse/cs.h ufsparse/cs.h cxsparse/cs.h cs.h],
  [cs${CXSPARSE_TAG}sqr],
  [C++], [don't use CXSparse library, disable some sparse matrix functionality])

if test -z "$warn_cxsparse"; then
  ## Additional check for CXSparse version >= 2.2
  if test $octave_cv_lib_cxsparse = yes; then
    OCTAVE_CHECK_CXSPARSE_VERSION_OK
    if test $octave_cv_cxsparse_version_ok = no; then
      AC_MSG_ERROR([CXSparse library is too old (< version 2.2).  Upgrade CXSparse (SuiteSparse) or configure Octave with --disable-cxsparse"])
    fi
  fi
fi

### Check for UMFPACK library.

save_LIBS="$LIBS"
save_CPPFLAGS="$CPPFLAGS"
LIBS="$AMD_LDFLAGS $AMD_LIBS $BLAS_LIBS $FLIBS $LIBS"
CPPFLAGS="$AMD_CPPFLAGS $CPPFLAGS"
OCTAVE_CHECK_LIB([umfpack], UMFPACK,
  [UMFPACK not found.  This will result in some lack of functionality for sparse matrices.],
  [suitesparse/umfpack.h ufsparse/umfpack.h umfpack/umfpack.h umfpack.h],
  [umfpack${UMFPACK_TAG}get_determinant],
  [], [don't use UMFPACK, disable some sparse matrix functionality])
CPPFLAGS="$save_CPPFLAGS"
LIBS="$save_LIBS"

if test -z "$UMFPACK_LIBS"; then
  ## Invalidate the cache and try again with -lcblas.
  $as_unset ac_cv_lib_umfpack_umfpack${UMFPACK_TAG}get_determinant
  $as_unset octave_cv_lib_umfpack
  save_LIBS="$LIBS"
  LIBS="-lcblas $AMD_LDFLAGS $AMD_LIBS $BLAS_LIBS $FLIBS $LIBS"
  OCTAVE_CHECK_LIB([umfpack], UMFPACK,
    [UMFPACK not found.  This will result in some lack of functionality for sparse matrices.],
    [suitesparse/umfpack.h ufsparse/umfpack.h umfpack/umfpack.h umfpack.h],
    [umfpack${UMFPACK_TAG}get_determinant],
    [], [don't use UMFPACK, disable some sparse matrix functionality])
  if test -n "$UMFPACK_LIBS"; then
    UMFPACK_LIBS="$UMFPACK_LIBS -lcblas"
  fi
  LIBS="$save_LIBS"
fi

### Check for KLU library and header.

OCTAVE_CHECK_LIB(klu, KLU,
  [KLU library not found.  This will result in some lack of functionality for sparse matrices.],
  [suitesparse/klu.h ufsparse/klu.h klu/klu.h klu.h], [klu_solve],
  [], [don't use KLU library, disable some sparse matrix functionality])

### SUITESPARSECONFIG_LIBS added to LIBS above.
LIBS="$suitesparse_save_LIBS"

## Collections of flags.
dnl These are here instead of just in the Makefile.am file because we
dnl substitute some of them into other source files like mkoctfile.

## Order matters, at least on some systems (Cygwin, for example).

SPARSE_XCPPFLAGS="$CHOLMOD_CPPFLAGS $UMFPACK_CPPFLAGS $AMD_CPPFLAGS $CAMD_CPPFLAGS $COLAMD_CPPFLAGS $CCOLAMD_CPPFLAGS $CXSPARSE_CPPFLAGS"

SPARSE_XLDFLAGS="$CHOLMOD_LDFLAGS $UMFPACK_LDFLAGS $AMD_LDFLAGS $CAMD_LDFLAGS $COLAMD_LDFLAGS  $CCOLAMD_LDFLAGS $CXSPARSE_LDFLAGS"

SPARSE_XLIBS="$CHOLMOD_LIBS $UMFPACK_LIBS $AMD_LIBS $CAMD_LIBS $COLAMD_LIBS $CCOLAMD_LIBS $CXSPARSE_LIBS $SUITESPARSECONFIG_LIBS"

AC_SUBST(SPARSE_XCPPFLAGS)
AC_SUBST(SPARSE_XLDFLAGS)
AC_SUBST(SPARSE_XLIBS)

## Check for UMFPACK separately split complex matrix and RHS.
if test -n "$UMFPACK_LIBS"; then
  save_CPPFLAGS="$CPPFLAGS"
  save_LDFLAGS="$LDFLAGS";
  save_LIBS="$LIBS";

  CPPFLAGS="$SPARSE_XCPPFLAGS $CPPFLAGS"
  LDFLAGS="$SPARSE_XLDFLAGS $LDFLAGS"
  LIBS="$SPARSE_XLIBS $LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS $xtra_libs"

  OCTAVE_UMFPACK_SEPARATE_SPLIT

  CPPFLAGS="$save_CPPFLAGS"
  LDFLAGS="$save_LDFLAGS"
  LIBS="$save_LIBS"
fi

### Check for SUNDIALS NVECTOR serial library and header.

OCTAVE_CHECK_LIB(sundials_nvecserial, [SUNDIALS NVECTOR],
  [SUNDIALS NVECTOR serial library not found.  Solvers ode15i and ode15s will be disabled.],
  [nvector/nvector_serial.h nvector_serial.h ], [N_VNew_Serial],
  [], [don't use SUNDIALS NVECTOR library, solvers ode15i and ode15s will be disabled])

### Check for SUNDIALS IDA library and header.

save_LIBS="$LIBS"
LIBS="$SUNDIALS_NVECSERIAL_LIBS $KLU_LIBS $BLAS_LIBS $FLIBS $LIBS"
OCTAVE_CHECK_LIB(sundials_ida, [SUNDIALS IDA],
  [SUNDIALS IDA library not found.  Solvers ode15i and ode15s will be disabled.],
  [ida/ida.h ida.h], [IDAInit],
  [], [don't use SUNDIALS IDA library, solvers ode15i and ode15s will be disabled],
  [warn_sundials_ida=
   OCTAVE_CHECK_SUNDIALS_SIZEOF_REALTYPE
   OCTAVE_CHECK_SUNDIALS_IDA_DENSE
   OCTAVE_CHECK_SUNDIALS_IDAKLU])
LIBS="$save_LIBS"

dnl Define this way instead of with an #if in oct-conf-post.h so that
dnl the build features script will get the correct value.
if test -n "$SUNDIALS_IDA_LIBS" \
    && test -n "$SUNDIALS_NVECSERIAL_LIBS" \
    && test $octave_cv_sundials_ida_dense = yes \
    && test $octave_cv_sundials_realtype_is_double = yes; then
  AC_DEFINE(HAVE_SUNDIALS, 1, [Define to 1 if SUNDIALS is available.])
fi

## Collections of flags.
dnl These are here instead of just in the Makefile.am file because we
dnl substitute some of them into other source files like mkoctfile.

dnl Order matters, at least on some systems (Cygwin, for example).

SUNDIALS_XCPPFLAGS="$SUNDIALS_IDA_CPPFLAGS $SUNDIALS_NVECSERIAL_CPPFLAGS $KLU_CPPFLAGS"

SUNDIALS_XLDFLAGS="$SUNDIALS_IDA_LDFLAGS $SUNDIALS_NVECSERIAL_LDFLAGS $KLU_LDFLAGS"

SUNDIALS_XLIBS="$SUNDIALS_IDA_LIBS $SUNDIALS_NVECSERIAL_LIBS $KLU_LIBS"

AC_SUBST(SUNDIALS_XCPPFLAGS)
AC_SUBST(SUNDIALS_XLDFLAGS)
AC_SUBST(SUNDIALS_XLIBS)

### Check for ARPACK library.

save_LIBS="$LIBS"
LIBS="$LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS"
OCTAVE_CHECK_LIB([arpack], ARPACK,
  [ARPACK not found.  The eigs function will be disabled.],
  [],
  [dseupd],
  [Fortran 77], [don't use the ARPACK library, disable eigs function],
  [warn_arpack=
   OCTAVE_CHECK_LIB_ARPACK_OK_1(
     [AC_DEFINE(HAVE_ARPACK, 1, [Define to 1 if ARPACK is available.])],
     [warn_arpack="ARPACK library found, but does not seem to work properly; disabling eigs function"])
   if test -z "$warn_arpack"; then
     OCTAVE_CHECK_LIB_ARPACK_OK_2([],
       [AC_MSG_WARN([ARPACK library found, but is buggy; upgrade library (>= v3.3.0) for better results])])
   fi
   ])
LIBS="$save_LIBS"

### Check for Java.

build_java=yes
AC_ARG_ENABLE([java],
  [AS_HELP_STRING([--disable-java],
    [disable Java interface])],
  [if test "$enableval" = no; then
     build_java=no
   fi],
  [])

AC_ARG_WITH([java-homedir],
  [AS_HELP_STRING([--with-java-homedir=DIR],
    [Java JDK directory in DIR])],
  [JAVA_HOMEDIR="$withval"])

AC_ARG_WITH([java-includedir],
  [AS_HELP_STRING([--with-java-includedir=DIR],
    [look for java include file <jni.h> in DIR])],
  [JAVA_CPPFLAGS="$withval"], [JAVA_CPPFLAGS=""])

AC_ARG_WITH([java-libdir],
  [AS_HELP_STRING([--with-java-libdir=DIR],
    [look for java library libjvm in DIR])],
  [JAVA_LDPATH="$withval"], [JAVA_LDPATH=""])

## Grab JAVA_HOME from environment variable if it exists
AC_ARG_VAR([JAVA_HOME], [path to Java JDK installation])
## But --with-java-homedir option overrides environment variable
if test -n "$JAVA_HOMEDIR"; then
  JAVA_HOME=$JAVA_HOMEDIR
fi
JAVA=
JAVAC=
JAR=
JAVA_LIBS=

dnl Fake loop so that "break" can be used to skip code blocks.
warn_java=
while test $build_java = yes
do
  ## Unset build_java.  Variable is set only if all configuration tests pass.
  build_java=no

  ## Warn if JAVA_HOME is unset.  It is *strongly* advised to specify JAVA_HOME.
  if test -z "$JAVA_HOME"; then
    warn_java_home="JAVA_HOME environment variable not initialized.  Auto-detection will proceed but is unreliable."
    OCTAVE_CONFIGURE_WARNING([warn_java_home])
  fi

  ## Search for a viable Java executable.
  if test -z "$JAVA_HOME"; then
    JAVA_PATH="$PATH"
  else
    JAVA_PATH="${JAVA_HOME}$PATH_SEPARATOR${JAVA_HOME}/jre/bin$PATH_SEPARATOR${JAVA_HOME}/bin$PATH_SEPARATOR${JAVA_HOME}/../bin$PATH_SEPARATOR${PATH}"
  fi
  AC_PATH_PROG(JAVA, java, [], [$JAVA_PATH])

  if test -z "$JAVA"; then
    warn_java="No Java executable found.  Octave will not be able to call Java methods."
    break
  fi

  if test -z "$JAVA_HOME"; then
    ## Find JAVA_HOME for JRE by running java and querying properties.
    JAVA_TMP_HOME=`"$JAVA" -classpath ${srcdir}/build-aux OctJavaQry JAVA_HOME`
    ## Strip directory back to top-level installation dir (JAVA_HOME for JDK).
    JAVA_HOME=`echo $JAVA_TMP_HOME | $SED -e 's|[[/\\]]bin[[/\\]]\?$||' | $SED -e 's|[[/\\]]jre[[/\\]]\?$||'`
  fi

  case $build_os in
    mingw* | msdosmsvc)
      ## Under Win32 platform, we want JAVA_HOME to be in MSYS format, that is
      ## without colon and backslashes, as it is also used as path separator.
      ## Use quoted paths as Java may be installed in a path with whitespaces
      ## (e.g. C:\Program Files\Java\...).
      if test -n "$JAVA_HOME"; then
        JAVA_HOME=`cd "$JAVA_HOME" && pwd`
      fi
    ;;
  esac

  ## Amend search path for JAVAC and JAR.
  if test -z "$JAVA_HOME"; then
    JAVA_PATH="$PATH"
  else
    JAVA_PATH="${JAVA_HOME}$PATH_SEPARATOR${JAVA_HOME}/bin$PATH_SEPARATOR${JAVA_HOME}/../bin$PATH_SEPARATOR${PATH}"
  fi

  AC_PATH_PROG(JAVAC, javac, [], [$JAVA_PATH])
  AC_PATH_PROG(JAR, jar, [], [$JAVA_PATH])

  if test -z "$JAVAC" || test -z "$JAR"; then
    warn_java="No javac compiler or jar executable found.  Octave will not be able to call Java methods."
    break
  fi

  ## Check Java version is recent enough.
  AC_MSG_CHECKING([for Java version])
  java_version=[`"$JAVA" -version 2>&1 | $SED -n -e 's/^[^ ]* version[^0-9"]*"\([^"]*\)".*/\1/p'`]
  AC_MSG_RESULT([$java_version])
  java_major=[`echo $java_version | $SED -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\..*$/\1/'`]
  java_minor=[`echo $java_version | $SED -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\..*$/\2/'`]
  if test $java_major -gt 1 || (test $java_major -eq 1 && test $java_minor -ge 5); then
    :  # Version is OK.  Do nothing.
  else
    warn_java="Java version is too old (< 1.5).  Octave will not be able to call Java methods."
    break
  fi

  ## At this point Win32 systems have enough configuration data.
  ## We assume that all appropriate variables (e.g. INCLUDE and LIB) already
  ## contain the required paths to compile and link against JDK.
  case $host_os in
    msdosmsvc)
      build_java=yes
      JAVA_LIBS=-ladvapi32
      AC_DEFINE(HAVE_JAVA, 1,
        [Define to 1 if Java is available and is at least version 1.5])
      break
    ;;
    mingw* | cygwin*)
      build_java=yes
      JAVA_LIBS=-ladvapi32
      if test $have_msvc = no; then
        if test -n "$JAVA_CPPFLAGS"; then
          JAVA_CPPFLAGS="-I\"${JAVA_CPPFLAGS}\" -I\"${JAVA_CPPFLAGS}/win32\""
        else
          JAVA_CPPFLAGS="-I\"${JAVA_HOME}/include\" -I\"${JAVA_HOME}/include/win32\""
        fi
        LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
      fi
      AC_DEFINE(HAVE_JAVA, 1,
        [Define to 1 if Java is available and is at least version 1.5])
      break
    ;;
  esac

  ## Determine which library filename to search for.
  case $host_os in
    darwin*)
      jvmlib=libjvm.dylib
    ;;
    *)
      jvmlib=libjvm.so
    ;;
  esac

  AC_MSG_CHECKING([for $jvmlib])

  if test -z "$JAVA_LDPATH"; then
    ## Run Java to try and determine library path to libjvm.so.
    JAVA_TMP_LDPATH=`$JAVA -classpath ${srcdir}/build-aux OctJavaQry JAVA_LDPATH`
    JAVA_TMP_LDPATH=`echo $JAVA_TMP_LDPATH | $SED -e "s/${PATH_SEPARATOR}/ /g"`
    for dir in $JAVA_TMP_LDPATH; do
      if test -f "$dir/$jvmlib"; then
        JAVA_LDPATH=$dir
        break
      fi
    done
  fi

  if test -z "$JAVA_LDPATH"; then
    ## Nothing found.  Try Java again using bootpath argument.
    JAVA_TMP_LDPATH=`$JAVA -classpath ${srcdir}/build-aux OctJavaQry JAVA_BOOTPATH`
    JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} ${JAVA_TMP_LDPATH}/client ${JAVA_TMP_LDPATH}/server"
    for dir in $JAVA_TMP_LDPATH; do
      if test -f "$dir/$jvmlib"; then
        JAVA_LDPATH=$dir
        break
      fi
    done
  fi

  if test -z "$JAVA_LDPATH"; then
    ## Java failed to find it's own library path.  Guess wildly.
    JAVA_TMP_LDPATH=`ls -d $JAVA_HOME/jre/lib/*/client`
    JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} `ls -d $JAVA_HOME/jre/lib/*/server`"
    ## Add some paths that might work on Macs.
    JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} ${JAVA_HOME}/../Libraries ${JAVA_HOME}/Libraries"
    ## Add some paths that might work on MinGW
    JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} ${JAVA_HOME}/bin/client ${JAVA_HOME}/bin/server"
    for dir in $JAVA_TMP_LDPATH; do
      if test -f "$dir/$jvmlib"; then
        JAVA_LDPATH=$dir
        break
      fi
    done
  fi

  ## Verify value passed in option --with-java-libdir
  if test -n "$JAVA_LDPATH"; then
    if test -f "${JAVA_LDPATH}/$jvmlib"; then
      :  # libjvm found
    else
      JAVA_LDPATH=""
    fi
  fi

  if test -z "$JAVA_LDPATH"; then
    AC_MSG_RESULT([not found])
    warn_java="Library $jvmlib not found.  Octave will not be able to call Java methods."
    break
  else
    AC_MSG_RESULT([$JAVA_LDPATH])
  fi

  AC_MSG_CHECKING([for include file <jni.h>])

  ## Java and JVM found.  Set up flags.
  case $host_os in
    darwin*)
      if test -n "$JAVA_CPPFLAGS"; then
        JAVA_CPPFLAGS="-I${JAVA_CPPFLAGS} -I${JAVA_CPPFLAGS}/darwin"
      else
        JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin"
      fi
    ;;
    *)
      if test -n "$JAVA_CPPFLAGS"; then
        JAVA_CPPFLAGS="-I${JAVA_CPPFLAGS} -I${JAVA_CPPFLAGS}/linux"
      else
        JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
      fi
    ;;
  esac

  ## Verify jni.h include file exists.
  JNI_PATH=`echo $JAVA_CPPFLAGS | $SED -e 's/-I//g'`
  have_jni=no
  for dir in $JNI_PATH; do
    if test -f "${dir}/jni.h"; then have_jni=yes; break; fi
  done
  if test $have_jni = yes; then
    AC_MSG_RESULT([$dir])
  else
    AC_MSG_RESULT([not found])
    warn_java="Include file <jni.h> not found.  Octave will not be able to call Java methods."
    break
  fi

  ## Passed all configuration tests.  A workable Java installation was found.
  build_java=yes
  AC_DEFINE(HAVE_JAVA, 1,
    [Define to 1 if Java is available and is at least version 1.5])
  break
done
if test -n "$warn_java"; then
  OCTAVE_CONFIGURE_WARNING([warn_java])
fi

AM_CONDITIONAL([AMCOND_HAVE_JAVA], [test $build_java = yes])
AC_SUBST(JAVA)
AC_SUBST(JAVAC)
AC_SUBST(JAR)
AC_SUBST(JAVA_CPPFLAGS)
AC_SUBST(JAVA_LIBS)
AC_DEFINE_UNQUOTED([JAVA_HOME], ["$JAVA_HOME"], [Java home (top-level installation dir)])
AC_DEFINE_UNQUOTED([JAVA_LDPATH], ["$JAVA_LDPATH"], [Java library path (libjvm)])

### Determine if documentation should and can be built.

ENABLE_DOCS=yes
AC_ARG_ENABLE([docs],
  [AS_HELP_STRING([--disable-docs], [don't build documentation files])],
  [if test "$enableval" = no; then
     ENABLE_DOCS=no
     warn_docs="building documentation disabled; make dist will fail."
     OCTAVE_CONFIGURE_WARNING([warn_docs])
   fi], [])
if test $ENABLE_DOCS = yes; then
  if test $opengl_graphics = no || { test "$have_qt_opengl_offscreen" = no && test -n "$warn_osmesa"; }; then
    if test -n "$warn_gnuplot"; then
      ENABLE_DOCS=no
      warn_docs_graphics="building documentation disabled because no suitable graphics toolkit is available; make dist will fail."
      OCTAVE_CONFIGURE_WARNING([warn_docs_graphics])
    fi
  fi
  if test -n "$warn_makeinfo"; then
    ENABLE_DOCS=no
    warn_docs_makeinfo="building documentation disabled because makeinfo was not found or does not support @sortas; make dist will fail."
    OCTAVE_CONFIGURE_WARNING([warn_docs_makeinfo])
  fi
fi
if test $ENABLE_DOCS = yes; then
  AC_DEFINE(ENABLE_DOCS, 1,
    [Define to 1 to build Octave documentation files.])
fi
AM_CONDITIONAL([AMCOND_BUILD_DOCS], [test $ENABLE_DOCS = yes])

AM_CONDITIONAL([AMCOND_BUILD_QT_DOCS],
               [test $ENABLE_DOCS = yes && test $build_qt_gui = yes])

### Determine whether Mercurial ID should be embedded in library binaries.

ENABLE_HG_ID=yes
AC_ARG_ENABLE([hg-id],
  [AS_HELP_STRING([--disable-hg-id],
    [disable embedding of hg id in libraries])],
  [if test "$enableval" = no; then ENABLE_HG_ID=no; fi], [])
AM_CONDITIONAL([AMCOND_ENABLE_HG_ID], [test $ENABLE_HG_ID = yes])

### Determine whether to install build logs with Octave.

install_build_logs=no
AC_ARG_ENABLE([install-build-logs],
  [AS_HELP_STRING([--enable-install-build-logs],
    [install build logs (i.e. config.log) with Octave])],
  [if test "$enableval" = yes; then install_build_logs=yes; fi])
AM_CONDITIONAL([AMCOND_INSTALL_BUILD_LOGS], [test $install_build_logs = yes])

### Add extra compiler flags now that feature testing is complete.

## Add warning flags

dnl Don't add -Wshadow for GCC 4.x.
case "$GCC_VERSION" in
  *4*) ;;
  *)   GCC_WSHADOW_OPTION=-Wshadow ;;
esac

GCC_EXTRA_FLAGS="-Wall -W $GCC_WSHADOW_OPTION -Wformat -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wcast-align -Wcast-qual"
GXX_EXTRA_FLAGS="-Wall -W $GCC_WSHADOW_OPTION -Wold-style-cast -Wformat -Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual"

try_extra_warning_flags=yes
AC_ARG_ENABLE([extra-warning-flags],
  [AS_HELP_STRING([--disable-extra-warning-flags],
    [don't add -Wall, -W, -Wformat, -Wold-style-cast, and other warning options to CFLAGS and CXXFLAGS])],
  [if test "$enableval" = no; then
     try_extra_warning_flags=no
   fi],
  [])

if test $try_extra_warning_flags = yes; then
  for flag in $GCC_EXTRA_FLAGS; do
    OCTAVE_CC_FLAG([$flag], [
      WARN_CFLAGS="$WARN_CFLAGS $flag";
      AC_MSG_RESULT([adding $flag to WARN_CFLAGS])])
  done
  for flag in $GXX_EXTRA_FLAGS; do
    OCTAVE_CXX_FLAG([$flag], [
      WARN_CXXFLAGS="$WARN_CXXFLAGS $flag";
      AC_MSG_RESULT([adding $flag to WARN_CXXFLAGS])])
  done
fi

## Add strict warning flags
GCC_STRICT_FLAGS="-Wconversion"
GXX_STRICT_FLAGS="-Wconversion -Weffc++"

try_strict_warning_flags=no
AC_ARG_ENABLE([strict-warning-flags],
  [AS_HELP_STRING([--enable-strict-warning-flags],
    [add extra strict warning options to CFLAGS and CXXFLAGS])],
  [if test "$enableval" = yes; then
     try_strict_warning_flags=yes
   fi],
  [])

if test $try_strict_warning_flags = yes; then
  for flag in $GCC_STRICT_FLAGS; do
    OCTAVE_CC_FLAG([$flag], [
      WARN_CFLAGS="$WARN_CFLAGS $flag";
      AC_MSG_RESULT([adding $flag to WARN_CFLAGS])])
  done
  for flag in $GXX_STRICT_FLAGS; do
    OCTAVE_CXX_FLAG([$flag], [
      WARN_CXXFLAGS="$WARN_CXXFLAGS $flag";
      AC_MSG_RESULT([adding $flag to WARN_CXXFLAGS])])
  done
fi

## Add sanitizer flags
GCC_ADDRESS_SANITIZER_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
GXX_ADDRESS_SANITIZER_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
LD_ADDRESS_SANITIZER_FLAGS="-fsanitize=address"

try_address_sanitizer_flags=no
AC_ARG_ENABLE([address-sanitizer-flags],
  [AS_HELP_STRING([--enable-address-sanitizer-flags],
    [add extra -fsanitize=address and -fno-omit-frame-pointer options to CFLAGS, CXXFLAGS, and LDFLAGS])],
  [if test "$enableval" = yes; then
     try_address_sanitizer_flags=yes
   fi],
  [])

if test $try_address_sanitizer_flags = yes; then
  ADDRESS_SANITIZER_OPTIONS="symbolize=1"
  AC_SUBST(ADDRESS_SANITIZER_OPTIONS)
fi

AM_CONDITIONAL([AMCOND_ADDRESS_SANITIZER_ENABLED],
  [test $try_address_sanitizer_flags = yes])

if test $try_address_sanitizer_flags = yes; then
  for flag in $GCC_ADDRESS_SANITIZER_FLAGS; do
    OCTAVE_CC_FLAG([$flag], [
      WARN_CFLAGS="$WARN_CFLAGS $flag";
      AC_MSG_RESULT([adding $flag to WARN_CFLAGS])])
  done
  for flag in $GXX_ADDRESS_SANITIZER_FLAGS; do
    OCTAVE_CXX_FLAG([$flag], [
      WARN_CXXFLAGS="$WARN_CXXFLAGS $flag";
      AC_MSG_RESULT([adding $flag to WARN_CXXFLAGS])])
  done
  dnl FIXME: do we really need an LD-specific test, or is this good enough?
  for flag in $LD_ADDRESS_SANITIZER_FLAGS; do
    OCTAVE_CC_FLAG([$flag], [
      WARN_LDFLAGS="$WARN_LDFLAGS $flag";
      AC_MSG_RESULT([adding $flag to WARN_LDFLAGS])])
  done
fi

AC_SUBST(WARN_CFLAGS)
AC_SUBST(WARN_CXXFLAGS)
AC_SUBST(WARN_LDFLAGS)

### Check for GCC-specific pragmas to control warnings.

AC_CACHE_CHECK([for @%:@pragma GCC diagnostic push/pop/ignore],
  [octave_cv_gcc_has_pragma_GCC_diagnostic],
  [AC_LANG_PUSH(C++)
   AC_TRY_COMPILE([], [
#pragma GCC diagnostic push
#pragma GCC diagnostic ignore "-Wold-style-cast"
  int three = (int) 3.1415926;
#pragma GCC diagnostic pop
    ],
    [octave_cv_gcc_has_pragma_GCC_diagnostic=yes],
    [octave_cv_gcc_has_pragma_GCC_diagnostic=no])
   AC_LANG_POP(C++)],
  ])

if test $octave_cv_gcc_has_pragma_GCC_diagnostic = yes; then
  AC_DEFINE(HAVE_PRAGMA_GCC_DIAGNOSTIC, 1,
    [Define to 1 if GCC supports @%:@pragma GCC diagnostic ...])
fi

## Check for one unusual warning used in pragmas that is not always available
if test $octave_cv_gcc_has_pragma_GCC_diagnostic = yes; then
  OCTAVE_CC_FLAG([-Wimplicit-fallthrough],
    [AC_DEFINE(HAVE_WARN_IMPLICIT_FALLTHROUGH, 1,
      [Define to 1 if GCC supports -Wimplicit-fallthrough warning])])
fi

### These are recommended by the gnulib bootstrap script:

GNULIB_LINK_DEPS="$FREXPF_LIBM $FREXP_LIBM $GETHOSTNAME_LIB $LIBSOCKET $LIB_CLOCK_GETTIME $LIB_CRYPTO $LIB_GETLOGIN $LIB_NANOSLEEP $LIB_SELECT $LTLIBICONV $LTLIBINTL $LTLIBTHREAD"

### FIXME: This is a kluge to transform $libdir/libiconv.dll.a to -liconv.
### It would probably be better to fix gnulib to not give us an absolute
### file name...

case $host_os in
  mingw*)
    ## Don't use $libdir here because that's defined to be
    ## ${exec_prefix}/lib and at this point, ${exec_prefix} is "NONE"!
    tmp_libiconv_dll="$LIBICONV_PREFIX/lib/libiconv.dll.a"
    MKOCTFILE_LIBICONV=`echo $LIBICONV | sed "s|$tmp_libiconv_dll|-liconv|"`
  ;;
  *)
    MKOCTFILE_LIBICONV="$LIBICONV"
  ;;
esac

MKOCTFILE_GNULIB_LINK_DEPS="$FREXPF_LIBM $FREXP_LIBM $GETHOSTNAME_LIB $LIBSOCKET $LIB_CLOCK_GETTIME $LIB_CRYPTO $LIB_GETLOGIN $LIB_NANOSLEEP $LIB_SELECT $MKOCTFILE_LIBICONV $LIBINTL $LIBTHREAD"

AC_SUBST(GNULIB_LINK_DEPS)

BASE_LIBOCTAVE_LINK_DEPS="$CURL_LIBS $SPARSE_XLIBS $ARPACK_LIBS $QRUPDATE_LIBS $FFTW_XLIBS $LAPACK_LIBS $BLAS_LIBS $READLINE_LIBS $TERM_LIBS $LIBGLOB $PCRE_LIBS $DL_LIBS $PTHREAD_LIBS $FLIBS $LIBS"

LIBOCTAVE_LINK_DEPS="$BASE_LIBOCTAVE_LINK_DEPS $GNULIB_LINK_DEPS"

MKOCTFILE_LIBOCTAVE_LINK_DEPS="$BASE_LIBOCTAVE_LINK_DEPS $MKOCTFILE_GNULIB_LINK_DEPS"

LIBOCTAVE_LINK_OPTS="$CURL_LDFLAGS $SPARSE_XLDFLAGS $ARPACK_LDFLAGS $QRUPDATE_LDFLAGS $FFTW_XLDFLAGS $PCRE_LDFLAGS"

AC_SUBST(LIBOCTAVE_LINK_DEPS)
AC_SUBST(LIBOCTAVE_LINK_OPTS)

if test $ENABLE_DYNAMIC_LINKING = yes; then
  LIBOCTINTERP_LINK_DEPS=""
else
  LIBOCTINTERP_LINK_DEPS="$DLDFCN_LIBS"
fi

LIBOCTINTERP_LINK_DEPS="$LIBOCTINTERP_LINK_DEPS $FT2_LIBS $HDF5_LIBS $MAGICK_LIBS $Z_LIBS $FFTW_XLIBS $OPENGL_LIBS $FONTCONFIG_LIBS $FREETYPE_LIBS $X11_LIBS $CARBON_LIBS $GL2PS_LIBS $LLVM_LIBS $JAVA_LIBS $LAPACK_LIBS"

LIBOCTINTERP_LINK_OPTS="$FT2_LDFLAGS $HDF5_LDFLAGS $MAGICK_LDFLAGS $Z_LDFLAGS $FFTW_XLDFLAGS $LLVM_LDFLAGS"

OCTAVE_LINK_DEPS=""
OCTAVE_LINK_OPTS=""

OCT_LINK_DEPS=""
OCT_LINK_OPTS="$LDFLAGS"

if test $link_all_deps = yes || test -n "$QT_LDFLAGS"; then
  MKOCTFILE_OCTAVE_LINK_DEPS="$LIBOCTINTERP_LINK_DEPS $MKOCTFILE_LIBOCTAVE_LINK_DEPS"
  MKOCTFILE_OCT_LINK_DEPS="$OCT_LINK_DEPS $MKOCTFILE_LIBOCTINTERP_LINK_DEPS"

  LIBOCTINTERP_LINK_DEPS="$LIBOCTINTERP_LINK_DEPS $LIBOCTAVE_LINK_DEPS"
  LIBOCTINTERP_LINK_OPTS="$LIBOCTINTERP_LINK_OPTS $LIBOCTAVE_LINK_OPTS"

  OCTAVE_LINK_DEPS="$LIBOCTINTERP_LINK_DEPS"
  OCTAVE_LINK_OPTS="$LIBOCTINTERP_LINK_OPTS"

  OCT_LINK_DEPS="$OCT_LINK_DEPS $LIBOCTINTERP_LINK_DEPS"
  OCT_LINK_OPTS="$OCT_LINK_OPTS $LIBOCTINTERP_LINK_OPTS"
fi

AC_SUBST(LIBOCTINTERP_LINK_DEPS)
AC_SUBST(LIBOCTINTERP_LINK_OPTS)

AC_SUBST(OCTAVE_LINK_DEPS)
AC_SUBST(OCTAVE_LINK_OPTS)

AC_SUBST(OCT_LINK_DEPS)
AC_SUBST(OCT_LINK_OPTS)

AC_SUBST(MKOCTFILE_OCTAVE_LINK_DEPS)
AC_SUBST(MKOCTFILE_OCT_LINK_DEPS)

LIBOCTGUI_LINK_DEPS=""
LIBOCTGUI_LINK_OPTS=""

OCTAVE_GUI_LINK_DEPS=""
OCTAVE_GUI_LINK_OPTS=""

if test $build_qt_gui = yes; then
  if test $ENABLE_DYNAMIC_LINKING = yes; then
    LIBOCTGUI_LINK_DEPS=""
  else
    LIBOCTGUI_LINK_DEPS="$DLDFCN_LIBS"
  fi

  LIBOCTGUI_LINK_DEPS="$LIBOCTGUI_LINK_DEPS $QT_LIBS $OPENGL_LIBS"
  LIBOCTGUI_LINK_OPTS="$QT_LDFLAGS"

  if test $link_all_deps = yes || test -n "$QT_LDFLAGS"; then
    LIBOCTGUI_LINK_DEPS="$LIBOCTGUI_LINK_DEPS $LIBOCTINTERP_LINK_DEPS"
    LIBOCTGUI_LINK_OPTS="$LIBOCTGUI_LINK_OPTS $LIBOCTINTERP_LINK_OPTS"

    OCTAVE_GUI_LINK_DEPS="$OCTAVE_GUI_LINK_DEPS $LIBOCTGUI_LINK_DEPS"
    OCTAVE_GUI_LINK_OPTS="$OCTAVE_GUI_LINK_OPTS $LIBOCTGUI_LINK_OPTS"
  fi
fi

AC_SUBST(LIBOCTGUI_LINK_DEPS)
AC_SUBST(LIBOCTGUI_LINK_OPTS)

AC_SUBST(OCTAVE_GUI_LINK_DEPS)
AC_SUBST(OCTAVE_GUI_LINK_OPTS)

##############################################################################
### Configuration tests done

### Restore original compilation flags
CFLAGS="$original_octave_configure_CFLAGS"
CXXFLAGS="$original_octave_configure_CXXFLAGS"

### Add footer to config.h

AH_BOTTOM([#include "oct-conf-post.h"])

### Make all AC_DEFINES available to testif feature of test.m function.
dnl This must reside at the bottom of configure.ac after all AC_DEFINES
dnl have been made.

AC_OUTPUT_MAKE_DEFS

AC_CONFIG_COMMANDS_PRE([
  ## Fully expand all directory variables.  These are normally left
  ## unexpanded (as explained and recommended by the autoconf manual).
  ## But we store configuration info in files and expect whatever
  ## is set at configure time to stay the same when Make is executed.
  ## Doing things like
  ##
  ##   configure --prefix=/some/where
  ##   make --prefix="/some/where/else
  ##
  ## won't work properly and is not allowed when building Octave.

  eval prefix="\"$prefix\""
  eval exec_prefix="\"$exec_prefix\""
  eval bindir="\"$bindir\""
  eval sbindir="\"$sbindir\""
  eval libexecdir="\"$libexecdir\""
  eval datarootdir="\"$datarootdir\""
  eval datadir="\"$datadir\""
  eval sysconfdir="\"$sysconfdir\""
  eval sharedstatedir="\"$sharedstatedir\""
  eval localstatedir="\"$localstatedir\""
  eval runstatedir="\"$runstatedir\""
  eval includedir="\"$includedir\""
  eval oldincludedir="\"$oldincludedir\""
  eval docdir="\"$docdir\""
  eval infodir="\"$infodir\""
  eval htmldir="\"$htmldir\""
  eval dvidir="\"$dvidir\""
  eval pdfdir="\"$pdfdir\""
  eval psdir="\"$psdir\""
  eval libdir="\"$libdir\""
  eval localedir="\"$localedir\""
  eval mandir="\"$mandir\""

  version="$OCTAVE_VERSION"
  api_version="$OCTAVE_API_VERSION"

  eval octlibdir="\"$octlibdir\""
  eval archlibdir="\"$archlibdir\""
  eval localarchlibdir="\"$localarchlibdir\""
  eval localapiarchlibdir="\"$localapiarchlibdir\""
  eval localverarchlibdir="\"$localverarchlibdir\""
  eval octfiledir="\"$octfiledir\""
  eval localoctfiledir="\"$localoctfiledir\""
  eval localapioctfiledir="\"$localapioctfiledir\""
  eval localveroctfiledir="\"$localveroctfiledir\""
  eval octincludedir="\"$octincludedir\""
  eval fcnfiledir="\"$fcnfiledir\""
  eval localfcnfiledir="\"$localfcnfiledir\""
  eval localapifcnfiledir="\"$localapifcnfiledir\""
  eval localverfcnfiledir="\"$localverfcnfiledir\""
  eval octetcdir="\"$octetcdir\""
  eval octlocaledir="\"$octlocaledir\""
  eval doc_cache_file="\"$doc_cache_file\""
  eval octtestsdir="\"$octtestsdir\""
  eval texi_macros_file="\"$texi_macros_file\""
  eval imagedir="\"$imagedir\""
  eval octdatadir="\"$octdatadir\""
  eval octdocdir="\"$octdocdir\""
  eval octfontsdir="\"$octfontsdir\""
  eval startupfiledir="\"$startupfiledir\""
  eval localstartupfiledir="\"$localstartupfiledir\""
  eval man1dir="\"$man1dir\""
  eval man1ext="\"$man1ext\""
  eval infofile="\"$infofile\""

  ## Also expand MKOCTFILE_DL_LDFLAGS, because it may depend on the values
  ## of variables expanded above.

  eval MKOCTFILE_DL_LDFLAGS="\"$MKOCTFILE_DL_LDFLAGS\""
])

### Do substitutions in Makefiles and other files that hold configuration info.

AUTOCONF_SUBST_VARS="`echo $ac_subst_vars`"

AC_SUBST(AUTOCONF_SUBST_VARS)
AC_SUBST(ac_config_files)
AC_SUBST(ac_config_headers)

AC_CONFIG_FILES([
  Makefile
  build-aux/check-subst-vars.sh:build-aux/check-subst-vars.in.sh
  doc/doxyhtml/Doxyfile
  libgnu/Makefile])

dnl We use a .in.h file for oct-conf-post.h simply to copy it to the build tree
dnl so that we don't have to add the -I${top_srcdir} to any CPPFLAGS variables.

AC_CONFIG_FILES([oct-conf-post.h-tmp:oct-conf-post.in.h])
AC_CONFIG_COMMANDS([oct-conf-post.h],
  [$SHELL $srcdir/build-aux/move-if-change oct-conf-post.h-tmp oct-conf-post.h])

OCTAVE_CONFIG_MOVE_IF_CHANGE_FILES([
  libgui/mk-default-qt-settings.sh
  liboctave/external/mk-f77-def.sh
  libinterp/corefcn/mk-mxarray-h.sh
  libinterp/mk-version-h.sh
  build-aux/subst-config-vals.sh
  build-aux/subst-cross-config-vals.sh
  build-aux/subst-default-vals.sh
  build-aux/subst-script-vals.sh])

AC_OUTPUT

### Print a summary of the build configuration.

AC_MSG_NOTICE([

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:              $F77 $FFLAGS
  Fortran libraries:             $FLIBS
  Lex libraries:                 $LEXLIB
  LIBS:                          $LIBS
  LDFLAGS:                       $LDFLAGS
  Extra LDFLAGS:                 $WARN_LDFLAGS

  AMD CPPFLAGS:                  $AMD_CPPFLAGS
  AMD LDFLAGS:                   $AMD_LDFLAGS
  AMD libraries:                 $AMD_LIBS
  ARPACK CPPFLAGS:               $ARPACK_CPPFLAGS
  ARPACK LDFLAGS:                $ARPACK_LDFLAGS
  ARPACK libraries:              $ARPACK_LIBS
  BLAS libraries:                $BLAS_LIBS
  BZ2 CPPFLAGS:                  $BZ2_CPPFLAGS
  BZ2 LDFLAGS:                   $BZ2_LDFLAGS
  BZ2 libraries:                 $BZ2_LIBS
  CAMD CPPFLAGS:                 $CAMD_CPPFLAGS
  CAMD LDFLAGS:                  $CAMD_LDFLAGS
  CAMD libraries:                $CAMD_LIBS
  CARBON libraries:              $CARBON_LIBS
  CCOLAMD CPPFLAGS:              $CCOLAMD_CPPFLAGS
  CCOLAMD LDFLAGS:               $CCOLAMD_LDFLAGS
  CCOLAMD libraries:             $CCOLAMD_LIBS
  CHOLMOD CPPFLAGS:              $CHOLMOD_CPPFLAGS
  CHOLMOD LDFLAGS:               $CHOLMOD_LDFLAGS
  CHOLMOD libraries:             $CHOLMOD_LIBS
  COLAMD CPPFLAGS:               $COLAMD_CPPFLAGS
  COLAMD LDFLAGS:                $COLAMD_LDFLAGS
  COLAMD libraries:              $COLAMD_LIBS
  CURL CPPFLAGS:                 $CURL_CPPFLAGS
  CURL LDFLAGS:                  $CURL_LDFLAGS
  CURL libraries:                $CURL_LIBS
  CXSPARSE CPPFLAGS:             $CXSPARSE_CPPFLAGS
  CXSPARSE LDFLAGS:              $CXSPARSE_LDFLAGS
  CXSPARSE libraries:            $CXSPARSE_LIBS
  DL libraries:                  $DL_LIBS
  FFTW3 CPPFLAGS:                $FFTW3_CPPFLAGS
  FFTW3 LDFLAGS:                 $FFTW3_LDFLAGS
  FFTW3 libraries:               $FFTW3_LIBS
  FFTW3F CPPFLAGS:               $FFTW3F_CPPFLAGS
  FFTW3F LDFLAGS:                $FFTW3F_LDFLAGS
  FFTW3F libraries:              $FFTW3F_LIBS
  FLTK CPPFLAGS:                 $FLTK_CPPFLAGS
  FLTK LDFLAGS:                  $FLTK_LDFLAGS
  FLTK libraries:                $FLTK_LIBS
  fontconfig CPPFLAGS:           $FONTCONFIG_CPPFLAGS
  fontconfig libraries:          $FONTCONFIG_LIBS
  FreeType2 CPPFLAGS:            $FT2_CPPFLAGS
  FreeType2 libraries:           $FT2_LIBS
  GLPK CPPFLAGS:                 $GLPK_CPPFLAGS
  GLPK LDFLAGS:                  $GLPK_LDFLAGS
  GLPK libraries:                $GLPK_LIBS
  HDF5 CPPFLAGS:                 $HDF5_CPPFLAGS
  HDF5 LDFLAGS:                  $HDF5_LDFLAGS
  HDF5 libraries:                $HDF5_LIBS
  Java home:                     $JAVA_HOME
  Java JVM path:                 $JAVA_LDPATH
  Java CPPFLAGS:                 $JAVA_CPPFLAGS
  Java libraries:                $JAVA_LIBS
  KLU CPPFLAGS:                  $KLU_CPPFLAGS
  KLU LDFLAGS:                   $KLU_LDFLAGS
  KLU libraries:                 $KLU_LIBS
  LAPACK libraries:              $LAPACK_LIBS
  LLVM CPPFLAGS:                 $LLVM_CPPFLAGS
  LLVM LDFLAGS:                  $LLVM_LDFLAGS
  LLVM libraries:                $LLVM_LIBS
  Magick++ CPPFLAGS:             $MAGICK_CPPFLAGS
  Magick++ LDFLAGS:              $MAGICK_LDFLAGS
  Magick++ libraries:            $MAGICK_LIBS
  OpenGL libraries:              $OPENGL_LIBS
  PCRE CPPFLAGS:                 $PCRE_CPPFLAGS
  PCRE LDFLAGS:                  $PCRE_LDFLAGS
  PCRE libraries:                $PCRE_LIBS
  PortAudio CPPFLAGS:            $PORTAUDIO_CPPFLAGS
  PortAudio LDFLAGS:             $PORTAUDIO_LDFLAGS
  PortAudio libraries:           $PORTAUDIO_LIBS
  PTHREAD flags:                 $PTHREAD_CFLAGS
  PTHREAD libraries:             $PTHREAD_LIBS
  QHULL CPPFLAGS:                $QHULL_CPPFLAGS
  QHULL LDFLAGS:                 $QHULL_LDFLAGS
  QHULL libraries:               $QHULL_LIBS
  QRUPDATE CPPFLAGS:             $QRUPDATE_CPPFLAGS
  QRUPDATE LDFLAGS:              $QRUPDATE_LDFLAGS
  QRUPDATE libraries:            $QRUPDATE_LIBS
  Qt CPPFLAGS:                   $QT_CPPFLAGS
  Qt LDFLAGS:                    $QT_LDFLAGS
  Qt libraries:                  $QT_LIBS
  Qt moc:                        $MOC $MOCFLAGS
  Qt uic:                        $UIC $UICFLAGS
  Qt rcc:                        $RCC $RCCFLAGS
  Qt lrelease:                   $LRELEASE $LRELEASEFLAGS
  Qt qcollectiongenerator:       $QCOLLECTIONGENERATOR $QCOLLECTIONGENERATORFLAGS
  Qt qhelpgenerator:             $QHELPGENERATOR $QHELPGENERATORFLAGS
  READLINE libraries:            $READLINE_LIBS
  Sndfile CPPFLAGS:              $SNDFILE_CPPFLAGS
  Sndfile LDFLAGS:               $SNDFILE_LDFLAGS
  Sndfile libraries:             $SNDFILE_LIBS
  SuiteSparse config libraries:  $SUITESPARSECONFIG_LIBS
  SUNDIALS IDA CPPFLAGS:         $SUNDIALS_IDA_CPPFLAGS
  SUNDIALS IDA LDFLAGS:          $SUNDIALS_IDA_LDFLAGS
  SUNDIALS IDA libraries:        $SUNDIALS_IDA_LIBS
  SUNDIALS NVECTOR CPPFLAGS:     $SUNDIALS_NVECSERIAL_CPPFLAGS
  SUNDIALS NVECTOR LDFLAGS:      $SUNDIALS_NVECSERIAL_LDFLAGS
  SUNDIALS NVECTOR libraries:    $SUNDIALS_NVECSERIAL_LIBS
  TERM libraries:                $TERM_LIBS
  UMFPACK CPPFLAGS:              $UMFPACK_CPPFLAGS
  UMFPACK LDFLAGS:               $UMFPACK_LDFLAGS
  UMFPACK libraries:             $UMFPACK_LIBS
  X11 include flags:             $X11_INCFLAGS
  X11 libraries:                 $X11_LIBS
  Z CPPFLAGS:                    $Z_CPPFLAGS
  Z LDFLAGS:                     $Z_LDFLAGS
  Z libraries:                   $Z_LIBS

  Default pager:                 $DEFAULT_PAGER
  gnuplot:                       $GNUPLOT

  Build Octave Qt GUI:                  $BUILD_QT_SUMMARY_MSG
  JIT compiler for loops:               $ENABLE_JIT
  Build Java interface:                 $build_java
  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
  64-bit array dims and indexing:       $ENABLE_64
  64-bit BLAS array dims and indexing:  $HAVE_64_BIT_BLAS
  OpenMP SMP multithreading:            $ENABLE_OPENMP
  Truncate intermediate FP results:     $ENABLE_FLOAT_TRUNCATE
  Build cross tools:                    $cross_tools
  Build docs:                           $ENABLE_DOCS
])

warn_msg_printed=false

OCTAVE_CONFIGURE_WARNING_SUMMARY

if test $ENABLE_DYNAMIC_LINKING = yes; then
  if test $SHARED_LIBS = no; then
    AC_MSG_WARN([])
    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 $opengl_graphics = no; then
  AC_MSG_WARN([])
  AC_MSG_WARN([The libraries needed for OpenGL graphics were not found.])
  AC_MSG_WARN([Creating plots is still possible if gnuplot is installed.])
  warn_msg_printed=true
fi

if test $ENABLE_ATOMIC_REFCOUNT = no; then
  AC_MSG_WARN([])
  AC_MSG_WARN([atomic reference counting disabled.])
  AC_MSG_WARN([This feature allows safe access to Octave data from another thread,])
  AC_MSG_WARN([and is required when using the GUI's Qt toolkit for plotting.])
fi

if $warn_msg_printed; then
  AC_MSG_NOTICE([])
  AC_MSG_NOTICE([NOTE: Libraries or auxiliary programs may be skipped if they are not found])
  AC_MSG_NOTICE([NOTE: OR if they are missing required features on your system.])
fi

### End of configure.