From 4be15fdd7974564faa97454fda415b3882c4142f Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Wed, 22 Feb 2017 01:47:15 +0100 Subject: gpg4libre: build libgpg-error natively on windows Change-Id: I479b79a7626469169af582dc79c4e99dc4620546 Reviewed-on: https://gerrit.libreoffice.org/34530 Reviewed-by: Siegmund Gorr Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens --- configure.ac | 2 + .../libgpg-error/ExternalProject_libgpg-error.mk | 21 +++ .../libgpg-error/UnpackedTarball_libgpg-error.mk | 3 + external/libgpg-error/w32-build-fixes-2.patch.1 | 31 ++++ external/libgpg-error/w32-build-fixes-3.patch.1 | 57 ++++++ external/libgpg-error/w32-build-fixes.patch | 206 +++++++++++++++++++++ 6 files changed, 320 insertions(+) create mode 100755 external/libgpg-error/w32-build-fixes-2.patch.1 create mode 100755 external/libgpg-error/w32-build-fixes-3.patch.1 create mode 100644 external/libgpg-error/w32-build-fixes.patch diff --git a/configure.ac b/configure.ac index e634474cffb8..fe5731470d2e 100644 --- a/configure.ac +++ b/configure.ac @@ -10159,6 +10159,8 @@ if test "$_os" = "Linux" -o "$_os" = "Darwin"; then LIBASSUAN_CFLAGS="-I${WORKDIR}/UnpackedTarball/libassuan/src" LIBASSUAN_LIBS="-L${WORKDIR}/UnpackedTarball/libassuan/src/.libs -lassuan" fi +else + BUILD_TYPE="$BUILD_TYPE LIBGPGERROR" fi AC_SUBST(SYSTEM_GPGMEPP) AC_SUBST(GPG_ERROR_CFLAGS) diff --git a/external/libgpg-error/ExternalProject_libgpg-error.mk b/external/libgpg-error/ExternalProject_libgpg-error.mk index 34a87c546f4e..ef22e3926b69 100644 --- a/external/libgpg-error/ExternalProject_libgpg-error.mk +++ b/external/libgpg-error/ExternalProject_libgpg-error.mk @@ -15,17 +15,38 @@ $(eval $(call gb_ExternalProject_register_targets,libgpg-error,\ $(eval $(call gb_ExternalProject_use_autoconf,libgpg-error,build)) +ifeq ($(COM),MSC) $(call gb_ExternalProject_get_state_target,libgpg-error,build): $(call gb_ExternalProject_run,build,\ MAKE=$(MAKE) ./configure \ + --enable-static \ + --disable-shared \ --disable-rpath \ --disable-languages \ --disable-doc \ + --disable-tests \ $(if $(filter LINUX,$(OS)), \ 'LDFLAGS=-Wl$(COMMA)-z$(COMMA)origin \ -Wl$(COMMA)-rpath$(COMMA)\$$$$ORIGIN') \ + --host=$(if $(filter INTEL,$(CPUNAME)),i686-mingw32,x86_64-w64-mingw32) \ + && $(MAKE) \ + ) + +else +$(call gb_ExternalProject_get_state_target,libgpg-error,build): + $(call gb_ExternalProject_run,build,\ + MAKE=$(MAKE) ./configure \ + --disable-rpath \ + --disable-languages \ + --disable-doc \ + $(if $(filter LINUX,$(OS)), \ + 'LDFLAGS=-Wl$(COMMA)-z$(COMMA)origin \ + -Wl$(COMMA)-rpath$(COMMA)\$$$$ORIGIN') \ + CPPFLAGS=" $(SOLARINC)" \ + $(if $(filter MSC,$(COM)),--force_use_syscfg=true) \ $(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \ && $(MAKE) \ ) +endif # vim: set noet sw=4 ts=4: diff --git a/external/libgpg-error/UnpackedTarball_libgpg-error.mk b/external/libgpg-error/UnpackedTarball_libgpg-error.mk index 8ac6cf77a560..2d662f4161d2 100644 --- a/external/libgpg-error/UnpackedTarball_libgpg-error.mk +++ b/external/libgpg-error/UnpackedTarball_libgpg-error.mk @@ -15,6 +15,9 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libgpg-error,0)) $(eval $(call gb_UnpackedTarball_add_patches,libgpg-error, \ external/libgpg-error/disable-rpath-option.patch \ + $(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-build-fixes-3.patch.1) \ )) # vim: set noet sw=4 ts=4: 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 100755 index 000000000000..3d9c4324a89c --- /dev/null +++ b/external/libgpg-error/w32-build-fixes-2.patch.1 @@ -0,0 +1,31 @@ +diff -ru libgpg-error.orig/src/Makefile.in libgpg-error/src/Makefile.in +--- libgpg-error.orig/src/Makefile.in 2017-09-12 08:18:29.376536700 +0200 ++++ libgpg-error/src/Makefile.in 2017-09-12 08:57:11.648083800 +0200 +@@ -512,8 +512,7 @@ + @HAVE_W32_SYSTEM_TRUE@arch_sources = w32-gettext.c w32-lock.c w32-lock-obj.h w32-thread.c \ + @HAVE_W32_SYSTEM_TRUE@ w32-iconv.c w32-estream.c + +-@HAVE_W32_SYSTEM_TRUE@RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ +-@HAVE_W32_SYSTEM_TRUE@ -DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS) ++@HAVE_W32_SYSTEM_TRUE@RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) -DLOCALEDIR=$(localedir) $(AM_CPPFLAGS) + + @HAVE_W32_SYSTEM_TRUE@LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE) + @HAVE_W32_SYSTEM_TRUE@SUFFIXES = .rc .lo +@@ -1242,7 +1241,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 + +@@ -1283,7 +1282,7 @@ + # It is correct to use $(CPP). We want the host's idea of the error codes. + mkerrcodes.h: Makefile mkerrcodes.awk $(gpg_extra_headers) + $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@ +- $(CPP) $(CPPFLAGS) $(extra_cppflags) -P _$@ | grep GPG_ERR_ | \ ++ $(CPP) $(CPPFLAGS) $(extra_cppflags) _$@ | grep GPG_ERR_ | \ + $(AWK) -f $(srcdir)/mkerrcodes.awk >$@ + -rm _$@ + diff --git a/external/libgpg-error/w32-build-fixes-3.patch.1 b/external/libgpg-error/w32-build-fixes-3.patch.1 new file mode 100755 index 000000000000..5883211f9570 --- /dev/null +++ b/external/libgpg-error/w32-build-fixes-3.patch.1 @@ -0,0 +1,57 @@ +diff -ru libgpg-error.orig/src/gpg-error.c libgpg-error/src/gpg-error.c +--- libgpg-error.orig/src/gpg-error.c 2016-12-02 22:55:32.000000000 +0100 ++++ libgpg-error/src/gpg-error.c 2017-09-13 22:25:10.040113800 +0200 +@@ -206,7 +206,7 @@ + static const char src_prefix[] = "GPG_ERR_SOURCE_"; + static const char code_prefix[] = "GPG_ERR_"; + +- if (!strncasecmp (src_prefix, str, sizeof (src_prefix) - 1)) ++ if (!_strnicmp (src_prefix, str, sizeof (src_prefix) - 1)) + { + gpg_err_source_t src; + +@@ -220,14 +220,14 @@ + const char *src_sym; + + src_sym = gpg_strsource_sym (src << GPG_ERR_SOURCE_SHIFT); +- if (src_sym && !strcasecmp (str, src_sym + sizeof (src_prefix) - 1)) ++ if (src_sym && !_stricmp (str, src_sym + sizeof (src_prefix) - 1)) + { + *err |= src << GPG_ERR_SOURCE_SHIFT; + return 1; + } + } + } +- else if (!strncasecmp (code_prefix, str, sizeof (code_prefix) - 1)) ++ else if (!_strnicmp (code_prefix, str, sizeof (code_prefix) - 1)) + { + gpg_err_code_t code; + +@@ -240,7 +240,7 @@ + { + const char *code_sym = gpg_strerror_sym (code); + if (code_sym +- && !strcasecmp (str, code_sym + sizeof (code_prefix) - 1)) ++ && !_stricmp (str, code_sym + sizeof (code_prefix) - 1)) + { + *err |= code; + return 1; +@@ -296,7 +296,7 @@ + for (src = 0; src < GPG_ERR_SOURCE_DIM; src++) + { + const char *src_str = gpg_strsource (src << GPG_ERR_SOURCE_SHIFT); +- if (src_str && !strcasecmp (str, src_str)) ++ if (src_str && !_stricmp (str, src_str)) + { + if (*have_source) + return 0; +@@ -310,7 +310,7 @@ + for (code = 0; code < GPG_ERR_CODE_DIM; code++) + { + const char *code_str = gpg_strerror (code); +- if (code_str && !strcasecmp (str, code_str)) ++ if (code_str && !_stricmp (str, code_str)) + { + if (*have_code) + return 0; +Nur in libgpg-error/src: gpg-error.c~. diff --git a/external/libgpg-error/w32-build-fixes.patch b/external/libgpg-error/w32-build-fixes.patch new file mode 100644 index 000000000000..e8a6b6145d46 --- /dev/null +++ b/external/libgpg-error/w32-build-fixes.patch @@ -0,0 +1,206 @@ +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 + #endif + #include +-#include ++/*#include */ + #include + #include + #include + #include +-#include ++#ifdef _WIN32 ++# include ++#else ++# include ++#endif + #include + #include + #include +@@ -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 + #include + #include +-#include ++#ifdef _WIN32 ++# include ++#else ++# include ++#endif + #include + #include + #include +--- src/Makefile.am 2017-02-28 13:33:38.000000000 +0100 ++++ src/Makefile.am~ 2017-09-10 21:52:19.739988146 +0200 +@@ -99,9 +99,9 @@ + + CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ + gpg-error.h gpgrt.h \ +- mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ ++ mkerrcodes.exe mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ + mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \ +- gpg-extra/errno.h mkheader $(tmp_files) lock-obj-pub.native.h ++ gpg-extra/errno.h mkheader.exe $(tmp_files) lock-obj-pub.native.h + + + # +@@ -251,7 +251,7 @@ + + # It is correct to use $(CC_FOR_BUILD) here. We want to run the + # program at build time. +-mkerrcodes: mkerrcodes.c mkerrcodes.h Makefile ++mkerrcodes.exe: mkerrcodes.c mkerrcodes.h Makefile + $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c + + if HAVE_W32CE_SYSTEM +@@ -261,7 +261,7 @@ + $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkw32errmap.c + endif + +-code-from-errno.h: mkerrcodes Makefile ++code-from-errno.h: mkerrcodes.exe Makefile + ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@ + + errnos-sym.h: Makefile mkstrtable.awk errnos.in +@@ -270,7 +270,7 @@ + $(srcdir)/errnos.in >$@ + + +-mkheader: mkheader.c Makefile ++mkheader.exe: mkheader.c Makefile + $(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c + + parts_of_gpg_error_h = \ +@@ -297,7 +297,7 @@ + + # We also depend on versioninfo.rc because that is build by + # config.status and thus has up-to-date version numbers. +-gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) \ ++gpg-error.h: Makefile mkheader.exe $(parts_of_gpg_error_h) \ + versioninfo.rc ../config.h + $(pre_mkheader_cmds) + ./mkheader $(host_os) $(host_triplet) $(srcdir)/gpg-error.h.in \ +diff -ru libgpg-error.orig/src/Makefile.in libgpg-error/src/Makefile.in +--- src/Makefile.in 2017-02-28 15:03:41.000000000 +0100 ++++ src/Makefile.in~ 2017-09-10 21:53:48.447987149 +0200 +@@ -493,9 +493,9 @@ + tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c + CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ + gpg-error.h gpgrt.h \ +- mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ ++ mkerrcodes.exe mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ + mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \ +- gpg-extra/errno.h mkheader $(tmp_files) lock-obj-pub.native.h ++ gpg-extra/errno.h mkheader.exe $(tmp_files) lock-obj-pub.native.h + + + # +@@ -1309,7 +1309,7 @@ + + # It is correct to use $(CC_FOR_BUILD) here. We want to run the + # program at build time. +-mkerrcodes: mkerrcodes.c mkerrcodes.h Makefile ++mkerrcodes.exe: mkerrcodes.c mkerrcodes.h Makefile + $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c + + # It is correct to use $(CC_FOR_BUILD) here. We want to run the +@@ -1317,7 +1317,7 @@ + @HAVE_W32CE_SYSTEM_TRUE@mkw32errmap: mkw32errmap.c mkw32errmap.tab.h Makefile + @HAVE_W32CE_SYSTEM_TRUE@ $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkw32errmap.c + +-code-from-errno.h: mkerrcodes Makefile ++code-from-errno.h: mkerrcodes.exe Makefile + ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@ + + errnos-sym.h: Makefile mkstrtable.awk errnos.in +@@ -1325,7 +1325,7 @@ + -v prefix=GPG_ERR_ -v namespace=errnos_ \ + $(srcdir)/errnos.in >$@ + +-mkheader: mkheader.c Makefile ++mkheader.exe: mkheader.c Makefile + $(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c + + @FORCE_USE_SYSCFG_FALSE@./lock-obj-pub.native.h: Makefile gen-posix-lock-obj$(EXEEXT) posix-lock-obj.h +@@ -1333,7 +1333,7 @@ + + # We also depend on versioninfo.rc because that is build by + # config.status and thus has up-to-date version numbers. +-gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) \ ++gpg-error.h: Makefile mkheader.exe $(parts_of_gpg_error_h) \ + versioninfo.rc ../config.h + $(pre_mkheader_cmds) + ./mkheader $(host_os) $(host_triplet) $(srcdir)/gpg-error.h.in \ +--- 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 + #include + #include +-#include ++#ifdef _WIN32 ++# include ++#else ++# include ++#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 -- cgit v1.2.3