[libxml2] Don't build unneeded .c source files



commit 14d38a7114c5776e9d4df77da3236ba0864b2d85
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Thu Sep 1 05:53:51 2022 +0200

    Don't build unneeded .c source files

 Makefile.am  | 117 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
 c14n.c       |   2 -
 configure.ac |  72 +++++++++++-------------------------
 3 files changed, 116 insertions(+), 75 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8d6358e8..385ad6ca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,33 +34,83 @@ lib_LTLIBRARIES = libxml2.la
 libxml2_la_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS) $(Z_CFLAGS) $(LZMA_CFLAGS)
 libxml2_la_LIBADD = $(XML_PRIVATE_LIBS)
 
-if USE_VERSION_SCRIPT
-LIBXML2_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/libxml2.syms
-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)
+if USE_VERSION_SCRIPT
+libxml2_la_LDFLAGS += $(VERSION_SCRIPT_FLAGS)$(srcdir)/libxml2.syms
+endif
 
+libxml2_la_SOURCES = buf.c chvalid.c dict.c entities.c encoding.c error.c \
+                    globals.c hash.c list.c parser.c parserInternals.c \
+                    SAX2.c threads.c tree.c uri.c valid.c xmlIO.c \
+                    xmlmemory.c xmlstring.c
+if WITH_C14N_SOURCES
+libxml2_la_SOURCES += c14n.c
+endif
+if WITH_CATALOG_SOURCES
+libxml2_la_SOURCES += catalog.c
+endif
+if WITH_DEBUG_SOURCES
+libxml2_la_SOURCES += debugXML.c
+endif
+if WITH_FTP_SOURCES
+libxml2_la_SOURCES += nanoftp.c
+endif
+if WITH_HTML_SOURCES
+libxml2_la_SOURCES += HTMLparser.c HTMLtree.c
+endif
+if WITH_HTTP_SOURCES
+libxml2_la_SOURCES += nanohttp.c
+endif
+if WITH_LEGACY_SOURCES
+libxml2_la_SOURCES += legacy.c
+if WITH_SAX1_SOURCES
+libxml2_la_SOURCES += SAX.c
+endif
+endif
+if WITH_LZMA_SOURCES
+libxml2_la_SOURCES += xzlib.c
+endif
+if WITH_MODULES_SOURCES
+libxml2_la_SOURCES += xmlmodule.c
+endif
+if WITH_OUTPUT_SOURCES
+libxml2_la_SOURCES += xmlsave.c
+endif
+if WITH_PATTERN_SOURCES
+libxml2_la_SOURCES += pattern.c
+endif
+if WITH_READER_SOURCES
+libxml2_la_SOURCES += xmlreader.c
+endif
+if WITH_REGEXPS_SOURCES
+libxml2_la_SOURCES += xmlregexp.c xmlunicode.c
+endif
+if WITH_SCHEMAS_SOURCES
+libxml2_la_SOURCES += relaxng.c xmlschemas.c xmlschemastypes.c
+if !WITH_XPATH_SOURCES
+libxml2_la_SOURCES += xpath.c
+endif
+endif
+if WITH_SCHEMATRON_SOURCES
+libxml2_la_SOURCES += schematron.c
+endif
 if WITH_TRIO_SOURCES
-trio_sources = triostr.c trio.c
-else
-trio_sources =
+libxml2_la_SOURCES += triostr.c trio.c
+endif
+if WITH_WRITER_SOURCES
+libxml2_la_SOURCES += xmlwriter.c
+endif
+if WITH_XINCLUDE_SOURCES
+libxml2_la_SOURCES += xinclude.c
+endif
+if WITH_XPATH_SOURCES
+libxml2_la_SOURCES += xpath.c
+endif
+if WITH_XPTR_SOURCES
+libxml2_la_SOURCES += xlink.c xpointer.c
 endif
-
-libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c  \
-               parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c  \
-               valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c  \
-               xpointer.c xinclude.c nanohttp.c nanoftp.c \
-               catalog.c globals.c threads.c c14n.c xmlstring.c buf.c \
-               xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
-               $(trio_sources) \
-               xmlreader.c relaxng.c dict.c SAX2.c \
-               xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
-               xmlmodule.c schematron.c xzlib.c
 
 DEPS = $(top_builddir)/libxml2.la
 LDADDS = $(top_builddir)/libxml2.la
@@ -175,7 +225,30 @@ asan:
        ./configure CFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security 
