summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/configure.ac
blob: a34ed6d83c5bf9405e15d7a57c89be88429965e7 (plain)
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
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
dnl NTP top-level configure.ac				-*- Autoconf -*-
dnl
m4_include([sntp/m4/version.m4])
AC_PREREQ([2.61])
AC_INIT(
    [ntp],
    [VERSION_NUMBER],
    [http://bugs.ntp.org./],
    [],
    [http://www.ntp.org./]dnl
)
AC_CONFIG_MACRO_DIR([sntp/m4])
AC_CONFIG_AUX_DIR([sntp/libevent/build-aux])
AC_LANG([C])

AC_PRESERVE_HELP_ORDER

# Bump ntp_configure_cache_version for each change to configure.ac or
# .m4 files which invalidates cached values from previous configure 
# runs.
#
# If the change affects cache variables used only by the main NTP
# configure.ac, then only its version number should be bumped, while
# the subdir configure.ac version numbers should be unchanged.  The
# same is true for a test/variable that is used only by one subdir
# being changed incompatibly; only that subdir's cache version needs
# bumping.
#
# If a change affects variables shared by all NTP configure scripts,
# please bump the version numbers of each.  If you are not sure, the
# safe choice is to bump all on any cache-invalidating change.
#
# In order to avoid the risk of version stamp collision between -stable
# and -dev branches, do not simply increment the version, instead use
# the date YYYYMMDD optionally with -HHMM if there is more than one
# bump in a day.

ntp_configure_cache_version=20120806

# When the cache version of config.cache and configure do not
# match, NTP_CACHEVERSION will flush the cache.

NTP_CACHEVERSION([main], [$ntp_configure_cache_version])

AM_INIT_AUTOMAKE([1.10 foreign -Wall -Wno-gnu])

dnl AM_SILENT_RULES req. automake 1.11.  [yes] defaults V=0
m4_ifdef(
    [AM_SILENT_RULES],
    [AM_SILENT_RULES([yes])]
)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
dnl the 'build' machine is where we run configure and compile
dnl the 'host' machine is where the resulting stuff runs.
AC_DEFINE_UNQUOTED([STR_SYSTEM], ["$host"],
    [canonical system (cpu-vendor-os) of where we should run])
AC_CONFIG_HEADERS([config.h])
dnl AC_ARG_PROGRAM

ntp_atom_ok=${ntp_atom_ok=no}
ntp_oncore_ok=${ntp_oncore_ok=no}
ntp_parse_ok=${ntp_parse_ok=no}
ntp_ripe_ncc_ok=${ntp_parse_ok=no}
ntp_jupiter_ok=${ntp_jupiter_ok=no}

NTP_PROG_CC
AC_PROG_CPP
# Do we need CXX for anything besides google test?
AC_PROG_CXX
AC_PROG_YACC
AC_PROG_CC_C_O
AX_C99_STRUCT_INIT

NTP_VPATH_HACK		dnl used only by ntpd/Makefile.am

NTP_LOCINFO([sntp])	dnl takes over from NTP_BINDIR, in NTP_LIBNTP

dnl AM_PROG_AR req. automake 1.12
m4_ifdef(
    [AM_PROG_AR],
    [AM_PROG_AR]
)

# So far, the only shared library we might use is libopts.
# It's a small library - we might as well use a static version of it.
AC_DISABLE_SHARED
AC_PROG_LIBTOOL
AC_SUBST([LIBTOOL_DEPS])

# NTP has (so far) been relying on leading-edge autogen, which
# means we need the appropriate corresponding libopts as well.
# Therefore, by default:
# - use the version of libopts we ship with
# - do not install it
# - build a static copy (AC_DISABLE_SHARED - done earlier)
case "${enable_local_libopts+set}" in
 set) ;;
 *) enable_local_libopts=yes ;;
esac
case "${enable_libopts_install+set}" in
 set) ;;
 *) enable_libopts_install=no ;;
esac
enable_nls=no
LIBOPTS_CHECK_NOBUILD([sntp/libopts])

NTP_LIBEVENT_CHECK_NOBUILD([2], [sntp/libevent])

NTP_LIBNTP

AC_MSG_CHECKING([for deprecated --with-arlib])
AC_ARG_WITH([arlib],
	AS_HELP_STRING([--with-arlib], [- deprecated, arlib not distributed]),
	[ans=$withval], [ans=no])
AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    AC_MSG_WARN([Please do not use --with-arlib, arlib is no longer included.  In the future, --with-arlib will not be recognized.])
    ;;
esac

dnl  we need to check for cross compile tools for vxWorks here
AC_PROG_AWK
AS_UNSET([ac_cv_prog_AWK])
AC_SUBST([AWK])				dnl scripts/ntpver.in
AC_PROG_MAKE_SET

AC_SUBST([CFLAGS])
AC_SUBST([LDFLAGS])

AC_PROG_LN_S
AC_ISC_POSIX


AC_PATH_PROG([PATH_PERL], [perl])
dnl  Saving cached hardcoded paths rather than searching $PATH during a
dnl  cached configure run is an optimization not worth the the cost of
dnl  preventing newly-installed tools from being found.  Short-circuit
dnl  the caching after the tests so preset overrides still work.
AS_UNSET([ac_cv_path_PATH_PERL])
AC_PATH_PROG([PATH_TEST], [test])
AS_UNSET([ac_cv_path_PATH_TEST])
test -z "$CONFIG_SHELL" && CONFIG_SHELL=/bin/sh
AC_SUBST([CONFIG_SHELL])		dnl for scripts #!/path/to/sh

AC_ARG_WITH(
    [net-snmp-config],
    [AS_HELP_STRING(
	[--with-net-snmp-config],
	[+ =net-snmp-config]
    )],
    [ans=$withval],
    [ans=yes]
)
case "$ans" in
 no)
    ;;
 yes)
    ans=net-snmp-config
    ;;
 /*)
    ;;
 */*)
    AC_MSG_ERROR([--with-net-snmp-config takes either a name or an absolute path])
    ;;
 *)
    ;;
