Makefile.gbuild                              |    6 
 Repository.mk                                |    4 
 RepositoryModule_host.mk                     |    5 
 canvas/Module_canvas.mk                      |    2 
 config_host.mk.in                            |    1 
 config_host/config_vclplug.h.in              |    1 
 configure.ac                                 |   55 ++++---
 connectivity/Library_postgresql-sdbc-impl.mk |   16 +-
 desktop/Module_desktop.mk                    |    2 
 extensions/Module_extensions.mk              |    2 
 libreofficekit/Module_libreofficekit.mk      |    2 
 sd/source/core/typemap.cxx                   |   42 +++++
 solenv/gbuild/LinkTarget.mk                  |   94 ++++++++++--
 solenv/gbuild/TargetLocations.mk             |    3 
 solenv/gbuild/gbuild.mk                      |    1 
 solenv/gbuild/platform/unxgcc.mk             |    8 -
 solenv/gbuild/static.mk                      |  207 +++++++++++++++++++++++++++
 static/CustomTarget_components.mk            |   37 ++++
 static/Library_components.mk                 |   18 ++
 static/Makefile                              |   13 +
 static/Module_static.mk                      |   20 ++
 static/README.md                             |    4 
 sw/source/uibase/app/swmodule.cxx            |    9 -
 vcl/Module_vcl.mk                            |    4 
 vcl/source/app/salplug.cxx                   |   22 ++
 xmlsecurity/Module_xmlsecurity.mk            |    2 
 26 files changed, 517 insertions(+), 63 deletions(-)

New commits:
commit dc9ccf3d8f294cd7ae9d5bece7b6c16c3b22f6a5
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Fri May 21 15:41:15 2021 +0200
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Wed Jan 12 11:12:46 2022 +0100

    gbuild: build static LO / link static executables
    
    This allows to build a complete static LibreOffice on Linux,
    except for linked externals. Since LO's static build implies
    disabled dynamic loading, one must select one VCL backend to
    be compiled in.
    
    See the (large) comment in solenv/gbuild/static.mk trying to
    explain, why this implementation was chosen (spoiler: seems
    there is no other way) and what is actually implemented.
    
    This will collect all libraries, statics and externals of
    executables. If the executable uses components, it will get
    linked to all static components. While it works with any
    Executable, it just makes sense for soffice.bin, because the
    static component map sucks every dependency in, bloating most
    other binaries.
    
    In theory on could generate the dependencies based on the list
    of used components (see gb_CppunitTest_use_components), then
    generate a specific static constructor map, directly include it
    in the exe's cxx code and then link the minimal dependencies.
    
    The static LO should build on Linux with:
    --enable-customtarget-components
    --disable-dynamic-loading
    
    Tested VCL plugin config is:
    --disable-gtk3
    --disable-gen
    --enable-qt5
    
    The partial build support is split into a 2nd patch.
    
    Change-Id: Iafc95752fae9e88095f54a21f1e30a4f080815e2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126790
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/Makefile.gbuild b/Makefile.gbuild
index 9e7f205e22d4..37e787abe1b9 100644
--- a/Makefile.gbuild
+++ b/Makefile.gbuild
@@ -20,8 +20,12 @@ include $(SRCDIR)/solenv/gbuild/gbuild.mk
 
 $(eval $(call 
gb_Module_make_global_targets,$(SRCDIR)/RepositoryModule_$(gb_Side).mk))
 
-ifneq (,$(DISABLE_DYNLOADING))
+ifeq ($(DISABLE_DYNLOADING),TRUE)
 $(if $(gb_LinkTarget__Lock),$(shell rm -f $(gb_LinkTarget__Lock)))
+ifeq ($(ENABLE_CUSTOMTARGET_COMPONENTS),TRUE)
+include $(SRCDIR)/solenv/gbuild/static.mk
+$(if $(filter a,$(gb_DEBUG_STATIC)),$(error Abort after static.mk))
+endif
 endif
 
 upload-symbols:
diff --git a/Repository.mk b/Repository.mk
index 23dbc470dbcc..19dc0b034189 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -476,14 +476,14 @@ $(eval $(call 
gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 
 $(eval $(call gb_Helper_register_plugins_for_install,OOOLIBS,ooo, \
     acc \
+    $(if $(ENABLE_CUSTOMTARGET_COMPONENTS),components) \
     cui \
     $(if $(USING_X11),desktop_detector) \
     icg \
     sdui \
-    $(if $(USING_X11),vclplug_gen) \
+    $(if $(ENABLE_GEN),vclplug_gen) \
     $(if $(filter $(OS),WNT),vclplug_win) \
     $(if $(filter $(OS),MACOSX),vclplug_osx) \
-    $(if $(USING_X11),,$(if $(ENABLE_QT5),vclplug_qt5)) \
 ))
 
 $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,postgresqlsdbc, 
\
diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk
index 1c28bb0f51c1..041496c14ae4 100644
--- a/RepositoryModule_host.mk
+++ b/RepositoryModule_host.mk
@@ -35,7 +35,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\
        canvas \
        chart2 \
        cli_ure \
-       $(call gb_Helper_optional,DESKTOP,codemaker) \
+    codemaker \
        comphelper \
        configmgr \
        connectivity \
@@ -119,6 +119,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\
        soltools \
        sot \
        starmath \
+    $(if $(ENABLE_CUSTOMTARGET_COMPONENTS),static) \
        stoc \
        store \
        svl \
@@ -160,6 +161,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\
        xmlsecurity \
 ))
 
+ifeq (,$(DISABLE_DYNLOADING))
 # Especially when building everything with symbols, the linking of the largest
 # libraries takes enormous amounts of RAM.     To prevent annoying OOM 
situations
 # etc., try to prevent linking these in parallel by adding artificial build
@@ -192,5 +194,6 @@ $(eval $(call repositorymodule_serialize,\
                svx svxcore xo sfx fwk svt vcl) \
 ))
 endif
+endif # !$(DISABLE_DYNLOADING)
 
 # vim: set noet sw=4 ts=4:
diff --git a/canvas/Module_canvas.mk b/canvas/Module_canvas.mk
index aadd9f369c83..79165c4976e7 100644
--- a/canvas/Module_canvas.mk
+++ b/canvas/Module_canvas.mk
@@ -25,7 +25,7 @@ $(eval $(call gb_Module_add_targets,canvas,\
        Library_simplecanvas \
        Library_vclcanvas \
     $(if $(filter DESKTOP,$(BUILD_TYPE)), \
-        $(if $(DISABLE_GUI),,Executable_canvasdemo)) \
+        $(if $(or 
$(DISABLE_GUI),$(DISABLE_DYNLOADING)),,Executable_canvasdemo)) \
 ))
 
 ifeq ($(ENABLE_CAIRO_CANVAS),TRUE)
diff --git a/config_host.mk.in b/config_host.mk.in
index 27e2e2359241..8d7b6bdfe7bf 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -158,6 +158,7 @@ export ENABLE_EVOAB2=@ENABLE_EVOAB2@
 export ENABLE_FIREBIRD_SDBC=@ENABLE_FIREBIRD_SDBC@
 export ENABLE_FORMULA_LOGGER=@ENABLE_FORMULA_LOGGER@
 export ENABLE_GDB_INDEX=@ENABLE_GDB_INDEX@
+export ENABLE_GEN=@ENABLE_GEN@
 export ENABLE_GIO=@ENABLE_GIO@
 export ENABLE_GPGMEPP=@ENABLE_GPGMEPP@
 export ENABLE_GSTREAMER_1_0=@ENABLE_GSTREAMER_1_0@
