File: configure.ac

package info (click to toggle)
netcdf-parallel 1%3A4.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 113,164 kB
  • sloc: ansic: 267,893; sh: 12,869; cpp: 5,822; yacc: 2,613; makefile: 1,813; lex: 1,216; xml: 173; awk: 2
file content (2092 lines) | stat: -rw-r--r-- 82,182 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
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
#                                               -*- Autoconf -*-
## Process this file with autoconf to produce a configure script.

# This is part of Unidata's netCDF package. Copyright 2005-2018, see
# the COPYRIGHT file for more information.
# Ed Hartnett, Ward Fisher, Dennis Heimbigner

# Running autoconf on this file will trigger a warning if
# autoconf is not at least the specified version.
AC_PREREQ([2.59])

# Initialize with name, version, and support email address.
AC_INIT([netCDF],[4.9.0],[support-netcdf@unidata.ucar.edu],[netcdf-c])

##
# Prefer an empty CFLAGS variable instead of the default -g -O2.
# See:
#   * http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/C-Compiler.html#C-Compiler
##
: ${CFLAGS=""}

AC_SUBST([NC_VERSION_MAJOR]) NC_VERSION_MAJOR=4
AC_SUBST([NC_VERSION_MINOR]) NC_VERSION_MINOR=9
AC_SUBST([NC_VERSION_PATCH]) NC_VERSION_PATCH=0
AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE=""

##
# These linker flags specify libtool version info.
# See http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
# for information regarding incrementing `-version-info`.
# These values should match those in CMakeLists.txt
AC_SUBST([netCDF_SO_VERSION]) netCDF_SO_VERSION=20:0:1

#####
# Set some variables used to generate a libnetcdf.settings file,
# pattered after the files generated by libhdf4, libhdf5.
#####

# Create the VERSION file, which contains the package version from
# AC_INIT.
echo AC_PACKAGE_VERSION>VERSION
AC_SUBST(PACKAGE_VERSION)

AC_MSG_NOTICE([netCDF AC_PACKAGE_VERSION])

# Keep libtool macros in an m4 directory.
AC_CONFIG_MACRO_DIR([m4])

# Configuration Date
if test "x$SOURCE_DATE_EPOCH" != "x" ; then
    AC_SUBST([CONFIG_DATE]) CONFIG_DATE="`date -u -d "${SOURCE_DATE_EPOCH}"`"
else
    AC_SUBST([CONFIG_DATE]) CONFIG_DATE="`date`"
fi

# Find out about the host we're building on.
AC_CANONICAL_HOST

# Find out about the target we're building for.
AC_CANONICAL_TARGET

AC_CONFIG_HEADERS([config.h])


##
# Check to see if the compiler supports -fno-strict-aliasing and, if so,
# add that to the C compiler flags.  This is in support of https://github.com/Unidata/netcdf-c/issues/1983.
##
SAVE_CFLAGS="${CFLAGS}"
AC_LANG_PUSH([C])
AC_LANG_COMPILER_REQUIRE
CFLAGS="${CFLAGS} -fno-strict-aliasing"

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
        [int i = 0;]])],
        [have_no_strict_aliasing=yes],
        [have_no_strict_aliasing=no])
AC_MSG_CHECKING([whether compiler supports -fno-strict-aliasing])
AC_MSG_RESULT([$have_no_strict_aliasing])
AC_LANG_POP([C])
if test $have_no_strict_aliasing = no; then
   CFLAGS=$SAVE_CFLAGS
fi
##
# Some files need to exist in build directories
# that do not correspond to their source directory, or
# the test program makes an assumption about where files
# live.  AC_CONFIG_LINKS provides a mechanism to link/copy files
# if an out-of-source build is happening.
##

AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat1.nc:nc_test4/ref_hdf5_compat1.nc])
AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat2.nc:nc_test4/ref_hdf5_compat2.nc])
AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat3.nc:nc_test4/ref_hdf5_compat3.nc])

AC_CONFIG_LINKS([hdf4_test/ref_chunked.hdf4:hdf4_test/ref_chunked.hdf4])
AC_CONFIG_LINKS([hdf4_test/ref_contiguous.hdf4:hdf4_test/ref_contiguous.hdf4])
AC_CONFIG_LINKS([dap4_test/baselinethredds/GOES16_CONUS_20170821_020218_0.47_1km_33.3N_91.4W.nc4.thredds:dap4_test/baselinethredds/GOES16_TEST1.nc4.thredds])

AM_INIT_AUTOMAKE([foreign dist-zip subdir-objects])
AM_MAINTAINER_MODE()

# Check for the existence of this file before proceeding.
AC_CONFIG_SRCDIR([include/netcdf.h])

# Figure out platforms of special interest
case "`uname`" in
  CYGWIN*) ISCYGWIN=yes;;
  Darwin*) ISOSX=yes;;
  WIN*) ISMSVC=yes;;
  MINGW*) ISMINGW=yes;;
esac

if test "x$MSYSTEM" != x ; then
ISMINGW=yes
ISMSYS=yes
fi

# Get windows version info
WINVER=`systeminfo | sed -e '/^OS Version:/p' -ed | sed -e 's|[^0-9]*\([0-9.]*\).*|\1|'`
WINVERMAJOR=`echo $WVER | sed -e 's|\([^.]*\)[.]\([^.]*\)[.]\(.*\)|\1|'`
WINVERBUILD=`echo $WVER | sed -e 's|\([^.]*\)[.]\([^.]*\)[.]\(.*\)|\3|'`
if test "x$WINVERMAJOR" = x ; then WINVERMAJOR=0; fi
if test "x$WINVERBUILD" = x ; then WINVERBUILD=0; fi
AC_DEFINE_UNQUOTED([WINVERMAJOR], [$WINVERMAJOR], [windows version major])
AC_DEFINE_UNQUOTED([WINVERBUILD], [$WINVERBUILD], [windows version build])

AC_MSG_NOTICE([checking supported formats])

# An explicit disable of netcdf-4 | netcdf4 is treated as if it was disable-hdf5
AC_MSG_CHECKING([whether we should build with netcdf4 (alias for HDF5)])
AC_ARG_ENABLE([netcdf4], [AS_HELP_STRING([--disable-netcdf4],
              [(deprecated synonym for --enable-hdf5)])])
test "x$enable_netcdf4" = xno || enable_netcdf4=yes
AC_MSG_RESULT([$enable_netcdf4 (deprecated; Please use with --disable-hdf5)])
AC_MSG_CHECKING([whether we should build with netcdf-4 (alias for HDF5)])
AC_ARG_ENABLE([netcdf-4], [AS_HELP_STRING([--disable-netcdf-4],
              [(synonym for --disable-netcdf4)])])
test "x$enable_netcdf_4" = xno || enable_netcdf_4=yes
AC_MSG_RESULT([$enable_netcdf_4])
# Propagate the alias
if test "x$enable_netcdf_4" = xno ; then enable_netcdf4=no; fi
if test "x$enable_netcdf4" = xno ; then enable_netcdf_4=no; fi

# Does the user want to use HDF5?
AC_MSG_CHECKING([whether we should build with HDF5])
AC_ARG_ENABLE([hdf5], [AS_HELP_STRING([--disable-hdf5],
              [do not build with HDF5])])
test "x$enable_hdf5" = xno || enable_hdf5=yes
if test "x$enable_netcdf4" = xno ; then enable_hdf5=no ; fi
# disable-netcdf4 is synonym for disable-hdf5
AC_MSG_RESULT([$enable_hdf5])

# Check whether we want to enable CDF5 support.
AC_MSG_CHECKING([whether CDF5 support should be disabled])
AC_ARG_ENABLE([cdf5],
              [AS_HELP_STRING([--disable-cdf5],
                              [build without CDF5 support. @<:@default: auto@:>@])],
              [enable_cdf5=${enableval}], [enable_cdf5=auto]
)
AC_MSG_RESULT($enable_cdf5)

# Does the user want to turn on HDF4 read ability?
AC_MSG_CHECKING([whether reading of HDF4 SD files is to be enabled])
AC_ARG_ENABLE([hdf4], [AS_HELP_STRING([--enable-hdf4],
              [build netcdf with HDF4 read capability (HDF4, HDF5 and zlib required)])])
test "x$enable_hdf4" = xyes || enable_hdf4=no
AC_MSG_RESULT($enable_hdf4)

AC_MSG_CHECKING([whether parallel I/O for classic files is to be enabled])
AC_ARG_ENABLE([pnetcdf], [AS_HELP_STRING([--enable-pnetcdf],
              [build with parallel I/O for classic files. @<:@default: disabled@:>@])])
test "x$enable_pnetcdf" = xyes || enable_pnetcdf=no
AC_MSG_RESULT($enable_pnetcdf)

# We need curl for remote operations
AC_CHECK_LIB([curl],[curl_easy_setopt],[found_curl=yes],[found_curl=no])
if test "x$found_curl" = "xyes" ; then
   AC_SEARCH_LIBS([curl_easy_setopt],[curl curl.dll cygcurl.dll], [],[])
fi

## Capture the state of the --enable-dap flag => enable dap2+dap4
AC_MSG_CHECKING([whether DAP client(s) are to be built])
AC_ARG_ENABLE([dap],
                 [AS_HELP_STRING([--disable-dap],
                                 [build without DAP client support.])])
test "x$enable_dap" = xno || enable_dap=yes
AC_MSG_RESULT($enable_dap)

if test "x$enable_dap" = xyes & test "x$found_curl" = xno ; then
  AC_MSG_WARN([curl required for dap access. DAP support disabled.])
  enable_dap=no
fi

AC_MSG_CHECKING([whether netcdf zarr storage format should be disabled])
AC_ARG_ENABLE([nczarr],
              [AS_HELP_STRING([--disable-nczarr],
                              [disable netcdf zarr storage support])])
test "x$enable_nczarr" = xno || enable_nczarr=yes
AC_MSG_RESULT($enable_nczarr)

# HDF5 | HDF4 | NCZarr => netcdf-4
if test "x$enable_hdf5" = xyes || test "x$enable_hdf4" = xyes || test "x$enable_nczarr" = xyes ; then
enable_netcdf_4=yes
fi
AC_MSG_CHECKING([whether netcdf-4 should be forcibly enabled])
AC_MSG_RESULT([$enable_netcdf_4])
# Synonym
enable_netcdf4=${enable_netcdf_4}

AC_MSG_NOTICE([checking user options])

# Did the user specify a default minimum blocksize (NCIO_MINBLOCKSIZE) for posixio?
AC_MSG_CHECKING([whether a NCIO_MINBLOCKSIZE was specified])
AC_ARG_WITH([minblocksize],
              [AS_HELP_STRING([--with-minblocksize=<integer>],
                              [Specify minimum I/O blocksize for netCDF classic and 64-bit offset format files.])],
            [NCIO_MINBLOCKSIZE=$with_minblocksize], [NCIO_MINBLOCKSIZE=256])
AC_MSG_RESULT([$NCIO_MINBLOCKSIZE])
AC_DEFINE_UNQUOTED([NCIO_MINBLOCKSIZE], [$NCIO_MINBLOCKSIZE], [min blocksize for posixio.])

# Find valgrind, if available, and add targets for it.
AX_VALGRIND_DFLT([sgcheck], [off])
AX_VALGRIND_CHECK
AM_CONDITIONAL(ENABLE_VALGRIND, [test "x$VALGRIND_ENABLED" = xyes])

###
# Doxygen and doxygen-related options.
###
AC_ARG_ENABLE([doxygen],
  [AS_HELP_STRING([--enable-doxygen],
    [Enable generation of documentation.])])
test "x$enable_doxygen" = xyes || enable_doxygen=no
AM_CONDITIONAL([BUILD_DOCS], [test "x$enable_doxygen" = xyes])

AC_ARG_ENABLE([doxygen-tasks],
    [AS_HELP_STRING([--enable-doxygen-tasks],
        [Enable Doxygen-generated test, todo and bug list documentation. Developers only.])])
test "x$enable_doxygen_tasks" = xyes || enable_doxygen_tasks=no
AM_CONDITIONAL([SHOW_DOXYGEN_TAG_LIST], [test "x$enable_doxygen_tasks" = xyes])
AC_SUBST([SHOW_DOXYGEN_TAG_LIST], [$enable_doxygen_tasks])

###
# Determine if we should build documentation
# configured for releases on the Unidata web server.
###
AC_ARG_ENABLE([doxygen-build-release-docs],
    [AS_HELP_STRING([--enable-doxygen-build-release-docs],
        [Build release documentation.  This is of interest only to developers.])])
test "x$enable_doxygen_build_release_docs" = xyes || enable_doxygen_build_release_docs=no
AM_CONDITIONAL([DOXYGEN_BUILD_RELEASE_DOCS], [test "x$enable_doxygen_build_release_docs" = xyes])

if test $enable_doxygen_build_release_docs = yes; then
   AC_SUBST([DOXYGEN_CSS_FILE], ["release.css"])
   AC_SUBST([DOXYGEN_HEADER_FILE], ["release_header.html"])
   AC_SUBST([DOXYGEN_SEARCHENGINE], ["NO"])
