This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit d77f67941712a82163741a1703edb3db8ce7e11b
Author: Jim Jagielski <[email protected]>
AuthorDate: Thu Aug 6 15:24:45 2026 -0400

    Add --with-static-system-libs, and drop -licuuc from the dmake LIBXML2LIB
    
    Takes a comma-separated list (libxml, libxslt, curl) and rewrites each
    "-lfoo" to the archive's absolute path, so a dylib sitting beside it can't
    win. Without it the choice is implicit -- and those dylibs carry absolute
    install names that don't exist on an end user's machine.
    
    LIBXML2LIB now filters -licuuc as RepositoryExternal.mk already did, so
    dmake and gbuild consumers agree.
---
 main/configure.ac                 | 89 +++++++++++++++++++++++++++++++++++++++
 main/forms/util/makefile.mk       |  7 +++
 main/set_soenv.in                 |  4 ++
 main/solenv/inc/libs.mk           | 11 ++++-
 main/xmlsecurity/util/makefile.mk |  7 +++
 5 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/main/configure.ac b/main/configure.ac
index 7d8c04b85e..f560a33bfb 100644
--- a/main/configure.ac
+++ b/main/configure.ac
@@ -441,6 +441,15 @@ AC_ARG_WITH(system-expat,
 AC_ARG_WITH(system-libxml,
 [  --with-system-libxml    Use libxml already on system
 ],,)
+AC_ARG_WITH(static-system-libs,
+[  --with-static-system-libs=LIST
+                          Comma-separated list of system libraries to link
+                          statically, e.g. "libxml,libxslt,curl". Supported:
+                          libxml, libxslt, curl. Without this the archive is
+                          used only when the prefix happens to have no dylib,
+                          so a dylib appearing there silently switches the
+                          build to dynamic linking.
+],,)
 AC_ARG_WITH(system-python,
 [  --with-system-python    Use python already on system
 ],,)
@@ -4029,6 +4038,7 @@ else
     BUILD_TYPE="$BUILD_TYPE LIBXML2 LIBXMLSEC"
 fi
 AC_SUBST(SYSTEM_LIBXML)
+AC_SUBST(SYSTEM_LIBXML_STATIC)
 AC_SUBST(LIBXML_CFLAGS)
 AC_SUBST(LIBXML_LIBS)
 AC_SUBST(LIBXML_PREFIX)
@@ -4729,6 +4739,85 @@ AC_SUBST(CURL_CFLAGS)
 AC_SUBST(CURL_LIBS)
 AC_SUBST(CURL_PREFIX)
 
+dnl ===================================================================
+dnl Pin selected system libraries to their static archives
+dnl ===================================================================
+dnl Runs after the libxml/libxslt/curl checks above, which is where the
+dnl *_PREFIX and *_LIBS values it rewrites are established.
+dnl
+dnl Without this the static-vs-dynamic choice is implicit: "-lfoo" lets the
+dnl linker take a dylib over an archive, and the libxml2 link in
+dnl forms/util and xmlsecurity/util explicitly prefers a dylib when the
+dnl prefix has one. Either way a dylib appearing at the prefix silently
+dnl turns a release build dynamic, and these dylibs carry absolute install
+dnl names that do not exist on an end user's machine.
+STATIC_SYSTEM_LIBS=
+STATIC_SYSTEM_LIBXML=NO
+STATIC_SYSTEM_LIBXSLT=NO
+STATIC_SYSTEM_CURL=NO
+if test -n "$with_static_system_libs" -a "$with_static_system_libs" != "no"; 
then
+   if test "$with_static_system_libs" = "yes"; then
+      AC_MSG_ERROR([--with-static-system-libs needs a list, e.g. 
--with-static-system-libs=libxml,libxslt,curl])
+   fi
+   for _sslib in `echo "$with_static_system_libs" | $SED -e 's/,/ /g'`; do
+      AC_MSG_CHECKING([for a static system $_sslib])
+      case "$_sslib" in
+      libxml)
+         _ssenabled="$SYSTEM_LIBXML"; _ssprefix="$LIBXML_PREFIX"; 
_ssopt="--with-system-libxml"
+         _ssarchives="libxml2.a"; _sslflags="-lxml2"
+         ;;
+      libxslt)
+         _ssenabled="$SYSTEM_LIBXSLT"; _ssprefix="$LIBXSLT_PREFIX"; 
_ssopt="--with-system-libxslt"
+         _ssarchives="libxslt.a libexslt.a"; _sslflags="-lxslt -lexslt"
+         ;;
+      curl)
+         _ssenabled="$SYSTEM_CURL"; _ssprefix="$CURL_PREFIX"; 
_ssopt="--with-system-curl"
+         _ssarchives="libcurl.a"; _sslflags="-lcurl"
+         ;;
+      *)
+         AC_MSG_ERROR([unsupported library "$_sslib" in 
--with-static-system-libs; supported: libxml, libxslt, curl])
+         ;;
+      esac
+      if test "$_ssenabled" != "YES"; then
+         AC_MSG_ERROR([--with-static-system-libs=$_sslib requires $_ssopt])
+      fi
+      if test -z "$_ssprefix"; then
+         AC_MSG_ERROR([--with-static-system-libs=$_sslib needs a prefix; give 
$_ssopt=DIR (macOS only)])
+      fi
+      for _ssa in $_ssarchives; do
+         if test ! -f "$_ssprefix/lib/$_ssa"; then
+            AC_MSG_ERROR([--with-static-system-libs=$_sslib given, but 
$_ssprefix/lib/$_ssa not found])
+         fi
+      done
+      dnl Replace each "-lfoo" with the archive's absolute path so the
+      dnl linker cannot pick a dylib sitting beside it. Matching on a
+      dnl trailing space (the value gets one appended, then trimmed) keeps
+      dnl this to portable BRE -- $SED is whatever sed AC_PATH_PROGS found,
+      dnl which is not required to be GNU, and \| alternation silently
+      dnl matches nothing under the BSD sed macOS ships.
+      for _ssl in $_sslflags; do
+         _ssa="lib`echo "$_ssl" | $SED -e 's/^-l//'`.a"
+         case "$_sslib" in
+         libxml)   LIBXML_LIBS=`echo "$LIBXML_LIBS " | $SED -e "s|$_ssl 
|$_ssprefix/lib/$_ssa |g" -e 's| *$||'` ;;
+         libxslt)  LIBXSLT_LIBS=`echo "$LIBXSLT_LIBS " | $SED -e "s|$_ssl 
|$_ssprefix/lib/$_ssa |g" -e 's| *$||'` ;;
+         curl)     CURL_LIBS=`echo "$CURL_LIBS " | $SED -e "s|$_ssl 
|$_ssprefix/lib/$_ssa |g" -e 's| *$||'` ;;
+         esac
+      done
+      case "$_sslib" in
+      libxml)   STATIC_SYSTEM_LIBXML=YES ;;
+      libxslt)  STATIC_SYSTEM_LIBXSLT=YES ;;
+      curl)     STATIC_SYSTEM_CURL=YES ;;
+      esac
+      STATIC_SYSTEM_LIBS="$STATIC_SYSTEM_LIBS $_sslib"
+      AC_MSG_RESULT([$_ssprefix/lib])
+   done
+   STATIC_SYSTEM_LIBS=`echo $STATIC_SYSTEM_LIBS`
+fi
+AC_SUBST(STATIC_SYSTEM_LIBS)
+AC_SUBST(STATIC_SYSTEM_LIBXML)
+AC_SUBST(STATIC_SYSTEM_LIBXSLT)
+AC_SUBST(STATIC_SYSTEM_CURL)
+
 dnl ===================================================================
 dnl Check for system mdds
 dnl ===================================================================