diff --git a/config_host/config_vclplug.h.in b/config_host/config_vclplug.h.in
index 794139606e29..b321f44e022e 100644
--- a/config_host/config_vclplug.h.in
+++ b/config_host/config_vclplug.h.in
@@ -15,6 +15,7 @@ Settings about which desktops have support enabled.
 /**
  * Set the enabled platform plugins
  */
+#define ENABLE_GEN 0
 #define ENABLE_GTK3 0
 #define ENABLE_GTK3_KDE5 0
 #define ENABLE_HEADLESS 0
diff --git a/configure.ac b/configure.ac
index aa9f75d7cf64..16ae752e0b86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1138,6 +1138,7 @@ fi
 # Set defaults, if not set by platform
 test "${test_cups+set}" = set || test_cups="$using_x11"
 test "${test_dbus+set}" = set || test_dbus="$using_x11"
+test "${test_gen+set}" = set || test_gen="$using_x11"
 test "${test_gstreamer_1_0+set}" = set || test_gstreamer_1_0="$using_x11"
 test "${test_gtk3+set}" = set || test_gtk3="$using_x11"
 test "${test_gtk4+set}" = set || test_gtk4="$using_x11"
@@ -1166,6 +1167,7 @@ disable_x11_tests()
 {
     test_cups=no
     test_dbus=no
+    test_gen=no
     test_gstreamer_1_0=no
     test_gtk3_kde5=no
     test_gtk3=no
@@ -1714,6 +1716,12 @@ AC_ARG_ENABLE(gtk3_kde5,
          platforms where Gtk3, Qt5 and Plasma is available.]),
 ,)
 
+AC_ARG_ENABLE(gen,
+    AS_HELP_STRING([--enable-gen],
+        [To select the gen backend in case of --disable-dynamic-loading.
+         Per default auto-enabled when X11 is used.]),
+,test "${test_gen}" = no -o "${enable_gen+set}" = set || enable_gen=yes)
+
 AC_ARG_ENABLE(gui,
     AS_HELP_STRING([--disable-gui],
         [Disable use of X11 or Wayland to reduce dependencies (e.g. for 
building LibreOfficeKit).]),
@@ -1977,7 +1985,7 @@ AC_ARG_ENABLE(xmlhelp,
 
 AC_ARG_ENABLE(customtarget-components,
     AS_HELP_STRING([--enable-customtarget-components],
-        [This is WIP and probably just works together with 
--enable-wasm-strip.]))
+        [Generates the static UNO object constructor mapping from the build.]))
 
 dnl ===================================================================
 dnl Optional Packages (--with/without-)
@@ -2943,15 +2951,6 @@ if test $_os != iOS -a $_os != Android -a $_os != 
Emscripten -a "$enable_fuzzers
     AC_DEFINE(HAVE_FEATURE_MULTIUSER_ENVIRONMENT)
 fi
 
-ENABLE_CUSTOMTARGET_COMPONENTS=
-if test "$enable_customtarget_components" = yes; then
-    ENABLE_CUSTOMTARGET_COMPONENTS=TRUE
-    if test -n "$with_locales" -a "$with_locales" != en -a "$with_locales" != 
ALL; then
-        AC_MSG_ERROR([Currently just --with-locales=all or en is supported 
with --enable-customtarget-components])
-    fi
-fi
-AC_SUBST(ENABLE_CUSTOMTARGET_COMPONENTS)
-
 # Whether to build "avmedia" functionality or not.
 
 if test "$enable_avmedia" = yes; then
@@ -3001,9 +3000,26 @@ if test "$enable_dynamic_loading" = yes; then
     BUILD_TYPE="$BUILD_TYPE DYNLOADING"
 else
     DISABLE_DYNLOADING='TRUE'
+    if test $_os != iOS -a $_os != Android; then
+        enable_database_connectivity=no
+        enable_nss=no
+        enable_odk=no
+        enable_python=no
+        enable_skia=no
+        with_java=no
+    fi
 fi
 AC_SUBST(DISABLE_DYNLOADING)
 
+ENABLE_CUSTOMTARGET_COMPONENTS=
+if test "$enable_customtarget_components" = yes -a "$DISABLE_DYNLOADING" = 
TRUE; then
+    ENABLE_CUSTOMTARGET_COMPONENTS=TRUE
+    if test -n "$with_locales" -a "$with_locales" != en -a "$with_locales" != 
ALL; then
+        AC_MSG_ERROR([Currently just --with-locales=all or en is supported 
with --enable-customtarget-components])
+    fi
+fi
+AC_SUBST(ENABLE_CUSTOMTARGET_COMPONENTS)
+
 if test "$enable_extensions" = yes; then
     BUILD_TYPE="$BUILD_TYPE EXTENSIONS"
     AC_DEFINE(HAVE_FEATURE_EXTENSIONS)
@@ -5255,6 +5271,10 @@ if test "$with_x" = "no"; then
     USING_X11=
 fi
 