-Werror=array-bounds -g" CXXFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security 
-Werror=array-bounds -g" LDFLAGS="-fsanitize=address,undefined" CC="clang" CXX="clang++" --disable-shared ; 
OptimOff  ; $(MAKE) clean ; $(MAKE)
 
 # Old test suite. This should be ported to C.
-tests: $(TEST_DEBUG) $(TEST_CATALOG) $(TEST_REGEXPS) $(TEST_SCHEMATRON) Timingtests $(TEST_VTIME) 
$(PYTHON_TESTS)
+
+OLD_TESTS = Timingtests
+if WITH_CATALOG_SOURCES
+OLD_TESTS += Catatests
+endif
+if WITH_DEBUG_SOURCES
+OLD_TESTS += Scripttests
+endif
+if WITH_REGEXPS_SOURCES
+OLD_TESTS += Automatatests
+endif
+if WITH_SCHEMAS_SOURCES
+if WITH_PYTHON
+OLD_TESTS += RelaxNGPythonTests SchemasPythonTests
+endif
+endif
+if WITH_SCHEMATRON_SOURCES
+OLD_TESTS += Schematrontests
+endif
+if WITH_VALID_SOURCES
+OLD_TESTS += VTimingtests
+endif
+
+tests: $(OLD_TESTS)
 
 Scripttests : xmllint$(EXEEXT)
        @(echo > .memdump)
diff --git a/c14n.c b/c14n.c
index 717e5cec..35fcf358 100644
--- a/c14n.c
+++ b/c14n.c
@@ -12,7 +12,6 @@
 #define IN_LIBXML
 #include "libxml.h"
 #ifdef LIBXML_C14N_ENABLED
-#ifdef LIBXML_OUTPUT_ENABLED
 
 #include <stdlib.h>
 #include <string.h>
@@ -2224,6 +2223,5 @@ xmlC11NNormalizeString(const xmlChar * input,
     *out = 0;
     return (buffer);
 }
-#endif /* LIBXML_OUTPUT_ENABLED */
 
 #endif /* LIBXML_C14N_ENABLED */
diff --git a/configure.ac b/configure.ac
index 7badc57b..f2bbeddc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -417,6 +417,7 @@ fi
 AC_SUBST(LZMA_CFLAGS)
 AC_SUBST(LZMA_LIBS)
 AC_SUBST(WITH_LZMA)
+AM_CONDITIONAL(WITH_LZMA_SOURCES, test "$WITH_LZMA" = "1")
 
 CPPFLAGS=${_cppflags}
 LIBS=${_libs}
@@ -755,7 +756,6 @@ dnl
 dnl check for python
 dnl
 
