[libxml2] Various "make distcheck" and portability fixups



commit 5706b6d8767e3c3f2e5b277b54e1af68035bc111
Author: Daniel Richard G <oss teragram com>
Date:   Mon Aug 6 11:32:54 2012 +0800

    Various "make distcheck" and portability fixups
    
    Makefile.am:
    
    * Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
       variable, it allows overriding the value at the command line, and
       (notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
       assignment when @MODULE_PLATFORM_LIBS@ is empty
    
    * Changed how the THREADS_W32 mechanism switches the build between
       testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
       allows this to work cleanly and plays well with dependencies
    
    * testapi.c should be specified as BUILT_SOURCES
    
    * Create symlinks to the test/ and result/ subdirs so that the runtests
       target is usable in out-of-source-tree builds
    
    * Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
    
    * Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
       instead of just "rm" is good form
    
    * (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
       pass
    
    configure.in:
    
    * Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
    
    * AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
       superceded by LT_INIT
    
    * Don't rebuild docs by default, as this requires GNU Make (as
       implemented)
    
    * Check for uint32_t as some platforms don't provide it
    
    * Check for some more functions, and undefine HAVE_MMAP if we don't also
       HAVE_MUNMAP (one system I tested on actually needed this)
    
    * Changed THREADS_W32 from a filename insert into an Automake conditional
    
    * The "Copyright" file will not be in the current directory if builddir !=
       srcdir
    
    doc/Makefile.am:
    
    * EXTRA_DIST cannot use wildcards when they refer to generated files; this
       breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
       Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
       as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
       "check-extra-dist", to simplify checking that the two variables are
       equivalent. (Note that this works only when builddir == srcdir)
    
       (I can implement this differently if desired; this is just one way of
       doing it)
    
    * Don't define an "all" target; this steps on Automake's toes
    
    * Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
       dependencies (as Make doesn't process the wildcards otherwise) and
       qualifying appropriate files with $(srcdir)
    
       (Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
       which we can count on as this is GNU-Make-only code anyway)
    
    doc/devhelp/Makefile.am:
    
    * Qualified appropriate files with $(srcdir)
    
    * Added an "uninstall-local" rule so that "make distcheck" passes
    
    doc/examples/Makefile.am:
    
    * Rather than use a wildcard that doesn't work, use a substitution that
       most Make programs can handle
    
    doc/examples/index.py:
    
    * Do the same here
    
    include/libxml/nanoftp.h:
    
    * Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
    
         user host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
         Include$ grep -R INVALID_SOCKET .
         ./WINSOCK.H:#define INVALID_SOCKET  (SOCKET)(~0)
         ./WINSOCK2.H:#define INVALID_SOCKET  (SOCKET)(~0)
    
    include/libxml/xmlversion.h.in:
    
    * Support ancient GCCs (I was actually able to build the library with 2.5
       but for this bit)
    
    python/Makefile.am:
    
    * Expanded CLEANFILES to allow "make distcheck" to pass
    
    python/tests/Makefile.am:
    
    * Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
       "make distcheck" to pass
    
    testRelax.c:
    
    * Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
       systems have the header but not the function)
    
    testSchemas.c:
    
    * Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
    
    testapi.c:
    
    * Don't use putenv() if it's not available
    
    threads.c:
    
    * This fixes the following build error on Solaris 8:
    
         libtool: compile:  cc -DHAVE_CONFIG_H -I. -I./include -I./include \
         -D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
         -xarch=v9 -xcrossfile -xO5 -c threads.c  -KPIC -DPIC -o threads.o
         "threads.c", line 442: controlling expressions must have scalar type
         "threads.c", line 512: controlling expressions must have scalar type
         cc: acomp failed for threads.c
         *** Error code 1
    
    trio.c:
    
    * Define isascii() if the system doesn't provide it
    
    trio.h:
    
    * The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
       HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
    
    win32/configure.js:
    
    * Added support for the LZMA compression option
    
    win32/Makefile.{bcb,mingw,msvc}:
    
    * Added appropriate bits to support WITH_LZMA=1
    
    * Install the header files under $(INCPREFIX)\libxml2\libxml instead of
       $(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
    
    xml2-config.in:
    
    * @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
       `xml2-config --libs` to provide a complete set of dependencies
    
    xmllint.c:
    
    * Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H

 Makefile.am                    |   79 ++++----
 configure.in                   |   25 ++-
 doc/Makefile.am                |  267 ++++++++++++++++++++++---
 doc/devhelp/Makefile.am        |   16 +-
 doc/examples/.cvsignore        |   20 +-
 doc/examples/Makefile.am       |  124 ++++++------
 doc/examples/examples.xml      |  440 ++++++++++++++++++++--------------------
 doc/examples/index.py          |    2 +-
 example/Makefile.am            |    6 +-
 include/libxml/nanoftp.h       |    1 +
 include/libxml/xmlversion.h.in |    6 +-
 python/Makefile.am             |    8 +-
 python/tests/Makefile.am       |    5 +-
 testRelax.c                    |    8 +-
 testSchemas.c                  |    8 +-
 testapi.c                      |    2 +
 threads.c                      |    4 +-
 trio.c                         |    4 +
 trio.h                         |    2 +-
 win32/Makefile.bcb             |   11 +-
 win32/Makefile.mingw           |   11 +-
 win32/Makefile.msvc            |    5 +-
 xml2-config.in                 |    6 +-
 xmllint.c                      |   18 +-
 xstc/Makefile.am               |    4 +-
 25 files changed, 674 insertions(+), 408 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index cb21543..c5e34ea 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,11 +2,11 @@
 
 ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS = include . doc example xstc @PYTHON_SUBDIR@
+SUBDIRS = include . doc example xstc $(PYTHON_SUBDIR)
 
 DIST_SUBDIRS = include . doc example python xstc
 
-INCLUDES = -I$(top_builddir)/include -I srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@ @LZMA_CFLAGS@
+INCLUDES = -I$(top_builddir)/include -I$(srcdir)/include $(THREAD_CFLAGS) $(Z_CFLAGS) $(LZMA_CFLAGS)
 
 noinst_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \
                 testThreads testC14N testAutomata testRegexp \
@@ -18,7 +18,7 @@ bin_PROGRAMS = xmllint xmlcatalog
 bin_SCRIPTS=xml2-config
 
 lib_LTLIBRARIES = libxml2.la
-libxml2_la_LIBADD = @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ $(ICONV_LIBS) @M_LIBS@ @WIN32_EXTRA_LIBADD@
+libxml2_la_LIBADD = $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD)
 
 if USE_VERSION_SCRIPT
 LIBXML2_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/libxml2.syms
@@ -26,10 +26,10 @@ else
 LIBXML2_VERSION_SCRIPT =
 endif
 
-libxml2_la_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ @WIN32_EXTRA_LDFLAGS@ \
-                     $(LIBXML2_VERSION_SCRIPT) \
-		     -version-info @LIBXML_VERSION_INFO@ \
-		     @MODULE_PLATFORM_LIBS@
+libxml2_la_LDFLAGS = $(CYGWIN_EXTRA_LDFLAGS) $(WIN32_EXTRA_LDFLAGS) \
+		     $(LIBXML2_VERSION_SCRIPT) \
+		     -version-info $(LIBXML_VERSION_INFO) \
+		     $(MODULE_PLATFORM_LIBS)
 
 if WITH_TRIO_SOURCES
 libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c  \
@@ -54,7 +54,7 @@ libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c  \
 endif
 
 DEPS = $(top_builddir)/libxml2.la
-LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ $(ICONV_LIBS) @M_LIBS@ @WIN32_EXTRA_LIBADD@
+LDADDS = $(STATIC_BINARIES) $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD)
 
 
 man_MANS = xml2-config.1 libxml.3
@@ -65,37 +65,37 @@ m4data_DATA = libxml.m4
 runtest_SOURCES=runtest.c
 runtest_LDFLAGS = 
 runtest_DEPENDENCIES = $(DEPS)
-runtest_LDADD= @BASE_THREAD_LIBS@ @RDL_LIBS@ $(LDADDS)
+runtest_LDADD= $(BASE_THREAD_LIBS) $(RDL_LIBS) $(LDADDS)
 
 testrecurse_SOURCES=testrecurse.c
 testrecurse_LDFLAGS = 
 testrecurse_DEPENDENCIES = $(DEPS)
-testrecurse_LDADD= @BASE_THREAD_LIBS@ @RDL_LIBS@ $(LDADDS)
+testrecurse_LDADD= $(BASE_THREAD_LIBS) $(RDL_LIBS) $(LDADDS)
 
 testlimits_SOURCES=testlimits.c
 testlimits_LDFLAGS = 
 testlimits_DEPENDENCIES = $(DEPS)
-testlimits_LDADD= @BASE_THREAD_LIBS@ @RDL_LIBS@ $(LDADDS)
+testlimits_LDADD= $(BASE_THREAD_LIBS) $(RDL_LIBS) $(LDADDS)
 
 testchar_SOURCES=testchar.c
 testchar_LDFLAGS = 
 testchar_DEPENDENCIES = $(DEPS)
-testchar_LDADD= @RDL_LIBS@ $(LDADDS)
+testchar_LDADD= $(RDL_LIBS) $(LDADDS)
 
 testdict_SOURCES=testdict.c
 testdict_LDFLAGS = 
 testdict_DEPENDENCIES = $(DEPS)
-testdict_LDADD= @RDL_LIBS@ $(LDADDS)
+testdict_LDADD= $(RDL_LIBS) $(LDADDS)
 
 runsuite_SOURCES=runsuite.c
 runsuite_LDFLAGS = 
 runsuite_DEPENDENCIES = $(DEPS)
-runsuite_LDADD= @RDL_LIBS@ $(LDADDS)
+runsuite_LDADD= $(RDL_LIBS) $(LDADDS)
 
 xmllint_SOURCES=xmllint.c
 xmllint_LDFLAGS = 
 xmllint_DEPENDENCIES = $(DEPS)
-xmllint_LDADD=  @RDL_LIBS@ $(LDADDS)
+xmllint_LDADD=  $(RDL_LIBS) $(LDADDS)
 
 testSAX_SOURCES=testSAX.c
 testSAX_LDFLAGS = 
@@ -110,7 +110,7 @@ testHTML_LDADD= $(LDADDS)
 xmlcatalog_SOURCES=xmlcatalog.c
 xmlcatalog_LDFLAGS = 
 xmlcatalog_DEPENDENCIES = $(DEPS)
-xmlcatalog_LDADD= @RDL_LIBS@ $(LDADDS)
+xmlcatalog_LDADD = $(RDL_LIBS) $(LDADDS)
 
 testXPath_SOURCES=testXPath.c
 testXPath_LDFLAGS = 
@@ -122,10 +122,14 @@ testC14N_LDFLAGS =
 testC14N_DEPENDENCIES = $(DEPS)
 testC14N_LDADD= $(LDADDS)
 
-testThreads_SOURCES=testThreads THREADS_W32@.c
+if THREADS_W32
+testThreads_SOURCES = testThreadsWin32.c
+else
+testThreads_SOURCES = testThreads.c
+endif
 testThreads_LDFLAGS = 
 testThreads_DEPENDENCIES = $(DEPS)
-testThreads_LDADD= @BASE_THREAD_LIBS@  $(LDADDS)
+testThreads_LDADD= $(BASE_THREAD_LIBS) $(LDADDS)
 
 testURI_SOURCES=testURI.c
 testURI_LDFLAGS = 
@@ -177,6 +181,8 @@ testapi.c: $(srcdir)/gentest.py
 	-@(if [ "$(PYTHON)" != "" ] ; then \
 	    $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
 
+BUILT_SOURCES = testapi.c
+
 testapi_SOURCES=testapi.c
 testapi_LDFLAGS = 
 testapi_DEPENDENCIES = $(DEPS)
@@ -193,9 +199,11 @@ runxmlconf_LDADD= $(LDADDS)
 #testOOM_LDADD= $(LDADDS)
 
 runtests:
+	[ -d test   ] || $(LN_S) $(srcdir)/test   .
+	[ -d result ] || $(LN_S) $(srcdir)/result .
 	$(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) ./testapi$(EXEEXT) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
-	@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; \
-	    $(MAKE) MAKEFLAGS+=--silent tests ; fi)
+	@(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \
+	    $(MAKE) tests ; fi)
 
 check: all runtests
 
@@ -206,10 +214,10 @@ check-valgrind: all
 
 testall : tests SVGtests SAXtests
 