else
   AC_SUBST([DOXYGEN_CSS_FILE], [])
   AC_SUBST([DOXYGEN_HEADER_FILE], [])
   AC_SUBST([DOXYGEN_SEARCHENGINE], ["YES"])
fi
AC_SUBST([DOXYGEN_SERVER_BASED_SEARCH], ["NO"])

AC_ARG_ENABLE([doxygen-pdf-output],
    [AS_HELP_STRING([--enable-doxygen-pdf-output],
        [Build netCDF library documentation in PDF format. Experimental.])])
               AM_CONDITIONAL([NC_ENABLE_DOXYGEN_PDF_OUTPUT], [test "x$enable_doxygen_pdf_output" = xyes])
AC_SUBST([NC_ENABLE_DOXYGEN_PDF_OUTPUT], [$enable_doxygen_pdf_output])

AC_ARG_ENABLE([dot],
	[AS_HELP_STRING([--enable-dot],
	[Use dot (provided by graphviz) to generate charts and graphs in the doxygen-based documentation.])])
	test "x$enable_dot" = xyes || enable_dot=no

AC_ARG_ENABLE([internal-docs],
  [AS_HELP_STRING([--enable-internal-docs],
    [Include documentation of library internals. This is of interest only to those developing the netCDF library.])])
test "x$enable_internal_docs" = xyes || enable_internal_docs=no
AC_SUBST([BUILD_INTERNAL_DOCS], [$enable_internal_docs])

# Doxygen is apparently buggy when trying to combine a markdown
# file with @internal. The equivalent can be faked using
# the Doxygen ENABLED_SECTIONS mechanism. See docs/testserver.dox
# to see how this is done.
sections=
if test "x$enable_internal_docs" = xyes ; then
sections="$sections INTERNAL"
fi
AC_SUBST([ENABLED_DOC_SECTIONS], [$sections])

AC_MSG_CHECKING([if fsync support is enabled])
AC_ARG_ENABLE([fsync],
              [AS_HELP_STRING([--enable-fsync],
                              [enable fsync support])],
				[],
				[enable_fsync=no])
test "x$enable_fsync" = xno || enable_fsync=yes
AC_MSG_RESULT($enable_fsync)
if test "x$enable_fsync" = xyes ; then
AC_DEFINE([USE_FSYNC], [1], [if true, include experimental fsync code])
fi

# Temporary until JNA bug is fixed (which is probably never).
# The problem being solved is this:
# > On Windows using the microsoft runtime, it is an error
# > for one library to free memory allocated by a different library.
# This is probably only an issue when using the netcdf-c library
# via JNA under Java.
AC_MSG_CHECKING([if jna bug workaround is enabled])
AC_ARG_ENABLE([jna],
              [AS_HELP_STRING([--enable-jna],
                              [enable jna bug workaround])],
				[],
				[enable_jna=no])
test "x$enable_jna" = xno || enable_jna=yes
AC_MSG_RESULT($enable_jna)
if test "x$enable_jna" = xyes ; then
AC_DEFINE([JNA], [1], [if true, include jna bug workaround code])
fi

# Does the user want to turn off unit tests (useful for test coverage
# analysis).
AC_MSG_CHECKING([if unit tests should be disabled])
AC_ARG_ENABLE([unit-tests],
  [AS_HELP_STRING([--disable-unit-tests],
    [Disable tests in unit_test directory. Other tests still run.])])
test "x$enable_unit_tests" = xno || enable_unit_tests=yes
AC_MSG_RESULT($enable_unit_tests)
AM_CONDITIONAL([BUILD_UNIT_TESTS], [test "x$enable_unit_tests" = xyes])

# Does the user require dynamic loading?
# This is only for those hdf5 installs that support it.
AC_MSG_CHECKING([do we require hdf5 dynamic-loading support])
AC_ARG_ENABLE([dynamic-loading], [AS_HELP_STRING([--enable-dynamic-loading],
				 [enable dynamic loading for use with supported hdf5 installs (libdl, HDF5 required)])])
test "x$enable_dynamic_loading" = xno || enable_dynamic_loading=yes
AC_MSG_RESULT([$enable_dynamic_loading])


# Does the user want to turn on extra HDF4 file tests?
AC_MSG_CHECKING([whether to fetch some sample HDF4 files from Unidata ftp site to test HDF4 reading (requires wget)])
AC_ARG_ENABLE([hdf4-file-tests], [AS_HELP_STRING([--enable-hdf4-file-tests],
              [get some HDF4 files from Unidata ftp site and test that they can be read])])
test "x$enable_hdf4" = xyes -a "x$enable_hdf4_file_tests" = xyes || enable_hdf4_file_tests=no
if test "x$enable_hdf4_file_tests" = xyes; then
   AC_DEFINE([USE_HDF4_FILE_TESTS], 1, [If true, use use wget to fetch some sample HDF4 data, and then test against it.])
fi
AC_MSG_RESULT($enable_hdf4_file_tests)

# Does the user want to try to install netcdf-fortran
# automatically?
AC_MSG_CHECKING([whether we should attempt to install netcdf-fortran (EXPERIMENTAL)])
AC_ARG_ENABLE([remote-fortran-bootstrap], [AS_HELP_STRING([--enable-remote-fortran-bootstrap],
			 [Download and install netcdf-fortran (EXPERIMENTAL)])])
test "x$enable_remote_fortran_bootstrap" = xyes || enable_remote_fortran_bootstrap=no
AC_MSG_RESULT([$enable_remote_fortran_bootstrap])

# Does the user want to run extra parallel tests when parallel netCDF-4 is built?
AC_MSG_CHECKING([whether parallel IO tests should be run])
AC_ARG_ENABLE([parallel-tests],
              [AS_HELP_STRING([--enable-parallel-tests],
                              [Run extra parallel IO tests. Requires netCDF-4
                              with parallel I/O support.])])
test "x$enable_parallel_tests" = xyes || enable_parallel_tests=no
AC_MSG_RESULT($enable_parallel_tests)

# Did the user specify an MPI launcher other than mpiexec?
AC_MSG_CHECKING([whether a user specified program to run mpi programs])
AC_ARG_WITH([mpiexec],
              [AS_HELP_STRING([--with-mpiexec=<command>],
                              [Specify command to launch MPI parallel tests.])],
            [MPIEXEC=$with_mpiexec], [MPIEXEC=mpiexec])
AC_MSG_RESULT([$MPIEXEC])
AC_SUBST([MPIEXEC], [$MPIEXEC])

# Did the user specify a default chunk size?
AC_MSG_CHECKING([whether a default chunk size in bytes was specified])
AC_ARG_WITH([default-chunk-size],
              [AS_HELP_STRING([--with-default-chunk-size=<integer>],
                              [Specify default size of chunks in bytes.])],
            [DEFAULT_CHUNK_SIZE=$with_default_chunk_size], [DEFAULT_CHUNK_SIZE=4194304])
AC_MSG_RESULT([$DEFAULT_CHUNK_SIZE])
AC_DEFINE_UNQUOTED([DEFAULT_CHUNK_SIZE], [$DEFAULT_CHUNK_SIZE], [default chunk size in bytes])

# Did the user specify a max per-var cache size?
AC_MSG_CHECKING([whether a maximum per-variable cache size for HDF5 was specified])
AC_ARG_WITH([max-default-cache-size],
              [AS_HELP_STRING([--with-max-default-cache-size=<integer>],
                              [Specify maximum size (in bytes) for the default per-var chunk cache.])],
            [MAX_DEFAULT_CACHE_SIZE=$with_max_default_cache_size], [MAX_DEFAULT_CACHE_SIZE=67108864])
AC_MSG_RESULT([$MAX_DEFAULT_CACHE_SIZE])
AC_DEFINE_UNQUOTED([MAX_DEFAULT_CACHE_SIZE], [$MAX_DEFAULT_CACHE_SIZE], [max size of the default per-var chunk cache.])

# Did the user specify a number of chunks in default per-var cache size?
AC_MSG_CHECKING([whether a number of chunks for the default per-variable cache was specified])
AC_ARG_WITH([default-chunks-in-cache],
              [AS_HELP_STRING([--with-default-chunks-in-cache=<integer>],
                              [Specify the number of chunks to store in default per-variable cache.])],
            [DEFAULT_CHUNKS_IN_CACHE=$with_default_chunks_in_cache], [DEFAULT_CHUNKS_IN_CACHE=10])
AC_MSG_RESULT([$DEFAULT_CHUNKS_IN_CACHE])
AC_DEFINE_UNQUOTED([DEFAULT_CHUNKS_IN_CACHE], [$DEFAULT_CHUNKS_IN_CACHE], [num chunks in default per-var chunk cache.])

# Did the user specify a default cache size for HDF5?
AC_MSG_CHECKING([whether a default file cache size for HDF5 was specified])
AC_ARG_WITH([chunk-cache-size],
              [AS_HELP_STRING([--with-chunk-cache-size=<integer>],
                              [Specify default file cache chunk size for HDF5 files in bytes.])],
            [CHUNK_CACHE_SIZE=$with_chunk_cache_size], [CHUNK_CACHE_SIZE=16777216])
AC_MSG_RESULT([$CHUNK_CACHE_SIZE])
AC_DEFINE_UNQUOTED([CHUNK_CACHE_SIZE], [$CHUNK_CACHE_SIZE], [default file chunk cache size in bytes.])

# Did the user specify a default cache nelems?
AC_MSG_CHECKING([whether a default file cache maximum number of elements for HDF5 was specified])
AC_ARG_WITH([chunk-cache-nelems],
              [AS_HELP_STRING([--with-chunk-cache-nelems=<integer>],
                              [Specify default maximum number of elements in the file chunk cache chunk for HDF5 files (should be prime number).])],
            [CHUNK_CACHE_NELEMS=$with_chunk_cache_nelems], [CHUNK_CACHE_NELEMS=4133])
AC_MSG_RESULT([$CHUNK_CACHE_NELEMS])
AC_DEFINE_UNQUOTED([CHUNK_CACHE_NELEMS], [$CHUNK_CACHE_NELEMS], [default file chunk cache nelems.])

# Did the user specify a default cache preemption?
AC_MSG_CHECKING([whether a default cache preemption for HDF5 was specified])
AC_ARG_WITH([chunk-cache-preemption],
              [AS_HELP_STRING([--with-chunk-cache-preemption=<float between 0 and 1 inclusive>],
                              [Specify default file chunk cache preemption policy for HDF5 files (a number between 0 and 1, inclusive).])],
            [CHUNK_CACHE_PREEMPTION=$with_chunk_cache_preemption], [CHUNK_CACHE_PREEMPTION=0.75])
AC_MSG_RESULT([$CHUNK_CACHE_PREEMPTION])
AC_DEFINE_UNQUOTED([CHUNK_CACHE_PREEMPTION], [$CHUNK_CACHE_PREEMPTION], [default file chunk cache preemption policy.])

# Does the user want to enable netcdf-4 logging?
AC_MSG_CHECKING([whether netCDF-4 logging is enabled])
AC_ARG_ENABLE([logging],
              [AS_HELP_STRING([--enable-logging],
                              [enable logging capability (only applies when netCDF-4 is built). \
			      This debugging features is only of interest to netCDF developers. \
			      Ignored if netCDF-4 is not enabled.])])
test "x$enable_logging" = xyes || enable_logging=no
AC_MSG_RESULT([$enable_logging])

# Does the user want to turn off nc_set_log_level() function? (It will
# always be defined if --enable-logging is used.)
AC_MSG_CHECKING([whether nc_set_log_level() function is included (will do nothing unless enable-logging is also used)])
AC_ARG_ENABLE([set_log_level_func], [AS_HELP_STRING([--disable-set-log-level-func],
              [disable the nc_set_log_level function])])
test "x$enable_set_log_level_func" = xno -a "x$enable_logging" = xno || enable_set_log_level_func=yes
if test "x$enable_set_log_level_func" = xyes -a "x$enable_netcdf_4" = xyes; then
   AC_DEFINE([ENABLE_SET_LOG_LEVEL], 1, [If true, define nc_set_log_level.])
fi
AC_MSG_RESULT($enable_set_log_level_func)


# CURLOPT_USERNAME is not defined until curl version 7.19.1
# CURLOPT_PASSWORD is not defined until curl version 7.19.1
# CURLOPT_KEYPASSWD is not defined until curl version 7.16.4
# CURLINFO_RESPONSE_CODE is not defined until curl version 7.10.7
# CURLOPT_CHUNK_BGN_FUNCTION is not defined until curl version 7.21.0
# CURL_MAX_READ_SIZE is not defined until 7.59

# Save/restore CFLAGS
SAVECFLAGS="$CFLAGS"
CFLAGS="${curl_cflags}"

AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include "curl/curl.h"],
[[int x = CURLOPT_USERNAME;]])],
                   [haveusername=yes],
                   [haveusername=no])
AC_MSG_CHECKING([whether CURLOPT_USERNAME is defined])
AC_MSG_RESULT([${haveusername}])
if test $haveusername = yes; then
  AC_DEFINE([HAVE_CURLOPT_USERNAME],[1],[Is CURLOPT_USERNAME defined])
fi

AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include "curl/curl.h"],
[[int x = CURLOPT_PASSWORD;]])],
                   [havepassword=yes],
                   [havepassword=no])