-PYTHON_TESTS=
 AS_IF([test "x$with_python" != "xno"], [
     AM_PATH_PYTHON
     PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
@@ -815,6 +815,7 @@ fi
 AC_SUBST(WITH_MODULES)
 AC_SUBST(MODULE_PLATFORM_LIBS)
 AC_SUBST(MODULE_EXTENSION)
+AM_CONDITIONAL(WITH_MODULES_SOURCES, test "$WITH_MODULES" = "1")
 
 dnl
 dnl Check for trio string functions
@@ -955,24 +956,20 @@ AC_SUBST(WITH_TREE)
 if test "$with_ftp" != "yes" ; then
     echo Disabling FTP support
     WITH_FTP=0
-    FTP_OBJ=
 else    
     WITH_FTP=1
-    FTP_OBJ=nanoftp.o
 fi
 AC_SUBST(WITH_FTP)
-AC_SUBST(FTP_OBJ)
+AM_CONDITIONAL(WITH_FTP_SOURCES, test "$WITH_FTP" = "1")
 
 if test "$with_http" = "no" ; then
     echo Disabling HTTP support
     WITH_HTTP=0
-    HTTP_OBJ=
 else    
     WITH_HTTP=1
-    HTTP_OBJ=nanohttp.o
 fi
 AC_SUBST(WITH_HTTP)
-AC_SUBST(HTTP_OBJ)
+AM_CONDITIONAL(WITH_HTTP_SOURCES, test "$WITH_HTTP" = "1")
 
 if test "$with_legacy" != "yes" ; then
     echo Disabling deprecated APIs
@@ -981,6 +978,7 @@ else
     WITH_LEGACY=1
 fi
 AC_SUBST(WITH_LEGACY)
+AM_CONDITIONAL(WITH_LEGACY_SOURCES, test "$WITH_LEGACY" = "1")
 
 if test "$with_reader" = "no" ; then
     echo Disabling the xmlReader parsing interface
@@ -993,14 +991,13 @@ else
     fi
 fi
 AC_SUBST(WITH_READER)
+AM_CONDITIONAL(WITH_READER_SOURCES, test "$WITH_READER" = "1")
 
 if test "$with_writer" = "no" ; then
     echo Disabling the xmlWriter saving interface
     WITH_WRITER=0
-#    WRITER_TEST=
 else    
     WITH_WRITER=1
-#    WRITER_TEST=Writertests
     if test "$with_push" = "no" ; then
         echo xmlWriter requires Push interface - enabling it
        with_push=yes
@@ -1011,7 +1008,7 @@ else
     fi
 fi
 AC_SUBST(WITH_WRITER)
-#AC_SUBST(WRITER_TEST)
+AM_CONDITIONAL(WITH_WRITER_SOURCES, test "$WITH_WRITER" = "1")
 
 if test "$with_pattern" = "no" ; then
     echo Disabling the xmlPattern parsing interface
@@ -1020,6 +1017,7 @@ else
     WITH_PATTERN=1
 fi
 AC_SUBST(WITH_PATTERN)
+AM_CONDITIONAL(WITH_PATTERN_SOURCES, test "$WITH_PATTERN" = "1")
 
 if test "$with_sax1" = "no" ; then
     echo Disabling the older SAX1 interface
@@ -1028,6 +1026,7 @@ else
     WITH_SAX1=1
 fi
 AC_SUBST(WITH_SAX1)
+AM_CONDITIONAL(WITH_SAX1_SOURCES, test "$WITH_SAX1" = "1")
 
 if test "$with_push" = "no" ; then
     echo Disabling the PUSH parser interfaces
@@ -1040,48 +1039,36 @@ AC_SUBST(WITH_PUSH)
 if test "$with_html" = "no" ; then
     echo Disabling HTML support
     WITH_HTML=0
-    HTML_OBJ=
 else    
     WITH_HTML=1
-    HTML_OBJ="HTMLparser.o HTMLtree.o"
 fi
 AC_SUBST(WITH_HTML)
-AC_SUBST(HTML_OBJ)
+AM_CONDITIONAL(WITH_HTML_SOURCES, test "$WITH_HTML" = "1")
 
 if test "$with_valid" = "no" ; then
     echo Disabling DTD validation support
     WITH_VALID=0
-    TEST_VTIME=
 else    
     WITH_VALID=1
-    TEST_VTIME=VTimingtests
 fi
 AC_SUBST(WITH_VALID)
-AC_SUBST(TEST_VALID)
-AC_SUBST(TEST_VTIME)
+AM_CONDITIONAL(WITH_VALID_SOURCES, test "$WITH_VALID" = "1")
 
 if test "$with_catalog" = "no" ; then
     echo Disabling Catalog support
     WITH_CATALOG=0
-    CATALOG_OBJ=
-    TEST_CATALOG=
 else    
     WITH_CATALOG=1
-    CATALOG_OBJ="catalog.o"
-    TEST_CATALOG=Catatests
 fi
 AC_SUBST(WITH_CATALOG)
-AC_SUBST(CATALOG_OBJ)
-AC_SUBST(TEST_CATALOG)
+AM_CONDITIONAL(WITH_CATALOG_SOURCES, test "$WITH_CATALOG" = "1")
 
 if test "$with_xptr" = "no" ; then
     echo Disabling XPointer support
     WITH_XPTR=0
     WITH_XPTR_LOCS=0
-    XPTR_OBJ=
 else    
     WITH_XPTR=1
-    XPTR_OBJ=xpointer.o
     if test "$with_xpath" = "no" ; then
         echo XPointer requires XPath support - enabling it
        with_xpath=yes
@@ -1094,38 +1081,34 @@ else
 fi
 AC_SUBST(WITH_XPTR)
 AC_SUBST(WITH_XPTR_LOCS)
-AC_SUBST(XPTR_OBJ)
+AM_CONDITIONAL(WITH_XPTR_SOURCES, test "$WITH_XPTR" = "1")
 
 if test "$with_c14n" = "no" ; then
     echo Disabling C14N support
     WITH_C14N=0
-    C14N_OBJ=
 else    
     WITH_C14N=1
-    C14N_OBJ="c14n.c"
     if test "$with_xpath" = "no" ; then
         echo C14N requires XPath support - enabling it
        with_xpath=yes
     fi
 fi
 AC_SUBST(WITH_C14N)
-AC_SUBST(C14N_OBJ)
+AM_CONDITIONAL(WITH_C14N_SOURCES, test "$WITH_C14N" = "1")
 
 if test "$with_xinclude" = "no" ; then
     echo Disabling XInclude support
     WITH_XINCLUDE=0
-    XINCLUDE_OBJ=
     with_xinclude="no"
 else    
     WITH_XINCLUDE=1
-    XINCLUDE_OBJ=xinclude.o
     if test "$with_xpath" = "no" ; then
         echo XInclude requires XPath support - enabling it
        with_xpath=yes
     fi
 fi
 AC_SUBST(WITH_XINCLUDE)
-AC_SUBST(XINCLUDE_OBJ)
+AM_CONDITIONAL(WITH_XINCLUDE_SOURCES, test "$WITH_XINCLUDE" = "1")
 
 if test "$with_xptr" = "" && test "$with_xpath" = "no" ; then
     with_xptr=no
@@ -1138,28 +1121,24 @@ fi
 if test "$with_schematron" = "no" ; then
     echo "Disabling Schematron support"
     WITH_SCHEMATRON=0
-    TEST_SCHEMATRON=
 else 
     echo "Enabled Schematron support"
     WITH_SCHEMATRON=1
-    TEST_SCHEMATRON="Schematrontests"
     with_xpath=yes
     with_pattern=yes
     with_schematron=yes
 fi
 AC_SUBST(WITH_SCHEMATRON)
-AC_SUBST(TEST_SCHEMATRON)
+AM_CONDITIONAL(WITH_SCHEMATRON_SOURCES, test "$WITH_SCHEMATRON" = "1")
 
 if test "$with_xpath" = "no" ; then
     echo Disabling XPATH support
     WITH_XPATH=0
-    XPATH_OBJ=
 else    
     WITH_XPATH=1
-    XPATH_OBJ=xpath.o
 fi
 AC_SUBST(WITH_XPATH)
-AC_SUBST(XPATH_OBJ)
+AM_CONDITIONAL(WITH_XPATH_SOURCES, test "$WITH_XPATH" = "1")
 
 dnl
 dnl output functions
@@ -1171,6 +1150,7 @@ else
     WITH_OUTPUT=1
 fi
 AC_SUBST(WITH_OUTPUT)
+AM_CONDITIONAL(WITH_OUTPUT_SOURCES, test "$WITH_OUTPUT" = "1")
 
 WITH_ICONV=0
 if test "$with_iconv" = "no" ; then
@@ -1299,37 +1279,28 @@ if test "$with_schemas" = "no" ; then
 else    
     echo "Enabled Schemas/Relax-NG support"
     WITH_SCHEMAS=1
-    AS_IF([test "x$with_python" != "xno"], [
-        PYTHON_TESTS="$PYTHON_TESTS RelaxNGPythonTests SchemasPythonTests"
-    ])
     with_regexps=yes
 fi
 AC_SUBST(WITH_SCHEMAS)
+AM_CONDITIONAL(WITH_SCHEMAS_SOURCES, test "$WITH_SCHEMAS" = "1")
 
 if test "$with_regexps" = "no" ; then
     echo Disabling Regexps support
     WITH_REGEXPS=0
-    TEST_REGEXPS=
 else    
     WITH_REGEXPS=1
-    TEST_REGEXPS="Automatatests"
 fi
 AC_SUBST(WITH_REGEXPS)
-AC_SUBST(TEST_REGEXPS)
+AM_CONDITIONAL(WITH_REGEXPS_SOURCES, test "$WITH_REGEXPS" = "1")
 
 if test "$with_debug" = "no" ; then
     echo Disabling DEBUG support
     WITH_DEBUG=0
-    DEBUG_OBJ=
-    TEST_DEBUG=
 else    
     WITH_DEBUG=1
-    DEBUG_OBJ=debugXML.o
-    TEST_DEBUG=Scripttests
 fi
 AC_SUBST(WITH_DEBUG)
-AC_SUBST(DEBUG_OBJ)
-AC_SUBST(TEST_DEBUG)
+AM_CONDITIONAL(WITH_DEBUG_SOURCES, test "$WITH_DEBUG" = "1")
 
 if test "$with_mem_debug" = "yes" ; then
     if test "$with_thread_alloc" = "yes" ; then
@@ -1434,7 +1405,6 @@ AC_SUBST(RDL_LIBS)
 dnl for the spec file
 RELDATE=`date +'%a %b %e %Y'`
 AC_SUBST(RELDATE)
-AC_SUBST(PYTHON_TESTS)
 
 # keep on one line for cygwin c.f. #130896
 AC_CONFIG_FILES([libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile 
include/private/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile 
fuzz/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h libxml-2.0.pc 
libxml-2.0-uninstalled.pc libxml2-config.cmake])


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