netcdf-c/libncxml/Makefile.am
Dennis Heimbigner 53464e8963 Allow optional use of libxml2
re: https://github.com/Unidata/netcdf-c/issues/2119

H/T to [Egbert Eich](https://github.com/e4t) and [Bas Couwenberg](https://github.com/sebastic) for this PR.

It is undesirable to make netcdf be dependent on the availability
of libxml2, but it is desirable to allow its use if available.

In order to do this, a wrapper API (include/ncxml.h) was constructed
that supports either ezxml or libxml2 as the implementation.
Additionally, the xml support code was moved to a new directory
netcdf-c/libncxml.

Primary changes:
* Create a new sub-directory named netcdf-c/libncxml to hold all the xml implementation code.
* Move ezxml.c and ezxml.h to libncxml
* Create a wrapper API -- include/ncxml.h
* Create an implementation, ncxml_ezxml.c to support use of ezxml.
* Create an implementation, ncxml_xml2.c to support use of libxml2.
* Add a check for libxml2 in configure.ac and CMakeLists.txt
* Modify libdap to use the wrapper API instead of ezxml directly.

Misc. Other Changes:
* Change include/netcdf_json.h from built source to be part of the distribution.
2021-11-01 22:37:05 -06:00

55 lines
1.4 KiB
Makefile

# WARNING: this is not the libxml2 library
# It comes from https://github.com/recp/xml
# Copyright 2009, UCAR/Unidata
# See the COPYRIGHT file for more information.
# Use automake or CMake for building under nix
# Use CMake for building under windows
# Get AM_CPPFLAGS and AM_LDFLAGS
include $(top_srcdir)/lib_flags.am
if HAVE_LIBXML2
AM_CPPFLAGS += ${XML2FLAGS}
endif
# This is our output. The ZARR convenience library.
noinst_LTLIBRARIES = libncxml.la
libncxml_la_LIBADD =
libncxml_la_LDFLAGS =
if HAVE_LIBXML2
libncxml_la_SOURCES = ncxml_xml2.c
else
libncxml_la_SOURCES = ncxml_ezxml.c ezxml.c ezxml.h
endif
EXTRA_DIST = CMakeLists.txt license.txt
# Construct ezxml from latest sources
REPO=https://downloads.sourceforge.net/project/ezxml/
EZXML=ezxml-0.8.6.tar.gz
makelib::
rm -fr ./ezxml.[ch] ./license.txt ./ezxml
tar -zxf ./${EZXML}
echo '#define EZXML_NOMMAP 1' > ezxml.c
cat <ezxml/ezxml.c | \
sed -e '/<unistd.h>/d' | \
sed -e 's|//\(.*\)|/*\1*/|' \
sed -e 's|//\(.*\)|/*\1*/|' \
cat >./ezxml.c
sed -e 's|//\(.*\)|/*\1*/|' <ezxml/ezxml.h >./ezxml.h
cp ezxml/license.txt .
rm -fr ezxml
# Define path to the xml github dir; this value assumes it is in a parallel directory to netcdf-c (YMMV)
GITSRC=${top_srcdir}/../tinyxml2
xmakelib::
rm -f readme.md LICENSE.txt
rm -fr ./tinyxml2.cpp ./tinyxml2.h
cp ${GITSRC}/readme.md .
cp ${GITSRC}/LICENSE.txt .
cp ${GITSRC}/tinyxml2.h ${GITSRC}/tinyxml2.cpp .