1
2dnl -*- autoconf -*-
3dnl Process this file with autoconf to produce a configure script.
4
5AC_PREREQ(2.63)
6dnl AC_PREREQ([2.68]); Fails on CentOS 6. jhrg 3/26/19
7dnl m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
8dnl m4_pattern_allow([^BISON_USE_NLS$])
9
10dnl Set the version number here. Set the build number using --with-build
11dnl The version info is put in the VERSION file. The build number is used
12dnl in the RPM spec file. The build number is not part of the pkg config
13dnl 'pc' files and tarball for the source. See
14dnl libdap4/travis/travis_libdap_build_offset.sh for info about setting the
15dnl base value for the build number. jhrg 3/22/21
16AC_INIT(libdap, 3.20.8, opendap-tech@opendap.org)
17
18dnl As an alternative, we can...
19dnl Read the version number from the file VERSION. The file must contain
20dnl only the version number in the form x.y.z or x.y.z-b. Newlines are
21dnl ignored. Anything else and the build will fail.
22dnl
23dnl But, this requires that the NEWS file have the version number AND build
24dnl number somewhere in the first 15 lines or the dist target will fail.
25dnl jhrg 3/17/21
26dnl https://stackoverflow.com/questions/8559456/read-a-version-number-from-a-file-in-configure-ac
27dnl AC_INIT([libdap], m4_normalize(m4_include([VERSION])), [opendap-tech@opendap.org])
28
29dnl Provide a way to pass in a build number. This is used by CI/CD systems to record
30dnl each build. The version number is set by the value in AC_INIT (see above). For
31dnl people building the source, it's not customary to supply a build number (i.e.,
32dnl if you're building the code for your own use, a build number seems like overkill).
33dnl jhrg 3/16/21
34AC_ARG_WITH([build],
35            [AC_HELP_STRING([--with-build=<number>],
36             [Inject the integer build number (default is to not define a build number)])],
37            [build_number=${withval}], [build_number=])
38
39dnl If a build number is given and valid (it must be an integer), use it. If it's
40dnl given but invalid, print a message and exit. jhrg 3/17/21
41AS_IF([test -n "$with_build"],
42    [AS_IF([echo $build_number | grep '^[[0-9]][[-0-9.]]*$' > /dev/null 2>&1 ],
43     [PACKAGE_VERSION=$PACKAGE_VERSION-$build_number
44      echo "PACKAGE_VERSION: $PACKAGE_VERSION; VERSION: $VERSION"],
45     [AC_MSG_ERROR([Invalid build number given (must be an integer): $build_number])])])
46
47AC_DEFINE(DAP_PROTOCOL_VERSION, ["4.0"], [Highest DAP version implemented?])
48AC_SUBST([DAP_PROTOCOL_VERSION])
49
50AC_CONFIG_SRCDIR([Connect.cc])
51AC_CONFIG_AUX_DIR(conf)
52AC_CONFIG_HEADERS([config.h dods-datatypes-config.h xdr-datatypes-config.h])
53AC_CONFIG_MACRO_DIR([conf])
54
55AM_INIT_AUTOMAKE
56AC_CONFIG_TESTDIR(tests, [.])
57
58AC_DEFINE(CNAME, "libdap", [What sort of HTTP client is this?])
59AC_DEFINE_UNQUOTED(CVER, "$PACKAGE_VERSION", [Client version number])
60AC_DEFINE_UNQUOTED(DVR, "libdap/$PACKAGE_VERSION", [Client name and version combined])
61AC_SUBST(DVR)
62
63dnl Use one of these two blocks to build a DAP2 or DAP 3.2 DDX
64dnl AC_DEFINE(DAP2_DDX, 1, [Build the DAP 2 version of the DDX])
65dnl AC_SUBST(DAP2_DDX)
66AC_DEFINE(DAP3_2_DDX, 1, [Build the DAP 3.2 version of the DDX])
67AC_SUBST(DAP3_2_DDX)
68
69AS_IF([echo $PACKAGE_VERSION | grep '^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)-\([[0-9]]*\)$'],
70      [PACKAGE_MAJOR_VERSION=`echo $PACKAGE_VERSION | sed 's@^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)-\([[0-9]]*\)$@\1@'`
71       PACKAGE_MINOR_VERSION=`echo $PACKAGE_VERSION | sed 's@^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)-\([[0-9]]*\)$@\2@'`
72       PACKAGE_PATCH_VERSION=`echo $PACKAGE_VERSION | sed 's@^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)-\([[0-9]]*\)$@\3@'`
73       PACKAGE_BUILD_NUMBER=`echo $PACKAGE_VERSION | sed 's@^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)-\([[0-9]]*\)$@\4@'`],
74      [AS_IF([echo $PACKAGE_VERSION | grep '^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$'],
75       [PACKAGE_MAJOR_VERSION=`echo $PACKAGE_VERSION | sed 's@^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$@\1@'`
76        PACKAGE_MINOR_VERSION=`echo $PACKAGE_VERSION | sed 's@^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$@\2@'`
77        PACKAGE_PATCH_VERSION=`echo $PACKAGE_VERSION | sed 's@^\([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$@\3@'`
78        PACKAGE_BUILD_NUMBER=],
79       [AC_MSG_ERROR([VERSION file does not contain a valid version number (x.y.z or x.y.z-b)])])])
80
81AC_MSG_NOTICE(Package Major Version: $PACKAGE_MAJOR_VERSION)
82AC_MSG_NOTICE(Package Minor Version: $PACKAGE_MINOR_VERSION)
83AC_MSG_NOTICE(Package Patch Version: $PACKAGE_PATCH_VERSION)
84AC_MSG_NOTICE(Package Build Number: $PACKAGE_BUILD_NUMBER)
85AC_SUBST(PACKAGE_MAJOR_VERSION)
86AC_SUBST(PACKAGE_MINOR_VERSION)
87AC_SUBST(PACKAGE_PATCH_VERSION)
88AC_SUBST(PACKAGE_BUILD_NUMBER)
89
90dnl flags for the compilers and linkers - set these before locating the
91dnl actual tools since some of the AC_PROG macros set these `flag variables'
92dnl to default values otherwise.
93
94AC_CANONICAL_HOST
95AC_SUBST(host)
96
97dnl How to set these SO variables:
98dnl No interfaces changed, only implementations (good): ==> Increment REVISION.
99dnl Interfaces added, none removed (good): ==> Increment CURRENT,
100dnl increment AGE, set REVISION to 0.
101dnl Interfaces removed or changed (BAD, breaks upward compatibility):
102dnl ==> Increment CURRENT, set AGE and REVISION to 0.
103
104DAPLIB_CURRENT=27
105DAPLIB_REVISION=4
106DAPLIB_AGE=0
107
108AC_SUBST(DAPLIB_CURRENT)
109AC_SUBST(DAPLIB_REVISION)
110AC_SUBST(DAPLIB_AGE)
111
112LIBDAP_VERSION="$DAPLIB_CURRENT:$DAPLIB_REVISION:$DAPLIB_AGE"
113AC_SUBST(LIBDAP_VERSION)
114
115CLIENTLIB_CURRENT=7
116CLIENTLIB_AGE=1
117CLIENTLIB_REVISION=11
118AC_SUBST(CLIENTLIB_CURRENT)
119AC_SUBST(CLIENTLIB_AGE)
120AC_SUBST(CLIENTLIB_REVISION)
121
122CLIENTLIB_VERSION="$CLIENTLIB_CURRENT:$CLIENTLIB_REVISION:$CLIENTLIB_AGE"
123AC_SUBST(CLIENTLIB_VERSION)
124
125SERVERLIB_CURRENT=13
126SERVERLIB_AGE=6
127SERVERLIB_REVISION=11
128AC_SUBST(SERVERLIB_CURRENT)
129AC_SUBST(SERVERLIB_AGE)
130AC_SUBST(SERVERLIB_REVISION)
131
132SERVERLIB_VERSION="$SERVERLIB_CURRENT:$SERVERLIB_REVISION:$SERVERLIB_AGE"
133AC_SUBST(SERVERLIB_VERSION)
134
135dnl Suppress the default values automake supplies for these. You can still
136dnl set them on the command line, however. (e.g., ./configure ... CXXFLAGS="-g -o3").
137dnl jhrg 2/6/18
138: ${CFLAGS=""}
139: ${CXXFLAGS=""}
140
141dnl Checks for programs.
142AC_PROG_AWK
143AC_PROG_CXX
144AC_PROG_CC
145
146dnl Call this gnulib macro right after a working C Compiler is found
147gl_EARLY
148
149dnl echo "CC = $CC"
150AS_IF([test "x$CC" = xgcc],
151      [AM_CONDITIONAL([COMPILER_IS_GCC],[true])],
152      [AM_CONDITIONAL([COMPILER_IS_GCC],[false])])
153
154dnl AC_PROG_YACC
155dnl AC_PROG_LEX
156
157dnl NB: CentOS 6 does not support C++-11 but does support some features:
158dnl https://gcc.gnu.org/gcc-4.4/cxx0x_status.html.
159dnl For now, I'm counting 0x as supporting C++-11 in our code.
160
161CXX11_FLAG=""
162
163CXX_FLAGS_CHECK([--std=c++11], [CXX11_FLAG=--std=c++11], [])
164
165AS_IF([test -z "$CXX11_FLAG"],
166      [CXX_FLAGS_CHECK([--std=c++0x], [CXX11_FLAG=--std=c++0x], [])])
167
168AS_IF([test -z "$CXX11_FLAG"],
169      [AC_MSG_ERROR([Not using C++11 (or C++0x)])],
170      [AC_MSG_NOTICE([Using $CXX11_FLAG for C++11 support])
171       cxx_debug_flags="$cxx_debug_flags --pedantic $CXX11_FLAG"])
172
173AC_SUBST(CXX11_FLAG)
174
175AM_PROG_LEX
176AC_PROG_INSTALL
177AC_PROG_LN_S
178AC_PROG_MAKE_SET
179AC_PROG_LIBTOOL
180
181dnl We really need bison and not yacc. If you use AC_PROG_YACC, the resulting
182dnl Makefile will call bison -y which doesn't know how to make the parsers
183dnl we require. jhrg 6/15/05
184AC_CHECK_PROG(YACC,[bison],[bison])
185
186dnl We have found bison; get its version
187bison_version=`bison --version | sed -n '/^bison.*/p' | sed 's@.* \(.*\)@\1@'`
188
189AC_MSG_CHECKING([for bison 3.0])
190
191# This was used to set a conditional in the d4_ce/Makefile.am to build
192# the DAP4 parsers using bison 3 or get pre-built sources from a set
193# of template files. That didn't work on some linux machines, so bison
194# 3 is a requirement for building until that gets sorted out. jhrg 4/5/15
195dnl AS_VERSION_COMPARE(["$bison_version"], ["3.0"],
196dnl 	[AM_CONDITIONAL([BISON3], [false])],
197dnl 	[AM_CONDITIONAL([BISON3], [true])],
198dnl 	[AM_CONDITIONAL([BISON3], [true])])
199
200AS_VERSION_COMPARE(["$bison_version"], ["3.0"],
201	[AC_MSG_ERROR([not found])],
202	[ ],
203	[ ])
204
205AC_MSG_RESULT([found vesion $bison_version])
206
207dnl Checks for header files.
208AC_HEADER_DIRENT
209AC_HEADER_STDC
210AC_HEADER_SYS_WAIT
211
212AC_CHECK_HEADERS_ONCE([fcntl.h malloc.h memory.h stddef.h stdlib.h string.h strings.h unistd.h pthread.h])
213AC_CHECK_HEADERS_ONCE([sys/param.h sys/time.h])
214AC_CHECK_HEADERS_ONCE([netinet/in.h])
215
216dnl AC_CHECK_HEADERS_ONCE([uuid/uuid.h uuid.h])
217dnl Do this because we have had a number of problems with the UUID header/library
218AC_CHECK_HEADERS([uuid/uuid.h],[found_uuid_uuid_h=true],[found_uuid_uuid_h=false])
219AC_CHECK_HEADERS([uuid.h],[found_uuid_h=true],[found_uuid_h=false])
220
221AS_IF([test $found_uuid_uuid_h = true -o $found_uuid_h = true], [], [AC_MSG_ERROR([Could not find uuid.h])])
222
223dnl Checks for typedefs, structures, and compiler characteristics.
224AC_C_CONST
225AC_C_INLINE
226AC_TYPE_SIZE_T
227AC_CHECK_MEMBERS([struct stat.st_blksize])
228AC_HEADER_TIME
229AC_STRUCT_TM
230AC_C_VOLATILE
231AC_C_BIGENDIAN
232
233# This is used by the DMR tests which must choose the correct set of baselines
234# based on word order given that DAP4 uses 'reader make right' and thus the
235# DAP4 data responses are different for different word order machines. jhrg 9/29/15
236AS_IF([test $ac_cv_c_bigendian = yes], [ac_word_order=big-endian], [ac_word_order=little-endian])
237AC_SUBST([ac_word_order])
238
239DODS_CHECK_SIZES
240
241AC_ARG_ENABLE([runtime-endian-check],
242    [AC_HELP_STRING([--enable-runtime-endian-check],
243                    [Enable runtime tests for big- or little-endian byte order (default is NO)])])
244
245AS_IF([test "x$enable_runtime_endian_check" = "xyes"], [
246    dnl Do the stuff needed for enabling the feature
247    AC_DEFINE([COMPUTE_ENDIAN_AT_RUNTIME], 1, [Should a function (run-time) be used to determine the byte order?])
248])
249
250# Checks for library functions.
251
252dnl using AC_CHECK_FUNCS does not run macros from gnulib.
253AC_CHECK_FUNCS([alarm atexit bzero dup2 getcwd getpagesize localtime_r memmove memset pow putenv setenv strchr strerror strtol strtoul timegm mktime])
254
255gl_SOURCE_BASE(gl)
256gl_M4_BASE(gl/m4)
257gl_MODULES(regex btyeswap)
258
259gl_INIT
260
261AC_ARG_WITH([curl], [AC_HELP_STRING([--with-curl=pfx], [curl/libcurl prefix; overrides other tests including pkgconfig])],
262            with_curl_prefix="$withval", with_curl_prefix="")
263
264dnl I wrote these checks because we need the *-config scripts to build, so
265dnl the AC_CHECK_LIB macro is not needed.
266
267curlprivatereq=
268curlprivatelibs=
269curl_set=
270
271if test -n "$with_curl_prefix" -a -x $with_curl_prefix/bin/curl-config
272then
273    AC_MSG_NOTICE([Using $with_curl_prefix as the curl prefix directory.])
274    CURL_LIBS="`$with_curl_prefix/bin/curl-config --libs`"
275    CURL_STATIC_LIBS=$CURL_LIBS
276    curlprivatelibs="`$with_curl_prefix/bin/curl-config --libs`"
277    CURL_CFLAGS="`$with_curl_prefix/bin/curl-config --cflags`"
278    curl_set="yes"
279elif test -n "$with_curl_prefix"
280then
281    AC_MSG_ERROR([You set the curl-prefix directory to $with_curl_prefix, but curl-config is not there.])
282fi
283
284if test -z "$curl_set"
285then
286    # curlprivatereq=
287    # curlprivatelibs=
288    libdap_pkgconfig_libcurl=yes
289    libdap_libcurl_module='libcurl >= 7.19.0'
290    PKG_CHECK_MODULES([CURL],[$libdap_libcurl_module],,
291        [libdap_pkgconfig_libcurl=no])
292    AC_MSG_CHECKING([for libcurl])
293
294    if test $libdap_pkgconfig_libcurl = 'yes'
295    then
296	   curlprivatereq=$libdap_libcurl_module
297	   CURL_STATIC_LIBS="`$PKG_CONFIG --static --libs libcurl`"
298	   AC_MSG_RESULT([yes; used pkg-config])
299    elif curl-config --version > /dev/null 2>&1
300    then
301	   version_libcurl=`curl-config --version | sed 's@libcurl \(.*\)@\1@'`
302
303       AS_VERSION_COMPARE(["$version_libcurl"], ["7.19.0"],
304                [AC_MSG_ERROR([I could not find libcurl 7.19.0 or newer, found $version_libcurl])])
305
306	   CURL_LIBS="`curl-config --libs`"
307	   CURL_STATIC_LIBS=$CURL_LIBS
308	   curlprivatelibs="`curl-config --libs`"
309	   CURL_CFLAGS="`curl-config --cflags`"
310	   AC_MSG_RESULT([yes; used curl-config and found version $version_libcurl])
311    else
312	   AC_MSG_ERROR([I could not find libcurl])
313    fi
314fi
315
316AC_SUBST([curlprivatereq])
317AC_SUBST([curlprivatelibs])
318AC_SUBST([CURL_LIBS])
319AC_SUBST([CURL_STATIC_LIBS])
320AC_SUBST([CURL_CFLAGS])
321
322dnl ******** new version, breaks the bes package step ********
323dnl jhrg 8/31/20
324dnl
325dnl AC_ARG_WITH(xml2,
326dnl     [AC_HELP_STRING([--with-xml2=PFX],
327dnl         [Prefix where libxml2 is installed (optional). This will override pkgconfig, etc.])],
328dnl     [with_xml2_prefix="$withval"],
329dnl     [with_xml2_prefix=""])
330dnl
331dnl AS_IF([test -n "$with_xml2_prefix" -a ! -x $with_xml2_prefix/bin/xml2-config],
332dnl     [AC_MSG_ERROR([You set the libxml2 prefix directory to $with_xml2_prefix, but xml2-config is not there.])])
333dnl
334dnl xmlprivatereq=
335dnl xmlprivatelibs=
336dnl xml_set=
337dnl
338dnl # I changed this code so that it searches for libxml2 using xml2-config
339dnl # first, then pkg-config. This works more reliably when working on OSX
340dnl # given Apple's penchant for moving the lib. jhrg 8/25/20
341dnl
342dnl AS_IF([test -n "$with_xml2_prefix" -a -x $with_xml2_prefix/bin/xml2-config],
343dnl     [
344dnl     AC_MSG_NOTICE([Using $with_xml2_prefix as the libxml2 prefix directory.])
345dnl     XML2_LIBS="`$with_xml2_prefix/bin/xml2-config --libs`"
346dnl     XML2_CFLAGS="`$with_xml2_prefix/bin/xml2-config --cflags`"
347dnl     xml_set="yes"
348dnl     ])
349dnl
350dnl # Try using the xml2-config script.
351dnl
352dnl AS_IF([test -z "$xml_set" & xml2-config --version > /dev/null 2>&1],
353dnl     [
354dnl     AC_MSG_CHECKING([for libxml2])
355dnl    	version_libxml2=`xml2-config --version`
356dnl
357dnl     AS_VERSION_COMPARE(["$version_libxml2"], ["2.7.0"],
358dnl         [AC_MSG_ERROR([I could not find libxml2 2.7.0 or newer])])
359dnl
360dnl    	XML2_LIBS="`xml2-config --libs`"
361dnl    	XML2_CFLAGS="`xml2-config --cflags`"
362dnl    	xmlprivatelibs="`xml2-config --libs `"
363dnl
364dnl    	# If XML2_CFLAGS does not have -I that ends in /libxml2, append that to
365dnl    	# the string bound to -I. Assume there is only on -I in XML2_CFLAGS. jhrg 8/25/20
366dnl    	AS_IF([echo $XML2_CFLAGS | grep -v -e '-I.*/libxml2'],
367dnl    	    [XML2_CFLAGS=`echo $XML2_CFLAGS | sed "s@\(-I.*\)@\1/libxml2/@g"`])
368dnl
369dnl    	AC_MSG_RESULT([yes; used xml2-config and found version $version_libxml2])
370dnl    	xml_set=yes
371dnl    	])
372dnl
373dnl # If not found, try pkg-config
374dnl AS_IF([test -z "$xml_set"],
375dnl     [
376dnl     libdap_libxml2_module='libxml-2.0 >= 2.7.0'
377dnl     PKG_CHECK_MODULES([XML2], [libdap_libxml2_module],
378dnl         [libdap_pkgconfig_libxml2=yes],
379dnl         [libdap_pkgconfig_libxml2=no])
380dnl     AS_IF([test $libdap_pkgconfig_libxml2 = yes],
381dnl         [
382dnl         XML2_LIBS="`$PKG_CONFIG --libs libxml-2.0`"
383dnl         XML2_CFLAGS="`$PKG_CONFIG --cflags libxml-2.0`"
384dnl         AC_MSG_RESULT([yes; used pkg-config])
385dnl         xmlprivatereq=$libdap_libxml2_module
386dnl         xml_set=yes
387dnl         ],
388dnl         [
389dnl 	    AC_MSG_ERROR([I could not find xml2-config])
390dnl 	    ])
391dnl     ])
392dnl
393dnl AS_IF([test -z "xml_set"],
394dnl     [
395dnl     AC_MSG_ERROR([I could not find xml2-config])
396dnl     ])
397dnl
398dnl AC_SUBST([xmlprivatereq])
399dnl AC_SUBST([xmlprivatelibs])
400dnl AC_SUBST([XML2_LIBS])
401dnl AC_SUBST([XML2_CFLAGS])
402dnl
403dnl ******** end new, broken-for-the-bes version *********
404
405dnl Version of XML2 configuration from git commit 8624abec8e3d510508c3c97ac60082700995af2c
406dnl jhrg 8/31/20
407
408AC_ARG_WITH(xml2,[  --with-xml2=PFX   Prefix where libxml2 is installed (optional). This will override pkgconfig, etc.],
409            with_xml2_prefix="$withval", with_xml2_prefix="")
410
411xmlprivatereq=
412xmlprivatelibs=
413xml_set=
414
415if test -n "$with_xml2_prefix" -a -x $with_xml2_prefix/bin/xml2-config
416then
417    AC_MSG_NOTICE([Using $with_xml2_prefix as the libxml2 prefix directory.])
418    XML2_LIBS="`$with_xml2_prefix/bin/xml2-config --libs`"
419    dnl XML2_STATIC_LIBS=$XML2_LIBS
420    xmlprivatelibs="`$with_xml2_prefix/bin/xml2-config --libs`"
421    XML2_CFLAGS="`$with_xml2_prefix/bin/xml2-config --cflags`"
422    xml_set="yes"
423elif test -n "$with_xml2_prefix"
424then
425    AC_MSG_ERROR([You set the libxml2 prefix directory to $with_xml2_prefix, but xml2-config is not there.])
426fi
427
428if test -z "$xml_set"
429then
430libdap_pkgconfig_libxml2=yes
431libdap_libxml2_module='libxml-2.0 >= 2.7.0'
432PKG_CHECK_MODULES([XML2],[$libdap_libxml2_module], ,[libdap_pkgconfig_libxml2=no])
433AC_MSG_CHECKING([for libxml2])
434if test $libdap_pkgconfig_libxml2 = 'yes'
435then
436	xmlprivatereq=$libdap_libxml2_module
437	dnl XML2_STATIC_LIBS="`$PKG_CONFIG --static --libs libxml-2.0`"
438	XML2_LIBS="`$PKG_CONFIG --libs libxml-2.0`"
439	AC_MSG_RESULT([yes; used pkg-config])
440elif xml2-config --version > /dev/null 2>&1
441then
442	version_libxml2=`xml2-config --version`
443
444        AS_VERSION_COMPARE(["$version_libxml2"], ["2.7.0"],
445                [AC_MSG_ERROR([I could not find libxml2 2.7.0 or newer])])
446
447	XML2_LIBS="`xml2-config --libs`"
448	dnl XML2_STATIC_LIBS=$XML2_LIBS
449	XML2_CFLAGS="`xml2-config --cflags`"
450	xmlprivatelibs="`xml2-config --libs `"
451	dnl `
452	AC_MSG_RESULT([yes; used xml2-config and found version $version_libxml2])
453else
454	AC_MSG_ERROR([I could not find xml2-config])
455fi
456fi
457
458AC_SUBST([xmlprivatereq])
459AC_SUBST([xmlprivatelibs])
460AC_SUBST([XML2_LIBS])
461dnl AC_SUBST([XML2_STATIC_LIBS])
462AC_SUBST([XML2_CFLAGS])
463
464dnl End old version of XML2 configuration. jhrg 8/31/20
465dnl ********
466
467AC_CHECK_LIB([pthread], [pthread_kill],
468	[PTHREAD_LIBS="-lpthread"],
469	[AC_MSG_ERROR([I could not find pthreads])])
470AC_SUBST([PTHREAD_LIBS])
471
472AC_CHECK_LIB([uuid], [uuid_generate],
473	[UUID_LIBS="-luuid"],
474	[UUID_LIBS=""])
475AC_SUBST([UUID_LIBS])
476
477AC_CHECK_LIB([crypto], [OpenSSL_add_all_algorithms],
478	[CRYPTO_LIBS="-lcrypto"],
479	[CRYPTO_LIBS=""])
480AC_SUBST([CRYPTO_LIBS])
481
482AM_PATH_CPPUNIT(1.12.0,
483	[AM_CONDITIONAL([CPPUNIT], [true])],
484	[
485	    PKG_CHECK_MODULES(CPPUNIT, [cppunit >= 1.12.0],
486		[AM_CONDITIONAL([CPPUNIT], [true])],
487		[AM_CONDITIONAL([CPPUNIT], [false])]
488	    )
489	]
490)
491
492DODS_DEBUG_OPTION
493
494dnl See util.cc:dods_root()
495AS_IF([test "$prefix" = "NONE"],
496      [AC_DEFINE([LIBDAP_ROOT], ["/usr/local"], [Set to the prefix directory])],
497	  [AC_DEFINE_UNQUOTED([LIBDAP_ROOT], ["$prefix"], [Set to the prefix directory])])
498
499dnl By default, DAP4 is enabled. Use this to disable. jhrg 5/12/15
500AC_ARG_ENABLE([dap4],
501    [AC_HELP_STRING([--enable-dap4], [Enable DAP4 types and responses (default is Yes)])],
502    [enable_dap4=${enableval}], [enable_dap4=yes])
503
504AS_IF([test x$enable_dap4 = xyes], [
505    dnl Do the stuff needed for enabling the feature
506    dnl echo "Defining DAP4! "
507    AC_DEFINE([DAP4], 1, [Should DAP4 support be enabled?])
508    AM_CONDITIONAL([DAP4_DEFINED], [true]) ],
509    [ dnl else enable_dap4 is false
510    AM_CONDITIONAL([DAP4_DEFINED], [false])
511])
512
513# AS_IF([test m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]),[2.64]) -ge 0],
514#	[AX_CHECK_COMPILE_FLAG([-fsanitize=address], [has_asan=yes], [has_asan=no])])
515
516AC_ARG_ENABLE([asan],
517    [AS_HELP_STRING([--enable-asan], [Build using the address sanitizer if available (default: no)])])
518
519# AM_CONDITIONAL([ENABLE_COVERAGE], [test x$enable_coverage = xyes])
520# AM_COND_IF([SHELL_WRAPPER],
521#           [AC_CONFIG_FILES([wrapper:wrapper.in])])
522
523AS_IF([test x$enable_asan = xyes -a x$has_asan = xyes],
524      [AC_MSG_NOTICE([Building Address Sanitizer version])
525       AM_CONDITIONAL([USE_ASAN], [true])],
526      [AC_MSG_NOTICE([Not building Address Sanitizer version])
527       AM_CONDITIONAL([USE_ASAN], [false])])
528
529AC_ARG_ENABLE([developer],
530    [AS_HELP_STRING([--enable-developer], [Build for debug (-g3 -O0); include assert() calls (default: no)])])
531
532AS_IF([test x$enable_developer = xyes],
533      [AC_MSG_NOTICE([Building developer version])
534       AM_CONDITIONAL([BUILD_DEVELOPER], [true])],
535      [AC_MSG_NOTICE([Not building developer version])
536       AM_CONDITIONAL([BUILD_DEVELOPER], [false])
537       AC_DEFINE([NDEBUG], [1], [Define this to suppres assert() calls.])])
538
539AC_ARG_ENABLE([coverage],
540    [AS_HELP_STRING([--enable-coverage], [Build so tests emit coverage data and enable coverage target (default: no)])])
541
542AC_CHECK_LIB([gcov], [gcov_open], [GCOV_LIBS="-lgcov"], [GCOV_LIBS=])
543
544AS_IF([test x$enable_coverage = xyes && which gcov],
545      [AC_MSG_NOTICE([Building coverage version])
546       AM_CONDITIONAL([ENABLE_COVERAGE], [true])
547       AS_IF([gcov -help | grep LLVM],
548       	     [GCOVR_FLAGS=],
549	         [GCOVR_FLAGS="-k -e '.*Test.cc' -e '.*T.cc' -e '.*-test.cc'"
550	          LIBS="-lgcov $LIBS"])],
551      [AC_MSG_NOTICE([Not building coverage version])
552       AS_IF([test x$enable_coverage = xyes],
553             [AC_MSG_NOTICE([Check that gcov is on your PATH])])
554       AM_CONDITIONAL([ENABLE_COVERAGE], [false])])
555
556# --xml-pretty -o gcovr_ouput.xml
557
558AC_SUBST([GCOVR_FLAGS])
559
560dnl autoheader macros; tack some text at the top and bottom of config_dap.h.in
561
562AH_TOP([#ifndef _config_h
563#define _config_h])
564
565AH_BOTTOM([#endif /* _config_h */])
566
567AC_CONFIG_FILES([Makefile
568                 libdap_VERSION
569                 libdap.spec
570                 libdap.pc
571                 libdapclient.pc
572                 libdapserver.pc
573                 main_page.doxygen
574	             doxy.conf
575	             abi_checker.xml
576
577                 gl/Makefile
578                 d4_ce/Makefile
579                 d4_function/Makefile
580
581                 tests/Makefile
582                 tests/atlocal
583
584                 unit-tests/Makefile
585                 unit-tests/cache-testsuite/Makefile])
586
587AC_CONFIG_FILES([dap-config], [chmod +x dap-config])
588
589AC_OUTPUT
590