diff --git a/CMakeLists.txt b/CMakeLists.txt index 691978ded..f97a0c9bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,6 +361,8 @@ endif() add_library(LibXml2 ${LIBXML2_HDRS} ${LIBXML2_SRCS}) add_library(LibXml2::LibXml2 ALIAS LibXml2) +target_compile_definitions(LibXml2 PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}") + if(NOT BUILD_SHARED_LIBS) target_compile_definitions(LibXml2 INTERFACE LIBXML_STATIC) set(XML_CFLAGS "-DLIBXML_STATIC") @@ -484,6 +486,7 @@ if(LIBXML2_WITH_PROGRAMS) foreach(PROGRAM ${PROGRAMS}) add_executable(${PROGRAM} ${PROGRAM}.c) add_executable(LibXml2::${PROGRAM} ALIAS ${PROGRAM}) + target_compile_definitions(${PROGRAM} PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}") target_link_libraries(${PROGRAM} LibXml2) if(HAVE_LIBHISTORY) target_link_libraries(${PROGRAM} history) @@ -539,6 +542,7 @@ if(LIBXML2_WITH_TESTS) ) foreach(TEST ${TESTS_THREADS}) add_executable(${TEST} ${TEST}.c) + target_compile_definitions(${TEST} PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}") if(WIN32) target_compile_definitions(${TEST} PRIVATE HAVE_WIN32_THREADS) endif() diff --git a/Makefile.am b/Makefile.am index 5d06aaaf5..57768dcdd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,7 +9,7 @@ endif DIST_SUBDIRS = include . doc example fuzz python xstc -AM_CPPFLAGS = -I$(top_builddir)/include -I$(srcdir)/include +AM_CPPFLAGS = -I$(top_builddir)/include -I$(srcdir)/include -DSYSCONFDIR='"$(sysconfdir)"' AM_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS) $(Z_CFLAGS) $(LZMA_CFLAGS) diff --git a/catalog.c b/catalog.c index 729fa55e6..b7837e3da 100644 --- a/catalog.c +++ b/catalog.c @@ -68,15 +68,15 @@ #define XML_URN_PUBID "urn:publicid:" #define XML_CATAL_BREAK ((xmlChar *) -1) #ifndef XML_XML_DEFAULT_CATALOG -#define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog" +#define XML_XML_DEFAULT_CATALOG "file://" SYSCONFDIR "/xml/catalog" #endif #ifndef XML_SGML_DEFAULT_CATALOG -#define XML_SGML_DEFAULT_CATALOG "file:///etc/sgml/catalog" +#define XML_SGML_DEFAULT_CATALOG "file://" SYSCONFDIR "/sgml/catalog" #endif #if defined(_WIN32) && defined(_MSC_VER) #undef XML_XML_DEFAULT_CATALOG -static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog"; +static char XML_XML_DEFAULT_CATALOG[256] = "file://" SYSCONFDIR "/xml/catalog"; #if !defined(_WINDOWS_) void* __stdcall GetModuleHandleA(const char*); unsigned long __stdcall GetModuleFileNameA(void*, char*, unsigned long); diff --git a/libxml.h b/libxml.h index 1330552b8..910ca49be 100644 --- a/libxml.h +++ b/libxml.h @@ -28,6 +28,10 @@ #include "config.h" #include +#ifndef SYSCONFDIR + #define SYSCONFDIR "/etc" +#endif + #if defined(__Lynx__) #include /* pull definition of size_t */ #include diff --git a/runtest.c b/runtest.c index 26443485b..d49905060 100644 --- a/runtest.c +++ b/runtest.c @@ -2927,7 +2927,7 @@ static int urip_rlen; */ static int uripMatch(const char * URI) { - if ((URI == NULL) || (!strcmp(URI, "file:///etc/xml/catalog"))) + if ((URI == NULL) || (!strcmp(URI, "file://" SYSCONFDIR "/xml/catalog"))) return(0); /* Verify we received the escaped URL */ if (strcmp(urip_rcvsURLs[urip_current], URI)) @@ -2946,7 +2946,7 @@ uripMatch(const char * URI) { */ static void * uripOpen(const char * URI) { - if ((URI == NULL) || (!strcmp(URI, "file:///etc/xml/catalog"))) + if ((URI == NULL) || (!strcmp(URI, "file://" SYSCONFDIR "/xml/catalog"))) return(NULL); /* Verify we received the escaped URL */ if (strcmp(urip_rcvsURLs[urip_current], URI)) diff --git a/xmlcatalog.c b/xmlcatalog.c index d4143ad13..9d926118e 100644 --- a/xmlcatalog.c +++ b/xmlcatalog.c @@ -40,7 +40,7 @@ static char *filename = NULL; #ifndef XML_SGML_DEFAULT_CATALOG -#define XML_SGML_DEFAULT_CATALOG "/etc/sgml/catalog" +#define XML_SGML_DEFAULT_CATALOG SYSCONFDIR "/sgml/catalog" #endif /************************************************************************ diff --git a/xmllint.c b/xmllint.c index 5dcb88405..b5dfbd037 100644 --- a/xmllint.c +++ b/xmllint.c @@ -81,7 +81,7 @@ #endif #ifndef XML_XML_DEFAULT_CATALOG -#define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog" +#define XML_XML_DEFAULT_CATALOG "file://" SYSCONFDIR "/xml/catalog" #endif typedef enum {