diff --git a/main/forms/util/makefile.mk b/main/forms/util/makefile.mk
index c38c8bd33d..5c46f97406 100644
--- a/main/forms/util/makefile.mk
+++ b/main/forms/util/makefile.mk
@@ -88,7 +88,14 @@ SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
 # (--enable-shared=no, no dylib at all) -- so without the "-" this aborts
 # the whole build the moment no dylib is found, instead of just leaving
 # the macro empty.
+#
+# --with-static-system-libs=libxml pins this to the archive, so a dylib
+# appearing at the prefix can't silently turn a release build dynamic.
+.IF "$(STATIC_SYSTEM_LIBXML)"=="YES"
+FORMS_LIBXML2_HAS_DYLIB:=
+.ELSE
 FORMS_LIBXML2_HAS_DYLIB:=$(shell -test -f $(LIBXML_PREFIX)/lib/libxml2.dylib 
&& echo yes)
+.ENDIF
 .IF "$(FORMS_LIBXML2_HAS_DYLIB)"=="yes"
 FORMS_LIBXML2LIB:=$(LIBXML_PREFIX)/lib/libxml2.dylib
 .ELSE
diff --git a/main/set_soenv.in b/main/set_soenv.in
index 167a145f6b..14157e0381 100644
--- a/main/set_soenv.in
+++ b/main/set_soenv.in
@@ -1985,6 +1985,10 @@ ToFile( "USE_FT_EMBOLDEN",   "@USE_FT_EMBOLDEN@",  "e" );
 ToFile( "LIBXML_CFLAGS",     "@LIBXML_CFLAGS@",    "e" );
 ToFile( "LIBXML_LIBS",       "@LIBXML_LIBS@",      "e" );
 ToFile( "LIBXML_PREFIX",     "@LIBXML_PREFIX@",    "e" );