-tests: XMLtests XMLenttests NStests IDtests Errtests APItests @READER_TEST@ @TEST_SAX@ @TEST_PUSH@ @TEST_HTML@ @TEST_PHTML@  @TEST_VALID@ URItests @TEST_PATTERN@ @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_SCHEMATRON@ @TEST_THREADS@ Timingtests @TEST_VTIME@ @PYTHON_TESTS@ @TEST_MODULES@
-	@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; \
-	    $(MAKE) MAKEFLAGS+=--silent tests ; fi)
-	@(cd doc/examples ; $(MAKE) MAKEFLAGS+=--silent tests)
+tests: XMLtests XMLenttests NStests IDtests Errtests APItests $(READER_TEST) $(TEST_SAX) $(TEST_PUSH) $(TEST_HTML) $(TEST_PHTML) $(TEST_VALID) URItests $(TEST_PATTERN) $(TEST_XPATH) $(TEST_XPTR) $(TEST_XINCLUDE) $(TEST_C14N) $(TEST_DEBUG) $(TEST_CATALOG) $(TEST_REGEXPS) $(TEST_SCHEMAS) $(TEST_SCHEMATRON) $(TEST_THREADS) Timingtests $(TEST_VTIME) $(PYTHON_TESTS) $(TEST_MODULES)
+	@(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \
+	    $(MAKE) tests ; fi)
+	@(cd doc/examples ; $(MAKE) tests)
 
 valgrind:
 	@echo '## Running the regression tests under Valgrind'
@@ -1120,7 +1128,7 @@ SchemasPythonTests:
 	    echo "## It is normal to see 11 errors reported" ; \
 	    $(CHECKER) $(PYTHON) $(srcdir)/check-xsddata-test-suite.py ; \
 	  fi)
-	@(if [ -x $(PYTHON) -a -d xstc ] ; then cd xstc ; $(MAKE) CHECKER="$(CHECKER)" MAKEFLAGS+=--silent pytests ; fi)
+	@(if [ -x $(PYTHON) -a -d xstc ] ; then cd xstc ; $(MAKE) CHECKER="$(CHECKER)" pytests ; fi)
 
 Patterntests: xmllint$(EXEEXT)
 	@(echo > .memdump)
@@ -1152,8 +1160,8 @@ ModuleTests: testModule$(EXEEXT) testdso.la
 
 cleanup:
 	-@(find . -name .\#\* -exec rm {} \;)
-	-@(find . -name \*.gcda -o *.gcno -exec rm {} \;)
-	-@(find . -name \*.orig -o -name \*.rej -o -name \*.old -exec rm {} \;)
+	-@(find . -name \*.gcda -o -name \*.gcno -exec rm -f {} \;)
+	-@(find . -name \*.orig -o -name \*.rej -o -name \*.old -exec rm -f {} \;)
 
 dist-hook: cleanup libxml2.spec
 	-cp libxml2.spec $(distdir)
@@ -1188,7 +1196,8 @@ xml2Conf.sh: xml2Conf.sh.in Makefile
 	       < $(srcdir)/xml2Conf.sh.in > xml2Conf.tmp \
 	&& mv xml2Conf.tmp xml2Conf.sh
 
-CLEANFILES=xml2Conf.sh *.gcda *.gcno
+CLEANFILES = runxmlconf.log test.out xml2Conf.sh *.gcda *.gcno *.res
+DISTCLEANFILES = COPYING libxml2.syms missing.lst
 
 confexecdir=$(libdir)
 confexec_DATA = xml2Conf.sh
@@ -1218,13 +1227,13 @@ DOC_MODULE=libxml2-$(VERSION)
 EXAMPLES_DIR=$(BASE_DIR)/$(DOC_MODULE)/examples
 
 install-data-local: 
-	@MKDIR_P@ $(DESTDIR)$(BASE_DIR)/$(DOC_MODULE)
-	- INSTALL@ -m 0644 $(srcdir)/Copyright $(DESTDIR)$(BASE_DIR)/$(DOC_MODULE)
-	@MKDIR_P@ $(DESTDIR)$(EXAMPLES_DIR)
-	- INSTALL@ -m 0644 $(srcdir)/xmllint.c $(DESTDIR)$(EXAMPLES_DIR)
-	- INSTALL@ -m 0644 $(srcdir)/testSAX.c $(DESTDIR)$(EXAMPLES_DIR)
-	- INSTALL@ -m 0644 $(srcdir)/testHTML.c $(DESTDIR)$(EXAMPLES_DIR)
-	- INSTALL@ -m 0644 $(srcdir)/testXPath.c $(DESTDIR)$(EXAMPLES_DIR)
+	$(MKDIR_P) $(DESTDIR)$(BASE_DIR)/$(DOC_MODULE)
+	-$(INSTALL) -m 0644 $(srcdir)/Copyright $(DESTDIR)$(BASE_DIR)/$(DOC_MODULE)
+	$(MKDIR_P) $(DESTDIR)$(EXAMPLES_DIR)
+	-$(INSTALL) -m 0644 $(srcdir)/xmllint.c $(DESTDIR)$(EXAMPLES_DIR)
+	-$(INSTALL) -m 0644 $(srcdir)/testSAX.c $(DESTDIR)$(EXAMPLES_DIR)
+	-$(INSTALL) -m 0644 $(srcdir)/testHTML.c $(DESTDIR)$(EXAMPLES_DIR)
+	-$(INSTALL) -m 0644 $(srcdir)/testXPath.c $(DESTDIR)$(EXAMPLES_DIR)
 
 uninstall-local:
 	rm -f $(DESTDIR)$(EXAMPLES_DIR)/testXPath.c
diff --git a/configure.in b/configure.in
index 0fb4983..ccbc330 100644
--- a/configure.in
+++ b/configure.in
@@ -58,6 +58,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_INSTALL
+AC_PROG_LN_S
 AC_PROG_MKDIR_P
 AC_PROG_CPP
 AC_PATH_PROG(RM, rm, /bin/rm)
@@ -68,8 +69,7 @@ AC_PATH_PROG(WGET, wget, /usr/bin/wget)
 AC_PATH_PROG(XMLLINT, xmllint, /usr/bin/xmllint)
 AC_PATH_PROG(XSLTPROC, xsltproc, /usr/bin/xsltproc)
 
-AC_LIBTOOL_WIN32_DLL
-AM_PROG_LIBTOOL
+LT_INIT
 
 dnl
 dnl if the system support linker version scripts for symbol versioning
@@ -205,8 +205,8 @@ AC_ARG_WITH(coverage,
 [  --with-coverage         build for code coverage with GCC (off)])
 
 AC_ARG_ENABLE(rebuild-docs,
-[  --enable-rebuild-docs[[=yes/no]]  rebuild some generated docs [[default=yes]]])
-AM_CONDITIONAL([REBUILD_DOCS], [test "$enable_rebuild_docs" = "no"])
+[  --enable-rebuild-docs[[=yes/no]]  rebuild some generated docs [[default=no]]])
+AM_CONDITIONAL([REBUILD_DOCS], [test "$enable_rebuild_docs" = "yes"])
 
 dnl
 dnl hard dependancies on options
@@ -500,6 +500,11 @@ AC_CHECK_HEADERS([dl.h])
 AC_CHECK_HEADERS([dlfcn.h])
 
 
+echo Checking types
+
+AC_TYPE_UINT32_T
+
+
 echo Checking libraries
 
 dnl Checks for library functions.
@@ -509,6 +514,12 @@ AC_CHECK_FUNCS(finite isnand fp_class class fpclass)
 AC_CHECK_FUNCS(strftime localtime gettimeofday ftime)
 AC_CHECK_FUNCS(stat _stat signal)
 AC_CHECK_FUNCS(rand rand_r srand time)
+AC_CHECK_FUNCS(isascii mmap munmap putenv)
+
+AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */
+#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
+#  undef /**/ HAVE_MMAP
+#endif])
 
 dnl Checking for va_copy availability
 AC_MSG_CHECKING([for va_copy])
@@ -949,7 +960,7 @@ else
     case $host_os in
        *mingw32*) if test "$with_threads" != "pthread" && test "$with_threads" != "no"; then
                WITH_THREADS="1"
-               THREADS_W32="Win32"
+               THREADS_W32="1"
                THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
            fi
        ;;
@@ -1010,7 +1021,7 @@ AC_SUBST(BASE_THREAD_LIBS)
 AC_SUBST(WITH_THREADS)
 AC_SUBST(THREAD_CFLAGS)
 AC_SUBST(TEST_THREADS)
-AC_SUBST(THREADS_W32)
+AM_CONDITIONAL(THREADS_W32, test -n "$THREADS_WIN32")
 
 dnl
 dnl xmllint shell history
@@ -1550,7 +1561,7 @@ AC_SUBST(RELDATE)
 AC_SUBST(PYTHON_TESTS)
 
 rm -f COPYING.LIB COPYING
-ln -s Copyright COPYING
+ln -s $srcdir/Copyright COPYING
 
 # keep on one line for cygwin c.f. #130896
 AC_OUTPUT(libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h xml2-config libxml-2.0.pc libxml-2.0-uninstalled.pc python/setup.py)
diff --git a/doc/Makefile.am b/doc/Makefile.am
index dd39f69..b9ab1ad 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -16,21 +16,229 @@ PAGES= architecture.html bugs.html contribs.html docs.html DOM.html \
     tree.html xmldtd.html XMLinfo.html XSLT.html
 APIPAGES=APIconstructors.html APIfiles.html APIfunctions.html \
     APIsymbols.html APIchunk0.html