+if test -z "$USING_X11" -a "$DISABLE_DYNLOADING" = TRUE -a "$enable_gen" = 
"yes"; then
+    AC_MSG_ERROR([Can't select gen VCL plugin, if --without-x is used!])
+fi
+
 if test "$using_x11" = yes; then
     if test "$USING_X11" = TRUE; then
         AC_DEFINE(USING_X11)
@@ -5550,6 +5570,7 @@ if test "$cross_compiling" = "yes"; then
         --disable-postgresql-sdbc \
         --disable-skia \
         --disable-xmlhelp \
+        --enable-dynamic-loading \
         --enable-icecream="$enable_icecream" \
         --without-doxygen \
         --without-webdav \
@@ -11487,20 +11508,14 @@ dnl 
===================================================================
 dnl Show which vclplugs will be built.
 dnl ===================================================================
 R=""
-if test "$USING_X11" != TRUE; then
-    enable_gtk3=no
-fi
 
+libo_ENABLE_VCLPLUG([gen])
 libo_ENABLE_VCLPLUG([gtk3])
 libo_ENABLE_VCLPLUG([gtk3_kde5])
 libo_ENABLE_VCLPLUG([gtk4])
+libo_ENABLE_VCLPLUG([kf5])
 libo_ENABLE_VCLPLUG([qt5])
 libo_ENABLE_VCLPLUG([qt6])
-libo_ENABLE_VCLPLUG([kf5])
-
-if test "x$USING_X11" = "xyes"; then
-    R="$R gen"
-fi
 
 if test "$_os" = "WINNT"; then
     R="$R win"
@@ -11520,6 +11535,10 @@ AC_MSG_NOTICE([VCLplugs to be 
built:${build_vcl_plugins}])
 VCL_PLUGIN_INFO=$R
 AC_SUBST([VCL_PLUGIN_INFO])
 
+if test "$DISABLE_DYNLOADING" = TRUE -a -z "$DISABLE_GUI" -a \( -z "$R" -o 
$(echo "$R" | wc -w) -ne 1 \); then
+    AC_MSG_ERROR([Can't build --disable-dynamic-loading without --disable-gui 
and a single VCL plugin"])
+fi
+
 dnl ===================================================================
 dnl Check for GTK libraries
 dnl ===================================================================
diff --git a/connectivity/Library_postgresql-sdbc-impl.mk 
b/connectivity/Library_postgresql-sdbc-impl.mk
index 8aa02ae169d5..497f5b742ef4 100644
--- a/connectivity/Library_postgresql-sdbc-impl.mk
+++ b/connectivity/Library_postgresql-sdbc-impl.mk
@@ -45,13 +45,15 @@ endif
 $(eval $(call gb_Library_use_externals,postgresql-sdbc-impl,\
        boost_headers \
        postgresql \
-       $(if $(filter-out MSC,$(COM)), \
-               openssl \
-               $(if $(ENABLE_LDAP),openldap) \
-               nss3 \
-               plc4 \
-               ssl3 \
-       ) \
+    $(if $(filter-out MSC,$(COM)), \
+        $(if $(ENABLE_OPENSSL),openssl) \
+        $(if $(ENABLE_LDAP), \
+            openldap \
+            nss3 \
+            plc4 \
+            ssl3 \
+        ) \
+    ) \
 ))
 
 ifeq ($(SYSTEM_POSTGRESQL),)
diff --git a/desktop/Module_desktop.mk b/desktop/Module_desktop.mk
index 15b2ad358d64..aca0273dc972 100644
--- a/desktop/Module_desktop.mk
+++ b/desktop/Module_desktop.mk
@@ -60,7 +60,7 @@ $(eval $(call gb_Module_add_targets,desktop,\
     Package_soffice_sh \
 ))
 endif
-endif
+endif # DESKTOP
 
 ifeq ($(OS),WNT)
 
diff --git a/extensions/Module_extensions.mk b/extensions/Module_extensions.mk
index c28f97b9cbd8..327314fb4250 100644
--- a/extensions/Module_extensions.mk
+++ b/extensions/Module_extensions.mk
@@ -13,7 +13,7 @@ $(eval $(call gb_Module_add_l10n_targets,extensions,\
        AllLangMoTarget_pcr \
 ))
 
-ifneq ($(filter-out iOS ANDROID,$(OS)),)
+ifeq (,$(DISABLE_DYNLOADING))
 $(eval $(call gb_Module_add_targets,extensions,\
        Library_abp \
        Library_scn \
diff --git a/libreofficekit/Module_libreofficekit.mk 
b/libreofficekit/Module_libreofficekit.mk
index 351f89a33e48..bf75f359e13e 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -28,7 +28,7 @@ $(eval $(call gb_Module_add_targets,libreofficekit,\
 endif # ($(ENABLE_GTK3),)
 
 $(eval $(call gb_Module_add_targets,libreofficekit,\
-    Executable_tilebench \
+    $(if $(DISABLE_DYNLOADING),,Executable_tilebench) \
     Package_selectionhandles \
     UIConfig_libreofficekit \
 ))
diff --git a/sd/source/core/typemap.cxx b/sd/source/core/typemap.cxx
index 046be764ba19..4378ad2d2f84 100644
--- a/sd/source/core/typemap.cxx
+++ b/sd/source/core/typemap.cxx
@@ -95,7 +95,49 @@
 #include <svx/galleryitem.hxx>
 #include <svx/sdangitm.hxx>
 
+#ifdef DISABLE_DYNLOADING
+/* Avoid clash with the ones from svx/source/form/typemap.cxx */
+#define aSfxBoolItem_Impl sd_source_core_typemap_aSfxBoolItem_Impl
+#define aSfxInt32Item_Impl sd_source_core_typemap_aSfxInt32Item_Impl
+#define aSfxStringItem_Impl sd_source_core_typemap_aSfxStringItem_Impl
+#define aSfxUInt16Item_Impl sd_source_core_typemap_aSfxUInt16Item_Impl
+#define aSfxUInt32Item_Impl sd_source_core_typemap_aSfxUInt32Item_Impl
+#define aSfxVoidItem_Impl sd_source_core_typemap_aSfxVoidItem_Impl
+#define aSvxClipboardFormatItem_Impl 
sd_source_core_typemap_aSvxClipboardFormatItem_Impl
+#define aSvxColorItem_Impl sd_source_core_typemap_aSvxColorItem_Impl
+#define aSvxContourItem_Impl sd_source_core_typemap_aSvxContourItem_Impl
+#define aSvxCrossedOutItem_Impl sd_source_core_typemap_aSvxCrossedOutItem_Impl
+#define aSvxFontHeightItem_Impl sd_source_core_typemap_aSvxFontHeightItem_Impl
+#define aSvxFontItem_Impl sd_source_core_typemap_aSvxFontItem_Impl
+#define aSvxLanguageItem_Impl sd_source_core_typemap_aSvxLanguageItem_Impl
+#define aSvxPostureItem_Impl sd_source_core_typemap_aSvxPostureItem_Impl
+#define aSvxShadowedItem_Impl sd_source_core_typemap_aSvxShadowedItem_Impl
+#define aSvxUnderlineItem_Impl sd_source_core_typemap_aSvxUnderlineItem_Impl
+#define aSvxOverlineItem_Impl sd_source_core_typemap_aSvxOverlineItem_Impl
+#define aSvxWeightItem_Impl sd_source_core_typemap_aSvxWeightItem_Impl
+#endif
+
 #define SFX_TYPEMAP
 #include <sdslots.hxx>
 
+#ifdef DISABLE_DYNLOADING
+#undef aSfxBoolItem_Impl
+#undef aSfxInt32Item_Impl
+#undef aSfxStringItem_Impl
+#undef aSfxUInt16Item_Impl
+#undef aSfxUInt32Item_Impl
+#undef aSfxVoidItem_Impl
+#undef aSvxClipboardFormatItem_Impl
+#undef aSvxColorItem_Impl
+#undef aSvxContourItem_Impl
+#undef aSvxCrossedOutItem_Impl
+#undef aSvxFontHeightItem_Impl
+#undef aSvxFontItem_Impl
+#undef aSvxLanguageItem_Impl
+#undef aSvxPostureItem_Impl
+#undef aSvxShadowedItem_Impl
+#undef aSvxTextLineItem_Impl
+#undef aSvxWeightItem_Impl
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index ce60b462ecee..b7cada89523b 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -36,6 +36,13 @@
 #  gb_LinkTarget_INCLUDE
 #  gb_YaccTarget__command(grammar-file, stem-for-message, source-target, 
include-target)
 
+# Same happens for the gb_LinkTarget_add_libs calls from 
RepositoryExternal.mk. But we have no real
+# way to separate for gbuild internal and external gb_LinkTarget_add_libs 
calls.
+# So this flags these call parameters with an @ postfix. But now these must be 
filtered out, so this
+# defines that filter, just in case we need to change it because it conflicts 
with some parameters.
+# FYI: on Windows, gb_Library_use_system_win32_libs also calls 
gb_LinkTarget_add_libs; easy to miss.
+gb_LinkTarget__syslib = %@
+
 # Detect whether symbols should be enabled for the given gbuild target.
 # enable if: no "-TARGET" defined AND [module is enabled OR "TARGET" defined]
 gb_LinkTarget__symbols_enabled = \
@@ -769,7 +776,7 @@ $(WORKDIR)/Clean/LinkTarget/% :
 # cat the deps of all objects in one file, then we need only open that one file
 # call gb_LinkTarget__command_dep,dep_target,linktargetname
 define gb_LinkTarget__command_dep
-$(call gb_Output_announce,LNK:$(2),$(true),DEP,1)
+$(call gb_Output_announce,LNK:$(2).d,$(true),DEP,1)
        $(call gb_Trace_StartRange,LNK:$(2),DEP)
 $(call gb_Helper_abbreviate_dirs,\
        mkdir -p $(dir $(1)) && \
@@ -838,6 +845,11 @@ $(call gb_LinkTarget_get_target,$(1)) : $(call 
gb_LinkTarget_get_headers_target,
 
 endef
 
+define gb_LinkTarget__add_linked_libs
+$(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $(2)
+
+endef
+
 # it's not possible to use a pattern rule for files in INSTDIR because
 # it would inevitably conflict with the pattern rule for Package
 # (especially since external libraries are delivered via Package)
@@ -860,7 +872,7 @@ endef
 ifeq ($(gb_FULLDEPS),$(true))
 $(call gb_LinkTarget_get_dep_target,%) : $(call 
gb_Executable_get_runtime_dependencies,concat-deps)
        $(call gb_LinkTarget__command_dep,$@,$*)
-endif
+endif # gb_FULLDEPS
 
 # Ok, this is some dark voodoo: When declaring a linktarget with
 # gb_LinkTarget_LinkTarget we set SELF in the headertarget to name of the
@@ -1029,7 +1041,7 @@ $(call gb_LinkTarget_get_dep_target,$(1)) : 
GENOBJCXXOBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : GENNASMOBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXCLROBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : YACCOBJECTS :=
-endif
+endif # gb_FULLDEPS
 
 gb_LinkTarget_CXX_SUFFIX_$(call 
gb_LinkTarget__get_workdir_linktargetname,$(1)) := cxx
 
@@ -1038,7 +1050,7 @@ $(if $(findstring $(INSTDIR),$(1)),$(call 
gb_LinkTarget__make_installed_rule,$(1
 
 $(call gb_PrecompiledHeader_generate_timestamp_rule,$(2))
 
-endef
+endef # gb_LinkTarget_LinkTarget
 
 # call gb_LinkTarget_set_soversion_script,linktarget,soversionscript
 define gb_LinkTarget_set_soversion_script
@@ -1124,6 +1136,11 @@ define gb_LinkTarget_add_libs
 $(call gb_LinkTarget_get_target,$(1)) : T_LIBS += $(2)
 $(if $(call gb_LinkTarget__is_merged,$(1)),\
   $(call gb_Library_get_linktarget_target,merged) : T_LIBS += $(2))
+ifeq ($(ENABLE_CUSTOMTARGET_COMPONENTS),TRUE)
+$(if $(gb_DEBUG_STATIC),$$(info $$(call 
gb_LinkTarget__get_all_libraries_var,$(1)) += $(filter-out $(call 
gb_LinkTarget__get_all_libraries,$(1)),$(patsubst 
%,$(gb_LinkTarget__syslib),$(2)))))
+$$(eval $$(call gb_LinkTarget__get_all_libraries_var,$(1)) += $(filter-out 
$(call gb_LinkTarget__get_all_libraries,$(1)),$(patsubst 
%,$(gb_LinkTarget__syslib),$(2))))
+$(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $(filter-out $(call 
gb_LinkTarget__get_all_libraries,$(1)),$(patsubst 
%,$(gb_LinkTarget__syslib),$(2)))
+endif
 
 endef
 
@@ -1210,6 +1227,38 @@ $(call gb_Library_get_target,$(1)) :| $(call 
gb_Library_get_headers_target,$(1))
 
 endef
 
+define gb_LinkTarget__generate_all_x_accessors
+gb_LinkTarget__get_all_$(1)_var = $$(call 
gb_LinkTarget__get_workdir_linktargetname,$$(1))<>ALL_$(2)
+gb_LinkTarget__get_all_$(1) = $$($$(call 
gb_LinkTarget__get_all_$(1)_var,$$(1)))
+gb_Library__get_all_$(1) = $$($$(call gb_LinkTarget__get_all_$(1)_var,$$(call 
gb_Library_get_linktarget,$$(1))))
+gb_Executable__get_all_$(1) = $$($$(call 
gb_LinkTarget__get_all_$(1)_var,$$(call gb_Executable_get_linktarget,$$(1))))
+gb_ExternalProject__get_all_$(1) = $$($$(call 
gb_LinkTarget__get_all_$(1)_var,$$(call 
gb_ExternalProject__get_workdir_linktargetname,$$(1))))
+gb_CppunitTest__get_all_$(1) = $$($$(call 
gb_LinkTarget__get_all_$(1)_var,$$(call 
gb_CppunitTest__get_workdir_linktargetname,$$(1))))
+
+endef
+
+$(eval $(call gb_LinkTarget__generate_all_x_accessors,libraries,LIBRARIES))
+gb_LinkTarget__filter_lo_libraries = $(filter-out 
$(gb_LinkTarget__syslib),$(1))
+gb_LinkTarget__get_all_lo_libraries = $(call 
gb_LinkTarget__filter_lo_libraries,$(call 
gb_LinkTarget__get_all_libraries,$(1)))
+gb_LinkTarget__filter_sys_libraries = $(filter $(gb_LinkTarget__syslib),$(1))
+gb_LinkTarget__get_all_sys_libraries = $(call 
gb_LinkTarget__filter_sys_libraries,$(call 
gb_LinkTarget__get_all_libraries,$(1)))
+$(eval $(call gb_LinkTarget__generate_all_x_accessors,externals,EXTERNALS))
+$(eval $(call gb_LinkTarget__generate_all_x_accessors,statics,STATICS))
+
+# call gb_LinkTarget__register_type,type,linktarget,type list
+define gb_LinkTarget__register_type
+ifeq ($(ENABLE_CUSTOMTARGET_COMPONENTS),TRUE)
+ifeq (,$(DISABLE_DYNLOADING))
+$$(error ENABLE_CUSTOMTARGET_COMPONENTS just works with DISABLE_DYNLOADING)
+endif
+$(foreach type,$(3),$(if $(filter $(type),$(call 
gb_LinkTarget__get_all_$(1),$(2))),, \
+    $(if $(gb_DEBUG_STATIC),$$(info $(call 
gb_LinkTarget__get_all_$(1)_var,$(2)) += $(type))) \
+    $$(eval $(call gb_LinkTarget__get_all_$(1)_var,$(2)) += $(type)) \
+))
+endif
+
+endef
+
 # call 
gb_LinkTarget__use_libraries,linktarget,requestedlibs,actuallibs,linktargetmakefilename
 define gb_LinkTarget__use_libraries
 
@@ -1227,23 +1276,29 @@ ifeq (,$(DISABLE_DYNLOADING))
 # depend on the exports of the library, not on the library itself
 # for faster incremental builds when the ABI is unchanged.
 # export files are created from the library, so this also ensures the library 
exists.
-$(call gb_LinkTarget_get_target,$(1)) : \
-       $(foreach lib,$(3),$(call gb_Library_get_exports_target,$(lib)))
+$(foreach lib,$(call gb_LinkTarget__filter_lo_libraries,$(3)),$(if $(filter 
$(lib),$(gb_Library_KNOWNLIBS)), \
+    $(eval $(call gb_LinkTarget_get_target,$(1)) : $(call 
gb_Library_get_exports_target,$(lib))) \
+))
 
 else # DISABLE_DYNLOADING
 # depend on the now-static libraries themself, but only if the target actually 
links to it
 ifneq (,$(call gb_LinkTarget_does_real_link,$(1)))
-$(foreach lib,$(3),$(if $(filter $(lib),$(gb_Library_KNOWNLIBS)), \
-    $(eval $(call gb_LinkTarget_get_target,$(1)) : $(call 
gb_Library_get_linktarget_target,$(lib))) \
-))
+$(call gb_LinkTarget_get_target,$(1)) : T_LIBS += $(call 
gb_LinkTarget__filter_sys_libraries,$(3))
+$(if $(filter-out Library,gb_LinkTarget__get_workdir_linktargetclass,$(1)), \
+    $(foreach lib,$(call gb_LinkTarget__filter_lo_libraries,$(3)),$(if 
$(filter $(lib),$(gb_Library_KNOWNLIBS)), \
+        $(eval $(call gb_LinkTarget_get_target,$(1)) : $(call 
gb_Library_get_linktarget_target,$(lib))) \
+    )))
 endif
 endif # DISABLE_DYNLOADING
 
-$(call gb_LinkTarget_get_headers_target,$(1)) : \
-       $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
-$(foreach lib,$(2),$(call gb_LinkTarget__lib_dummy_depend,$(lib)))
+$(call gb_LinkTarget__register_type,libraries,$(1),$(3))
 
-endef
+$(foreach lib,$(call gb_LinkTarget__filter_lo_libraries,$(2)),$(if $(filter 
$(lib),$(gb_Library_KNOWNLIBS)), \
+    $(eval $(call gb_LinkTarget_get_headers_target,$(1)) : $(call 
gb_Library_get_headers_target,$(lib))) \
+    $(call gb_LinkTarget__lib_dummy_depend,$(lib)) \
+))
+
+endef # gb_LinkTarget__use_libraries
 
 # libraries which are merged but need to be built for gb_BUILD_HELPER_TOOLS
 gb_BUILD_HELPER_LIBS := $(foreach lib, \
@@ -1287,9 +1342,9 @@ endef
 
 # call gb_LinkTarget_use_libraries,linktarget,libs
 define gb_LinkTarget_use_libraries
-ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
+ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS) $(gb_LinkTarget__syslib),$(2)))
 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort 
$(gb_Library_KNOWNLIBS)),ALL))
-$$(eval $$(call gb_Output_error,Cannot link against library/libraries 
'$$(filter-out $(gb_Library_KNOWNLIBS),$(2))'. Libraries must be registered in 
Repository.mk or RepositoryExternal.mk))
+$$(eval $$(call gb_Output_error,Cannot link against library/libraries 
'$$(filter-out $(gb_Library_KNOWNLIBS) $(gb_LinkTarget__syslib),$(2))'. 
Libraries must be registered in Repository.mk or RepositoryExternal.mk))
 endif
 ifneq (,$$(filter $(2),$(gb_Library_KNOWNPLUGINS)))
 ifneq (,$$(filter $(1),$$(foreach plugin,$(gb_Library_KNOWNPLUGINS),$(call 
gb_Library__get_workdir_linktargetname,$(plugin)))))
@@ -1333,11 +1388,14 @@ ifneq (,$(call gb_LinkTarget_does_real_link,$(1)))
 $(foreach lib,$(2), \
     $$(eval $(call gb_LinkTarget_get_target,$(1)): $(call 
gb_StaticLibrary_get_linktarget_target,$(lib))))
 endif
+
+$(call gb_LinkTarget__register_type,statics,$(1),$(2))
+
 $(call gb_LinkTarget_get_headers_target,$(1)) : \
        $(foreach lib,$(2),$(call gb_StaticLibrary_get_headers_target,$(lib)))
 $(foreach lib,$(2),$(call gb_LinkTarget__static_lib_dummy_depend,$(lib)))
 
-endef
+endef # gb_LinkTarget_use_static_libraries
 
 # call 
gb_LinkTarget_add_cobject,linktarget,sourcefile,cflags,linktargetmakefilename
 define gb_LinkTarget_add_cobject
@@ -2038,6 +2096,9 @@ $(if $(filter undefined,$(origin 
gb_LinkTarget__use_$(2))),\
         $(call gb_LinkTarget__use_$(2),$(call 
gb_Library_get_linktarget,merged)))) \
     $(call gb_LinkTarget__use_$(2),$(1)) \
 )
+
+$(call gb_LinkTarget__register_type,externals,$(1),$(2))
+
 endef
 
 # $(call gb_LinkTarget_use_externals,library,externals)
@@ -2156,6 +2217,7 @@ ifeq ($(call gb_LinkTarget__is_build_tool,$(1)),$(true))
 $$(eval $$(call gb_Output_error,Plugin support for build tools not 
implemented))
 endif
 
+$(if $(filter $(2),$(gb_Library_KNOWNLOADERS)),,gb_Library_KNOWNLOADERS += 
$(2))
 $(if $(3),,$(call gb_LinkTarget_use_libraries,$(1),$(2),,$(4)))
 
 endef
diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk
index 2dd50de62b94..3e4b044d86b2 100644
--- a/solenv/gbuild/TargetLocations.mk
+++ b/solenv/gbuild/TargetLocations.mk
@@ -67,6 +67,7 @@ gb_GenCxxObject_get_dwo_target = 
$(WORKDIR)/GenCxxObject/$(1).dwo
 gb_GenNasmObject_get_target = $(WORKDIR)/GenNasmObject/$(1).o
 gb_GenNasmObject_get_dwo_target = $(WORKDIR)/GenNasmObject/$(1).dwo
 gb_Executable_get_headers_target = $(WORKDIR)/Headers/Executable/$(1)
+gb_Executable_get_linktargetfile = $(call gb_LinkTarget_get_target,$(call 
gb_Executable_get_linktarget,$1))
 gb_Executable_get_runtime_target = $(WORKDIR_FOR_BUILD)/Executable/$(1).run
 gb_Extension_get_target = $(WORKDIR)/Extension/$(1).oxt
 gb_Extension_get_rootdir = $(WORKDIR)/Extension/$(1)/root
@@ -406,6 +407,8 @@ $(call 
gb_Executable__get_workdir_linktargetname,$(1))<>$(call gb_Executable_get
 endef
 gb_Executable_get_linktarget_target = $(call gb_LinkTarget_get_target,$(call 
gb_Executable_get_linktarget,$(1)))
 
+gb_ExternalProject__get_workdir_linktargetname = ExternalProject/$(1)
+
 define gb_Library__get_workdir_linktargetname
 Library/$(call gb_Library_get_filename,$(1))
 endef
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index 5f8dacfae841..98deb69c1a13 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -287,7 +287,6 @@ gb_TEST_ENV_VARS += 
SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION=1
 ifeq (,$(SAL_USE_VCLPLUGIN))
 gb_TEST_ENV_VARS += SAL_USE_VCLPLUGIN=svp
 endif
-gb_TEST_ENV_VARS += UNO_HOME=file://$$I/program
 
 # This is used to detect whether LibreOffice is being built (as opposed to 
building
 # 3rd-party code). Used for tag deprecation for API we want to
diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk
index 684ab7695f77..b3efff76f892 100644
--- a/solenv/gbuild/platform/unxgcc.mk
+++ b/solenv/gbuild/platform/unxgcc.mk
@@ -65,10 +65,13 @@ gb_LinkTarget_LDFLAGS += \
        -Wl,--sysroot=$(SYSBASE)
 endif
 
+ifeq (,$(DISABLE_DYNLOADING))
 gb_LinkTarget_LDFLAGS += \
        -Wl,-rpath-link,$(SYSBASE)/lib:$(SYSBASE)/usr/lib \
        -Wl,-z,combreloc \
 
+endif
+
 ifeq ($(HAVE_LD_HASH_STYLE),TRUE)
 gb_LinkTarget_LDFLAGS += \
        -Wl,--hash-style=$(WITH_LINKER_HASH_STYLE) \
@@ -112,7 +115,8 @@ $(if $(strip $(and \
     )),$(true))
 endef
 
-gb_LinkTarget__NeedsCxxLinker = $(if 
$(CXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS)$(filter-out 
XTRUE,X$(ENABLE_RUNTIME_OPTIMIZATIONS)),$(true))
+# In theory would would need to track, if any of the linked objects is C++ 
code, so for the static build we assume yes :-(
+gb_LinkTarget__NeedsCxxLinker = $(if 
$(CXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS)$(filter-out 
XTRUE,X$(ENABLE_RUNTIME_OPTIMIZATIONS)$(DISABLE_DYNLOADING)),$(true))
 
 # note that `cat $(extraobjectlist)` is needed to build with older gcc 
versions, e.g. 4.1.2 on SLED10
 # we want to use @$(extraobjectlist) in the long run
@@ -146,7 +150,7 @@ $(call gb_Helper_abbreviate_dirs,\
                    -Wl$(COMMA)--start-group \
                    $(patsubst lib%.a,-l%,$(patsubst lib%.so,-l%,$(patsubst 
%.$(gb_Library_UDK_MAJORVER),%,$(foreach lib,$(LINKED_LIBS),$(call 
gb_Library_get_filename,$(lib)))))) \
                    $(foreach lib,$(LINKED_STATIC_LIBS),$(call 
gb_StaticLibrary_get_target,$(lib))) \
-                   $(T_LIBS) \
+                   $(patsubst $(gb_LinkTarget__syslib),%,$(T_LIBS)) \
                    $(if $(call 
gb_LinkTarget__NeedsCxxLinker),$(T_STDLIBS_CXX)) \
                    -Wl$(COMMA)--end-group \
                , \
diff --git a/solenv/gbuild/static.mk b/solenv/gbuild/static.mk
new file mode 100644
index 000000000000..346a18991134
--- /dev/null
+++ b/solenv/gbuild/static.mk
@@ -0,0 +1,207 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+# "spezialgelagerter Sonderfall" :-(
+#
+# *******************************************
+# Use gb_DEBUG_STATIC=t to dump various debug info for the static build 
preparation!
+# Use gb_DEBUG_STATIC=a to abort / error after the dump
+# *******************************************
+#
+# "Generic" comment from the author:
+# My thought was: the dependency info is already there. Can't be too hard to 
use it for
+# correct static linkage... well it took more then two weeks to hopefully 
identify all
+# problems / edge cases. Now I can appreciate the usage bin/lo-all-static-libs 
even more.
+#
+# This code moved a few times to the various gbuild / make phases: Makefile / 
module
+# setup (in use_(libraries|externals)), post parsing (like now), make 
"dependency" tree
+# processing. It currently looks like this is the only working option.
+#
+# For static linking, we must collect all depending libraries, externals and 
statics to
+# be available at link time. And Libraries and externals can use each other. 
This could
+# be done "in-line", while make processes the dependency tree and would have 
the correct
+# order, so no separate tree-walking would be needed.
+# It can't be done while reading / processing the modules, as this happens in 
no order, so
+# depending modules will be missing.
+#
+# Then there is the (gbuild new) concept of plugin libraries. These depend on 
some loader
+# libraries, like vcl and vclplug_* or gie. For a shared library build, these 
plugins are
+# just dlopen'ed, but for a static build, any linked binary must also link the 
plugins, which
+# turns plugins + loaders into a dependency cycle. The implemented solution is 
to just add
+# plugins to executables, if these depend on a loader library. This results in 
the additional
+# rule: nothing non-plugin is allowed to depend on a plugins (see 
gb_Library_set_plugin_for).
+#
+# And we can't add these dependencies while make is already processing the 
Executables,
+# because these contain additional eval'ed targets, which we can't create in 
make recipes.
+# This is especially true for externals (see gb_LinkTarget__use_* in 
RepositoryExternal.mk).
+# We also can't add all plugins to all executables, as we have multiple helper
+# binaries, which are needed early and don't depend on plugins.
+#
+# So the only option left seems to be to walk the dependency tree ourself and 
expand all
+# the libraries and externals and then add the plugins to the executables. 
Statics are
+# handled after that, since these won't need extra dependencies not already 
known.
+# It's a bit fragile in theory, as you can add "gbuild-undetectable" 
dependencies to any
+# target in the modules, which would need some manual adjustment, but 
currently that
+# doesn't seem to happen in any breaking way and it works to link multiple 
Executable
+# with large and small expanded dependency lists.
+#
+# Then there is the special static "components" library, which simply depends 
on all build
+# components. In theory these could be limited per-module (Writer, Calc, 
etc.), but currently
+# this is not implemented and instead solenv/bin/native-code.py is used, so 
actually
+# everything is build and "cleaned up" at link time, which is especially 
expensive for WASM.
+# That library is currently just used for Emscripten, but could be used 
generally for
+# static builds.
+#
+# There is already a lot of $(info ...) protected by the already mentioned 
$(gb_DEBUG_STATIC).
+
+ifeq ($(gb_FULLDEPS),$(true))
+ifeq (,$(gb_PARTIAL_BUILD))
+
+$(foreach lib,$(gb_Library_KNOWNLIBS),$(if $(call 
gb_Library__get_component,$(lib)), \
+    $(eval $(call gb_Library_use_libraries,components,$(lib)))))
+
+define gb_LinkTarget__add_x_template
+
+# call gb_LinkTarget__add_$(1),linktarget,objects
+define gb_LinkTarget__add_$(1)
+$$(foreach item,$$(2),$$(if $$(filter $$(item),GBUILD_TOUCHED $$(call 
gb_LinkTarget__get_all_$(1),$$(1))),,
+    $$(if $(gb_DEBUG_STATIC),$$(info $$(call 
gb_LinkTarget__get_all_$(1)_var,$$(call 
gb_LinkTarget__get_workdir_linktargetname,$$(1))) += $$(item)))
+    $$(eval $$(call gb_LinkTarget__get_all_$(1)_var,$$(call 
gb_LinkTarget__get_workdir_linktargetname,$$(1))) += $$(item))
+))
+endef
+
+endef # gb_LinkTarget__add_x_template
+
+ifneq (,$(gb_DEBUG_STATIC))
+$(info $(call gb_LinkTarget__add_x_template,libraries))
+$(info $(call gb_LinkTarget__add_x_template,externals))
+$(info $(call gb_LinkTarget__add_x_template,statics))
+endif
+$(eval $(call gb_LinkTarget__add_x_template,libraries))
+$(eval $(call gb_LinkTarget__add_x_template,externals))
+$(eval $(call gb_LinkTarget__add_x_template,statics))
+
+# call gb_LinkTarget__add_linktargets,linktarget,class,func,objects
+define gb_LinkTarget__add_linktargets
+$(call gb_LinkTarget__add_$(3),$(1),$(4))
+$(foreach item,$(foreach mapped,$(4),$(call 
gb_$(2)__get_workdir_linktargetname,$(mapped))),
+    $(call gb_LinkTarget__add_libraries,$(1),$(call 
gb_LinkTarget__get_all_libraries,$(item)))
+    $(call gb_LinkTarget__add_externals,$(1),$(call 
gb_LinkTarget__get_all_externals,$(item)))
+    $(call gb_LinkTarget__add_statics,$(1),$(call 
gb_LinkTarget__get_all_statics,$(item)))
+)
+endef
+
+# contains the list of all touched workdir_linktargetname(s)
+gb_LinkTarget__ALL_TOUCHED =
+
+define gb_LinkTarget__add_touch
+$(eval $(call gb_LinkTarget__get_all_libraries_var,$(call 
gb_LinkTarget__get_workdir_linktargetname,$(1))) += GBUILD_TOUCHED)
+$(eval $(call gb_LinkTarget__get_all_externals_var,$(call 
gb_LinkTarget__get_workdir_linktargetname,$(1))) += GBUILD_TOUCHED)
+$(eval $(call gb_LinkTarget__get_all_statics_var,$(call 
gb_LinkTarget__get_workdir_linktargetname,$(1))) += GBUILD_TOUCHED)
+gb_LinkTarget__ALL_TOUCHED += $(1)
+
+endef
+
+define gb_LinkTarget__remove_touch
+$(call gb_LinkTarget__get_all_libraries_var,$(1)) := $(filter-out 
GBUILD_TOUCHED,$(call gb_LinkTarget__get_all_libraries,$(1)))
+$(call gb_LinkTarget__get_all_externals_var,$(1)) := $(filter-out 
GBUILD_TOUCHED,$(call gb_LinkTarget__get_all_externals,$(1)))
+$(call gb_LinkTarget__get_all_statics_var,$(1)) := $(filter-out 
GBUILD_TOUCHED,$(call gb_LinkTarget__get_all_statics,$(1)))
+
+endef
+
+# call gb_LinkTarget__fill_all_deps.linktargetname
+define gb_LinkTarget__fill_all_deps
+$(if $(filter GBUILD_TOUCHED,$(call 
gb_LinkTarget__get_all_lo_libraries,$(1))),,
+
+    # LO has quite a few dependency loops, so touch first to break them
+    $(call gb_LinkTarget__add_touch,$(1))
+
+    # Add lo libraries
+    $(foreach item,$(filter-out GBUILD_TOUCHED,$(call 
gb_LinkTarget__get_all_lo_libraries,$(1))),
+        $(call gb_LinkTarget__fill_all_deps,$(call 
gb_Library_get_linktarget,$(item)))
+        $(call gb_LinkTarget__add_libraries,$(1),$(call 
gb_Library__get_all_libraries,$(item)))
+        $(call gb_LinkTarget__add_externals,$(1),$(call 
gb_Library__get_all_externals,$(item)))
+        $(call gb_LinkTarget__add_statics,$(1),$(call 
gb_Library__get_all_statics,$(item)))
+    )
+
+    # Add (win32) system libraries
+    $(call gb_LinkTarget__add_libraries,$(1),$(call 
gb_LinkTarget__get_all_sys_libraries,$(1)))
+
+    # Add externals
+    $(foreach item,$(filter-out GBUILD_TOUCHED,$(call 
gb_LinkTarget__get_all_externals,$(1))),
+        $(call gb_LinkTarget__fill_all_deps,$(call 
gb_ExternalProject__get_workdir_linktargetname,$(item)))
+        $(call gb_LinkTarget__add_libraries,$(1),$(call 
gb_ExternalProject__get_all_libraries,$(item)))
+        $(call gb_LinkTarget__add_externals,$(1),$(call 
gb_ExternalProject__get_all_externals,$(item)))
+        $(call gb_LinkTarget__add_statics,$(1),$(call 
gb_ExternalProject__get_all_statics,$(item)))
+    )
+
+    # Add statics
+    $(foreach item,$(filter-out GBUILD_TOUCHED,$(call 
gb_LinkTarget__get_all_statics,$(1))),
+        $(call gb_LinkTarget__fill_all_deps,$(call 
gb_StaticLibrary_get_linktarget,$(item)))
+        $(call gb_LinkTarget__add_libraries,$(1),$(call 
gb_StaticLibrary__get_all_libraries,$(item)))
+        $(call gb_LinkTarget__add_externals,$(1),$(call 
gb_StaticLibrary__get_all_externals,$(item)))
+        $(call gb_LinkTarget__add_statics,$(1),$(call 
gb_StaticLibrary__get_all_statics,$(item)))
+    )
+
+    $(if $(gb_DEBUG_STATIC),
+        $(info gb_LinkTarget__fill_all_deps libraries for $(call 
gb_LinkTarget__get_workdir_linktargetname,$(1)) out: $(call 
gb_LinkTarget__get_all_libraries,$(1)))
+        $(info gb_LinkTarget__fill_all_deps externals for $(call 
gb_LinkTarget__get_workdir_linktargetname,$(1)) out: $(call 
gb_LinkTarget__get_all_externals,$(1)))
+        $(info gb_LinkTarget__fill_all_deps statics   for $(call 
gb_LinkTarget__get_workdir_linktargetname,$(1)) out: $(call 
gb_LinkTarget__get_all_statics,$(1)))
+    )
+)
+
+endef
+
+
+# call gb_LinkTarget__expand_executable,linktarget
+define gb_LinkTarget__expand_executable
+$(call gb_LinkTarget__fill_all_deps,$(1))
+
+# 1. Check if cppuhelper loader for components is requested and add the needed 
plugin dependences
+#    This is a *HACK*, so we don't have to recursively check loader libraries
+# 2. Find any other loader libraries and add the needed plugin dependences
+$(if $(filter cppuhelper,$(filter $(gb_Library_KNOWNLOADERS),$(call 
gb_LinkTarget__get_all_libraries,$(1)))),
+    $(call gb_LinkTarget__add_linktargets,$(1),Library,libraries,$(call 
gb_Library__get_plugins,cppuhelper)))
+$(foreach loader,$(filter $(filter-out 
cppuhelper,$(gb_Library_KNOWNLOADERS)),$(call 
gb_LinkTarget__get_all_libraries,$(1))),
+    $(call gb_LinkTarget__add_linktargets,$(1),Library,libraries,$(call 
gb_Library__get_plugins,$(loader))))
+
+$(if $(filter-out GBUILD_TOUCHED,$(call 
gb_LinkTarget__get_all_libraries,$(1))),
+    $(eval $(call gb_LinkTarget_use_libraries,$(1),$(filter-out 
GBUILD_TOUCHED,$(call gb_LinkTarget__get_all_libraries,$(1))))))
+
+$(if $(filter-out GBUILD_TOUCHED,$(call 
gb_LinkTarget__get_all_externals,$(1))),
+    $(eval $(call gb_LinkTarget_use_externals,$(1),$(filter-out 
GBUILD_TOUCHED,$(call gb_LinkTarget__get_all_externals,$(1))))))
+
+$(if $(filter-out GBUILD_TOUCHED,$(call gb_LinkTarget__get_all_statics,$(1))),
+    $(eval $(call gb_LinkTarget_use_static_libraries,$(1),$(filter-out 
GBUILD_TOUCHED,$(call gb_LinkTarget__get_all_statics,$(1))))))
+
+# Some fixes for the _use_external_project(s) mess
+$(if $(filter icui18n icuuc,$(call gb_LinkTarget__get_all_externals,$(1))),
+    $(call gb_LinkTarget_use_externals,$(1),icudata))
+$(if $(filter orcus-parser,$(call gb_LinkTarget__get_all_externals,$(1))),
+    $(call gb_LinkTarget_use_static_libraries,$(1),boost_filesystem))
+
+$(if $(gb_DEBUG_STATIC),
+    $(info gb_LinkTarget__expand_executable libraries for $(call 
gb_LinkTarget__get_workdir_linktargetname,$(1)): $(call 
gb_LinkTarget__get_all_libraries,$(1)))
+    $(info gb_LinkTarget__expand_executable externals for $(call 
gb_LinkTarget__get_workdir_linktargetname,$(1)): $(call 
gb_LinkTarget__get_all_externals,$(1)))
+    $(info gb_LinkTarget__expand_executable statics   for $(call 
gb_LinkTarget__get_workdir_linktargetname,$(1)): $(call 
gb_LinkTarget__get_all_statics,$(1)))
+)
+
+endef
+
+$(foreach lib,$(gb_Library_KNOWNLIBS), \
+    $(eval $(call gb_LinkTarget__fill_all_deps,$(call 
gb_Library_get_linktarget,$(lib)))))
+$(foreach exec,$(gb_Executable_KNOWN), \
+    $(eval $(call gb_LinkTarget__expand_executable,$(call 
gb_Executable_get_linktarget,$(exec)))))
+$(foreach workdir_linktargetname,$(gb_LinkTarget__ALL_TOUCHED), \
+    $(eval $(call gb_LinkTarget__remove_touch,$(workdir_linktargetname))))
+
+endif # !gb_PARTIAL_BUILD
+endif # gb_FULLDEPS
+
+# vim: set noet sw=4 ts=4:
diff --git a/static/CustomTarget_components.mk 
b/static/CustomTarget_components.mk
new file mode 100644
index 000000000000..510395c9488b
--- /dev/null
+++ b/static/CustomTarget_components.mk
@@ -0,0 +1,37 @@
+# vim: set noet sw=4 ts=4:
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CustomTarget_CustomTarget,static/components))
+
+static_WORKDIR := $(call gb_CustomTarget_get_workdir,static)
+postprocess_WORKDIR := $(call gb_CustomTarget_get_workdir,postprocess)
+
+$(call gb_CustomTarget_get_target,static/components): \
+    $(static_WORKDIR)/component_maps.cxx \
+
+define gb_static_components_create_component_map
+TEMPFILE=`$(gb_MKTEMP)` && \
+$(call gb_Helper_abbreviate_dirs, \
+    $(call gb_ExternalExecutable_get_command,python) \
+        $(SRCDIR)/solenv/bin/native-code.py -c 
$(postprocess_WORKDIR)/services_constructors.list \
+) > $$TEMPFILE && \
+$(call gb_Helper_replace_if_different_and_touch,$${TEMPFILE},$(1))
+
+endef
+
+$(static_WORKDIR)/component_maps.cxx: \
+    $(postprocess_WORKDIR)/services_constructors.list \
+    $(SRCDIR)/solenv/bin/native-code.py \
+    $(call gb_ExternalExecutable_get_dependencies,python) \
+    | $(static_WORKDIR)/.dir
+       $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,2)
+       $(call gb_static_components_create_component_map,$@)
+
+# vim: set noet sw=4:
diff --git a/static/Library_components.mk b/static/Library_components.mk
new file mode 100644
index 000000000000..ae142a30eaee
--- /dev/null
+++ b/static/Library_components.mk
@@ -0,0 +1,18 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 
100 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,components))
+
+$(eval $(call gb_Library_set_plugin_for,components,cppuhelper))
+
+$(eval $(call gb_Library_add_generated_exception_objects,components,\
+    CustomTarget/static/component_maps \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/static/Makefile b/static/Makefile
new file mode 100644
index 000000000000..0c6f47b1790f
--- /dev/null
+++ b/static/Makefile
@@ -0,0 +1,13 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/static/Module_static.mk b/static/Module_static.mk
new file mode 100644
index 000000000000..c6e332b174ca
--- /dev/null
+++ b/static/Module_static.mk
@@ -0,0 +1,20 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$(eval $(call gb_Module_Module,static))
+
+ifeq ($(ENABLE_CUSTOMTARGET_COMPONENTS),TRUE)
+
+$(eval $(call gb_Module_add_targets,static,\
+    CustomTarget_components \
+    Library_components \
+))
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/static/README.md b/static/README.md
new file mode 100644
index 000000000000..c150d917ce09
--- /dev/null
+++ b/static/README.md
@@ -0,0 +1,4 @@
+# Static build components library
+
+The library contains a map of all build component names
+to their constructor function calls.
diff --git a/sw/source/uibase/app/swmodule.cxx 
b/sw/source/uibase/app/swmodule.cxx
index 51052b8f82b6..f564a36d0ed0 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -175,9 +175,14 @@ OUString SwResId(TranslateNId aContextSingularPlural, int 
nCardinality)
 uno::Reference< scanner::XScannerManager2 > const &
 SwModule::GetScannerManager()
 {
-    if (!m_xScannerManager.is())
+    static bool bTestScannerManager = true;
+    if (bTestScannerManager && !m_xScannerManager.is())
     {
-        m_xScannerManager = scanner::ScannerManager::create( 
comphelper::getProcessComponentContext() );
+        try {
+            m_xScannerManager = scanner::ScannerManager::create( 
comphelper::getProcessComponentContext() );
+        }
+        catch (...) {}
+        bTestScannerManager = false;
     }
     return m_xScannerManager;
 }
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index bdd7bd91f5a4..acd0de996364 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -31,7 +31,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
         Package_skia_denylist ) \
     $(if $(filter DESKTOP FUZZERS,$(BUILD_TYPE)), \
         StaticLibrary_vclmain \
-        $(if $(DISABLE_GUI),, \
+        $(if $(or $(DISABLE_GUI),$(DISABLE_DYNLOADING)),, \
             $(if $(filter LINUX MACOSX SOLARIS WNT %BSD,$(OS)), \
                 Executable_vcldemo \
                 Executable_icontest \
@@ -61,7 +61,7 @@ $(eval $(call gb_Module_add_l10n_targets,vcl,\
 
 ifeq ($(USING_X11),TRUE)
 $(eval $(call gb_Module_add_targets,vcl,\
-    Library_vclplug_gen \
+    $(if $(ENABLE_GEN),Library_vclplug_gen) \
     Library_desktop_detector \
     StaticLibrary_glxtest \
     Package_fontunxppds \
diff --git a/vcl/source/app/salplug.cxx b/vcl/source/app/salplug.cxx
index 313ca6a4d719..968ec902a4e0 100644
--- a/vcl/source/app/salplug.cxx
+++ b/vcl/source/app/salplug.cxx
@@ -65,16 +65,15 @@ oslModule pCloseModule = nullptr;
 
 SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = false )
 {
+#ifdef HEADLESS_VCLPLUG
+    if (rModuleBase == "svp")
+        return svp_create_SalInstance();
+#endif
 #ifdef DISABLE_DYNLOADING
     (void)rModuleBase;
     (void)bForce;
     return create_SalInstance();
 #else // !DISABLE_DYNLOADING
-#ifdef HEADLESS_VCLPLUG
-    if (rModuleBase == "svp")
-        return svp_create_SalInstance();
-#endif
-
     SalInstance* pInst = nullptr;
     OUString aUsedModuleBase(rModuleBase);
     if (aUsedModuleBase == "kde5")
@@ -183,7 +182,9 @@ SalInstance* autodetect_plugin()
 #if ENABLE_GTK3
         "gtk3",
 #endif
+#if ENABLE_GEN
         "gen",
+#endif
         nullptr
     };
 
@@ -192,7 +193,9 @@ SalInstance* autodetect_plugin()
 #if ENABLE_GTK3
         "gtk3",
 #endif
+#if ENABLE_GEN
         "gen",
+#endif
         nullptr
     };
 
@@ -282,26 +285,33 @@ SalInstance *CreateSalInstance()
         pInst = autodetect_plugin();
 #endif
 
+#ifdef DISABLE_DYNLOADING
+    if (!pInst)
+        pInst = tryInstance("");
+#else
     // fallback, try everything
     static const char* const pPlugin[] = {
 #ifdef _WIN32
         "win",
 #elif defined(MACOSX)
         "osx",
-#else
+#else // !_WIN32 && !MACOSX
 #if ENABLE_GTK3
         "gtk3",
 #endif
 #if ENABLE_KF5
         "kf5",
 #endif
+#if ENABLE_GEN
         "gen",
 #endif
+#endif // !_WIN32 && !MACOSX
         nullptr
      };
 
     for (int i = 0; !pInst && pPlugin[i]; ++i)
         pInst = tryInstance( OUString::createFromAscii( pPlugin[ i ] ) );
+#endif // !DISABLE_DYNLOADING
 
     if( ! pInst )
     {
diff --git a/xmlsecurity/Module_xmlsecurity.mk 
b/xmlsecurity/Module_xmlsecurity.mk
index d911b16c6438..62852c0a4d1d 100644
--- a/xmlsecurity/Module_xmlsecurity.mk
+++ b/xmlsecurity/Module_xmlsecurity.mk
@@ -40,7 +40,7 @@ $(eval $(call gb_Module_add_screenshot_targets,xmlsecurity,\
 ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
 ifneq (,$(or $(ENABLE_NSS),$(filter WNT,$(OS))))
 $(eval $(call gb_Module_add_targets,xmlsecurity,\
-    Executable_pdfverify \
+    $(if $(DISABLE_DYNLOADING),,Executable_pdfverify) \
 ))
 endif
 endif

Reply via email to