summaryrefslogtreecommitdiff
path: root/external/gpgmepp
diff options
context:
space:
mode:
authorThorsten Behrens <thorsten.behrens@cib.de>2017-11-15 21:31:07 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-11-22 17:57:08 +0100
commit50a55d862034b7a06510c014332236f44e306831 (patch)
tree422addf00716499a75d07cfb69d53aa0e2b0f118 /external/gpgmepp
parentbafbaa3fed95f28f368b0bd4256dbe2a714e3bd8 (diff)
gpg4libre: cleanup gpgme & add gbuild lib for gpgmepp
This moves the external to gpgmepp, since that's what we _actually_ link against; plus tons of enablement for Windows build, mostly related to linker probs integration. There's still no good way to build a DLL with autotools, so we fall back to gbuild manual make, see also tdf#91480 Change-Id: Ifd8217ef58536612d2389d48e343db133a13fb9c Reviewed-on: https://gerrit.libreoffice.org/44970 Reviewed-by: Siegmund Gorr <siegmund.gorr@cib.de> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'external/gpgmepp')
-rw-r--r--external/gpgmepp/ExternalPackage_gpgmepp.mk30
-rw-r--r--external/gpgmepp/ExternalProject_gpgmepp.mk66
-rw-r--r--external/gpgmepp/Library_gpgmepp.mk79
-rw-r--r--external/gpgmepp/Makefile14
-rw-r--r--external/gpgmepp/Module_gpgmepp.mk31
-rw-r--r--external/gpgmepp/README2
-rw-r--r--external/gpgmepp/UnpackedTarball_gpgmepp.mk25
-rw-r--r--external/gpgmepp/add-minimal-keyexport.patch68
-rw-r--r--external/gpgmepp/find-libgpg-error-libassuan.patch59
-rw-r--r--external/gpgmepp/fix-autoconf-macros.patch39
-rw-r--r--external/gpgmepp/w32-build-fixes.patch.1133
-rw-r--r--external/gpgmepp/w32-disable-docs.patch.115
-rw-r--r--external/gpgmepp/w32-fix-libtool.patch.138
-rw-r--r--external/gpgmepp/w32-fix-win32-macro.patch.1175
14 files changed, 774 insertions, 0 deletions
diff --git a/external/gpgmepp/ExternalPackage_gpgmepp.mk b/external/gpgmepp/ExternalPackage_gpgmepp.mk
new file mode 100644
index 000000000000..d5285520619f
--- /dev/null
+++ b/external/gpgmepp/ExternalPackage_gpgmepp.mk
@@ -0,0 +1,30 @@
+# -*- 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,gpgmepp,gpgmepp))
+
+$(eval $(call gb_ExternalPackage_use_external_project,gpgmepp,gpgmepp))
+
+ifneq ($(DISABLE_DYNLOADING),TRUE)
+
+ifeq ($(OS),LINUX)
+
+$(eval $(call gb_ExternalPackage_add_file,gpgmepp,$(LIBO_LIB_FOLDER)/libgpgmepp.so.6,lang/cpp/src/.libs/libgpgmepp.so.6.4.0))
+$(eval $(call gb_ExternalPackage_add_file,gpgmepp,$(LIBO_LIB_FOLDER)/libgpgme.so.11,src/.libs/libgpgme.so.11.18.0))
+
+else ifeq ($(OS),MACOSX)
+
+$(eval $(call gb_ExternalPackage_add_file,gpgmepp,$(LIBO_LIB_FOLDER)/libgpgmepp.6.dylib,lang/cpp/src/.libs/libgpgmepp.6.dylib))
+$(eval $(call gb_ExternalPackage_add_file,gpgmepp,$(LIBO_LIB_FOLDER)/libgpgme.11.dylib,src/.libs/libgpgme.11.dylib))
+
+endif
+
+endif # $(DISABLE_DYNLOADING)
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/gpgmepp/ExternalProject_gpgmepp.mk b/external/gpgmepp/ExternalProject_gpgmepp.mk
new file mode 100644
index 000000000000..4b69774771fd
--- /dev/null
+++ b/external/gpgmepp/ExternalProject_gpgmepp.mk
@@ -0,0 +1,66 @@
+# -*- 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,gpgmepp))
+
+$(eval $(call gb_ExternalProject_register_targets,gpgmepp,\
+ build \
+))
+
+$(eval $(call gb_ExternalProject_use_autoconf,gpgmepp,build))
+
+$(eval $(call gb_ExternalProject_use_externals,gpgmepp,\
+ libgpg-error \
+ libassuan \
+))
+
+ifeq ($(COM),MSC)
+$(call gb_ExternalProject_get_state_target,gpgmepp,build):
+ $(call gb_ExternalProject_run,build,\
+ autoreconf \
+ && ./configure \
+ --disable-shared \
+ --disable-languages \
+ --disable-gpgconf-test \
+ --disable-gpg-test \
+ --disable-gpgsm-test \
+ --disable-g13-test \
+ --disable-glibtest \
+ CFLAGS='$(CFLAGS) \
+ $(if $(ENABLE_OPTIMIZED), \
+ $(gb_COMPILEROPTFLAGS),$(gb_COMPILERNOOPTFLAGS)) \
+ $(if $(ENABLE_DEBUG),$(gb_DEBUG_CFLAGS)) \
+ $(if $(filter $(true),$(gb_SYMBOL)),$(gb_DEBUGINFO_FLAGS))' \
+ --host=$(if $(filter INTEL,$(CPUNAME)),i686-mingw32,x86_64-w64-mingw32) \
+ && $(MAKE) \
+ )
+else
+$(call gb_ExternalProject_get_state_target,gpgmepp,build):
+ $(call gb_ExternalProject_run,build,\
+ autoreconf \
+ && ./configure \
+ --enable-languages="cpp" \
+ GPG_ERROR_CFLAGS="$(GPG_ERROR_CFLAGS)" \
+ GPG_ERROR_LIBS="$(GPG_ERROR_LIBS)" \
+ LIBASSUAN_CFLAGS="$(LIBASSUAN_CFLAGS)" \
+ LIBASSUAN_LIBS="$(LIBASSUAN_LIBS)" \
+ CFLAGS='$(CFLAGS) \
+ $(if $(ENABLE_OPTIMIZED), \
+ $(gb_COMPILEROPTFLAGS),$(gb_COMPILERNOOPTFLAGS)) \
+ $(if $(ENABLE_DEBUG),$(gb_DEBUG_CFLAGS)) \
+ $(if $(filter $(true),$(gb_SYMBOL)),$(gb_DEBUGINFO_FLAGS))' \
+ $(if $(filter LINUX,$(OS)), \
+ 'LDFLAGS=-Wl$(COMMA)-z$(COMMA)origin \
+ -Wl$(COMMA)-rpath$(COMMA)\$$$$ORIGIN') \
+ $(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
+ && $(MAKE) \
+ )
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/gpgmepp/Library_gpgmepp.mk b/external/gpgmepp/Library_gpgmepp.mk
new file mode 100644
index 000000000000..7649753fe748
--- /dev/null
+++ b/external/gpgmepp/Library_gpgmepp.mk
@@ -0,0 +1,79 @@
+# -*- 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_Library_Library,gpgmepp))
+
+$(eval $(call gb_Library_use_unpacked,gpgmepp,gpgmepp))
+
+$(eval $(call gb_Library_use_externals,gpgmepp,\
+ libgpg-error \
+ libassuan \
+))
+
+$(eval $(call gb_LinkTarget_use_external_project,\
+ $(call gb_Library_get_linktarget,gpgmepp),gpgmepp,full))
+
+$(eval $(call gb_Library_set_warnings_not_errors,gpgmepp))
+
+$(eval $(call gb_Library_set_include,gpgmepp,\
+ -I$(call gb_UnpackedTarball_get_dir,gpgmepp)/lang/cpp/src \
+ -I$(call gb_UnpackedTarball_get_dir,gpgmepp)/lang/cpp/src/interfaces \
+ -I$(call gb_UnpackedTarball_get_dir,gpgmepp) \
+ -I$(call gb_UnpackedTarball_get_dir,gpgmepp)/src \
+ -I$(call gb_UnpackedTarball_get_dir,libgpg-error)/src \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_add_libs,gpgmepp,\
+ ws2_32.lib shell32.lib \
+ -LIBPATH:$(call gb_UnpackedTarball_get_dir,gpgmepp)/src/.libs libgpgme.lib \
+))
+
+$(eval $(call gb_Library_add_defs,gpgmepp,\
+ -DHAVE_CONFIG_H \
+ -DBUILDING_GPGMEPP \
+ -DDLL_EXPORT \
+ -DPIC \
+))
+
+$(eval $(call gb_Library_set_generated_cxx_suffix,gpgmepp,cpp))
+
+$(eval $(call gb_Library_add_generated_exception_objects,gpgmepp,\
+ UnpackedTarball/gpgmepp/lang/cpp/src/callbacks \
+ UnpackedTarball/gpgmepp/lang/cpp/src/configuration \
+ UnpackedTarball/gpgmepp/lang/cpp/src/context \
+ UnpackedTarball/gpgmepp/lang/cpp/src/context_vanilla \
+ UnpackedTarball/gpgmepp/lang/cpp/src/data \
+ UnpackedTarball/gpgmepp/lang/cpp/src/decryptionresult \
+ UnpackedTarball/gpgmepp/lang/cpp/src/defaultassuantransaction \
+ UnpackedTarball/gpgmepp/lang/cpp/src/editinteractor \
+ UnpackedTarball/gpgmepp/lang/cpp/src/encryptionresult \
+ UnpackedTarball/gpgmepp/lang/cpp/src/engineinfo \
+ UnpackedTarball/gpgmepp/lang/cpp/src/eventloopinteractor \
+ UnpackedTarball/gpgmepp/lang/cpp/src/exception \
+ UnpackedTarball/gpgmepp/lang/cpp/src/gpgadduserideditinteractor \
+ UnpackedTarball/gpgmepp/lang/cpp/src/gpgagentgetinfoassuantransaction \
+ UnpackedTarball/gpgmepp/lang/cpp/src/gpggencardkeyinteractor \
+ UnpackedTarball/gpgmepp/lang/cpp/src/gpgsetexpirytimeeditinteractor \
+ UnpackedTarball/gpgmepp/lang/cpp/src/gpgsetownertrusteditinteractor \
+ UnpackedTarball/gpgmepp/lang/cpp/src/gpgsignkeyeditinteractor \
+ UnpackedTarball/gpgmepp/lang/cpp/src/importresult \
+ UnpackedTarball/gpgmepp/lang/cpp/src/key \
+ UnpackedTarball/gpgmepp/lang/cpp/src/keygenerationresult \
+ UnpackedTarball/gpgmepp/lang/cpp/src/keylistresult \
+ UnpackedTarball/gpgmepp/lang/cpp/src/scdgetinfoassuantransaction \
+ UnpackedTarball/gpgmepp/lang/cpp/src/signingresult \
+ UnpackedTarball/gpgmepp/lang/cpp/src/swdbresult \
+ UnpackedTarball/gpgmepp/lang/cpp/src/tofuinfo \
+ UnpackedTarball/gpgmepp/lang/cpp/src/trustitem \
+ UnpackedTarball/gpgmepp/lang/cpp/src/verificationresult \
+ UnpackedTarball/gpgmepp/lang/cpp/src/vfsmountresult \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/gpgmepp/Makefile b/external/gpgmepp/Makefile
new file mode 100644
index 000000000000..569ad8a0ba7a
--- /dev/null
+++ b/external/gpgmepp/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/gpgmepp/Module_gpgmepp.mk b/external/gpgmepp/Module_gpgmepp.mk
new file mode 100644
index 000000000000..1c13a2a5fcb8
--- /dev/null
+++ b/external/gpgmepp/Module_gpgmepp.mk
@@ -0,0 +1,31 @@
+# -*- 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,gpgmepp))
+
+$(eval $(call gb_Module_add_targets,gpgmepp,\
+ UnpackedTarball_gpgmepp \
+ ExternalProject_gpgmepp \
+))
+
+ifeq ($(COM),MSC)
+
+$(eval $(call gb_Module_add_targets,gpgmepp,\
+ Library_gpgmepp \
+))
+
+else
+
+$(eval $(call gb_Module_add_targets,gpgmepp,\
+ ExternalPackage_gpgmepp \
+))
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/gpgmepp/README b/external/gpgmepp/README
new file mode 100644
index 000000000000..220028e42471
--- /dev/null
+++ b/external/gpgmepp/README
@@ -0,0 +1,2 @@
+A library for easy access to GnuPG (GnuPG Made Easy)
+[https://www.gnupg.org/related_software/gpgme/index.html]
diff --git a/external/gpgmepp/UnpackedTarball_gpgmepp.mk b/external/gpgmepp/UnpackedTarball_gpgmepp.mk
new file mode 100644
index 000000000000..db8c398e3003
--- /dev/null
+++ b/external/gpgmepp/UnpackedTarball_gpgmepp.mk
@@ -0,0 +1,25 @@
+# -*- 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,gpgmepp))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,gpgmepp,$(GPGME_TARBALL)))
+
+$(eval $(call gb_UnpackedTarball_set_patchlevel,gpgmepp,0))
+
+$(eval $(call gb_UnpackedTarball_add_patches,gpgmepp, \
+ external/gpgmepp/find-libgpg-error-libassuan.patch \
+ external/gpgmepp/fix-autoconf-macros.patch \
+ external/gpgmepp/add-minimal-keyexport.patch \
+ $(if $(filter MSC,$(COM)),external/gpgmepp/w32-build-fixes.patch.1) \
+ $(if $(filter MSC,$(COM)),external/gpgmepp/w32-disable-docs.patch.1) \
+ $(if $(filter MSC,$(COM)),external/gpgmepp/w32-fix-win32-macro.patch.1) \
+ $(if $(filter MSC,$(COM)),external/gpgmepp/w32-fix-libtool.patch.1) \
+))
+# vim: set noet sw=4 ts=4:
diff --git a/external/gpgmepp/add-minimal-keyexport.patch b/external/gpgmepp/add-minimal-keyexport.patch
new file mode 100644
index 000000000000..abaeb15897fc
--- /dev/null
+++ b/external/gpgmepp/add-minimal-keyexport.patch
@@ -0,0 +1,68 @@
+--- lang/cpp/src/context.h.bak 2017-10-18 12:28:00.898945587 +0200
++++ lang/cpp/src/context.h 2017-10-18 12:28:35.794832395 +0200
+@@ -178,10 +178,10 @@
+ // Key Export
+ //
+
+- GpgME::Error exportPublicKeys(const char *pattern, Data &keyData);
+- GpgME::Error exportPublicKeys(const char *pattern[], Data &keyData);
+- GpgME::Error startPublicKeyExport(const char *pattern, Data &keyData);
+- GpgME::Error startPublicKeyExport(const char *pattern[], Data &keyData);
++ GpgME::Error exportPublicKeys(const char *pattern, Data &keyData, bool minimal=false);
++ GpgME::Error exportPublicKeys(const char *pattern[], Data &keyData, bool minimal=false);
++ GpgME::Error startPublicKeyExport(const char *pattern, Data &keyData, bool minimal=false);
++ GpgME::Error startPublicKeyExport(const char *pattern[], Data &keyData, bool minimal=false);
+
+ //
+ // Key Import
+--- lang/cpp/src/context.cpp.bak 2017-10-18 12:27:50.830978224 +0200
++++ lang/cpp/src/context.cpp 2017-10-18 12:30:13.278515603 +0200
+@@ -557,14 +557,14 @@
+ }
+ }
+
+-Error Context::exportPublicKeys(const char *pattern, Data &keyData)
++Error Context::exportPublicKeys(const char *pattern, Data &keyData, bool minimal)
+ {
+ d->lastop = Private::Export;
+ Data::Private *const dp = keyData.impl();
+- return Error(d->lasterr = gpgme_op_export(d->ctx, pattern, 0, dp ? dp->data : 0));
++ return Error(d->lasterr = gpgme_op_export(d->ctx, pattern, minimal ? GPGME_EXPORT_MODE_MINIMAL : 0, dp ? dp->data : 0));
+ }
+
+-Error Context::exportPublicKeys(const char *patterns[], Data &keyData)
++Error Context::exportPublicKeys(const char *patterns[], Data &keyData, bool minimal)
+ {
+ d->lastop = Private::Export;
+ #ifndef HAVE_GPGME_EXT_KEYLIST_MODE_EXTERNAL_NONBROKEN
+@@ -574,17 +574,17 @@
+ }
+ #endif
+ Data::Private *const dp = keyData.impl();
+- return Error(d->lasterr = gpgme_op_export_ext(d->ctx, patterns, 0, dp ? dp->data : 0));
++ return Error(d->lasterr = gpgme_op_export_ext(d->ctx, patterns, minimal ? GPGME_EXPORT_MODE_MINIMAL : 0, dp ? dp->data : 0));
+ }
+
+-Error Context::startPublicKeyExport(const char *pattern, Data &keyData)
++Error Context::startPublicKeyExport(const char *pattern, Data &keyData, bool minimal)
+ {
+ d->lastop = Private::Export;
+ Data::Private *const dp = keyData.impl();
+- return Error(d->lasterr = gpgme_op_export_start(d->ctx, pattern, 0, dp ? dp->data : 0));
++ return Error(d->lasterr = gpgme_op_export_start(d->ctx, pattern, minimal ? GPGME_EXPORT_MODE_MINIMAL : 0, dp ? dp->data : 0));
+ }
+
+-Error Context::startPublicKeyExport(const char *patterns[], Data &keyData)
++Error Context::startPublicKeyExport(const char *patterns[], Data &keyData, bool minimal)
+ {
+ d->lastop = Private::Export;
+ #ifndef HAVE_GPGME_EXT_KEYLIST_MODE_EXTERNAL_NONBROKEN
+@@ -594,7 +594,7 @@
+ }
+ #endif
+ Data::Private *const dp = keyData.impl();
+- return Error(d->lasterr = gpgme_op_export_ext_start(d->ctx, patterns, 0, dp ? dp->data : 0));
++ return Error(d->lasterr = gpgme_op_export_ext_start(d->ctx, patterns, minimal ? GPGME_EXPORT_MODE_MINIMAL : 0, dp ? dp->data : 0));
+ }
+
+ ImportResult Context::importKeys(const Data &data)
diff --git a/external/gpgmepp/find-libgpg-error-libassuan.patch b/external/gpgmepp/find-libgpg-error-libassuan.patch
new file mode 100644
index 000000000000..2ddd4d2f2e62
--- /dev/null
+++ b/external/gpgmepp/find-libgpg-error-libassuan.patch
@@ -0,0 +1,59 @@
+diff --git a/configure.ac b/configure.ac
+index f28480b..92a3e85 100644
+--- configure.ac
++++ configure.ac
+@@ -674,15 +674,34 @@ AC_CHECK_FUNCS(setlocale)
+
+ # Checking for libgpg-error.
+ have_gpg_error=no
+-AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
+- have_gpg_error=yes, have_gpg_error=no)
++if test "x${GPG_ERROR_CFLAGS}" = x; then
++ AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
++ have_gpg_error=yes, have_gpg_error=no)
++else
++ have_gpg_error=yes
++ GPG_ERROR_CFLAGS="$GPG_ERROR_CFLAGS"
++ GPG_ERROR_LIBS="$GPG_ERROR_LIBS"
++ AC_SUBST(GPG_ERROR_CFLAGS)
++ AC_SUBST(GPG_ERROR_LIBS)
++
++fi
++
+ AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
+ [The default error source for GPGME.])
+
+ # And for libassuan.
+ have_libassuan=no
+-AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
++if test "x${LIBASSUAN_CFLAGS}" = x; then
++ AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
+ have_libassuan=yes, have_libassuan=no)
++else
++ have_libassuan=yes
++ LIBASSUAN_CFLAGS="$LIBASSUAN_CFLAGS"
++ LIBASSUAN_LIBS="$LIBASSUAN_LIBS"
++ AC_SUBST(LIBASSUAN_CFLAGS)
++ AC_SUBST(LIBASSUAN_LIBS)
++fi
++
+ if test "$have_libassuan" = "yes"; then
+ AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version",
+ [version of the libassuan library])
+diff --git a/src/Makefile.am b/src/Makefile.am
+index ce6f1d4..6b1d835 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -97,10 +97,10 @@ endif
+
+ # We use a global CFLAGS setting for all library
+ # versions, because then every object file is only compiled once.
+-AM_CFLAGS = @LIBASSUAN_CFLAGS@ @GLIB_CFLAGS@
++AM_CFLAGS = @LIBASSUAN_CFLAGS@ @GPG_ERROR_CFLAGS@ @GLIB_CFLAGS@
+
+ gpgme_tool_SOURCES = gpgme-tool.c argparse.c argparse.h
+-gpgme_tool_LDADD = libgpgme.la @LIBASSUAN_LIBS@
++gpgme_tool_LDADD = libgpgme.la @LIBASSUAN_LIBS@ @GPG_ERROR_LIBS@
+
+
+ if HAVE_W32_SYSTEM
diff --git a/external/gpgmepp/fix-autoconf-macros.patch b/external/gpgmepp/fix-autoconf-macros.patch
new file mode 100644
index 000000000000..627c7b15247a
--- /dev/null
+++ b/external/gpgmepp/fix-autoconf-macros.patch
@@ -0,0 +1,39 @@
+diff -ur gpgme.org/configure.ac gpgme/configure.ac
+--- configure.ac 2017-02-16 15:18:45.051417378 +0100
++++ configure.ac~ 2017-02-16 15:20:03.635059285 +0100
+@@ -35,6 +35,11 @@
+ # decimalized short revision number, a beta version string, and a flag
+ # indicating a development version (mym4_isgit). Note that the m4
+ # processing is done by autoconf and not during the configure run.
++m4_define([m4_chomp_all],
++[m4_format([[%.*s]], m4_bregexp(m4_translit([[$1]], [
++/], [/ ]), [/*$]), [$1])])
++
++m4_define([m4_esyscmd_s], [m4_chomp_all(m4_esyscmd([$1]))])
+ m4_define(mym4_version,
+ [mym4_version_major.mym4_version_minor.mym4_version_micro])
+ m4_define([mym4_revision],
+@@ -90,7 +90,22 @@
+ AC_CONFIG_MACRO_DIR([m4])
+ AC_CONFIG_SRCDIR(src/gpgme.h.in)
+ AC_CONFIG_HEADER(config.h)
+-AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
++
++dnl Initialize automake. automake < 1.12 didn't have serial-tests and
++dnl gives an error if it sees this, but for automake >= 1.13
++dnl serial-tests is required so we have to include it. Solution is to
++dnl test for the version of automake (by running an external command)
++dnl and provide it if necessary. Note we have to do this entirely using
++dnl m4 macros since automake queries this macro by running
++dnl 'autoconf --trace ...'.
++m4_define([serial_tests], [
++ m4_esyscmd([automake --version |
++ head -1 |
++ awk '{split ($NF,a,"."); if (a[1] == 1 && a[2] >= 12) { print "serial-tests" }}'
++ ])
++])
++AM_INIT_AUTOMAKE(foreign serial_tests dist-bzip2 no-dist-gzip) dnl NB: Do not [quote] this parameter.
++
+ AM_MAINTAINER_MODE
+ AC_CANONICAL_HOST
+ AM_SILENT_RULES
diff --git a/external/gpgmepp/w32-build-fixes.patch.1 b/external/gpgmepp/w32-build-fixes.patch.1
new file mode 100644
index 000000000000..9bc8f52b4c64
--- /dev/null
+++ b/external/gpgmepp/w32-build-fixes.patch.1
@@ -0,0 +1,133 @@
+diff -ru gpgme.orig/m4/ax_cxx_compile_stdcxx.m4 gpgme/m4/ax_cxx_compile_stdcxx.m4
+--- gpgme.orig/m4/ax_cxx_compile_stdcxx.m4 2016-05-27 22:04:36.000000000 +0200
++++ gpgme/m4/ax_cxx_compile_stdcxx.m4 2017-09-29 17:34:49.795243600 +0200
+@@ -156,7 +156,7 @@
+
+ #error "This is not a C++ compiler"
+
+-#elif __cplusplus < 201103L
++#elif __cplusplus < 201103L && !(defined _MSC_VER)
+
+ #error "This is not a C++11 compiler"
+
+diff -ru gpgme.orig/src/dirinfo.c gpgme/src/dirinfo.c
+--- gpgme.orig/src/dirinfo.c 2017-03-21 11:09:41.000000000 +0100
++++ gpgme/src/dirinfo.c 2017-09-30 08:36:13.239279300 +0200
+@@ -33,6 +33,10 @@
+
+ DEFINE_STATIC_LOCK (dirinfo_lock);
+
++#ifndef F_OK
++#define F_OK 0
++#endif
++
+ /* Constants used internally to select the data. */
+ enum
+ {
+diff -ru gpgme.orig/src/mbox-util.c gpgme/src/mbox-util.c
+--- gpgme.orig/src/mbox-util.c 2016-11-16 13:22:41.000000000 +0100
++++ gpgme/src/mbox-util.c 2017-09-30 08:18:29.270567500 +0200
+@@ -28,7 +28,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if HAVE_UNISTD_H
+ #include <unistd.h>
++#endif
+ #include <errno.h>
+
+ #include "mbox-util.h"
+diff -ru gpgme.orig/src/priv-io.h gpgme/src/priv-io.h
+--- gpgme.orig/src/priv-io.h 2016-11-16 13:23:14.000000000 +0100
++++ gpgme/src/priv-io.h 2017-09-30 08:20:38.770562400 +0200
+@@ -36,6 +36,9 @@
+ #ifdef HAVE_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
++#if _MSC_VER
++typedef int pid_t;
++#endif
+
+
+ /* A single file descriptor passed to spawn. For child fds, dup_to
+diff -ru gpgme.orig/src/util.h gpgme/src/util.h
+--- gpgme.orig/src/util.h 2017-03-28 11:41:30.000000000 +0200
++++ gpgme/src/util.h 2017-09-30 08:10:54.194049100 +0200
+@@ -39,6 +39,9 @@
+ #ifdef HAVE_UNISTD_H
+ # include <unistd.h>
+ #endif
++#ifdef _MSC_VER
++typedef int pid_t;
++#endif
+
+ #include "gpgme.h"
+
+diff -ru gpgme.orig/src/w32-util.c gpgme/src/w32-util.c
+--- gpgme.orig/src/w32-util.c 2017-03-09 09:01:10.000000000 +0100
++++ gpgme/src/w32-util.c 2017-09-30 08:32:02.114330500 +0200
+@@ -721,7 +721,8 @@
+ v /= 62;
+ XXXXXX[5] = letters[v % 62];
+
+- fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
++ //fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
++ fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL);
+ if (fd >= 0)
+ {
+ gpg_err_set_errno (save_errno);
+diff -ru gpgme.orig/src/Makefile.am gpgme/src/Makefile.am
+--- gpgme.orig/src/Makefile.am 2017-09-30 11:50:07.456960000 +0200
++++ gpgme/src/Makefile.am 2017-09-30 11:51:29.609649400 +0200
+@@ -26,7 +26,7 @@
+ m4data_DATA = gpgme.m4
+ nodist_include_HEADERS = gpgme.h
+
+-bin_PROGRAMS = gpgme-tool
++bin_PROGRAMS =
+
+ if BUILD_W32_GLIB
+ ltlib_gpgme_glib = libgpgme-glib.la
+@@ -99,8 +99,8 @@
+ # versions, because then every object file is only compiled once.
+ AM_CFLAGS = @LIBASSUAN_CFLAGS@ @GPG_ERROR_CFLAGS@ @GLIB_CFLAGS@
+
+-gpgme_tool_SOURCES = gpgme-tool.c argparse.c argparse.h
+-gpgme_tool_LDADD = libgpgme.la @LIBASSUAN_LIBS@ @GPG_ERROR_LIBS@
++gpgme_tool_SOURCES =
++gpgme_tool_LDADD =
+
+
+ if HAVE_W32_SYSTEM
+@@ -120,7 +120,7 @@
+ SUFFIXES = .rc .lo
+
+ .rc.lo:
+- $(LTRCCOMPILE) -i "$<" -o "$@"
++ $(LTRCCOMPILE) -i $< -o $@
+
+ gpgme_res = versioninfo.lo
+ no_undefined = -no-undefined
+diff -ru gpgme.orig/src/vfs-mount.c gpgme/src/vfs-mount.c
+--- gpgme.orig/src/vfs-mount.c 2017-03-09 09:01:10.000000000 +0100
++++ gpgme/src/vfs-mount.c 2017-09-30 13:10:51.845807600 +0200
+@@ -68,7 +68,7 @@
+ if (err)
+ return err;
+
+- if (! strcasecmp ("MOUNTPOINT", code))
++ if (! _stricmp ("MOUNTPOINT", code))
+ {
+ if (opd->result.mount_dir)
+ free (opd->result.mount_dir);
+diff -ur gpgmepp.org/src/w32-glib-io.c gpgmepp/src/w32-glib-io.c
+--- gpgmepp.org/src/w32-glib-io.c 2016-11-16 13:22:41.000000000 +0100
++++ gpgmepp/src/w32-glib-io.c 2017-11-20 06:40:44.793945300 +0100
+@@ -37,6 +37,7 @@
+ #ifdef HAVE_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
++#include <winsock2.h>
+ #include <glib.h>
+ #include <windows.h>
+ #include <io.h>
diff --git a/external/gpgmepp/w32-disable-docs.patch.1 b/external/gpgmepp/w32-disable-docs.patch.1
new file mode 100644
index 000000000000..603122131ea3
--- /dev/null
+++ b/external/gpgmepp/w32-disable-docs.patch.1
@@ -0,0 +1,15 @@
+Disable doc building the hard way - should rather be a config option
+like libgpg-error's --disable-doc
+
+diff -ur gpgmepp.org/Makefile.am gpgmepp/Makefile.am
+--- gpgmepp.org/Makefile.am 2016-11-16 13:20:18.000000000 +0100
++++ gpgmepp/Makefile.am 2017-11-20 15:34:49.086731000 +0100
+@@ -33,7 +33,7 @@
+ tests =
+ endif
+
+-SUBDIRS = src ${tests} doc lang
++SUBDIRS = src ${tests} lang
+
+ # Fix the version of the spec file and create a file named VERSION
+ # to be used for patch's Prereq: feature.
diff --git a/external/gpgmepp/w32-fix-libtool.patch.1 b/external/gpgmepp/w32-fix-libtool.patch.1
new file mode 100644
index 000000000000..9a7adf713694
--- /dev/null
+++ b/external/gpgmepp/w32-fix-libtool.patch.1
@@ -0,0 +1,38 @@
+Gross hack to make libtool work with gcc-wrapper - frontended
+link.exe on Windows. Make libtool ignore all libs & simply pass
+them on as-is to the linker
+
+A proper fix would be to make gcc-wrapper behave like gcc during
+linking, by accepting cygwin path names, and correctly expanding
+-l<short_lib_name> to lib<short_lib_name>.lib
+
+diff -ur gpgmepp.org/m4/libtool.m4 gpgmepp/m4/libtool.m4
+--- gpgmepp.org/m4/libtool.m4 2016-11-16 13:20:16.000000000 +0100
++++ gpgmepp/m4/libtool.m4 2017-11-21 22:00:05.006587800 +0100
+@@ -3209,24 +3209,11 @@
+ ;;
+
+ cygwin*)
+- # func_win32_libid is a shell function defined in ltmain.sh
+- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+- lt_cv_file_magic_cmd='func_win32_libid'
++ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+ mingw* | pw32*)
+- # Base MSYS/MinGW do not provide the 'file' command needed by
+- # func_win32_libid shell function, so use a weaker test based on 'objdump',
+- # unless we find 'file', for example because we are cross-compiling.
+- # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+- if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+- lt_cv_file_magic_cmd='func_win32_libid'
+- else
+- # Keep this pattern in sync with the one in func_win32_libid.
+- lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+- lt_cv_file_magic_cmd='$OBJDUMP -f'
+- fi
++ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+ cegcc*)
diff --git a/external/gpgmepp/w32-fix-win32-macro.patch.1 b/external/gpgmepp/w32-fix-win32-macro.patch.1
new file mode 100644
index 000000000000..70a8b5ffe6e8
--- /dev/null
+++ b/external/gpgmepp/w32-fix-win32-macro.patch.1
@@ -0,0 +1,175 @@
+diff -ur gpgmepp.org/lang/cpp/src/callbacks.cpp gpgmepp/lang/cpp/src/callbacks.cpp
+--- gpgmepp.org/lang/cpp/src/callbacks.cpp 2016-10-18 19:22:02.000000000 +0200
++++ gpgmepp/lang/cpp/src/callbacks.cpp 2017-11-20 18:03:04.290060900 +0100
+@@ -38,7 +38,9 @@
+ #include <cassert>
+ #include <cerrno>
+ #include <cstring>
++#if HAVE_UNISTD_H
+ #include <unistd.h>
++#endif
+ #include <stdlib.h>
+
+ static inline gpgme_error_t make_err_from_syserror()
+diff -ur gpgmepp.org/lang/cpp/src/data.h gpgmepp/lang/cpp/src/data.h
+--- gpgmepp.org/lang/cpp/src/data.h 2017-03-24 15:20:32.000000000 +0100
++++ gpgmepp/lang/cpp/src/data.h 2017-11-20 17:23:24.802711200 +0100
+@@ -31,6 +31,11 @@
+ #include <algorithm>
+ #include <memory>
+
++#ifdef _MSC_VER
++# include <BaseTsd.h>
++typedef SSIZE_T ssize_t;
++#endif
++
+ namespace GpgME
+ {
+
+diff -ur gpgmepp.org/lang/cpp/src/editinteractor.cpp gpgmepp/lang/cpp/src/editinteractor.cpp
+--- gpgmepp.org/lang/cpp/src/editinteractor.cpp 2017-03-09 09:01:10.000000000 +0100
++++ gpgmepp/lang/cpp/src/editinteractor.cpp 2017-11-20 18:09:33.022674700 +0100
+@@ -30,9 +30,11 @@
+
+ #include <gpgme.h>
+
+-#ifdef _WIN32
++#ifdef _MSC_VER
+ # include <io.h>
+-#include <windows.h>
++# include <windows.h>
++# include <BaseTsd.h>
++ typedef SSIZE_T ssize_t;
+ #else
+ # include <unistd.h>
+ #endif
+diff -ur gpgmepp.org/lang/cpp/src/gpgmepp_export.h gpgmepp/lang/cpp/src/gpgmepp_export.h
+--- gpgmepp.org/lang/cpp/src/gpgmepp_export.h 2016-08-04 15:03:09.000000000 +0200
++++ gpgmepp/lang/cpp/src/gpgmepp_export.h 2017-11-20 16:57:47.805691100 +0100
+@@ -29,14 +29,14 @@
+ # ifndef GPGMEPP_EXPORT
+ # ifdef BUILDING_GPGMEPP
+ /* We are building this library */
+-# ifdef WIN32
++# ifdef _MSC_VER
+ # define GPGMEPP_EXPORT __declspec(dllexport)
+ # else
+ # define GPGMEPP_EXPORT __attribute__((visibility("default")))
+ # endif
+ # else
+ /* We are using this library */
+-# ifdef WIN32
++# ifdef _MSC_VER
+ # define GPGMEPP_EXPORT __declspec(dllimport)
+ # else
+ # define GPGMEPP_EXPORT __attribute__((visibility("default")))
+@@ -45,7 +45,7 @@
+ # endif
+
+ # ifndef GPGMEPP_NO_EXPORT
+-# ifdef WIN32
++# ifdef _MSC_VER
+ # define GPGMEPP_NO_EXPORT
+ # else
+ # define GPGMEPP_NO_EXPORT __attribute__((visibility("hidden")))
+@@ -54,7 +54,11 @@
+ #endif
+
+ #ifndef GPGMEPP_DEPRECATED
+-# define GPGMEPP_DEPRECATED __attribute__ ((__deprecated__))
++# ifdef _MSC_VER
++# define GPGMEPP_DEPRECATED __declspec(deprecated("deprecated"))
++# else
++# define GPGMEPP_DEPRECATED __attribute__ ((__deprecated__))
++# endif
+ #endif
+
+ #ifndef GPGMEPP_DEPRECATED_EXPORT
+diff -ur gpgmepp.org/lang/cpp/src/interfaces/dataprovider.h gpgmepp/lang/cpp/src/interfaces/dataprovider.h
+--- gpgmepp.org/lang/cpp/src/interfaces/dataprovider.h 2016-05-17 14:32:37.000000000 +0200
++++ gpgmepp/lang/cpp/src/interfaces/dataprovider.h 2017-11-20 18:03:11.332715700 +0100
+@@ -29,6 +29,11 @@
+
+ #include <gpg-error.h>
+
++#ifdef _MSC_VER
++# include <BaseTsd.h>
++typedef SSIZE_T ssize_t;
++#endif
++
+ namespace GpgME
+ {
+
+diff -ur gpgmepp.org/lang/cpp/src/key.cpp gpgmepp/lang/cpp/src/key.cpp
+--- gpgmepp.org/lang/cpp/src/key.cpp 2017-03-20 20:10:15.000000000 +0100
++++ gpgmepp/lang/cpp/src/key.cpp 2017-11-20 17:44:50.321858800 +0100
+@@ -33,10 +33,16 @@
+ #include <gpgme.h>
+
+ #include <string.h>
++#if HAVE_STRINGS_H
+ #include <strings.h>
++#endif
+ #include <istream>
+ #include <iterator>
+
++#ifdef _MSC_VER
++# define strcasecmp _stricmp
++#endif
++
+ const GpgME::Key::Null GpgME::Key::null;
+
+ namespace GpgME
+diff -ur gpgmepp.org/lang/cpp/src/key.h gpgmepp/lang/cpp/src/key.h
+--- gpgmepp.org/lang/cpp/src/key.h 2017-03-20 20:10:15.000000000 +0100
++++ gpgmepp/lang/cpp/src/key.h 2017-11-20 17:07:51.551632000 +0100
+@@ -30,7 +30,6 @@
+ #include "gpgmefw.h"
+
+ #include <memory>
+-#include <sys/time.h>
+
+ #include <vector>
+ #include <algorithm>
+diff -ur gpgmepp.org/lang/qt/src/qgpgme_export.h gpgmepp/lang/qt/src/qgpgme_export.h
+--- gpgmepp.org/lang/qt/src/qgpgme_export.h 2016-11-03 17:32:30.000000000 +0100
++++ gpgmepp/lang/qt/src/qgpgme_export.h 2017-11-20 16:58:27.395388000 +0100
+@@ -39,14 +39,14 @@
+ # ifndef QGPGME_EXPORT
+ # ifdef BUILDING_QGPGME
+ /* We are building this library */
+-# ifdef WIN32
++# ifdef _WIN32
+ # define QGPGME_EXPORT __declspec(dllexport)
+ # else
+ # define QGPGME_EXPORT __attribute__((visibility("default")))
+ # endif
+ # else
+ /* We are using this library */
+-# ifdef WIN32
++# ifdef _WIN32
+ # define QGPGME_EXPORT __declspec(dllimport)
+ # else
+ # define QGPGME_EXPORT __attribute__((visibility("default")))
+@@ -55,7 +55,7 @@
+ # endif
+
+ # ifndef QGPGME_NO_EXPORT
+-# ifdef WIN32
++# ifdef _WIN32
+ # define QGPGME_NO_EXPORT
+ # else
+ # define QGPGME_NO_EXPORT __attribute__((visibility("hidden")))
+@@ -64,7 +64,11 @@
+ #endif
+
+ #ifndef QGPGME_DEPRECATED
+-# define QGPGME_DEPRECATED __attribute__ ((__deprecated__))
++# ifdef _MSC_VER
++# define QGPGME_DEPRECATED __declspec(deprecated("deprecated"))
++# else
++# define QGPGME_DEPRECATED __attribute__ ((__deprecated__))
++# endif
+ #endif
+
+ #ifndef QGPGME_DEPRECATED_EXPORT