-EXTRA_DIST=xmlcatalog_man.xml tutorial/*.html tutorial/*.c tutorial/*.pdf \
-           tutorial/images/*.png tutorial/images/callouts/*.png \
-	   API*.html *.1 *.xsl *.html *.gif w3c.png html/*.html \
-	   html/*.png libxml2-api.xml index.py search.php \
-	   apibuild.py libxml2.xsa xmllint.xml xmlcatalog_man.xml \
-	   README.docs symbols.xml
 
+if REBUILD_DOCS
+EXTRA_DIST_wc = xmlcatalog_man.xml $(wildcard tutorial/*.html) \
+    $(wildcard tutorial/*.c) $(wildcard tutorial/*.pdf) \
+    $(wildcard tutorial/images/*.png) \
+    $(wildcard tutorial/images/callouts/*.png) $(wildcard API*.html) \
+    $(wildcard *.1) $(wildcard *.xsl) $(wildcard *.html) \
+    $(wildcard *.gif) w3c.png $(wildcard html/*.html) \
+    $(wildcard html/*.png) libxml2-api.xml index.py search.php \
+    apibuild.py libxml2.xsa xmllint.xml xmlcatalog_man.xml \
+    README.docs symbols.xml
+endif
+
+# Expanded form of EXTRA_DIST_wc
+#
+EXTRA_DIST = \
+	APIchunk0.html \
+	APIchunk1.html \
+	APIchunk2.html \
+	APIchunk3.html \
+	APIchunk4.html \
+	APIchunk5.html \
+	APIchunk6.html \
+	APIchunk7.html \
+	APIchunk8.html \
+	APIchunk9.html \
+	APIchunk10.html \
+	APIchunk11.html \
+	APIchunk12.html \
+	APIchunk13.html \
+	APIchunk14.html \
+	APIchunk15.html \
+	APIchunk16.html \
+	APIchunk17.html \
+	APIchunk18.html \
+	APIchunk19.html \
+	APIchunk20.html \
+	APIchunk21.html \
+	APIchunk22.html \
+	APIchunk23.html \
+	APIchunk24.html \
+	APIchunk25.html \
+	APIchunk26.html \
+	APIchunk27.html \
+	APIchunk28.html \
+	APIchunk29.html \
+	APIconstructors.html \
+	APIfiles.html \
+	APIfunctions.html \
+	APIsymbols.html \
+	ChangeLog.xsl \
+	DOM.gif \
+	DOM.html \
+	FAQ.html \
+	Libxml2-Logo-180x168.gif \
+	Libxml2-Logo-90x34.gif \
+	README.docs \
+	XMLinfo.html \
+	XSLT.html \
+	api.xsl \
+	apibuild.py \
+	architecture.html \
+	bugs.html \
+	catalog.gif \
+	catalog.html \
+	checkapisym.xsl \
+	contribs.html \
+	docs.html \
+	downloads.html \
+	elfgcchack.xsl \
+	encoding.html \
+	entities.html \
+	example.html \
+	guidelines.html \
+	help.html \
+	html/book1.html \
+	html/home.png \
+	html/index.html \
+	html/left.png \
+	html/libxml-DOCBparser.html \
+	html/libxml-HTMLparser.html \
+	html/libxml-HTMLtree.html \
+	html/libxml-SAX.html \
+	html/libxml-SAX2.html \
+	html/libxml-c14n.html \
+	html/libxml-catalog.html \
+	html/libxml-chvalid.html \
+	html/libxml-debugXML.html \
+	html/libxml-dict.html \
+	html/libxml-encoding.html \
+	html/libxml-entities.html \
+	html/libxml-globals.html \
+	html/libxml-hash.html \
+	html/libxml-lib.html \
+	html/libxml-list.html \
+	html/libxml-nanoftp.html \
+	html/libxml-nanohttp.html \
+	html/libxml-parser.html \
+	html/libxml-parserInternals.html \
+	html/libxml-pattern.html \
+	html/libxml-relaxng.html \
+	html/libxml-schemasInternals.html \
+	html/libxml-schematron.html \
+	html/libxml-threads.html \
+	html/libxml-tree.html \
+	html/libxml-uri.html \
+	html/libxml-valid.html \
+	html/libxml-xinclude.html \
+	html/libxml-xlink.html \
+	html/libxml-xmlIO.html \
+	html/libxml-xmlautomata.html \
+	html/libxml-xmlerror.html \
+	html/libxml-xmlexports.html \
+	html/libxml-xmlmemory.html \
+	html/libxml-xmlmodule.html \
+	html/libxml-xmlreader.html \
+	html/libxml-xmlregexp.html \
+	html/libxml-xmlsave.html \
+	html/libxml-xmlschemas.html \
+	html/libxml-xmlschemastypes.html \
+	html/libxml-xmlstring.html \
+	html/libxml-xmlunicode.html \
+	html/libxml-xmlversion.html \
+	html/libxml-xmlwriter.html \
+	html/libxml-xpath.html \
+	html/libxml-xpathInternals.html \
+	html/libxml-xpointer.html \
+	html/right.png \
+	html/up.png \
+	index.html \
+	index.py \
+	interface.html \
+	intro.html \
+	library.html \
+	libxml.gif \
+	libxml2-api.xml \
+	libxml2.xsa \
+	namespaces.html \
+	newapi.xsl \
+	news.html \
+	news.xsl \
+	python.html \
+	redhat.gif \
+	search.php \
+	searches.html \
+	searches.xsl \
+	site.xsl \
+	smallfootonly.gif \
+	structure.gif \
+	symbols.xml \
+	syms.xsl \
+	threads.html \
+	tree.html \
+	tutorial/apa.html \
+	tutorial/apb.html \
+	tutorial/apc.html \
+	tutorial/apd.html \
+	tutorial/ape.html \
+	tutorial/apf.html \
+	tutorial/apg.html \
+	tutorial/aph.html \
+	tutorial/api.html \
+	tutorial/ar01s02.html \
+	tutorial/ar01s03.html \
+	tutorial/ar01s04.html \
+	tutorial/ar01s05.html \
+	tutorial/ar01s06.html \
+	tutorial/ar01s07.html \
+	tutorial/ar01s08.html \
+	tutorial/ar01s09.html \
+	tutorial/images/blank.png \
+	tutorial/images/callouts/1.png \
+	tutorial/images/callouts/10.png \
+	tutorial/images/callouts/2.png \
+	tutorial/images/callouts/3.png \
+	tutorial/images/callouts/4.png \
+	tutorial/images/callouts/5.png \
+	tutorial/images/callouts/6.png \
+	tutorial/images/callouts/7.png \
+	tutorial/images/callouts/8.png \
+	tutorial/images/callouts/9.png \
+	tutorial/images/caution.png \
+	tutorial/images/draft.png \
+	tutorial/images/home.png \
+	tutorial/images/important.png \
+	tutorial/images/next.png \
+	tutorial/images/note.png \
+	tutorial/images/prev.png \
+	tutorial/images/tip.png \
+	tutorial/images/toc-blank.png \
+	tutorial/images/toc-minus.png \
+	tutorial/images/toc-plus.png \
+	tutorial/images/up.png \
+	tutorial/images/warning.png \
+	tutorial/includeaddattribute.c \
+	tutorial/includeaddkeyword.c \
+	tutorial/includeconvert.c \
+	tutorial/includegetattribute.c \
+	tutorial/includekeyword.c \
+	tutorial/includexpath.c \
+	tutorial/index.html \
+	tutorial/ix01.html \
+	tutorial/xmltutorial.pdf \
+	upgrade.html \
+	w3c.png \
+	wiki.xsl \
+	xml.html \
+	xmlcatalog.1 \
+	xmlcatalog_man.html \
+	xmlcatalog_man.xml \
+	xmldtd.html \
+	xmlio.html \
+	xmllint.1 \
+	xmllint.html \
+	xmllint.xml \
+	xmlmem.html \
+	xmlreader.html \
+	xsa.xsl
 
 man_MANS = xmllint.1 xmlcatalog.1
 
 if REBUILD_DOCS
-all: web $(top_builddir)/NEWS libxml2.xsa $(man_MANS)
-else
-all:
-endif
+docs: web $(top_builddir)/NEWS libxml2.xsa $(man_MANS)
 
 api: libxml2-api.xml libxml2-refs.xml $(APIPAGES) $(srcdir)/html/index.html $(WIN32_DIR)/libxml2.def.src ../elfgcchack.h $(srcdir)/site.xsl
 
@@ -89,10 +297,10 @@ $(WIN32_DIR)/libxml2.def.src: libxml2-api.xml
 	  $(XSLTPROC) -o $(WIN32_DIR)/libxml2.def.src \
 	  --nonet $(WIN32_DIR)/defgen.xsl libxml2-api.xml ; fi )
 
-libxml2-api.xml libxml2-refs.xml ../libxml2.syms: apibuild.py symbols.xml syms.xsl checkapisym.xsl ../include/libxml/*.h ../*.c
-	-(./apibuild.py)
-	($(XSLTPROC) checkapisym.xsl libxml2-api.xml)
-	($(XSLTPROC) -o ../libxml2.syms syms.xsl symbols.xml)
+libxml2-api.xml libxml2-refs.xml ../libxml2.syms: apibuild.py symbols.xml syms.xsl checkapisym.xsl $(wildcard $(top_srcdir)/include/libxml/*.h) $(wildcard $(top_srcdir)/*.c)
+	-($(srcdir)/apibuild.py)
+	($(XSLTPROC) $(srcdir)/checkapisym.xsl $(srcdir)/libxml2-api.xml)
+	($(XSLTPROC) -o ../libxml2.syms $(srcdir)/syms.xsl $(srcdir)/symbols.xml)
 	-@(cd .. ; $(MAKE) rebuild_testapi)
 
 
@@ -102,28 +310,35 @@ xmllint.1: xmllint.xml
 xmlcatalog.1: xmlcatalog_man.xml
 	-@($(XSLTPROC) --nonet xmlcatalog_man.xml)
 
+check-extra-dist:
+	for f in $(EXTRA_DIST_wc) ; do echo $$f; done | sort -u >tmp.EXTRA_DIST_wc
+	for f in $(EXTRA_DIST) ;    do echo $$f; done | sort    >tmp.EXTRA_DIST
+	diff -u tmp.EXTRA_DIST_wc tmp.EXTRA_DIST
+	rm -f tmp.EXTRA_DIST_wc tmp.EXTRA_DIST
+endif
+
 clean-local:
 	rm -f *~ *.bak *.hierarchy *.signals *-unused.txt
 
 maintainer-clean-local: clean-local
 	rm -rf libxml-decl-list.txt libxml-decl.txt 
 
-rebuild: api all
+rebuild: api docs
 
 install-data-local: 
-	@MKDIR_P@ $(DESTDIR)$(HTML_DIR)
-	- INSTALL@ -m 0644 $(srcdir)/xml.html $(srcdir)/encoding.html $(srcdir)/FAQ.html $(srcdir)/structure.gif $(srcdir)/DOM.gif $(srcdir)/smallfootonly.gif $(srcdir)/redhat.gif $(srcdir)/libxml.gif $(srcdir)/w3c.png $(srcdir)/Libxml2-Logo-180x168.gif $(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(HTML_DIR)
-	@MKDIR_P@ $(DESTDIR)$(HTML_DIR)/html
-	- INSTALL@ -m 0644 $(srcdir)/html/*.html $(DESTDIR)$(HTML_DIR)/html
-	- INSTALL@ -m 0644 $(srcdir)/html/*.png $(DESTDIR)$(HTML_DIR)/html
-	@MKDIR_P@ $(DESTDIR)$(HTML_DIR)/tutorial
-	- INSTALL@ -m 0644 $(srcdir)/tutorial/*.* \
+	$(MKDIR_P) $(DESTDIR)$(HTML_DIR)
+	-$(INSTALL) -m 0644 $(srcdir)/xml.html $(srcdir)/encoding.html $(srcdir)/FAQ.html $(srcdir)/structure.gif $(srcdir)/DOM.gif $(srcdir)/smallfootonly.gif $(srcdir)/redhat.gif $(srcdir)/libxml.gif $(srcdir)/w3c.png $(srcdir)/Libxml2-Logo-180x168.gif $(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(HTML_DIR)
+	$(MKDIR_P) $(DESTDIR)$(HTML_DIR)/html
+	-$(INSTALL) -m 0644 $(srcdir)/html/*.html $(DESTDIR)$(HTML_DIR)/html
+	-$(INSTALL) -m 0644 $(srcdir)/html/*.png $(DESTDIR)$(HTML_DIR)/html
+	$(MKDIR_P) $(DESTDIR)$(HTML_DIR)/tutorial
+	-$(INSTALL) -m 0644 $(srcdir)/tutorial/*.* \
 		$(DESTDIR)$(HTML_DIR)/tutorial
-	@MKDIR_P@ $(DESTDIR)$(HTML_DIR)/tutorial/images
-	- INSTALL@ -m 0644 $(srcdir)/tutorial/images/*.* \
+	$(MKDIR_P) $(DESTDIR)$(HTML_DIR)/tutorial/images
+	-$(INSTALL) -m 0644 $(srcdir)/tutorial/images/*.* \
 		$(DESTDIR)$(HTML_DIR)/tutorial/images
-	@MKDIR_P@ $(DESTDIR)$(HTML_DIR)/tutorial/images/callouts
-	- INSTALL@ -m 0644 $(srcdir)/tutorial/images/callouts/*.* \
+	$(MKDIR_P) $(DESTDIR)$(HTML_DIR)/tutorial/images/callouts
+	-$(INSTALL) -m 0644 $(srcdir)/tutorial/images/callouts/*.* \
 		$(DESTDIR)$(HTML_DIR)/tutorial/images/callouts
 
 .PHONY : html xml templates scan
diff --git a/doc/devhelp/Makefile.am b/doc/devhelp/Makefile.am
index 36852f9..23c77b8 100644
--- a/doc/devhelp/Makefile.am
+++ b/doc/devhelp/Makefile.am
@@ -63,11 +63,17 @@ all: libxml2.devhelp $(HTML_FILES)
 libxml2.devhelp $(HTML_FILES): devhelp.xsl html.xsl $(top_srcdir)/doc/libxml2-api.xml
 	-@(echo Rebuilding devhelp files)
 	-@(if [ -x $(XSLTPROC) ] ; then \
-	  $(XSLTPROC) --nonet -o $(srcdir)/libxml2.devhelp devhelp.xsl $(top_srcdir)/doc/libxml2-api.xml ; fi );
+	  $(XSLTPROC) --nonet -o $(srcdir)/libxml2.devhelp $(srcdir)/devhelp.xsl $(top_srcdir)/doc/libxml2-api.xml ; fi );
 
 install-data-local: 
-	- MKDIR_P@ $(DESTDIR)$(DEVHELP_DIR)
-	- INSTALL@ -m 0644 $(srcdir)/libxml2.devhelp $(DESTDIR)$(DEVHELP_DIR)
-	- INSTALL@ -m 0644 $(EXTRA_FORMAT:%=$(srcdir)/%) $(DESTDIR)$(DEVHELP_DIR)
-	- INSTALL@ -m 0644 $(HTML_FILES:%=$(srcdir)/%) $(DESTDIR)$(DEVHELP_DIR)
+	-$(MKDIR_P) $(DESTDIR)$(DEVHELP_DIR)
+	-$(INSTALL) -m 0644 $(srcdir)/libxml2.devhelp $(DESTDIR)$(DEVHELP_DIR)
+	-$(INSTALL) -m 0644 $(EXTRA_FORMAT:%=$(srcdir)/%) $(DESTDIR)$(DEVHELP_DIR)
+	-$(INSTALL) -m 0644 $(HTML_FILES:%=$(srcdir)/%) $(DESTDIR)$(DEVHELP_DIR)
 
+uninstall-local:
+	rm -f $(DESTDIR)$(DEVHELP_DIR)/libxml2.devhelp
+	rm -f $(DESTDIR)$(DEVHELP_DIR)/*.css
+	rm -f $(DESTDIR)$(DEVHELP_DIR)/*.html
+	rm -f $(DESTDIR)$(DEVHELP_DIR)/*.png
+	-rmdir $(DESTDIR)$(DEVHELP_DIR)
diff --git a/doc/examples/.cvsignore b/doc/examples/.cvsignore
index 7097a62..0c5a3b1 100644
--- a/doc/examples/.cvsignore
+++ b/doc/examples/.cvsignore
@@ -1,18 +1,18 @@
 .memdump
 Makefile.in
 Makefile
-xpath2
-reader1
-reader4
-parse2
-reader2
+xpath1
 parse3
-reader3
+reader2
 tree2
+io1
 parse4
+xpath2
 io2
-testWriter
-io1
-xpath1
-parse1
+reader1
 tree1
+reader3
+parse2
+parse1
+reader4
+testWriter
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index bdac7bb..dadbd90 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -5,94 +5,94 @@ LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(I
 
 rebuild: examples.xml index.html
 
-examples.xml: index.py *.c
+examples.xml: index.py $(noinst_PROGRAMS:=.c)
 	-@($(srcdir)/index.py)
 
 index.html: examples.xml examples.xsl
 	-@(xsltproc examples.xsl examples.xml && echo "Rebuilt web page" && xmllint --valid --noout index.html)
 
 install-data-local: 
-	@MKDIR_P@ $(DESTDIR)$(HTML_DIR)
+	$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
 	- INSTALL@ -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml $(srcdir)/*.xsl $(srcdir)/*.res $(DESTDIR)$(HTML_DIR)
 
-EXTRA_DIST=examples.xsl index.py examples.xml writer.xml test3.xml tst.xml test1.xml test2.xml io2.res xpath2.res tree1.res reader4.res io1.res tree2.res reader3.res xpath1.res reader1.res 
+EXTRA_DIST=examples.xsl index.py test2.xml tst.xml examples.xml test1.xml writer.xml test3.xml io2.res reader4.res tree2.res xpath2.res xpath1.res reader3.res reader1.res tree1.res io1.res 
 
-noinst_PROGRAMS=xpath2 reader1 reader4 parse2 reader2 parse3 reader3 tree2 parse4 io2 testWriter io1 xpath1 parse1 tree1 
+noinst_PROGRAMS=xpath1 parse3 reader2 tree2 io1 parse4 xpath2 io2 reader1 tree1 reader3 parse2 parse1 reader4 testWriter 
 
-xpath2_SOURCES=xpath2.c
-xpath2_LDFLAGS=
-xpath2_DEPENDENCIES= $(DEPS)
-xpath2_LDADD= @RDL_LIBS@ $(LDADDS)
-
-reader1_SOURCES=reader1.c
-reader1_LDFLAGS=
-reader1_DEPENDENCIES= $(DEPS)
-reader1_LDADD= @RDL_LIBS@ $(LDADDS)
-
-reader4_SOURCES=reader4.c
-reader4_LDFLAGS=
-reader4_DEPENDENCIES= $(DEPS)
-reader4_LDADD= @RDL_LIBS@ $(LDADDS)
-
-parse2_SOURCES=parse2.c
-parse2_LDFLAGS=
-parse2_DEPENDENCIES= $(DEPS)
-parse2_LDADD= @RDL_LIBS@ $(LDADDS)
-
-reader2_SOURCES=reader2.c
-reader2_LDFLAGS=
-reader2_DEPENDENCIES= $(DEPS)
-reader2_LDADD= @RDL_LIBS@ $(LDADDS)
+xpath1_SOURCES=xpath1.c
+xpath1_LDFLAGS=
+xpath1_DEPENDENCIES= $(DEPS)
+xpath1_LDADD= @RDL_LIBS@ $(LDADDS)
 
 parse3_SOURCES=parse3.c
 parse3_LDFLAGS=
 parse3_DEPENDENCIES= $(DEPS)
 parse3_LDADD= @RDL_LIBS@ $(LDADDS)
 
-reader3_SOURCES=reader3.c
-reader3_LDFLAGS=
-reader3_DEPENDENCIES= $(DEPS)
-reader3_LDADD= @RDL_LIBS@ $(LDADDS)
+reader2_SOURCES=reader2.c
+reader2_LDFLAGS=
+reader2_DEPENDENCIES= $(DEPS)
+reader2_LDADD= @RDL_LIBS@ $(LDADDS)
 
 tree2_SOURCES=tree2.c
 tree2_LDFLAGS=
 tree2_DEPENDENCIES= $(DEPS)
 tree2_LDADD= @RDL_LIBS@ $(LDADDS)
 
+io1_SOURCES=io1.c
+io1_LDFLAGS=
+io1_DEPENDENCIES= $(DEPS)
+io1_LDADD= @RDL_LIBS@ $(LDADDS)
+
 parse4_SOURCES=parse4.c
 parse4_LDFLAGS=
 parse4_DEPENDENCIES= $(DEPS)
 parse4_LDADD= @RDL_LIBS@ $(LDADDS)
 
+xpath2_SOURCES=xpath2.c
+xpath2_LDFLAGS=
+xpath2_DEPENDENCIES= $(DEPS)
+xpath2_LDADD= @RDL_LIBS@ $(LDADDS)
+
 io2_SOURCES=io2.c
 io2_LDFLAGS=
 io2_DEPENDENCIES= $(DEPS)
 io2_LDADD= @RDL_LIBS@ $(LDADDS)
 
-testWriter_SOURCES=testWriter.c
-testWriter_LDFLAGS=
-testWriter_DEPENDENCIES= $(DEPS)
-testWriter_LDADD= @RDL_LIBS@ $(LDADDS)
+reader1_SOURCES=reader1.c
+reader1_LDFLAGS=
+reader1_DEPENDENCIES= $(DEPS)
+reader1_LDADD= @RDL_LIBS@ $(LDADDS)
 
-io1_SOURCES=io1.c
-io1_LDFLAGS=
-io1_DEPENDENCIES= $(DEPS)
-io1_LDADD= @RDL_LIBS@ $(LDADDS)
+tree1_SOURCES=tree1.c
+tree1_LDFLAGS=
+tree1_DEPENDENCIES= $(DEPS)
+tree1_LDADD= @RDL_LIBS@ $(LDADDS)
 
-xpath1_SOURCES=xpath1.c
-xpath1_LDFLAGS=
-xpath1_DEPENDENCIES= $(DEPS)
-xpath1_LDADD= @RDL_LIBS@ $(LDADDS)
+reader3_SOURCES=reader3.c
+reader3_LDFLAGS=
+reader3_DEPENDENCIES= $(DEPS)
+reader3_LDADD= @RDL_LIBS@ $(LDADDS)
+
+parse2_SOURCES=parse2.c
+parse2_LDFLAGS=
+parse2_DEPENDENCIES= $(DEPS)
+parse2_LDADD= @RDL_LIBS@ $(LDADDS)
 
 parse1_SOURCES=parse1.c
 parse1_LDFLAGS=
 parse1_DEPENDENCIES= $(DEPS)
 parse1_LDADD= @RDL_LIBS@ $(LDADDS)
 
-tree1_SOURCES=tree1.c
-tree1_LDFLAGS=
-tree1_DEPENDENCIES= $(DEPS)
-tree1_LDADD= @RDL_LIBS@ $(LDADDS)
+reader4_SOURCES=reader4.c
+reader4_LDFLAGS=
+reader4_DEPENDENCIES= $(DEPS)
+reader4_LDADD= @RDL_LIBS@ $(LDADDS)
+
+testWriter_SOURCES=testWriter.c
+testWriter_LDFLAGS=
+testWriter_DEPENDENCIES= $(DEPS)
+testWriter_LDADD= @RDL_LIBS@ $(LDADDS)
 
 valgrind: 
 	$(MAKE) CHECKER='valgrind' tests
@@ -100,35 +100,35 @@ valgrind:
 tests: $(noinst_PROGRAMS)
 	@(echo '## examples regression tests')
 	@(echo > .memdump)
-	@($(CHECKER) ./xpath2 test3.xml '//discarded' discarded > xpath2.tmp ; diff xpath2.tmp xpath2.res ; rm xpath2.tmp)
-	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ./reader1 test2.xml > reader1.tmp ; diff reader1.tmp reader1.res ; rm reader1.tmp)
-	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ./reader4 test1.xml test2.xml test3.xml > reader4.tmp ; diff reader4.tmp reader4.res ; rm reader4.tmp)
-	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ./parse2 test2.xml)
-	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ./reader2 test2.xml > reader1.tmp ; diff reader1.tmp reader1.res ; rm reader1.tmp)
+	@($(CHECKER) ././xpath1 test3.xml '//child2' > xpath1.tmp ; diff xpath1.tmp xpath1.res ; rm xpath1.tmp)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
 	@($(CHECKER) ./parse3)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ./reader3 > reader3.tmp ; diff reader3.tmp reader3.res ; rm reader3.tmp)
+	@($(CHECKER) ./reader2 test2.xml > reader1.tmp ; diff reader1.tmp reader1.res ; rm reader1.tmp)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
 	@($(CHECKER) ./tree2 > tree2.tmp ; diff tree2.tmp tree2.res ; rm tree2.tmp)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
+	@($(CHECKER) ./io1 > io1.tmp ; diff io1.tmp io1.res ; rm -f io1.tmp)
+	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
 	@($(CHECKER) ./parse4 test3.xml)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
+	@($(CHECKER) ./xpath2 test3.xml '//discarded' discarded > xpath2.tmp ; diff xpath2.tmp xpath2.res ; rm xpath2.tmp)
+	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
 	@($(CHECKER) ./io2 > io2.tmp ; diff io2.tmp io2.res ; rm -f io2.tmp)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ./testWriter ; for i in 1 2 3 4 ; do diff writer.xml writer$$i.res ; done ; rm writer*.res)
+	@($(CHECKER) ./reader1 test2.xml > reader1.tmp ; diff reader1.tmp reader1.res ; rm reader1.tmp)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ./io1 > io1.tmp ; diff io1.tmp io1.res ; rm -f io1.tmp)
+	@($(CHECKER) ./tree1 test2.xml > tree1.tmp ; diff tree1.tmp tree1.res ; rm tree1.tmp)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ././xpath1 test3.xml '//child2' > xpath1.tmp ; diff xpath1.tmp xpath1.res ; rm xpath1.tmp)
+	@($(CHECKER) ./reader3 > reader3.tmp ; diff reader3.tmp reader3.res ; rm reader3.tmp)
+	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
+	@($(CHECKER) ./parse2 test2.xml)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
 	@($(CHECKER) ./parse1 test1.xml)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
-	@($(CHECKER) ./tree1 test2.xml > tree1.tmp ; diff tree1.tmp tree1.res ; rm tree1.tmp)
+	@($(CHECKER) ./reader4 test1.xml test2.xml test3.xml > reader4.tmp ; diff reader4.tmp reader4.res ; rm reader4.tmp)
+	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
+	@($(CHECKER) ./testWriter ; for i in 1 2 3 4 ; do diff writer.xml writer$$i.res ; done ; rm writer*.res)
 	@(grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
 
 
diff --git a/doc/examples/examples.xml b/doc/examples/examples.xml
index a237a0e..681e848 100644
--- a/doc/examples/examples.xml
+++ b/doc/examples/examples.xml
@@ -1,69 +1,4 @@
 <examples>
-  <example filename='reader2.c'>
-    <synopsis>Parse and validate an XML file with an xmlReader</synopsis>
-    <purpose>Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.)</purpose>
-    <usage>reader2 &lt;valid_xml_filename&gt;</usage>
-    <test>reader2 test2.xml &gt; reader1.tmp ; diff reader1.tmp reader1.res ; rm reader1.tmp</test>
-    <author>Daniel Veillard</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>xmlReader</section>
-    <includes>
-      <include>&lt;libxml/xmlreader.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='45' file='xmlstring' name='xmlStrlen'/>
-      <function line='109' file='parser' name='xmlCleanupParser'/>
-      <function line='38' file='xmlreader' name='xmlTextReaderNodeType'/>
-      <typedef line='60' file='xmlreader' name='xmlTextReaderPtr'/>
-      <function line='113' file='xmlmemory' name='xmlMemoryDump'/>
-      <function line='34' file='xmlreader' name='xmlTextReaderConstValue'/>
-      <enum line='70' file='parser' name='XML_PARSE_NOENT'/>
-      <function line='37' file='xmlreader' name='xmlTextReaderDepth'/>
-      <enum line='71' file='parser' name='XML_PARSE_DTDVALID'/>
-      <enum line='69' file='parser' name='XML_PARSE_DTDATTR'/>
-      <function line='84' file='xmlreader' name='xmlFreeTextReader'/>
-      <macro line='104' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='30' file='xmlreader' name='xmlTextReaderConstName'/>
-      <function line='41' file='xmlreader' name='xmlTextReaderHasValue'/>
-      <function line='76' file='xmlreader' name='xmlTextReaderRead'/>
-      <function line='40' file='xmlreader' name='xmlTextReaderIsEmptyElement'/>
-      <function line='68' file='xmlreader' name='xmlReaderForFile'/>
-      <function line='81' file='xmlreader' name='xmlTextReaderIsValid'/>
-    </uses>
-  </example>
-  <example filename='xpath2.c'>
-    <synopsis>Load a document, locate subelements with XPath, modify said elements and save the resulting document.</synopsis>
-    <purpose>Shows how to make a full round-trip from a load/edit/save</purpose>
-    <usage>xpath2 &lt;xml-file&gt; &lt;xpath-expr&gt; &lt;new-value&gt;</usage>
-    <test>xpath2 test3.xml &apos;//discarded&apos; discarded &gt; xpath2.tmp ; diff xpath2.tmp xpath2.res ; rm xpath2.tmp</test>
-    <author>Aleksey Sanin and Daniel Veillard</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>XPath</section>
-    <includes>
-      <include>&lt;libxml/parser.h&gt;</include>
-      <include>&lt;libxml/xpath.h&gt;</include>
-      <include>&lt;libxml/xpathInternals.h&gt;</include>
-      <include>&lt;libxml/tree.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='162' file='tree' name='xmlNodeSetContent'/>
-      <function line='127' file='tree' name='xmlDocDump'/>
-      <typedef line='88' file='xpath' name='xmlXPathObjectPtr'/>
-      <function line='56' file='xmlmemory' name='xmlMemoryDump'/>
-      <function line='110' file='xpath' name='xmlXPathEvalExpression'/>
-      <function line='95' file='parser' name='xmlParseFile'/>
-      <function line='123' file='xpath' name='xmlXPathFreeObject'/>
-      <function line='102' file='xpath' name='xmlXPathNewContext'/>
-      <function line='51' file='parser' name='xmlCleanupParser'/>
-      <macro line='45' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <typedef line='87' file='xpath' name='xmlXPathContextPtr'/>
-      <function line='124' file='xpath' name='xmlXPathFreeContext'/>
-      <function line='41' file='parser' name='xmlInitParser'/>
-      <function line='131' file='tree' name='xmlFreeDoc'/>
-      <enum line='180' file='tree' name='XML_NAMESPACE_DECL'/>
-      <typedef line='86' file='tree' name='xmlDocPtr'/>
-    </uses>
-  </example>
   <example filename='xpath1.c'>
     <synopsis>Evaluate XPath expression and prints result node set.</synopsis>
     <purpose>Shows how to evaluate XPath expression and register known namespaces in XPath context.</purpose>
@@ -123,27 +58,36 @@
       <typedef line='27' file='tree' name='xmlDocPtr'/>
     </uses>
   </example>
-  <example filename='io2.c'>
-    <synopsis>Output to char buffer</synopsis>
-    <purpose>Demonstrate the use of xmlDocDumpMemory to output document to a character buffer</purpose>
-    <usage>io2</usage>
-    <test>io2 &gt; io2.tmp ; diff io2.tmp io2.res ; rm -f io2.tmp</test>
-    <author>John Fleck</author>
+  <example filename='reader2.c'>
+    <synopsis>Parse and validate an XML file with an xmlReader</synopsis>
+    <purpose>Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.)</purpose>
+    <usage>reader2 &lt;valid_xml_filename&gt;</usage>
+    <test>reader2 test2.xml &gt; reader1.tmp ; diff reader1.tmp reader1.res ; rm reader1.tmp</test>
+    <author>Daniel Veillard</author>
     <copy>see Copyright for the status of this software. </copy>
-    <section>InputOutput</section>
+    <section>xmlReader</section>
     <includes>
-      <include>&lt;libxml/parser.h&gt;</include>
+      <include>&lt;libxml/xmlreader.h&gt;</include>
     </includes>
     <uses>
-      <function line='29' file='tree' name='xmlNodeSetContent'/>
-      <function line='36' file='tree' name='xmlDocDumpFormatMemory'/>
-      <variable line='42' file='globals' name='xmlFree'/>
-      <function line='30' file='tree' name='xmlDocSetRootElement'/>
-      <typedef line='20' file='tree' name='xmlDocPtr'/>
-      <function line='43' file='tree' name='xmlFreeDoc'/>
-      <typedef line='19' file='tree' name='xmlNodePtr'/>
-      <function line='27' file='tree' name='xmlNewDoc'/>
-      <function line='28' file='tree' name='xmlNewNode'/>
+      <function line='45' file='xmlstring' name='xmlStrlen'/>
+      <function line='109' file='parser' name='xmlCleanupParser'/>
+      <function line='38' file='xmlreader' name='xmlTextReaderNodeType'/>
+      <typedef line='60' file='xmlreader' name='xmlTextReaderPtr'/>
+      <function line='113' file='xmlmemory' name='xmlMemoryDump'/>
+      <function line='34' file='xmlreader' name='xmlTextReaderConstValue'/>
+      <enum line='70' file='parser' name='XML_PARSE_NOENT'/>
+      <function line='37' file='xmlreader' name='xmlTextReaderDepth'/>
+      <enum line='71' file='parser' name='XML_PARSE_DTDVALID'/>
+      <enum line='69' file='parser' name='XML_PARSE_DTDATTR'/>
+      <function line='84' file='xmlreader' name='xmlFreeTextReader'/>
+      <macro line='104' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+      <function line='30' file='xmlreader' name='xmlTextReaderConstName'/>
+      <function line='41' file='xmlreader' name='xmlTextReaderHasValue'/>
+      <function line='76' file='xmlreader' name='xmlTextReaderRead'/>
+      <function line='40' file='xmlreader' name='xmlTextReaderIsEmptyElement'/>
+      <function line='68' file='xmlreader' name='xmlReaderForFile'/>
+      <function line='81' file='xmlreader' name='xmlTextReaderIsValid'/>
     </uses>
   </example>
   <example filename='tree2.c'>
@@ -174,6 +118,108 @@
       <function line='39' file='tree' name='xmlNewDoc'/>
     </uses>
   </example>
+  <example filename='io1.c'>
+    <synopsis>Example of custom Input/Output</synopsis>
+    <purpose>Demonstrate the use of xmlRegisterInputCallbacks to build a custom I/O layer, this is used in an XInclude method context to show how dynamic document can be built in a clean way.</purpose>
+    <usage>io1</usage>
+    <test>io1 &gt; io1.tmp ; diff io1.tmp io1.res ; rm -f io1.tmp</test>
+    <author>Daniel Veillard</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>InputOutput</section>
+    <includes>
+      <include>&lt;libxml/parser.h&gt;</include>
+      <include>&lt;libxml/xmlIO.h&gt;</include>
+      <include>&lt;libxml/xinclude.h&gt;</include>
+      <include>&lt;libxml/tree.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='143' file='tree' name='xmlDocDump'/>
+      <function line='158' file='xmlmemory' name='xmlMemoryDump'/>
+      <function line='149' file='tree' name='xmlFreeDoc'/>
+      <function line='154' file='parser' name='xmlCleanupParser'/>
+      <macro line='117' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+      <function line='134' file='xinclude' name='xmlXIncludeProcess'/>
+      <function line='117' file='xmlIO' name='xmlRegisterInputCallbacks'/>
+      <function line='124' file='parser' name='xmlReadMemory'/>
+      <typedef line='105' file='tree' name='xmlDocPtr'/>
+    </uses>
+  </example>
+  <example filename='parse4.c'>
+    <synopsis>Parse an XML document chunk by chunk to a tree and free it</synopsis>
+    <purpose>Demonstrate the use of xmlCreatePushParserCtxt() and xmlParseChunk() to read an XML file progressively into a tree and and xmlFreeDoc() to free the resulting tree</purpose>
+    <usage>parse4 test3.xml</usage>
+    <test>parse4 test3.xml</test>
+    <author>Daniel Veillard</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>Parsing</section>
+    <includes>
+      <include>&lt;libxml/tree.h&gt;</include>
+      <include>&lt;libxml/parser.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='94' file='parser' name='xmlFreeParserCtxt'/>
+      <function line='86' file='parser' name='xmlParseChunk'/>
+      <function line='103' file='tree' name='xmlFreeDoc'/>
+      <function line='135' file='xmlmemory' name='xmlMemoryDump'/>
+      <function line='67' file='parser' name='xmlCreatePushParserCtxt'/>
+      <function line='131' file='parser' name='xmlCleanupParser'/>
+      <macro line='120' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+      <typedef line='45' file='tree' name='xmlParserCtxtPtr'/>
+      <typedef line='47' file='tree' name='xmlDocPtr'/>
+    </uses>
+  </example>
+  <example filename='xpath2.c'>
+    <synopsis>Load a document, locate subelements with XPath, modify said elements and save the resulting document.</synopsis>
+    <purpose>Shows how to make a full round-trip from a load/edit/save</purpose>
+    <usage>xpath2 &lt;xml-file&gt; &lt;xpath-expr&gt; &lt;new-value&gt;</usage>
+    <test>xpath2 test3.xml &apos;//discarded&apos; discarded &gt; xpath2.tmp ; diff xpath2.tmp xpath2.res ; rm xpath2.tmp</test>
+    <author>Aleksey Sanin and Daniel Veillard</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>XPath</section>
+    <includes>
+      <include>&lt;libxml/parser.h&gt;</include>
+      <include>&lt;libxml/xpath.h&gt;</include>
+      <include>&lt;libxml/xpathInternals.h&gt;</include>
+      <include>&lt;libxml/tree.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='162' file='tree' name='xmlNodeSetContent'/>
+      <function line='127' file='tree' name='xmlDocDump'/>
+      <typedef line='88' file='xpath' name='xmlXPathObjectPtr'/>
+      <function line='110' file='xpath' name='xmlXPathEvalExpression'/>
+      <function line='95' file='parser' name='xmlParseFile'/>
+      <function line='123' file='xpath' name='xmlXPathFreeObject'/>
+      <function line='102' file='xpath' name='xmlXPathNewContext'/>
+      <typedef line='87' file='xpath' name='xmlXPathContextPtr'/>
+      <function line='124' file='xpath' name='xmlXPathFreeContext'/>
+      <function line='41' file='parser' name='xmlInitParser'/>
+      <function line='131' file='tree' name='xmlFreeDoc'/>
+      <enum line='180' file='tree' name='XML_NAMESPACE_DECL'/>
+      <typedef line='86' file='tree' name='xmlDocPtr'/>
+    </uses>
+  </example>
+  <example filename='io2.c'>
+    <synopsis>Output to char buffer</synopsis>
+    <purpose>Demonstrate the use of xmlDocDumpMemory to output document to a character buffer</purpose>
+    <usage>io2</usage>
+    <test>io2 &gt; io2.tmp ; diff io2.tmp io2.res ; rm -f io2.tmp</test>
+    <author>John Fleck</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>InputOutput</section>
+    <includes>
+      <include>&lt;libxml/parser.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='29' file='tree' name='xmlNodeSetContent'/>
+      <function line='36' file='tree' name='xmlDocDumpFormatMemory'/>
+      <variable line='42' file='globals' name='xmlFree'/>
+      <function line='30' file='tree' name='xmlDocSetRootElement'/>
+      <typedef line='20' file='tree' name='xmlDocPtr'/>
+      <typedef line='19' file='tree' name='xmlNodePtr'/>
+      <function line='27' file='tree' name='xmlNewDoc'/>
+      <function line='28' file='tree' name='xmlNewNode'/>
+    </uses>
+  </example>
   <example filename='reader1.c'>
     <synopsis>Parse an XML file with an xmlReader</synopsis>
     <purpose>Demonstrate the use of xmlReaderForFile() to parse an XML file and dump the informations about the nodes found in the process. (Note that the XMLReader functions require libxml2 version later than 2.6.)</purpose>
@@ -187,14 +233,11 @@
     </includes>
     <uses>
       <function line='44' file='xmlstring' name='xmlStrlen'/>
-      <function line='94' file='parser' name='xmlCleanupParser'/>
       <function line='37' file='xmlreader' name='xmlTextReaderNodeType'/>
       <typedef line='59' file='xmlreader' name='xmlTextReaderPtr'/>
-      <function line='98' file='xmlmemory' name='xmlMemoryDump'/>
       <function line='33' file='xmlreader' name='xmlTextReaderConstValue'/>
       <function line='36' file='xmlreader' name='xmlTextReaderDepth'/>
       <function line='69' file='xmlreader' name='xmlFreeTextReader'/>
-      <macro line='89' file='xmlversion' name='LIBXML_TEST_VERSION'/>
       <function line='29' file='xmlreader' name='xmlTextReaderConstName'/>
       <function line='40' file='xmlreader' name='xmlTextReaderHasValue'/>
       <function line='67' file='xmlreader' name='xmlTextReaderRead'/>
@@ -202,70 +245,22 @@
       <function line='62' file='xmlreader' name='xmlReaderForFile'/>
     </uses>
   </example>
-  <example filename='testWriter.c'>
-    <synopsis>use various APIs for the xmlWriter</synopsis>
-    <purpose>tests a number of APIs for the xmlWriter, especially the various methods to write to a filename, to a memory buffer, to a new document, or to a subtree. It shows how to do encoding string conversions too. The resulting documents are then serialized.</purpose>
-    <usage>testWriter</usage>
-    <test>testWriter ; for i in 1 2 3 4 ; do diff writer.xml writer$$i.res ; done ; rm writer*.res</test>
-    <author>Alfred Mickautsch</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>xmlWriter</section>
-    <includes>
-      <include>&lt;libxml/encoding.h&gt;</include>
-      <include>&lt;libxml/xmlwriter.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='913' file='xmlwriter' name='xmlTextWriterStartDocument'/>
-      <function line='1121' file='xmlwriter' name='xmlTextWriterEndDocument'/>
-      <variable line='1183' file='globals' name='xmlRealloc'/>
-      <function line='925' file='xmlwriter' name='xmlTextWriterWriteComment'/>
-      <function line='1156' file='encoding' name='xmlFindCharEncodingHandler'/>
-      <variable line='1166' file='globals' name='xmlMalloc'/>
-      <typedef line='879' file='tree' name='xmlDocPtr'/>
-      <typedef line='341' file='tree' name='xmlBufferPtr'/>
-      <macro line='885' file='parser' name='XML_DEFAULT_VERSION'/>
-      <function line='901' file='tree' name='xmlDocSetRootElement'/>
-      <function line='1127' file='xmlwriter' name='xmlFreeTextWriter'/>
-      <function line='1096' file='xmlwriter' name='xmlTextWriterStartElement'/>
-      <function line='347' file='tree' name='xmlBufferCreate'/>
-      <function line='1111' file='xmlwriter' name='xmlTextWriterEndElement'/>
-      <function line='76' file='xmlwriter' name='xmlNewTextWriterFilename'/>
-      <function line='959' file='xmlwriter' name='xmlTextWriterWriteFormatComment'/>
-      <function line='1073' file='xmlwriter' name='xmlTextWriterWriteFormatElement'/>
-      <typedef line='1151' file='encoding' name='xmlCharEncodingHandlerPtr'/>
-      <function line='1131' file='tree' name='xmlFreeDoc'/>
-      <typedef line='880' file='tree' name='xmlNodePtr'/>
-      <function line='949' file='xmlwriter' name='xmlTextWriterWriteAttribute'/>
-      <function line='632' file='xmlwriter' name='xmlNewTextWriterDoc'/>
-      <function line='894' file='tree' name='xmlNewDocNode'/>
-      <function line='1129' file='tree' name='xmlSaveFileEnc'/>
-      <function line='904' file='xmlwriter' name='xmlNewTextWriterTree'/>
-      <function line='355' file='xmlwriter' name='xmlNewTextWriterMemory'/>
-      <variable line='1180' file='globals' name='xmlFree'/>
-      <function line='613' file='tree' name='xmlBufferFree'/>
-      <typedef line='878' file='xmlwriter' name='xmlTextWriterPtr'/>
-      <function line='1103' file='xmlwriter' name='xmlTextWriterWriteElement'/>
-      <function line='885' file='tree' name='xmlNewDoc'/>
-    </uses>
-  </example>
-  <example filename='parse4.c'>
-    <synopsis>Parse an XML document chunk by chunk to a tree and free it</synopsis>
-    <purpose>Demonstrate the use of xmlCreatePushParserCtxt() and xmlParseChunk() to read an XML file progressively into a tree and and xmlFreeDoc() to free the resulting tree</purpose>
-    <usage>parse4 test3.xml</usage>
-    <test>parse4 test3.xml</test>
-    <author>Daniel Veillard</author>
+  <example filename='tree1.c'>
+    <synopsis>Navigates a tree to print element names</synopsis>
+    <purpose>Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.</purpose>
+    <usage>tree1 filename_or_URL</usage>
+    <test>tree1 test2.xml &gt; tree1.tmp ; diff tree1.tmp tree1.res ; rm tree1.tmp</test>
+    <author>Dodji Seketeli</author>
     <copy>see Copyright for the status of this software. </copy>
-    <section>Parsing</section>
+    <section>Tree</section>
     <includes>
       <include>&lt;libxml/tree.h&gt;</include>
       <include>&lt;libxml/parser.h&gt;</include>
     </includes>
     <uses>
-      <function line='94' file='parser' name='xmlFreeParserCtxt'/>
-      <function line='86' file='parser' name='xmlParseChunk'/>
-      <function line='67' file='parser' name='xmlCreatePushParserCtxt'/>
-      <typedef line='45' file='tree' name='xmlParserCtxtPtr'/>
-      <typedef line='47' file='tree' name='xmlDocPtr'/>
+      <enum line='36' file='tree' name='XML_ELEMENT_NODE'/>
+      <function line='74' file='tree' name='xmlDocGetRootElement'/>
+      <function line='67' file='parser' name='xmlReadFile'/>
     </uses>
   </example>
   <example filename='reader3.c'>
@@ -289,25 +284,24 @@
       <function line='38' file='xmlreader' name='xmlReaderForFile'/>
     </uses>
   </example>
-  <example filename='io1.c'>
-    <synopsis>Example of custom Input/Output</synopsis>
-    <purpose>Demonstrate the use of xmlRegisterInputCallbacks to build a custom I/O layer, this is used in an XInclude method context to show how dynamic document can be built in a clean way.</purpose>
-    <usage>io1</usage>
-    <test>io1 &gt; io1.tmp ; diff io1.tmp io1.res ; rm -f io1.tmp</test>
+  <example filename='parse2.c'>
+    <synopsis>Parse and validate an XML file to a tree and free the result</synopsis>
+    <purpose>Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.</purpose>
+    <usage>parse2 test2.xml</usage>
+    <test>parse2 test2.xml</test>
     <author>Daniel Veillard</author>
     <copy>see Copyright for the status of this software. </copy>
-    <section>InputOutput</section>
+    <section>Parsing</section>
     <includes>
-      <include>&lt;libxml/parser.h&gt;</include>
-      <include>&lt;libxml/xmlIO.h&gt;</include>
-      <include>&lt;libxml/xinclude.h&gt;</include>
       <include>&lt;libxml/tree.h&gt;</include>
+      <include>&lt;libxml/parser.h&gt;</include>
     </includes>
     <uses>
-      <function line='143' file='tree' name='xmlDocDump'/>
-      <function line='134' file='xinclude' name='xmlXIncludeProcess'/>
-      <function line='117' file='xmlIO' name='xmlRegisterInputCallbacks'/>
-      <function line='124' file='parser' name='xmlReadMemory'/>
+      <function line='47' file='parser' name='xmlFreeParserCtxt'/>
+      <enum line='35' file='parser' name='XML_PARSE_DTDVALID'/>
+      <function line='29' file='parser' name='xmlNewParserCtxt'/>
+      <typedef line='25' file='tree' name='xmlParserCtxtPtr'/>
+      <function line='35' file='parser' name='xmlCtxtReadFile'/>
     </uses>
   </example>
   <example filename='parse1.c'>
@@ -326,24 +320,6 @@
       <function line='26' file='parser' name='xmlReadFile'/>
     </uses>
   </example>
-  <example filename='tree1.c'>
-    <synopsis>Navigates a tree to print element names</synopsis>
-    <purpose>Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.</purpose>
-    <usage>tree1 filename_or_URL</usage>
-    <test>tree1 test2.xml &gt; tree1.tmp ; diff tree1.tmp tree1.res ; rm tree1.tmp</test>
-    <author>Dodji Seketeli</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>Tree</section>
-    <includes>
-      <include>&lt;libxml/tree.h&gt;</include>
-      <include>&lt;libxml/parser.h&gt;</include>
-    </includes>
-    <uses>
-      <enum line='36' file='tree' name='XML_ELEMENT_NODE'/>
-      <function line='74' file='tree' name='xmlDocGetRootElement'/>
-      <function line='67' file='parser' name='xmlReadFile'/>
-    </uses>
-  </example>
   <example filename='reader4.c'>
     <synopsis>Parse multiple XML files reusing an xmlReader</synopsis>
     <purpose>Demonstrate the use of xmlReaderForFile() and xmlReaderNewFile to parse XML files while reusing the reader object and parser context.  (Note that the XMLReader functions require libxml2 version later than 2.6.)</purpose>
@@ -364,34 +340,58 @@
       <function line='72' file='xmlreader' name='xmlReaderForFile'/>
     </uses>
   </example>
-  <example filename='parse2.c'>
-    <synopsis>Parse and validate an XML file to a tree and free the result</synopsis>
-    <purpose>Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.</purpose>
-    <usage>parse2 test2.xml</usage>
-    <test>parse2 test2.xml</test>
-    <author>Daniel Veillard</author>
+  <example filename='testWriter.c'>
+    <synopsis>use various APIs for the xmlWriter</synopsis>
+    <purpose>tests a number of APIs for the xmlWriter, especially the various methods to write to a filename, to a memory buffer, to a new document, or to a subtree. It shows how to do encoding string conversions too. The resulting documents are then serialized.</purpose>
+    <usage>testWriter</usage>
+    <test>testWriter ; for i in 1 2 3 4 ; do diff writer.xml writer$$i.res ; done ; rm writer*.res</test>
+    <author>Alfred Mickautsch</author>
     <copy>see Copyright for the status of this software. </copy>
-    <section>Parsing</section>
+    <section>xmlWriter</section>
     <includes>
-      <include>&lt;libxml/tree.h&gt;</include>
-      <include>&lt;libxml/parser.h&gt;</include>
+      <include>&lt;libxml/encoding.h&gt;</include>
+      <include>&lt;libxml/xmlwriter.h&gt;</include>
     </includes>
     <uses>
-      <function line='47' file='parser' name='xmlFreeParserCtxt'/>
-      <enum line='35' file='parser' name='XML_PARSE_DTDVALID'/>
-      <function line='29' file='parser' name='xmlNewParserCtxt'/>
-      <typedef line='25' file='tree' name='xmlParserCtxtPtr'/>
-      <function line='35' file='parser' name='xmlCtxtReadFile'/>
+      <function line='913' file='xmlwriter' name='xmlTextWriterStartDocument'/>
+      <function line='1121' file='xmlwriter' name='xmlTextWriterEndDocument'/>
+      <variable line='1183' file='globals' name='xmlRealloc'/>
+      <function line='925' file='xmlwriter' name='xmlTextWriterWriteComment'/>
+      <function line='1156' file='encoding' name='xmlFindCharEncodingHandler'/>
+      <variable line='1166' file='globals' name='xmlMalloc'/>
+      <typedef line='341' file='tree' name='xmlBufferPtr'/>
+      <macro line='885' file='parser' name='XML_DEFAULT_VERSION'/>
+      <function line='901' file='tree' name='xmlDocSetRootElement'/>
+      <function line='1127' file='xmlwriter' name='xmlFreeTextWriter'/>
+      <function line='1096' file='xmlwriter' name='xmlTextWriterStartElement'/>
+      <function line='347' file='tree' name='xmlBufferCreate'/>
+      <function line='1111' file='xmlwriter' name='xmlTextWriterEndElement'/>
+      <function line='76' file='xmlwriter' name='xmlNewTextWriterFilename'/>
+      <function line='959' file='xmlwriter' name='xmlTextWriterWriteFormatComment'/>
+      <function line='1073' file='xmlwriter' name='xmlTextWriterWriteFormatElement'/>
+      <typedef line='1151' file='encoding' name='xmlCharEncodingHandlerPtr'/>
+      <typedef line='880' file='tree' name='xmlNodePtr'/>
+      <function line='949' file='xmlwriter' name='xmlTextWriterWriteAttribute'/>
+      <function line='632' file='xmlwriter' name='xmlNewTextWriterDoc'/>
+      <function line='894' file='tree' name='xmlNewDocNode'/>
+      <function line='1129' file='tree' name='xmlSaveFileEnc'/>
+      <function line='904' file='xmlwriter' name='xmlNewTextWriterTree'/>
+      <function line='355' file='xmlwriter' name='xmlNewTextWriterMemory'/>
+      <variable line='1180' file='globals' name='xmlFree'/>
+      <function line='613' file='tree' name='xmlBufferFree'/>
+      <typedef line='878' file='xmlwriter' name='xmlTextWriterPtr'/>
+      <function line='1103' file='xmlwriter' name='xmlTextWriterWriteElement'/>
+      <function line='885' file='tree' name='xmlNewDoc'/>
     </uses>
   </example>
   <symbols>
     <symbol name='LIBXML_TEST_VERSION'>
-      <ref filename='reader2.c'/>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
       <ref filename='parse3.c'/>
+      <ref filename='reader2.c'/>
       <ref filename='tree2.c'/>
-      <ref filename='reader1.c'/>
+      <ref filename='io1.c'/>
+      <ref filename='parse4.c'/>
     </symbol>
     <symbol name='XML_DEFAULT_VERSION'>
       <ref filename='testWriter.c'/>
@@ -401,8 +401,8 @@
       <ref filename='tree1.c'/>
     </symbol>
     <symbol name='XML_NAMESPACE_DECL'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='XML_PARSE_DTDATTR'>
       <ref filename='reader2.c'/>
@@ -430,12 +430,12 @@
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlCleanupParser'>
-      <ref filename='reader2.c'/>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
       <ref filename='parse3.c'/>
+      <ref filename='reader2.c'/>
       <ref filename='tree2.c'/>
-      <ref filename='reader1.c'/>
+      <ref filename='io1.c'/>
+      <ref filename='parse4.c'/>
     </symbol>
     <symbol name='xmlCreateIntSubset'>
       <ref filename='tree2.c'/>
@@ -447,9 +447,9 @@
       <ref filename='parse2.c'/>
     </symbol>
     <symbol name='xmlDocDump'>
+      <ref filename='io1.c'/>
       <ref filename='xpath2.c'/>
       <ref filename='reader3.c'/>
-      <ref filename='io1.c'/>
     </symbol>
     <symbol name='xmlDocDumpFormatMemory'>
       <ref filename='io2.c'/>
@@ -458,16 +458,16 @@
       <ref filename='tree1.c'/>
     </symbol>
     <symbol name='xmlDocPtr'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
       <ref filename='parse3.c'/>
-      <ref filename='io2.c'/>
-      <ref filename='testWriter.c'/>
+      <ref filename='io1.c'/>
       <ref filename='parse4.c'/>
+      <ref filename='xpath2.c'/>
+      <ref filename='io2.c'/>
     </symbol>
     <symbol name='xmlDocSetRootElement'>
-      <ref filename='io2.c'/>
       <ref filename='tree2.c'/>
+      <ref filename='io2.c'/>
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlFindCharEncodingHandler'>
@@ -479,12 +479,12 @@
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlFreeDoc'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
       <ref filename='parse3.c'/>
-      <ref filename='io2.c'/>
       <ref filename='tree2.c'/>
-      <ref filename='testWriter.c'/>
+      <ref filename='io1.c'/>
+      <ref filename='parse4.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlFreeParserCtxt'>
       <ref filename='parse4.c'/>
@@ -500,34 +500,34 @@
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlInitParser'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlMalloc'>
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlMemoryDump'>
-      <ref filename='reader2.c'/>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
       <ref filename='parse3.c'/>
+      <ref filename='reader2.c'/>
       <ref filename='tree2.c'/>
-      <ref filename='reader1.c'/>
+      <ref filename='io1.c'/>
+      <ref filename='parse4.c'/>
     </symbol>
     <symbol name='xmlNewChild'>
       <ref filename='tree2.c'/>
     </symbol>
     <symbol name='xmlNewDoc'>
-      <ref filename='io2.c'/>
       <ref filename='tree2.c'/>
+      <ref filename='io2.c'/>
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlNewDocNode'>
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlNewNode'>
-      <ref filename='io2.c'/>
       <ref filename='tree2.c'/>
+      <ref filename='io2.c'/>
     </symbol>
     <symbol name='xmlNewParserCtxt'>
       <ref filename='parse2.c'/>
@@ -566,16 +566,16 @@
       <ref filename='parse4.c'/>
     </symbol>
     <symbol name='xmlParseFile'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlParserCtxtPtr'>
       <ref filename='parse4.c'/>
       <ref filename='parse2.c'/>
     </symbol>
     <symbol name='xmlReadFile'>
-      <ref filename='parse1.c'/>
       <ref filename='tree1.c'/>
+      <ref filename='parse1.c'/>
     </symbol>
     <symbol name='xmlReadMemory'>
       <ref filename='parse3.c'/>
@@ -692,28 +692,28 @@
       <ref filename='io1.c'/>
     </symbol>
     <symbol name='xmlXPathContextPtr'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlXPathEvalExpression'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlXPathFreeContext'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlXPathFreeObject'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlXPathNewContext'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlXPathObjectPtr'>
-      <ref filename='xpath2.c'/>
       <ref filename='xpath1.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlXPathRegisterNs'>
       <ref filename='xpath1.c'/>
@@ -721,22 +721,22 @@
   </symbols>
   <sections>
     <section name='InputOutput'>
-      <example filename='io2.c'/>
       <example filename='io1.c'/>
+      <example filename='io2.c'/>
     </section>
     <section name='Parsing'>
       <example filename='parse3.c'/>
       <example filename='parse4.c'/>
-      <example filename='parse1.c'/>
       <example filename='parse2.c'/>
+      <example filename='parse1.c'/>
     </section>
     <section name='Tree'>
       <example filename='tree2.c'/>
       <example filename='tree1.c'/>
     </section>
     <section name='XPath'>
-      <example filename='xpath2.c'/>
       <example filename='xpath1.c'/>
+      <example filename='xpath2.c'/>
     </section>
     <section name='xmlReader'>
       <example filename='reader2.c'/>
diff --git a/doc/examples/index.py b/doc/examples/index.py
index 11df6f0..536d5dc 100755
--- a/doc/examples/index.py
+++ b/doc/examples/index.py
@@ -227,7 +227,7 @@ LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(I
 
 rebuild: examples.xml index.html
 
-examples.xml: index.py *.c
+examples.xml: index.py $(noinst_PROGRAMS:=.c)
 	-@($(srcdir)/index.py)
 
 index.html: examples.xml examples.xsl
diff --git a/example/Makefile.am b/example/Makefile.am
index 9eb6a76..f8a137b 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1,10 +1,10 @@
 noinst_PROGRAMS	= gjobread
 
-INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@
+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)/include $(THREAD_CFLAGS) $(Z_CFLAGS)
 DEPS = $(top_builddir)/libxml2.la
-LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm @WIN32_EXTRA_LIBADD@
+LDADDS = $(STATIC_BINARIES) $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(ICONV_LIBS) -lm $(WIN32_EXTRA_LIBADD)
 
 gjobread_SOURCES=gjobread.c
 gjobread_LDFLAGS=
 gjobread_DEPENDENCIES= $(DEPS)
-gjobread_LDADD= @RDL_LIBS@ $(LDADDS)
+gjobread_LDADD = $(RDL_LIBS) $(LDADDS)
diff --git a/include/libxml/nanoftp.h b/include/libxml/nanoftp.h
index 397bbba..abb4bf7 100644
--- a/include/libxml/nanoftp.h
+++ b/include/libxml/nanoftp.h
@@ -31,6 +31,7 @@
  * macro used to provide portability of code to windows sockets
  * the value to be used when the socket is not valid
  */