AC_MSG_CHECKING([whether CURLOPT_PASSWORD is defined])
AC_MSG_RESULT([${havepassword}])
if test $havepassword = yes; then
  AC_DEFINE([HAVE_CURLOPT_PASSWORD],[1],[Is CURLOPT_PASSWORD defined])
fi

AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include "curl/curl.h"],
[[int x = CURLOPT_KEYPASSWD;]])],
                   [havekeypassword=yes],
                   [havekeypassword=no])
AC_MSG_CHECKING([whether CURLOPT_KEYPASSWD is defined])
AC_MSG_RESULT([${havekeypassword}])
if test $havekeypassword = yes; then
  AC_DEFINE([HAVE_CURLOPT_KEYPASSWD],[1],[Is CURLOPT_KEYPASSWD defined])
fi

AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include "curl/curl.h"],
[[int x = CURLINFO_RESPONSE_CODE;]])],
                   [haveresponsecode=yes],
                   [haveresponsecode=no])
AC_MSG_CHECKING([whether CURLINFO_RESPONSE_CODE is defined])
AC_MSG_RESULT([${haveresponsecode}])
if test $haveresponsecode = yes; then
  AC_DEFINE([HAVE_CURLINFO_RESPONSE_CODE],[1],[Is CURLINFO_RESPONSE_CODE defined])
fi

AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include "curl/curl.h"],
[[int x = CURLOPT_BUFFERSIZE;]])],
                   [havecurloption=yes],
                   [havecurloption=no])
AC_MSG_CHECKING([whether CURLOPT_BUFFERSIZE is defined])
AC_MSG_RESULT([${havecurloption}])
if test $havecurloption = yes; then
  AC_DEFINE([HAVE_CURLOPT_BUFFERSIZE],[1],[Is CURLOPT_BUFFERSIZE defined])
fi

AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include "curl/curl.h"],
[[int x = CURLOPT_TCP_KEEPALIVE;]])],
                   [havecurloption=yes],
                   [havecurloption=no])
AC_MSG_CHECKING([whether CURLOPT_TCP_KEEPALIVE is defined])
AC_MSG_RESULT([${havecurloption}])
if test $havecurloption = yes; then
  AC_DEFINE([HAVE_CURLOPT_KEEPALIVE],[1],[Is CURLOPT_TCP_KEEPALIVE defined])
fi
# CURLOPT_VERIFYHOST semantics differ depending on version
AC_MSG_CHECKING([whether libcurl is version 7.66 or later?])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include "curl/curl.h"],
[[
#if LIBCURL_VERSION_NUM < 0x074200
error "<7.66";
#endif
]])], [libcurl766=yes], [libcurl766=no])

AC_MSG_RESULT([$libcurl766])
if test x$libcurl66 = xno; then
  AC_DEFINE([HAVE_LIBCURL_766],[1],[Is libcurl version 7.66 or later])
fi

CFLAGS="$SAVECFLAGS"

###
# Libxml2 control block.
###

AC_MSG_CHECKING([whether to search for and use external libxml2])
AC_ARG_ENABLE([libxml2],
              [AS_HELP_STRING([--disable-libxml2],
                              [disable detection and use of libxml2 in favor of the bundled ezxml interpreter])])
test "x$enable_libxml2" = xno || enable_libxml2=yes
AC_MSG_RESULT([$enable_libxml2])

have_libxml2=no
if test "x$enable_libxml2" = xyes; then
  # We can optionally use libxml2 for DAP4, if available
  AC_CHECK_LIB([xml2],[xmlReadMemory],[have_libxml2=yes],[have_libxml2=no])
  if test "x$have_libxml2" = "xyes" ; then
      AC_SEARCH_LIBS([xmlReadMemory],[xml2 xml2.dll cygxml2.dll], [],[])
  fi
  if test "x$have_libxml2" = xyes; then
     XML2FLAGS=`xml2-config --cflags`
     AC_SUBST([XML2FLAGS],${XML2FLAGS})
     AC_DEFINE([HAVE_LIBXML2], [1], [if true, use libxml2])
  fi
fi

if test "x$enable_libxml2" = xyes; then
XMLPARSER="libxml2"
else
XMLPARSER="tinyxml2 (bundled)"
fi

# Need a condition and subst for this
AM_CONDITIONAL(ENABLE_LIBXML2, [test "x$enable_libxml2" = xyes])
AC_SUBST([XMLPARSER],[${XMLPARSER}])

###
# End Libxml2 block
###

# --enable-dap => enable-dap4
enable_dap4=$enable_dap
AC_MSG_CHECKING([whether dap remote testing should be enabled])
AC_ARG_ENABLE([dap-remote-tests],
              [AS_HELP_STRING([--enable-dap-remote-tests],
                                 [enable dap remote tests])])
test "x$enable_dap_remote_tests" = xno || enable_dap_remote_tests=yes
if test "x$enable_dap" = "xno" ; then
  enable_dap_remote_tests=no
fi
AC_MSG_RESULT($enable_dap_remote_tests)

# Default is not to do the remote authorization tests.
AC_MSG_CHECKING([whether dap remote authorization testing should be enabled (default off)])
AC_ARG_ENABLE([dap-auth-tests],
              [AS_HELP_STRING([--enable-dap-auth-tests],
                                 [enable dap remote authorization tests])])
test "x$enable_dap_auth_tests" = xyes || enable_dap_auth_tests=no
# dap must be enabled
if test "x$enable_dap" = "xno" ; then
  enable_dap_auth_tests=no
fi
# if remote tests are disabled, then so is this
if test "x$enable_dap_remote_tests" = "xno" ; then
  enable_dap_remote_tests=no
fi
AC_MSG_RESULT($enable_dap_auth_tests)

# Did the user specify a list of test servers to try for remote tests?
AC_MSG_CHECKING([which remote test server(s) to use])
AC_ARG_WITH([testservers],
              [AS_HELP_STRING([--with-testservers=<host:port>,<host:port>...],
                              [Specify the testserver(s) to try for remote tests.])],
            [REMOTETESTSERVERS=$with_testservers], [REMOTETESTSERVERS=no])
msg="$REMOTETESTSERVERS"
if test "x$REMOTETESTSERVERS" = xno ; then
  svclist="remotetest.unidata.ucar.edu"
  REMOTETESTSERVERS="$svclist"
fi
AC_MSG_RESULT([$svclist])
AC_DEFINE_UNQUOTED([REMOTETESTSERVERS], ["$REMOTETESTSERVERS"], [the testservers for remote tests.])

# Set the config.h flags
if test "x$enable_dap" = xyes; then
   AC_DEFINE([USE_DAP], [1], [if true, build DAP Client])
   AC_DEFINE([ENABLE_DAP], [1], [if true, build DAP Client])
fi

if test "x$enable_dap_remote_tests" = xyes; then
   AC_DEFINE([ENABLE_DAP_REMOTE_TESTS], [1], [if true, do remote tests])
fi

AC_MSG_CHECKING([whether the time-consuming dap tests should be enabled (default off)])
AC_ARG_ENABLE([dap-long-tests],
              [AS_HELP_STRING([--enable-dap-long-tests],
                                 [enable dap long tests])])
test "x$enable_dap_long_tests" = xyes || enable_dap_long_tests=no
if test "x$enable_dap_remote_tests" = "xno" ; then
  enable_dap_long_tests=no
fi
AC_MSG_RESULT([$enable_dap_long_tests])

# Control zarr storage
if test "x$enable_nczarr" = xyes ; then
  if test "x$enable_netcdf_4" = xno ; then
    AC_MSG_WARN([netCDF-4 disabled, so you must not enable nczarr])
    enable_nczarr=no
  fi
fi

if test "x$enable_nczarr" = xyes; then
   AC_DEFINE([ENABLE_NCZARR], [1], [if true, build NCZarr Client])
   AC_SUBST(ENABLE_NCZARR)
fi
AM_CONDITIONAL(ENABLE_NCZARR, [test x$enable_nczarr = xyes])

##########
# Look for Standardized libraries
##########

# See if we have libblosc
AC_CHECK_LIB([blosc],[blosc_init],[have_blosc=yes],[have_blosc=no])
if test "x$have_blosc" = "xyes" ; then
   AC_SEARCH_LIBS([blosc_init],[blosc blosc.dll cygblosc.dll], [], [])
   AC_DEFINE([HAVE_BLOSC], [1], [if true, blosc library is available])
fi

# See if we have libzstd
AC_CHECK_LIB([zstd],[ZSTD_compress],[have_zstd=yes],[have_zstd=no])
if test "x$have_zstd" = "xyes" ; then
   AC_SEARCH_LIBS([ZSTD_compress],[zstd zstd.dll cygzstd.dll], [], [])
   AC_DEFINE([HAVE_ZSTD], [1], [if true, zstd library is available])
fi
AC_MSG_CHECKING([whether libzstd library is available])
AC_MSG_RESULT([${have_zstd}])

# See if we have libbz2
AC_CHECK_LIB([bz2],[BZ2_bzCompress],[have_bz2=yes],[have_bz2=no])
if test "x$have_bz2" = "xyes" ; then
     AC_SEARCH_LIBS([BZ2_bzCompress],[bz2 bz2.dll cygbz2.dll], [], [])
     AC_DEFINE([HAVE_BZ2], [1], [if true, bz2 library is installed])
fi
AC_MSG_CHECKING([whether libbz2 library is available])
AC_MSG_RESULT([${have_bz2}])

if test "x$have_bz2" = "xno" ; then
  have_local_bz2=yes
  AC_MSG_NOTICE([Defaulting to internal libbz2])
else
  have_local_bz2=no
fi
AM_CONDITIONAL(HAVE_LOCAL_BZ2, [test "x$have_local_bz2" = xyes])

# Note that szip management is tricky.
# This is because we have three things to consider:
# 1. is libsz available?
# 2. is szip enabled in HDF5?
# 3. is nczarr enabled?
# We need separate flags for cases 1 and 2

# See if we have libsz (usually via libaec)
AC_CHECK_LIB([sz],[SZ_BufftoBuffCompress],[have_sz=yes],[have_sz=no])
if test "x$have_sz" = "xyes" ; then
   AC_SEARCH_LIBS([SZ_BufftoBuffCompress],[sz sz.dll cygsz.dll], [], [])
   AC_DEFINE([HAVE_SZ], [1], [if true, libsz (==szip) is available])
fi
AC_MSG_CHECKING([whether libsz library is available])
AC_MSG_RESULT([${have_sz}])

##########

# See if we have libzip for NCZarr
AC_CHECK_LIB([zip],[zip_open],[have_zip=yes],[have_zip=no])
if test "x$have_zip" = "xyes" ; then
   AC_SEARCH_LIBS([zip_open],[zip zip.dll cygzip.dll], [], [])
fi
AC_MSG_CHECKING([whether libzip library is available])
AC_MSG_RESULT([${have_zip}])

enable_nczarr_zip=${have_zip} # alias

if test "x$enable_nczarr" = xno ; then
enable_nczarr_zip=no
fi


AC_MSG_CHECKING([whether nczarr zip support is enabled])
AC_MSG_RESULT([${enable_nczarr_zip}])

if test "x$enable_nczarr_zip" = xyes ; then
AC_DEFINE([ENABLE_NCZARR_ZIP], [1], [If true, then libzip found])
fi
AM_CONDITIONAL(ENABLE_NCZARR_ZIP, [test "x$enable_nczarr_zip" = xyes])

# Check for enabling of S3 support
AC_MSG_CHECKING([whether netcdf zarr S3 support should be enabled])
AC_ARG_ENABLE([nczarr-s3],
              [AS_HELP_STRING([--enable-nczarr-s3],
                              [enable netcdf zarr S3 support; make sure to set LDFLAGS])])
test "x$enable_nczarr_s3" = xyes || enable_nczarr_s3=no
if test "x$enable_nczarr" = xno ; then
enable_nczarr_s3=no
fi
AC_MSG_RESULT($enable_nczarr_s3)

# Note we check for the library after checking for enable_nczarr_s3
# because for some reason this screws up if we unconditionally test for sdk
# and it is not available. Fix someday
enable_s3_sdk=no
if test "x$enable_nczarr_s3" = xyes ; then
# See if we have the s3 aws library
# Check for the AWS S3 SDK library
AC_LANG_PUSH([C++])
AC_SEARCH_LIBS([aws_allocator_is_valid],[aws-c-common aws-cpp-sdk-s3 aws-cpp-sdk-core], [enable_s3_sdk=yes],[enable_s3_sdk=no])
AC_LANG_POP
fi

AC_MSG_CHECKING([whether AWS S3 SDK library is available])
AC_MSG_RESULT([$enable_s3_sdk])

if test "x$enable_s3_sdk" = xno ; then
AC_MSG_WARN([No S3 library available; disabling S3 support])
enable_nczarr_s3=no
fi

if test "x$enable_s3_sdk" = xyes ; then
AC_DEFINE([ENABLE_S3_SDK], [1], [If true, then S3 sdk was found])
fi
AM_CONDITIONAL(ENABLE_S3_SDK, [test "x$enable_s3_sdk" = xyes])

