summaryrefslogtreecommitdiffstats
path: root/external/libgpg-error
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /external/libgpg-error
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'external/libgpg-error')
-rw-r--r--external/libgpg-error/ExternalPackage_libgpg-error.mk28
-rw-r--r--external/libgpg-error/ExternalProject_libgpg-error.mk52
-rw-r--r--external/libgpg-error/Makefile14
-rw-r--r--external/libgpg-error/Module_libgpg-error.mk18
-rw-r--r--external/libgpg-error/README2
-rw-r--r--external/libgpg-error/UnpackedTarball_libgpg-error.mk26
-rw-r--r--external/libgpg-error/clang-cl.patch11
-rw-r--r--external/libgpg-error/libgpgerror-bundled-soname.patch.122
-rw-r--r--external/libgpg-error/w32-build-fixes-2.patch.121
-rw-r--r--external/libgpg-error/w32-build-fixes-4.patch13
-rw-r--r--external/libgpg-error/w32-build-fixes-5.patch149
-rw-r--r--external/libgpg-error/w32-build-fixes.patch121
-rw-r--r--external/libgpg-error/w32-disable-dllinit.patch.155
13 files changed, 532 insertions, 0 deletions
diff --git a/external/libgpg-error/ExternalPackage_libgpg-error.mk b/external/libgpg-error/ExternalPackage_libgpg-error.mk
new file mode 100644
index 0000000000..fd887fb577
--- /dev/null
+++ b/external/libgpg-error/ExternalPackage_libgpg-error.mk
@@ -0,0 +1,28 @@
+# -*- 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_ExternalPackage_ExternalPackage,libgpg-error,libgpg-error))
+
+$(eval $(call gb_ExternalPackage_use_external_project,libgpg-error,libgpg-error))
+
+ifneq ($(DISABLE_DYNLOADING),TRUE)
+
+ifeq ($(OS),LINUX)
+
+$(eval $(call gb_ExternalPackage_add_file,libgpg-error,$(LIBO_LIB_FOLDER)/libgpg-error-lo.so.0,src/.libs/libgpg-error-lo.so.0.34.0))
+
+else ifeq ($(OS),MACOSX)
+
+$(eval $(call gb_ExternalPackage_add_file,libgpg-error,$(LIBO_LIB_FOLDER)/libgpg-error.0.dylib,src/.libs/libgpg-error.0.dylib))
+
+endif
+
+endif # $(DISABLE_DYNLOADING)
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libgpg-error/ExternalProject_libgpg-error.mk b/external/libgpg-error/ExternalProject_libgpg-error.mk
new file mode 100644
index 0000000000..88b9b2be50
--- /dev/null
+++ b/external/libgpg-error/ExternalProject_libgpg-error.mk
@@ -0,0 +1,52 @@
+# -*- 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_ExternalProject_ExternalProject,libgpg-error))
+
+$(eval $(call gb_ExternalProject_register_targets,libgpg-error,\
+ build \
+))
+
+$(eval $(call gb_ExternalProject_use_autoconf,libgpg-error,build))
+
+ifeq ($(COM),MSC)
+$(call gb_ExternalProject_get_state_target,libgpg-error,build): $(call gb_Executable_get_target_for_build,cpp)
+ $(call gb_Trace_StartRange,libgpg-error,EXTERNAL)
+ $(call gb_ExternalProject_run,build,\
+ $(gb_WIN_GPG_cross_setup_exports) \
+ && MAKE=$(MAKE) $(gb_RUN_CONFIGURE) ./configure \
+ --enable-static \
+ --disable-shared \
+ --disable-rpath \
+ --disable-languages \
+ --disable-doc \
+ --disable-tests \
+ $(gb_WIN_GPG_platform_switches) \
+ && $(MAKE) \
+ )
+ $(call gb_Trace_EndRange,libgpg-error,EXTERNAL)
+else
+$(call gb_ExternalProject_get_state_target,libgpg-error,build):
+ $(call gb_Trace_StartRange,libgpg-error,EXTERNAL)
+ $(call gb_ExternalProject_run,build,\
+ MAKE=$(MAKE) $(gb_RUN_CONFIGURE) ./configure \
+ --disable-rpath \
+ --disable-languages \
+ --disable-doc \
+ CFLAGS="$(CFLAGS) $(call gb_ExternalProject_get_build_flags,libgpg-error)" \
+ CPPFLAGS="$(SOLARINC)" \
+ $(gb_CONFIGURE_PLATFORMS) \
+ $(if $(filter MACOSX,$(OS)),--prefix=/@.__________________________________________________OOO) \
+ $(if $(filter TRUE,$(DISABLE_DYNLOADING)),--disable-shared,--disable-static) \
+ && $(MAKE) \
+ )
+ $(call gb_Trace_EndRange,libgpg-error,EXTERNAL)
+
+endif
+# vim: set noet sw=4 ts=4:
diff --git a/external/libgpg-error/Makefile b/external/libgpg-error/Makefile
new file mode 100644
index 0000000000..569ad8a0ba
--- /dev/null
+++ b/external/libgpg-error/Makefile
@@ -0,0 +1,14 @@
+# -*- 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/external/libgpg-error/Module_libgpg-error.mk b/external/libgpg-error/Module_libgpg-error.mk
new file mode 100644
index 0000000000..0079dcba98
--- /dev/null
+++ b/external/libgpg-error/Module_libgpg-error.mk
@@ -0,0 +1,18 @@
+# -*- 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,libgpg-error))
+
+$(eval $(call gb_Module_add_targets,libgpg-error,\
+ ExternalProject_libgpg-error \
+ ExternalPackage_libgpg-error \
+ UnpackedTarball_libgpg-error \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libgpg-error/README b/external/libgpg-error/README
new file mode 100644
index 0000000000..84288267a1
--- /dev/null
+++ b/external/libgpg-error/README
@@ -0,0 +1,2 @@
+A small library that defines common error values for GnuPG components
+[https://www.gnupg.org/related_software/libgpg-error/index.html]
diff --git a/external/libgpg-error/UnpackedTarball_libgpg-error.mk b/external/libgpg-error/UnpackedTarball_libgpg-error.mk
new file mode 100644
index 0000000000..698c419973
--- /dev/null
+++ b/external/libgpg-error/UnpackedTarball_libgpg-error.mk
@@ -0,0 +1,26 @@
+# -*- 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_UnpackedTarball_UnpackedTarball,libgpg-error))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,libgpg-error,$(LIBGPGERROR_TARBALL)))
+
+$(eval $(call gb_UnpackedTarball_set_patchlevel,libgpg-error,0))
+
+$(eval $(call gb_UnpackedTarball_add_patches,libgpg-error, \
+ $(if $(filter MSC,$(COM)),external/libgpg-error/w32-build-fixes.patch) \
+ $(if $(filter MSC,$(COM)),external/libgpg-error/w32-build-fixes-2.patch.1) \
+ $(if $(filter MSC,$(COM)),external/libgpg-error/w32-disable-dllinit.patch.1) \
+ external/libgpg-error/w32-build-fixes-4.patch \
+ $(if $(filter MSC,$(COM)),external/libgpg-error/w32-build-fixes-5.patch) \
+ $(if $(filter LINUX,$(OS)),external/libgpg-error/libgpgerror-bundled-soname.patch.1) \
+ external/libgpg-error/clang-cl.patch \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libgpg-error/clang-cl.patch b/external/libgpg-error/clang-cl.patch
new file mode 100644
index 0000000000..3a635c5d89
--- /dev/null
+++ b/external/libgpg-error/clang-cl.patch
@@ -0,0 +1,11 @@
+--- src/gpg-error.h.in
++++ src/gpg-error.h.in
+@@ -152,7 +152,7 @@
+ /*
+ * GCC feature test.
+ */
+-#if __GNUC__
++#ifdef __GNUC__
+ # define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
diff --git a/external/libgpg-error/libgpgerror-bundled-soname.patch.1 b/external/libgpg-error/libgpgerror-bundled-soname.patch.1
new file mode 100644
index 0000000000..6b5c47b4cf
--- /dev/null
+++ b/external/libgpg-error/libgpgerror-bundled-soname.patch.1
@@ -0,0 +1,22 @@
+--- libgpg-error/src/Makefile.in.orig 2019-01-28 14:11:10.518425440 +0100
++++ libgpg-error/src/Makefile.in 2019-01-28 14:11:16.901414229 +0100
+@@ -540,7 +540,7 @@
+ @HAVE_LD_VERSION_SCRIPT_TRUE@libgpg_error_vers_opt = -Wl,--version-script=$(srcdir)/gpg-error.vers
+ libgpg_error_la_LDFLAGS = \
+ -no-undefined $(export_symbols) $(libgpg_error_vers_opt) \
+- $(extra_ltoptions) -version-info \
++ $(extra_ltoptions) -release lo -version-info \
+ @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@
+
+ libgpg_error_la_SOURCES = gettext.h $(arch_sources) \
+--- libgpg-error/src/gpg-error.vers.orig 2019-01-28 14:08:11.413740011 +0100
++++ libgpg-error/src/gpg-error.vers 2019-01-28 14:08:34.172700037 +0100
+@@ -20,7 +20,7 @@
+ # visibility.h and gpg-error.def.in as well.
+
+
+-GPG_ERROR_1.0 {
++GPG_ERROR_LIBREOFFICE {
+ global:
+ gpg_strerror;
+ gpg_strerror_r;
diff --git a/external/libgpg-error/w32-build-fixes-2.patch.1 b/external/libgpg-error/w32-build-fixes-2.patch.1
new file mode 100644
index 0000000000..5f2a7b9258
--- /dev/null
+++ b/external/libgpg-error/w32-build-fixes-2.patch.1
@@ -0,0 +1,21 @@
+diff -ru libgpg-error.orig/src/Makefile.in libgpg-error/src/Makefile.in
+--- libgpg-error.orig/src/Makefile.in 2023-04-06 17:30:13.000000000 +0900
++++ libgpg-error/src/Makefile.in 2023-08-30 14:44:01.102310369 +0900
+@@ -1619,7 +1618,7 @@
+
+
+ @HAVE_W32_SYSTEM_TRUE@.rc.lo:
+-@HAVE_W32_SYSTEM_TRUE@ $(LTRCCOMPILE) -i "$<" -o "$@"
++@HAVE_W32_SYSTEM_TRUE@ $(LTRCCOMPILE) -i $< -o $@
+
+ @HAVE_W32_SYSTEM_TRUE@versioninfo.lo : gpg-error.w32-manifest
+
+@@ -1660,7 +1659,7 @@
+ # It is correct to use $(CPP). We want the host's idea of the error codes.
+ mkerrcodes.h: Makefile mkerrcodes.awk
+ $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@
+- $(CPP) $(CPPFLAGS) -P _$@ | grep GPG_ERR_ | \
++ $(CPP) $(CPPFLAGS) _$@ | grep GPG_ERR_ | \
+ $(AWK) -f $(srcdir)/mkerrcodes.awk >$@
+ -rm _$@
+
diff --git a/external/libgpg-error/w32-build-fixes-4.patch b/external/libgpg-error/w32-build-fixes-4.patch
new file mode 100644
index 0000000000..1d4e052a56
--- /dev/null
+++ b/external/libgpg-error/w32-build-fixes-4.patch
@@ -0,0 +1,13 @@
+Avoid MFC dependency - can go with very basic includes instead
+
+--- src/versioninfo.rc.in~ 2017-02-28 14:48:38.000000000 +0100
++++ src/versioninfo.rc.in 2017-11-29 01:41:47.549804600 +0100
+@@ -14,8 +14,6 @@
+
+ #line __LINE__ "versioninfo.rc.in"
+
+-#include <afxres.h>
+-
+
+ VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @BUILD_FILEVERSION@
diff --git a/external/libgpg-error/w32-build-fixes-5.patch b/external/libgpg-error/w32-build-fixes-5.patch
new file mode 100644
index 0000000000..80d52f720e
--- /dev/null
+++ b/external/libgpg-error/w32-build-fixes-5.patch
@@ -0,0 +1,149 @@
+--- src/argparse.c 2021-11-03 13:44:56.000000000 +0100
++++ src/argparse.c~ 2022-01-03 17:05:23.418077200 +0100
+@@ -33,8 +33,12 @@
+ #include <stdarg.h>
+ #include <limits.h>
+ #include <errno.h>
+-#include <unistd.h>
+ #include <time.h>
++#ifdef _WIN32
++# define R_OK 04
++# define strncasecmp _strnicmp
++# define strcasecmp _stricmp
++#endif
+
+ #include "gpgrt-int.h"
+
+--- src/gpg-error.c 2022-03-04 20:25:28.000000000 +0900
++++ src/gpg-error.c~ 2023-08-30 15:10:24.521856169 +0900
+@@ -61,6 +61,11 @@
+ #define drop_locale_dir(dir)
+ #endif
+
++#ifdef _WIN32
++# define strncasecmp _strnicmp
++# define strcasecmp _stricmp
++#endif
++
+ static void
+ i18n_init (void)
+ {
+--- src/spawn-w32.c 2023-08-30 15:24:46.861855840 +0900
++++ src/spawn-w32.c~ 2023-08-30 15:26:04.581855810 +0900
+@@ -56,7 +56,7 @@
+ * Previous versions interpreted X_OK as F_OK anyway, so we'll just
+ * use F_OK directly. */
+ #undef X_OK
+-#define X_OK F_OK
++#define X_OK 0
+
+ /* For HANDLE and the internal file descriptor (fd) of this module:
+ * HANDLE can be represented by an intptr_t which should be true for
+
+--- src/logging.c 2023-03-21 18:33:56.000000000 +0900
++++ src/logging.c~ 2023-08-30 15:37:20.661855553 +0900
+@@ -44,7 +44,12 @@
+ # include <netinet/in.h>
+ # include <arpa/inet.h>
+ #endif /*!HAVE_W32_SYSTEM*/
+-#include <unistd.h>
++#ifdef _WIN32
++# include <io.h>
++# include <process.h>
++#else
++# include <unistd.h>
++#endif
+ #include <fcntl.h>
+ /* #include <execinfo.h> */
+
+@@ -53,6 +58,15 @@
+
+
+ #ifdef HAVE_W32_SYSTEM
++# ifndef S_IRUSR
++# define S_IRUSR _S_IREAD
++# endif
++# ifndef S_IWUSR
++# define S_IWUSR _S_IWRITE
++# endif
++# ifndef S_IXUSR
++# define S_IXUSR 0x00400000
++# endif
+ # ifndef S_IRWXG
+ # define S_IRGRP S_IRUSR
+ # define S_IWGRP S_IWUSR
+--- src/Makefile.am 2022-08-19 17:39:54.000000000 +0900
++++ src/Makefile.am~ 2023-08-30 15:41:10.371855465 +0900
+@@ -208,8 +208,8 @@
+ # libgpg_error_la_DEPENDENCIES = \
+ # $(srcdir)/gpg-error.vers
+
+-libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
+-libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(socklibs) $(LIBTHREAD)
++libgpg_error_la_CPPFLAGS = -DLOCALEDIR=$(localelidir)
++libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(socklibs) -ladvapi32 $(LIBTHREAD)
+
+ gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
+ gpg_error_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" \
+--- src/Makefile.in 2023-08-30 14:44:01.102310369 +0900
++++ src/Makefile.in~ 2023-08-30 15:54:38.371855157 +0900
+@@ -662,8 +662,8 @@
+
+ # libgpg_error_la_DEPENDENCIES = \
+ # $(srcdir)/gpg-error.vers
+-libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
+-libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(socklibs) $(LIBTHREAD)
++libgpg_error_la_CPPFLAGS = -DLOCALEDIR=$(localedir)
++libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(socklibs) -ladvapi32 $(LIBTHREAD)
+ gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
+ gpg_error_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" \
+ -DLOCALEDIR=\"$(localedir)\"
+--- src/sysutils.c 2023-03-21 18:33:56.000000000 +0900
++++ src/sysutils.c~ 2023-08-30 15:57:34.401855090 +0900
+@@ -22,7 +22,12 @@
+ #include <stdlib.h>
+ #include <stdint.h>
+ #include <string.h>
+-#include <unistd.h>
++#ifdef _WIN32
++# include <io.h>
++# define W_OK 02
++#else
++# include <unistd.h>
++#endif
+ #include <errno.h>
+ #ifdef HAVE_W32_SYSTEM
+ # include <windows.h>
+--- src/visibility.c 2020-06-05 18:54:56.410442900 +0200
++++ src/visibility.c~ 2019-01-04 12:56:54.000000000 +0100
+@@ -1067,11 +1067,7 @@
+ _gpgrt_log_assert (const char *expr, const char *file,
+ int line, const char *func)
+ {
+-#ifdef GPGRT_HAVE_MACRO_FUNCTION
+ _gpgrt__log_assert (expr, file, line, func);
+-#else
+- _gpgrt__log_assert (expr, file, line);
+-#endif
+ }
+
+
+--- src/w32-add.h 2020-06-06 00:32:38.502203300 +0200
++++ src/w32-add.h~ 2018-12-07 14:48:19.000000000 +0100
+@@ -65,3 +65,5 @@
+ char *gpgrt_w32_reg_query_string (const char *root,
+ const char *dir,
+ const char *name);
++
++wchar_t *utf8_to_wchar (const char *string, size_t length, size_t *retlen);
+--- src/w32-gettext.c 2022-03-04 21:44:26.000000000 +0900
++++ src/w32-gettext.c~ 2023-08-30 16:01:12.861855006 +0900
+@@ -1325,7 +1325,7 @@
+ is not defined. If LENGTH is zero and RETLEN NULL the function
+ assumes that STRING is a nul-terminated string and returns a
+ (wchar_t)0-terminated string. */
++wchar_t *
+-static wchar_t *
+ utf8_to_wchar (const char *string, size_t length, size_t *retlen)
+ {
+ int n;
diff --git a/external/libgpg-error/w32-build-fixes.patch b/external/libgpg-error/w32-build-fixes.patch
new file mode 100644
index 0000000000..1de57e4240
--- /dev/null
+++ b/external/libgpg-error/w32-build-fixes.patch
@@ -0,0 +1,121 @@
+diff -ur libgpg-error.org/src/estream.c libgpg-error/src/estream.c
+--- src/estream.c 2016-11-16 13:22:03.000000000 +0100
++++ src/estream.c~ 2017-02-19 17:53:15.010869000 +0100
+@@ -74,12 +74,16 @@
+ # include <sys/time.h>
+ #endif
+ #include <sys/types.h>
+-#include <sys/file.h>
++/*#include <sys/file.h>*/
+ #include <sys/stat.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <unistd.h>
++#ifdef _WIN32
++# include <io.h>
++#else
++# include <unistd.h>
++#endif
+ #include <stdarg.h>
+ #include <fcntl.h>
+ #include <errno.h>
+@@ -109,6 +113,15 @@
+
+
+ #ifdef HAVE_W32_SYSTEM
++# ifndef S_IRUSR
++# define S_IRUSR _S_IREAD
++# endif
++# ifndef S_IWUSR
++# define S_IWUSR _S_IWRITE
++# endif
++# ifndef S_IXUSR
++# define S_IXUSR 0x00400000
++# endif
+ # ifndef S_IRGRP
+ # define S_IRGRP S_IRUSR
+ # endif
+diff -ur libgpg-error.org/src/estream-printf.c libgpg-error/src/estream-printf.c
+--- src/estream-printf.c 2016-12-02 22:51:19.000000000 +0100
++++ src/estream-printf.c~ 2017-02-19 18:02:52.239383500 +0100
+@@ -85,7 +85,11 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <unistd.h>
++#ifdef _WIN32
++# include <io.h>
++#else
++# include <unistd.h>
++#endif
+ #include <stdarg.h>
+ #include <errno.h>
+ #include <stddef.h>
+--- src/mkheader.c 2016-11-16 13:22:03.000000000 +0100
++++ src/mkheader.c~ 2017-02-19 17:35:32.172009000 +0100
+@@ -16,7 +16,11 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <errno.h>
+-#include <unistd.h>
++#ifdef _WIN32
++# include <io.h>
++#else
++# include <unistd.h>
++#endif
+
+ #define PGM "mkheader"
+
+@@ -402,12 +406,20 @@
+
+ repl_flag = !!strchr (name, '&');
+ incfname = mk_include_name (name, repl_flag? host_triplet : NULL);
++#ifdef _WIN32
++ rc = _access (incfname, 04);
++#else
+ rc = access (incfname, R_OK);
++#endif
+ if (rc && repl_flag)
+ {
+ free (incfname);
+ incfname = mk_include_name (name, host_os);
++#ifdef _WIN32
++ rc = _access (incfname, 04);
++#else
+ rc = access (incfname, R_OK);
++#endif
+ }
+ if (!rc)
+ include_file (fname, lnr, name, outf);
+diff -ur libgpg-error.org/src/w32-estream.c libgpg-error/src/w32-estream.c
+--- src/w32-estream.c 2016-11-16 13:22:03.000000000 +0100
++++ src/w32-estream.c~ 2017-02-19 17:37:35.879037500 +0100
+@@ -42,6 +42,11 @@
+
+ #include "gpgrt-int.h"
+
++#ifdef _WIN32
++/* no ssize_t in windows std headers, emulate for native build */
++typedef SSIZE_T ssize_t;
++#endif
++
+ /*
+ * In order to support es_poll on Windows, we create a proxy shim that
+ * we use as the estream I/O functions. This shim creates reader and
+--- src/spawn-w32.c 2019-08-22 12:30:38.000000000 +0200
++++ src/spawn-w32.c~ 2020-05-26 01:37:17.759077700 +0200
+@@ -34,7 +34,11 @@
+ #ifdef HAVE_SIGNAL_H
+ # include <signal.h>
+ #endif
+-#include <unistd.h>
++#ifdef _WIN32
++# include <io.h>
++#else
++# include <unistd.h>
++#endif
+ #include <fcntl.h>
+ #ifdef HAVE_STAT
+ # include <sys/stat.h>
+
diff --git a/external/libgpg-error/w32-disable-dllinit.patch.1 b/external/libgpg-error/w32-disable-dllinit.patch.1
new file mode 100644
index 0000000000..96abb3bbdc
--- /dev/null
+++ b/external/libgpg-error/w32-disable-dllinit.patch.1
@@ -0,0 +1,55 @@
+Disable all DLL init functions in libgpg-error, since they're
+not actually run in statically linked libs. And libtool seems
+to unconditionally set that flag on all Windows builds.
+
+diff -ur libgpg-error.org/src/init.c libgpg-error/src/init.c
+--- libgpg-error.org/src/init.c 2017-02-28 10:11:05.000000000 +0100
++++ libgpg-error/src/init.c 2017-11-23 16:44:56.850797400 +0100
+@@ -88,7 +88,7 @@
+ _gpg_err_init (void)
+ {
+ #ifdef HAVE_W32_SYSTEM
+-# ifdef DLL_EXPORT
++# ifdef HAVE_DLL_INIT
+ /* We always have a constructor and thus this function is called
+ automatically. Due to the way the C init code of mingw works,
+ the constructors are called before our DllMain function is
+@@ -130,7 +130,7 @@
+ void
+ _gpg_err_deinit (int mode)
+ {
+-#if defined (HAVE_W32_SYSTEM) && !defined(DLL_EXPORT)
++#if defined (HAVE_W32_SYSTEM) && !defined(HAVE_DLL_INIT)
+ struct tls_space_s *tls;
+
+ tls = TlsGetValue (tls_index);
+@@ -473,7 +473,7 @@
+
+
+ /* Entry point called by the DLL loader. */
+-#ifdef DLL_EXPORT
++#ifdef HAVE_DLL_INIT
+ int WINAPI
+ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
+ {
+diff -ur libgpg-error.org/src/w32-gettext.c libgpg-error/src/w32-gettext.c
+--- libgpg-error.org/src/w32-gettext.c 2016-12-02 22:51:19.000000000 +0100
++++ libgpg-error/src/w32-gettext.c 2017-11-23 16:43:28.450453000 +0100
+@@ -1180,7 +1180,7 @@
+ DLL. If used as a static lib we can't control the process set; for
+ example it might be used with a main module which is not build with
+ mingw and thus does not know how to call the constructors. */
+-#ifdef DLL_EXPORT
++#ifdef HAVE_DLL_INIT
+ static void module_init (void) _GPG_ERR_CONSTRUCTOR;
+ #endif
+ static void
+@@ -1195,7 +1195,7 @@
+ }
+ }
+
+-#if !defined(DLL_EXPORT) || !defined(_GPG_ERR_HAVE_CONSTRUCTOR)
++#if !defined(HAVE_DLL_INIT) || !defined(_GPG_ERR_HAVE_CONSTRUCTOR)
+ void
+ _gpg_w32__init_gettext_module (void)
+ {