+#undef  INVALID_SOCKET
 #define INVALID_SOCKET (-1)
 #endif
 
diff --git a/include/libxml/xmlversion.h.in b/include/libxml/xmlversion.h.in
index ddd4633..c98e7ca 100644
--- a/include/libxml/xmlversion.h.in
+++ b/include/libxml/xmlversion.h.in
@@ -412,7 +412,11 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
  */
 
 #ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__((unused))
+# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
+#  define ATTRIBUTE_UNUSED __attribute__((unused))
+# else
+#  define ATTRIBUTE_UNUSED
+# endif
 #endif
 
 /**
diff --git a/python/Makefile.am b/python/Makefile.am
index 68d2236..f34aa98 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -21,7 +21,7 @@ EXTRA_DIST = 			\
 	libxml.py		\
 	libxml2-python-api.xml
 
-libxml2mod_la_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ @WIN32_EXTRA_LDFLAGS@ -module -avoid-version 
+libxml2mod_la_LDFLAGS = $(CYGWIN_EXTRA_LDFLAGS) $(WIN32_EXTRA_LDFLAGS) -module -avoid-version
 
 if WITH_PYTHON
 mylibs = \
@@ -31,7 +31,7 @@ python_LTLIBRARIES = libxml2mod.la
 
 libxml2mod_la_SOURCES = $(srcdir)/libxml.c $(srcdir)/types.c
 nodist_libxml2mod_la_SOURCES = libxml2-py.c
-libxml2mod_la_LIBADD = $(mylibs) @CYGWIN_EXTRA_PYTHON_LIBADD@ @WIN32_EXTRA_PYTHON_LIBADD@ @PYTHON_LIBS@ -lpython$(PYTHON_VERSION)
+libxml2mod_la_LIBADD = $(mylibs) $(CYGWIN_EXTRA_PYTHON_LIBADD) $(WIN32_EXTRA_PYTHON_LIBADD) $(PYTHON_LIBS) -lpython$(PYTHON_VERSION)
 
 $(srcdir)/libxml.c: libxml2-py.h # to generate before to compile
 
@@ -53,7 +53,7 @@ GENERATED= libxml2class.py \
 	   libxml2-py.c \
 	   libxml2-py.h
 
-CLEANFILES= $(GENERATED) gen_prog libxml2.py
+CLEANFILES = $(GENERATED) gen_prog libxml2.py *.pyc
 
 $(GENERATED): gen_prog
 
@@ -63,5 +63,5 @@ gen_prog: $(srcdir)/$(GENERATE) $(API_DESC)
 endif
 
 tests test: all
-	cd tests && $(MAKE) MAKEFLAGS+=--silent tests
+	cd tests && $(MAKE) tests
 
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am
index 52c89fc..ca72fdd 100644
--- a/python/tests/Makefile.am
+++ b/python/tests/Makefile.am
@@ -55,6 +55,8 @@ XMLS=		\
     invalid.xml	\
     test.dtd
 
+CLEANFILES = core tmp.xml *.pyc
+
 if WITH_PYTHON
 tests: $(PYTESTS)
 	@echo "## running Python regression tests"
@@ -69,6 +71,3 @@ tests: $(PYTESTS)
 else
 tests:
 endif
-
-clean:
-	rm -f *.pyc core
diff --git a/testRelax.c b/testRelax.c
index e18b3c2..6133348 100644
--- a/testRelax.c
+++ b/testRelax.c
@@ -49,7 +49,7 @@ static int debug = 0;
 #endif
 static int noout = 0;
 static int tree = 0;
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 static int memory = 0;
 #endif
 
@@ -65,7 +65,7 @@ int main(int argc, char **argv) {
 	    debug++;
 	else
 #endif
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 	if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) {
 	    memory++;
         } else
@@ -84,7 +84,7 @@ int main(int argc, char **argv) {
 	    if (schema == NULL) {
 		xmlRelaxNGParserCtxtPtr ctxt;
 
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 		if (memory) {
 		    int fd;
 		    struct stat info;
@@ -174,7 +174,7 @@ int main(int argc, char **argv) {
 #endif
 	printf("\t--noout : do not print the result\n");
 	printf("\t--tree : print the intermediate Relax-NG document tree\n");
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 	printf("\t--memory : test the schemas in memory parsing\n");
 #endif
     }
diff --git a/testSchemas.c b/testSchemas.c
index 47f8b39..b1cb753 100644
--- a/testSchemas.c
+++ b/testSchemas.c
@@ -49,7 +49,7 @@
 static int debug = 0;
 #endif
 static int noout = 0;
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 static int memory = 0;
 #endif
 
@@ -65,7 +65,7 @@ int main(int argc, char **argv) {
 	    debug++;
 	else
 #endif
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 	if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) {
 	    memory++;
         } else
@@ -80,7 +80,7 @@ int main(int argc, char **argv) {
 	    if (schema == NULL) {
 		xmlSchemaParserCtxtPtr ctxt;
 
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 		if (memory) {
 		    int fd;
 		    struct stat info;
@@ -164,7 +164,7 @@ int main(int argc, char **argv) {
 	printf("\t--debug : dump a debug tree of the in-memory document\n");
 #endif
 	printf("\t--noout : do not print the result\n");
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 	printf("\t--memory : test the schemas in memory parsing\n");
 #endif
     }
diff --git a/testapi.c b/testapi.c
index 4f4b39b..25e47be 100644
--- a/testapi.c
+++ b/testapi.c
@@ -127,8 +127,10 @@ int main(int argc, char **argv) {
     int ret;
     int blocks, mem;
 
+#ifdef HAVE_PUTENV
     /* access to the proxy can slow up regression tests a lot */
     putenv((char *) "http_proxy=");