# Check for enabling S3 testing
AC_MSG_CHECKING([whether netcdf zarr S3 testing should be enabled])
AC_ARG_ENABLE([nczarr-s3-tests],
              [AS_HELP_STRING([--enable-nczarr-s3-tests],
                              [enable netcdf zarr S3 testing])])
test "x$enable_nczarr_s3_tests" = xyes || enable_nczarr_s3_tests=no
AC_MSG_RESULT($enable_nczarr_s3_tests)

# Disable S3 tests if S3 support is disabled
if test "x$enable_nczarr_s3" = xno && test "x$enable_nczarr_s3_tests" = xyes ; then
    AC_MSG_ERROR([NCZarr S3 support is disabled; please remove option --enable-nczarr-s3-tests])
    enable_nczarr_s3_tests=no
fi

if test "x$enable_nczarr_s3" = xyes ; then
  AC_DEFINE([ENABLE_NCZARR_S3], [1], [if true, build libnczarr with S3 support enabled])
fi
AM_CONDITIONAL(ENABLE_NCZARR_S3, [test "x$enable_nczarr_s3" = xyes])

if test "x$enable_nczarr_s3_tests" = xyes ; then
  AC_DEFINE([ENABLE_NCZARR_S3_TESTS], [1], [if true, build libnczarr with S3 tests enabled])
fi
AM_CONDITIONAL(ENABLE_NCZARR_S3_TESTS, [test "x$enable_nczarr_s3_tests" = xyes])

if test "x$enable_nczarr_s3_tests" = xyes ; then
  AC_MSG_WARN([*** DO NOT ENABLE_NCZARR_S3_TESTS UNLESS YOU HAVE ACCESS TO THE UNIDATA S3 BUCKET! ***])
fi

# Set default
# Did the user specify a default cache size for NCZarr?
AC_MSG_CHECKING([whether a default file cache size for NCZarr was specified])
AC_ARG_WITH([chunk-cache-size-nczarr],
              [AS_HELP_STRING([--with-chunk-cache-size-nczarr=<integer>],
                              [Specify default maximum space used by the chunk cache NCZarr.])],
            [CHUNK_CACHE_SIZE_NCZARR=$with_chunk_cache_size_nczarr], [CHUNK_CACHE_SIZE_NCZARR=4194304])
AC_MSG_RESULT([$CHUNK_CACHE_SIZE_NCZARR])
AC_DEFINE_UNQUOTED([CHUNK_CACHE_SIZE_NCZARR], [$CHUNK_CACHE_SIZE_NCZARR], [default nczarr chunk cache size.])

# This has multiversion capability
AC_MSG_CHECKING([whether multi-filter support is enabled])
has_multifilters=yes
AC_MSG_RESULT($has_multifilters)
AC_DEFINE([HAS_MULTIFILTERS], [1], [if true, multi-filter support enabled])

# Check whether we want to enable strict null byte header padding.
# See https://github.com/Unidata/netcdf-c/issues/657 for more information.
AC_MSG_CHECKING([whether to enable strict null-byte header padding when reading (default off)])
AC_ARG_ENABLE([strict-null-byte-header-padding],
    [AS_HELP_STRING([--enable-strict-null-byte-header-padding],
                    [enable strict null-byte header padding when reading netCDF3 files.])])
test "x$enable_strict_null_byte_header_padding" = xyes || enable_strict_null_byte_header_padding=no
AC_MSG_RESULT($enable_strict_null_byte_header_padding)

if test "x$enable_strict_null_byte_header_padding" = xyes; then
   AC_DEFINE([USE_STRICT_NULL_BYTE_HEADER_PADDING], [1], [if true, enable strict null byte header padding])
fi

AM_CONDITIONAL(USE_STRICT_NULL_BYTE_HEADER_PADDING, [test x$enable_strict_null_byte_header_padding = xyes ])

# Does the user want to use the ffio module?
AC_MSG_CHECKING([whether FFIO will be used])
AC_ARG_ENABLE([ffio],
              [AS_HELP_STRING([--enable-ffio],
                              [use ffio instead of posixio (ex. on the Cray)])])
test "x$enable_ffio" = xyes || enable_ffio=no
AC_MSG_RESULT($enable_ffio)
if test "x$enable_ffio" = xyes; then
   AC_DEFINE([USE_FFIO], [1], [if true, use ffio instead of posixio])
fi
AM_CONDITIONAL(USE_FFIO, [test x$enable_ffio = xyes])

# Does the user want to use the stdio module?
AC_MSG_CHECKING([whether STDIO will be used])
AC_ARG_ENABLE([stdio],
              [AS_HELP_STRING([--enable-stdio],
                              [use stdio instead of posixio (ex. on the Cray)])])
test "x$enable_stdio" = xyes || enable_stdio=no
AC_MSG_RESULT($enable_stdio)
if test "x$enable_stdio" = xyes; then
   AC_DEFINE([USE_STDIO], [1], [if true, use stdio instead of posixio])
fi
AM_CONDITIONAL(USE_STDIO, [test x$enable_stdio = xyes])

nc_build_c=yes
nc_build_v2=yes
nc_build_utilities=yes
nc_build_tests=yes
nc_build_examples=yes

