1#                                               -*- Autoconf -*-
2## Process this file with autoconf to produce a configure script.
3
4# This is part of Unidata's netCDF package. Copyright 2005-2018, see
5# the COPYRIGHT file for more information.
6# Ed Hartnett, Ward Fisher, Dennis Heimbigner
7
8# Running autoconf on this file will trigger a warning if
9# autoconf is not at least the specified version.
10AC_PREREQ([2.59])
11
12# Initialize with name, version, and support email address.
13AC_INIT([netCDF], [4.7.4], [support-netcdf@unidata.ucar.edu], [netcdf-c])
14
15##
16# Prefer an empty CFLAGS variable instead of the default -g -O2.
17# See:
18#   * http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/C-Compiler.html#C-Compiler
19##
20: ${CFLAGS=""}
21
22AC_SUBST([NC_VERSION_MAJOR]) NC_VERSION_MAJOR=4
23AC_SUBST([NC_VERSION_MINOR]) NC_VERSION_MINOR=7
24AC_SUBST([NC_VERSION_PATCH]) NC_VERSION_PATCH=4
25AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE=""
26
27#####
28# Set some variables used to generate a libnetcdf.settings file,
29# pattered after the files generated by libhdf4, libhdf5.
30#####
31
32# Create the VERSION file, which contains the package version from
33# AC_INIT.
34echo AC_PACKAGE_VERSION>VERSION
35AC_SUBST(PACKAGE_VERSION)
36
37AC_MSG_NOTICE([netCDF AC_PACKAGE_VERSION])
38
39# Keep libtool macros in an m4 directory.
40AC_CONFIG_MACRO_DIR([m4])
41
42# Configuration Date
43if test "x$SOURCE_DATE_EPOCH" != "x" ; then
44    AC_SUBST([CONFIG_DATE]) CONFIG_DATE="`date -u -d "${SOURCE_DATE_EPOCH}"`"
45else
46    AC_SUBST([CONFIG_DATE]) CONFIG_DATE="`date`"
47fi
48
49# Find out about the host we're building on.
50AC_CANONICAL_HOST
51
52# Find out about the target we're building for.
53AC_CANONICAL_TARGET
54
55AC_CONFIG_HEADERS([config.h])
56
57##
58# Some files need to exist in build directories
59# that do not correspond to their source directory, or
60# the test program makes an assumption about where files
61# live.  AC_CONFIG_LINKS provides a mechanism to link/copy files
62# if an out-of-source build is happening.
63##
64
65AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat1.nc:nc_test4/ref_hdf5_compat1.nc])
66AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat2.nc:nc_test4/ref_hdf5_compat2.nc])
67AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat3.nc:nc_test4/ref_hdf5_compat3.nc])
68
69AC_CONFIG_LINKS([hdf4_test/ref_chunked.hdf4:hdf4_test/ref_chunked.hdf4])
70AC_CONFIG_LINKS([hdf4_test/ref_contiguous.hdf4:hdf4_test/ref_contiguous.hdf4])
71
72AM_INIT_AUTOMAKE([foreign dist-zip subdir-objects])
73AM_MAINTAINER_MODE()
74
75# Check for the existence of this file before proceeding.
76AC_CONFIG_SRCDIR([include/netcdf.h])
77
78AC_MSG_NOTICE([checking user options])
79
80# Did the user specify a default minimum blocksize (NCIO_MINBLOCKSIZE) for posixio?
81AC_MSG_CHECKING([whether a NCIO_MINBLOCKSIZE was specified])
82AC_ARG_WITH([minblocksize],
83              [AS_HELP_STRING([--with-minblocksize=<integer>],
84                              [Specify minimum I/O blocksize for netCDF classic and 64-bit offset format files.])],
85            [NCIO_MINBLOCKSIZE=$with_minblocksize], [NCIO_MINBLOCKSIZE=256])
86AC_MSG_RESULT([$NCIO_MINBLOCKSIZE])
87AC_DEFINE_UNQUOTED([NCIO_MINBLOCKSIZE], [$NCIO_MINBLOCKSIZE], [min blocksize for posixio.])
88
89# Find valgrind, if available, and add targets for it.
90AX_VALGRIND_DFLT([sgcheck], [off])
91AX_VALGRIND_CHECK
92AM_CONDITIONAL(ENABLE_VALGRIND, [test "x$VALGRIND_ENABLED" = xyes])
93
94###
95# Doxygen and doxygen-related options.
96###
97AC_ARG_ENABLE([doxygen],
98  [AS_HELP_STRING([--enable-doxygen],
99    [Enable generation of documentation.])])
100test "x$enable_doxygen" = xyes || enable_doxygen=no
101AM_CONDITIONAL([BUILD_DOCS], [test "x$enable_doxygen" = xyes])
102
103AC_ARG_ENABLE([doxygen-tasks],
104    [AS_HELP_STRING([--enable-doxygen-tasks],
105        [Enable Doxygen-generated test, todo and bug list documentation. Developers only.])])
106test "x$enable_doxygen_tasks" = xyes || enable_doxygen_tasks=no
107AM_CONDITIONAL([SHOW_DOXYGEN_TAG_LIST], [test "x$enable_doxygen_tasks" = xyes])
108AC_SUBST([SHOW_DOXYGEN_TAG_LIST], [$enable_doxygen_tasks])
109
110###
111# Determine if we should build documentation
112# configured for releases on the Unidata web server.
113###
114AC_ARG_ENABLE([doxygen-build-release-docs],
115    [AS_HELP_STRING([--enable-doxygen-build-release-docs],
116        [Build release documentation.  This is of interest only to developers.])])
117test "x$enable_doxygen_build_release_docs" = xyes || enable_doxygen_build_release_docs=no
118AM_CONDITIONAL([DOXYGEN_BUILD_RELEASE_DOCS], [test "x$enable_doxygen_build_release_docs" = xyes])
119
120if test $enable_doxygen_build_release_docs = yes; then
121   AC_SUBST([DOXYGEN_CSS_FILE], ["release.css"])
122   AC_SUBST([DOXYGEN_HEADER_FILE], ["release_header.html"])
123   AC_SUBST([DOXYGEN_SEARCHENGINE], ["NO"])
124else
125   AC_SUBST([DOXYGEN_CSS_FILE], [])
126   AC_SUBST([DOXYGEN_HEADER_FILE], [])
127   AC_SUBST([DOXYGEN_SEARCHENGINE], ["YES"])
128fi
129AC_SUBST([DOXYGEN_SERVER_BASED_SEARCH], ["NO"])
130
131AC_ARG_ENABLE([doxygen-pdf-output],
132    [AS_HELP_STRING([--enable-doxygen-pdf-output],
133        [Build netCDF library documentation in PDF format. Experimental.])])
134               AM_CONDITIONAL([NC_ENABLE_DOXYGEN_PDF_OUTPUT], [test "x$enable_doxygen_pdf_output" = xyes])
135AC_SUBST([NC_ENABLE_DOXYGEN_PDF_OUTPUT], [$enable_doxygen_pdf_output])
136
137AC_ARG_ENABLE([dot],
138	[AS_HELP_STRING([--enable-dot],
139	[Use dot (provided by graphviz) to generate charts and graphs in the doxygen-based documentation.])])
140	test "x$enable_dot" = xyes || enable_dot=no
141
142AC_ARG_ENABLE([internal-docs],
143  [AS_HELP_STRING([--enable-internal-docs],
144    [Include documentation of library internals. This is of interest only to those developing the netCDF library.])])
145test "x$enable_internal_docs" = xyes || enable_internal_docs=no
146AC_SUBST([BUILD_INTERNAL_DOCS], [$enable_internal_docs])
147
148# Doxygen is apparently buggy when trying to combine a markdown
149# file with @internal. The equivalent can be faked using
150# the Doxygen ENABLED_SECTIONS mechanism. See docs/testserver.dox
151# to see how this is done.
152sections=
153if test "x$enable_internal_docs" = xyes ; then
154sections="$sections INTERNAL"
155fi
156AC_SUBST([ENABLED_DOC_SECTIONS], [$sections])
157
158AC_MSG_CHECKING([if fsync support is enabled])
159AC_ARG_ENABLE([fsync],
160              [AS_HELP_STRING([--enable-fsync],
161                              [enable fsync support])],
162				[],
163				[enable_fsync=no])
164test "x$enable_fsync" = xno || enable_fsync=yes
165AC_MSG_RESULT($enable_fsync)
166if test "x$enable_fsync" = xyes ; then
167AC_DEFINE([USE_FSYNC], [1], [if true, include experimental fsync code])
168fi
169
170# Temporary until JNA bug is fixed (which is probably never).
171# The problem being solved is this:
172# > On Windows using the microsoft runtime, it is an error
173# > for one library to free memory allocated by a different library.
174# This is probably only an issue when using the netcdf-c library
175# via JNA under Java.
176AC_MSG_CHECKING([if jna bug workaround is enabled])
177AC_ARG_ENABLE([jna],
178              [AS_HELP_STRING([--enable-jna],
179                              [enable jna bug workaround])],
180				[],
181				[enable_jna=no])
182test "x$enable_jna" = xno || enable_jna=yes
183AC_MSG_RESULT($enable_jna)
184if test "x$enable_jna" = xyes ; then
185AC_DEFINE([JNA], [1], [if true, include jna bug workaround code])
186fi
187
188# Does the user want to turn off unit tests (useful for test coverage
189# analysis).
190AC_ARG_ENABLE([unit-tests],
191  [AS_HELP_STRING([--disable-unit-tests],
192    [Disable tests in unit_test directory. Other tests still run.])])
193test "x$enable_unit_tests" = xno || enable_unit_tests=yes
194AM_CONDITIONAL([BUILD_UNIT_TESTS], [test "x$enable_unit_tests" = xyes])
195
196# Does the user want to build netcdf-4?
197AC_MSG_CHECKING([whether we should build netCDF-4])
198AC_ARG_ENABLE([netcdf-4], [AS_HELP_STRING([--disable-netcdf-4],
199              [do not build with netcdf-4 (else HDF5 and zlib required)])])
200test "x$enable_netcdf_4" = xno || enable_netcdf_4=yes
201
202# Synonym
203AC_ARG_ENABLE([netcdf4], [AS_HELP_STRING([--disable-netcdf4],
204              [(just a synonym for --disable-netcdf-4)])])
205test "x$enable_netcdf4" = xno || enable_netcdf4=yesi
206if test "x$enable_netcdf4" = xno ; then
207enable_netcdf_4=no
208fi
209AC_MSG_RESULT([$enable_netcdf_4])
210
211# Does the user want to use HDF5?
212# WARNING: enable_hdf5 does not imply that use_netcdf_4 is enabled
213AC_MSG_CHECKING([whether we should build with HDF5])
214#enable_hdf5=$enable_netcdf_4
215AC_ARG_ENABLE([hdf5], [AS_HELP_STRING([--disable-hdf5],
216              [do not build with HDF5])])
217test "x$enable_hdf5" = xno || enable_hdf5=yes
218if test "x$enable_netcdf_4" = xno ; then
219enable_hdf5=no
220fi
221AC_MSG_RESULT([$enable_hdf5])
222
223# Does the user require dynamic loading?
224# This is only for those hdf5 installs that support it.
225AC_MSG_CHECKING([do we require hdf5 dynamic-loading support])
226AC_ARG_ENABLE([dynamic-loading], [AS_HELP_STRING([--enable-dynamic-loading],
227				 [enable dynamic loading for use with supported hdf5 installs (libdl, HDF5 required)])])
228test "x$enable_dynamic_loading" = xno || enable_dynamic_loading=yes
229AC_MSG_RESULT([$enable_dynamic_loading])
230
231# Does the user want to turn on HDF4 read ability?
232AC_MSG_CHECKING([whether reading of HDF4 SD files is to be enabled])
233AC_ARG_ENABLE([hdf4], [AS_HELP_STRING([--enable-hdf4],
234              [build netcdf-4 with HDF4 read capability (HDF4, HDF5 and zlib required)])])
235test "x$enable_hdf4" = xyes || enable_hdf4=no
236if test "x$enable_hdf4" = xyes -a "x$enable_netcdf_4" = xno; then
237      AC_MSG_ERROR([NetCDF-4 is required for HDF4 features])
238fi
239AC_MSG_RESULT($enable_hdf4)
240
241# Does the user want to turn on extra HDF4 file tests?
242AC_MSG_CHECKING([whether to fetch some sample HDF4 files from Unidata ftp site to test HDF4 reading (requires wget)])
243AC_ARG_ENABLE([hdf4-file-tests], [AS_HELP_STRING([--enable-hdf4-file-tests],
244              [get some HDF4 files from Unidata ftp site and test that they can be read])])
245test "x$enable_hdf4" = xyes -a "x$enable_hdf4_file_tests" = xyes || enable_hdf4_file_tests=no
246if test "x$enable_hdf4_file_tests" = xyes; then
247   AC_DEFINE([USE_HDF4_FILE_TESTS], 1, [If true, use use wget to fetch some sample HDF4 data, and then test against it.])
248fi
249AC_MSG_RESULT($enable_hdf4_file_tests)
250
251# Does the user want to try to install netcdf-fortran
252# automatically?
253AC_MSG_CHECKING([whether we should attempt to install netcdf-fortran (EXPERIMENTAL)])
254AC_ARG_ENABLE([remote-fortran-bootstrap], [AS_HELP_STRING([--enable-remote-fortran-bootstrap],
255			 [Download and install netcdf-fortran (EXPERIMENTAL)])])
256test "x$enable_remote_fortran_bootstrap" = xyes || enable_remote_fortran_bootstrap=no
257AC_MSG_RESULT([$enable_remote_fortran_bootstrap])
258
259# Does the user want to run extra parallel tests when parallel netCDF-4 is built?
260AC_MSG_CHECKING([whether parallel IO tests should be run])
261AC_ARG_ENABLE([parallel-tests],
262              [AS_HELP_STRING([--enable-parallel-tests],
263                              [Run extra parallel IO tests. Requires netCDF-4
264                              with parallel I/O support.])])
265test "x$enable_parallel_tests" = xyes || enable_parallel_tests=no
266AC_MSG_RESULT($enable_parallel_tests)
267
268# Did the user specify an MPI launcher other than mpiexec?
269AC_MSG_CHECKING([whether a user specified program to run mpi programs])
270AC_ARG_WITH([mpiexec],
271              [AS_HELP_STRING([--with-mpiexec=<command>],
272                              [Specify command to launch MPI parallel tests.])],
273            [MPIEXEC=$with_mpiexec], [MPIEXEC=mpiexec])
274AC_MSG_RESULT([$MPIEXEC])
275AC_SUBST([MPIEXEC], [$MPIEXEC])
276
277# Did the user specify a default chunk size?
278AC_MSG_CHECKING([whether a default chunk size in bytes was specified])
279AC_ARG_WITH([default-chunk-size],
280              [AS_HELP_STRING([--with-default-chunk-size=<integer>],
281                              [Specify default size of chunks in bytes.])],
282            [DEFAULT_CHUNK_SIZE=$with_default_chunk_size], [DEFAULT_CHUNK_SIZE=4194304])
283AC_MSG_RESULT([$DEFAULT_CHUNK_SIZE])
284AC_DEFINE_UNQUOTED([DEFAULT_CHUNK_SIZE], [$DEFAULT_CHUNK_SIZE], [default chunk size in bytes])
285
286# Did the user specify a max per-var cache size?
287AC_MSG_CHECKING([whether a maximum per-variable cache size for HDF5 was specified])
288AC_ARG_WITH([max-default-cache-size],
289              [AS_HELP_STRING([--with-max-default-cache-size=<integer>],
290                              [Specify maximum size (in bytes) for the default per-var chunk cache.])],
291            [MAX_DEFAULT_CACHE_SIZE=$with_max_default_cache_size], [MAX_DEFAULT_CACHE_SIZE=67108864])
292AC_MSG_RESULT([$MAX_DEFAULT_CACHE_SIZE])
293AC_DEFINE_UNQUOTED([MAX_DEFAULT_CACHE_SIZE], [$MAX_DEFAULT_CACHE_SIZE], [max size of the default per-var chunk cache.])
294
295# Did the user specify a number of chunks in default per-var cache size?
296AC_MSG_CHECKING([whether a number of chunks for the default per-variable cache was specified])
297AC_ARG_WITH([default-chunks-in-cache],
298              [AS_HELP_STRING([--with-default-chunks-in-cache=<integer>],
299                              [Specify the number of chunks to store in default per-variable cache.])],
300            [DEFAULT_CHUNKS_IN_CACHE=$with_default_chunks_in_cache], [DEFAULT_CHUNKS_IN_CACHE=10])
301AC_MSG_RESULT([$DEFAULT_CHUNKS_IN_CACHE])
302AC_DEFINE_UNQUOTED([DEFAULT_CHUNKS_IN_CACHE], [$DEFAULT_CHUNKS_IN_CACHE], [num chunks in default per-var chunk cache.])
303
304# Did the user specify a default cache size?
305AC_MSG_CHECKING([whether a default file cache size for HDF5 was specified])
306AC_ARG_WITH([chunk-cache-size],
307              [AS_HELP_STRING([--with-chunk-cache-size=<integer>],
308                              [Specify default file cache chunk size for HDF5 files in bytes.])],
309            [CHUNK_CACHE_SIZE=$with_chunk_cache_size], [CHUNK_CACHE_SIZE=16777216])
310AC_MSG_RESULT([$CHUNK_CACHE_SIZE])
311AC_DEFINE_UNQUOTED([CHUNK_CACHE_SIZE], [$CHUNK_CACHE_SIZE], [default file chunk cache size in bytes.])
312
313# Did the user specify a default cache nelems?
314AC_MSG_CHECKING([whether a default file cache maximum number of elements for HDF5 was specified])
315AC_ARG_WITH([chunk-cache-nelems],
316              [AS_HELP_STRING([--with-chunk-cache-nelems=<integer>],
317                              [Specify default maximum number of elements in the file chunk cache chunk for HDF5 files (should be prime number).])],
318            [CHUNK_CACHE_NELEMS=$with_chunk_cache_nelems], [CHUNK_CACHE_NELEMS=4133])
319AC_MSG_RESULT([$CHUNK_CACHE_NELEMS])
320AC_DEFINE_UNQUOTED([CHUNK_CACHE_NELEMS], [$CHUNK_CACHE_NELEMS], [default file chunk cache nelems.])
321
322# Did the user specify a default cache preemption?
323AC_MSG_CHECKING([whether a default cache preemption for HDF5 was specified])
324AC_ARG_WITH([chunk-cache-preemption],
325              [AS_HELP_STRING([--with-chunk-cache-preemption=<float between 0 and 1 inclusive>],
326                              [Specify default file chunk cache preemption policy for HDF5 files (a number between 0 and 1, inclusive).])],
327            [CHUNK_CACHE_PREEMPTION=$with_chunk_cache_preemption], [CHUNK_CACHE_PREEMPTION=0.75])
328AC_MSG_RESULT([$CHUNK_CACHE_PREEMPTION])
329AC_DEFINE_UNQUOTED([CHUNK_CACHE_PREEMPTION], [$CHUNK_CACHE_PREEMPTION], [default file chunk cache preemption policy.])
330
331# Does the user want to enable netcdf-4 logging?
332AC_MSG_CHECKING([whether netCDF-4 logging is enabled])
333AC_ARG_ENABLE([logging],
334              [AS_HELP_STRING([--enable-logging],
335                              [enable logging capability (only applies when netCDF-4 is built). \
336			      This debugging features is only of interest to netCDF developers. \
337			      Ignored if netCDF-4 is not enabled.])])
338test "x$enable_logging" = xyes || enable_logging=no
339AC_MSG_RESULT([$enable_logging])
340
341# Does the user want to turn off nc_set_log_level() function? (It will
342# always be defined if --enable-logging is used.)
343AC_MSG_CHECKING([whether nc_set_log_level() function is included (will do nothing unless enable-logging is also used)])
344AC_ARG_ENABLE([set_log_level_func], [AS_HELP_STRING([--disable-set-log-level-func],
345              [disable the nc_set_log_level function])])
346test "x$enable_set_log_level_func" = xno -a "x$enable_logging" = xno || enable_set_log_level_func=yes
347if test "x$enable_set_log_level_func" = xyes -a "x$enable_netcdf_4" = xyes; then
348   AC_DEFINE([ENABLE_SET_LOG_LEVEL], 1, [If true, define nc_set_log_level.])
349fi
350AC_MSG_RESULT($enable_set_log_level_func)
351
352## Capture the state of the --enable-dap flag => enable dap2+dap4
353AC_MSG_CHECKING([whether DAP client(s) are to be built])
354AC_ARG_ENABLE([dap],
355                 [AS_HELP_STRING([--disable-dap],
356                                 [build without DAP client support.])])
357test "x$enable_dap" = xno || enable_dap=yes
358AC_MSG_RESULT($enable_dap)
359
360# We need curl for DAP and byterange
361AC_CHECK_LIB([curl],[curl_easy_setopt],[found_curl=yes],[found_curl=no])
362if test "x$enable_dap" = "xyes" ; then
363   AC_SEARCH_LIBS([curl_easy_setopt],[curl curl.dll], [],
364      [AC_MSG_ERROR([curl required for remote access. Install curl or build with --disable-dap.])])
365fi
366
367# --enable-dap => enable-dap4
368enable_dap4=$enable_dap
369# Default is to do the short remote tests.
370# Temporary: Change default to npt do these tests
371AC_MSG_CHECKING([whether dap remote testing should be enabled (default on)])
372AC_ARG_ENABLE([dap-remote-tests],
373              [AS_HELP_STRING([--disable-dap-remote-tests],
374                                 [disable dap remote tests])])
375test "x$enable_dap_remote_tests" = xyes || enable_dap_remote_tests=no
376if test "x$enable_dap" = "xno" ; then
377  enable_dap_remote_tests=no
378fi
379AC_MSG_RESULT($enable_dap_remote_tests)
380
381# Default is not to do the remote authorization tests.
382AC_MSG_CHECKING([whether dap remote authorization testing should be enabled (default off)])
383AC_ARG_ENABLE([dap-auth-tests],
384              [AS_HELP_STRING([--enable-dap-auth-tests],
385                                 [enable dap remote authorization tests])])
386test "x$enable_dap_auth_tests" = xyes || enable_dap_auth_tests=no
387# dap must be enabled
388if test "x$enable_dap" = "xno" ; then
389  enable_dap_auth_tests=no
390fi
391# if remote tests are disabled, then so is this
392if test "x$enable_dap_remote_tests" = "xno" ; then
393  enable_dap_remote_tests=no
394fi
395AC_MSG_RESULT($enable_dap_auth_tests)
396
397# Did the user specify a list of test servers to try for remote tests?
398AC_MSG_CHECKING([which remote test server(s) to use])
399AC_ARG_WITH([testservers],
400              [AS_HELP_STRING([--with-testservers=<host:port>,<host:port>...],
401                              [Specify the testserver(s) to try for remote tests.])],
402            [REMOTETESTSERVERS=$with_testservers], [REMOTETESTSERVERS=no])
403msg="$REMOTETESTSERVERS"
404if test "x$REMOTETESTSERVERS" = xno ; then
405  svclist="remotetest.unidata.ucar.edu"
406  REMOTETESTSERVERS="$svclist"
407fi
408AC_MSG_RESULT([$svclist])
409AC_DEFINE_UNQUOTED([REMOTETESTSERVERS], ["$REMOTETESTSERVERS"], [the testservers for remote tests.])
410
411# Set the config.h flags
412if test "x$enable_dap" = xyes; then
413   AC_DEFINE([USE_DAP], [1], [if true, build DAP Client])
414   AC_DEFINE([ENABLE_DAP], [1], [if true, build DAP Client])
415fi
416
417if test "x$enable_dap_remote_tests" = xyes; then
418   AC_DEFINE([ENABLE_DAP_REMOTE_TESTS], [1], [if true, do remote tests])
419fi
420
421AC_MSG_CHECKING([whether the time-consuming dap tests should be enabled (default off)])
422AC_ARG_ENABLE([dap-long-tests],
423              [AS_HELP_STRING([--enable-dap-long-tests],
424                                 [enable dap long tests])])
425test "x$enable_dap_long_tests" = xyes || enable_dap_long_tests=no
426if test "x$enable_dap_remote_tests" = "xno" ; then
427  enable_dap_long_tests=no
428fi
429AC_MSG_RESULT([$enable_dap_long_tests])
430
431AM_CONDITIONAL(INTERNAL_OCLIB,[test "x" = "x"])
432
433# Check whether we want to enable strict null byte header padding.
434# See https://github.com/Unidata/netcdf-c/issues/657 for more information.
435AC_MSG_CHECKING([whether to enable strict null-byte header padding when reading (default off)])
436AC_ARG_ENABLE([strict-null-byte-header-padding],
437    [AS_HELP_STRING([--enable-strict-null-byte-header-padding],
438                    [enable strict null-byte header padding when reading netCDF3 files.])])
439test "x$enable_strict_null_byte_header_padding" = xyes || enable_strict_null_byte_header_padding=no
440AC_MSG_RESULT($enable_strict_null_byte_header_padding)
441
442if test "x$enable_strict_null_byte_header_padding" = xyes; then
443   AC_DEFINE([USE_STRICT_NULL_BYTE_HEADER_PADDING], [1], [if true, enable strict null byte header padding])
444fi
445
446AM_CONDITIONAL(USE_STRICT_NULL_BYTE_HEADER_PADDING, [test x$enable_strict_null_byte_header_padding = xyes ])
447
448# Does the user want to use the ffio module?
449AC_MSG_CHECKING([whether FFIO will be used])
450AC_ARG_ENABLE([ffio],
451              [AS_HELP_STRING([--enable-ffio],
452                              [use ffio instead of posixio (ex. on the Cray)])])
453test "x$enable_ffio" = xyes || enable_ffio=no
454AC_MSG_RESULT($enable_ffio)
455if test "x$enable_ffio" = xyes; then
456   AC_DEFINE([USE_FFIO], [1], [if true, use ffio instead of posixio])
457fi
458AM_CONDITIONAL(USE_FFIO, [test x$enable_ffio = xyes])
459
460# Does the user want to use the stdio module?
461AC_MSG_CHECKING([whether STDIO will be used])
462AC_ARG_ENABLE([stdio],
463              [AS_HELP_STRING([--enable-stdio],
464                              [use stdio instead of posixio (ex. on the Cray)])])
465test "x$enable_stdio" = xyes || enable_stdio=no
466AC_MSG_RESULT($enable_stdio)
467if test "x$enable_stdio" = xyes; then
468   AC_DEFINE([USE_STDIO], [1], [if true, use stdio instead of posixio])
469fi
470AM_CONDITIONAL(USE_STDIO, [test x$enable_stdio = xyes])
471
472nc_build_c=yes
473nc_build_v2=yes
474nc_build_utilities=yes
475nc_build_tests=yes
476nc_build_examples=yes
477
478# Does the user want to build examples?
479AC_MSG_CHECKING([whether examples should be built])
480AC_ARG_ENABLE([examples],
481              [AS_HELP_STRING([--disable-examples],
482                              [don't build the netCDF examples during make check \
483                              (examples are treated as extra tests by netCDF)])])
484test "x$enable_examples" = xno && nc_build_examples=no
485AC_MSG_RESULT($nc_build_examples)
486AM_CONDITIONAL(BUILD_EXAMPLES, [test x$nc_build_examples = xyes])
487
488# Does the user want to disable the V2 API?
489AC_MSG_CHECKING([whether v2 netCDF API should be built])
490AC_ARG_ENABLE([v2],
491              [AS_HELP_STRING([--disable-v2],
492                              [turn off the netCDF version 2 API])])
493test "x$enable_v2" = xno && nc_build_v2=no
494AC_MSG_RESULT($nc_build_v2)
495AM_CONDITIONAL(BUILD_V2, [test x$nc_build_v2 = xyes])
496if test "x$nc_build_v2" = xno; then
497   AC_DEFINE_UNQUOTED(NO_NETCDF_2, 1, [do not build the netCDF version 2 API])
498else
499   AC_DEFINE_UNQUOTED(USE_NETCDF_2, 1, [build the netCDF version 2 API])
500fi
501
502# Does the user want to disable ncgen/ncdump/nccopy?
503AC_MSG_CHECKING([whether the ncgen/ncdump/nccopy should be built])
504AC_ARG_ENABLE([utilities],
505              [AS_HELP_STRING([--disable-utilities],
506                              [don't build netCDF utilities ncgen, ncdump, and nccopy])])
507test "x$nc_build_c" = xno && enable_utilities=no
508test "x$enable_utilities" = xno && nc_build_utilities=no
509AC_MSG_RESULT($nc_build_utilities)
510AM_CONDITIONAL(BUILD_UTILITIES, [test x$nc_build_utilities = xyes])
511
512# Does the user want to disable all tests?
513AC_MSG_CHECKING([whether test should be built and run])
514AC_ARG_ENABLE([testsets],
515              [AS_HELP_STRING([--disable-testsets],
516                              [don't build or run netCDF tests])])
517test "x$enable_testsets" = xno || enable_testsets=yes
518nc_build_tests=$enable_testsets
519AC_MSG_RESULT($nc_build_tests)
520AM_CONDITIONAL(BUILD_TESTSETS, [test x$nc_build_tests = xyes])
521
522# Does the user want to run tests for large files (> 2GiB)?
523AC_MSG_CHECKING([whether large file (> 2GB) tests should be run])
524AC_ARG_ENABLE([large-file-tests],
525              [AS_HELP_STRING([--enable-large-file-tests],
526                              [Run tests which create very large data files (~13 GB disk space
527                              required, but it will be recovered when tests are complete). See
528                              option --with-temp-large to specify temporary directory])])
529test "x$enable_large_file_tests" = xyes || enable_large_file_tests=no
530AC_MSG_RESULT($enable_large_file_tests)
531AM_CONDITIONAL(LARGE_FILE_TESTS, [test x$enable_large_file_tests = xyes])
532if test "x$enable_large_file_tests" = xyes; then
533   AC_DEFINE([LARGE_FILE_TESTS], [1], [do large file tests])
534fi
535
536# Does the user want to run benchmarks?
537AC_MSG_CHECKING([whether benchmarks should be run])
538AC_ARG_ENABLE([benchmarks],
539              [AS_HELP_STRING([--enable-benchmarks],
540                              [Run benchmarks. This will cause sample data files from the Unidata ftp
541                              site to be fetched. The benchmarks are a bunch of extra tests, which
542                              are timed. We use these tests to check netCDF performance.])])
543test "x$enable_benchmarks" = xyes || enable_benchmarks=no
544AC_MSG_RESULT($enable_benchmarks)
545if test "x$enable_netcdf4" = xno -a "x$enable_benchmarks" = xyes; then
546AC_MSG_ERROR([Can't use benchmarks if netCDF-4 is disabled.])
547fi
548AM_CONDITIONAL(BUILD_BENCHMARKS, [test x$enable_benchmarks = xyes])
549
550# Does the user want to use extreme numbers in testing.
551AC_MSG_CHECKING([whether extreme numbers should be used in tests])
552AC_ARG_ENABLE([extreme-numbers],
553              [AS_HELP_STRING([--disable-extreme-numbers],
554                              [don't use extreme numbers during testing, such as MAX_INT - 1])])
555case "$host_cpu $host_os" in
556     *386*solaris*)
557        test "x$enable_extreme_numbers" = xyes || enable_extreme_numbers=no
558        ;;
559     *)
560        test "x$enable_extreme_numbers" = xno || enable_extreme_numbers=yes
561        ;;
562esac
563AC_MSG_RESULT($enable_extreme_numbers)
564
565if test "x$enable_extreme_numbers" = xyes; then
566   AC_DEFINE(USE_EXTREME_NUMBERS, 1, [set this to use extreme numbers in tests])
567fi
568
569# If the env. variable TEMP_LARGE is set, or if
570# --with-temp-large=<directory>, use it as a place for the large
571# (i.e. > 2 GiB) files created during the large file testing.
572AC_MSG_CHECKING([where to put large temp files if large file tests are run])
573AC_ARG_WITH([temp-large],
574            [AS_HELP_STRING([--with-temp-large=<directory>],
575                            [specify directory where large files (i.e. >2 GB) \
576                            will be written, if large files tests are run with
577                            --enable-large-file-tests])],
578            [TEMP_LARGE=$with_temp_large])
579TEMP_LARGE=${TEMP_LARGE-.}
580AC_MSG_RESULT($TEMP_LARGE)
581#AC_SUBST(TEMP_LARGE)
582AC_DEFINE_UNQUOTED([TEMP_LARGE], ["$TEMP_LARGE"], [Place to put very large netCDF test files.])
583
584# Specify extra values to add to _NCProperties attribute
585# --with-ncproperties-extra="<name>=<value>|...".
586# Note: need to figure out a way to do this programmatically also
587AC_MSG_CHECKING([Extra values for _NCProperties])
588AC_ARG_WITH([ncproperties-extra],
589            [AS_HELP_STRING([--with-ncproperties-extra="<name>=<value>,...],
590                            [specify extra pairs for _NCProperties])],
591            [NCPROPERTIES_EXTRA=$with_ncproperties_extra],
592            [NCPROPERTIES_EXTRA=""])
593AC_MSG_RESULT([$NCPROPERTIES_EXTRA])
594AC_DEFINE_UNQUOTED([NCPROPERTIES_EXTRA], ["$NCPROPERTIES_EXTRA"], [Extra pairs for _NCProperties])
595
596# Did the user specify a user-defined format 0?
597AC_MSG_CHECKING([whether user-defined format 0 was specified])
598AC_ARG_WITH([udf0],
599              [AS_HELP_STRING([--with-udf0=<dispatch_name>],
600                              [Specify a dispatch table for user-defined format 0.])],
601            [UDF0_DISPATCH=$with_udf0])
602AC_MSG_RESULT([$UDF0_DISPATCH])
603if test -n "$UDF0_DISPATCH"; then
604   AC_DEFINE_UNQUOTED([UDF0_DISPATCH], [$UDF0_DISPATCH], [dispatch table for user-defined format 0.])
605   AC_DEFINE_UNQUOTED([UDF0_DISPATCH_FUNC], [get_$UDF0_DISPATCH()], [function to get dispatch table for user-defined format 0.])
606   AC_DEFINE([USE_UDF0], [1], [if true, use user-defined format 0 in utilities])
607   AC_CHECK_LIB([$UDF0_DISPATCH], [get_$UDF0_DISPATCH], [],
608                                 [AC_MSG_ERROR([Can't find or link to the user-defined format 0 library.])],
609                                 [])
610fi
611
612# Did the user specify a magic number for user-defined format 0?
613AC_MSG_CHECKING([whether a magic number for user-defined format 0 was specified])
614AC_ARG_WITH([udf0-magic-number],
615              [AS_HELP_STRING([--with-udf0-magic-number=<magic_number>],
616                              [Specify a magic number for user-defined format 0 (ignored unless --with-udf0 is also used).])],
617            [UDF0_MAGIC_NUMBER=$with_udf0_magic_number])
618AC_MSG_RESULT([$UDF0_MAGIC_NUMBER])
619
620# Did the user specify a user-defined format 1?
621AC_MSG_CHECKING([whether user-defined format 1 was specified])
622AC_ARG_WITH([udf1],
623              [AS_HELP_STRING([--with-udf1=<dispatch_name>],
624                              [Specify a dispatch table for user-defined format 1.])],
625            [UDF1_DISPATCH=$with_udf1])
626AC_MSG_RESULT([$UDF1_DISPATCH])
627if test -n "$UDF1_DISPATCH"; then
628   AC_DEFINE_UNQUOTED([UDF1_DISPATCH], [$UDF1_DISPATCH], [dispatch table for user-defined format 1.])
629   AC_DEFINE_UNQUOTED([UDF1_DISPATCH_FUNC], [get_$UDF1_DISPATCH()], [function to get dispatch table for user-defined format 1.])
630   AC_DEFINE([USE_UDF1], [1], [if true, use user-defined format 1 in utilities])
631   AC_CHECK_LIB([$UDF1_DISPATCH], [get_$UDF1_DISPATCH], [],
632                                 [AC_MSG_ERROR([Can't find or link to the user-defined format 1 library.])],
633                                 [])
634fi
635
636# Did the user specify a magic number for user-defined format 0?
637AC_MSG_CHECKING([whether a magic number for user-defined format 1 was specified])
638AC_ARG_WITH([udf1-magic-number],
639              [AS_HELP_STRING([--with-udf1-magic-number=<magic_number>],
640                              [Specify a magic number for user-defined format 1 (ignored unless --with-udf1 is also used).])],
641            [UDF1_MAGIC_NUMBER=$with_udf1_magic_number])
642AC_MSG_RESULT([$UDF1_MAGIC_NUMBER])
643
644# According to the autoconf mailing list gurus, we must test for
645# compilers unconditionally. That is, we can't skip looking for the
646# fortran compilers, just because the user doesn't want fortran. This
647# is due to a limitation in autoconf.
648
649# Find the C compiler.
650AC_MSG_NOTICE([finding C compiler])
651
652## Compiler with version information. This consists of the full path
653## name of the compiler and the reported version number.
654AC_SUBST([CC_VERSION])
655## Strip anything that looks like a flag off of $CC
656CC_NOFLAGS=`echo $CC | sed 's/ -.*//'`
657
658if `echo $CC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
659  CC_VERSION="$CC"
660else
661  CC_VERSION="$CC";
662  for x in `echo $PATH | sed -e 's/:/ /g'`; do
663    if test -x $x/$CC_NOFLAGS; then
664      CC_VERSION="$x/$CC"
665      break
666    fi
667  done
668fi
669if test -n "$cc_version_info"; then
670  CC_VERSION="$CC_VERSION ( $cc_version_info)"
671fi
672
673
674AC_PROG_CC
675AM_PROG_CC_C_O
676AC_C_CONST
677
678# CURLOPT_USERNAME is not defined until curl version 7.19.1
679# CURLOPT_PASSWORD is not defined until curl version 7.19.1
680# CURLOPT_KEYPASSWD is not defined until curl version 7.16.4
681# CURLINFO_RESPONSE_CODE is not defined until curl version 7.10.7
682# CURLOPT_CHUNK_BGN_FUNCTION is not defined until curl version 7.21.0
683# CURL_MAX_READ_SIZE is not defined until 7.59
684
685# Save/restore CFLAGS
686SAVECFLAGS="$CFLAGS"
687CFLAGS="${curl_cflags}"
688
689AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
690[#include "curl/curl.h"],
691[[int x = CURLOPT_USERNAME;]])],
692                   [haveusername=yes],
693                   [haveusername=no])
694AC_MSG_CHECKING([whether CURLOPT_USERNAME is defined])
695AC_MSG_RESULT([${haveusername}])
696if test $haveusername = yes; then
697  AC_DEFINE([HAVE_CURLOPT_USERNAME],[1],[Is CURLOPT_USERNAME defined])
698fi
699
700AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
701[#include "curl/curl.h"],
702[[int x = CURLOPT_PASSWORD;]])],
703                   [havepassword=yes],
704                   [havepassword=no])
705AC_MSG_CHECKING([whether CURLOPT_PASSWORD is defined])
706AC_MSG_RESULT([${havepassword}])
707if test $havepassword = yes; then
708  AC_DEFINE([HAVE_CURLOPT_PASSWORD],[1],[Is CURLOPT_PASSWORD defined])
709fi
710
711AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
712[#include "curl/curl.h"],
713[[int x = CURLOPT_KEYPASSWD;]])],
714                   [havekeypassword=yes],
715                   [havekeypassword=no])
716AC_MSG_CHECKING([whether CURLOPT_KEYPASSWD is defined])
717AC_MSG_RESULT([${havekeypassword}])
718if test $havekeypassword = yes; then
719  AC_DEFINE([HAVE_CURLOPT_KEYPASSWD],[1],[Is CURLOPT_KEYPASSWD defined])
720fi
721
722AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
723[#include "curl/curl.h"],
724[[int x = CURLINFO_RESPONSE_CODE;]])],
725                   [haveresponsecode=yes],
726                   [haveresponsecode=no])
727AC_MSG_CHECKING([whether CURLINFO_RESPONSE_CODE is defined])
728AC_MSG_RESULT([${haveresponsecode}])
729if test $haveresponsecode = yes; then
730  AC_DEFINE([HAVE_CURLINFO_RESPONSE_CODE],[1],[Is CURLINFO_RESPONSE_CODE defined])
731fi
732
733AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
734[#include "curl/curl.h"],
735[[int x = CURLOPT_BUFFERSIZE;]])],
736                   [havecurloption=yes],
737                   [havecurloption=no])
738AC_MSG_CHECKING([whether CURLOPT_BUFFERSIZE is defined])
739AC_MSG_RESULT([${havecurloption}])
740if test $havecurloption = yes; then
741  AC_DEFINE([HAVE_CURLOPT_BUFFERSIZE],[1],[Is CURLOPT_BUFFERSIZE defined])
742fi
743
744AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
745[#include "curl/curl.h"],
746[[int x = CURLOPT_TCP_KEEPALIVE;]])],
747                   [havecurloption=yes],
748                   [havecurloption=no])
749AC_MSG_CHECKING([whether CURLOPT_TCP_KEEPALIVE is defined])
750AC_MSG_RESULT([${havecurloption}])
751if test $havecurloption = yes; then
752  AC_DEFINE([HAVE_CURLOPT_KEEPALIVE],[1],[Is CURLOPT_TCP_KEEPALIVE defined])
753fi
754
755CFLAGS="$SAVECFLAGS"
756
757# Set up libtool.
758AC_MSG_NOTICE([setting up libtool])
759LT_PREREQ([2.2])
760LT_INIT()
761
762AC_MSG_NOTICE([finding other utilities])
763
764# Is m4 installed? If not, bail.
765AC_CHECK_PROGS([NC_M4], [m4])
766if test -z "$NC_M4"; then
767   AC_MSG_ERROR([Cannot find m4 utility. Install m4 and try again.])
768fi
769
770# Is doxygen installed? If so, have configure construct the Doxyfile.
771AC_CHECK_PROGS([DOXYGEN], [doxygen])
772if test -z "$DOXYGEN"; then
773   AC_MSG_WARN([Doxygen not found - documentation will not be built])
774fi
775
776# Is graphviz/dot installed? If so, we'll use dot to create
777# graphs in the documentation.
778AC_CHECK_PROGS([DOT], [dot])
779if test -z "$DOT"; then
780   AC_MSG_WARN([dot not found - will use simple charts in documentation])
781   HAVE_DOT=NO
782elif test "x$enable_dot" = xno; then
783   HAVE_DOT=NO
784else
785   HAVE_DOT=YES
786fi
787# If we have doxygen, and it's enabled, then process the file.
788if test "x$enable_doxygen" != xno; then
789   if test -n "$DOXYGEN"; then
790        AC_SUBST(HAVE_DOT)
791        AC_CONFIG_FILES([docs/Doxyfile])
792   fi
793# Note: the list of files to input to doxygen
794# has been moved to docs/Doxyfile.in so
795# that make distcheck works correctly.
796# Any new inputs should be inserted into
797# docs/Doxyfile.in and possibley docs/Makefile.am
798fi
799
800# Find the install program.
801AC_PROG_INSTALL
802
803# Check to see if any macros must be set to enable large (>2GB) files.
804AC_SYS_LARGEFILE
805
806AC_MSG_NOTICE([displaying some results])
807
808## This next macro just prints some results for debugging
809## support issues.
810UD_DISPLAY_RESULTS
811
812# For nightly build testing, output CC, FC, etc.
813echo "CPPFLAGS=$CPPFLAGS CC=$CC CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS LIBS=$LIBS" >> comps.txt
814
815AC_MSG_NOTICE([checking types, headers, and functions])
816
817AC_CHECK_HEADERS([sys/param.h])
818AC_CHECK_HEADERS([libgen.h])
819#AC_CHECK_HEADERS([locale.h])
820AC_HEADER_STDC
821AC_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])
822
823# Do sys/resource.h separately
824#AC_CHECK_HEADERS([sys/resource.h],[havesysresource=1],[havesysresource=0])
825#if test "x$enable_dll" != xyes ; then
826AC_CHECK_HEADERS([sys/resource.h])
827#fi
828
829# See if we have ftw.h to walk directory trees
830AC_CHECK_HEADERS([ftw.h])
831
832# Check for these functions...
833AC_CHECK_FUNCS([strlcat snprintf strcasecmp fileno \
834                strdup strtoll strtoull \
835		mkstemp mktemp random \
836		getrlimit gettimeofday fsync MPI_Comm_f2c MPI_Info_f2c])
837
838# disable dap4 if netcdf-4 is disabled
839#if test "x$enable_netcdf_4" = "xno" ; then
840if test "x$enable_hdf5" = "xno" ; then
841    AC_MSG_WARN([netcdf-4 not enabled; disabling DAP4])
842    enable_dap4=no
843fi
844
845if test "x$enable_dap4" = xyes; then
846   AC_DEFINE([ENABLE_DAP4], [1], [if true, build DAP4 Client])
847fi
848
849# check for useful, but not essential, memio support
850AC_CHECK_FUNCS([memmove getpagesize sysconf])
851
852# Does the user want to allow use of mmap for NC_DISKLESS?
853AC_MSG_CHECKING([whether mmap is enabled for in-memory files])
854AC_ARG_ENABLE([mmap],
855              [AS_HELP_STRING([--enable-mmap],
856                              [allow mmap for in-memory files])])
857test "x$enable_mmap" = xyes || enable_mmap=no
858AC_MSG_RESULT($enable_mmap)
859
860# check for mmap availability before committing to use mmap
861have_mmap="$enable_mmap"
862AC_CHECK_FUNCS([mmap],[havemmapfcn=yes],[havemmapfcn=no])
863if test "x$havemmapfcn" = xno ; then
864have_mmap=no
865fi
866
867# check for mremap availability; not strictly needed
868AC_CHECK_FUNCS([mremap],[havemremapfcn=yes],[havemmapfcn=no])
869
870# Check for MAP_ANONYMOUS
871AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
872[#include <sys/mman.h>],
873[[int x = MAP_ANONYMOUS;]])],
874                   [havemapanon=yes],
875                   [havemapanon=no])
876AC_MSG_CHECKING([whether MAP_ANONYMOUS is defined])
877AC_MSG_RESULT([${havemapanon}])
878if test "x$havemapanon" != xyes ; then
879  have_mmap=no
880fi
881
882if test "x$have_mmap" != xyes ; then
883  echo "mmap functionality is not available: disabling mmap"
884  enable_mmap=no
885fi
886
887if test "x$enable_mmap" = xyes; then
888    AC_DEFINE([USE_MMAP], [1], [if true, use mmap for in-memory files])
889fi
890
891# Does the user want to allow reading of remote data via range headers?
892AC_MSG_CHECKING([whether byte range support is enabled])
893AC_ARG_ENABLE([byterange],
894              [AS_HELP_STRING([--enable-byterange],
895                              [allow byte-range I/O])])
896test "x$enable_byterange" = xyes || enable_byterange=no
897AC_MSG_RESULT($enable_byterange)
898# Need curl for byte ranges
899if test "x$found_curl" = xno && test "x$enable_byterange" = xyes ; then
900  AC_MSG_ERROR([curl required for byte range support. Install curl or build without --enable-byterange.])
901  enable_byterange=no
902fi
903
904if test "x$enable_byterange" = xyes; then
905    AC_DEFINE([ENABLE_BYTERANGE], [1], [if true, support byte-range read of remote datasets.])
906fi
907
908AC_FUNC_ALLOCA
909AC_CHECK_DECLS([isnan, isinf, isfinite],,,[#include <math.h>])
910AC_STRUCT_ST_BLKSIZE
911UD_CHECK_IEEE
912AC_CHECK_TYPES([size_t, ssize_t, schar, uchar, longlong, ushort, uint, int64, uint64])
913AC_TYPE_OFF_T
914AC_TYPE_UINTPTR_T
915AC_C_CHAR_UNSIGNED
916AC_C_BIGENDIAN
917
918###
919# Crude hack to work around an issue
920# in Cygwin.
921###
922SLEEPCMD=""
923PLTFORMOUT="$(uname | cut -d '_' -f 1)"
924if test "$PLTFORMOUT" = "CYGWIN"; then
925   ISCYGWIN=yes
926   SLEEPCMD="sleep 5"
927   AC_MSG_NOTICE([Pausing between sizeof() checks to mitigate a Cygwin issue.])
928fi
929AM_CONDITIONAL(ISCYGWIN, [test "x$ISCYGWIN" = xyes])
930
931$SLEEPCMD
932AC_CHECK_SIZEOF(short)
933$SLEEPCMD
934AC_CHECK_SIZEOF(int)
935$SLEEPCMD
936AC_CHECK_SIZEOF(long)
937$SLEEPCMD
938AC_CHECK_SIZEOF(long long)
939$SLEEPCMD
940AC_CHECK_SIZEOF(float)
941$SLEEPCMD
942AC_CHECK_SIZEOF(double)
943$SLEEPCMD
944AC_CHECK_SIZEOF(off_t)
945$SLEEPCMD
946AC_CHECK_SIZEOF(size_t)
947$SLEEPCMD
948AC_CHECK_SIZEOF(unsigned long long)
949
950# Check whether we want to enable CDF5 support.
951AC_MSG_CHECKING([whether CDF5 support should be disabled])
952AC_ARG_ENABLE([cdf5],
953              [AS_HELP_STRING([--disable-cdf5],
954                              [build without CDF5 support. @<:@default: auto@:>@])],
955              [enable_cdf5=${enableval}], [enable_cdf5=auto]
956)
957if test "$ac_cv_sizeof_size_t" -lt "8" ; then
958   if test "x${enable_cdf5}" = xyes ; then
959      dnl unable to support CDF5, but --enable-cdf5 is explicitly set
960      AC_MSG_ERROR([Unable to support CDF5 feature because size_t is less than 8 bytes])
961   fi
962   enable_cdf5=no
963else
964   if test "x${enable_cdf5}" != xno ; then
965      enable_cdf5=yes
966   fi
967fi
968AC_MSG_RESULT($enable_cdf5)
969
970if test "x${enable_cdf5}" = xyes; then
971   AC_DEFINE([ENABLE_CDF5], [1], [if true, enable CDF5 Support])
972fi
973AM_CONDITIONAL(ENABLE_CDF5, [test x$enable_cdf5 = xyes ])
974
975$SLEEPCMD
976if test "$ac_cv_type_uchar" = yes ; then
977   AC_CHECK_SIZEOF(uchar)
978else
979   AC_CHECK_SIZEOF(unsigned char)
980fi
981
982$SLEEPCMD
983if test "$ac_cv_type_ushort" = yes ; then
984   AC_CHECK_SIZEOF(ushort)
985else
986   AC_CHECK_SIZEOF(unsigned short int)
987fi
988
989$SLEEPCMD
990if test "$ac_cv_type_uint" = yes ; then
991   AC_CHECK_SIZEOF(uint)
992else
993   AC_CHECK_SIZEOF(unsigned int)
994fi
995$SLEEPCMD
996if test "$ac_cv_type_ushort" = yes ; then
997   AC_CHECK_SIZEOF(ushort)
998else
999   AC_CHECK_SIZEOF(unsigned short int)
1000fi
1001$SLEEPCMD
1002if test "$ac_cv_type_uint" = yes ; then
1003   AC_CHECK_SIZEOF(uint)
1004else
1005   AC_CHECK_SIZEOF(unsigned int)
1006fi
1007$SLEEPCMD
1008AC_CHECK_SIZEOF(ssize_t)
1009$SLEEPCMD
1010AC_CHECK_SIZEOF([void*])
1011
1012if test "x$enable_netcdf_4" = xyes || test "x$enable_dap" = xyes; then
1013   AC_SEARCH_LIBS([deflate], [zlibwapi zlibstat zlib zlib1 z], [], [
1014     AC_MSG_ERROR([Can't find or link to the z library. Turn off netCDF-4 and \
1015     DAP clients with --disable-netcdf-4 --disable-dap, or see config.log for errors.])])
1016   AC_SEARCH_LIBS([dlopen], [dl dld], [], [])
1017fi
1018
1019# We need the math library
1020AC_CHECK_LIB([m], [floor], [],
1021[AC_MSG_ERROR([Can't find or link to the math library.])])
1022
1023if test "x$enable_netcdf_4" = xyes; then
1024   AC_DEFINE([USE_NETCDF4], [1], [if true, build netCDF-4])
1025fi
1026
1027# Set defaults
1028hdf5_parallel=no
1029hdf5_supports_par_filters=no
1030enable_szlib=no
1031
1032if test "x$enable_hdf5" = xyes; then
1033
1034   AC_DEFINE([USE_HDF5], [1], [if true, use HDF5])
1035   AC_DEFINE([H5_USE_16_API], [1], [use HDF5 1.6 API])
1036
1037   # Check for the main hdf5 and hdf5_hl library.
1038
1039   AC_SEARCH_LIBS([H5Fflush], [hdf5dll hdf5], [],
1040   [AC_MSG_ERROR([Can't find or link to the hdf5 library. Use --disable-netcdf-4, or see config.log for errors.])])
1041   AC_SEARCH_LIBS([H5DSis_scale], [hdf5_hldll hdf5_hl], [],
1042   [AC_MSG_ERROR([Can't find or link to the hdf5 high-level. Use --disable-netcdf-4, or see config.log for errors.])])
1043
1044   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.])])
1045
1046   # Was HDF5 built with zlib as netCDF requires?
1047   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "H5pubconf.h"],
1048   [[#if !H5_HAVE_ZLIB_H
1049   # error
1050   #endif]
1051   ])], [], [AC_MSG_ERROR([HDF5 was not built with zlib, which is required. Rebuild HDF5 with zlib.])])
1052
1053   # H5Pset_fapl_mpiposix and H5Pget_fapl_mpiposix have been removed since HDF5 1.8.12.
1054   # Use H5Pset_fapl_mpio and H5Pget_fapl_mpio, instead.
1055   AC_CHECK_FUNCS([H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5free_memory H5resize_memory H5allocate_memory H5Pset_libver_bounds H5Pset_all_coll_metadata_ops H5Dread_chunk])
1056
1057   # Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0)
1058   if test "x$ac_cv_func_H5Pset_all_coll_metadata_ops" = xyes; then
1059      AC_DEFINE([HDF5_HAS_COLL_METADATA_OPS], [1], [if true, use collective metadata ops in parallel netCDF-4])
1060   fi
1061
1062   # If parallel is available in hdf5, enable it in the C code. Also add some stuff to netcdf.h.
1063   if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes -o "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then
1064      hdf5_parallel=yes
1065   fi
1066
1067   AC_MSG_CHECKING([whether parallel io is enabled in hdf5])
1068   AC_MSG_RESULT([$hdf5_parallel])
1069
1070   # Check to see if HDF5 library is 1.10.3 or greater. If so, allows
1071   # parallel I/O with filters. This allows zlib/szip compression to
1072   # be used with parallel I/O, which is very helpful to HPC users.
1073   if test "x$ac_cv_func_H5Dread_chunk" = xyes; then
1074      AC_DEFINE([HDF5_SUPPORTS_PAR_FILTERS], [1], [if true, HDF5 is at least version 1.10.3 and allows parallel I/O with zip])
1075      hdf5_supports_par_filters=yes
1076   fi
1077   AC_MSG_CHECKING([whether HDF5 allows parallel filters])
1078   AC_MSG_RESULT([$ac_cv_func_H5Dread_chunk])
1079
1080   # Check to see if user asked for parallel build, but HDF5 does not support it.
1081   if test "x$hdf5_parallel" = "xno"; then
1082      if test "x$enable_parallel_tests" = "xyes"; then
1083         AC_MSG_ERROR([Parallel tests requested, but no parallel HDF5 installation detected.])
1084      fi
1085   fi
1086
1087   # Check whether HDF5 was built with the SZLIB library. If so we
1088   # must be able to link to szip library.
1089   AC_MSG_CHECKING([whether szlib was used when building HDF5])
1090   if test "x$ac_cv_func_H5Z_SZIP" = xyes; then
1091      enable_szlib=yes
1092      AC_DEFINE([USE_SZIP], [1], [if true, compile in szip compression in netCDF-4 variables])
1093   fi
1094   AC_MSG_RESULT([$enable_szlib])
1095fi
1096
1097# If the user wants hdf4 built in, check it out.
1098if test "x$enable_hdf4" = xyes; then
1099   AC_CHECK_LIB([jpeg], [jpeg_CreateCompress], [],
1100                [AC_MSG_ERROR([Jpeg library required for --enable-hdf4 builds.])])
1101   AC_CHECK_HEADERS([mfhdf.h], [], [nc_mfhdf_h_missing=yes])
1102   if test "x$nc_mfhdf_h_missing" = xyes; then
1103      AC_MSG_ERROR([Cannot find mfhdf.h, yet --enable-hdf4 was used.])
1104   fi
1105   AC_CHECK_LIB([df], [Hclose], [], [AC_MSG_ERROR([Can't find or link to the hdf4 df library. See config.log for errors.])])
1106   AC_CHECK_LIB([mfhdf], [NC_arrayfill], [AC_MSG_ERROR([HDF4 library must be built with --disable-netcdf.])], [])
1107   AC_CHECK_LIB([mfhdf], [SDcreate], [], [AC_MSG_ERROR([Can't find or link to the hdf4 mfhdf library. See config.log for errors.])])
1108
1109   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.])])
1110   AC_DEFINE([USE_HDF4], [1], [if true, use HDF4 too])
1111fi
1112
1113# There are several cases for parallelism:
1114# 1. PnetCDF enabled => we want to parallelism for CDF-1,CDF-2,and CDF-5
1115# 2. hdf5 has mpio enabled
1116#    a. do not want to use it for netcdf4
1117#    b. do want to use it for netcdf4
1118
1119# Should we provide parallel io for netcdf-4?
1120if test "x$enable_hdf5" = xyes ; then
1121   AC_ARG_ENABLE([parallel4],
1122	[AS_HELP_STRING([--disable-parallel4],
1123                        [disable parallel I/O for netcdf-4, even if it's enabled in libhdf5])],
1124			[user_set_parallel4=${enableval}]2)
1125   test "x$enable_parallel4" = xno || enable_parallel4=yes
1126
1127   # If user wants parallel IO for netCDF-4, make sure HDF5 can provide it.
1128   if test "x$enable_parallel4" = xyes; then
1129      if test "x$hdf5_parallel" = xno; then
1130      	 # If user specifically asked for parallel4, then error out.
1131	 if test "x$user_set_parallel4" = xyes; then
1132	    AC_MSG_ERROR([Paralllel IO in netCDF-4 requested, but HDF5 does not provide parallel IO.])
1133	 fi
1134         # User didn't specify, so disable parallel4
1135	 enable_parallel4=no
1136	 AC_MSG_WARN([Parallel io disabled for netcdf-4 because hdf5 does not support])
1137      fi
1138   fi
1139else
1140   enable_parallel4=no
1141fi
1142AC_MSG_CHECKING([whether parallel I/O is enabled for netcdf-4])
1143AC_MSG_RESULT($enable_parallel4)
1144
1145# We have already tested for parallel io in netcdf4
1146# parallel I/O for CDF-1, 2, and 5 files can also be done through PnetCDF
1147AC_MSG_CHECKING([whether parallel I/O for classic files is to be enabled])
1148AC_ARG_ENABLE([pnetcdf], [AS_HELP_STRING([--enable-pnetcdf],
1149              [build with parallel I/O for classic files. @<:@default: disabled@:>@])])
1150test "x$enable_pnetcdf" = xyes || enable_pnetcdf=no
1151AC_MSG_RESULT($enable_pnetcdf)
1152
1153# See if the PnetCDF lib is available and of the
1154# right version (1.6.0 or later)
1155if test "x$enable_pnetcdf" = xyes; then
1156  pnetcdf_conflict=no
1157  AC_CHECK_LIB([pnetcdf], [ncmpi_create], [],[pnetcdf_conflict=yes])
1158
1159  if test "x$pnetcdf_conflict" = xyes ; then
1160     AC_MSG_ERROR([Cannot link to PnetCDF library.])
1161  fi
1162
1163  # Pnetcdf did not support utf-8 until 1.6.0
1164
1165  AC_MSG_CHECKING([Is libpnetcdf version 1.6.0 or later?])
1166  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1167#include <pnetcdf.h>
1168#if (PNETCDF_VERSION_MAJOR*1000 + PNETCDF_VERSION_MINOR < 1006)
1169      choke me
1170#endif
1171  ]])], [pnetcdf16=yes], [pnetcdf16=no])
1172  AC_MSG_RESULT([$pnetcdf16])
1173  if test x$pnetcdf16 = xno; then
1174    AC_MSG_ERROR([--enable-pnetcdf requires version 1.6.0 or later])
1175  fi
1176fi
1177
1178# Now, set enable_parallel if either enable_pnetcdf or enable_parallel4 is set
1179if test "x$enable_pnetcdf" = xyes -o "x$enable_parallel4" = xyes; then
1180  enable_parallel=yes
1181else
1182  enable_parallel=no
1183fi
1184AM_CONDITIONAL(ENABLE_PARALLEL, [test x$enable_parallel = xyes ])
1185
1186if test "x$hdf5_parallel" = xyes; then
1187  # Provide more precise parallel control
1188  AC_DEFINE([HDF5_PARALLEL], [1], [if true, hdf5 has parallelism enabled])
1189fi
1190
1191# Set config flags
1192if test "x$enable_parallel4" = xyes; then
1193  # Provide more precise parallel control
1194  AC_DEFINE([USE_PARALLEL4], [1], [if true, parallel netcdf-4 is in use])
1195fi
1196
1197if test "x$enable_pnetcdf" = xyes; then
1198  AC_DEFINE([USE_PNETCDF], [1], [if true, PnetCDF is used])
1199fi
1200
1201# If enable_parallel is in use, enable it in the C code. Also add some stuff to netcdf.h.
1202if test "x$enable_parallel" = xyes; then
1203  AC_DEFINE([USE_PARALLEL], [1], [if true, PnetCDF or parallel netcdf-4 is in use])
1204fi
1205
1206AC_ARG_ENABLE([erange_fill],
1207   [AS_HELP_STRING([--enable-erange-fill],
1208                   [Enable use of fill value when out-of-range type
1209                    conversion causes NC_ERANGE error. @<:@default: disabled@:>@])],
1210   [enable_erange_fill=${enableval}], [enable_erange_fill=auto]
1211)
1212
1213# check PnetCDF's settings on enable_erange_fill and relax_coord_bound
1214if test "x$enable_pnetcdf" = xyes; then
1215   UD_CHECK_HEADER_PATH([pnetcdf.h])
1216
1217   AC_MSG_CHECKING([if erange-fill is enabled in PnetCDF])
1218   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1219#include <pnetcdf.h>
1220#if !defined(PNETCDF_ERANGE_FILL) || PNETCDF_ERANGE_FILL == 0
1221      choke me
1222#endif]])], [enable_erange_fill_pnetcdf=yes], [enable_erange_fill_pnetcdf=no])
1223   AC_MSG_RESULT([$enable_erange_fill_pnetcdf])
1224   if test "x$enable_erange_fill" = xauto ; then
1225      enable_erange_fill=$enable_erange_fill_pnetcdf
1226   elif test "$enable_erange_fill" != "$enable_erange_fill_pnetcdf"; then
1227      if test "$enable_erange_fill" = yes; then
1228         AC_MSG_ERROR([Enabling erange-fill conflicts with PnetCDF setting])
1229      else
1230         AC_MSG_ERROR([Disabling erange-fill conflicts with PnetCDF setting])
1231      fi
1232   fi
1233
1234   AC_MSG_CHECKING([if relax-coord-bound is enabled in PnetCDF])
1235   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1236#include <pnetcdf.h>
1237#if !defined(PNETCDF_RELAX_COORD_BOUND) || PNETCDF_RELAX_COORD_BOUND == 0
1238      choke me
1239#endif]])], [relax_coord_bound_pnetcdf=yes], [relax_coord_bound_pnetcdf=no])
1240   AC_MSG_RESULT([$relax_coord_bound_pnetcdf])
1241   if test x"$relax_coord_bound_pnetcdf" != xyes; then
1242      AC_MSG_ERROR([PNetCDF must be built with relax-coord-bound])
1243   fi
1244else
1245   if test "x$enable_erange_fill" = xauto; then
1246      # if --enable-erange-fill is not used, default setting is no
1247      enable_erange_fill=no
1248   fi
1249fi
1250
1251if test "x$enable_erange_fill" = xyes ; then
1252   if test "x$M4FLAGS" = x ; then
1253      M4FLAGS="-DERANGE_FILL"
1254   else
1255      M4FLAGS="$M4FLAGS -DERANGE_FILL"
1256   fi
1257   AC_DEFINE([ERANGE_FILL], [1], [if true, use _FillValue for NC_ERANGE data elements])
1258fi
1259AC_SUBST(M4FLAGS)
1260
1261# Check for downloading/building fortran via postinstall script.
1262if test "x$enable_remote_fortran_bootstrap" = xyes; then
1263   AC_DEFINE([BUILD_FORTRAN], 1, [If true, will attempt to download and build netcdf-fortran.])
1264fi
1265
1266# No logging for netcdf-3.
1267if test "x$enable_netcdf_4" = xno; then
1268   enable_logging=no
1269fi
1270if test "x$enable_logging" = xyes; then
1271   AC_DEFINE([LOGGING], 1, [If true, turn on logging.])
1272fi
1273
1274# Automake conditionals need to be called, whether the answer is yes
1275# or no.
1276AM_CONDITIONAL(BUILD_PARALLEL, [test x$enable_parallel = xyes])
1277AM_CONDITIONAL(TEST_PARALLEL4, [test "x$enable_parallel4" = xyes -a "x$enable_parallel_tests" = xyes])
1278AM_CONDITIONAL(BUILD_DAP, [test "x$enable_dap" = xyes])
1279AM_CONDITIONAL(USE_DAP, [test "x$enable_dap" = xyes]) # Alias
1280# Provide protocol specific flags
1281AM_CONDITIONAL(ENABLE_DAP, [test "x$enable_dap" = xyes])
1282AM_CONDITIONAL(ENABLE_DAP4, [test "x$enable_dap4" = xyes])
1283AM_CONDITIONAL(USE_STRICT_NULL_BYTE_HEADER_PADDING, [test x$enable_strict_null_byte_header_padding = xyes])
1284AM_CONDITIONAL(ENABLE_CDF5, [test "x$enable_cdf5" = xyes])
1285AM_CONDITIONAL(ENABLE_DAP_REMOTE_TESTS, [test "x$enable_dap_remote_tests" = xyes])
1286AM_CONDITIONAL(ENABLE_DAP_AUTH_TESTS, [test "x$enable_dap_auth_tests" = xyes])
1287AM_CONDITIONAL(ENABLE_DAP_LONG_TESTS, [test "x$enable_dap_long_tests" = xyes])
1288AM_CONDITIONAL(USE_SZIP, [test "x$ac_cv_func_H5Z_SZIP" = xyes])
1289AM_CONDITIONAL(USE_PNETCDF_DIR, [test ! "x$PNETCDFDIR" = x])
1290AM_CONDITIONAL(USE_LOGGING, [test "x$enable_logging" = xyes])
1291AM_CONDITIONAL(CROSS_COMPILING, [test "x$cross_compiling" = xyes])
1292AM_CONDITIONAL(USE_NETCDF4, [test x$enable_netcdf_4 = xyes])
1293AM_CONDITIONAL(USE_HDF5, [test x$enable_hdf5 = xyes])
1294AM_CONDITIONAL(USE_HDF4, [test x$enable_hdf4 = xyes])
1295AM_CONDITIONAL(USE_HDF4_FILE_TESTS, [test x$enable_hdf4_file_tests = xyes])
1296AM_CONDITIONAL(USE_RENAMEV3, [test x$enable_netcdf_4 = xyes -o x$enable_dap = xyes])
1297AM_CONDITIONAL(BUILD_FORTRAN, [test x$enable_remote_fortran_bootstrap = xyes])
1298AM_CONDITIONAL(USE_PNETCDF, [test x$enable_pnetcdf = xyes])
1299AM_CONDITIONAL(USE_DISPATCH, [test x$enable_dispatch = xyes])
1300AM_CONDITIONAL(BUILD_MMAP, [test x$enable_mmap = xyes])
1301AM_CONDITIONAL(BUILD_DOCS, [test x$enable_doxygen = xyes])
1302AM_CONDITIONAL(SHOW_DOXYGEN_TAG_LIST, [test x$enable_doxygen_tasks = xyes])
1303AM_CONDITIONAL(ENABLE_METADATA_PERF, [test x$enable_metadata_perf = xyes])
1304AM_CONDITIONAL(ENABLE_BYTERANGE, [test "x$enable_byterange" = xyes])
1305AM_CONDITIONAL(RELAX_COORD_BOUND, [test "xyes" = xyes])
1306AM_CONDITIONAL(HAS_PAR_FILTERS, [test x$hdf5_supports_par_filters = xyes ])
1307
1308# If the machine doesn't have a long long, and we want netCDF-4, then
1309# we've got problems!
1310if test "x$enable_netcdf_4" = xyes; then
1311   AC_TYPE_LONG_LONG_INT
1312   AC_TYPE_UNSIGNED_LONG_LONG_INT
1313dnl    if test ! "x$ac_cv_type_long_long_int" = xyes -o ! "x$ac_cv_type_unsigned_long_long_int" = xyes; then
1314dnl       AC_MSG_ERROR([This platform does not support long long types. These are required for netCDF-4.])
1315dnl    fi
1316fi
1317
1318# Create the file name for a "make ftpbin" which is used to generate a
1319# binary distribution. For each release we generate binary releases on
1320# the thousands of machines in Unidata's vast underground complex at
1321# an undisclosed location in the Rocky Mountains. The binary
1322# distributions, along with the 25-foot thick cement slabs and the
1323# giant springs, will help distribute netCDF even after a catastrophic
1324# meteor strike.
1325AC_MSG_CHECKING([what to call the output of the ftpbin target])
1326BINFILE_NAME=binary-netcdf-$PACKAGE_VERSION
1327test "x$enable_netcdf_4" = xno && BINFILE_NAME=${BINFILE_NAME}_nc3
1328BINFILE_NAME=${BINFILE_NAME}.tar
1329AC_SUBST(BINFILE_NAME)
1330AC_MSG_RESULT([$BINFILE_NAME $FC $CXX])
1331
1332##
1333# Bugfix for Cygwin.
1334##
1335AC_MSG_CHECKING([if libtool needs -no-undefined flag to build shared libraries])
1336case "`uname`" in
1337     CYGWIN*|MINGW*|AIX*)
1338     ## Add in the -no-undefined flag to LDFLAGS for libtool.
1339     AC_MSG_RESULT([yes])
1340     NOUNDEFINED=" -no-undefined"
1341     ;;
1342     *)
1343     ## Don't add anything
1344     AC_MSG_RESULT([no])
1345     ;;
1346esac
1347
1348AC_MSG_CHECKING([value of LIBS])
1349AC_MSG_RESULT([$LIBS])
1350
1351# Flags for nc-config script; by design $prefix, $includir, $libdir,
1352# etc.  are left as shell variables in the script so as to facilitate
1353# relocation
1354if test "x$with_netcdf_c_lib" = x ; then
1355   NC_LIBS="-lnetcdf"
1356else
1357   NC_LIBS="$with_netcdf_c_lib"
1358fi
1359if test "x$enable_shared" != xyes; then
1360   NC_LIBS="$LDFLAGS $NC_LIBS $LIBS"
1361fi
1362
1363case "x$target_os" in
1364xsolaris*)
1365  NEWNCLIBS=""
1366  for x in $NC_LIBS ; do
1367    case "$x" in
1368    -L*) r=`echo "$x" | sed -e 's|^-L|-R|'`
1369	 NEWNCLIBS="$NEWNCLIBS $x $r"
1370	 ;;
1371    *)	 NEWNCLIBS="$NEWNCLIBS $x" ;;
1372    esac
1373  done
1374  NC_LIBS="$NEWNCLIBS"
1375  ;;
1376*);;
1377esac
1378
1379NC_FLIBS="-lnetcdff $NC_LIBS"
1380
1381# temporary to deal with a JNA problem
1382AC_MSG_CHECKING([If compilation is for use with JNA])
1383AC_ARG_ENABLE([jna],
1384              [AS_HELP_STRING([--enable-jna],
1385                              [enable jna bug fix])],
1386				[],
1387				[enable_jna=no])
1388test "x$enable_jna" = xno || enable_jna=yes
1389AC_MSG_RESULT($enable_jna)
1390if test "x$enable_jna" = xyes ; then
1391AC_DEFINE([JNA], [1], [if true, include JNA bug fix])
1392fi
1393
1394# Control filter test/example
1395AC_MSG_CHECKING([whether filter testing should be run])
1396AC_ARG_ENABLE([filter-testing],
1397              [AS_HELP_STRING([--disable-filter-testing],
1398                              [Do not run filter test and example; requires shared libraries and netCDF-4])])
1399test "x$enable_filter_testing" = xno || enable_filter_testing=yes
1400AC_MSG_RESULT($enable_filter_testing)
1401
1402if test "x$enable_netcdf_4" = xno ; then
1403AC_MSG_WARN([netCDF-4 disabled => --disable-filter-testing])
1404enable_filter_testing=no
1405fi
1406
1407if test "x$enable_hdf5" = xno ; then
1408AC_MSG_WARN([HDF5 disabled => --disable-filter-testing])
1409enable_filter_testing=no
1410fi
1411
1412if test "x$enable_shared" = xno ; then
1413AC_MSG_WARN([Shared libraries are disabled => --disable-filter-testing])
1414enable_filter_testing=no
1415fi
1416AM_CONDITIONAL(ENABLE_FILTER_TESTING, [test x$enable_filter_testing = xyes])
1417
1418AC_SUBST(NC_LIBS,[$NC_LIBS])
1419AC_SUBST(HAS_DAP,[$enable_dap])
1420AC_SUBST(HAS_DAP2,[$enable_dap])
1421AC_SUBST(HAS_DAP4,[$enable_dap4])
1422AC_SUBST(HAS_NC2,[$nc_build_v2])
1423AC_SUBST(HAS_NC4,[$enable_netcdf_4])
1424AC_SUBST(HAS_CDF5,[$enable_cdf5])
1425AC_SUBST(HAS_HDF4,[$enable_hdf4])
1426AC_SUBST(HAS_HDF5,[$enable_hdf5])
1427AC_SUBST(HAS_PNETCDF,[$enable_pnetcdf])
1428AC_SUBST(HAS_LOGGING, [$enable_logging])
1429AC_SUBST(HAS_SZLIB,[$enable_szlib])
1430AC_SUBST(HAS_SZLIB_WRITE, [$enable_szlib])
1431AC_SUBST(HAS_PARALLEL,[$enable_parallel])
1432AC_SUBST(HAS_PARALLEL4,[$enable_parallel4])
1433AC_SUBST(HAS_DISKLESS,[yes])
1434AC_SUBST(HAS_MMAP,[$enable_mmap])
1435AC_SUBST(HAS_JNA,[$enable_jna])
1436AC_SUBST(HAS_ERANGE_FILL,[$enable_erange_fill])
1437AC_SUBST(HAS_BYTERANGE,[$enable_byterange])
1438AC_SUBST(RELAX_COORD_BOUND,[yes])
1439AC_SUBST([HAS_PAR_FILTERS], [$hdf5_supports_par_filters])
1440
1441# Include some specifics for netcdf on windows.
1442#AH_VERBATIM([_WIN32_STRICMP],
1443AH_BOTTOM(
1444[/* Define strcasecmp, snprintf on Win32 systems. */
1445#ifdef _WIN32
1446	#define strcasecmp _stricmp
1447	#define snprintf _snprintf
1448#endif])
1449
1450# Access netcdf specific version of config.h
1451AH_BOTTOM([#include "ncconfigure.h"])
1452
1453##################################################
1454# Uncomment this to keep a copy of autoconf defines at this point, for
1455# debugging purposes.
1456# cp confdefs.h my_config.h
1457
1458#####
1459# Create output variables from various
1460# shell variables, for use in generating
1461# libnetcdf.settings.
1462#####
1463AC_SUBST([enable_shared])
1464AC_SUBST([enable_static])
1465AC_SUBST([CFLAGS])
1466AC_SUBST([CPPFLAGS])
1467AC_SUBST([LDFLAGS])
1468AC_SUBST([AM_CFLAGS])
1469AC_SUBST([AM_CPPFLAGS])
1470AC_SUBST([AM_LDFLAGS])
1471AC_SUBST([NOUNDEFINED])
1472
1473# Args:
1474# 1. netcdf_meta.h variable
1475# 2. conditional variable that is yes or no.
1476# 3. default condition
1477#
1478# example: AX_SET_META([NC_HAS_NC2],[$nc_build_v2],[]) # Because it checks for no.
1479#          AX_SET_META([NC_HAS_HDF4],[$enable_hdf4],[yes])
1480AC_DEFUN([AX_SET_META],[
1481  if [ test "x$2" = x$3 ]; then
1482     AC_SUBST([$1]) $1=1
1483  else
1484     AC_SUBST([$1]) $1=0
1485  fi
1486])
1487
1488#####
1489# Define values used in include/netcdf_meta.h
1490#####
1491AC_SUBST([NC_VERSION]) NC_VERSION=$VERSION
1492AX_SET_META([NC_HAS_NC2],[$nc_build_v2],[yes])
1493AX_SET_META([NC_HAS_NC4],[$enable_netcdf_4],[yes])
1494AX_SET_META([NC_HAS_HDF4],[$enable_hdf4],[yes])
1495AX_SET_META([NC_HAS_HDF5],[$enable_netcdf_4],[yes])
1496AX_SET_META([NC_HAS_SZIP],[$ac_cv_func_H5Z_SZIP],[yes])
1497AX_SET_META([NC_HAS_DAP2],[$enable_dap],[yes])
1498AX_SET_META([NC_HAS_DAP4],[$enable_dap4],[yes])
1499AX_SET_META([NC_HAS_DISKLESS],[yes],[yes])
1500AX_SET_META([NC_HAS_MMAP],[$enable_mmap],[yes])
1501AX_SET_META([NC_HAS_JNA],[$enable_jna],[yes])
1502AX_SET_META([NC_HAS_PNETCDF],[$enable_pnetcdf],[yes])
1503AX_SET_META([NC_HAS_PARALLEL],[$enable_parallel],[yes])
1504AX_SET_META([NC_HAS_PARALLEL4],[$enable_parallel4],[yes])
1505AX_SET_META([NC_HAS_CDF5],[$enable_cdf5],[yes])
1506AX_SET_META([NC_HAS_ERANGE_FILL], [$enable_erange_fill],[yes])
1507AX_SET_META([NC_HAS_PAR_FILTERS], [$hdf5_supports_par_filters],[yes])
1508AX_SET_META([NC_HAS_BYTERANGE],[$enable_byterange],[yes])
1509AC_SUBST([NC_DISPATCH_VERSION], [2])
1510#####
1511# End netcdf_meta.h definitions.
1512#####
1513
1514# This would be true for a cmake build.
1515AC_SUBST([ISCMAKE], [])
1516
1517# This would be true for a visual studio build.
1518AC_SUBST([MSVC], [])
1519
1520AC_MSG_NOTICE([generating header files and makefiles])
1521AC_CONFIG_FILES(test_common.sh:test_common.in)
1522AC_CONFIG_FILES(nc_test4/findplugin.sh:nc_test4/findplugin.in)
1523AC_CONFIG_FILES(examples/C/findplugin.sh:nc_test4/findplugin.in)
1524AC_CONFIG_FILES(ncdap_test/findtestserver.c:ncdap_test/findtestserver.c.in)
1525AC_CONFIG_FILES(dap4_test/findtestserver4.c:ncdap_test/findtestserver.c.in)
1526AC_CONFIG_FILES(dap4_test/pingurl4.c:ncdap_test/pingurl.c)
1527AC_CONFIG_FILES([h5_test/run_par_tests.sh], [chmod ugo+x h5_test/run_par_tests.sh])
1528AC_CONFIG_FILES([nc_test4/run_par_test.sh], [chmod ugo+x nc_test4/run_par_test.sh])
1529AC_CONFIG_FILES([nc_perf/run_par_bm_test.sh], [chmod ugo+x nc_perf/run_par_bm_test.sh])
1530AC_CONFIG_FILES([examples/C/run_par_test.sh], [chmod ugo+x examples/C/run_par_test.sh])
1531AC_CONFIG_FILES([nc-config], [chmod 755 nc-config])
1532AC_CONFIG_FILES([Makefile
1533                 netcdf.pc
1534                 libnetcdf.settings
1535                 postinstall.sh
1536                 include/netcdf_meta.h
1537                 include/Makefile
1538                 h5_test/Makefile
1539                 hdf4_test/Makefile
1540                 libsrc/Makefile
1541                 libsrc4/Makefile
1542                 libhdf5/Makefile
1543                 libsrcp/Makefile
1544                 ncdump/Makefile
1545                 ncgen3/Makefile
1546                 ncgen/Makefile
1547                 examples/Makefile
1548                 examples/C/Makefile
1549                 examples/CDL/Makefile
1550                 oc2/Makefile
1551                 libdap2/Makefile
1552                 libdap4/Makefile
1553                 libhdf4/Makefile
1554                 libdispatch/Makefile
1555                 liblib/Makefile
1556                 ncdump/cdl/Makefile
1557                 ncdump/expected/Makefile
1558                 docs/Makefile
1559                 docs/images/Makefile
1560                 unit_test/Makefile
1561                 nctest/Makefile
1562                 nc_test4/Makefile
1563                 nc_perf/Makefile
1564                 nc_test/Makefile
1565                 ncdap_test/Makefile
1566                 ncdap_test/testdata3/Makefile
1567                 ncdap_test/expected3/Makefile
1568                 ncdap_test/expectremote3/Makefile
1569                 dap4_test/Makefile
1570                 plugins/Makefile
1571                 ])
1572AC_OUTPUT()
1573
1574cat libnetcdf.settings
1575