+#endif
 
     memset(chartab, 0, sizeof(chartab));
     strncpy((char *) chartab, "  chartab\n", 20);
diff --git a/threads.c b/threads.c
index 1eeac0e..6d25565 100644
--- a/threads.c
+++ b/threads.c
@@ -439,7 +439,7 @@ __xmlGlobalInitMutexLock(void)
     /* Make sure the global init lock is initialized and then lock it. */
 #ifdef HAVE_PTHREAD_H
     /* The mutex is statically initialized, so we just lock it. */
-    if (pthread_mutex_lock)
+    if (pthread_mutex_lock != NULL)
         pthread_mutex_lock(&global_init_lock);
 #elif defined HAVE_WIN32_THREADS
     LPCRITICAL_SECTION cs;
@@ -509,7 +509,7 @@ void
 __xmlGlobalInitMutexUnlock(void)
 {
 #ifdef HAVE_PTHREAD_H
-    if (pthread_mutex_unlock)
+    if (pthread_mutex_unlock != NULL)
         pthread_mutex_unlock(&global_init_lock);
 #elif defined HAVE_WIN32_THREADS
     if (global_init_lock != NULL) {
diff --git a/trio.c b/trio.c
index b116ccc..a0e3d4d 100644
--- a/trio.c
+++ b/trio.c
@@ -307,6 +307,10 @@ typedef trio_longlong_t trio_int64_t;
 #define NAN_LOWER "nan"
 #define NAN_UPPER "NAN"
 
+#if !defined(HAVE_ISASCII) && !defined(isascii)
+#  define isascii(x) ((unsigned int)(x) < 128)
+#endif
+
 /* Various constants */
 enum {
   TYPE_PRINT = 1,
diff --git a/trio.h b/trio.h
index eab1b6d..108a709 100644
--- a/trio.h
+++ b/trio.h
@@ -28,7 +28,7 @@
  * Use autoconf defines if present. Packages using trio must define
  * HAVE_CONFIG_H as a compiler option themselves.
  */
-#if defined(HAVE_CONFIG_H)
+#if defined(TRIO_HAVE_CONFIG_H)
 # include "config.h"
 #endif
 
diff --git a/win32/Makefile.bcb b/win32/Makefile.bcb
index d612e2d..a374b71 100644
--- a/win32/Makefile.bcb
+++ b/win32/Makefile.bcb
@@ -68,6 +68,9 @@ CFLAGS = $(CFLAGS) -DHAVE_PTHREAD_H
 !if "$(WITH_ZLIB)" == "1"
 CFLAGS = $(CFLAGS) -DHAVE_ZLIB_H
 !endif
+!if "$(WITH_LZMA)" == "1"
+CFLAGS = $(CFLAGS) -DHAVE_LZMA_H
+!endif
 
 # The linker and its options.
 LD = ilink32.exe
@@ -92,6 +95,9 @@ LIBS = $(LIBS) iconvomf.lib
 !if "$(WITH_ZLIB)" == "1"
 LIBS = $(LIBS) zlibomf.lib
 !endif
+!if "$(WITH_LZMA)" == "1"
+LIBS = $(LIBS) liblzma.lib
+!endif
 !if "$(WITH_THREADS)" == "posix"
 LIBS = $(LIBS) pthreadVC.lib
 !endif
@@ -250,10 +256,11 @@ distclean : clean
 rebuild : clean all
 
 install-libs : all
-	if not exist "$(INCPREFIX)\libxml" mkdir "$(INCPREFIX)\libxml"
+	if not exist "$(INCPREFIX)\libxml2" mkdir "$(INCPREFIX)\libxml2"
+	if not exist "$(INCPREFIX)\libxml2\libxml" mkdir "$(INCPREFIX)\libxml2\libxml"
 	if not exist "$(BINPREFIX)" mkdir "$(BINPREFIX)"
 	if not exist "$(LIBPREFIX)" mkdir "$(LIBPREFIX)"
-	copy $(XML_SRCDIR)\include\libxml\*.h "$(INCPREFIX)\libxml"
+	copy $(XML_SRCDIR)\include\libxml\*.h "$(INCPREFIX)\libxml2\libxml"
 	copy $(BINDIR)\$(XML_SO) "$(SOPREFIX)"
 	copy $(BINDIR)\$(XML_A) "$(LIBPREFIX)"
 	copy $(BINDIR)\$(XML_IMP) "$(LIBPREFIX)"
diff --git a/win32/Makefile.mingw b/win32/Makefile.mingw
index 0f8198b..dbe967d 100644
--- a/win32/Makefile.mingw
+++ b/win32/Makefile.mingw
@@ -60,6 +60,9 @@ endif
 ifeq ($(WITH_ZLIB),1)
 CFLAGS += -DHAVE_ZLIB_H
 endif
+ifeq ($(WITH_LZMA),1)
+CFLAGS += -DHAVE_LZMA_H
+endif
 
 # The linker and its options.
 LD = gcc.exe
@@ -83,6 +86,9 @@ ifeq ($(WITH_ZLIB),1)
 # LIBS += -lzdll
 LIBS += -lz
 endif
+ifeq ($(WITH_LZMA),1)
+LIBS += -llzma
+endif
 ifeq ($(WITH_THREADS),posix)
 LIBS += -lpthreadGC
 endif
@@ -254,10 +260,11 @@ distclean : clean
 rebuild : clean all
 
 install-libs : all
-	cmd.exe /C "if not exist $(INCPREFIX)\libxml mkdir $(INCPREFIX)\libxml"
+	cmd.exe /C "if not exist $(INCPREFIX)\libxml2 mkdir $(INCPREFIX)\libxml2"
+	cmd.exe /C "if not exist $(INCPREFIX)\libxml2\libxml mkdir $(INCPREFIX)\libxml2\libxml"
 	cmd.exe /C "if not exist $(BINPREFIX) mkdir $(BINPREFIX)"
 	cmd.exe /C "if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)"
-	cmd.exe /C "copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml"
+	cmd.exe /C "copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml2\libxml"
 	cmd.exe /C "copy $(BINDIR)\$(XML_SO) $(SOPREFIX)"
 	cmd.exe /C "copy $(BINDIR)\$(XML_A) $(LIBPREFIX)"
 	cmd.exe /C "copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)"
diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
index cc93372..8ef4f5e 100644
--- a/win32/Makefile.msvc
+++ b/win32/Makefile.msvc
@@ -299,11 +299,12 @@ distclean : clean
 rebuild : clean all
 
 install-libs : all
-	if not exist $(INCPREFIX)\libxml mkdir $(INCPREFIX)\libxml
+	if not exist $(INCPREFIX)\libxml2 mkdir $(INCPREFIX)\libxml2
+	if not exist $(INCPREFIX)\libxml2\libxml mkdir $(INCPREFIX)\libxml2\libxml
 	if not exist $(BINPREFIX) mkdir $(BINPREFIX)
 	if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
 	if not exist $(SOPREFIX) mkdir $(SOPREFIX)
-	copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml
+	copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml2\libxml
 	copy $(BINDIR)\$(XML_SO) $(SOPREFIX)
 	copy $(BINDIR)\$(XML_A) $(LIBPREFIX)
 	copy $(BINDIR)\$(XML_A_DLL) $(LIBPREFIX)
diff --git a/xml2-config.in b/xml2-config.in
index 2989325..1957486 100644
--- a/xml2-config.in
+++ b/xml2-config.in
@@ -86,12 +86,12 @@ while test $# -gt 0; do
 	then
 	    if [ "@XML_LIBDIR@" = "-L/usr/lib" -o "@XML_LIBDIR@" = "-L/usr/lib64" ]
 	    then
-		echo @XML_LIBS@ 
+		echo @XML_LIBS@ @MODULE_PLATFORM_LIBS@
 	    else
-		echo @XML_LIBDIR@ @XML_LIBS@ 
+		echo @XML_LIBDIR@ @XML_LIBS@ @MODULE_PLATFORM_LIBS@
 	    fi
 	else
-	    echo @XML_LIBDIR@ @XML_LIBS@ @WIN32_EXTRA_LIBADD@
+	    echo @XML_LIBDIR@ @XML_LIBS@ @MODULE_PLATFORM_LIBS@ @WIN32_EXTRA_LIBADD@
 	fi
        	;;
 
diff --git a/xmllint.c b/xmllint.c
index 3edeccb..8c1ca8a 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -169,7 +169,7 @@ static int nodefdtd = 0;
 #ifdef LIBXML_PUSH_ENABLED
 static int push = 0;
 #endif /* LIBXML_PUSH_ENABLED */
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 static int memory = 0;
 #endif
 static int testIO = 0;
@@ -1823,7 +1823,7 @@ static void processNode(xmlTextReaderPtr reader) {
 static void streamFile(char *filename) {
     xmlTextReaderPtr reader;
     int ret;
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
     int fd = -1;
     struct stat info;
     const char *base = NULL;
@@ -1974,7 +1974,7 @@ static void streamFile(char *filename) {
 	patstream = NULL;
     }
 #endif
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
     if (memory) {
         xmlFreeParserInputBuffer(input);
 	munmap((char *) base, info.st_size);
@@ -2212,7 +2212,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
         }
     }
 #endif /* LIBXML_PUSH_ENABLED */
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
     else if ((html) && (memory)) {
 	int fd;
 	struct stat info;
@@ -2327,7 +2327,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 		if (rectxt == NULL)
 		    xmlFreeParserCtxt(ctxt);
 	    }
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 	} else if (memory) {
 	    int fd;
 	    struct stat info;
@@ -2591,7 +2591,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 		}
 	    } else
 #endif
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 	    if (memory) {
 		xmlChar *result;
 		int len;
@@ -2619,7 +2619,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 		}
 
 	    } else
-#endif /* HAVE_SYS_MMAN_H */
+#endif /* HAVE_MMAP */
 	    if (compress) {
 		xmlSaveFile(output ? output : "-", doc);
 	    } else if (oldout) {
@@ -3017,7 +3017,7 @@ static void usage(const char *name) {
 #ifdef LIBXML_PUSH_ENABLED
     printf("\t--push : use the push mode of the parser\n");
 #endif /* LIBXML_PUSH_ENABLED */
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
     printf("\t--memory : parse from memory\n");
 #endif
     printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n");
@@ -3247,7 +3247,7 @@ main(int argc, char **argv) {
 	         (!strcmp(argv[i], "--push")))
 	    push++;
 #endif /* LIBXML_PUSH_ENABLED */
-#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_MMAP
 	else if ((!strcmp(argv[i], "-memory")) ||
 	         (!strcmp(argv[i], "--memory")))
 	    memory++;
diff --git a/xstc/Makefile.am b/xstc/Makefile.am
index 966a8de..5ef1819 100644
--- a/xstc/Makefile.am
+++ b/xstc/Makefile.am
@@ -118,7 +118,7 @@ pytests: $(PYSCRIPTS) $(TESTDIRS)
 
 tests:
 	-@(if [ -x $(PYTHON) ] ; then 					\
-	   $(MAKE) MAKEFLAGS+=--silent pytests ; fi);
+	   $(MAKE) pytests ; fi);
 
 #
 # Heavy, works well only on RHEL3
@@ -126,7 +126,7 @@ tests:
 valgrind:
 	-@(if [ -x $(PYTHON) ] ; then 					\
 	   echo '## Running the regression tests under Valgrind' ;	\
-	   $(MAKE) CHECKER='valgrind -q' MAKEFLAGS+=--silent pytests ; fi);
+	   $(MAKE) CHECKER='valgrind -q' pytests ; fi);
 
 CLEANFILES=$(PYSCRIPTS) test.log
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]