# Does the user want to build examples?
AC_MSG_CHECKING([whether examples should be built])
AC_ARG_ENABLE([examples],
              [AS_HELP_STRING([--disable-examples],
                              [don't build the netCDF examples during make check \
                              (examples are treated as extra tests by netCDF)])])
test "x$enable_examples" = xno && nc_build_examples=no
AC_MSG_RESULT($nc_build_examples)
AM_CONDITIONAL(BUILD_EXAMPLES, [test x$nc_build_examples = xyes])

# Does the user want to disable the V2 API?
AC_MSG_CHECKING([whether v2 netCDF API should be built])
AC_ARG_ENABLE([v2],
              [AS_HELP_STRING([--disable-v2],
                              [turn off the netCDF version 2 API])])
test "x$enable_v2" = xno && nc_build_v2=no
AC_MSG_RESULT($nc_build_v2)
AM_CONDITIONAL(BUILD_V2, [test x$nc_build_v2 = xyes])
if test "x$nc_build_v2" = xno; then
   AC_DEFINE_UNQUOTED(NO_NETCDF_2, 1, [do not build the netCDF version 2 API])
else
   AC_DEFINE_UNQUOTED(USE_NETCDF_2, 1, [build the netCDF version 2 API])
fi

# Does the user want to disable ncgen/ncdump/nccopy/...?
AC_MSG_CHECKING([whether the ncgen/ncdump/nccopy should be built])
AC_ARG_ENABLE([utilities],
              [AS_HELP_STRING([--disable-utilities],
                              [don't build netCDF utilities ncgen, ncdump, and nccopy])])
test "x$nc_build_c" = xno && enable_utilities=no
test "x$enable_utilities" = xno && nc_build_utilities=no
AC_MSG_RESULT($nc_build_utilities)
AM_CONDITIONAL(BUILD_UTILITIES, [test x$nc_build_utilities = xyes])

# Does the user want to disable all tests?
AC_MSG_CHECKING([whether test should be built and run])
AC_ARG_ENABLE([testsets],
              [AS_HELP_STRING([--disable-testsets],
                              [don't build or run netCDF tests])])
test "x$enable_testsets" = xno || enable_testsets=yes
nc_build_tests=$enable_testsets
AC_MSG_RESULT($nc_build_tests)
AM_CONDITIONAL(BUILD_TESTSETS, [test x$nc_build_tests = xyes])

# Does the user want to run tests for large files (> 2GiB)?
AC_MSG_CHECKING([whether large file (> 2GB) tests should be run])
AC_ARG_ENABLE([large-file-tests],
              [AS_HELP_STRING([--enable-large-file-tests],
                              [Run tests which create very large data files (~13 GB disk space
                              required, but it will be recovered when tests are complete). See
                              option --with-temp-large to specify temporary directory])])
test "x$enable_large_file_tests" = xyes || enable_large_file_tests=no
AC_MSG_RESULT($enable_large_file_tests)
AM_CONDITIONAL(LARGE_FILE_TESTS, [test x$enable_large_file_tests = xyes])
if test "x$enable_large_file_tests" = xyes; then
   AC_DEFINE([LARGE_FILE_TESTS], [1], [do large file tests])
fi

# Does the user want to run benchmarks?
AC_MSG_CHECKING([whether benchmarks should be run])
AC_ARG_ENABLE([benchmarks],
              [AS_HELP_STRING([--enable-benchmarks],
                              [Run benchmarks. This will cause sample data files from the Unidata ftp
                              site to be fetched. The benchmarks are a bunch of extra tests, which
                              are timed. We use these tests to check netCDF performance.])])
test "x$enable_benchmarks" = xyes || enable_benchmarks=no
AC_MSG_RESULT($enable_benchmarks)
if test "x$enable_HDF5" = xno -a "x$enable_benchmarks" = xyes; then
AC_MSG_ERROR([Can't use benchmarks if HDF5 is disabled.])
fi
AM_CONDITIONAL(BUILD_BENCHMARKS, [test x$enable_benchmarks = xyes])

# Does the user want to use extreme numbers in testing.
AC_MSG_CHECKING([whether extreme numbers should be used in tests])
AC_ARG_ENABLE([extreme-numbers],
              [AS_HELP_STRING([--disable-extreme-numbers],
                              [don't use extreme numbers during testing, such as MAX_INT - 1])])
case "$host_cpu $host_os" in
     *386*solaris*)
        test "x$enable_extreme_numbers" = xyes || enable_extreme_numbers=no
        ;;
     *)
        test "x$enable_extreme_numbers" = xno || enable_extreme_numbers=yes
        ;;
esac
AC_MSG_RESULT($enable_extreme_numbers)

if test "x$enable_extreme_numbers" = xyes; then
   AC_DEFINE(USE_EXTREME_NUMBERS, 1, [set this to use extreme numbers in tests])
fi

# If the env. variable TEMP_LARGE is set, or if
# --with-temp-large=<directory>, use it as a place for the large
# (i.e. > 2 GiB) files created during the large file testing.
AC_MSG_CHECKING([where to put large temp files if large file tests are run])
AC_ARG_WITH([temp-large],
            [AS_HELP_STRING([--with-temp-large=<directory>],
                            [specify directory where large files (i.e. >2 GB) \
                            will be written, if large files tests are run with
                            --enable-large-file-tests])],
            [TEMP_LARGE=$with_temp_large])
TEMP_LARGE=${TEMP_LARGE-.}
AC_MSG_RESULT($TEMP_LARGE)
#AC_SUBST(TEMP_LARGE)
AC_DEFINE_UNQUOTED([TEMP_LARGE], ["$TEMP_LARGE"], [Place to put very large netCDF test files.])

# Specify extra values to add to _NCProperties attribute
# --with-ncproperties-extra="<name>=<value>|...".
# Note: need to figure out a way to do this programmatically also
AC_MSG_CHECKING([Extra values for _NCProperties])
AC_ARG_WITH([ncproperties-extra],
            [AS_HELP_STRING([--with-ncproperties-extra="<name>=<value>,...],
                            [specify extra pairs for _NCProperties])],
            [NCPROPERTIES_EXTRA=$with_ncproperties_extra],
            [NCPROPERTIES_EXTRA=""])
AC_MSG_RESULT([$NCPROPERTIES_EXTRA])
AC_DEFINE_UNQUOTED([NCPROPERTIES_EXTRA], ["$NCPROPERTIES_EXTRA"], [Extra pairs for _NCProperties])

# Did the user specify a user-defined format 0?
AC_MSG_CHECKING([whether user-defined format 0 was specified])
AC_ARG_WITH([udf0],
              [AS_HELP_STRING([--with-udf0=<dispatch_name>],
                              [Specify a dispatch table for user-defined format 0.])],
            [UDF0_DISPATCH=$with_udf0])
AC_MSG_RESULT([$UDF0_DISPATCH])
if test -n "$UDF0_DISPATCH"; then
   AC_DEFINE_UNQUOTED([UDF0_DISPATCH], [$UDF0_DISPATCH], [dispatch table for user-defined format 0.])
   AC_DEFINE_UNQUOTED([UDF0_DISPATCH_FUNC], [get_$UDF0_DISPATCH()], [function to get dispatch table for user-defined format 0.])
   AC_DEFINE([USE_UDF0], [1], [if true, use user-defined format 0 in utilities])
   AC_CHECK_LIB([$UDF0_DISPATCH], [get_$UDF0_DISPATCH], [],
                                 [AC_MSG_ERROR([Can't find or link to the user-defined format 0 library.])],
                                 [])
fi

# Did the user specify a magic number for user-defined format 0?
AC_MSG_CHECKING([whether a magic number for user-defined format 0 was specified])
AC_ARG_WITH([udf0-magic-number],
              [AS_HELP_STRING([--with-udf0-magic-number=<magic_number>],
                              [Specify a magic number for user-defined format 0 (ignored unless --with-udf0 is also used).])],
            [UDF0_MAGIC_NUMBER=$with_udf0_magic_number])
AC_MSG_RESULT([$UDF0_MAGIC_NUMBER])

# Did the user specify a user-defined format 1?
AC_MSG_CHECKING([whether user-defined format 1 was specified])
AC_ARG_WITH([udf1],
              [AS_HELP_STRING([--with-udf1=<dispatch_name>],
                              [Specify a dispatch table for user-defined format 1.])],
            [UDF1_DISPATCH=$with_udf1])
AC_MSG_RESULT([$UDF1_DISPATCH])
if test -n "$UDF1_DISPATCH"; then
   AC_DEFINE_UNQUOTED([UDF1_DISPATCH], [$UDF1_DISPATCH], [dispatch table for user-defined format 1.])
   AC_DEFINE_UNQUOTED([UDF1_DISPATCH_FUNC], [get_$UDF1_DISPATCH()], [function to get dispatch table for user-defined format 1.])
   AC_DEFINE([USE_UDF1], [1], [if true, use user-defined format 1 in utilities])
   AC_CHECK_LIB([$UDF1_DISPATCH], [get_$UDF1_DISPATCH], [],
                                 [AC_MSG_ERROR([Can't find or link to the user-defined format 1 library.])],
                                 [])
fi

# Did the user specify a magic number for user-defined format 0?
AC_MSG_CHECKING([whether a magic number for user-defined format 1 was specified])
AC_ARG_WITH([udf1-magic-number],
              [AS_HELP_STRING([--with-udf1-magic-number=<magic_number>],
                              [Specify a magic number for user-defined format 1 (ignored unless --with-udf1 is also used).])],
            [UDF1_MAGIC_NUMBER=$with_udf1_magic_number])
AC_MSG_RESULT([$UDF1_MAGIC_NUMBER])

# According to the autoconf mailing list gurus, we must test for
# compilers unconditionally. That is, we can't skip looking for the
# fortran compilers, just because the user doesn't want fortran. This
# is due to a limitation in autoconf.

# Find the C compiler.
AC_MSG_NOTICE([finding C compiler])

## Compiler with version information. This consists of the full path
## name of the compiler and the reported version number.
AC_SUBST([CC_VERSION])
## Strip anything that looks like a flag off of $CC
CC_NOFLAGS=`echo $CC | sed 's/ -.*//'`

if `echo $CC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
  CC_VERSION="$CC"
else
  CC_VERSION="$CC";
  for x in `echo $PATH | sed -e 's/:/ /g'`; do
    if test -x $x/$CC_NOFLAGS; then
      CC_VERSION="$x/$CC"
      break
    fi
  done
fi
if test -n "$cc_version_info"; then
  CC_VERSION="$CC_VERSION ( $cc_version_info)"
fi


AC_PROG_CC
AC_PROG_CXX
AM_PROG_CC_C_O
AC_C_CONST

# Set up libtool.
AC_MSG_NOTICE([setting up libtool])
LT_PREREQ([2.2])
LT_INIT()

AC_MSG_NOTICE([finding other utilities])

# Is m4 installed? If not, bail.
AC_CHECK_PROGS([NC_M4], [m4])
if test -z "$NC_M4"; then
   AC_MSG_ERROR([Cannot find m4 utility. Install m4 and try again.])
fi

# Is doxygen installed? If so, have configure construct the Doxyfile.
AC_CHECK_PROGS([DOXYGEN], [doxygen])
if test -z "$DOXYGEN"; then
   AC_MSG_WARN([Doxygen not found - documentation will not be built])
fi

# Is graphviz/dot installed? If so, we'll use dot to create
# graphs in the documentation.
AC_CHECK_PROGS([DOT], [dot])
if test -z "$DOT"; then
   AC_MSG_WARN([dot not found - will use simple charts in documentation])
   HAVE_DOT=NO
elif test "x$enable_dot" = xno; then
   HAVE_DOT=NO
else
   HAVE_DOT=YES
fi
# If we have doxygen, and it's enabled, then process the file.
if test "x$enable_doxygen" != xno; then
   if test -n "$DOXYGEN"; then
        AC_SUBST(HAVE_DOT)
        AC_CONFIG_FILES([docs/Doxyfile])
   fi
# Note: the list of files to input to doxygen
# has been moved to docs/Doxyfile.in so
# that make distcheck works correctly.
# Any new inputs should be inserted into
# docs/Doxyfile.in and possibley docs/Makefile.am
fi

# Find the install program.
AC_PROG_INSTALL

# Check to see if any macros must be set to enable large (>2GB) files.
AC_SYS_LARGEFILE

AC_MSG_NOTICE([displaying some results])

## This next macro just prints some results for debugging
## support issues.
UD_DISPLAY_RESULTS

# For nightly build testing, output CC, FC, etc.
echo "CPPFLAGS=$CPPFLAGS CC=$CC CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS LIBS=$LIBS" >> comps.txt

AC_MSG_NOTICE([checking types, headers, and functions])

AC_CHECK_HEADERS([sys/param.h])
AC_CHECK_HEADERS([libgen.h])
#AC_CHECK_HEADERS([locale.h])
AC_HEADER_STDC
AC_CHECK_HEADERS([locale.h stdio.h stdarg.h fcntl.h malloc.h stdlib.h string.h strings.h unistd.h sys/stat.h getopt.h sys/time.h sys/types.h time.h dirent.h])

# Do sys/resource.h separately
#AC_CHECK_HEADERS([sys/resource.h],[havesysresource=1],[havesysresource=0])
#if test "x$enable_dll" != xyes ; then
AC_CHECK_HEADERS([sys/resource.h])
#fi

# See if we have ftw.h to walk directory trees
AC_CHECK_HEADERS([ftw.h])

# See if we can do stack tracing programmatically
AC_CHECK_HEADERS([execinfo.h])

# Check for these functions...
AC_CHECK_FUNCS([strlcat snprintf strcasecmp fileno \
                strdup strtoll strtoull \
		mkstemp mktemp random \
		getrlimit gettimeofday fsync MPI_Comm_f2c MPI_Info_f2c \
		strncasecmp])

# See if clock_gettime is available and its arg types.
AC_CHECK_FUNCS([clock_gettime])
AC_CHECK_TYPES([struct timespec])

# disable dap4 if hdf5 is disabled
if test "x$enable_hdf5" = "xno" ; then
    AC_MSG_WARN([netcdf-4 not enabled; disabling DAP4])
    enable_dap4=no
fi

if test "x$ISOSX" = xyes && "x$have_libxml2" = xno ; then
  AC_MSG_ERROR([Error: OSX requires libxml2 => --disable-dap4.])
  enable_dap4=no
fi

if test "x$enable_dap4" = xyes; then
   AC_DEFINE([ENABLE_DAP4], [1], [if true, build DAP4 Client])
fi

# check for useful, but not essential, memio support
AC_CHECK_FUNCS([memmove getpagesize sysconf])

# Does the user want to allow use of mmap for NC_DISKLESS?
AC_MSG_CHECKING([whether mmap is enabled for in-memory files])
AC_ARG_ENABLE([mmap],
              [AS_HELP_STRING([--enable-mmap],
                              [allow mmap for in-memory files])])
test "x$enable_mmap" = xyes || enable_mmap=no
AC_MSG_RESULT($enable_mmap)

# check for mmap availability before committing to use mmap
have_mmap="$enable_mmap"
AC_CHECK_FUNCS([mmap],[havemmapfcn=yes],[havemmapfcn=no])
if test "x$havemmapfcn" = xno ; then
have_mmap=no
fi

# check for mremap availability; not strictly needed
AC_CHECK_FUNCS([mremap],[havemremapfcn=yes],[havemmapfcn=no])

# Check for MAP_ANONYMOUS
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include <sys/mman.h>],
[[int x = MAP_ANONYMOUS;]])],
                   [havemapanon=yes],
                   [havemapanon=no])
AC_MSG_CHECKING([whether MAP_ANONYMOUS is defined])
AC_MSG_RESULT([${havemapanon}])
if test "x$havemapanon" != xyes ; then
  have_mmap=no
fi

if test "x$have_mmap" != xyes ; then
  if test "x$enable_mmap" = xyes ; then
     AC_MSG_WARN([mmap functionality is not available: disabling mmap])
  else
     AC_MSG_NOTICE([mmap functionality is not available: disabling mmap])
  fi
  enable_mmap=no
fi

if test "x$enable_mmap" = xyes; then
    AC_DEFINE([USE_MMAP], [1], [if true, use mmap for in-memory files])
fi

# Does the user want to allow reading of remote data via range headers?
AC_MSG_CHECKING([whether byte range support is enabled])
AC_ARG_ENABLE([byterange],
              [AS_HELP_STRING([--enable-byterange],
                              [allow byte-range I/O])])
test "x$enable_byterange" = xyes || enable_byterange=no
AC_MSG_RESULT($enable_byterange)
# Need curl for byte ranges
if test "x$found_curl" = xno && test "x$enable_byterange" = xyes ; then
  AC_MSG_ERROR([curl required for byte range support. Install curl or build without --enable-byterange.])
  enable_byterange=no
fi

if test "x$enable_byterange" = xyes; then
    AC_DEFINE([ENABLE_BYTERANGE], [1], [if true, support byte-range read of remote datasets.])
fi

# Does the user want to disable atexit?
AC_MSG_CHECKING([whether nc_finalize should be invoked at exit])
AC_ARG_ENABLE([atexit-finalize],
               [AS_HELP_STRING([--disable-atexit-finalize],
                               [disable invoking nc_finalize at exit])])
test "x$enable_atexit_finalize" = xno || enable_atexit_finalize=yes
AC_MSG_RESULT($enable_atexit_finalize)

# Check for atexit
AC_CHECK_FUNCS([atexit])

# If no atexit, then disable atexit finalize
if test "x$enable_atexit_finalize" = xyes ; then
  if test "x$ac_cv_func_function" = xno ; then
    enable_atexit_finalize=no
    AC_MSG_ERROR([atexit() required for enable-atexit-finalize.])
  fi
fi

if test "x$enable_atexit_finalize" = xyes ; then
  AC_DEFINE([ENABLE_ATEXIT_FINALIZE], [1], [If true, enable nc_finalize via atexit()])
fi

# Need libdl(d) for plugins
AC_CHECK_LIB([dl],[dlopen],[have_libdld=yes],[have_libdld=no])
if test "x$have_libdld" = "xyes" ; then
   AC_SEARCH_LIBS([dlopen],[dl dld], [],[])
fi

# Does the user want plugins?
AC_MSG_CHECKING([whether dynamically loaded plugins is enabled])
AC_ARG_ENABLE([plugins],
              [AS_HELP_STRING([--disable-plugins],
                              [disallow dynamically loaded plugins])])
test "x$enable_plugins" = xno || enable_plugins=yes
AC_MSG_RESULT([$enable_plugins])
if test "x$have_libdld" = xno && test "x$ISMSVC" = xno; then
  enable_plugins=no
  AC_MSG_WARN([libdld required for enable-plugins.])
fi
if test "x$enable_plugins" = xyes && test "x$enable_shared" = xno; then
    AC_MSG_WARN([--disable-shared => --disable-plugins])
    enable_plugins=no
fi

if test "x$enable_plugins" = xyes; then
    AC_DEFINE([ENABLE_PLUGINS], [1], [if true, support dynamically loaded plugins])
fi
AM_CONDITIONAL(ENABLE_PLUGINS, [test "x$enable_plugins" = xyes])
AC_SUBST(USEPLUGINS, [${enable_plugins}])

AC_FUNC_ALLOCA
AC_CHECK_DECLS([isnan, isinf, isfinite],,,[#include <math.h>])
AC_STRUCT_ST_BLKSIZE
UD_CHECK_IEEE
AC_CHECK_TYPES([size_t, ssize_t, schar, uchar, longlong, ushort, uint, int64, uint64, size64_t, ssize64_t, _off64_t, uint64_t, ptrdiff_t])
AC_TYPE_OFF_T
AC_TYPE_UINTPTR_T
AC_C_CHAR_UNSIGNED
AC_C_BIGENDIAN

AM_CONDITIONAL(ISCYGWIN, [test "x$ISCYGWIN" = xyes])
AM_CONDITIONAL(ISMSVC, [test "x$ISMSVC" = xyes])
AM_CONDITIONAL(ISOSX, [test "x$ISOSX" = xyes])
AM_CONDITIONAL(ISMINGW, [test "x$ISMINGW" = xyes])
AM_CONDITIONAL(ISMSYS, [test "x$ISMSYS" = xyes])

AC_SUBST([ISMSVC], [${ISMSVC}])
  AC_SUBST([WINVERMAJOR], [${WINVERMAJOR}])
  AC_SUBST([WINVERBUILD], [${WINVERBUILD}])
AC_SUBST([ISCYGWIN], [${ISCYGWIN}])
AC_SUBST([ISOSX], [${ISOSX}])
AC_SUBST([ISMINGW], [${ISMINGW}])
AC_SUBST([ISMSYS], [${ISMSYS}])

if test "x$ISMSVC" != x ; then REGEDIT=yes; fi
if test "x$ISMSYS" != x ; then REGEDIT=yes; fi
if test "x$ISCYGWIN" != x ; then REGEDIT=yes; fi
if test "x$REGEDIT" = xyes; then
  AC_DEFINE([REGEDIT], 1, [dreg.c usable])
fi
AM_CONDITIONAL(REGEDIT, [test "x$REGEDIT" = xyes])
AC_SUBST([ISREGEDIT], [yes])

###
# Crude hack to work around an issue
# in Cygwin.
###
SLEEPCMD=""
if test "x$ISCYGWIN" = "xyes"; then
   SLEEPCMD="sleep 5"
   AC_MSG_NOTICE([Pausing between sizeof() checks to mitigate a Cygwin issue.])
fi

$SLEEPCMD
AC_CHECK_SIZEOF(short)
$SLEEPCMD
AC_CHECK_SIZEOF(int)
$SLEEPCMD
AC_CHECK_SIZEOF(long)
$SLEEPCMD
AC_CHECK_SIZEOF(long long)
$SLEEPCMD
AC_CHECK_SIZEOF(float)
$SLEEPCMD
AC_CHECK_SIZEOF(double)
$SLEEPCMD
AC_CHECK_SIZEOF(off_t)
$SLEEPCMD
AC_CHECK_SIZEOF(size_t)
$SLEEPCMD
AC_CHECK_SIZEOF(unsigned long long)


if test "$ac_cv_sizeof_size_t" -lt "8" ; then
   if test "x${enable_cdf5}" = xyes ; then
      dnl unable to support CDF5, but --enable-cdf5 is explicitly set
      AC_MSG_ERROR([Unable to support CDF5 feature because size_t is less than 8 bytes])
   fi
   enable_cdf5=no
else
   if test "x${enable_cdf5}" != xno ; then
      enable_cdf5=yes
   fi
fi

if test "x${enable_cdf5}" = xyes; then
   AC_DEFINE([ENABLE_CDF5], [1], [if true, enable CDF5 Support])
fi
AM_CONDITIONAL(ENABLE_CDF5, [test x$enable_cdf5 = xyes ])

$SLEEPCMD
if test "$ac_cv_type_uchar" = yes ; then
   AC_CHECK_SIZEOF(uchar)
else
   AC_CHECK_SIZEOF(unsigned char)
fi

$SLEEPCMD
if test "$ac_cv_type_ushort" = yes ; then
   AC_CHECK_SIZEOF(ushort)
else
   AC_CHECK_SIZEOF(unsigned short int)
fi

$SLEEPCMD
if test "$ac_cv_type_uint" = yes ; then
   AC_CHECK_SIZEOF(uint)
else
   AC_CHECK_SIZEOF(unsigned int)
fi
$SLEEPCMD
if test "$ac_cv_type_ushort" = yes ; then
   AC_CHECK_SIZEOF(ushort)
else
   AC_CHECK_SIZEOF(unsigned short int)
fi
$SLEEPCMD
if test "$ac_cv_type_uint" = yes ; then
   AC_CHECK_SIZEOF(uint)
else
   AC_CHECK_SIZEOF(unsigned int)
fi
$SLEEPCMD
AC_CHECK_SIZEOF(ssize_t)
$SLEEPCMD
AC_CHECK_SIZEOF([void*])

if test "x$enable_hdf5" = xyes || test "x$enable_dap" = xyes ; then
   AC_SEARCH_LIBS([deflate], [zlibwapi zlibstat zlib zlib1 z], [], [
     AC_MSG_ERROR([Can't find or link to the z library. Turn off netCDF-4 and \
     DAP clients with --disable-hdf5 --disable-dap, or see config.log for errors.])])
fi

# We need the math library
AC_CHECK_LIB([m], [floor], [],
[AC_MSG_ERROR([Can't find or link to the math library.])])

if test "x$enable_netcdf_4" = xyes; then
   AC_DEFINE([USE_NETCDF4], [1], [if true, build netCDF-4])
fi

# Set defaults
hdf5_parallel=no
hdf5_supports_par_filters=no
enable_hdf5_szip=no
has_ross3=no

if test "x$enable_hdf5" = xyes; then

   AC_DEFINE([USE_HDF5], [1], [if true, use HDF5])
   AC_DEFINE([H5_USE_16_API], [1], [use HDF5 1.6 API])

   # Check for the main hdf5 and hdf5_hl library.

   AC_SEARCH_LIBS([H5Fflush], [hdf5 hdf5.dll], [],
   [AC_MSG_ERROR([Can't find or link to the hdf5 library. Use --disable-hdf5, or see config.log for errors.])])
   AC_SEARCH_LIBS([H5DSis_scale], [hdf5_hl hdf5_hl.dll], [],
   [AC_MSG_ERROR([Can't find or link to the hdf5 library. Use --disable-hdf5, or see config.log for errors.])])

   AC_CHECK_HEADERS([hdf5.h], [], [AC_MSG_ERROR([Compiling a test with HDF5 failed.  Either hdf5.h cannot be found, or config.log should be checked for other reason.])])

   # Was HDF5 built with zlib as netCDF requires?
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "H5public.h"],
   [[#if !H5_HAVE_ZLIB_H
   # error
   #endif]
   ])], [], [AC_MSG_ERROR([HDF5 was not built with zlib, which is required. Rebuild HDF5 with zlib.])])

   # H5Pset_fapl_mpiposix and H5Pget_fapl_mpiposix have been removed since HDF5 1.8.12.
   # Use H5Pset_fapl_mpio and H5Pget_fapl_mpio, instead.

   AC_CHECK_FUNCS([H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5Pset_all_coll_metadata_ops H5Literate])

   # Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0)
   if test "x$ac_cv_func_H5Pset_all_coll_metadata_ops" = xyes; then
      AC_DEFINE([HDF5_HAS_COLL_METADATA_OPS], [1], [if true, use collective metadata ops in parallel netCDF-4])
   fi

   # If parallel is available in hdf5, enable it in the C code. Also add some stuff to netcdf.h.
   if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes -o "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then
      hdf5_parallel=yes
   fi
   AC_MSG_CHECKING([whether parallel io is enabled in hdf5])
   AC_MSG_RESULT([$hdf5_parallel])

   # See if H5Dread_chunk is available
   AC_SEARCH_LIBS([H5Dread_chunk],[hdf5_hldll hdf5_hl], [has_readchunks=yes], [has_readdhunks=no])

   # See if hdf5 library supports Read-Only S3 (byte-range) driver
   AC_SEARCH_LIBS([H5Pset_fapl_ros3],[hdf5_hldll hdf5_hl], [has_ros3=yes], [has_ros3=no])
   if test "x$has_ros3" = xyes && test "x$enable_byterange" = xyes; then
    AC_DEFINE([ENABLE_HDF5_ROS3], [1], [if true, support byte-range using hdf5 virtual file driver.])
   fi

   # Check to see if HDF5 library is 1.10.3 or greater. If so, allows
   # parallel I/O with filters. This allows zlib/szip compression to
   # be used with parallel I/O, which is very helpful to HPC users.
   if test "x$has_readchunks" = xyes; then
      AC_DEFINE([HDF5_SUPPORTS_PAR_FILTERS], [1], [if true, HDF5 is at least version 1.10.3 and allows parallel I/O with zip])
      hdf5_supports_par_filters=yes
   fi
   AC_MSG_CHECKING([whether HDF5 allows parallel filters])
   AC_MSG_RESULT([$has_readchunks])

   # Check to see if user asked for parallel build, but HDF5 does not support it.
   if test "x$hdf5_parallel" = "xno"; then
      if test "x$enable_parallel_tests" = "xyes"; then
         AC_MSG_ERROR([Parallel tests requested, but no parallel HDF5 installation detected.])
      fi
   fi

   # Check whether HDF5 was built with the SZLIB library. If so we
   # must be able to link to szip library.
   AC_MSG_CHECKING([whether szlib was used when building HDF5])
   if test "x$ac_cv_func_H5Z_SZIP" = xyes; then
      enable_hdf5_szip=yes
      AC_DEFINE([HAVE_H5Z_SZIP], [1], [if true, compile in szip compression in netCDF-4 variables])
   fi
   AC_MSG_RESULT([$enable_hdf5_szip])

   # Check to see if HDF5 library is 1.10.6 or greater.
   # Used to control path name conversion
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <H5public.h>]], [[
#if (H5_VERS_MAJOR*10000 + H5_VERS_MINOR*100 + H5_VERS_RELEASE < 11006)
      choke me
#endif
  ]])], [hdf5_version_1106=yes], [hdf5_version_1106=no])
  AC_MSG_CHECKING([whether HDF5 library is version 1.10.6 or later])
  AC_MSG_RESULT([$hdf5_version_1106])
  if test "x$hdf5_version_1106" = xyes; then
      AC_DEFINE([HDF5_UTF8_PATHS], [1], [if true, HDF5 paths can be utf-8])
   fi

fi

AM_CONDITIONAL(ENABLE_NCDUMPCHUNKS, [test "x$has_readchunks" = xyes ])

# If the user wants hdf4 built in, check it out.
if test "x$enable_hdf4" = xyes; then
   AC_CHECK_LIB([jpeg], [jpeg_CreateCompress], [],
                [AC_MSG_ERROR([Jpeg library required for --enable-hdf4 builds.])])
   AC_CHECK_HEADERS([mfhdf.h], [], [nc_mfhdf_h_missing=yes])
   if test "x$nc_mfhdf_h_missing" = xyes; then
      AC_MSG_ERROR([Cannot find mfhdf.h, yet --enable-hdf4 was used.])
   fi
   AC_CHECK_LIB([df], [Hclose], [], [AC_MSG_ERROR([Can't find or link to the hdf4 df library. See config.log for errors.])])
   AC_CHECK_LIB([mfhdf], [NC_arrayfill], [AC_MSG_ERROR([HDF4 library must be built with --disable-netcdf.])], [])
   AC_CHECK_LIB([mfhdf], [SDcreate], [], [AC_MSG_ERROR([Can't find or link to the hdf4 mfhdf library. See config.log for errors.])])

   AC_CHECK_LIB([jpeg], [jpeg_set_quality], [], [AC_MSG_ERROR([Can't find or link to the jpeg library (required by hdf4). See config.log for errors.])])
   AC_DEFINE([USE_HDF4], [1], [if true, use HDF4 too])
fi

# There are several cases for parallelism:
# 1. PnetCDF enabled => we want to parallelism for CDF-1,CDF-2,and CDF-5
# 2. hdf5 has mpio enabled
#    a. do not want to use it for netcdf4
#    b. do want to use it for netcdf4

# Should we provide parallel io for netcdf-4?
if test "x$enable_hdf5" = xyes ; then
   AC_ARG_ENABLE([parallel4],
	[AS_HELP_STRING([--disable-parallel4],
                        [disable parallel I/O for netcdf-4, even if it's enabled in libhdf5])],
			[user_set_parallel4=${enableval}]2)
   test "x$enable_parallel4" = xno || enable_parallel4=yes

   # If user wants parallel IO for netCDF-4, make sure HDF5 can provide it.
   if test "x$enable_parallel4" = xyes; then
      if test "x$hdf5_parallel" = xno; then
      	 # If user specifically asked for parallel4, then error out.
	 if test "x$user_set_parallel4" = xyes; then
	    AC_MSG_ERROR([Paralllel IO in netCDF-4 requested, but HDF5 does not provide parallel IO.])
	 fi
         # User didn't specify, so disable parallel4
	 enable_parallel4=no
	 AC_MSG_WARN([Parallel io disabled for netcdf-4 because hdf5 does not support])
      fi
   fi
else
   enable_parallel4=no
fi
AC_MSG_CHECKING([whether parallel I/O is enabled for netcdf-4])
AC_MSG_RESULT($enable_parallel4)

# We have already tested for parallel io in netcdf4
# parallel I/O for CDF-1, 2, and 5 files can also be done through PnetCDF
# See if the PnetCDF lib is available and of the
# right version (1.6.0 or later)
if test "x$enable_pnetcdf" = xyes; then
  pnetcdf_conflict=no
  AC_CHECK_LIB([pnetcdf], [ncmpi_create], [],[pnetcdf_conflict=yes])

  if test "x$pnetcdf_conflict" = xyes ; then
     AC_MSG_ERROR([Cannot link to PnetCDF library.])
  fi

  # Pnetcdf did not support utf-8 until 1.6.0

  AC_MSG_CHECKING([Is libpnetcdf version 1.6.0 or later?])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pnetcdf.h>]], [[
#if (PNETCDF_VERSION_MAJOR*1000 + PNETCDF_VERSION_MINOR < 1006)
      choke me
#endif
  ]])], [pnetcdf16=yes], [pnetcdf16=no])
  AC_MSG_RESULT([$pnetcdf16])
  if test x$pnetcdf16 = xno; then
    AC_MSG_ERROR([--enable-pnetcdf requires version 1.6.0 or later])
  fi
fi

# Now, set enable_parallel if either enable_pnetcdf or enable_parallel4 is set
if test "x$enable_pnetcdf" = xyes -o "x$enable_parallel4" = xyes; then
  enable_parallel=yes
else
  enable_parallel=no
fi
AM_CONDITIONAL(ENABLE_PARALLEL, [test x$enable_parallel = xyes ])

if test "x$hdf5_parallel" = xyes; then
  # Provide more precise parallel control
  AC_DEFINE([HDF5_PARALLEL], [1], [if true, hdf5 has parallelism enabled])
fi

# Set config flags
if test "x$enable_parallel4" = xyes; then
  # Provide more precise parallel control
  AC_DEFINE([USE_PARALLEL4], [1], [if true, parallel netcdf-4 is in use])
fi

if test "x$enable_pnetcdf" = xyes; then
  AC_DEFINE([USE_PNETCDF], [1], [if true, PnetCDF is used])
fi

# If enable_parallel is in use, enable it in the C code. Also add some stuff to netcdf.h.
if test "x$enable_parallel" = xyes; then
  AC_DEFINE([USE_PARALLEL], [1], [if true, PnetCDF or parallel netcdf-4 is in use])
fi

AC_ARG_ENABLE([erange_fill],
   [AS_HELP_STRING([--enable-erange-fill],
                   [Enable use of fill value when out-of-range type
                    conversion causes NC_ERANGE error. @<:@default: disabled@:>@])],
   [enable_erange_fill=${enableval}], [enable_erange_fill=auto]
)

# check PnetCDF's settings on enable_erange_fill and relax_coord_bound
if test "x$enable_pnetcdf" = xyes; then
   UD_CHECK_HEADER_PATH([pnetcdf.h])

   AC_MSG_CHECKING([if erange-fill is enabled in PnetCDF])
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pnetcdf.h>]], [[
#if !defined(PNETCDF_ERANGE_FILL) || PNETCDF_ERANGE_FILL == 0
      choke me
#endif]])], [enable_erange_fill_pnetcdf=yes], [enable_erange_fill_pnetcdf=no])
   AC_MSG_RESULT([$enable_erange_fill_pnetcdf])
   if test "x$enable_erange_fill" = xauto ; then
      enable_erange_fill=$enable_erange_fill_pnetcdf
   elif test "$enable_erange_fill" != "$enable_erange_fill_pnetcdf"; then
      if test "$enable_erange_fill" = yes; then
         AC_MSG_ERROR([Enabling erange-fill conflicts with PnetCDF setting])
      else
         AC_MSG_ERROR([Disabling erange-fill conflicts with PnetCDF setting])
      fi
   fi

   AC_MSG_CHECKING([if relax-coord-bound is enabled in PnetCDF])
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pnetcdf.h>]], [[
#if !defined(PNETCDF_RELAX_COORD_BOUND) || PNETCDF_RELAX_COORD_BOUND == 0
      choke me
#endif]])], [relax_coord_bound_pnetcdf=yes], [relax_coord_bound_pnetcdf=no])
   AC_MSG_RESULT([$relax_coord_bound_pnetcdf])
   if test x"$relax_coord_bound_pnetcdf" != xyes; then
      AC_MSG_ERROR([PNetCDF must be built with relax-coord-bound])
   fi
else
   if test "x$enable_erange_fill" = xauto; then
      # if --enable-erange-fill is not used, default setting is no
      enable_erange_fill=no
   fi
fi

if test "x$enable_erange_fill" = xyes ; then
   if test "x$M4FLAGS" = x ; then
      M4FLAGS="-DERANGE_FILL"
   else
      M4FLAGS="$M4FLAGS -DERANGE_FILL"
   fi
   AC_DEFINE([ERANGE_FILL], [1], [if true, use _FillValue for NC_ERANGE data elements])
fi
AC_SUBST(M4FLAGS)

# Check for downloading/building fortran via postinstall script.
if test "x$enable_remote_fortran_bootstrap" = xyes; then
   AC_DEFINE([BUILD_FORTRAN], 1, [If true, will attempt to download and build netcdf-fortran.])
fi

# No logging for netcdf-3.
if test "x$enable_netcdf_4" = xno; then
   enable_logging=no
fi
if test "x$enable_logging" = xyes; then
   AC_DEFINE([LOGGING], 1, [If true, turn on logging.])
fi

# Control NCZarr filters
# Does the user want to use NCZarr filters?
AC_MSG_CHECKING([whether we should enable NCZarr filters])
AC_ARG_ENABLE([nczarr-filters], [AS_HELP_STRING([--disable-nczarr-filters],
              [disable NCZarr filters])])
test "x$enable_nczarr_filters" = xno || enable_nczarr_filters=yes
AC_MSG_RESULT([$enable_nczarr_filters])

# Control filter test/example
AC_MSG_CHECKING([whether filter testing should be run])
AC_ARG_ENABLE([filter-testing],
              [AS_HELP_STRING([--disable-filter-testing],
                              [Do not run filter test and example; requires shared libraries and HDF5|NCZarr])])
test "x$enable_filter_testing" = xno || enable_filter_testing=yes
AC_MSG_RESULT($enable_filter_testing)

# Apply constraints
if test "x$enable_plugins" = xno ; then
AC_MSG_WARN([--disable-plugins => --disable-nczarr-filters])
enable_nczarr_filters=no
fi

if test "x$enable_plugins" = xno ; then
AC_MSG_WARN([--disable-plugins => --disable-filter-testing])
enable_filter_testing=no
fi

if test "x$enable_filter_testing" = xno; then
AC_MSG_WARN([--disable-filter-testing => --disable-nczarr-filter-testing])
enable_nczarr_filter_testing=no
fi

if test "x$enable_nczarr" = xno; then
AC_MSG_WARN([--disable-nczarr => --disable-nczarr-filters])
enable_nczarr_filters=no
enable_nczarr_filter_testing=no
fi

if test "x$enable_nczarr_filters" = xyes; then
   AC_DEFINE([ENABLE_NCZARR_FILTERS], [1], [if true, enable NCZarr filters])
fi

# Client side filter registration is permanently disabled
enable_clientside_filters=no

AM_CONDITIONAL(ENABLE_CLIENTSIDE_FILTERS, [test x$enable_clientside_filters = xyes])
AM_CONDITIONAL(ENABLE_FILTER_TESTING, [test x$enable_filter_testing = xyes])
AM_CONDITIONAL(ENABLE_NCZARR_FILTERS, [test x$enable_nczarr_filters = xyes])

# Automake conditionals need to be called, whether the answer is yes
# or no.
AM_CONDITIONAL(BUILD_PARALLEL, [test x$enable_parallel = xyes])
AM_CONDITIONAL(TEST_PARALLEL4, [test "x$enable_parallel4" = xyes -a "x$enable_parallel_tests" = xyes])
AM_CONDITIONAL(BUILD_DAP, [test "x$enable_dap" = xyes])
AM_CONDITIONAL(USE_DAP, [test "x$enable_dap" = xyes]) # Alias
# Provide protocol specific flags
AM_CONDITIONAL(ENABLE_DAP, [test "x$enable_dap" = xyes])
AM_CONDITIONAL(ENABLE_DAP4, [test "x$enable_dap4" = xyes])
AM_CONDITIONAL(USE_STRICT_NULL_BYTE_HEADER_PADDING, [test x$enable_strict_null_byte_header_padding = xyes])
AM_CONDITIONAL(ENABLE_CDF5, [test "x$enable_cdf5" = xyes])
AM_CONDITIONAL(ENABLE_DAP_REMOTE_TESTS, [test "x$enable_dap_remote_tests" = xyes])
AM_CONDITIONAL(ENABLE_DAP_AUTH_TESTS, [test "x$enable_dap_auth_tests" = xyes])
AM_CONDITIONAL(ENABLE_DAP_LONG_TESTS, [test "x$enable_dap_long_tests" = xyes])
AM_CONDITIONAL(USE_PNETCDF_DIR, [test ! "x$PNETCDFDIR" = x])
AM_CONDITIONAL(USE_LOGGING, [test "x$enable_logging" = xyes])
AM_CONDITIONAL(CROSS_COMPILING, [test "x$cross_compiling" = xyes])
AM_CONDITIONAL(USE_NETCDF4, [test x$enable_netcdf_4 = xyes])
AM_CONDITIONAL(USE_HDF5, [test x$enable_hdf5 = xyes])
AM_CONDITIONAL(USE_HDF4, [test x$enable_hdf4 = xyes])
AM_CONDITIONAL(USE_HDF4_FILE_TESTS, [test x$enable_hdf4_file_tests = xyes])
AM_CONDITIONAL(USE_RENAMEV3, [test x$enable_netcdf_4 = xyes -o x$enable_dap = xyes])
AM_CONDITIONAL(BUILD_FORTRAN, [test x$enable_remote_fortran_bootstrap = xyes])
AM_CONDITIONAL(USE_PNETCDF, [test x$enable_pnetcdf = xyes])
AM_CONDITIONAL(USE_DISPATCH, [test x$enable_dispatch = xyes])
AM_CONDITIONAL(BUILD_MMAP, [test x$enable_mmap = xyes])
AM_CONDITIONAL(BUILD_DOCS, [test x$enable_doxygen = xyes])
AM_CONDITIONAL(SHOW_DOXYGEN_TAG_LIST, [test x$enable_doxygen_tasks = xyes])
AM_CONDITIONAL(ENABLE_METADATA_PERF, [test x$enable_metadata_perf = xyes])
AM_CONDITIONAL(ENABLE_BYTERANGE, [test "x$enable_byterange" = xyes])
AM_CONDITIONAL(RELAX_COORD_BOUND, [test "xyes" = xyes])
AM_CONDITIONAL(HAS_PAR_FILTERS, [test x$hdf5_supports_par_filters = xyes ])
AM_CONDITIONAL(ENABLE_NCZARR, [test "x$enable_nczarr" = xyes])
AM_CONDITIONAL(ENABLE_S3_SDK, [test "x$enable_s3_sdk" = xyes])
AM_CONDITIONAL(HAS_MULTIFILTERS, [test "x$has_multifilters" = xyes])
AM_CONDITIONAL(HAVE_SZ, [test "x$have_sz" = xyes])
AM_CONDITIONAL(HAVE_H5Z_SZIP, [test "x$enable_hdf5_szip" = xyes])
AM_CONDITIONAL(HAVE_BLOSC, [test "x$have_blosc" = xyes])
AM_CONDITIONAL(HAVE_BZ2, [test "x$have_bz2" = xyes])
AM_CONDITIONAL(HAVE_ZSTD, [test "x$have_zstd" = xyes])

# If the machine doesn't have a long long, and we want netCDF-4, then
# we've got problems!
if test "x$enable_netcdf_4" = xyes; then
   AC_TYPE_LONG_LONG_INT
   AC_TYPE_UNSIGNED_LONG_LONG_INT
dnl    if test ! "x$ac_cv_type_long_long_int" = xyes -o ! "x$ac_cv_type_unsigned_long_long_int" = xyes; then
dnl       AC_MSG_ERROR([This platform does not support long long types. These are required for netCDF-4.])
dnl    fi
fi

# Create the file name for a "make ftpbin" which is used to generate a
# binary distribution. For each release we generate binary releases on
# the thousands of machines in Unidata's vast underground complex at
# an undisclosed location in the Rocky Mountains. The binary
# distributions, along with the 25-foot thick cement slabs and the
# giant springs, will help distribute netCDF even after a catastrophic
# meteor strike.
AC_MSG_CHECKING([what to call the output of the ftpbin target])
BINFILE_NAME=binary-netcdf-$PACKAGE_VERSION
test "x$enable_netcdf_4" = xno && BINFILE_NAME=${BINFILE_NAME}_nc3
BINFILE_NAME=${BINFILE_NAME}.tar
AC_SUBST(BINFILE_NAME)
AC_MSG_RESULT([$BINFILE_NAME $FC $CXX])

##
# Bugfix for Cygwin.
##
AC_MSG_CHECKING([if libtool needs -no-undefined flag to build shared libraries])
NOUNDEFINED=""
case "`uname`" in
     CYGWIN*|MINGW*|AIX*)
     ## Add in the -no-undefined flag to LDFLAGS for libtool.
     AC_MSG_RESULT([yes])
     NOUNDEFINED=" -no-undefined"
     ;;
     *)
     ## Don't add anything
     AC_MSG_RESULT([no])
     ;;
esac

AC_MSG_CHECKING([value of LIBS])
AC_MSG_RESULT([$LIBS])

# Flags for nc-config script; by design $prefix, $includir, $libdir,
# etc.  are left as shell variables in the script so as to facilitate
# relocation
if test "x$with_netcdf_c_lib" = x ; then
   NC_LIBS="-lnetcdf"
else
   NC_LIBS="$with_netcdf_c_lib"
fi
if test "x$enable_shared" != xyes; then
   NC_LIBS="$LDFLAGS $NC_LIBS $LIBS"
fi

case "x$target_os" in
xsolaris*)
  NEWNCLIBS=""
  for x in $NC_LIBS ; do
    case "$x" in
    -L*) r=`echo "$x" | sed -e 's|^-L|-R|'`
	 NEWNCLIBS="$NEWNCLIBS $x $r"
	 ;;
    *)	 NEWNCLIBS="$NEWNCLIBS $x" ;;
    esac
  done
  NC_LIBS="$NEWNCLIBS"
  ;;
*);;
esac

NC_FLIBS="-lnetcdff $NC_LIBS"


AC_SUBST(NC_LIBS,[$NC_LIBS])
AC_SUBST(HAS_DAP,[$enable_dap])
AC_SUBST(HAS_DAP2,[$enable_dap])
AC_SUBST(HAS_DAP4,[$enable_dap4])
AC_SUBST(HAS_NC2,[$nc_build_v2])
AC_SUBST(HAS_NC4,[$enable_netcdf_4])
AC_SUBST(HAS_CDF5,[$enable_cdf5])
AC_SUBST(HAS_HDF4,[$enable_hdf4])
AC_SUBST(HAS_BENCHMARKS,[$enable_benchmarks])
AC_SUBST(HAS_HDF5,[$enable_hdf5])
AC_SUBST(HAS_PNETCDF,[$enable_pnetcdf])
AC_SUBST(HAS_LOGGING, [$enable_logging])
AC_SUBST(HAS_PARALLEL,[$enable_parallel])
AC_SUBST(HAS_PARALLEL4,[$enable_parallel4])
AC_SUBST(HAS_DISKLESS,[yes])
AC_SUBST(HAS_MMAP,[$enable_mmap])
AC_SUBST(HAS_JNA,[$enable_jna])
AC_SUBST(HAS_ERANGE_FILL,[$enable_erange_fill])
AC_SUBST(HAS_BYTERANGE,[$enable_byterange])
AC_SUBST(RELAX_COORD_BOUND,[yes])
AC_SUBST([HAS_PAR_FILTERS], [$hdf5_supports_par_filters])
AC_SUBST(HAS_NCZARR,[$enable_nczarr])
AC_SUBST(DO_NCZARR_S3_TESTS,[$enable_nczarr_s3_tests])
AC_SUBST(HAS_MULTIFILTERS,[$has_multifilters])
AC_SUBST(DO_NCZARR_ZIP_TESTS,[$enable_nczarr_zip])
AC_SUBST([HAS_QUANTIZE],[yes])
AC_SUBST(HAS_LOGGING,[$enable_logging])
AC_SUBST(DO_FILTER_TESTS,[$enable_filter_testing])
AC_SUBST(HAS_SZLIB,[$have_sz])
AC_SUBST(HAS_SZLIB_WRITE, [$have_sz])
AC_SUBST(HAS_ZSTD,[$have_zstd])

# Always available
std_filters="deflate bz2"
if test "x$enable_szlib" = xyes ; then
std_filters="${std_filters} szip"
fi
# We need to include szip iff HDF5 && HDF5_HAS_SZIP || !HDF5 && NCZARR && libsz
if test "x$enable_hdf5" = xyes && test "x$enable_hdf5_szip" = xyes ; then
  std_filters="${std_filters} szip"
fi
if test "x$enable_hdf5" = xno && test "x$have_sz" = xyes ; then
std_filters="${std_filters} szip"
fi
if test "x$have_blosc" = xyes ; then
std_filters="${std_filters} blosc"
fi
if test "x$have_zstd" = xyes ; then
std_filters="${std_filters} zstd"
fi

AC_SUBST(STD_FILTERS,[$std_filters])

# If user wants, then install selected standard filters
AC_MSG_CHECKING([whether and where we should install plugins])
AC_ARG_WITH([plugin-dir], [AS_HELP_STRING([--with-plugin-dir=<absolute directory>|no|--without-plugin-dir],
              [Install selected standard filters in specified or default directory])],
	      [],[with_plugin_dir=no])
AC_MSG_RESULT([$with_plugin_dir])
if test "x$with_plugin_dir" = xno ; then # option missing|disabled
    with_plugin_dir=no
    with_plugin_dir_setting="N.A."
    enable_plugin_dir=no
elif test "x$with_plugin_dir" = xyes ; then # --with-plugin-dir, no argument
    # Default to last dir (lowest search priority) in HDF5_PLUGIN_PATH
    PLUGIN_PATH="$HDF5_PLUGIN_PATH"
    if test "x${PLUGIN_PATH}" = x ; then
        if test "x$ISMSVC" = xyes || test "x$ISMINGW" = xyes; then
	    PLUGIN_PATH="${ALLUSERSPROFILE}\\hdfd5\\lib\\plugin"
	else
	    PLUGIN_PATH="/usr/local/hdf5/lib/plugin"
	fi
    fi
    # Use the lowest priority dir in the path
    if test "x$ISMSVC" = xyes || test "x$ISMINGW" = xyes; then
      PLUGIN_DIR=`echo "$PLUGIN_PATH" | tr ';' ' '`
    else
      PLUGIN_DIR=`echo "$PLUGIN_PATH" | tr ':' ' '`
    fi
    for pp in ${PLUGIN_DIR} ; do last="$pp"; done
    PLUGIN_DIR="$last"
    with_plugin_dir_setting="$PLUGIN_DIR"
    # canonical form is all forward slashes
    with_plugin_dir=`echo "$PLUGIN_DIR" | tr '\\\\' '/'`
    enable_plugin_dir=yes
    AC_MSG_NOTICE([Defaulting to --with-plugin-dir=$with_plugin_dir])
else # --with-plugin-dir=<dir|path>
    with_plugin_dir_setting="$with_plugin_dir"
    enable_plugin_dir=yes
fi
AM_CONDITIONAL([ENABLE_PLUGIN_DIR], [test "x$enable_plugin_dir" = xyes])
AC_SUBST([PLUGIN_INSTALL_DIR], [$with_plugin_dir])
# Better value for libnetcdf.settings
AC_SUBST([PLUGIN_INSTALL_DIR_SETTING], [$with_plugin_dir_setting])

# Access netcdf specific version of config.h
AH_BOTTOM([#include "ncconfigure.h"])

##################################################
# Uncomment this to keep a copy of autoconf defines at this point, for
# debugging purposes.
# cp confdefs.h my_config.h

#####
# Create output variables from various
# shell variables, for use in generating
# libnetcdf.settings.
#####
AC_SUBST([enable_shared])
AC_SUBST([enable_static])
AC_SUBST([CFLAGS])
AC_SUBST([CPPFLAGS])
AC_SUBST([LDFLAGS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_SUBST([NOUNDEFINED])

# Args:
# 1. netcdf_meta.h variable
# 2. conditional variable that is yes or no.
# 3. default condition
#
# example: AX_SET_META([NC_HAS_NC2],[$nc_build_v2],[]) # Because it checks for no.
#          AX_SET_META([NC_HAS_HDF4],[$enable_hdf4],[yes])
AC_DEFUN([AX_SET_META],[
  if [ test "x$2" = x$3 ]; then
     AC_SUBST([$1]) $1=1
  else
     AC_SUBST([$1]) $1=0
  fi
])

#####
# Define values used in include/netcdf_meta.h
#####
AC_SUBST([NC_VERSION]) NC_VERSION=$VERSION
AX_SET_META([NC_HAS_NC2],[$nc_build_v2],[yes])
AX_SET_META([NC_HAS_NC4],[$enable_netcdf_4],[yes])
AX_SET_META([NC_HAS_HDF4],[$enable_hdf4],[yes])
AX_SET_META([NC_HAS_BENCHMARKS],[$enable_benchmarks],[yes])
AX_SET_META([NC_HAS_HDF5],[$enable_hdf5],[yes])
AX_SET_META([NC_HAS_DAP2],[$enable_dap],[yes])
AX_SET_META([NC_HAS_DAP4],[$enable_dap4],[yes])
AX_SET_META([NC_HAS_DISKLESS],[yes],[yes])
AX_SET_META([NC_HAS_MMAP],[$enable_mmap],[yes])
AX_SET_META([NC_HAS_JNA],[$enable_jna],[yes])
AX_SET_META([NC_HAS_PNETCDF],[$enable_pnetcdf],[yes])
AX_SET_META([NC_HAS_PARALLEL],[$enable_parallel],[yes])
AX_SET_META([NC_HAS_PARALLEL4],[$enable_parallel4],[yes])
AX_SET_META([NC_HAS_CDF5],[$enable_cdf5],[yes])
AX_SET_META([NC_HAS_ERANGE_FILL], [$enable_erange_fill],[yes])
AX_SET_META([NC_HAS_PAR_FILTERS], [$hdf5_supports_par_filters],[yes])
AX_SET_META([NC_HAS_BYTERANGE],[$enable_byterange],[yes])
AX_SET_META([NC_HAS_NCZARR],[$enable_nczarr],[yes])
AX_SET_META([NC_HAS_MULTIFILTERS],[$has_multifilters],[yes])
AX_SET_META([NC_HAS_LOGGING],[$enable_logging],[yes])
AX_SET_META([NC_HAS_QUANTIZE],[yes],[yes])
AX_SET_META([NC_HAS_SZIP],[$enable_hdf5_szip],[yes])
AX_SET_META([NC_HAS_ZSTD],[$have_zstd],[yes])

# This is the version of the dispatch table. If the dispatch table is
# changed, this should be incremented, so that user-defined format
# applications like PIO can determine whether they have an appropriate
# dispatch table to submit. If this is changed, make sure the value in
# CMakeLists.txt also changes to match.

AC_SUBST([NC_DISPATCH_VERSION], [5])
AC_DEFINE_UNQUOTED([NC_DISPATCH_VERSION], [${NC_DISPATCH_VERSION}], [Dispatch table version.])

#####
# End netcdf_meta.h definitions.
#####

# This would be true for a cmake build.
AC_SUBST([ISCMAKE], [])

# Provide  conditional to temporarily suppress tests and such
AM_CONDITIONAL([AX_IGNORE], [test xno = xyes])

AC_MSG_NOTICE([generating header files and makefiles])
AC_CONFIG_FILES(test_common.sh:test_common.in)
AC_CONFIG_FILES(nc_test4/findplugin.sh:nc_test4/findplugin.in)
AC_CONFIG_FILES(nczarr_test/findplugin.sh:nc_test4/findplugin.in)
AC_CONFIG_FILES(plugins/findplugin.sh:nc_test4/findplugin.in)
AC_CONFIG_FILES(examples/C/findplugin.sh:nc_test4/findplugin.in)
AC_CONFIG_FILES(ncdap_test/findtestserver.c:ncdap_test/findtestserver.c.in)
AC_CONFIG_FILES([nc_test/run_pnetcdf_tests.sh:nc_test/run_pnetcdf_tests.sh.in],[chmod ugo+x nc_test/run_pnetcdf_tests.sh])
AC_CONFIG_FILES(dap4_test/findtestserver4.c:ncdap_test/findtestserver.c.in)
AC_CONFIG_FILES(dap4_test/pingurl4.c:ncdap_test/pingurl.c)
AC_CONFIG_FILES([h5_test/run_par_tests.sh], [chmod ugo+x h5_test/run_par_tests.sh])
AC_CONFIG_FILES([nc_test4/run_par_test.sh], [chmod ugo+x nc_test4/run_par_test.sh])
AC_CONFIG_FILES([nc_perf/run_par_bm_test.sh], [chmod ugo+x nc_perf/run_par_bm_test.sh])
AC_CONFIG_FILES([nc_perf/run_gfs_test.sh], [chmod ugo+x nc_perf/run_gfs_test.sh])
AC_CONFIG_FILES(nczarr_test/timer_utils.h:unit_test/timer_utils.h)
AC_CONFIG_FILES(nczarr_test/timer_utils.c:unit_test/timer_utils.c)
AC_CONFIG_FILES(nczarr_test/test_filter.c:nc_test4/test_filter.c)
AC_CONFIG_FILES(nczarr_test/test_filter_misc.c:nc_test4/test_filter_misc.c)
AC_CONFIG_FILES(nczarr_test/tst_multifilter.c:nc_test4/tst_multifilter.c)
AC_CONFIG_FILES(nczarr_test/test_filter_repeat.c:nc_test4/test_filter_repeat.c)
AC_CONFIG_FILES(nczarr_test/test_filter_order.c:nc_test4/test_filter_order.c)
AC_CONFIG_FILES([examples/C/run_par_test.sh], [chmod ugo+x examples/C/run_par_test.sh])
AC_CONFIG_FILES([nc-config], [chmod 755 nc-config])
AC_CONFIG_FILES([Makefile
                 netcdf.pc
                 libnetcdf.settings
                 postinstall.sh
                 include/netcdf_meta.h
                 include/netcdf_dispatch.h
                 include/Makefile
                 h5_test/Makefile
                 hdf4_test/Makefile
                 libsrc/Makefile
                 libsrc4/Makefile
                 libhdf5/Makefile
                 libsrcp/Makefile
                 ncdump/Makefile
                 ncgen3/Makefile
                 ncgen/Makefile
                 examples/Makefile
                 examples/C/Makefile
                 examples/CDL/Makefile
                 oc2/Makefile
                 libdap2/Makefile
                 libdap4/Makefile
                 libhdf4/Makefile
                 libnczarr/Makefile
                 libncpoco/Makefile
                 libncxml/Makefile
                 libdispatch/Makefile
                 liblib/Makefile
                 ncdump/cdl/Makefile
                 ncdump/expected/Makefile
                 docs/Makefile
                 docs/images/Makefile
                 unit_test/Makefile
                 nctest/Makefile
                 nc_test4/Makefile
                 nc_perf/Makefile
                 nc_test/Makefile
                 ncdap_test/Makefile
                 ncdap_test/testdata3/Makefile
                 ncdap_test/expected3/Makefile
                 ncdap_test/expectremote3/Makefile
                 dap4_test/Makefile
                 plugins/Makefile
		 nczarr_test/Makefile
                 ])
AC_OUTPUT()

cat libnetcdf.settings