+ToFile( "STATIC_SYSTEM_LIBS", "@STATIC_SYSTEM_LIBS@",  "e" );
+ToFile( "STATIC_SYSTEM_LIBXML", "@STATIC_SYSTEM_LIBXML@", "e" );
+ToFile( "STATIC_SYSTEM_LIBXSLT","@STATIC_SYSTEM_LIBXSLT@","e" );
+ToFile( "STATIC_SYSTEM_CURL",  "@STATIC_SYSTEM_CURL@",  "e" );
 ToFile( "SYSTEM_EXPAT",      "@SYSTEM_EXPAT@",     "e" );
 ToFile( "ENABLE_MYSQLC",     "@ENABLE_MYSQLC@",    "e" );
 ToFile( "SYSTEM_MYSQL",      "@SYSTEM_MYSQL@",     "e" );
diff --git a/main/solenv/inc/libs.mk b/main/solenv/inc/libs.mk
index ab9ba42e48..e7051a7b4e 100644
--- a/main/solenv/inc/libs.mk
+++ b/main/solenv/inc/libs.mk
@@ -170,7 +170,10 @@ SVTOOLLIB=-lsvt$(DLLPOSTFIX)
 XMLSECLIB=-lxmlsec1
 XMLSECLIB-NSS=-lxmlsec1-nss
 .IF "$(SYSTEM_LIBXML)"=="YES"
-LIBXML2LIB=$(LIBXML_LIBS)
+# Drop -licuuc for the same reason RepositoryExternal.mk does: libxml2 has
+# already satisfied its own ICU dependency, and forwarding it here makes
+# consumers link this tree's bundled ICU instead.
+LIBXML2LIB=$(LIBXML_LIBS:s/-licuuc//)
 .ELSE
 .IF "$(OS)"=="MACOSX"
 # Bundled libxml2 is a static archive on macOS (main/libxml2/makefile.mk), 
which
@@ -245,7 +248,13 @@ NEON3RDLIB=-lneon
 .IF "$(OS)" == "FREEBSD" && "$(CPUNAME)" == "POWERPC64"
 JPEG3RDLIB=/usr/local/lib/libjpeg.so
 .ENDIF
+.IF "$(SYSTEM_CURL)"=="YES" && "$(STATIC_SYSTEM_CURL)"=="YES"
+# --with-static-system-libs=curl. Unlike XSLTLIB/LIBXML2LIB this is a bare
+# -lcurl rather than $(CURL_LIBS), so configure's rewrite doesn't reach it.
+CURLLIB=$(CURL_PREFIX)/lib/libcurl.a
+.ELSE
 CURLLIB=-lcurl
+.ENDIF
 SFX2LIB=-lsfx$(DLLPOSTFIX)
 SFXLIB=-lsfx$(DLLPOSTFIX)
 EGGTRAYLIB=-leggtray$(DLLPOSTFIX)
diff --git a/main/xmlsecurity/util/makefile.mk 
b/main/xmlsecurity/util/makefile.mk
index 14793f4cda..c93f3e087f 100644
--- a/main/xmlsecurity/util/makefile.mk
+++ b/main/xmlsecurity/util/makefile.mk
@@ -164,7 +164,14 @@ SHL2STDLIBS+= $(NSS3LIB) $(NSPR4LIB)
 # (--enable-shared=no, no dylib at all) -- so without the "-" this aborts
 # the whole build the moment no dylib is found, instead of just leaving
 # the macro empty.
+#
+# --with-static-system-libs=libxml pins this to the archive, so a dylib
+# appearing at the prefix can't silently turn a release build dynamic.
+.IF "$(STATIC_SYSTEM_LIBXML)"=="YES"
+XMLSECURITY_LIBXML2_HAS_DYLIB:=
+.ELSE
 XMLSECURITY_LIBXML2_HAS_DYLIB:=$(shell -test -f 
$(LIBXML_PREFIX)/lib/libxml2.dylib && echo yes)
+.ENDIF
 .IF "$(XMLSECURITY_LIBXML2_HAS_DYLIB)"=="yes"
 XMLSECURITY_SYSTEM_LIBXML2:=$(LIBXML_PREFIX)/lib/libxml2.dylib
 XMLSECURITY_SYSTEM_LIBXML2_EXTRALIBS:=

Reply via email to