esac
PROG_NET_SNMP_CONFIG=$ans
AC_MSG_CHECKING([for net-snmp-config path])
case "$PROG_NET_SNMP_CONFIG" in
 no) ;;
 /*)
    PATH_NET_SNMP_CONFIG=$PROG_NET_SNMP_CONFIG
    ;;
 *)
    AC_PATH_PROG([PATH_NET_SNMP_CONFIG], [$PROG_NET_SNMP_CONFIG])
    AS_UNSET([ac_cv_path_PATH_NET_SNMP_CONFIG])
;;
esac
AC_MSG_RESULT([$PATH_NET_SNMP_CONFIG])

case "$PATH_NET_SNMP_CONFIG" in
 /*)	AC_CACHE_CHECK(
	    [for net-snmp version],
	    [ntp_cv_net_snmp_version],
	    [ntp_cv_net_snmp_version=`$PATH_NET_SNMP_CONFIG --version`]
	)
	;;
esac

case "$host" in
 *-*-vxworks*)
    ac_link="$ac_link $VX_KERNEL"
    ;;
esac

# HMS: a check for -lnsl used to be here - now being done in NTP_LIBNTP
AC_SEARCH_LIBS([openlog], [gen syslog])
# XXX library list will be in ac_cv_search_openlog

# LIBSECCOMP is off by default -- needs testing with all the features
# Please send bug reports to loganaden@gmail.com
AC_MSG_CHECKING([if we want to use libseccomp sandboxing (EXPERIMENTAL)])
AC_ARG_ENABLE(
    [libseccomp],
    [AS_HELP_STRING(
	[--enable-libseccomp],
	[EXPERIMENTAL: enable support for libseccomp sandboxing (default is no) ]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=no]
)
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok" in
 yes)
    AC_SEARCH_LIBS(
	[seccomp_init],
	[seccomp],
	[AC_DEFINE([LIBSECCOMP], [1],
	    [Define to any value to include libseccomp sandboxing.])]
    )
    AC_TRY_RUN([
	#include <stdio.h>
	#include <stdlib.h>
	#include <errno.h>
	#include <sys/prctl.h>
	#include <linux/seccomp.h>

	int main(void)
	{
		int ret;
		ret = prctl(PR_GET_SECCOMP, 0, 0, 0, 0);
		if (ret < 0) {
			switch (errno) {
			case ENOSYS:
				return 1;
			case EINVAL:
				return 1;
			default:
				return 1;
			}
		}
		ret = 
		prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
		if (ret < 0) {
			switch (errno) {
			case EINVAL:
				return 1;
			case EFAULT:
				return 0;
			default:
				return 1;
		}
	}
return 1;
}
]
, AC_DEFINE([KERN_SECCOMP], 1, 
[Define to use libseccomp system call filtering.])   
, []
)
    ;;
esac

NTP_FACILITYNAMES

dnl Digital UNIX V4.0 and Solaris 7 have POSIX.1c functions in -lrt
dnl Solaris 2.6 only has -lposix4; in Solaris 7, this is a symlink to -lrt,
dnl so only use one of them.  Linux (glibc-2.1.2 and -2.2.2, at least)
dnl does Strange Things with extra processes using the Posix-compatibility
dnl real-time library, so we don't want to use it.
dnl
dnl 081118 Harlan got tired of looking for a way to get the sched*()
dnl functions to link OK with either cc or gcc.

case "$host" in
 *-*-*linux*) ;;
 *-*-osf4*) ;;
 *-*-osf5*) ;;
 *)
    # HMS: Make sure we check for -lrt for clock_* before this...
    case "$ac_cv_search_clock_gettime" in
     '') AC_MSG_ERROR([Internal Error: Haven't looked for clock_gettime() yet!]) ;;
    esac
    AC_SEARCH_LIBS([sched_setscheduler], [rt posix4])
    ;;
esac

AC_CHECK_HEADERS([bstring.h])
AC_CHECK_HEADER(
    [dns_sd.h],
    [AC_SEARCH_LIBS(
	[DNSServiceRegister],
	[dns_sd],
	[AC_DEFINE([HAVE_DNSREGISTRATION], [1],
	    [Use Rendezvous/DNS-SD registration])]
    )]
)
AC_CHECK_HEADERS([fcntl.h fnmatch.h ieeefp.h inttypes.h kvm.h math.h])

AC_CHECK_HEADERS([memory.h netdb.h poll.h])
AC_CHECK_HEADERS([sgtty.h stdatomic.h])
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([stdlib.h string.h termio.h])
AC_CHECK_HEADERS([termios.h timepps.h timex.h unistd.h])

case "$host" in
 *-*-aix*)
    AC_CHECK_HEADERS([utmpx.h])
    case "$ac_cv_header_utmpx_h" in
     yes)
	;;
     *)
	AC_CHECK_HEADERS([utmp.h])
	;;
    esac
    ;;
 *)
    AC_CHECK_HEADERS([utmp.h utmpx.h])
    ;;
esac

#
# On Suns only (so far) getpass() truncates the typed password to 8
# characters, but getpassphrase() allows up to 257.  Most systems'
# getpass() does not truncate, at least not so as to affect ntpq and
# ntpdc password prompts.
#
# So check for getpassphrase(), but only on Sun operating systems.
#
case "$host" in
 *-*-sunos*|*-*-solaris*)
    AC_CHECK_FUNCS([getpassphrase])
esac


AC_CHECK_HEADERS([net/if6.h])
AC_CHECK_HEADERS([net/route.h], [], [], [
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <net/if.h>
])

AC_CHECK_HEADERS([netinfo/ni.h])
case "$ac_cv_header_netinfo_ni_h" in
 yes)
    AC_DEFINE([HAVE_NETINFO], [1], [NetInfo support?])
esac
AC_CHECK_HEADERS([sun/audioio.h sys/audioio.h sys/file.h])
case "$host" in
 *-*-sunos4*)
    ;;
 *)
    AC_CHECK_HEADERS([sys/ioctl.h])
    ;;
esac
AC_CHECK_HEADERS([sys/ipc.h sys/lock.h sys/mman.h])
# HMS: Check sys/proc.h and sys/resource.h after some others
AC_CHECK_HEADERS([sys/modem.h sys/ppsclock.h sys/ppstime.h sched.h])
case "$ac_cv_header_sched_h" in
 yes)
    ;;
 *)
    AC_CHECK_HEADERS([sys/sched.h])
    ;;
esac
# HMS: Check sys/shm.h after some others
AC_CHECK_HEADERS([sys/select.h sys/signal.h sys/sockio.h])
# HMS: Checked sys/socket.h earlier
case "$host" in
 *-*-netbsd*)
    ;;
 *)
    AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h])
    ;;
esac
AC_CHECK_HEADERS([sys/stat.h sys/stream.h stropts.h sys/stropts.h sys/syssgi.h])
AC_CHECK_HEADERS([sys/systune.h sys/termios.h sys/tpro.h sys/wait.h])
case "$host" in
*-convex-*)
    AC_CHECK_HEADERS([/sys/sync/queue.h /sys/sync/sema.h])
    ;;
*-*-bsdi*)
    AC_CHECK_HEADERS([machine/inline.h sys/pcl720.h sys/i8253.h])
    ;;
esac

case "$ac_cv_header_stdatomic_h" in
 yes)
	AC_CHECK_FUNCS([atomic_thread_fence])
	AC_CACHE_CHECK(
	    [for atomic_thread_fence()],
	    [ntp_cv_func_atomic_thread_fence],
	    [AC_COMPILE_IFELSE(
		[AC_LANG_PROGRAM(
		    [[
			#include <stdatomic.h>
		    ]],
		    [[
			atomic_thread_fence(memory_order_seq_cst);
		    ]]
		)]
		[ntp_cv_func_atomic_thread_fence=yes],
		[ntp_cv_func_atomic_thread_fence=no]
	    )]
	)
    ;;
esac

case "$host" in
 *-*-solaris2.6)
    # Broken...
    ;;
 *)
    AC_CHECK_FUNCS([ntp_adjtime ntp_gettime])
    ;;
esac

case "$host" in
 *-*-*linux*)
    case "$ac_cv_func_ntp_gettime" in
     yes)
	;;
     *)
	AC_CHECK_FUNCS([__ntp_gettime])
	case "$ac_cv_func___ntp_gettime" in
	 yes)
	    AC_DEFINE([ntp_gettime], [__ntp_gettime], [deviant])
		    AC_DEFINE([HAVE_NTP_GETTIME], [1], [via __ntp_gettime])
	esac
	;;
    esac
    AC_CHECK_FUNCS([adjtimex])
    case "$ac_cv_func_adjtimex" in
     yes)
	AC_DEFINE([ntp_adjtime], [adjtimex], [deviant])
	AC_DEFINE([HAVE_NTP_ADJTIME], [1], [via adjtimex])
	have_adjtimex=1
	;;
     *)
	AC_CHECK_FUNCS([__adjtimex])
	case "$ac_cv_func___adjtimex" in
	 yes)
	    AC_DEFINE([ntp_adjtime], [__adjtimex], [deviant])
	    AC_DEFINE([HAVE_NTP_ADJTIME], [1], [via __adjtimex])
	    AC_DEFINE([adjtimex], [__adjtimex], [deviant])
	    AC_DEFINE([HAVE_ADJTIMEX], [1], [via __adjtimex])
	    have_adjtimex=1
	esac
	;;
    esac
esac
case "$have_adjtimex" in
 '')
    # nlist stuff is only needed for tickadj.
    saved_LIBS="$LIBS"
    LIBS=
    AC_SEARCH_LIBS([nlist], [elf ld mld])
    # XXX ac_cv_search_nlist will be 'none required', 'no', or '-l...'
    AC_SEARCH_LIBS([kvm_open], [kvm])	dnl We already know about -lelf here...
    # XXX ac_cv_search_kvm_open will be 'none required', 'no', or '-l...'
    AC_CHECK_HEADERS([nlist.h sys/var.h])
    case "$ac_cv_header_nlist_h" in
     yes)
	AC_DEFINE([NLIST_STRUCT], [1], [nlist stuff])
	AC_CACHE_CHECK(
	    [for n_un in struct nlist],
	    [ntp_cv_struct_nlist_n_un],
	    [AC_COMPILE_IFELSE(
		[AC_LANG_PROGRAM(
		    [[
			#include <nlist.h>
		    ]],
		    [[
			struct nlist n;
			n.n_un.n_name = 0;
		    ]]
		)]
		[ntp_cv_struct_nlist_n_un=yes],
		[ntp_cv_struct_nlist_n_un=no]
	    )]
	)
	case "$ntp_cv_struct_nlist_n_un" in
	 yes)
	    AC_DEFINE([NLIST_NAME_UNION], [1],
		[does struct nlist use a name union?])
	esac
    esac
    AC_SUBST([LDADD_NLIST])
    LDADD_NLIST="$LIBS"
    LIBS="$saved_LIBS"
    AS_UNSET([saved_LIBS])
esac

AC_CHECK_HEADERS([sys/proc.h], [], [], [
    #ifdef HAVE_SYS_TYPES_H
    # include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_TIME_H
    # include <sys/time.h>
    #endif
])

AC_CHECK_HEADERS([sys/resource.h], [], [], [
    #ifdef HAVE_SYS_TIME_H
    # include <sys/time.h>
    #endif
])

AC_CHECK_HEADERS([sys/shm.h], [], [], [
    #ifdef HAVE_SYS_TYPES_H
    # include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_IPC_H
    # include <sys/ipc.h>
    #endif
])

AC_CHECK_HEADERS([sys/timex.h], [], [], [
    #ifdef HAVE_SYS_TIME_H
    # include <sys/time.h>
    #endif
])

AC_TYPE_SIGNAL
AC_TYPE_OFF_T
AC_STRUCT_TM	dnl defines TM_IN_SYS_TIME used by refclock_parse.c

AC_CACHE_CHECK(
    [for a fallback value for HZ],
    [ntp_cv_default_hz],
    [
	ntp_cv_default_hz=100
	case "$host" in
	 alpha*-dec-osf4*|alpha*-dec-osf5*)
	    ntp_cv_default_hz=1024
	    ;;
	 mips-dec-ultrix4*)
	    ntp_cv_default_hz=256
	    ;;
	esac
    ]
)
AC_DEFINE_UNQUOTED([DEFAULT_HZ], [$ntp_cv_default_hz],
    [What is the fallback value for HZ?])

AC_CACHE_CHECK(
    [if we need to override the system's value for HZ],
    [ntp_cv_override_hz],
    [
	ntp_cv_override_hz=no
	case "$host" in
	 alpha*-dec-osf4*|alpha*-dec-osf5*)
	    ntp_cv_override_hz=yes
	    ;;
	 mips-dec-ultrix4*)
	    ntp_cv_override_hz=yes
	    ;;
	 *-*-freebsd*)
	    ntp_cv_override_hz=yes
	    ;;
	 *-*-sunos4*)
	    ntp_cv_override_hz=yes
	    ;;
	 *-*-kfreebsd*)
	    ntp_cv_override_hz=yes
	    ;;
	esac
    ]
)
case "$ntp_cv_override_hz" in
 yes)
    AC_DEFINE([OVERRIDE_HZ], [1],
	[Do we need to override the system's idea of HZ?])
esac

dnl AC_CACHE_CHECK(ut_host in struct utmp, ac_cv_func_ut_host_in_utmp,
dnl [AC_TRY_LINK([#include <sys/types.h>
dnl #include <utmp.h>], [struct utmp ut; ut.ut_host;],
dnl ac_cv_func_ut_host_in_utmp=yes, ac_cv_func_ut_host_in_utmp=no)])
dnl if test $su_cv_func_ut_host_in_utmp = yes; then
dnl   AC_DEFINE(HAVE_UT_HOST)
dnl fi

dnl AC_MSG_CHECKING(if we can get the system boot time)
dnl AC_CACHE_VAL(su_cv_have_boot_time,
dnl [AC_EGREP_CPP(yes,
dnl [#ifdef HAVE_UTMPX_H
dnl #include <utmpx.h>
dnl #else
dnl #include <utmp.h>
dnl #endif
dnl #ifdef BOOT_TIME
dnl yes
dnl #endif
dnl ], su_cv_have_boot_time=yes, su_cv_have_boot_time=no)])
dnl AC_MSG_RESULT($su_cv_have_boot_time)

AC_CACHE_CHECK(
    [for struct rt_msghdr],
    [ntp_cv_struct_rt_msghdr],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#include <sys/types.h>
		#include <sys/socket.h>
		#include <net/if.h>
		#include <net/route.h>
	    ]],
	    [[
		struct rt_msghdr p;
	    ]]
	)],
	[ntp_cv_struct_rt_msghdr=yes],
	[ntp_cv_struct_rt_msghdr=no]
    )]
)

AC_CACHE_CHECK(
    [for struct rtattr],
    [ntp_cv_rtattr],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#include <stddef.h>
		#include <sys/socket.h>
		#include <linux/rtnetlink.h>
	    ]],
	    [[
		struct rtattr p;
	    ]]
	)],
	[ntp_cv_rtattr=yes],
	[ntp_cv_rtattr=no]
    )]
)

case "$ntp_cv_struct_rt_msghdr$ntp_cv_rtattr" in
 *yes*)
    AC_DEFINE([HAS_ROUTING_SOCKET], [1],
	[Do we have a routing socket (rt_msghdr or rtattr)?])
    case "$ntp_cv_rtattr" in
     yes)
	AC_DEFINE([HAVE_RTNETLINK], [1],
	    [Do we have Linux routing socket?])
    esac
esac

AC_CACHE_CHECK(
    [struct sigaction for sa_sigaction],
    [ntp_cv_struct_sigaction_has_sa_sigaction],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#include <signal.h>
	    ]],
	    [[
		struct sigaction act;
		act.sa_sigaction = 0;
	    ]]
	)],
	[ntp_cv_struct_sigaction_has_sa_sigaction=yes],
	[ntp_cv_struct_sigaction_has_sa_sigaction=no]
    )]
)
case "$ntp_cv_struct_sigaction_has_sa_sigaction" in
 yes)
    AC_DEFINE([HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION], [1], [Obvious])
esac

AC_CACHE_CHECK(
    [for struct ppsclockev],
    [ntp_cv_struct_ppsclockev],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#ifdef HAVE_SYS_TYPES_H
		# include <sys/types.h>
		#endif
		#ifdef HAVE_SYS_TERMIOS_H
		# include <sys/termios.h>
		#endif
		#ifdef HAVE_SYS_TIME_H
		# include <sys/time.h>
		#endif
		#ifdef HAVE_SYS_PPSCLOCK_H
		# include <sys/ppsclock.h>
		#endif
	    ]],
	    [[
		extern struct ppsclockev *pce;
		return pce->serial;
	    ]]
	)],
	[ntp_cv_struct_ppsclockev=yes],
	[ntp_cv_struct_ppsclockev=no]
    )]
)
case "$ntp_cv_struct_ppsclockev" in
 yes)
    AC_DEFINE([HAVE_STRUCT_PPSCLOCKEV], [1],
	[Does a system header define struct ppsclockev?])
esac

case "$ac_cv_header_machine_soundcard_h$ac_cv_header_sys_soundcard_h" in
  *yes*)
    AC_CACHE_CHECK(
	[for struct snd_size],
	[ntp_cv_struct_snd_size],
	[AC_COMPILE_IFELSE(
	    [AC_LANG_PROGRAM(
		[[
		    #ifdef HAVE_MACHINE_SOUNDCARD_H
		    # include <machine/soundcard.h>
		    #endif
		    #ifdef HAVE_SYS_SOUNDCARD_H
		    # include <sys/soundcard.h>
		    #endif
		]],
		[[
		    extern struct snd_size *ss;
		    return ss->rec_size;
		]]
	    )],
	    [ntp_cv_struct_snd_size=yes],
	    [ntp_cv_struct_snd_size=no]
        )]
    )
    case "$ntp_cv_struct_snd_size" in
     yes)
	AC_DEFINE([HAVE_STRUCT_SND_SIZE], [1],
	    [Do we have struct snd_size?])
    esac
esac

AC_CACHE_CHECK(
    [struct clockinfo for hz],
    [ntp_cv_struct_clockinfo_has_hz],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#include <sys/time.h>
	    ]],
	    [[
		extern struct clockinfo *pc;
		return pc->hz;
	    ]]
	)],
	[ntp_cv_struct_clockinfo_has_hz=yes],
	[ntp_cv_struct_clockinfo_has_hz=no]
    )]
)
case "$ntp_cv_struct_clockinfo_has_hz" in
 yes)
    AC_DEFINE([HAVE_HZ_IN_STRUCT_CLOCKINFO], [1], [Obvious])
esac

AC_CACHE_CHECK(
    [struct clockinfo for tickadj],
    [ntp_cv_struct_clockinfo_has_hz],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#include <sys/time.h>
	    ]],
	    [[
		extern struct clockinfo *pc;
		return pc->tickadj;
	    ]]
	)],
	[ntp_cv_struct_clockinfo_has_hz=yes],
	[ntp_cv_struct_clockinfo_has_hz=no]
    )]
)
case "$ntp_cv_struct_clockinfo_has_hz" in
 yes)
    AC_DEFINE([HAVE_TICKADJ_IN_STRUCT_CLOCKINFO], [1], [Obvious])
esac

case "$ntp_cv_struct_ntptimeval" in
 yes)
    AC_CHECK_MEMBERS(
	[struct ntptimeval.time.tv_nsec],
	[],
	[],
	[
	    #ifdef HAVE_SYS_TIME_H
	    # include <sys/time.h>
	    #else
	    # ifdef HAVE_TIME_H
	    #  include <time.h>
	    # endif
	    #endif
	    #ifdef HAVE_SYS_TIMEX_H
	    # include <sys/timex.h>
	    #else
	    # ifdef HAVE_TIMEX_H
	    #  include <timex.h>
	    # endif
	    #endif
	]
    )
esac

#### 

AC_CHECK_FUNCS([arc4random_buf])

#### 

saved_LIBS="$LIBS"
LIBS="$LIBS $LDADD_LIBNTP"
AC_CHECK_FUNCS([daemon])
# XXX if we keep everything in LIBS and also keep separate lists, this simplifies.
LIBS="$saved_LIBS"
AS_UNSET([saved_LIBS])

AC_CHECK_FUNCS(
    [finite],
    [],
    [AC_CHECK_FUNCS(
	[isfinite],
	[],
	[
	    AC_MSG_CHECKING([for isfinite with <math.h>])
	    _libs=$LIBS
	    # XXX
	    LIBS="$LIBS -lm"
	    AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
		    [[
			#include <math.h>
		    ]],
		    [[
			float f = 0.0;
			isfinite(f);
		    ]]
		)],
		[ans=yes],
		[ans=no]
	    )
	    LIBS=$_libs
	    AC_MSG_RESULT([$ans])
	    case "$ans" in
	     yes)
		AC_DEFINE([HAVE_ISFINITE], [1])
	    esac
	]
    )]
)

AC_CHECK_FUNCS([fnmatch getbootfile getuid getrusage nanosleep strsignal])

# kvm_open() is only used by tickadj.  Also see above.
case "$ac_cv_header_kvm_h" in
 yes)
    AC_CHECK_FUNCS([kvm_open])
    ;;
esac

case "$host" in
 *-*-sco3.2v5.0.*)
    # Just stubs.  Sigh.
    ;;
 *) AC_CHECK_FUNCS([mkstemp])
    ;;
esac
AC_CHECK_FUNCS([mktime])
case "$host" in
 *-*-aix[[4-9]]*)
    # XXX only verified thru AIX6.
    # Just a stub.  Sigh.
    ;;
 *-*-irix[[45]]*)
    # Just a stub in "old" Irix.  Sigh.
    ;;
# In the belief that the fix for bug 1223 fixes mlockall() under linux...
# *-*-*linux*)
#    # there, but more trouble than it is worth for now (resolver problems)
#    ;;
 *-*-qnx*)
    # Apparently there but not working in QNX.  Sigh?
    ;;
 *-*-sco3.2v5.0.*)
    # Just a stub.  Sigh.
    ;;
 alpha*-dec-osf4*|alpha*-dec-osf5*)
    # mlockall is there, as a #define calling memlk via <sys/mman.h>
    # Not easy to test for - cheat.
    AC_CHECK_FUNCS([memlk], [ac_cv_func_mlockall=yes])
    AC_CHECK_FUNCS([mlockall])
    ;;
 *) AC_CHECK_FUNCS([mlockall])
    ;;
esac
AC_CHECK_FUNCS([nice plock pututline pututxline readlink rtprio])
case "$host" in
 *-*-aix[[4-9]]*)
    # XXX only verified thru AIX6.
    # Just a stub in AIX 4.  Sigh.
    ;;
 *-*-solaris2.5*)
    # Just stubs in solaris2.5.  Sigh.
    ;;
 *) AC_CHECK_FUNCS([sched_setscheduler])
    ;;
esac
AC_CHECK_FUNCS([setlinebuf setpgid setpriority setsid setvbuf])
AC_CHECK_FUNCS([strdup strerror setrlimit strchr])
case "$host" in
 *-*-aix[[4-9]]*)
    # XXX only verified thru AIX6.
    # Just stubs.  Sigh.
    ;;
 *-*-netbsd1*)
    # Just stubs.  Sigh.
    ;;
 *-*-netbsdelf1*)
    # Just stubs.  Sigh.
    ;;
 *-*-openbsd*)
    # Just stubs.  Sigh.
    ;;
 *)
    AC_CHECK_FUNCS([timer_create])
    ;;
esac

NTP_RLIMIT_ITEMS

# some OSes prefer _exit() in forked children to exit()
AC_CHECK_FUNCS([_exit])
ntp_worker_child_exit=exit
case "$ac_cv_func__exit::$host_os" in
 yes::netbsd*)
    ntp_worker_child_exit=_exit
    ;;
 yes::openbsd*)
    ntp_worker_child_exit=_exit
    ;;
esac
AC_DEFINE_UNQUOTED([WORKER_CHILD_EXIT], [$ntp_worker_child_exit],
		   [routine worker child proc uses to exit.])

AC_CHECK_FUNCS([umask uname updwtmp updwtmpx])

###

# http://bugs.ntp.org/737
case "$ac_cv_func_recvmsg" in
 yes)
    AC_CACHE_CHECK(
	[if we need extra help to define struct iovec],
	[ntp_cv_struct_iovec_help],
	[
	    compiled=no
	    for ntp_cv_struct_iovec_help in '0' '1'; do
		AC_COMPILE_IFELSE(
		    [AC_LANG_PROGRAM(
			[[
			    #ifdef HAVE_SYS_TYPES_H
			    # include <sys/types.h>
			    #endif
			    #ifdef HAVE_SYS_SOCKET_H
			    # include <sys/socket.h>
			    #endif
			    #if $ntp_cv_struct_iovec_help
			    # include <sys/uio.h>
			    #endif
			]],
			[[
			    void foo(void) {
				ssize_t x;
				int s = 0;
				struct iovec iov;
				struct msghdr mh;
				int flags = 0;

				mh.msg_iov = &iov;
				x = recvmsg(s, &mh, flags);
			    }
			]]
		    )],
		    [compiled=yes ; break 1],
		    []
		)
	    done
	    case "$compiled" in
	     no)
		ntp_cv_struct_iovec_help=0
	    esac
	    AS_UNSET([compiled])
	]
    )
    case "$ntp_cv_struct_iovec_help" in
     1)
	AC_DEFINE([HAVE_SYS_UIO_H], [1],
	    [Use sys/uio.h for struct iovec help])
    esac
esac

AC_CACHE_CHECK(
    [number of arguments taken by setpgrp()],
    [ntp_cv_func_setpgrp_nargs],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#ifdef HAVE_SYS_TYPES_H
		# include <sys/types.h>
		#endif
		#ifdef HAVE_UNISTD_H
		# include <unistd.h>
		#endif
	    ]],
	    [[
		setpgrp(0, 0);
	    ]]
	)],
	[ntp_cv_func_setpgrp_nargs=2],
	[ntp_cv_func_setpgrp_nargs=0]
    )]
)
case "$ntp_cv_func_setpgrp_nargs" in
 0)
    AC_DEFINE([HAVE_SETPGRP_0], [1],
	      [define if setpgrp takes 0 arguments])
esac

AC_CACHE_CHECK(
    [if we need to declare 'errno'],
    [ntp_cv_decl_errno],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#ifdef HAVE_ERRNO_H
		# include <errno.h>
		#endif
	    ]],
	    [[
		errno = 0;
	    ]]
	)],
	[ntp_cv_decl_errno=no],
	[ntp_cv_decl_errno=yes]
    )]
)
case "$ntp_cv_decl_errno" in
 yes)
    AC_DEFINE([DECL_ERRNO], [1], [Declare errno?])
esac

dnl (prr) aix 4.3 defines h_errno as (*(int *)h_errno_which()) for
dnl MT purposes.  This makes the line "extern int h_errno" choke
dnl the compiler.  Hopefully adding !defined(h_errno) fixes this
dnl without breaking any other platforms.
dnl
AC_CACHE_CHECK(
    [if we may declare 'h_errno'],
    [ntp_cv_decl_h_errno],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#include <sys/types.h>
		#ifdef HAVE_NETINET_IN_H
		# include <netinet/in.h>
		#endif
		#ifdef HAVE_ARPA_NAMESER_H
		# include <arpa/nameser.h>
		#endif
		#ifdef HAVE_NETDB_H
		# include <netdb.h>
		#endif
		#ifdef HAVE_RESOLV_H
		# include <resolv.h>
		#endif
	    ]],
	    [[
		extern int h_errno;
	    ]]
	)],
	[ntp_cv_decl_h_errno=yes],
	[ntp_cv_decl_h_errno=no]
    )]
)
case "$ntp_cv_decl_h_errno" in
 yes)
    AC_DEFINE([DECL_H_ERRNO], [1], [Declare h_errno?])
esac

AC_CACHE_CHECK(
    [if declaring 'syscall()' is ok],
    [ntp_cv_decl_syscall],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#ifdef HAVE_SYS_TYPES_H
		# include <sys/types.h>
		#endif
		#ifdef HAVE_UNISTD_H
		# include <unistd.h>
		#endif
	    ]],
	    [[
		extern int syscall (int, ...);
	    ]]
	)]
	[ntp_cv_decl_syscall=yes],
	[ntp_cv_decl_syscall=no]
    )]
)
case "$ntp_cv_decl_syscall" in
 yes)
    AC_DEFINE([DECL_SYSCALL], [1], [Declare syscall()?])
esac

case "$host" in
 *-*-aix4.3.*)
    AC_DEFINE([DECL_HSTRERROR_0], [1], [Declaration style])		# Needed for XLC under AIX 4.3.2
    ;;
 *-*-mpeix*)
    AC_DEFINE([DECL_ADJTIME_0], [1], [Declaration style])
    AC_DEFINE([DECL_INET_NTOA_0], [1], [Declaration style])
    AC_DEFINE([DECL_MKTEMP_0], [1], [Declaration style])
    AC_DEFINE([DECL_SELECT_0], [1], [Declaration style])
    AC_DEFINE([DECL_SETITIMER_0], [1], [Declaration style])
    AC_DEFINE([DECL_SYSLOG_0], [1], [Declaration style])
    AC_DEFINE([DECL_TIMEOFDAY_0], [1], [Declaration style])
    ;;
 *-*-osf[[45]]*)
    AC_DEFINE([DECL_PLOCK_0], [1], [Declaration style])
    AC_DEFINE([DECL_STIME_1], [1], [Declaration style])
    ;;
 *-*-qnx*)
    AC_DEFINE([DECL_ADJTIME_0], [1], [Declaration style])
    ;;
 *-*-riscos4*)
    AC_DEFINE([DECL_ADJTIME_0], [1], [Declaration style])
    AC_DEFINE([DECL_BZERO_0], [1], [Declaration style])
    AC_DEFINE([DECL_IOCTL_0], [1], [Declaration style])
    AC_DEFINE([DECL_IPC_0], [1], [Declaration style])
    AC_DEFINE([DECL_MEMMOVE_0], [1], [Declaration style])
    AC_DEFINE([DECL_MKTEMP_0], [1], [Declaration style])
    AC_DEFINE([DECL_RENAME_0], [1], [Declaration style])
    AC_DEFINE([DECL_SELECT_0], [1], [Declaration style])
    AC_DEFINE([DECL_SETITIMER_0], [1], [Declaration style])
    AC_DEFINE([DECL_SETPRIORITY_0], [1], [Declaration style])
    AC_DEFINE([DECL_STDIO_0], [1], [Declaration style])
    AC_DEFINE([DECL_STRTOL_0], [1], [Declaration style])
    AC_DEFINE([DECL_SYSLOG_0], [1], [Declaration style])
    AC_DEFINE([DECL_TIME_0], [1], [Declaration style])
    AC_DEFINE([DECL_TIMEOFDAY_0], [1], [Declaration style])
    AC_DEFINE([DECL_TOLOWER_0], [1], [Declaration style])
    ;;
 *-*-solaris2*)
    AC_DEFINE([DECL_MKSTEMP_0], [1], [Declaration style])
    AC_DEFINE([DECL_SETPRIORITY_1], [1], [Declaration style])
    case "$host" in
     *-*-solaris2.4)
        AC_DEFINE([DECL_TIMEOFDAY_0], [1], [Declaration style])
	;;
    esac
    ;;
 *-*-sunos4*)
    AC_DEFINE([DECL_ADJTIME_0], [1], [Declaration style])
    AC_DEFINE([DECL_BCOPY_0], [1], [Declaration style])
    AC_DEFINE([DECL_BZERO_0], [1], [Declaration style])
    AC_DEFINE([DECL_IOCTL_0], [1], [Declaration style])
    AC_DEFINE([DECL_IPC_0], [1], [Declaration style])
    AC_DEFINE([DECL_MEMMOVE_0], [1], [Declaration style])
    AC_DEFINE([DECL_MKTEMP_0], [1], [Declaration style])
    AC_DEFINE([DECL_MKSTEMP_0], [1], [Declaration style])
    AC_DEFINE([DECL_RENAME_0], [1], [Declaration style])
    AC_DEFINE([DECL_SELECT_0], [1], [Declaration style])
    AC_DEFINE([DECL_SETITIMER_0], [1], [Declaration style])
    AC_DEFINE([DECL_SETPRIORITY_0], [1], [Declaration style])
    AC_DEFINE([DECL_SIGVEC_0], [1], [Declaration style])
    case "`basename $ac_cv_prog_CC`" in
     acc*) ;;
     *) AC_DEFINE([DECL_STDIO_0], [1], [Declaration style])
	;;
    esac
    AC_DEFINE([DECL_STRTOL_0], [1], [Declaration style])
    AC_DEFINE([DECL_SYSLOG_0], [1], [Declaration style])
    AC_DEFINE([DECL_TIME_0], [1], [Declaration style])
    AC_DEFINE([DECL_TIMEOFDAY_0], [1], [Declaration style])
    AC_DEFINE([DECL_TOLOWER_0], [1], [Declaration style])
    AC_DEFINE([DECL_TOUPPER_0], [1], [Declaration style])
    AC_DEFINE([DECL_STRERROR_0], [1], [Declaration style])
    ;;
 *-*-ultrix4*)
    AC_DEFINE([DECL_ADJTIME_0], [1], [Declaration style])
    AC_DEFINE([DECL_BZERO_0], [1], [Declaration style])
    AC_DEFINE([DECL_CFSETISPEED_0], [1], [Declaration style])
    AC_DEFINE([DECL_IOCTL_0], [1], [Declaration style])
    AC_DEFINE([DECL_IPC_0], [1], [Declaration style])
    AC_DEFINE([DECL_MKTEMP_0], [1], [Declaration style])
    AC_DEFINE([DECL_NLIST_0], [1], [Declaration style])
    AC_DEFINE([DECL_PLOCK_0], [1], [Declaration style])
    AC_DEFINE([DECL_SELECT_0], [1], [Declaration style])
    AC_DEFINE([DECL_SETITIMER_0], [1], [Declaration style])
    AC_DEFINE([DECL_SETPRIORITY_0], [1], [Declaration style])
    AC_DEFINE([DECL_STIME_0], [1], [Declaration style])
    AC_DEFINE([DECL_SYSLOG_0], [1], [Declaration style])
    AC_DEFINE([DECL_TIMEOFDAY_0], [1], [Declaration style])
    ;;
esac

case "$host" in
 *-*-sco3.2*)
    AC_DEFINE([TERMIOS_NEEDS__SVID3], [1],
	[Do we need to #define _SVID3 when we #include <termios.h>?])
    ;;
esac

case "$host" in
 *-*-hpux[[567]]*)
    AC_DEFINE([NEED_RCVBUF_SLOP], [1],
	[Do we need extra room for SO_RCVBUF? (HPUX < 8)])
esac

dnl Using AC_CACHE_CHECK to honor preset ntp_cv_var_open_bcast_socket
AC_CACHE_CHECK(
    [if we will open the broadcast socket],
    [ntp_cv_var_open_bcast_socket],
    [
	ans=yes
	case "$host" in
	 *-*-domainos)
	    ans=no
	esac
	ntp_cv_var_open_bcast_socket=$ans
    ]
)
case "$ntp_cv_var_open_bcast_socket" in
 yes)
    AC_DEFINE([OPEN_BCAST_SOCKET], [1],
	[Should we open the broadcast socket?])
esac

case "$host" in
 *-*-hpux*)
    AC_DEFINE([NEED_HPUX_FINDCONFIG], [1],
	[Do we want the HPUX FindConfig()?])
esac

dnl using AC_CACHE_CHECK to honor preset $ntp_cv_arg_setpgrp_negpid
AC_CACHE_CHECK(
    [if process groups are set with -pid],
    [ntp_cv_arg_setpgrp_negpid],
    [
	case "$host" in
	 *-*-hpux[[567]]*)
	    ans=no
	    ;;
	 *-*-hpux*)
	    ans=yes
	    ;;
	 *-*-*linux*)
	    ans=yes
	    ;;
	 *-*-sunos3*)
	    ans=yes
	    ;;
	 *-*-ultrix2*)
	    ans=yes
	    ;;
	 *)
	    ans=no
	    ;;
	esac
	ntp_cv_arg_setpgrp_negpid=$ans
    ]
)
case "$ntp_cv_arg_setpgrp_negpid" in
 yes)
    AC_DEFINE([UDP_BACKWARDS_SETOWN], [1],
	[Do we set process groups with -pid?])
esac

AC_CACHE_CHECK(
    [if we need a ctty for F_SETOWN],
    [ntp_cv_func_ctty_for_f_setown],
    [
	case "$host" in
	 *-*-bsdi[[23]]*)
	    ans=yes
	    ;;
	 *-*-freebsd*)
	    ans=yes
	    ;;
	# NetBSD versions prior to 3.99.8 require a CTTY for F_SETOWN,
	# while later versions will fail a ioctl(TIOCSCTTY, 0) call in
	# some cases and so should not have USE_FSETOWNCTTY.  "netbsd"
	# in $host may be followed by "aout", "ecoff", or "elf".
	 *-*-netbsd*[[a-z]]3.[[0-8]]*|*-*-netbsd*[[a-z]][[0-2]].*|*-*-netbsd*[[a-z]]3.99.[[0-7]])
	    ans=yes
	    ;;
	 *-*-netbsd3.[[0-8]]*|*-*-netbsd[[0-2]].*|*-*-netbsd3.99.[[0-7]])
	    ans=yes
	    ;;
	 *-*-openbsd*)
	    ans=yes
	    ;;
	 *-*-osf*)
	    ans=yes
	    ;;
	 *-*-darwin*)
	    ans=yes
	    ;;
	 *)
	    ans=no
	    ;;
	esac
	ntp_cv_func_ctty_for_f_setown=$ans
    ]
)
case "$ntp_cv_func_ctty_for_f_setown" in
 yes)
    AC_DEFINE([USE_FSETOWNCTTY], [1], [Must we have a CTTY for fsetown?])
esac

AC_CACHE_CHECK(
    [if the OS clears cached routes when more specifics become available],
    [ntp_cv_os_routeupdates],
    [
	case "$host" in
	 *-*-netbsd*)
	    ans=yes
	    ;;
	 *)
	    ans=no
	    ;;
	esac
	ntp_cv_os_routeupdates=$ans
    ]
)
case "$ntp_cv_os_routeupdates" in
 yes)
    AC_DEFINE([OS_MISSES_SPECIFIC_ROUTE_UPDATES], [1],
	[need to recreate sockets on changed routing?])
esac

AC_CACHE_CHECK(
    [if the wildcard socket needs REUSEADDR to bind other addresses],
    [ntp_cv_os_wildcardreuse],
    [
	case "$host" in
	 *-*-*linux*)
	    ans=yes
	    ;;
	 *) ans=no
	    ;;
	esac
	ntp_cv_os_wildcardreuse=$ans
    ]
)
case "$ntp_cv_os_wildcardreuse" in
 yes)
    AC_DEFINE([OS_NEEDS_REUSEADDR_FOR_IFADDRBIND], [1],
	[wildcard socket needs REUSEADDR to bind interface addresses])
esac

case "$host" in
 *-*-aix*)
    AC_DEFINE([NLIST_EXTRA_INDIRECTION], [1],
	[Might nlist() values require an extra level of indirection (AIX)?])
esac

AC_CACHE_CHECK(
    [for a minimum recommended value of tickadj],
    [ntp_cv_var_min_rec_tickadj],
    [
	ans=no
	case "$host" in
	 *-*-aix*)
	    ans=40
	    ;;
	esac
	ntp_cv_var_min_rec_tickadj=$ans
    ]
)
case "$ntp_cv_var_min_rec_tickadj" in
 ''|no)
    ;;
 *)
    AC_DEFINE_UNQUOTED([MIN_REC_TICKADJ], [$ntp_cv_var_min_rec_tickadj],
	[Should we recommend a minimum value for tickadj?])
esac

AC_CACHE_CHECK(
    [if the TTY code permits PARENB and IGNPAR],
    [ntp_cv_no_parenb_ignpar],
    [
	ans=no
	case "$host" in
	 i?86-*-*linux*)
	    ans=yes
	    ;;
	 mips-sgi-irix*)
	    ans=yes
	    ;;
	 i?86-*-freebsd[[123]].*)
	    ;;
	 i?86-*-freebsd*)
	    ans=yes
	    ;;
	 *-*-unicosmp*)
	    ans=yes
	    ;;
	esac
	ntp_cv_no_parenb_ignpar=$ans
    ]
)
case "$ntp_cv_no_parenb_ignpar" in
 yes)
    AC_DEFINE([NO_PARENB_IGNPAR], [1],
	[Is there a problem using PARENB and IGNPAR?])
esac

AC_MSG_CHECKING([if we're including processing time debugging code])
AC_ARG_ENABLE(
    [debug-timing],
    [AS_HELP_STRING(
	[--enable-debug-timing],
	[- include processing time debugging code (costs performance)]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=no]
)
case "$ntp_ok" in
 yes)
    AC_DEFINE([DEBUG_TIMING], [1], [Enable processing time debugging?])
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([for a the number of minutes in a DST adjustment])
AC_ARG_ENABLE(
    [dst-minutes],
    [AS_HELP_STRING(
	[--enable-dst-minutes],
	[=60 minutes per DST adjustment])   dnl @<:@ is [, @:>@ is ]
    ],
    [ans=$enableval],
    [ans=60]
)
AC_DEFINE_UNQUOTED([DSTMINUTES], [$ans],
    [The number of minutes in a DST adjustment])
AC_MSG_RESULT([$ans])

AC_MSG_CHECKING([if ntpd will retry permanent DNS failures])
AC_ARG_ENABLE(
    [ignore-dns-errors],
    [AS_HELP_STRING(
	[--enable-ignore-dns-errors],
	[- retry DNS queries on any error]
    )],
    [ans=$enableval],
    [ans=no]
)
case "$ans" in
 yes)
    AC_DEFINE([IGNORE_DNS_ERRORS], [1],
	[Retry queries on _any_ DNS error?])
esac
AC_MSG_RESULT([$ans])

AC_CACHE_CHECK(
    [availability of ntp_{adj,get}time()],
    [ntp_cv_var_ntp_syscalls],
    [
	ntp_cv_var_ntp_syscalls=no
	case "$ac_cv_func_ntp_adjtime$ac_cv_func_ntp_gettime$ac_cv_func___adjtimex" in
	 yesyes*)
	    ntp_cv_var_ntp_syscalls=libc
	    ;;
	 *yes)
	    ntp_cv_var_ntp_syscalls=inline
	    ;;
	 *)
	    AC_PREPROC_IFELSE(
		[AC_LANG_SOURCE(
		    [
			#include <sys/syscall.h>
			#if !defined(SYS_ntp_gettime) || !defined(SYS_ntp_adjtime)
			# error
			#endif
		    ])],
		[ntp_cv_var_ntp_syscalls=kernel]
	    )
	    ;;
	 esac
    ]
)
case "$ntp_cv_var_ntp_syscalls" in
 libc)
    AC_DEFINE([NTP_SYSCALLS_LIBC], [1],
	[Do we have ntp_{adj,get}time in libc?])
    ;;
 kernel)
    AC_DEFINE([NTP_SYSCALLS_STD], [1],
	[Do we have ntp_{adj,get}time in the kernel?])
    ;;
esac

AC_CACHE_CHECK(
    [if sys/timex.h has STA_FLL],
    [ntp_cv_var_sta_fll],
    [AC_PREPROC_IFELSE(
	[AC_LANG_SOURCE(
	    [
		#include <sys/timex.h>
		#ifndef STA_FLL
		# error
		#endif
	    ])],
	[ntp_cv_var_sta_fll=yes],
	[ntp_cv_var_sta_fll=no]
    )]
)

AC_CACHE_CHECK(
    [if we have kernel PLL support],
    [ntp_cv_var_kernel_pll],
    [dnl ntp_cv_var_ntp_syscalls is {no,libc,kernel}
	case "$ac_cv_header_sys_timex_h$ntp_cv_struct_ntptimeval$ntp_cv_var_sta_fll$ntp_cv_var_ntp_syscalls" in
	 *no*)
	    ntp_cv_var_kernel_pll=no
	    ;;
	 *) ntp_cv_var_kernel_pll=yes
	    ;;
	esac
    ]
)
case "$ntp_cv_var_kernel_pll" in
 yes)
    AC_DEFINE([KERNEL_PLL], [1],
	[Does the kernel support precision time discipline?])
esac

AC_CACHE_CHECK(
    [if SIOCGIFCONF returns buffer size in the buffer],
    [ntp_cv_size_returned_in_buffer],
    [
	ans=no
	case "$host" in
	 *-fujitsu-uxp*)
	    ans=yes
	    ;;
	 *-ncr-sysv4*)
	    ans=yes
	    ;;
	 *-univel-sysv*)
	    ans=yes
	    ;;
	esac
	ntp_cv_size_returned_in_buffer=$ans
    ]
)
case "$ntp_cv_size_returned_in_buffer" in
 yes)
    AC_DEFINE([SIZE_RETURNED_IN_BUFFER], [1],
	[Does SIOCGIFCONF return size in the buffer?])
esac

# Check for ioctls TIOCGPPSEV
AC_MSG_CHECKING([for TTY PPS ioctl TIOCGPPSEV])
case "$ac_cv_header_termios_h" in
 yes)
    AC_PREPROC_IFELSE(
	[AC_LANG_SOURCE([
	    #include <termios.h>
	    #ifndef TIOCGPPSEV
	    # error
	    #endif
	])],
	[ntp_ok=yes],
	[ntp_ok=no]
    )
    ;;
 *)
    ntp_ok=no
    ;;
esac
case "$ntp_ok" in
 yes)
    AC_DEFINE([HAVE_TIOCGPPSEV], [1],
	[Do we have the TIOCGPPSEV ioctl (Solaris)?])
esac
AC_MSG_RESULT([$ntp_ok])

# Check for ioctls TIOCSPPS
AC_MSG_CHECKING([for TTY PPS ioctl TIOCSPPS])
case "$ac_cv_header_termios_h" in
 yes)
    AC_PREPROC_IFELSE(
	[AC_LANG_SOURCE([
	    #include <termios.h>
	    #ifndef TIOCSPPS
	    # error
	    #endif
	 ])],
	 [ntp_ok=yes],
	 [ntp_ok=no]
    )
    ;;
 *)
    ntp_ok=no
    ;;
esac
case "$ntp_ok" in
 yes)
    AC_DEFINE([HAVE_TIOCSPPS], [1],
	[Do we have the TIOCSPPS ioctl (Solaris)?])
esac
AC_MSG_RESULT([$ntp_ok])

# Check for ioctls CIOGETEV
AC_MSG_CHECKING([for TTY PPS ioctl CIOGETEV])
case "$ac_cv_header_sys_ppsclock_h" in
 yes)
    AC_PREPROC_IFELSE(
	[AC_LANG_SOURCE([
	    #include <sys/ppsclock.h>
	    #ifndef CIOGETEV
	    # error
	    #endif
	])],
	[ntp_ok=yes],
	[ntp_ok=no]
    )
    ;;
 *)
    ntp_ok=no
    ;;
esac
case "$ntp_ok" in
 yes)
    AC_DEFINE([HAVE_CIOGETEV], [1],
	[Do we have the CIOGETEV ioctl (SunOS, Linux)?])
esac
AC_MSG_RESULT([$ntp_ok])

# ATOM/PPSAPI stuff.

ntp_atom_ok=yes

# Check for header timepps.h, if found then we have PPS API (Draft RFC) stuff.

# The PPSAPI headers need "inline" ($ac_cv_c_inline='inline')
# The PPSAPI needs struct timespec.
# The PPSAPI also needs a timepps header.

case "$ac_cv_c_inline$ntp_cv_struct_timespec" in
 inlineyes)
    case "$ac_cv_header_timepps_h$ac_cv_header_sys_timepps_h$host_os" in
     *yes* | *sunos* | *solaris* | *sco* | *netbsd* )
	AC_DEFINE(HAVE_PPSAPI, 1, [Do we have the PPS API per the Draft RFC?])
	ntp_jupiter_ok=yes
	ntp_oncore_ok=yes
	ntp_parse_ok=yes
	ntp_ripe_ncc_ok=yes
	;;
    esac
    ;;
esac

# Check for ioctls TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG
AC_CHECK_HEADER([linux/serial.h])
case "$ac_cv_header_sys_ppsclock_h$ac_cv_header_linux_serial_h" in
  yesyes)
    AC_MSG_CHECKING([ioctl TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG])
    AC_PREPROC_IFELSE(
	[AC_LANG_SOURCE([
	    #include <sys/time.h>
	    typedef int u_int;
	    #include <sys/ppsclock.h>
	    #include <linux/serial.h>

	    #ifndef TIOCGSERIAL
	    # error
	    #endif
	    #ifndef TIOCSSERIAL
	    # error
	    #endif
	    #ifndef ASYNC_PPS_CD_POS
	    # error
	    #endif
	    #ifndef ASYNC_PPS_CD_NEG
	    # error
	    #endif
	    #ifndef CIOGETEV
	    # error
	    #endif
	])],
	[ntp_ok=yes],
	[ntp_ok=no]
    )
    AC_MSG_RESULT([$ntp_ok])
    ;;
  *)
    ntp_ok=no
    ;;
esac
case "$ntp_ok" in
 yes)
    AC_DEFINE([HAVE_TIO_SERIAL_STUFF], 1,
	[Do we have the TIO serial stuff?])
esac

# Check for SHMEM_STATUS support
AC_MSG_CHECKING([SHMEM_STATUS support])
case "$ac_cv_header_sys_mman_h" in
 yes)
    ntp_ok=yes
    ;;
 *)
    ntp_ok=no
    ;;
esac
case "$ntp_ok" in
 yes)
    AC_DEFINE([ONCORE_SHMEM_STATUS], [1],
	[Do we have support for SHMEM_STATUS?])
esac
AC_MSG_RESULT([$ntp_ok])

ntp_refclock=no

# HPUX only, and by explicit request
AC_MSG_CHECKING([Datum/Bancomm bc635/VME interface])
AC_ARG_ENABLE(
    [BANCOMM],
    [AS_HELP_STRING(
	[--enable-BANCOMM],
	[- Datum/Bancomm bc635/VME interface]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=no]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_BANC], [1], [Datum/Bancomm bc635/VME interface?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$host" in
 yes*-*-hpux*) ;;
 yes*) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
esac

#HPUX only, and only by explicit request
AC_MSG_CHECKING([TrueTime GPS receiver/VME interface])
AC_ARG_ENABLE(
    [GPSVME],
    [AS_HELP_STRING(
	[--enable-GPSVME],
	[- TrueTime GPS receiver/VME interface]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=no]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_GPSVME], 1, [TrueTime GPS receiver/VME interface?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$host" in
 yes*-*-hpux*) ;;
 yes*) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
esac

AC_MSG_CHECKING([for PCL720 clock support])
case "$ac_cv_header_machine_inline_h$ac_cv_header_sys_pcl720_h$ac_cv_header_sys_i8253_h" in
 yesyesyes)
    AC_DEFINE([CLOCK_PPS720], 1, [PCL 720 clock support])
    ans=yes
    ;;
 *)
    ans=no
    ;;
esac
AC_MSG_RESULT([$ans])

AC_MSG_CHECKING([for default inclusion of all suitable non-PARSE clocks])
AC_ARG_ENABLE(
    [all-clocks],
    [AS_HELP_STRING(
	[--enable-all-clocks],
	[+ include all suitable non-PARSE clocks:]
    )],
    [ntp_eac=$enableval],
    [ntp_eac=yes]
)
AC_MSG_RESULT([$ntp_eac])

# HMS: Should we also require ntp_parse_ok?
AC_MSG_CHECKING([if we have support for PARSE clocks])
case "$ntp_atom_ok$ac_cv_header_termio_h$ac_cv_header_termios_h" in
 yes*yes*)
    ntp_canparse=yes
    ;;
 *) ntp_canparse=no
    ;;
esac
AC_MSG_RESULT([$ntp_canparse])

AC_MSG_CHECKING([if we have support for audio clocks])
case "$ac_cv_header_sun_audioio_h$ac_cv_header_sys_audioio_h$ac_cv_header_machine_soundcard_h$ac_cv_header_sys_soundcard_h" in
 *yes*)
    ntp_canaudio=yes
    AC_DEFINE([HAVE_AUDIO], [], [Do we have audio support?])
    ;;
 *) ntp_canaudio=no ;;
esac
AC_MSG_RESULT([$ntp_canaudio])

AC_MSG_CHECKING([if we have support for the SHM refclock interface])
case "$ac_cv_header_sys_ipc_h$ac_cv_header_sys_shm_h" in
 yesyes)
    ntp_canshm=yes
    ;;
 *) ntp_canshm=no ;;
esac
AC_MSG_RESULT([$ntp_canshm])

# Test for termios TIOCMBIS modem control (ACTS, Heath, Palisade)
AC_CACHE_CHECK(
    [for termios modem control],
    [ntp_cv_modem_control],
    [AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
	    [[
		#ifdef HAVE_UNISTD_H
		# include <unistd.h>
		#endif
		#ifdef HAVE_TERMIOS_H
		# include <termios.h>
		#endif
		#ifdef HAVE_SYS_IOCTL_H
		# include <sys/ioctl.h>
		#endif
	    ]],
	    [[
		int	dtr = TIOCM_DTR;

		ioctl(1, TIOCMBIS, (char *)&dtr);
	    ]]
	)],
	[ntp_cv_modem_control=yes],
	[ntp_cv_modem_control=no]
    )]
)
case "$ntp_eac::$ntp_cv_modem_control" in
 yes::yes)
    ntp_enable_all_modem_control_clocks=yes
    ;;
 *)
    ntp_enable_all_modem_control_clocks=no
    ;;
esac

# Requires modem control
AC_MSG_CHECKING([ACTS modem service])
AC_ARG_ENABLE(
    [ACTS],
    [AS_HELP_STRING(
	[--enable-ACTS],
	[s ACTS modem service]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_enable_all_modem_control_clocks]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_ACTS], [1], [ACTS modem service])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Arbiter 1088A/B GPS receiver])
AC_ARG_ENABLE(
    [ARBITER],
    [AS_HELP_STRING(
	[--enable-ARBITER],
	[+ Arbiter 1088A/B GPS receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_ARBITER], [1], [Arbiter 1088A/B GPS receiver])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Arcron MSF receiver])
AC_ARG_ENABLE(
    [ARCRON_MSF],
    [AS_HELP_STRING(
	[--enable-ARCRON-MSF],
	[+ Arcron MSF receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_ARCRON_MSF], [1], [ARCRON support?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Austron 2200A/2201A GPS receiver])
AC_ARG_ENABLE(
    [AS2201],
    [AS_HELP_STRING(
	[--enable-AS2201],
	[+ Austron 2200A/2201A GPS receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_AS2201], [1], [Austron 2200A/2201A GPS receiver?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([ATOM PPS interface])
AC_ARG_ENABLE(
    [ATOM],
    [AS_HELP_STRING(
	[--enable-ATOM],
	[s ATOM PPS interface]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_atom_ok" in
 no) ntp_ok=no ;;
esac
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_ATOM], [1], [PPS interface?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Chrono-log K-series WWVB receiver])
AC_ARG_ENABLE(
    [CHRONOLOG],
    [AS_HELP_STRING(
	[--enable-CHRONOLOG],
	[+ Chrono-log K-series WWVB receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_CHRONOLOG], [1], [Chronolog K-series WWVB receiver?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([CHU modem/decoder])
AC_ARG_ENABLE(
    [CHU],
    [AS_HELP_STRING(
	[--enable-CHU],
	[+ CHU modem/decoder]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_CHU], [1], [CHU modem/decoder])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
ntp_refclock_chu=$ntp_ok

AC_MSG_CHECKING([CHU audio/decoder])
AC_ARG_ENABLE(
    [AUDIO-CHU],
    [AS_HELP_STRING(
	[--enable-AUDIO-CHU],
	[s CHU audio/decoder]
    )],
    [ntp_ok=$enableval],
    [
	case "$ntp_eac$ntp_refclock_chu$ntp_canaudio" in
	 *no*)	ntp_ok=no  ;;
	 *)	ntp_ok=yes ;;
	esac
    ]
)
AC_MSG_RESULT([$ntp_ok])
# We used to check for sunos/solaris target...
case "$ntp_ok$ntp_refclock_chu$ntp_canaudio" in
 yes*no*) AC_MSG_WARN([*** But the expected answer is...no ***])
esac

# Not under HP-UX
AC_MSG_CHECKING([Datum Programmable Time System])
AC_ARG_ENABLE(
    [DATUM],
    [AS_HELP_STRING(
	[--enable-DATUM],
	[s Datum Programmable Time System]
    )],
    [ntp_ok=$enableval],
    [
	case "$ac_cv_header_termios_h" in
	 yes)
	    ntp_ok=$ntp_eac
	    ;;
	 *) ntp_ok=no
	    ;;
	esac
    ]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_DATUM], [1], [Datum Programmable Time System?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Dumb generic hh:mm:ss local clock])
AC_ARG_ENABLE(
    [DUMBCLOCK],
    [AS_HELP_STRING(
	[--enable-DUMBCLOCK],
	[+ Dumb generic hh:mm:ss local clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_DUMBCLOCK], [1], [Dumb generic hh:mm:ss local clock?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Forum Graphic GPS])
AC_ARG_ENABLE(
    [FG],
    [AS_HELP_STRING(
	[--enable-FG],
	[+ Forum Graphic GPS]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_FG], [1], [Forum Graphic GPS datating station driver?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

# Requires modem control
AC_MSG_CHECKING([Heath GC-1000 WWV/WWVH receiver])
AC_ARG_ENABLE(
    [HEATH],
    [AS_HELP_STRING(
	[--enable-HEATH],
	[s Heath GC-1000 WWV/WWVH receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_enable_all_modem_control_clocks]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_HEATH], [1], [Heath GC-1000 WWV/WWVH receiver?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([for hopf serial clock device])
AC_ARG_ENABLE(
    [HOPFSERIAL],
    [AS_HELP_STRING(
	[--enable-HOPFSERIAL],
	[+ hopf serial clock device]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_HOPF_SERIAL], [1], [HOPF serial clock device?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([for hopf PCI clock 6039])
AC_ARG_ENABLE(
    [HOPFPCI],
    [AS_HELP_STRING(
	[--enable-HOPFPCI],
	[+ hopf 6039 PCI board]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_HOPF_PCI], [1], [HOPF PCI clock device?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([HP 58503A GPS receiver])
AC_ARG_ENABLE(
    [HPGPS],
    [AS_HELP_STRING(
	[--enable-HPGPS],
	[+ HP 58503A GPS receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_HPGPS], 1, [HP 58503A GPS receiver?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([IRIG audio decoder])
AC_ARG_ENABLE(
    [IRIG],
    [AS_HELP_STRING(
	[--enable-IRIG],
	[s IRIG audio decoder]
    )],
    [ntp_ok=$enableval],
    [
	case "$ntp_eac$ntp_canaudio" in
	 *no*)	ntp_ok=no  ;;
	 *)	ntp_ok=yes ;;
	esac
    ]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_IRIG], [1], [IRIG audio decoder?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canaudio" in
 yesno) AC_MSG_WARN([*** But the expected answer is... no ***])
esac

AC_MSG_CHECKING([for JJY receiver])
AC_ARG_ENABLE(
    [JJY],
    [AS_HELP_STRING(
	[--enable-JJY],
	[+ JJY receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_JJY], [1], [JJY receiver?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Rockwell Jupiter GPS receiver])
AC_ARG_ENABLE(
    [JUPITER],
    [AS_HELP_STRING(
	[--enable-JUPITER],
	[s Rockwell Jupiter GPS receiver]
    )],
    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
case "$ntp_jupiter_ok" in
 no) ntp_ok=no ;;
esac
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_JUPITER], [1], [Rockwell Jupiter GPS clock?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Leitch CSD 5300 Master Clock System Driver])
AC_ARG_ENABLE(
    [LEITCH],
    [AS_HELP_STRING(
	[--enable-LEITCH],
	[+ Leitch CSD 5300 Master Clock System Driver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_LEITCH], [1],
	[Leitch CSD 5300 Master Clock System Driver?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([local clock reference])
AC_ARG_ENABLE(
    [LOCAL-CLOCK],
    [AS_HELP_STRING(
	[--enable-LOCAL-CLOCK],
	[+ local clock reference]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_LOCAL], [1], [local clock reference?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

dnl Bug 340: longstanding unfixed bugs
dnl AC_MSG_CHECKING([EES M201 MSF receiver])
dnl AC_ARG_ENABLE([MSFEES],
dnl     [AS_HELP_STRING([--enable-MSFEES], [+ EES M201 MSF receiver])],
dnl     [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
dnl if test "$ntp_ok" = "yes"; then
dnl     ntp_refclock=yes
dnl     AC_DEFINE([CLOCK_MSFEES], [1], [EES M201 MSF receiver])
dnl fi
dnl AC_MSG_RESULT([$ntp_ok])

# Not Ultrix
AC_MSG_CHECKING([Magnavox MX4200 GPS receiver])
AC_ARG_ENABLE(
    [MX4200],
    [AS_HELP_STRING(
	[--enable-MX4200 ],
	[s Magnavox MX4200 GPS receiver]
    )],
    [ntp_ok=$enableval],
    [
	case "$ac_cv_var_ppsclock" in
	 yes)
	    ntp_ok=$ntp_eac
	    ;;
	 *)
	    ntp_ok=no
	    ;;
	esac
    ]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_MX4200], [1], [Magnavox MX4200 GPS receiver])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$host" in
 yes*-*-ultrix*) AC_MSG_WARN([*** But the expected answer is... no ***])
esac

AC_MSG_CHECKING([for NeoClock4X receiver])
AC_ARG_ENABLE(
    [NEOCLOCK4X],
    [AS_HELP_STRING(
	[--enable-NEOCLOCK4X],
	[+ NeoClock4X DCF77 / TDF receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_NEOCLOCK4X], [1], [NeoClock4X])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([NMEA GPS receiver])
AC_ARG_ENABLE(
    [NMEA],
    [AS_HELP_STRING(
	[--enable-NMEA],
	[+ NMEA GPS receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_NMEA], [1], [NMEA GPS receiver])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_CHECK_FUNCS([strtoll])
AC_MSG_CHECKING([for GPSD JSON receiver])
AC_ARG_ENABLE(
    [GPSD],
    [AS_HELP_STRING(
	[--enable-GPSD],
	[+ GPSD JSON receiver]
    )],
    [ntp_ok=$enableval],
    [case "$ac_cv_func_strtoll" in
     yes) ntp_ok=$ntp_eac ;;
     *)   ntp_ok="no" ;;
    esac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_GPSDJSON], [1], [GPSD JSON receiver])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([for ONCORE Motorola VP/UT Oncore GPS])
AC_ARG_ENABLE(
    [ONCORE],
    [AS_HELP_STRING(
	[--enable-ONCORE],
	[s Motorola VP/UT Oncore GPS receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_oncore_ok" in
 no) ntp_ok=no ;;
esac
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_ONCORE], 1, [Motorola UT Oncore GPS])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

# Requires modem control
AC_MSG_CHECKING([for Palisade clock])
AC_ARG_ENABLE(
    [PALISADE],
    [AS_HELP_STRING(
	[--enable-PALISADE],
	[s Palisade clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_enable_all_modem_control_clocks]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_PALISADE], [1], [Palisade clock])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Conrad parallel port radio clock])
AC_ARG_ENABLE(
    [PCF],
    [AS_HELP_STRING(
	[--enable-PCF ],
	[+ Conrad parallel port radio clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_PCF], [1], [Conrad parallel port radio clock])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([PST/Traconex 1020 WWV/WWVH receiver])
AC_ARG_ENABLE(
    [PST],
    [AS_HELP_STRING(
	[--enable-PST],
	[+ PST/Traconex 1020 WWV/WWVH receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_PST], [1], [PST/Traconex 1020 WWV/WWVH receiver])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([RIPENCC specific Trimble driver])
AC_ARG_ENABLE(
    [RIPENCC],
    [AS_HELP_STRING(
	[--enable-RIPENCC],
	[- RIPENCC specific Trimble driver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=no]
)
# 020629: HMS: s/$ntp_eac -> -/no because of ptr += sprintf(ptr, ...) usage
case "$ntp_ripe_ncc_ok" in
 no) ntp_ok=no ;;
esac
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_RIPENCC], [],[RIPE NCC Trimble clock])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

# Danny Meyer says SHM compiles (with a few warnings) under Win32.
# For *IX, we need sys/ipc.h and sys/shm.h.
AC_MSG_CHECKING([for SHM clock attached thru shared memory])
AC_ARG_ENABLE(
    [SHM],
    [AS_HELP_STRING(
	[--enable-SHM],
	[s SHM clock attached thru shared memory]
    )],
    [ntp_ok=$enableval],
    [
	case "$ntp_eac$ntp_canshm" in
	 *no*)	ntp_ok=no  ;;
	 *)	ntp_ok=yes ;;
	esac
    ]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_SHM], [1], [clock thru shared memory])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Spectracom 8170/Netclock/2 WWVB receiver])
AC_ARG_ENABLE(
    [SPECTRACOM],
    [AS_HELP_STRING(
	[--enable-SPECTRACOM],
	[+ Spectracom 8170/Netclock/2 WWVB receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_SPECTRACOM], [1],
	[Spectracom 8170/Netclock/2 WWVB receiver])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([KSI/Odetics TPRO/S GPS receiver/IRIG interface])
AC_ARG_ENABLE(
    [TPRO],
    [AS_HELP_STRING(
	[--enable-TPRO],
	[s KSI/Odetics TPRO/S GPS receiver/IRIG interface]
    )],
    [ntp_ok=$enableval],
    [
	case "$ac_cv_header_sys_tpro_h" in
	 yes)
	    ntp_ok=$ntp_eac
	    ;;
	 *)
	    ntp_ok=no
	    ;;
	esac
    ]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_TPRO], [1],
	[KSI/Odetics TPRO/S GPS receiver/IRIG interface])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ac_cv_header_sys_tpro" in
 yesno) AC_MSG_WARN([*** But the expected answer is... no ***])
esac

# Not on a vax-dec-bsd
AC_MSG_CHECKING([Kinemetrics/TrueTime receivers])
AC_ARG_ENABLE(
    [TRUETIME],
    [AS_HELP_STRING(
	[--enable-TRUETIME],
	[s Kinemetrics/TrueTime receivers]
    )],
    [ntp_ok=$enableval],
    [
	case "$host" in
	 vax-dec-bsd)
	    ntp_ok=no
	    ;;
	 *)
	    ntp_ok=$ntp_eac
	    ;;
	esac
    ]
)    
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_TRUETIME], [1], [Kinemetrics/TrueTime receivers])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$host" in
 yesvax-dec-bsd) AC_MSG_WARN([*** But the expected answer is... no ***])
esac

AC_MSG_CHECKING([TrueTime 560 IRIG-B decoder])
AC_ARG_ENABLE(
    [TT560],
    [AS_HELP_STRING(
	[--enable-TT560],
	[- TrueTime 560 IRIG-B decoder]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=no]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_TT560], [], [TrueTime 560 IRIG-B decoder?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Ultralink M320 WWVB receiver])
AC_ARG_ENABLE(
    [ULINK],
    [AS_HELP_STRING(
	[--enable-ULINK],
	[+ Ultralink WWVB receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_ULINK], [1], [Ultralink M320 WWVB receiver?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([Spectracom TSYNC PCI timing board])
AC_ARG_ENABLE(
    [TSYNCPCI],
    [AS_HELP_STRING(
	[--enable-TSYNCPCI],
	[s Spectracom TSYNC timing board]
    )],
    [ntp_ok=$enableval],
    [
	case "$host" in
	 *-*-*linux*)
	    ntp_ok=$ntp_eac
	    ;;
	 *)
	    ntp_ok=no
	esac
    ]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_TSYNCPCI], [1], [Spectracom TSYNC timing board])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([WWV receiver])
AC_ARG_ENABLE(
    [WWV],
    [AS_HELP_STRING(
	[--enable-WWV],
	[s WWV Audio receiver]
    )],
    [ntp_ok=$enableval],
    [
	case "$ntp_eac$ntp_canaudio" in
	 *no*)	ntp_ok=no  ;;
	 *)	ntp_ok=yes ;;
	esac
    ]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_WWV], [1], [WWV audio driver])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canaudio" in
 yesno) AC_MSG_WARN([*** But the expected answer is... no ***])
esac

AC_MSG_CHECKING([for Zyfer receiver])
AC_ARG_ENABLE(
    [ZYFER],
    [AS_HELP_STRING(
	[--enable-ZYFER],
	[+ Zyfer GPStarplus receiver]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eac]
)
case "$ntp_ok" in
 yes)
    ntp_refclock=yes
    AC_DEFINE([CLOCK_ZYFER], [1], [Zyfer GPStarplus])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

AC_MSG_CHECKING([for default inclusion of all suitable PARSE clocks])
AC_ARG_ENABLE(
    [parse-clocks],
    [AS_HELP_STRING(
	[--enable-parse-clocks],
	[- include all suitable PARSE clocks:]
    )],
    [ntp_eapc=$enableval],
    [
	case "$ntp_eac" in
	 yes)	ntp_eapc=$ntp_canparse ;;
	 *)	ntp_eapc=no ;;
	esac
	# Delete the next line one of these days
	ntp_eapc=no
    ]
)
AC_MSG_RESULT($ntp_eapc)

case "$ntp_eac$ntp_eapc$ntp_canparse" in
 noyes*)
    AC_MSG_ERROR(["--enable-parse-clocks" requires "--enable-all-clocks".])
    ;;
 yesyesno)
    AC_MSG_ERROR([You said "--enable-parse-clocks" but PARSE isn't supported on this platform!])
    ;;
esac

ntp_libparse=no
ntp_parseutil=no
ntp_rawdcf=no

AC_MSG_CHECKING([Diem Computime Radio Clock])
AC_ARG_ENABLE(
    [COMPUTIME],
    [AS_HELP_STRING(
	[--enable-COMPUTIME],
	[s Diem Computime Radio Clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_COMPUTIME], [1], [Diems Computime Radio Clock?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([ELV/DCF7000 clock])
AC_ARG_ENABLE(
    [DCF7000],
    [AS_HELP_STRING(
	[--enable-DCF7000],
	[s ELV/DCF7000 clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_DCF7000], [1], [ELV/DCF7000 clock?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([HOPF 6021 clock])
AC_ARG_ENABLE(
    [HOPF6021],
    [AS_HELP_STRING(
	[--enable-HOPF6021],
	[s HOPF 6021 clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_HOPF6021], [1], [HOPF 6021 clock?])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([Meinberg clocks])
AC_ARG_ENABLE(
    [MEINBERG],
    [AS_HELP_STRING(
	[--enable-MEINBERG],
	[s Meinberg clocks]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_MEINBERG], [1], [Meinberg clocks])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([DCF77 raw time code])
AC_ARG_ENABLE(
    [RAWDCF],
    [AS_HELP_STRING(
	[--enable-RAWDCF],
	[s DCF77 raw time code]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_parseutil=yes
    ntp_refclock=yes
    ntp_rawdcf=yes
    AC_DEFINE([CLOCK_RAWDCF], [1], [DCF77 raw time code])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

case "$ntp_rawdcf" in
 yes)
    AC_CACHE_CHECK([if we must enable parity for RAWDCF],
	[ntp_cv_rawdcf_parity],
	[
	    ans=no
	    case "$host" in
	     *-*-*linux*)
		ans=yes
		;;
	    esac
	    ntp_cv_rawdcf_parity=$ans
	]
    )
    case "$ntp_cv_rawdcf_parity" in
     yes)
	AC_DEFINE([RAWDCF_NO_IGNPAR], [1],
	    [Should we not IGNPAR (Linux)?]) ;;
    esac
esac

AC_MSG_CHECKING([RCC 8000 clock])
AC_ARG_ENABLE(
    [RCC8000],
    [AS_HELP_STRING(
	[--enable-RCC8000],
	[s RCC 8000 clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_RCC8000], [1], [RCC 8000 clock])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([Schmid DCF77 clock])
AC_ARG_ENABLE(
    [SCHMID],
    [AS_HELP_STRING(
	[--enable-SCHMID ],
	[s Schmid DCF77 clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_SCHMID], [1], [Schmid DCF77 clock])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([Trimble GPS receiver/TAIP protocol])
AC_ARG_ENABLE(
    [TRIMTAIP],
    [AS_HELP_STRING(
	[--enable-TRIMTAIP],
	[s Trimble GPS receiver/TAIP protocol]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_TRIMTAIP], [1],
	[Trimble GPS receiver/TAIP protocol])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([Trimble GPS receiver/TSIP protocol])
AC_ARG_ENABLE(
    [TRIMTSIP],
    [AS_HELP_STRING(
	[--enable-TRIMTSIP],
	[s Trimble GPS receiver/TSIP protocol]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_TRIMTSIP], [1],
	[Trimble GPS receiver/TSIP protocol])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([WHARTON 400A Series clock])
AC_ARG_ENABLE(
    [WHARTON],
    [AS_HELP_STRING(
	[--enable-WHARTON],
	[s WHARTON 400A Series clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_WHARTON_400A], [1], [WHARTON 400A Series clock])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING([VARITEXT clock])
AC_ARG_ENABLE(
    [VARITEXT],
    [AS_HELP_STRING(
	[--enable-VARITEXT],
	[s VARITEXT clock]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=$ntp_eapc]
)
case "$ntp_ok" in
 yes)
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE([CLOCK_VARITEXT], [1], [VARITEXT clock])
    ;;
esac
AC_MSG_RESULT([$ntp_ok])
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
esac

AC_MSG_CHECKING(SEL240X clock)
AC_ARG_ENABLE(SEL240X,
    AC_HELP_STRING([--enable-SEL240X], [s SEL240X clock]),
    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
if test "$ntp_ok" = "yes"; then
    ntp_libparse=yes
    ntp_refclock=yes
    AC_DEFINE(CLOCK_SEL240X, 1, [SEL240X protocol])
fi
AC_MSG_RESULT($ntp_ok)
case "$ntp_ok$ntp_canparse" in
 yesno)
    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
    ;;
esac

AC_SUBST([LIBPARSE])
AC_SUBST([MAKE_LIBPARSE])
AC_SUBST([MAKE_LIBPARSE_KERNEL])
AC_SUBST([MAKE_CHECK_Y2K])

AC_MSG_CHECKING([if we need to make and use the parse libraries])
ans=no
case "$ntp_libparse" in
 yes)
    ans=yes
    AC_DEFINE([CLOCK_PARSE], [1], [PARSE driver interface])
    LIBPARSE=../libparse/libparse.a
    MAKE_LIBPARSE=libparse.a
    # HMS: check_y2k trips the 34 year problem now...
    false && MAKE_CHECK_Y2K=check_y2k
esac
AC_MSG_RESULT([$ans])

NTP_OPENSSL

NTP_CRYPTO_RAND

# if we are using OpenSSL (--with-crypto), by default Autokey is enabled
AC_MSG_CHECKING([if we want to include NTP Autokey protocol support])
AC_ARG_ENABLE(
    [autokey],
    AS_HELP_STRING(
	[--enable-autokey],
	[+ support NTP Autokey protocol]
	),
    [ntp_autokey=$enableval],
    [ntp_autokey=$ntp_openssl]
)
case "$ntp_autokey" in
 no)
    ;;
 *)
    case "$ntp_openssl" in
     no)
	AC_MSG_WARN([Disabling Autokey, --enable-autokey requires --with-crypto.])
	ntp_autokey=no
	;;
     *)
	AC_DEFINE([AUTOKEY], [1], [Support NTP Autokey protocol?])
	ntp_autokey=yes
	;;
    esac
    ;;
esac
AC_MSG_RESULT([$ntp_autokey])

AC_SUBST([MAKE_CHECK_LAYOUT])
AC_MSG_CHECKING([if we want to run check-layout])
case "$cross_compiling$PATH_PERL" in
 no/*)
    MAKE_CHECK_LAYOUT=check-layout
    ans=yes
    ;;
 *)
    ans=no
    ;;
esac
AC_MSG_RESULT([$ans])

AC_SUBST([TESTDCF])
AC_SUBST([DCFD])
AC_MSG_CHECKING([if we can make dcf parse utilities])
ans=no
case "$ntp_parseutil" in
 yes)
    case "$host" in
     *-*-sunos4*|*-*-solaris2*|*-*-*linux*|*-*-netbsd*)
	ans="dcfd testdcf"
	DCFD=dcfd
	TESTDCF=testdcf
    esac
    ;;
esac
AC_MSG_RESULT([$ans])

AC_SUBST([MAKE_PARSEKMODULE])
AC_MSG_CHECKING([if we can build kernel streams modules for parse])
ans=no
case "$ntp_parseutil$ac_cv_header_sys_stropts_h" in
 yesyes)
    case "$host" in
     sparc-*-sunos4*)
        case "$ntp_cv_var_kernel_pll" in
	yes)
	    AC_DEFINE([PPS_SYNC], [1], [PARSE kernel PLL PPS support])
	    ;;
	esac
	ans=parsestreams
	MAKE_PARSEKMODULE=parsestreams.loadable_module.o
	;;
     sparc-*-solaris2*)
	ans=parsesolaris
	MAKE_PARSEKMODULE=parse
	AC_CHECK_HEADERS([strings.h])
	;;
    esac
    ;;
esac
AC_MSG_RESULT([$ans])

AC_MSG_CHECKING([if we need basic refclock support])
case "$ntp_refclock" in
 yes)
    AC_DEFINE([REFCLOCK], [1], [Basic refclock support?])
    ;;
esac
AC_MSG_RESULT($ntp_refclock)

dnl Things that can be made in clockstuff
AC_SUBST([PROPDELAY], [propdelay])
AC_SUBST([CHUTEST]) dnl needs work to compile

AC_SUBST([MAKE_ADJTIMED])
AC_MSG_CHECKING([if we want HP-UX adjtimed support])
case "$host" in
 *-*-hpux[[56789]]*)
    ans=yes
    ;;
 *) ans=no
    ;;
esac
case "$ans" in
 yes)
    MAKE_ADJTIMED=adjtimed
    AC_DEFINE([NEED_HPUX_ADJTIME], [1],
	[Do we need HPUX adjtime() library support?])
    ;;
 *) ADJTIMED_DB=
    ADJTIMED_DL=
    ADJTIMED_DS=
    ADJTIMED_MS=
    ;;
esac
AC_MSG_RESULT([$ans])

AC_MSG_CHECKING([if we want QNX adjtime support])
case "$host" in
 *-*-qnx*)
    ans=yes
    ;;
 *) ans=no
    ;;
esac
case "$ans" in
 yes)
    AC_DEFINE([NEED_QNX_ADJTIME], [1],
	[Do we need the qnx adjtime call?])
    ;;
esac
AC_MSG_RESULT([$ans])

AC_MSG_CHECKING([if we can read kmem])

#  the default is to enable it if the system has the capability

case "$ac_cv_func_nlist$ac_cv_func_K_open$ac_cv_func_kvm_open" in
 *yes*)
    ans=yes
    ;;
 *) ans=no
    ;;
esac

case "$host" in
 *-*-domainos)	# Won't be found...
    ans=no
    ;;
 *-*-hpux*)
    #ans=no
    ;;
 *-*-irix[[456]]*)
    ans=no
    ;;
 *-*-*linux*)
    ans=no
    ;;
 *-*-winnt3.5)
    ans=no
    ;;
 *-*-unicosmp*)
    ans=no
    ;;
esac

# --enable-kmem / --disable-kmem controls if present
AC_ARG_ENABLE(
    [kmem],
    [AS_HELP_STRING(
	[--enable-kmem],
	[s read /dev/kmem for tick and/or tickadj]
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    can_kmem=yes
    ;;
 *)
    can_kmem=no
    AC_DEFINE([NOKMEM], [1], [Should we NOT read /dev/kmem?])
esac


AC_MSG_CHECKING([if adjtime is accurate])

# target-dependent defaults

case "$host" in
 i386-sequent-ptx*)
    ans=no
    ;;
 i386-unknown-osf1*)
    ans=yes
    ;;
 mips-sgi-irix[[456]]*)
    ans=yes
    ;;
 *-fujitsu-uxp*)
    ans=yes
    ;;
 *-ibm-aix[[4-9]]*)
    # XXX only verified thru AIX6.
    ans=yes
    ;;
 *-*-*linux*)
    ans=yes
    ;;
 *-*-solaris2.[[01]])
    ans=no
    ;;
 *-*-solaris2*)
    ans=yes
    ;;
 *-*-unicosmp*)
    ans=yes
    ;;
 *) ans=no
    ;;
esac

# --enable-accurate-adjtime / --disable-accurate-adjtime
# override the default
AC_ARG_ENABLE(
    [accurate-adjtime],
    [AS_HELP_STRING(
	[--enable-accurate-adjtime],
	[s the adjtime() call is accurate]
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    AC_DEFINE([ADJTIME_IS_ACCURATE], [1], [Is adjtime() accurate?])
    adjtime_is_accurate=yes
    ;;
 *)
    adjtime_is_accurate=no
    ;;
esac

AC_CACHE_CHECK(
    [the name of 'tick' in the kernel],
    [ntp_cv_nlist_tick],
    [
	ans=_tick
	case "$host" in
	 m68*-hp-hpux*) # HP9000/300?
	    ans=_old_tick
	    ;;
	 *-apple-aux[[23]]*)
	    ans=tick
	    ;;
	 *-hp-hpux*)
	    ans=old_tick
	    ;;
	 *-ibm-aix[[3-9]]*)
	    # XXX only verified thru AIX6.
	    ans=no
	    ;;
	 *-*-mpeix*)
	    ans=no
	    ;;
	 *-*-ptx*)
	    ans=tick
	    ;;
	 *-*-sco3.2v[[45]]*)
	    ans=no
	    ;;
	 *-*-solaris2*)
	    ans=nsec_per_tick
	    ;;
	 *-*-sysv4*)
	    ans=tick
	    ;;
	esac
	ntp_cv_nlist_tick=$ans
    ]
)
case "$ntp_cv_nlist_tick" in
 ''|no)
    ;;	# HMS: I think we can only get 'no' here...
 *)
    AC_DEFINE_UNQUOTED([K_TICK_NAME], ["$ntp_cv_nlist_tick"],
	[What is the name of TICK in the kernel?])
esac

AC_CACHE_CHECK(
    [for the units of 'tick'],
    [ntp_cv_tick_nano],
    [
	ans=usec
	case "$host" in
	 *-*-solaris2*)
	    ans=nsec
	    ;;
	esac
	ntp_cv_tick_nano=$ans
    ]
)
case "$ntp_cv_tick_nano" in
 nsec)
    AC_DEFINE([TICK_NANO], [1], [Is K_TICK_NAME in nanoseconds?])
esac

AC_CACHE_CHECK(
    [the name of 'tickadj' in the kernel],
    [ntp_cv_nlist_tickadj],
    [
	ans=_tickadj
	case "$host" in
	 m68*-hp-hpux*) # HP9000/300?
	    ans=_tickadj
	    ;;
	 *-apple-aux[[23]]*)
	    ans=tickadj
	    ;;
	 *-hp-hpux10*)
	    ans=no
	    ;;
	 *-hp-hpux9*)
	    ans=no
	    ;;
	 *-hp-hpux*)
	    ans=tickadj
	    ;;
	 *-*-aix*)
	    ans=tickadj
	    ;;
	 *-*-mpeix*)
	    ans=no
	    ;;
	 *-*-ptx*)
	    ans=tickadj
	    ;;
	 *-*-sco3.2v4*)
	    ans=no
	    ;;
	 *-*-sco3.2v5.0*)
	    ans=clock_drift
	    ;;
	 *-*-solaris2*)
	    ans=no	# hrestime_adj
	    ;;
	 *-*-sysv4*)
	    ans=tickadj
	    ;;
	esac
	ntp_cv_nlist_tickadj=$ans
    ]
)
case "$ntp_cv_nlist_tickadj" in
 ''|no)
    ;;	# HMS: I think we can only get 'no' here...
 *)
    AC_DEFINE_UNQUOTED([K_TICKADJ_NAME], ["$ntp_cv_nlist_tickadj"],
	[What is the name of TICKADJ in the kernel?])
esac

AC_CACHE_CHECK(
    [for the units of 'tickadj'],
    [ntp_cv_tickadj_nano],
    [
	ans=usec
	case "$host" in
	 *-*-solaris2*)
	    ans=nsec
	    ;;
	esac
	ntp_cv_tickadj_nano=$ans
    ]
)
case "$ntp_cv_tickadj_nano" in
 nsec)
    AC_DEFINE([TICKADJ_NANO], [1], [Is K_TICKADJ_NAME in nanoseconds?])
esac

AC_CACHE_CHECK(
    [half-heartedly for 'dosynctodr' in the kernel],
    [ntp_cv_nlist_dosynctodr],
    [
	case "$host" in
	 *-apple-aux[[23]]*)
	    ans=no
	    ;;
	 *-sni-sysv*)
	    ans=dosynctodr
	    ;;
	 *-stratus-vos)
	    ans=no
	    ;;
	 *-*-aix*)
	    ans=dosynctodr
	    ;;
	 *-*-hpux*)
	    ans=no
	    ;;
	 *-*-mpeix*)
	    ans=no
	    ;;
	 *-*-nextstep*)
	    ans=_dosynctodr
	    ;;
	 *-*-ptx*)
	    ans=doresettodr
	    ;;
	 *-*-sco3.2v4*)
	    ans=no
	    ;;
	 *-*-sco3.2v5*)
	    ans=track_rtc
	    ;;
	 *-*-solaris2*)
	    ans=dosynctodr
	    ;;
	 *-*-sysv4*)
	    ans=doresettodr
	    ;;
	 *)
	    ans=_dosynctodr
	    ;;
	esac
	ntp_cv_nlist_dosynctodr=$ans
    ]
)
case "$ntp_cv_nlist_dosynctodr" in
 no)
    ;;
 *)
    AC_DEFINE_UNQUOTED([K_DOSYNCTODR_NAME], ["$ntp_cv_nlist_dosynctodr"],
	[What is (probably) the name of DOSYNCTODR in the kernel?])
    ;;
esac

AC_CACHE_CHECK(
    [half-heartedly for 'noprintf' in the kernel],
    [ntp_cv_nlist_noprintf],
    [
	case "$host" in
	 *-apple-aux[[23]]*)
	    ans=no
	    ;;
	 *-sni-sysv*)
	    ans=noprintf
	    ;;
	 *-stratus-vos)
	    ans=no
	    ;;
	 *-*-aix*)
	    ans=noprintf
	    ;;
	 *-*-hpux*)
	    ans=no
	    ;;
	 *-*-mpeix*)
	    ans=no
	    ;;
	 *-*-ptx*)
	    ans=noprintf
	    ;;
	 *-*-nextstep*)
	    ans=_noprintf
	    ;;
	 *-*-solaris2*)
	    ans=noprintf
	    ;;
	 *-*-sysv4*)
	    ans=noprintf
	    ;;
	 *)
	    ans=_noprintf
	    ;;
	esac
	ntp_cv_nlist_noprintf=$ans
    ]
)
case "$ntp_cv_nlist_noprintf" in
 no)
    ;;
 *)
    AC_DEFINE_UNQUOTED([K_NOPRINTF_NAME], ["$ntp_cv_nlist_noprintf"],
	[What is (probably) the name of NOPRINTF in the kernel?])
    ;;
esac

dnl The tick/tickadj sections were written by Skippy, who never learned
dnl that it's impolite (horridly gross) to show your guts in public.

dnl	tick		tickadj
dnl	10000		80	    Unixware
dnl	1000000L/hz	tick/16     (Solaris,UXPV,HPUX) && ADJTIME_IS_ACCURATE
dnl	10000		150	    sgi IRIX
dnl	1000000L/hz	1000	    RS6000 && NOKMEM
dnl	1000000L/hz	668	    DOMAINOS && NOKMEM
dnl	1000000L/hz	500/HZ	    other && NOKMEM
dnl	txc.tick	1	    Linux
dnl	(every / 10)	50	    WinNT - tickadj is roughly 500/hz
dnl	1000000L/hz	(nlist)     (Solaris && !ADJTIME_IS_ACCURATE),
dnl				    (RS6000 && !NOKMEM), SINIX MIPS

dnl But we'll only use these "values" if we can't find anything else.

AC_MSG_CHECKING([for a default value for 'tick'])

# target-dependent default for tick

case "$host" in
 *-*-pc-cygwin*)
    AC_MSG_ERROR([tick needs work for cygwin])
    ;;
 *-univel-sysv*)
    ans=10000
    ;;
 *-*-irix*)
    ans=10000
    ;;
 *-*-*linux*)
    ans=txc.tick
    ;;
 *-*-mpeix*)
    ans=no
    ;;
 *-*-winnt3.5)
    ans='(every / 10)'
    ;;
 *-*-unicosmp*)
    ans=10000
    ;;
 *)
    ans='1000000L/hz'
    ;;
esac

AC_ARG_ENABLE(
    [tick],
    [AS_HELP_STRING(
	[--enable-tick=VALUE],
	[s force a value for 'tick']
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 ''|no)
    ;;	# HMS: I think we can only get 'no' here...
 *)
    AC_DEFINE_UNQUOTED([PRESET_TICK], [$ans],
	[Preset a value for 'tick'?])
esac

AC_MSG_CHECKING([for a default value for 'tickadj'])

# target-specific default
ans='500/hz'
case "$host" in
 *-fujitsu-uxp*)
    case "$adjtime_is_accurate" in
     yes)
	ans='tick/16'
    esac
    ;;
 *-univel-sysv*)
    ans=80
    ;;
 *-*-aix*)
    case "$can_kmem" in
     no)
	ans=1000
	;;
    esac
    ;;
 *-*-domainos)	# Skippy: won't be found...
    case "$can_kmem" in
     no)
	ans=668
	;;
    esac
    ;;
 *-*-hpux*)
    case "$adjtime_is_accurate" in
     yes)
	ans='tick/16'
	;;
    esac
    ;;
 *-*-irix*)
    ans=150
    ;;
 *-*-mpeix*)
    ans=no
    ;;
 *-*-sco3.2v5.0*)
    ans=10000L/hz
    ;;
 *-*-winnt3.5)
    ans=50
    ;;
 *-*-unicosmp*)
    ans=150
    ;;
esac

AC_ARG_ENABLE(
    [tickadj],
    [AS_HELP_STRING(
	[--enable-tickadj=VALUE],
	[s force a value for 'tickadj']
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

default_tickadj=$ans

case "$default_tickadj" in
 ''|no)
    ;;	# HMS: I think we can only get 'no' here...
 *)
    AC_DEFINE_UNQUOTED([PRESET_TICKADJ], [$default_tickadj],
	[Preset a value for 'tickadj'?]) ;;
esac

# Newer versions of ReliantUNIX round adjtime() values down to
# 1/100s (system tick). Sigh ...
# Unfortunately, there is no easy way to know if particular release
# has this "feature" or any obvious way to test for it.
case "$host" in
 mips-sni-sysv4*)
    AC_DEFINE([RELIANTUNIX_CLOCK], [1],
	[Do we want the ReliantUNIX clock hacks?])
esac

case "$host" in
 *-*-sco3.2v5*)
    AC_DEFINE([SCO5_CLOCK], [1], [Do we want the SCO clock hacks?])
esac

ntp_cv_make_tickadj=yes
case "$can_kmem$ac_cv_var_tick$default_tickadj" in
 nonono)	# Don't read KMEM, no presets.  Bogus.
    AC_MSG_WARN([Can't read kmem, no PRESET_TICK or PRESET_TICKADJ.  No tickadj.])
    ntp_cv_make_tickadj=no
    ;;
 nono*)		# Don't read KMEM, no PRESET_TICK but PRESET_TICKADJ.  Bogus.
    AC_MSG_WARN([Can't read kmem but no PRESET_TICK.  No tickadj.])
    ntp_cv_make_tickadj=no
    ;;
 no*no)		# Don't read KMEM, PRESET_TICK but no PRESET_TICKADJ.  Bogus.
    AC_MSG_WARN([Can't read kmem but no PRESET_TICKADJ.  No tickadj.])
    ntp_cv_make_tickadj=no
    ;;
 no*)		# Don't read KMEM, PRESET_TICK and PRESET_TICKADJ.  Cool.
    ;;
 yesnono)	# Read KMEM, no presets.  Cool.
    ;;
 yesno*)	# Read KMEM, no PRESET_TICK but PRESET_TICKADJ.  Bogus.
    AC_MSG_WARN([PRESET_TICKADJ is defined but not PRESET_TICK.  Please report this.])
    ;;
 yes*no)	# Read KMEM, PRESET_TICK but no PRESET_TICKADJ.  Cool.
    ;;
 yes*)		# READ KMEM, PRESET_TICK and PRESET_TICKADJ.
    ;;
 *)		# Generally bogus.
    AC_MSG_ERROR([This shouldn't happen.])
    ;;
esac

AC_SUBST(MAKE_NTPTIME)
AC_CACHE_CHECK([if we want and can make the ntptime utility], ac_cv_make_ntptime,
[case "$host" in
 *) case "$ntp_cv_struct_ntptimeval$ntp_cv_var_kernel_pll" in
     yesyes)
	ans=yes
	;;
     *)
	ans=no
	;;
    esac
    ;;
esac
ac_cv_make_ntptime=$ans])
case "$ac_cv_make_ntptime" in
 yes)
    MAKE_NTPTIME=ntptime
    ;;
 *)
    NTPTIME_DB=
    NTPTIME_DL=
    NTPTIME_DS=
    NTPTIME_MS=
    ;;
esac

AC_SUBST([MAKE_TICKADJ])
case "$host" in
 mips-sni-sysv4*)
    # tickadj is pretty useless on newer versions of ReliantUNIX
    # Do not bother
    ntp_cv_make_tickadj=no
    ;;
 *-*-irix*)
    ntp_cv_make_tickadj=no
    ;;
 *-*-solaris2*)
    # DLM says tickadj is a no-no starting with solaris2.5
    case "$host" in
     *-*-solaris2.1[[0-9]]*)
	ntp_cv_make_tickadj=no
	;;
     *-*-solaris2.[[0-4]]*) ;;
     *) ntp_cv_make_tickadj=no ;;
    esac
    ;;
 *-*-unicosmp*)
    ntp_cv_make_tickadj=no
    ;;
esac

#
# Despite all the above, we always make tickadj.  Setting
# ntp_cv_make_tickadj before AC_CACHE_CHECK will cause a false
# report that the configuration variable was cached.  It may
# be better to simply remove the hunk above, I did not want
# to remove it if there is hope it will be used again.
#
AS_UNSET([ntp_cv_make_tickadj])

AC_CACHE_CHECK(
    [if we want and can make the tickadj utility],
    [ntp_cv_make_tickadj],
    [ntp_cv_make_tickadj=yes]
)
case "$ntp_cv_make_tickadj" in
 yes)
    MAKE_TICKADJ=tickadj
    ;;
 *)
    CALC_TICKADJ_DB=
    CALC_TICKADJ_DL=
    CALC_TICKADJ_DS=
    CALC_TICKADJ_MS=
    TICKADJ_DB=
    TICKADJ_DL=
    TICKADJ_DS=
    TICKADJ_MS=
    ;;
esac

AC_SUBST([MAKE_TIMETRIM])
AC_CACHE_CHECK(
    [if we want and can make the timetrim utility],
    [ntp_cv_make_timetrim],
    [
	case "$host" in
	 *-*-irix*)
	    ntp_cv_make_timetrim=yes
	    ;;
	 *-*-unicosmp*)
	    ntp_cv_make_timetrim=yes
	    ;;
	 *)
	    ntp_cv_make_timetrim=no
	    ;;
	esac
    ]
)
case "$ntp_cv_make_timetrim" in
 yes)
    MAKE_TIMETRIM=timetrim
    ;;
 *) TIMETRIM_DB=
    TIMETRIM_DL=
    TIMETRIM_DS=
    TIMETRIM_MS=
    ;;
esac

AC_SUBST([MAKE_LIBNTPSIM])
AC_SUBST([MAKE_NTPDSIM])

AC_MSG_CHECKING([if we want to build the NTPD simulator])
AC_ARG_ENABLE(
    [simulator],
    [AS_HELP_STRING(
	[--enable-simulator],
	[- build/install the NTPD simulator?]
    )],
    [ans=$enableval],
    [ans=no]
)
AC_MSG_RESULT([$ans])
case "$ans" in
 yes)
    MAKE_NTPDSIM=ntpdsim
    MAKE_LIBNTPSIM=libntpsim.a
    ;;
 *)
    NTPDSIM_DB=
    NTPDSIM_DL=
    NTPDSIM_DS=
    NTPDSIM_MS=
    ;;
esac

case "$build" in
 $host)
    ;;
 *) case "$host" in
     *-*-vxworks*)
	LDFLAGS="$LDFLAGS -r"
	;;
    esac
    ;;
esac

NTP_WITHSNTP

AC_MSG_CHECKING([if we want to build ntpsnmpd])
AC_ARG_WITH(
    [ntpsnmpd],
    [AS_HELP_STRING(
	[--with-ntpsnmpd],
	[s Build ntpsnmpd MIB agent?]
    )],
    [ans=$withval],
    [
	case "$PATH_NET_SNMP_CONFIG" in
	 /*)	ans=yes ;;
	 *)	ans=no  ;;
	esac
    ]
)
AC_MSG_RESULT([$ans])
case "$ans" in
 yes)
    case "$PATH_NET_SNMP_CONFIG" in
     /*)
	SNMP_LIBS=`$PATH_NET_SNMP_CONFIG --agent-libs`
	# Bug 2815.  This is a bit of a hack, but it works...
	case "$ntp_cv_net_snmp_version" in
	 5.3*)	SNMP_LIBS=`echo $SNMP_LIBS | $SED -e 's/-lnetsnmpagent/-lnetsnmpagent -lnetsnmpmibs/'`
		;;
	esac
	AC_SUBST([SNMP_LIBS])
	# HMS: we really want to separate CPPFLAGS and CFLAGS
	foo=`$PATH_NET_SNMP_CONFIG --cflags`
	SNMP_CPPFLAGS=
	SNMP_CFLAGS=
	for i in $foo; do
	    case "$i" in
	     -D*|-U*|-I*)
		SNMP_CPPFLAGS="$SNMP_CPPFLAGS $i"
		;;
	    *)	SNMP_CFLAGS="$SNMP_CFLAGS $i"
		;;
	    esac
	done
	AC_SUBST([SNMP_CPPFLAGS])
	AC_SUBST([SNMP_CFLAGS])

	save_CFLAGS=$CFLAGS
	save_CPPFLAGS=$CPPFLAGS
	save_LIBS=$LIBS
	CFLAGS=$SNMP_CFLAGS
	CPPFLAGS=$SNMP_CPPFLAGS

	AC_CHECK_HEADER(
	    [net-snmp/net-snmp-config.h],
	    [MAKE_NTPSNMPD=ntpsnmpd],
	    [AC_MSG_WARN([net-snmp-config present but net-snmp headers are not available!])]
	)

	# Do this last, as we're messing up LIBS.
	# check -lnetsnmp for netsnmp_daemonize
	LIBS=`$PATH_NET_SNMP_CONFIG --libs`
	AC_CHECK_LIB(
	    [netsnmp],
	    [netsnmp_daemonize],
	    [ans=yes],
	    [ans=no]
	)
	case "$ans" in
	 no)
	    AC_DEFINE([NEED_NETSNMP_DAEMONIZE], [1],
		[We need to provide netsnmp_daemonize()])
	esac
	
	CFLAGS=$save_CFLAGS
	AS_UNSET([save_CFLAGS])
	CPPFLAGS=$save_CPPFLAGS
	AS_UNSET([save_CPPFLAGS])
	LIBS=$save_LIBS
	AS_UNSET([save_LIBS])
	;;
     *) 
	AC_MSG_WARN([Cannot build ntpsnmpd - net-snmp-config cannot be found])
	;;
    esac
    ;;
esac
AC_SUBST([MAKE_NTPSNMPD])

case "$MAKE_NTPSNMPD" in
 '')
    NTPSNMPD_DB=
    NTPSNMPD_DL=
    NTPSNMPD_DS=
    NTPSNMPD_MS=
    ;;
esac

AC_MSG_CHECKING([if we should always slew the time])

# target-specific defaults

case "$host" in
 *-apple-aux[[23]]*)
    ans=yes
    ;;
 *-*-bsdi[[012]]*)
    ans=no
    ;;
 *-*-bsdi*)
    ans=yes
    ;;
 *-*-openvms*)	# HMS: won't be found
    ans=yes
    ;;
 *) ans=no
    ;;
esac

# --enable-slew-always / --disable-slew-always overrides default

AC_ARG_ENABLE(
    [slew-always],
    [AS_HELP_STRING(
	[--enable-slew-always],
	[s always slew the time]
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    AC_DEFINE([SLEWALWAYS], [1], [Slew always?])
esac

AC_MSG_CHECKING([if we should step and slew the time])

case "$host" in
 *-sni-sysv*)
    ans=yes
    ;;
 *-stratus-vos)
    ans=no
    ;;
 *-univel-sysv*)
    ans=no
    ;;
 *-*-ptx*)
    ans=yes
    ;;
 *-*-solaris2.1[[0-9]]*)
    ans=no
    ;;
 *-*-solaris2.[[012]]*)
    ans=yes
    ;;
 *-*-sysv4*)	# HMS: Does this catch Fujitsu UXP?
    ans=yes
    ;;
 *) ans=no
    ;;
esac

AC_ARG_ENABLE(
    [step-slew],
    [AS_HELP_STRING(
	[--enable-step-slew],
	[s step and slew the time]
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    AC_DEFINE([STEP_SLEW], [1], [Step, then slew the clock?])
esac

AC_MSG_CHECKING([if ntpdate should step the time])

case "$host" in
 *-apple-aux[[23]]*)
    ans=yes
    ;;
 *) ans=no
    ;;
esac

AC_ARG_ENABLE(
    [ntpdate-step],
    [AS_HELP_STRING(
	[--enable-ntpdate-step],
	[s if ntpdate should step the time]
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    AC_DEFINE([FORCE_NTPDATE_STEP], [1],
	[force ntpdate to step the clock if !defined(STEP_SLEW) ?])
esac


AC_MSG_CHECKING([if we should sync TODR clock every hour])

case "$host" in
 *-*-nextstep*)
    ans=yes
    ;;
 *-*-openvms*)	# HMS: won't be found
    ans=yes
    ;;
 *)
    ans=no
    ;;
esac

AC_ARG_ENABLE(
    [hourly-todr-sync],
    [AS_HELP_STRING(
	[--enable-hourly-todr-sync],
	[s if we should sync TODR hourly]
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ac_cv_var_sync_todr" in
 yes)
    AC_DEFINE([DOSYNCTODR], [1], [synch TODR hourly?]) ;;
esac


AC_MSG_CHECKING([if we should avoid kernel FLL bug])

case "$host" in
 *-*-solaris2.6)
    unamev=`uname -v`
    case "$unamev" in
     Generic_105181-*)
	old_IFS="$IFS"
	IFS="-"
	set $unamev
	IFS="$old_IFS"
	if test "$2" -ge 17
	then
	    # Generic_105181-17 and higher
	    ans=no
	else
	    ans=yes
	fi
	;;
     *)
	ans=yes
	;;
    esac
    ;;
 *-*-solaris2.7)
    unamev=`uname -v`
    case "$unamev" in
     Generic_106541-*)
	old_IFS="$IFS"
	IFS="-"
	set $unamev
	IFS="$old_IFS"
	if test "$2" -ge 07
	then
	    # Generic_106541-07 and higher
	    ans=no
	else
	    ans=yes
	fi
	;;
     *)
	ans=yes
	;;
    esac
    ;;
 *)
    ans=no
    ;;
esac

AC_ARG_ENABLE(
    [kernel-fll-bug],
    [AS_HELP_STRING(
	[--enable-kernel-fll-bug],
	[s if we should avoid a kernel FLL bug]
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    AC_DEFINE([KERNEL_FLL_BUG], [1], [Does the kernel have an FLL bug?])
esac


AC_MSG_CHECKING([if we want new session key behavior])
AC_ARG_ENABLE(
    [bug1243-fix],
    [AS_HELP_STRING(
	[--enable-bug1243-fix],
	[+ use unmodified autokey session keys]
    )],
    [ans=$enableval],
    [ans=yes]
)
AC_MSG_RESULT([$ans])
case "$ans" in
 no)
    AC_DEFINE([DISABLE_BUG1243_FIX], [1],
	[use old autokey session key behavior?])
esac


AC_MSG_CHECKING([if we want the explicit 127.0.0.0/8 martian filter])
AC_ARG_ENABLE(
    [bug3020-fix],
    [AS_HELP_STRING(
	[--enable-bug3020-fix],
	[+ Provide the explicit 127.0.0.0/8 martian filter]
    )],
    [ans=$enableval],
    [ans=yes]
)
AC_MSG_RESULT([$ans])
case "$ans" in
 yes)
    AC_DEFINE([ENABLE_BUG3020_FIX], [1],
	[Provide the explicit 127.0.0.0/8 martian filter?])
esac


AC_MSG_CHECKING([if we should use the IRIG sawtooth filter])

case "$host" in
 *-*-solaris2.[[89]])
    ans=yes
    ;;
 *-*-solaris2.1[[0-9]]*)
    ans=yes
    ;;
 *) ans=no
    ;;
esac

AC_ARG_ENABLE(
    [irig-sawtooth],
    [AS_HELP_STRING(
	[--enable-irig-sawtooth],
	[s if we should enable the IRIG sawtooth filter]
    )],
    [ans=$enableval]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    AC_DEFINE([IRIG_SUCKS], [1],
	[Should we use the IRIG sawtooth filter?])
esac

AC_MSG_CHECKING([if we should enable NIST lockclock scheme])
AC_ARG_ENABLE(
	[nist],
	[AS_HELP_STRING(
	    [--enable-nist],
	    [- if we should enable the NIST lockclock scheme]
	)],
	[ans=$enableval],
	[ans=no]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 yes)
    AC_DEFINE([LOCKCLOCK], [1],
	[Should we align with the NIST lockclock scheme?]) ;;
esac

AC_MSG_CHECKING([if we want support for Samba's signing daemon])
AC_ARG_ENABLE(
    [ntp-signd],
    [AS_HELP_STRING(
	[--enable-ntp-signd],
	[- Provide support for Samba's signing daemon, =/var/run/ntp_signd]
    )],
    [ans=$enableval],
    [ans=no]
)

AC_MSG_RESULT([$ans])

case "$ans" in
 no)
    ntp_signd_path=
    ;;
 yes)
    ntp_signd_path=/var/run/ntp_signd
    ;;
 *)
    ntp_signd_path="$ans"
esac

case "$ntp_signd_path" in
 '')
    ;;
 *)
    AC_DEFINE([HAVE_NTP_SIGND], [1],
	[Do we want support for Samba's signing daemon?])
    AC_DEFINE_UNQUOTED([NTP_SIGND_PATH], ["$ntp_signd_path"],
	[Path to sign daemon rendezvous socket])
    ;;
esac

AC_CHECK_HEADERS([libscf.h])
LSCF=
case "$ac_cv_header_libscf_h" in
 yes)
    LSCF='-lscf'
esac
AC_SUBST([LSCF])

NTP_IPV6


#
# Look for a sysctl call to get the list of network interfaces.
#
AC_CACHE_CHECK(
    [for interface list sysctl],
    [ntp_cv_iflist_sysctl],
    [AC_PREPROC_IFELSE(
	[AC_LANG_SOURCE([
	    #include <sys/param.h>
	    #include <sys/sysctl.h>
	    #include <sys/socket.h>
	    #ifndef NET_RT_IFLIST
	    # error
	    #endif
	])],
	[ntp_cv_iflist_sysctl=yes],
	[ntp_cv_iflist_sysctl=no]
    )]
)
case "$ntp_cv_iflist_sysctl" in
 yes)
    AC_DEFINE([HAVE_IFLIST_SYSCTL], [1], [have iflist_sysctl?])
esac

###

AC_MSG_CHECKING([if we want the saveconfig mechanism])
AC_ARG_ENABLE(
    [saveconfig],
    [AS_HELP_STRING(
	[--enable-saveconfig],
	[+ saveconfig mechanism]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=yes]
)
ntp_saveconfig_enabled=0
case "$ntp_ok" in
 yes)
    ntp_saveconfig_enabled=1
    AC_DEFINE([SAVECONFIG], [1], [saveconfig mechanism])
    ;;
esac
AM_CONDITIONAL([SAVECONFIG_ENABLED], [test x$ntp_saveconfig_enabled = x1])
AC_MSG_RESULT([$ntp_ok])

###

AC_MSG_CHECKING([if we want the experimental leap smear code])
AC_ARG_ENABLE(
    [leap-smear],
    [AS_HELP_STRING(
	[--enable-leap-smear],
	[- experimental leap smear code]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=no]
)
ntp_leap_smear_enabled=0
case "$ntp_ok" in
 yes)
    ntp_leap_smear_enabled=1
    AC_DEFINE([LEAP_SMEAR], [1], [leap smear mechanism])
    AC_SUBST([HAVE_LEAPSMEARINTERVAL])
    HAVE_LEAPSMEARINTERVAL="leapsmearinterval 0"
    ;;
esac
AC_MSG_RESULT([$ntp_ok])

###

AC_MSG_CHECKING([if we want dynamic interleave support])
AC_ARG_ENABLE(
    [dynamic-interleave],
    [AS_HELP_STRING(
	[--enable-dynamic-interleave],
	[- dynamic interleave support]
    )],
    [ntp_ok=$enableval],
    [ntp_ok=no]
)
ntp_dynamic_interleave=0
case "$ntp_ok" in
 yes)
    ntp_dynamic_interleave=1
    ;;
esac
AC_DEFINE_UNQUOTED([DYNAMIC_INTERLEAVE], [$ntp_dynamic_interleave],
    [support dynamic interleave?])
AC_MSG_RESULT([$ntp_ok])

NTP_UNITYBUILD

dnl  gtest is needed for our tests subdirs. It would be nice if we could
dnl  require a C++ compiler only if we will use gtest, but AC_PROG_CXX
dnl  can't be conditionalized.
NTP_GOOGLETEST

NTP_PROBLEM_TESTS

###

AC_DEFINE_DIR([NTP_KEYSDIR], [sysconfdir],
    [Default location of crypto key info])

AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([adjtimed/Makefile])
AC_CONFIG_FILES([clockstuff/Makefile])
AC_CONFIG_FILES([include/Makefile])
AC_CONFIG_FILES([include/isc/Makefile])
AC_CONFIG_FILES([kernel/Makefile])
AC_CONFIG_FILES([kernel/sys/Makefile])
AC_CONFIG_FILES([libntp/Makefile])
AC_CONFIG_FILES([libparse/Makefile])
AC_CONFIG_FILES([ntpd/Makefile])
AC_CONFIG_FILES([ntpd/complete.conf],	[sed -e '/^rlimit$/d' -e '/^$/d' < ntpd/complete.conf > ntpd/complete.conf.new && mv ntpd/complete.conf.new ntpd/complete.conf])
AC_CONFIG_FILES([ntpdate/Makefile])
AC_CONFIG_FILES([ntpdc/Makefile])
AC_CONFIG_FILES([ntpdc/nl.pl],		[chmod +x ntpdc/nl.pl])
AC_CONFIG_FILES([ntpq/Makefile])
AC_CONFIG_FILES([ntpsnmpd/Makefile])
AC_CONFIG_FILES([parseutil/Makefile])
AC_CONFIG_FILES([scripts/Makefile])
AC_CONFIG_FILES([scripts/build/Makefile])
AC_CONFIG_FILES([scripts/build/genAuthors],	[chmod +x scripts/build/genAuthors])
AC_CONFIG_FILES([scripts/build/mkver],	[chmod +x scripts/build/mkver])
AC_CONFIG_FILES([scripts/calc_tickadj/Makefile])
AC_CONFIG_FILES([scripts/calc_tickadj/calc_tickadj], [chmod +x scripts/calc_tickadj/calc_tickadj])
AC_CONFIG_FILES([scripts/lib/Makefile])
AC_CONFIG_FILES([scripts/ntp-wait/Makefile])
AC_CONFIG_FILES([scripts/ntp-wait/ntp-wait],	[chmod +x scripts/ntp-wait/ntp-wait])
AC_CONFIG_FILES([scripts/ntpsweep/Makefile])
AC_CONFIG_FILES([scripts/ntpsweep/ntpsweep],	[chmod +x scripts/ntpsweep/ntpsweep])
AC_CONFIG_FILES([scripts/ntptrace/Makefile])
AC_CONFIG_FILES([scripts/ntptrace/ntptrace],	[chmod +x scripts/ntptrace/ntptrace])
AC_CONFIG_FILES([scripts/ntpver],	[chmod +x scripts/ntpver])
AC_CONFIG_FILES([scripts/plot_summary],	[chmod +x scripts/plot_summary])
AC_CONFIG_FILES([scripts/summary],	[chmod +x scripts/summary])
AC_CONFIG_FILES([scripts/update-leap/Makefile])
AC_CONFIG_FILES([scripts/update-leap/update-leap], [chmod +x scripts/update-leap/update-leap])
AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([tests/bug-2803/Makefile])
AC_CONFIG_FILES([tests/libntp/Makefile])
AC_CONFIG_FILES([tests/ntpd/Makefile])
AC_CONFIG_FILES([tests/ntpq/Makefile])
AC_CONFIG_FILES([tests/sandbox/Makefile])
AC_CONFIG_FILES([tests/sec-2853/Makefile])
AC_CONFIG_FILES([util/Makefile])

perllibdir="${datadir}/ntp/lib"
AC_DEFINE_DIR([PERLLIBDIR], [perllibdir], [data dir])

calc_tickadj_opts="$srcdir/scripts/calc_tickadj/calc_tickadj-opts"
AC_SUBST_FILE([calc_tickadj_opts])
ntp_wait_opts="$srcdir/scripts/ntp-wait/ntp-wait-opts"
AC_SUBST_FILE([ntp_wait_opts])
ntpsweep_opts="$srcdir/scripts/ntpsweep/ntpsweep-opts"
AC_SUBST_FILE([ntpsweep_opts])
ntptrace_opts="$srcdir/scripts/ntptrace/ntptrace-opts"
AC_SUBST_FILE([ntptrace_opts])
summary_opts="$srcdir/scripts/summary-opts"
AC_SUBST_FILE([summary_opts])
plot_summary_opts="$srcdir/scripts/plot_summary-opts"
AC_SUBST_FILE([plot_summary_opts])

AC_CONFIG_SUBDIRS([sntp])

AC_OUTPUT
OpenPOWER on IntegriCloud