This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch AOO42X in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 6d7cc7bfde5e4f953549929d761b3a6f6a9d699f Author: Jim Jagielski <[email protected]> AuthorDate: Thu Aug 6 14:38:22 2026 -0400 RepositoryExternal.mk, libs.mk: prefer /usr/local/lib static libs on macOS If the user already has a prebuilt libxml2.a/libxslt.a/libexslt.a/ libcurl.a/libiconv.a under /usr/local/lib, use that instead of what this tree just built. Falls back to the tree's own copy when absent. (cherry picked from commit 9b92099a7350282ddfb677eafe03e37ee774e545) --- main/RepositoryExternal.mk | 35 +++++++++++++++++++++++++++++++---- main/solenv/inc/libs.mk | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/main/RepositoryExternal.mk b/main/RepositoryExternal.mk index 523065187d..0773f902de 100644 --- a/main/RepositoryExternal.mk +++ b/main/RepositoryExternal.mk @@ -160,10 +160,17 @@ ifeq ($(OS),MACOSX) # not a dylib, so it can't be a PLAINLIB like the else-branch below. A static # archive carries no transitive deps, so its own libxml-2.0.pc's # "Libs.private: -lpthread -liconv -lm" must be added explicitly. +# +# If the user already has prebuilt static libs under /usr/local/lib, prefer +# those over the tree's own build (Apple's SDK ships no static libiconv.a, +# only a .tbd stub for the dylib, so a /usr/local one is additive there). +gb_libxml2_static_lib := $(if $(wildcard /usr/local/lib/libxml2.a),/usr/local/lib/libxml2.a,$(OUTDIR)/lib/libxml2.a) +gb_libiconv_static_lib := $(if $(wildcard /usr/local/lib/libiconv.a),/usr/local/lib/libiconv.a,-liconv) + define gb_LinkTarget__use_libxml2 $(call gb_LinkTarget_add_libs,$(1),\ - $(OUTDIR)/lib/libxml2.a \ - -lpthread -liconv -lm \ + $(gb_libxml2_static_lib) \ + -lpthread $(gb_libiconv_static_lib) -lm \ ) endef @@ -200,10 +207,14 @@ ifeq ($(OS),MACOSX) # Bundled libxslt/libexslt build as static archives on macOS (see # main/libxslt/makefile.mk); link by absolute path, same as libxml2 above. +# Prefer a prebuilt /usr/local/lib copy when the user already has one. +gb_libxslt_static_lib := $(if $(wildcard /usr/local/lib/libxslt.a),/usr/local/lib/libxslt.a,$(OUTDIR)/lib/libxslt.a) +gb_libexslt_static_lib := $(if $(wildcard /usr/local/lib/libexslt.a),/usr/local/lib/libexslt.a,$(OUTDIR)/lib/libexslt.a) + define gb_LinkTarget__use_libxslt $(call gb_LinkTarget_add_libs,$(1),\ - $(OUTDIR)/lib/libxslt.a \ - $(OUTDIR)/lib/libexslt.a \ + $(gb_libxslt_static_lib) \ + $(gb_libexslt_static_lib) \ ) endef @@ -441,18 +452,34 @@ endef else # !SYSTEM_CURL +ifeq ($(OS),MACOSX) + +# If the user already has a prebuilt static libcurl.a under /usr/local/lib, +# prefer that copy over the tree's own (dylib) build. +gb_curl_static_lib := $(wildcard /usr/local/lib/libcurl.a) + +else # !MACOSX ifeq ($(OS),WNT) $(eval $(call gb_Helper_register_libraries,PLAINLIBS_NONE,libcurl)) else $(eval $(call gb_Helper_register_libraries,PLAINLIBS_NONE,curl)) endif +endif # MACOSX define gb_LinkTarget__use_curl +ifeq ($(OS),MACOSX) +ifneq ($(gb_curl_static_lib),) +$(call gb_LinkTarget_add_libs,$(1),$(gb_curl_static_lib)) +else +$(call gb_LinkTarget_add_linked_libs,$(1),curl) +endif +else ifeq ($(OS),WNT) $(call gb_LinkTarget_add_linked_libs,$(1),libcurl) else $(call gb_LinkTarget_add_linked_libs,$(1),curl) endif +endif endef endif # SYSTEM_CURL diff --git a/main/solenv/inc/libs.mk b/main/solenv/inc/libs.mk index ab9ba42e48..b9478bd835 100644 --- a/main/solenv/inc/libs.mk +++ b/main/solenv/inc/libs.mk @@ -175,7 +175,22 @@ LIBXML2LIB=$(LIBXML_LIBS) .IF "$(OS)"=="MACOSX" # Bundled libxml2 is a static archive on macOS (main/libxml2/makefile.mk), which # carries no transitive deps -- add what its own .pc's Libs.private needs. -LIBXML2LIB=-lxml2 -lpthread -liconv -lm +# If the user already has prebuilt static libs under /usr/local/lib, prefer +# those over the tree's own build (Apple's SDK ships no static libiconv.a, +# only a .tbd stub for the dylib, so a /usr/local one is additive there). +PREBUILT_LIBXML2_A:=$(shell -test -f /usr/local/lib/libxml2.a && echo yes) +PREBUILT_LIBICONV_A:=$(shell -test -f /usr/local/lib/libiconv.a && echo yes) +.IF "$(PREBUILT_LIBXML2_A)"=="yes" +LIBXML2LIB_XML2A=/usr/local/lib/libxml2.a +.ELSE +LIBXML2LIB_XML2A=-lxml2 +.ENDIF +.IF "$(PREBUILT_LIBICONV_A)"=="yes" +LIBXML2LIB_ICONVA=/usr/local/lib/libiconv.a +.ELSE +LIBXML2LIB_ICONVA=-liconv +.ENDIF +LIBXML2LIB=$(LIBXML2LIB_XML2A) -lpthread $(LIBXML2LIB_ICONVA) -lm .ELSE LIBXML2LIB=-lxml2 .ENDIF @@ -245,7 +260,18 @@ NEON3RDLIB=-lneon .IF "$(OS)" == "FREEBSD" && "$(CPUNAME)" == "POWERPC64" JPEG3RDLIB=/usr/local/lib/libjpeg.so .ENDIF +.IF "$(SYSTEM_CURL)"!="YES" && "$(OS)"=="MACOSX" +# If the user already has a prebuilt static libcurl.a under /usr/local/lib, +# prefer that copy over the tree's own (dylib) build. +PREBUILT_LIBCURL_A:=$(shell -test -f /usr/local/lib/libcurl.a && echo yes) +.IF "$(PREBUILT_LIBCURL_A)"=="yes" +CURLLIB=/usr/local/lib/libcurl.a +.ELSE +CURLLIB=-lcurl +.ENDIF +.ELSE CURLLIB=-lcurl +.ENDIF SFX2LIB=-lsfx$(DLLPOSTFIX) SFXLIB=-lsfx$(DLLPOSTFIX) EGGTRAYLIB=-leggtray$(DLLPOSTFIX) @@ -287,8 +313,17 @@ GTESTLIB= -lgtest .IF "$(SYSTEM_LIBXSLT)"=="YES" XSLTLIB=$(LIBXSLT_LIBS) .ELSE +.IF "$(OS)"=="MACOSX" +PREBUILT_LIBXSLT_A:=$(shell -test -f /usr/local/lib/libxslt.a && echo yes) +.IF "$(PREBUILT_LIBXSLT_A)"=="yes" +XSLTLIB=/usr/local/lib/libxslt.a $(LIBXML2LIB) +.ELSE XSLTLIB=-lxslt $(LIBXML2LIB) .ENDIF +.ELSE +XSLTLIB=-lxslt $(LIBXML2LIB) +.ENDIF +.ENDIF .IF "$(GUI)$(COM)"=="WNTGCC" || "$(GUI)"=="OS2" JVMFWKLIB = -ljvmfwk$(UDK_MAJOR) .ELSE # "$(GUI)$(COM)"=="WNTGCC"
