1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-11 05:17:37 +03:00

Respect --sysconfdir in source files

* Prefix installations need to point to a non-root `etc`
  - Gentoo Prefix has been patching this for over 10 years:
    https://bugs.gentoo.org/317891
  - MacPorts has to manually replace paths after patching:
    cc3bb736e9/textproc/libxml2/Portfile (L46)
This commit is contained in:
David Seifert 2022-03-30 00:32:35 +02:00 committed by Nick Wellnhofer
parent 74263eff5f
commit 865520f048
7 changed files with 16 additions and 8 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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);

View File

@ -28,6 +28,10 @@
#include "config.h"
#include <libxml/xmlversion.h>
#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
#endif
#if defined(__Lynx__)
#include <stdio.h> /* pull definition of size_t */
#include <varargs.h>

View File

@ -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))

View File

@ -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
/************************************************************************

View File

@ -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 {