summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuintus <quintus@quintilianus.eu>2016-07-29 19:41:49 (GMT)
committerQuintus <quintus@quintilianus.eu>2016-07-29 19:41:49 (GMT)
commite6b7de09f654cce6a1c20518dddc5c2e660217d3 (patch)
tree17b8b2ce56b41a4ec1edf3afddf421e46a744195 /src
parent8737985c5fe09c2e46fe01cdc50db2efcc3292d1 (diff)
parentd6349ea72a222a10f4c13fed33ff5764239836ab (diff)
downloadmxe-e6b7de09f654cce6a1c20518dddc5c2e660217d3.zip
mxe-e6b7de09f654cce6a1c20518dddc5c2e660217d3.tar.gz
mxe-e6b7de09f654cce6a1c20518dddc5c2e660217d3.tar.bz2
Merge remote-tracking branch 'upstream/master' into cegui-0.8
Diffstat (limited to 'src')
-rw-r--r--src/aubio.mk1
-rw-r--r--src/djvulibre-1-fixes.patch51
-rw-r--r--src/djvulibre-test.c17
-rw-r--r--src/djvulibre.mk33
-rw-r--r--src/ghostscript-1-fixes.patch1389
-rw-r--r--src/ghostscript-test.c46
-rw-r--r--src/ghostscript.mk76
-rw-r--r--src/libspectre-1-fixes.patch50
-rw-r--r--src/libspectre-test.c23
-rw-r--r--src/libspectre.mk32
-rw-r--r--src/ocaml-camlimages-1-fixes.patch126
-rw-r--r--src/poppler-1-win32.patch26
12 files changed, 1819 insertions, 51 deletions
diff --git a/src/aubio.mk b/src/aubio.mk
index df05acb..0a32734 100644
--- a/src/aubio.mk
+++ b/src/aubio.mk
@@ -28,6 +28,7 @@ define $(PKG)_BUILD
--with-target-platform='win$(BITS)' \
--prefix='$(PREFIX)/$(TARGET)' \
--enable-fftw3f \
+ --libdir='$(PREFIX)/$(TARGET)/lib' \
$(if $(BUILD_STATIC), \
--enable-static --disable-shared --disable-jack, \
--disable-static --enable-shared)
diff --git a/src/djvulibre-1-fixes.patch b/src/djvulibre-1-fixes.patch
new file mode 100644
index 0000000..d62bd8a
--- /dev/null
+++ b/src/djvulibre-1-fixes.patch
@@ -0,0 +1,51 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains ad hoc patches for cross building.
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: darealshinji <djcj@gmx.de>
+Date: Sun, 24 Jul 2016 09:33:22 +0200
+Subject: [PATCH] define XXX_EXPORT symbols
+
+
+diff --git a/libdjvu/Makefile.am b/libdjvu/Makefile.am
+index 1111111..2222222 100644
+--- a/libdjvu/Makefile.am
++++ b/libdjvu/Makefile.am
+@@ -33,6 +33,8 @@ libdjvulibre_la_LIBADD = $(JPEG_LIBS) $(PTHREAD_LIBS)
+ libdjvulibre_la_LDFLAGS = -no-undefined -version-info $(version_info)
+
+ if HAVE_OS_WIN32
++libdjvulibre_la_CPPFLAGS += -DDJVUAPI_EXPORT
++libdjvulibre_la_CPPFLAGS += -DDDJVUAPI_EXPORT -DMINILISPAPI_EXPORT
+ libdjvulibre_la_LDFLAGS += -Wl,--export-all-symbols
+ endif
+
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: darealshinji <djcj@gmx.de>
+Date: Sun, 24 Jul 2016 09:36:49 +0200
+Subject: [PATCH] disable unknown pragma warnings
+
+
+diff --git a/libdjvu/miniexp.cpp b/libdjvu/miniexp.cpp
+index 1111111..2222222 100644
+--- a/libdjvu/miniexp.cpp
++++ b/libdjvu/miniexp.cpp
+@@ -382,6 +382,7 @@ static void NTAPI gctls_cb(PVOID, DWORD dwReason, PVOID) {
+ {CSLOCK(r);TlsFree(tlsIndex);tlsIndex=TLS_OUT_OF_INDEXES;}
+ }
+ # endif
++#ifndef __GNUC__
+ // -- Very black magic to clean tls variables.
+ # ifdef _M_IX86
+ # pragma comment (linker, "/INCLUDE:_tlscb")
+@@ -391,6 +392,7 @@ static void NTAPI gctls_cb(PVOID, DWORD dwReason, PVOID) {
+ # pragma const_seg(".CRT$XLB")
+ extern "C" PIMAGE_TLS_CALLBACK tlscb = gctls_cb;
+ # pragma const_seg()
++#endif /* !__GNUC__ */
+
+ #else
+ // No threads
diff --git a/src/djvulibre-test.c b/src/djvulibre-test.c
new file mode 100644
index 0000000..51889a2
--- /dev/null
+++ b/src/djvulibre-test.c
@@ -0,0 +1,17 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <libdjvu/ddjvuapi.h>
+
+int main(int argc, char *argv[])
+{
+ ddjvu_context_t *djvu_test;
+ (void)argc;
+
+ djvu_test = ddjvu_context_create(argv[0]);
+ ddjvu_context_release(djvu_test);
+
+ return 0;
+}
diff --git a/src/djvulibre.mk b/src/djvulibre.mk
new file mode 100644
index 0000000..5e3fc5b
--- /dev/null
+++ b/src/djvulibre.mk
@@ -0,0 +1,33 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG := djvulibre
+$(PKG)_VERSION := 3.5.27
+$(PKG)_CHECKSUM := e69668252565603875fb88500cde02bf93d12d48a3884e472696c896e81f505f
+$(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL := http://$(SOURCEFORGE_MIRROR)/project/djvu/DjVuLibre/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS := gcc jpeg tiff zlib
+
+define $(PKG)_UPDATE
+ $(WGET) -q -O- 'http://sourceforge.net/projects/djvu/files/DjVuLibre/' | \
+ $(SED) -n 's,.*/\([0-9][^A-Za-z"]*\)/".*,\1,p' | \
+ head -1
+endef
+
+# can't build a working static library for now
+# https://sourceforge.net/p/djvu/bugs/274/
+define $(PKG)_BUILD_SHARED
+ cd '$(SOURCE_DIR)' && autoreconf -fi
+ cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \
+ $(MXE_CONFIGURE_OPTS) \
+ --disable-desktopfiles
+ $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
+ $(MAKE) -C '$(BUILD_DIR)' -j 1 install-strip \
+ $(MXE_DISABLE_CRUFT) dist_bin_SCRIPTS=
+
+ '$(TARGET)-g++' \
+ -W -Wall -Werror -pedantic \
+ '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
+ `'$(TARGET)-pkg-config' ddjvuapi --cflags --libs`
+endef
diff --git a/src/ghostscript-1-fixes.patch b/src/ghostscript-1-fixes.patch
new file mode 100644
index 0000000..a662a6a
--- /dev/null
+++ b/src/ghostscript-1-fixes.patch
@@ -0,0 +1,1389 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains ad hoc patches for cross building.
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Boris Nagaev <bnagaev@gmail.com>
+Date: Sat, 16 Jul 2016 13:01:59 +0200
+Subject: [PATCH] apply mingw-build.patch from MINGW-packages
+
+Source: https://git.io/vKz1V
+
+diff --git a/Makefile.in b/Makefile.in
+index 1111111..2222222 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -60,6 +60,14 @@ GPDLOBJDIR=./$(BUILDDIRPREFIX)@OBJDIR_BSDMAKE_WORKAROUND@
+
+ CONTRIBDIR=@srcdir@/contrib
+
++# ------ MINGW options ------ #
++
++MINGW_BUILD=@MINGW_BUILD@
++MINGW_PLATFORM=@MINGW_PLATFORM@
++MINGW_PLATFORM_BITS=@MINGW_PLATFORM_BITS@
++MINGW_WITH_WINLIB_NAMES=@MINGW_WITH_WINLIB_NAMES@
++MINGW_WITH_GDI=@MINGW_WITH_GDI@
++
+ # Do not edit the next group of lines.
+
+ include $(GLSRCDIR)/version.mak
+@@ -433,8 +441,8 @@ LDFLAGS_SO=@DYNAMIC_LDFLAGS@
+ # Solaris may need -lnsl -lsocket -lposix4.
+ # (Libraries required by individual drivers are handled automatically.)
+
+-EXTRALIBS=$(XTRALIBS) @LIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ @JPX_AUTOCONF_LIBS@
+-AUXEXTRALIBS=$(XTRALIBS) @LIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ @JPX_AUTOCONF_LIBS@ @AUX_SHARED_ZLIB@
++EXTRALIBS=$(XTRALIBS) @LIBS@ @MINGW_XTLIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ @JPX_AUTOCONF_LIBS@
++AUXEXTRALIBS=$(XTRALIBS) @LIBS@ @MINGW_XTLIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ @JPX_AUTOCONF_LIBS@ @AUX_SHARED_ZLIB@
+
+ # Define the standard libraries to search at the end of linking.
+ # Most platforms require -lpthread for the POSIX threads library;
+@@ -484,9 +492,10 @@ SYNC=@SYNC@
+ RM=rm -f
+
+ # ------ Dynamic loader options ------- #
+-SOC_CFLAGS = @SOC_CFLAGS@
+-SOC_LIBS = @SOC_LIBS@
+-SOC_LOADER = @SOC_LOADER@
++SOC_CFLAGS = @SOC_CFLAGS@
++SOC_LIBS = @SOC_LIBS@
++SOC_LOADER = @SOC_LOADER@
++SOC_LOADER_PLAIN = @SOC_LOADER_PLAIN@
+
+ # on virtually every Unix-a-like system, this is "so",
+ # but Apple just had to be different, so it's now set
+@@ -637,7 +646,17 @@ AK=
+
+ CCFLAGS=$(GENOPT) $(CAPOPT) $(CFLAGS)
+ CC_=$(CC) $(CCFLAGS)
+-CCAUX_=$(CCAUX) $(CFLAGS)
++
++ifeq ($(MINGW_BUILD), 1)
++ # adding -lz to the compilation flags seems to be an error:
++ # if not always, then at least under MSys/MinGW,
++ # compiled against the system's zlib,
++ # and having no zlib sub-folder (see also: unixaux.mak)
++ CCAUX_=$(CCAUX) $(CFLAGS)
++else
++ CCAUX_=$(CCAUX) $(CFLAGS) @AUX_SHARED_ZLIB@
++endif
++
+ CC_LEAF=$(CC_)
+ # note gcc can't use -fomit-frame-pointer with -pg.
+ CC_LEAF_PG=$(CC_)
+@@ -707,6 +726,12 @@ include $(GLSRCDIR)/unixinst.mak
+ @CONTRIBINCLUDE@
+ @CUPSINCLUDE@
+
++# conditionally include the two .mak files that are only needed with a MINGW build
++ifeq ($(MINGW_BUILD), 1)
++ include $(GLSRCDIR)/mingw-fs.mak
++ include $(GLSRCDIR)/mingwlib.mak
++endif
++
+ # Clean up after the autotools scripts
+ distclean : clean config-clean soclean pgclean debugclean mementoclean
+ -$(RM_) -r $(BINDIR) $(GLOBJDIR) $(PSOBJDIR) $(AUXDIR)
+diff --git a/base/gp_mswin.c b/base/gp_mswin.c
+index 1111111..2222222 100644
+--- a/base/gp_mswin.c
++++ b/base/gp_mswin.c
+@@ -989,7 +989,7 @@ bool gp_fseekable (FILE *f)
+
+ /* ------------------------- _snprintf -----------------------------*/
+
+-#if defined(_MSC_VER) && _MSC_VER>=1900 /* VS 2014 and later have (finally) snprintf */
++#if (defined(_MSC_VER) && _MSC_VER>=1900) || defined(__MINGW64_VERSION_MAJOR) /* VS 2014 and later have (finally) snprintf */
+ # define STDC99
+ #else
+ /* Microsoft Visual C++ 2005 doesn't properly define snprintf,
+diff --git a/base/gp_mswin.h b/base/gp_mswin.h
+index 1111111..2222222 100644
+--- a/base/gp_mswin.h
++++ b/base/gp_mswin.h
+@@ -56,4 +56,13 @@ extern int is_spool(const char *queue);
+
+ #endif /* !defined(RC_INVOKED) */
+
++// in gp_mswin.c, mswin_popen is called
++// before it is implemented, so we must
++// provide a prototype (at least with GCC) to
++// avoid implicit definition with the wrong return type
++
++#ifdef __GNUC__
++FILE *mswin_popen(const char *cmd, const char *mode);
++#endif
++
+ #endif /* gp_mswin_INCLUDED */
+diff --git a/base/gs.mak b/base/gs.mak
+index 1111111..2222222 100644
+--- a/base/gs.mak
++++ b/base/gs.mak
+@@ -520,6 +520,7 @@ $(gconfig_h) : $(gconfxx_h)
+ # save our set of makefile variables that are defined in every build (paths, etc.)
+ $(gconfigd_h) : $(ECHOGS_XE) $(GS_MAK) $(GLSRCDIR)$(D)version.mak $(MAKEDIRS)
+ $(EXP)$(ECHOGS_XE) -w $(gconfigd_h) -x 23 define -s -u GS_LIB_DEFAULT -x 2022 $(GS_LIB_DEFAULT) -x 22
++ $(MINGW_FONTPATH_PATCH_OR_EMPTY_COMMAND)
+ $(EXP)$(ECHOGS_XE) -a $(gconfigd_h) -x 23 define -s -u GS_DEV_DEFAULT -x 2022 $(GS_DEV_DEFAULT) -x 22
+ $(EXP)$(ECHOGS_XE) -a $(gconfigd_h) -x 23 define -s -u GS_CACHE_DIR -x 2022 $(GS_CACHE_DIR) -x 22
+ $(EXP)$(ECHOGS_XE) -a $(gconfigd_h) -x 23 define -s -u SEARCH_HERE_FIRST -s $(SEARCH_HERE_FIRST)
+diff --git a/base/lib.mak b/base/lib.mak
+index 1111111..2222222 100644
+--- a/base/lib.mak
++++ b/base/lib.mak
+@@ -42,13 +42,13 @@ GLCCSHARED=$(CC_SHARED) $(GLCCFLAGS)
+ # We can't use $(CC_) for GLLCMSCC becuase that includes /Za on
+ # msvc builds, and lcms configures itself to depend on msvc extensions
+ # (inline asm, including windows.h) when compiled under msvc.
+-GLLCMSCC=$(CC) $(LCMS_CFLAGS) $(CFLAGS) $(I_)$(GLI_) $(II)$(LCMSSRCDIR)$(D)include$(_I) $(GLF_)
++GLLCMSCC=$(CC) $(LCMS_CFLAGS) $(CFLAGS) $(I_)$(GLI_) $(GLF_)
+ lcms_h=$(LCMSSRCDIR)$(D)include$(D)lcms.h
+ icc34_h=$(GLSRC)icc34.h
+ # We can't use $(CC_) for GLLCMS2CC becuase that includes /Za on
+ # msvc builds, and lcms configures itself to depend on msvc extensions
+ # (inline asm, including windows.h) when compiled under msvc.
+-GLLCMS2CC=$(CC) $(LCMS2_CFLAGS) $(CFLAGS) $(I_)$(GLI_) $(II)$(LCMS2SRCDIR)$(D)include$(_I) $(GLF_)
++GLLCMS2CC=$(CC) $(LCMS2_CFLAGS) $(CFLAGS) $(I_)$(GLI_) $(GLF_)
+ lcms2_h=$(LCMS2SRCDIR)$(D)include$(D)lcms2.h
+ lcms2_plugin_h=$(LCMS2SRCDIR)$(D)include$(D)lcms2_plugin.h
+
+diff --git a/base/mingw-fp.sh b/base/mingw-fp.sh
+new file mode 100644
+index 1111111..2222222
+--- /dev/null
++++ b/base/mingw-fp.sh
+@@ -0,0 +1 @@
++sed -i -e 's?\\?/?g' $1
+diff --git a/base/mingw-fs.mak b/base/mingw-fs.mak
+new file mode 100644
+index 1111111..2222222
+--- /dev/null
++++ b/base/mingw-fs.mak
+@@ -0,0 +1,34 @@
++# MSys/MinGW file- and operating-system section
++# adapted from winplat.mak
++
++# Define the name of this makefile.
++
++MINGW_FS_MAK=$(GLSRC)mingw-fs.mak
++
++# Define generic Windows-specific modules.
++
++mingw-fs_=$(GLOBJ)gp_ntfs.$(OBJ) $(GLOBJ)gp_win32.$(OBJ)
++$(GLD)mingw-fs.dev : $(MINGW_FS_MAK) $(ECHOGS_XE) $(mingw-fs_)
++ $(SETMOD) $(GLD)mingw-fs $(mingw-fs_)
++
++$(GLOBJ)gp_ntfs.$(OBJ): $(GLSRC)gp_ntfs.c $(AK)\
++ $(dos__h) $(memory__h) $(stdio__h) $(string__h) $(windows__h)\
++ $(gp_h) $(gpmisc_h) $(gsmemory_h) $(gsstruct_h) $(gstypes_h) $(gsutil_h)
++ $(GLCC) $(GLO_)gp_ntfs.$(OBJ) $(C_) $(GLSRC)gp_ntfs.c
++
++$(GLOBJ)gp_win32.$(OBJ): $(GLSRC)gp_win32.c $(AK)\
++ $(dos__h) $(malloc__h) $(stdio__h) $(string__h) $(windows__h)\
++ $(gp_h) $(gsmemory_h) $(gstypes_h)
++ $(GLCC) $(GLO_)gp_win32.$(OBJ) $(C_) $(GLSRC)gp_win32.c
++
++# Define the Windows thread / synchronization module.
++
++winsync_=$(GLOBJ)gp_wsync.$(OBJ)
++$(GLD)winsync.dev : $(MINGW_FS_MAK) $(ECHOGS_XE) $(winsync_)
++ $(SETMOD) $(GLD)winsync $(winsync_)
++ $(ADDMOD) $(GLD)winsync -replace $(GLD)nosync
++
++$(GLOBJ)gp_wsync.$(OBJ): $(GLSRC)gp_wsync.c $(AK)\
++ $(dos__h) $(malloc__h) $(stdio__h) $(string__h) $(windows__h)\
++ $(gp_h) $(gsmemory_h) $(gstypes_h)
++ $(GLCC) $(GLO_)gp_wsync.$(OBJ) $(C_) $(GLSRC)gp_wsync.c
+diff --git a/base/mingwlib.mak b/base/mingwlib.mak
+new file mode 100644
+index 1111111..2222222
+--- /dev/null
++++ b/base/mingwlib.mak
+@@ -0,0 +1,76 @@
++# Common makefile section for MSys/MinGW
++# adapted from winlib.mak
++
++# Define the files to be removed by `make clean'.
++# nmake expands macros when encountered, not when used,
++# so this must precede the !include statements.
++
++BEGINFILES=$(GLGENDIR)\ccf32.tr\
++ $(GLOBJDIR)\*.res $(GLOBJDIR)\*.ico\
++ $(BINDIR)\$(GSDLL).dll $(BINDIR)\$(GSCONSOLE).exe\
++ $(BINDIR)\setupgs.exe $(BINDIR)\uninstgs.exe\
++ $(GLOBJDIR)\cups\*.h\
++ $(BEGINFILES2)
++
++# -------------------------------- Library -------------------------------- #
++
++# The MSys/MinGW Win32 platform
++
++mingw32__=$(GLOBJ)gp_mswin.$(OBJ) $(GLOBJ)gp_wgetv.$(OBJ) $(GLOBJ)gp_wpapr.$(OBJ) \
++ $(GLOBJ)gp_stdia.$(OBJ) $(GLOBJ)gp_wutf8.$(OBJ)
++mingw32_inc=$(GLD)nosync.dev $(GLD)mingw-fs.dev
++
++$(GLGEN)mingw32_.dev: $(mingw32__) $(ECHOGS_XE) $(mingw32_inc)
++ $(SETMOD) $(GLGEN)mingw32_ $(mingw32__)
++ $(ADDMOD) $(GLGEN)mingw32_ -include $(mingw32_inc)
++
++$(GLOBJ)gp_mswin.$(OBJ): $(GLSRC)gp_mswin.c $(AK) $(gp_mswin_h) \
++ $(ctype__h) $(dos__h) $(malloc__h) $(memory__h) $(pipe__h) \
++ $(stdio__h) $(string__h) $(windows__h) $(winspool_h)\
++ $(gx_h) $(gp_h) $(gpcheck_h) $(gpmisc_h) $(gserrors_h) $(gsexit_h)
++ $(GLCC) $(GLO_)gp_mswin.$(OBJ) $(C_) $(GLSRC)gp_mswin.c
++
++$(GLOBJ)gp_wutf8.$(OBJ): $(GLSRC)gp_wutf8.c $(windows__h)
++ $(GLCC) $(GLO_)gp_wutf8.$(OBJ) $(C_) $(GLSRC)gp_wutf8.c
++
++$(GLOBJ)gp_wgetv.$(OBJ): $(GLSRC)gp_wgetv.c $(AK) $(gscdefs_h)
++ $(GLCC) $(GLO_)gp_wgetv.$(OBJ) $(C_) $(GLSRC)gp_wgetv.c
++
++$(GLOBJ)gp_wpapr.$(OBJ): $(GLSRC)gp_wpapr.c $(AK) $(gp_h)
++ $(GLCC) $(GLO_)gp_wpapr.$(OBJ) $(C_) $(GLSRC)gp_wpapr.c
++
++# Define MS-Windows handles (file system) as a separable feature.
++
++mshandle_=$(GLOBJ)gp_mshdl.$(OBJ)
++$(GLD)mshandle.dev: $(ECHOGS_XE) $(mshandle_)
++ $(SETMOD) $(GLD)mshandle $(mshandle_)
++ $(ADDMOD) $(GLD)mshandle -iodev handle
++
++$(GLOBJ)gp_mshdl.$(OBJ): $(GLSRC)gp_mshdl.c $(AK)\
++ $(ctype__h) $(errno__h) $(stdio__h) $(string__h)\
++ $(gsmemory_h) $(gstypes_h) $(gxiodev_h) $(gserrors_h)
++ $(GLCC) $(GLO_)gp_mshdl.$(OBJ) $(C_) $(GLSRC)gp_mshdl.c
++
++# Define MS-Windows printer (file system) as a separable feature.
++
++msprinter_=$(GLOBJ)gp_msprn.$(OBJ)
++$(GLD)msprinter.dev: $(ECHOGS_XE) $(msprinter_)
++ $(SETMOD) $(GLD)msprinter $(msprinter_)
++ $(ADDMOD) $(GLD)msprinter -iodev printer
++
++$(GLOBJ)gp_msprn.$(OBJ): $(GLSRC)gp_msprn.c $(AK)\
++ $(ctype__h) $(errno__h) $(stdio__h) $(string__h)\
++ $(gsmemory_h) $(gstypes_h) $(gxiodev_h)
++ $(GLCC) $(GLO_)gp_msprn.$(OBJ) $(C_) $(GLSRC)gp_msprn.c
++
++# Define MS-Windows polling as a separable feature
++# because it is not needed by the gslib.
++mspoll_=$(GLOBJ)gp_mspol.$(OBJ)
++$(GLD)mspoll.dev: $(ECHOGS_XE) $(mspoll_)
++ $(SETMOD) $(GLD)mspoll $(mspoll_)
++
++$(GLOBJ)gp_mspol.$(OBJ): $(GLSRC)gp_mspol.c $(AK)\
++ $(gx_h) $(gp_h) $(gpcheck_h)
++ $(GLCC) $(GLO_)gp_mspol.$(OBJ) $(C_) $(GLSRC)gp_mspol.c
++
++# end of mingwlib.mak
+diff --git a/base/stat_.h b/base/stat_.h
+index 1111111..2222222 100644
+--- a/base/stat_.h
++++ b/base/stat_.h
+@@ -43,7 +43,7 @@
+ * Microsoft C uses _stat instead of stat,
+ * for both the function name and the structure name.
+ */
+-#ifdef _MSC_VER
++#if defined(_MSC_VER) || defined(__MINGW32__)
+ # define stat _stat
+ #define struct_stat struct _stat
+ #else
+diff --git a/base/time_.h b/base/time_.h
+index 1111111..2222222 100644
+--- a/base/time_.h
++++ b/base/time_.h
+@@ -78,7 +78,7 @@ struct timezone {
+ #endif
+
+ /* Some System V environments, and Posix environments, need <sys/times.h>. */
+-#if defined(HAVE_SYS_TIMES_H) && HAVE_SYS_TIMES_H == 1
++#if defined(HAVE_SYS_TIMES_H) && HAVE_SYS_TIMES_H == 1 && !defined(__MINGW32__)
+ # include <sys/times.h>
+ # define use_times_for_usertime 1
+ /* Posix 1003.1b-1993 section 4.8.1.5 says that
+diff --git a/base/unix-aux.mak b/base/unix-aux.mak
+index 1111111..2222222 100644
+--- a/base/unix-aux.mak
++++ b/base/unix-aux.mak
+@@ -69,6 +69,13 @@ $(GLOBJ)gp_sysv.$(OBJ): $(GLSRC)gp_sysv.c $(stdio__h) $(time__h) $(AK)\
+ $(UNIX_AUX_MAK) $(MAKEDIRS)
+ $(GLCC) $(GLO_)gp_sysv.$(OBJ) $(C_) $(GLSRC)gp_sysv.c
+
++# the MINGW platform / build environment, joining unix for the ride
++mingw__=$(GLOBJ)gp_wgetv.$(OBJ) $(GLOBJ)gp_wpapr.$(OBJ) $(GLOBJ)gp_win32.$(OBJ) $(GLOBJ)gp_mswin.$(OBJ) $(GLOBJ)gp_ntfs.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ) $(GLOBJ)gp_wutf8.$(OBJ) $(GLOBJ)gp_nxpsprn.$(OBJ)
++$(GLGEN)mingw_.dev: $(mingw__) $(GLD)nosync.dev $(GLD)smd5.dev
++ $(SETMOD) $(GLGEN)mingw_ $(mingw__) -include $(GLD)nosync
++ $(ADDMOD) $(GLGEN)mingw_ -include $(GLD)smd5
++
++
+ # -------------------------- Auxiliary programs --------------------------- #
+
+ $(ECHOGS_XE): $(GLSRC)echogs.c $(AK) $(stdpre_h) $(UNIX_AUX_MAK) $(MAKEDIRS)
+@@ -91,18 +98,31 @@ $(GENHT_XE): $(GLSRC)genht.c $(AK) $(GENHT_DEPS) $(UNIX_AUX_MAK) $(MAKEDIRS)
+ # To get GS to use the system zlib, you remove/hide the gs/zlib directory
+ # which means that the mkromfs build can't find the zlib source it needs.
+ # So it's split into two targets, one using the zlib source directly.....
+-MKROMFS_OBJS_0=$(MKROMFS_ZLIB_OBJS) $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
+- $(AUX)gscdefs.$(OBJ) $(AUX)gp_unix.$(OBJ) $(AUX)gp_unifs.$(OBJ) $(AUX)gp_unifn.$(OBJ) \
+- $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ) $(AUX)memento.$(OBJ)
++ifeq ($(MINGW_BUILD), 1)
++ MKROMFS_OBJS_0=$(MKROMFS_ZLIB_OBJS) $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
++ $(AUX)gscdefs.$(OBJ) $(AUX)gp_ntfs.$(OBJ) $(AUX)gp_mswin.$(OBJ) \
++ $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ) $(AUX)memento.$(OBJ)
++else
++ MKROMFS_OBJS_0=$(MKROMFS_ZLIB_OBJS) $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
++ $(AUX)gscdefs.$(OBJ) $(AUX)gp_unix.$(OBJ) $(AUX)gp_unifs.$(OBJ) $(AUX)gp_unifn.$(OBJ) \
++ $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ) $(AUX)memento.$(OBJ)
++endif
+
+ $(MKROMFS_XE)_0: $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS_0) $(UNIX_AUX_MAK) $(MAKEDIRS)
+ $(CCAUX_) $(GENOPT) $(CFLAGS) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_0 $(MKROMFS_OBJS_0) $(AUXEXTRALIBS)
+
+ # .... and one using the zlib library linked via the command line
+-MKROMFS_OBJS_1=$(AUX)gscdefs.$(OBJ) \
+- $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
+- $(AUX)gp_unix.$(OBJ) $(AUX)gp_unifs.$(OBJ) $(AUX)gp_unifn.$(OBJ) \
+- $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ)
++# (here two, MINGW has a different set of dependencies,
++# most notably gp_ntfs and gp_wutf8)
++ifeq ($(MINGW_BUILD), 1)
++ MKROMFS_OBJS_1=$(GLOBJ)gp_ntfs.$(OBJ) $(GLOBJ)gp_wutf8.$(OBJ) \
++ $(GLOBJ)gpmisc.$(OBJ) $(GLOBJ)gp_wgetv.$(OBJ) $(GLOBJ)gscdefs.$(OBJ)
++else
++ MKROMFS_OBJS_1=$(AUX)gscdefs.$(OBJ) \
++ $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
++ $(AUX)gp_unix.$(OBJ) $(AUX)gp_unifs.$(OBJ) $(AUX)gp_unifn.$(OBJ) \
++ $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ)
++endif
+
+ $(MKROMFS_XE)_1: $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS_1) $(UNIX_AUX_MAK) $(MAKEDIRS)
+ $(CCAUX_) $(GENOPT) $(CFLAGS) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_1 $(MKROMFS_OBJS_1) $(AUXEXTRALIBS)
+diff --git a/base/unix-dll.mak b/base/unix-dll.mak
+index 1111111..2222222 100644
+--- a/base/unix-dll.mak
++++ b/base/unix-dll.mak
+@@ -35,17 +35,38 @@ SODEBUGDIRPREFIX=sodebug
+ # Shared object names
+
+ # simple loader (no support for display device)
+-GSSOC_XENAME=$(GS_SO_BASE)c$(XE)
++ifeq ($(MINGW_WITH_WINLIB_NAMES), 1)
++ GSSOC_XENAME=gswin$(MINGW_PLATFORM_BITS)c$(XE)
++else
++ GSSOC_XENAME=$(GS_SO_BASE)c$(XE)
++endif
++
+ GSSOC_XE=$(BINDIR)/$(GSSOC_XENAME)
+ GSSOC=$(BINDIR)/$(GSSOC_XENAME)
+
+ # loader suporting display device using Gtk+
+-GSSOX_XENAME=$(GS_SO_BASE)x$(XE)
++ifeq ($(MINGW_WITH_WINLIB_NAMES), 1)
++ GSSOX_XENAME=gswin$(MINGW_PLATFORM_BITS)$(XE)
++else
++ GSSOX_XENAME=$(GS_SO_BASE)x$(XE)
++endif
++
+ GSSOX_XE=$(BINDIR)/$(GSSOX_XENAME)
+ GSSOX=$(BINDIR)/$(GSSOX_XENAME)
+
+-# shared library
+-GS_SONAME_BASE=lib$(GS_SO_BASE)
++# shared library: handle unix and mingw library names
++ifeq ($(MINGW_BUILD), 1)
++ ifeq ($(MINGW_WITH_WINLIB_NAMES), 1)
++ GS_SONAME_BASE=gsdll$(MINGW_PLATFORM_BITS)
++ GS_SONAME_LINK=$(GS_SONAME_BASE)
++ else
++ GS_SONAME_BASE=lib$(GS_SO_BASE)
++ GS_SONAME_LINK=lib$(GS_SO_BASE)
++ endif
++else
++ GS_SONAME_BASE=lib$(GS_SO_BASE)
++ GS_SONAME_LINK=$(GS_SO_BASE)
++endif
+
+ # GNU/Linux
+ GS_SOEXT=$(SO_LIB_EXT)
+@@ -82,30 +103,30 @@ GS_SO_MAJOR_MINOR=$(BINDIR)/$(GS_SONAME_MAJOR_MINOR)
+
+ # Create symbolic links to the Ghostscript interpreter library
+
+-$(GS_SO): $(GS_SO_MAJOR) $(UNIX_DLL_MAK) $(MAKEDIRS)
++$(GS_SO): $(GS_SO_MAJOR_MINOR) $(UNIX_DLL_MAK) $(MAKEDIRS)
+ $(RM_) $(GS_SO)
+- ln -s $(GS_SONAME_MAJOR_MINOR) $(GS_SO)
++ ln -s $(GS_SONAME_MAJOR) $(GS_SO)
+
+-$(GS_SO_MAJOR): $(GS_SO_MAJOR_MINOR) $(UNIX_DLL_MAK) $(MAKEDIRS)
+- $(RM_) $(GS_SO_MAJOR)
+- ln -s $(GS_SONAME_MAJOR_MINOR) $(GS_SO_MAJOR)
++$(GS_SO_MAJOR_MINOR): $(GS_SO_MAJOR) $(UNIX_DLL_MAK) $(MAKEDIRS)
++ $(RM_) $(GS_SO_MAJOR_MINOR)
++ ln -s $(GS_SONAME_MAJOR) $(GS_SO_MAJOR_MINOR)
+
+ so-links-subtarget: $(GS_SO) $(UNIX_DLL_MAK) $(MAKEDIRS)
+ $(NO_OP)
+
+ # Build the small Ghostscript loaders, with Gtk+ and without
+ $(GSSOC_XE): so-links-subtarget $(PSSRC)$(SOC_LOADER) $(UNIX_DLL_MAK) $(MAKEDIRS)
+- $(GLCC) -g -o $(GSSOC_XE) $(PSSRC)dxmainc.c \
+- -L$(BINDIR) -l$(GS_SO_BASE)
++ $(GLCC) -g -o $(GSSOC_XE) $(PSSRC)$(SOC_LOADER_PLAIN) \
++ -L$(BINDIR) -l$(GS_SONAME_LINK)
+
+ $(GSSOX_XE): so-links-subtarget $(PSSRC)$(SOC_LOADER) $(UNIX_DLL_MAK) $(MAKEDIRS)
+ $(GLCC) -g $(SOC_CFLAGS) -o $(GSSOX_XE) $(PSSRC)$(SOC_LOADER) \
+- -L$(BINDIR) -l$(GS_SO_BASE) $(SOC_LIBS)
++ -L$(BINDIR) -l$(GS_SONAME_LINK) $(SOC_LIBS)
+
+ # ------------------------- Recursive make targets ------------------------- #
+
+ SODEFS=\
+- GS_XE=$(BINDIR)/$(GS_SONAME_MAJOR_MINOR)\
++ GS_XE=$(BINDIR)/$(GS_SONAME_MAJOR)\
+ DISPLAY_DEV=$(DD)display.dev\
+ STDIO_IMPLEMENTATION=c\
+ BUILDDIRPREFIX=$(BUILDDIRPREFIX)
+@@ -179,11 +200,17 @@ install-so-subtarget: so-subtarget
+ -mkdir -p $(DESTDIR)$(gsincludedir)
+ $(INSTALL_PROGRAM) $(GSSOC) $(DESTDIR)$(bindir)/$(GSSOC_XENAME)
+ $(INSTALL_PROGRAM) $(GSSOX) $(DESTDIR)$(bindir)/$(GSSOX_XENAME)
+- $(INSTALL_PROGRAM) $(BINDIR)/$(GS_SONAME_MAJOR_MINOR) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR_MINOR)
+- $(RM_) $(DESTDIR)$(libdir)/$(GS_SONAME)
+- ln -s $(GS_SONAME_MAJOR_MINOR) $(DESTDIR)$(libdir)/$(GS_SONAME)
+- $(RM_) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR)
+- ln -s $(GS_SONAME_MAJOR_MINOR) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR)
++ @if test "$(MINGW_BUILD)" = "1" ; then \
++ $(INSTALL_PROGRAM) $(BINDIR)/$(GS_SONAME_MAJOR) $(DESTDIR)$(bindir)/$(GS_SONAME_MAJOR) ; \
++ $(INSTALL_PROGRAM) $(BINDIR)/$(GS_SONAME_LINK).dll.a $(DESTDIR)$(libdir)/$(GS_SONAME_LINK).dll.a ; \
++ else \
++ $(INSTALL_PROGRAM) $(BINDIR)/$(GS_SONAME_MAJOR) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR) ; \
++ $(RM_) $(DESTDIR)$(libdir)/$(GS_SONAME) ; \
++ ln -s $(GS_SONAME_MAJOR) $(DESTDIR)$(libdir)/$(GS_SONAME) ; \
++ $(RM_) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR) ; \
++ ln -s $(GS_SONAME_MAJOR) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR_MINOR) ; \
++ fi
++ $(INSTALL_DATA) $(GLSRCDIR)/gserrors.h $(DESTDIR)$(gsincludedir)gserrors.h
+ $(INSTALL_DATA) $(PSSRC)iapi.h $(DESTDIR)$(gsincludedir)iapi.h
+ $(INSTALL_DATA) $(PSSRC)ierrors.h $(DESTDIR)$(gsincludedir)ierrors.h
+ $(INSTALL_DATA) $(GLSRC)gserrors.h $(DESTDIR)$(gsincludedir)gserrors.h
+diff --git a/base/unix-gcc.mak b/base/unix-gcc.mak
+index 1111111..2222222 100644
+--- a/base/unix-gcc.mak
++++ b/base/unix-gcc.mak
+@@ -79,7 +79,7 @@ INSTALL_PROGRAM = $(INSTALL) -m 755
+ INSTALL_DATA = $(INSTALL) -m 644
+ INSTALL_SHARED =
+
+-prefix = /usr/local
++prefix = /usr
+ exec_prefix = ${prefix}
+ bindir = ${exec_prefix}/bin
+ scriptdir = $(bindir)
+@@ -98,7 +98,7 @@ gsdatadir = $(gsdir)/$(GS_DOT_VERSION)
+ gssharedir = ${exec_prefix}/lib/ghostscript/$(GS_DOT_VERSION)
+ gsincludedir = ${prefix}/include/ghostscript/
+
+-docdir=$(gsdatadir)/doc
++docdir=$(gsdatadir)/doc/ghostscript-$(GS_DOT_VERSION)
+ exdir=$(gsdatadir)/examples
+ GS_DOCDIR=$(docdir)
+
+diff --git a/base/unixhead.mak b/base/unixhead.mak
+index 1111111..2222222 100644
+--- a/base/unixhead.mak
++++ b/base/unixhead.mak
+@@ -22,7 +22,12 @@
+ # Define the platform name. For a "stock" System V platform,
+ # use sysv_ instead of unix_.
+
+-GSPLATFORM=unix_
++# select platform: unix or mingw
++ifeq ($(MINGW_BUILD), 1)
++ GSPLATFORM=mingw_
++else
++ GSPLATFORM=unix_
++endif
+
+ # Define the syntax for command, object, and executable files.
+
+@@ -65,3 +70,9 @@ CONFLDTR=-ol
+ # Define the compilation rules and flags.
+
+ BEGINFILES=
++
++ifeq ($(MINGW_BUILD), 1)
++ MINGW_FONTPATH_PATCH_OR_EMPTY_COMMAND=$(SH) $(GLSRCDIR)/mingw-fp.sh $(gconfigd_h)
++else
++ MINGW_FONTPATH_PATCH_OR_EMPTY_COMMAND=
++endif
+diff --git a/configure.ac b/configure.ac
+index 1111111..2222222 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -187,6 +187,26 @@ case `uname` in
+ SET_DT_SONAME="so"
+ fi
+ ;;
++ MINGW*)
++ MINGW_BUILD=1
++ MINGW_PLATFORM=`uname`
++ MINGW_XTLIBS="-lwinspool"
++
++ # inner MINGW case statement: 32/64 bits
++ case $MINGW_PLATFORM in
++ MINGW32*)
++ MINGW_PLATFORM_BITS=32
++ ;;
++ MINGW64*)
++ MINGW_PLATFORM_BITS=64
++ ;;
++ esac
++
++ AC_SUBST(MINGW_BUILD)
++ AC_SUBST(MINGW_PLATFORM)
++ AC_SUBST(MINGW_PLATFORM_BITS)
++ AC_SUBST(MINGW_XTLIBS)
++ ;;
+ esac
+
+ AC_SUBST(SET_DT_SONAME)
+@@ -1521,12 +1541,41 @@ AC_SUBST(JPXDIR)
+ AC_SUBST(SHARE_JPX)
+ AC_SUBST(JPXDEVS)
+
++dnl checks for MinGW shared object name and gdi must precede the gtk checks
++dnl check whether MinGW should use the MSVC dll names
++AC_ARG_WITH([winlib-names], AC_HELP_STRING([--with-winlib-names],
++ [MSys/MinGW only: dll and executable names should be gsdll32.dll (gsdll64.dll), gswin32.exe (gswin64.exe), and gswin32c.exe (gswin64c.exe)]),
++ [], [with_winlib_names=no])
++if test "x$with_winlib_names" = "xyes"; then
++ MINGW_WITH_WINLIB_NAMES=1
++fi
++
++dnl check whether MinGW should use the gdi-based (dwmain.c, dwmainc.c) front end
++AC_ARG_WITH([gdi], AC_HELP_STRING([--with-gdi],
++ [MSys/MinGW only: use the gdi-based Shared Object loaders (dwmain.c & dwmainc.c; implies --with-winlib-names=yes): not yet implemented]),
++ [], [with_gdi=no])
++if test "x$with_gdi" = "xyes"; then
++ MINGW_WITH_WINLIB_NAMES=1
++ MINGW_WITH_GDI=1
++ # SOC_LOADER value will be set after the initial gtk test
++fi
++
++AC_SUBST(MINGW_WITH_WINLIB_NAMES)
++AC_SUBST(MINGW_WITH_GDI)
++
+ dnl check if we can/should build the gtk loader
+ AC_ARG_ENABLE([gtk], AC_HELP_STRING([--disable-gtk],
+ [Do not build the gtk loader]))
+ SOC_CFLAGS=""
+ SOC_LIBS=""
+-SOC_LOADER=""
++SOC_LOADER="" # default may not be set before the gtk+-2.0 test
++SOC_LOADER_PLAIN=""
++
++if test "x$with_gdi" = "xyes"; then
++ AC_MSG_WARN([the gdi front end under MSys/MinGW is not yet implemented])
++ enable_gtk=yes # try to use gtk+ instead
++fi
++
+ if test "x$enable_gtk" != "xno"; then
+ # Try GTK+ 3.x first...
+ if test "x$PKGCONFIG" != x; then
+@@ -1559,9 +1608,15 @@ if test "x$SOC_LOADER" = "x"; then
+ SOC_LOADER="dxmainc.c"
+ fi
+
++dnl set default SOC_LOADER_PLAIN as necessary
++if test "x$SOC_LOADER_PLAIN" = x; then
++ SOC_LOADER_PLAIN="dxmainc.c"
++fi
++
+ AC_SUBST(SOC_CFLAGS)
+ AC_SUBST(SOC_LIBS)
+ AC_SUBST(SOC_LOADER)
++AC_SUBST(SOC_LOADER_PLAIN)
+
+ dnl look for omni implementation
+ AC_ARG_WITH([omni], AC_HELP_STRING([--with-omni],
+@@ -2103,6 +2158,12 @@ case `uname` in
+ DYNAMIC_LDFLAGS="-shared -Wl,-brtl,-G -fPIC"
+ SO_LIB_EXT=".so"
+ ;;
++ MINGW*)
++ DYNAMIC_CFLAGS="-fPIC"
++ DYNAMIC_LDFLAGS="-fPIC -shared"
++ DYNAMIC_LIBS=""
++ DYNANIC_LIB_EXT="dll"
++ ;;
+ esac
+
+ AC_ARG_ENABLE([dynamic], AC_HELP_STRING([--enable-dynamic],
+@@ -2175,6 +2236,20 @@ if test "x$datadir" = 'x${prefix}/share'; then
+ fi
+
+ dnl Fix "fontpath" variable...
++if test $MINGW_BUILD = 1; then
++ # Add a reference to the Windows Fonts directory.
++ # This must take place priot to the test below,
++ # as it is also our way to avoid inclusion
++ # of the various unix font directories.
++ # Since gs uses here a colon as delimiter,
++ # we must refer to %windir% as /c/Windows
++ if test "x$fontpath" = "x"; then
++ fontpath="/c/Windows/Fonts"
++ else
++ fontpath="${fontpath}:/c/Windows/Fonts"
++ fi
++fi
++
+ if test "x$fontpath" = "x"; then
+ # These font directories are used by various Linux distributions...
+ fontpath="$datadir/fonts/default/ghostscript"
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Boris Nagaev <bnagaev@gmail.com>
+Date: Sat, 16 Jul 2016 13:05:54 +0200
+Subject: [PATCH] import patch libspectre.patch from MINGW-packages
+
+Source: https://git.io/vKz18
+
+diff --git a/psi/iapi.h b/psi/iapi.h
+index 1111111..2222222 100644
+--- a/psi/iapi.h
++++ b/psi/iapi.h
+@@ -246,6 +246,7 @@ GSDLLEXPORT int GSDLLAPI gsapi_init_with_args(void *instance,
+ int argc, char **argv);
+
+ #ifdef __WIN32__
++#include <stddef.h>
+ GSDLLEXPORT int GSDLLAPI gsapi_init_with_argsA(void *instance,
+ int argc, char **argv);
+
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Boris Nagaev <bnagaev@gmail.com>
+Date: Sat, 16 Jul 2016 13:13:22 +0200
+Subject: [PATCH] import patch ghostscript-sys-zlib.patch from MINGW-packages
+
+Source: https://git.io/vKz1D
+
+diff --git a/configure.ac b/configure.ac
+index 1111111..2222222 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -912,7 +912,7 @@ AC_MSG_CHECKING([for local zlib source])
+ dnl zlib is needed for language level 3, and libpng
+ # we must define ZLIBDIR regardless because png.mak does a -I$(ZLIBDIR)
+ # this seems a harmless default
+-ZLIBDIR=src
++ZLIBDIR=$includedir
+ AUX_SHARED_ZLIB=
+
+ if test -d $srcdir/zlib; then
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: darealshinji <djcj@gmx.de>
+Date: Sat, 16 Jul 2016 13:15:57 +0200
+Subject: [PATCH] further changes for MXE
+
+
+diff --git a/Makefile.in b/Makefile.in
+index 1111111..2222222 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -110,6 +110,9 @@ docdir=$(gsdatadir)/doc
+ exdir=$(gsdatadir)/examples
+ GS_DOCDIR=$(docdir)
+
++# Are we cross-compiling?
++CROSS_COMPILING=@CROSS_COMPILING@
++
+ # Choose whether to compile the .ps initialization files into the executable.
+ # See gs.mak for details.
+
+@@ -184,7 +187,7 @@ XPS=@XPS@
+ GPDL=@GPDL@
+
+ XE=@EXEEXT@
+-XEAUX=@EXEEXT@
++XEAUX=@EXEEXTAUX@
+
+ PCL_XPS_TARGETS=@PCL_TARGET@ @XPS_TARGET@ @GPDL_TARGET@
+
+@@ -369,7 +372,7 @@ RANLIB=@RANLIB@
+ # Define the name of the C compiler (target and host (AUX))
+
+ CC=@CC@
+-CCAUX=@CC@
++CCAUX=@CCAUX@
+
+ # Define the name of the linker for the final link step.
+ # Normally this is the same as the C compiler.
+@@ -379,6 +382,7 @@ CCAUXLD=$(CCAUX)
+
+ # Define the default gcc flags.
+ GCFLAGS=@CPPFLAGS@ @GCFLAGS@ @CFLAGS@
++GCFLAGS_AUX=@GCFLAGS@
+
+ # Define the added flags for standard, debugging, profiling
+ # and shared object builds.
+@@ -442,7 +446,11 @@ LDFLAGS_SO=@DYNAMIC_LDFLAGS@
+ # (Libraries required by individual drivers are handled automatically.)
+
+ EXTRALIBS=$(XTRALIBS) @LIBS@ @MINGW_XTLIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ @JPX_AUTOCONF_LIBS@
++ifeq ($(CROSS_COMPILING),yes)
++AUXEXTRALIBS=$(XTRALIBS) -lz
++else
+ AUXEXTRALIBS=$(XTRALIBS) @LIBS@ @MINGW_XTLIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ @JPX_AUTOCONF_LIBS@ @AUX_SHARED_ZLIB@
++endif
+
+ # Define the standard libraries to search at the end of linking.
+ # Most platforms require -lpthread for the POSIX threads library;
+@@ -492,10 +500,10 @@ SYNC=@SYNC@
+ RM=rm -f
+
+ # ------ Dynamic loader options ------- #
+-SOC_CFLAGS = @SOC_CFLAGS@
+-SOC_LIBS = @SOC_LIBS@
+-SOC_LOADER = @SOC_LOADER@
+-SOC_LOADER_PLAIN = @SOC_LOADER_PLAIN@
++SOC_CFLAGS = @SOC_CFLAGS@
++SOC_LIBS = @SOC_LIBS@
++SOC_LOADER = @SOC_LOADER@
++SOC_LOADER_PLAIN = @SOC_LOADER_PLAIN@
+
+ # on virtually every Unix-a-like system, this is "so",
+ # but Apple just had to be different, so it's now set
+@@ -646,16 +654,15 @@ AK=
+
+ CCFLAGS=$(GENOPT) $(CAPOPT) $(CFLAGS)
+ CC_=$(CC) $(CCFLAGS)
+-
+ ifeq ($(MINGW_BUILD), 1)
+ # adding -lz to the compilation flags seems to be an error:
+- # if not always, then at least under MSys/MinGW,
++ # if not always, then at least under MSys/MinGW,
+ # compiled against the system's zlib,
+ # and having no zlib sub-folder (see also: unixaux.mak)
+- CCAUX_=$(CCAUX) $(CFLAGS)
++ CCAUX_=$(CCAUX) -I"@TARGET_INCLUDE@" $(GCFLAGS_AUX)
+ else
+ CCAUX_=$(CCAUX) $(CFLAGS) @AUX_SHARED_ZLIB@
+-endif
++endif
+
+ CC_LEAF=$(CC_)
+ # note gcc can't use -fomit-frame-pointer with -pg.
+diff --git a/base/gp_mswin.h b/base/gp_mswin.h
+index 1111111..2222222 100644
+--- a/base/gp_mswin.h
++++ b/base/gp_mswin.h
+@@ -56,7 +56,7 @@ extern int is_spool(const char *queue);
+
+ #endif /* !defined(RC_INVOKED) */
+
+-// in gp_mswin.c, mswin_popen is called
++// in gp_mswin.c, mswin_popen is called
+ // before it is implemented, so we must
+ // provide a prototype (at least with GCC) to
+ // avoid implicit definition with the wrong return type
+diff --git a/base/gp_unix.c b/base/gp_unix.c
+index 1111111..2222222 100644
+--- a/base/gp_unix.c
++++ b/base/gp_unix.c
+@@ -13,6 +13,9 @@
+ CA 94903, U.S.A., +1(415)492-9861, for further information.
+ */
+
++#if defined(__WIN32__) && !defined(METRO)
++#include "windows_.h"
++#endif
+
+ /* Unix-specific routines for Ghostscript */
+
+@@ -442,3 +445,11 @@ void gp_enumerate_fonts_free(void *enum_state)
+ }
+ #endif
+ }
++
++#if defined(__WIN32__) && !defined(METRO)
++/* include gp_local_arg_encoding_get_codepoint for MinGW cross-builds */
++#ifndef GP_LAEGC_INCLUDED
++# define GP_LAEGC_INCLUDED
++#endif
++#include "gp_win32.c"
++#endif
+diff --git a/base/gp_win32.c b/base/gp_win32.c
+index 1111111..2222222 100644
+--- a/base/gp_win32.c
++++ b/base/gp_win32.c
+@@ -13,6 +13,7 @@
+ CA 94903, U.S.A., +1(415)492-9861, for further information.
+ */
+
++#ifndef GP_LAEGC_INCLUDED
+
+ /* Common platform-specific routines for MS-Windows WIN32 */
+ /* originally hacked from gp_msdos.c by Russell Lang */
+@@ -131,6 +132,8 @@ const char gp_null_file_name[] = "nul";
+ /* Define the name that designates the current directory. */
+ const char gp_current_directory_name[] = ".";
+
++#endif /* GP_LAEGC_INCLUDED */
++
+ /* A function to decode the next codepoint of the supplied args from the
+ * local windows codepage, or -1 for EOF.
+ */
+diff --git a/base/lib.mak b/base/lib.mak
+index 1111111..2222222 100644
+--- a/base/lib.mak
++++ b/base/lib.mak
+@@ -76,7 +76,7 @@ stdpre_h=$(GLSRC)stdpre.h $(stdpn_h)
+ stdint__h=$(GLSRC)stdint_.h $(std_h)
+
+ $(GLGEN)arch.h : $(GENARCH_XE)
+- $(EXP)$(GENARCH_XE) $(GLGEN)arch.h $(TARGET_ARCH_FILE)
++ test -f $@ || $(GENARCH_XE) $(GLGEN)arch.h $(TARGET_ARCH_FILE)
+
+ # Platform interfaces
+
+diff --git a/base/unix-aux.mak b/base/unix-aux.mak
+index 1111111..2222222 100644
+--- a/base/unix-aux.mak
++++ b/base/unix-aux.mak
+@@ -69,7 +69,7 @@ $(GLOBJ)gp_sysv.$(OBJ): $(GLSRC)gp_sysv.c $(stdio__h) $(time__h) $(AK)\
+ $(UNIX_AUX_MAK) $(MAKEDIRS)
+ $(GLCC) $(GLO_)gp_sysv.$(OBJ) $(C_) $(GLSRC)gp_sysv.c
+
+-# the MINGW platform / build environment, joining unix for the ride
++# the MINGW platform / build environment, joining unix for the ride
+ mingw__=$(GLOBJ)gp_wgetv.$(OBJ) $(GLOBJ)gp_wpapr.$(OBJ) $(GLOBJ)gp_win32.$(OBJ) $(GLOBJ)gp_mswin.$(OBJ) $(GLOBJ)gp_ntfs.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ) $(GLOBJ)gp_wutf8.$(OBJ) $(GLOBJ)gp_nxpsprn.$(OBJ)
+ $(GLGEN)mingw_.dev: $(mingw__) $(GLD)nosync.dev $(GLD)smd5.dev
+ $(SETMOD) $(GLGEN)mingw_ $(mingw__) -include $(GLD)nosync
+@@ -98,6 +98,11 @@ $(GENHT_XE): $(GLSRC)genht.c $(AK) $(GENHT_DEPS) $(UNIX_AUX_MAK) $(MAKEDIRS)
+ # To get GS to use the system zlib, you remove/hide the gs/zlib directory
+ # which means that the mkromfs build can't find the zlib source it needs.
+ # So it's split into two targets, one using the zlib source directly.....
++ifeq ($(CROSS_COMPILING),yes)
++MKROMFS_OBJS_0=$(MKROMFS_ZLIB_OBJS) $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
++ $(AUX)gscdefs.$(OBJ) $(AUX)gp_unix.$(OBJ) $(AUX)gp_unifs.$(OBJ) $(AUX)gp_unifn.$(OBJ) \
++ $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ) $(AUX)memento.$(OBJ)
++else
+ ifeq ($(MINGW_BUILD), 1)
+ MKROMFS_OBJS_0=$(MKROMFS_ZLIB_OBJS) $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
+ $(AUX)gscdefs.$(OBJ) $(AUX)gp_ntfs.$(OBJ) $(AUX)gp_mswin.$(OBJ) \
+@@ -107,13 +112,20 @@ else
+ $(AUX)gscdefs.$(OBJ) $(AUX)gp_unix.$(OBJ) $(AUX)gp_unifs.$(OBJ) $(AUX)gp_unifn.$(OBJ) \
+ $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ) $(AUX)memento.$(OBJ)
+ endif
++endif
+
+ $(MKROMFS_XE)_0: $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS_0) $(UNIX_AUX_MAK) $(MAKEDIRS)
+- $(CCAUX_) $(GENOPT) $(CFLAGS) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_0 $(MKROMFS_OBJS_0) $(AUXEXTRALIBS)
++ $(CCAUX_) $(GENOPT) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_0 $(MKROMFS_OBJS_0) $(AUXEXTRALIBS)
+
+ # .... and one using the zlib library linked via the command line
+ # (here two, MINGW has a different set of dependencies,
+ # most notably gp_ntfs and gp_wutf8)
++ifeq ($(CROSS_COMPILING),yes)
++MKROMFS_OBJS_1=$(AUX)gscdefs.$(OBJ) \
++ $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
++ $(AUX)gp_unix.$(OBJ) $(AUX)gp_unifs.$(OBJ) $(AUX)gp_unifn.$(OBJ) \
++ $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ)
++else
+ ifeq ($(MINGW_BUILD), 1)
+ MKROMFS_OBJS_1=$(GLOBJ)gp_ntfs.$(OBJ) $(GLOBJ)gp_wutf8.$(OBJ) \
+ $(GLOBJ)gpmisc.$(OBJ) $(GLOBJ)gp_wgetv.$(OBJ) $(GLOBJ)gscdefs.$(OBJ)
+@@ -123,9 +135,10 @@ else
+ $(AUX)gp_unix.$(OBJ) $(AUX)gp_unifs.$(OBJ) $(AUX)gp_unifn.$(OBJ) \
+ $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ)
+ endif
++endif
+
+ $(MKROMFS_XE)_1: $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS_1) $(UNIX_AUX_MAK) $(MAKEDIRS)
+- $(CCAUX_) $(GENOPT) $(CFLAGS) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_1 $(MKROMFS_OBJS_1) $(AUXEXTRALIBS)
++ $(CCAUX_) $(GENOPT) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_1 $(MKROMFS_OBJS_1) $(AUXEXTRALIBS)
+
+ $(MKROMFS_XE): $(MKROMFS_XE)_$(SHARE_ZLIB) $(UNIX_AUX_MAK) $(MAKEDIRS)
+ $(CP_) $(MKROMFS_XE)_$(SHARE_ZLIB) $(MKROMFS_XE)
+diff --git a/base/unix-dll.mak b/base/unix-dll.mak
+index 1111111..2222222 100644
+--- a/base/unix-dll.mak
++++ b/base/unix-dll.mak
+@@ -54,7 +54,8 @@ endif
+ GSSOX_XE=$(BINDIR)/$(GSSOX_XENAME)
+ GSSOX=$(BINDIR)/$(GSSOX_XENAME)
+
+-# shared library: handle unix and mingw library names
++# shared library
++# handle unix and mingw library names
+ ifeq ($(MINGW_BUILD), 1)
+ ifeq ($(MINGW_WITH_WINLIB_NAMES), 1)
+ GS_SONAME_BASE=gsdll$(MINGW_PLATFORM_BITS)
+@@ -210,7 +211,6 @@ install-so-subtarget: so-subtarget
+ $(RM_) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR) ; \
+ ln -s $(GS_SONAME_MAJOR) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR_MINOR) ; \
+ fi
+- $(INSTALL_DATA) $(GLSRCDIR)/gserrors.h $(DESTDIR)$(gsincludedir)gserrors.h
+ $(INSTALL_DATA) $(PSSRC)iapi.h $(DESTDIR)$(gsincludedir)iapi.h
+ $(INSTALL_DATA) $(PSSRC)ierrors.h $(DESTDIR)$(gsincludedir)ierrors.h
+ $(INSTALL_DATA) $(GLSRC)gserrors.h $(DESTDIR)$(gsincludedir)gserrors.h
+diff --git a/base/unixhead.mak b/base/unixhead.mak
+index 1111111..2222222 100644
+--- a/base/unixhead.mak
++++ b/base/unixhead.mak
+@@ -25,7 +25,7 @@
+ # select platform: unix or mingw
+ ifeq ($(MINGW_BUILD), 1)
+ GSPLATFORM=mingw_
+-else
++else
+ GSPLATFORM=unix_
+ endif
+
+diff --git a/configure.ac b/configure.ac
+index 1111111..2222222 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -24,6 +24,9 @@ AC_PREREQ(2.63)
+ AC_LANG(C)
+ AC_CONFIG_SRCDIR(psi/gs.c)
+
++AC_CANONICAL_HOST
++AC_CANONICAL_BUILD
++
+ dnl Inherit compiler flags from the environment...
+ CFLAGS="${CFLAGS:=}"
+ CPPFLAGS="${CPPFLAGS:=}"
+@@ -106,7 +109,7 @@ AC_PROG_RANLIB
+ #AC_PROG_INSTALL
+
+ dnl pkg-config is used for several tests now...
+-AC_PATH_PROG(PKGCONFIG, pkg-config)
++AC_PATH_TARGET_TOOL(PKGCONFIG, pkg-config)
+
+ dnl --------------------------------------------------
+ dnl Allow excluding the contributed drivers
+@@ -117,8 +120,8 @@ AC_ARG_ENABLE([contrib], AC_HELP_STRING([--disable-contrib],
+ CONTRIBINCLUDE="include $srcdir/contrib/contrib.mak"
+ INSTALL_CONTRIB="install-contrib-extras"
+
+-case `uname` in
+- MINGW*|MSYS*)
++case $host in
++ *-mingw*)
+ AC_MSG_WARN([disabling contrib devices])
+ enable_contrib=no
+ ;;
+@@ -146,28 +149,23 @@ dnl --------------------------------------------------
+
+ CC_OPT_FLAGS_TO_TRY="-O"
+ SET_DT_SONAME="-soname="
++MINGW_BUILD=0
+
+-case `uname` in
+- Linux*|GNU*)
++case $host in
++ *-linux*|*-gnu*|*bsd*)
+ if test $ac_cv_prog_gcc = yes; then
+ CC_OPT_FLAGS_TO_TRY="-O2"
+ CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
+ fi
+ ;;
+- *BSD)
+- if test $ac_cv_prog_gcc = yes; then
+- CC_OPT_FLAGS_TO_TRY="-O2"
+- CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
+- fi
+- ;;
+- Darwin*)
++ *-darwin*)
+ if test $ac_cv_prog_gcc = yes; then
+ CC_OPT_FLAGS_TO_TRY="-O2"
+ CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
+ fi
+ SET_DT_SONAME=""
+ ;;
+- SunOS)
++ *-sunos*|*-solaris*)
+ CC_OPT_FLAGS_TO_TRY="-O2"
+ # the trailing space is required!
+ if test $ac_cv_prog_gcc = no; then
+@@ -180,33 +178,32 @@ case `uname` in
+ CC_DBG_FLAGS_TO_TRY="-g -O0"
+ fi
+ ;;
+- AIX)
++ *-aix*)
+ if test $ac_cv_prog_gcc = yes; then
+ CC_OPT_FLAGS_TO_TRY="-O2"
+ CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
+ SET_DT_SONAME="so"
+ fi
+ ;;
+- MINGW*)
+- MINGW_BUILD=1
+- MINGW_PLATFORM=`uname`
+- MINGW_XTLIBS="-lwinspool"
+-
+- # inner MINGW case statement: 32/64 bits
+- case $MINGW_PLATFORM in
+- MINGW32*)
+- MINGW_PLATFORM_BITS=32
+- ;;
+- MINGW64*)
+- MINGW_PLATFORM_BITS=64
+- ;;
+- esac
+-
+- AC_SUBST(MINGW_BUILD)
+- AC_SUBST(MINGW_PLATFORM)
+- AC_SUBST(MINGW_PLATFORM_BITS)
+- AC_SUBST(MINGW_XTLIBS)
+- ;;
++ *-mingw*)
++ MINGW_BUILD=1
++ MINGW_XTLIBS="-lwinspool"
++ # inner MINGW case statement: 32/64 bits
++ case $host in
++ i?86-*)
++ MINGW_PLATFORM=MINGW32
++ MINGW_PLATFORM_BITS=32
++ ;;
++ x86_64-*)
++ MINGW_PLATFORM=MINGW64
++ MINGW_PLATFORM_BITS=64
++ ;;
++ esac
++ AC_SUBST(MINGW_BUILD)
++ AC_SUBST(MINGW_PLATFORM)
++ AC_SUBST(MINGW_PLATFORM_BITS)
++ AC_SUBST(MINGW_XTLIBS)
++ ;;
+ esac
+
+ AC_SUBST(SET_DT_SONAME)
+@@ -227,10 +224,16 @@ fi
+
+ ARCH_CONF_HEADER=
+
+-case `uname` in
+- Darwin*)
++case $host in
++ *-darwin*)
+ ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/osx-x86-x86_64-ppc-gcc.h"
+ ;;
++ i?86-*-mingw*)
++ ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/windows-x86-msvc.h"
++ ;;
++ x86_64-*-mingw*)
++ ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/windows-x64-msvc.h"
++ ;;
+ *)
+ ARCH_CONF_HEADER=
+ ;;
+@@ -342,8 +345,8 @@ dnl --------------------------------------------------
+
+ OBJDIR_BSDMAKE_WORKAROUND=obj
+
+-case `uname` in
+- *BSD)
++case $host in
++ *bsd*)
+ OBJDIR_BSDMAKEWORKAOROUND="notobj"
+ ;;
+ esac
+@@ -513,8 +516,8 @@ AC_ARG_ENABLE([threading], AC_HELP_STRING([--disable-threading],
+ # if you haven't got pread/pwrite, we can't use multithreading
+ if test "x$HAVE_PREAD_PWRITE" != "x"; then
+ if test "$enable_threading" != "no"; then
+- case `uname` in
+- MINGW*|MSYS*)
++ case $host in
++ *-mingw*)
+ AC_MSG_WARN([disabling support for pthreads......])
+ ;;
+ *)
+@@ -1251,8 +1254,8 @@ dnl look for IJS implementation
+ AC_ARG_WITH([ijs], AC_HELP_STRING([--without-ijs],
+ [disable IJS driver support]))
+
+-case `uname` in
+- MINGW*|MSYS*)
++case $host in
++ *-mingw*)
+ AC_MSG_WARN([disabling the ijs device])
+ with_ijs=no
+ ;;
+@@ -1311,11 +1314,11 @@ if test x$with_luratech != xno; then
+ SHARE_JBIG2=0
+ JBIG2DIR=$srcdir/luratech/ldf_jb2
+
+- case `uname` in
+- Darwin*)
++ case $host in
++ *-darwin*)
+ JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -DMAC -DMAC_OS_X_BUILD"
+ ;;
+- AIX)
++ *-aix*)
+ if test $ac_cv_prog_gcc = yes; then
+ JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -fsigned-char -DLINUX"
+ else
+@@ -1433,11 +1436,11 @@ if test x$with_luratech != xno; then
+ SHARE_JPX=0
+ JPXDIR=$srcdir/luratech/lwf_jp2
+
+- case `uname` in
+- Darwin*)
++ case $host in
++ *-darwin*)
+ JPX_AUTOCONF_CFLAGS="-DUSE_LWF_JP2 -DMAC -DMAC_OS_X_BUILD"
+ ;;
+- AIX)
++ *-aix*)
+ if test $ac_cv_prog_gcc = yes; then
+ JPX_AUTOCONF_CFLAGS="-DUSE_LWF_JP2 -fsigned-char -DLINUX"
+ else
+@@ -1568,7 +1571,7 @@ AC_ARG_ENABLE([gtk], AC_HELP_STRING([--disable-gtk],
+ [Do not build the gtk loader]))
+ SOC_CFLAGS=""
+ SOC_LIBS=""
+-SOC_LOADER="" # default may not be set before the gtk+-2.0 test
++SOC_LOADER=""
+ SOC_LOADER_PLAIN=""
+
+ if test "x$with_gdi" = "xyes"; then
+@@ -2111,8 +2114,8 @@ SO_LIB_EXT=".so"
+ DLL_EXT=""
+ SO_LIB_VERSION_SEPARATOR="."
+
+-case `uname` in
+- Linux*|GNU*)
++case $host in
++ *-linux*|*-gnu*|*bsd*)
+ DYNAMIC_CFLAGS="-fPIC"
+ DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)"
+ if test $ac_cv_prog_gcc = yes; then
+@@ -2123,25 +2126,20 @@ case `uname` in
+ fi
+ SO_LIB_EXT=".so"
+ ;;
+- MINGW*|MSYS*)
+- DYNAMIC_CFLAGS=""
++ *-mingw*)
++ DYNAMIC_LIBS=""
++ DYNAMIC_CFLAGS="-DGSDLLEXPORT=\"__declspec(dllexport)\""
+ DYNAMIC_LDFLAGS="-shared -Wl,--out-implib=\$(BINDIR)/lib\$(GS_SO_BASE).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import"
+ SO_LIB_EXT=""
+ DLL_EXT=".dll"
+ SO_LIB_VERSION_SEPARATOR="-"
+ ;;
+- *BSD)
+- DYNAMIC_CFLAGS="-fPIC"
+- DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)"
+- DYNAMIC_LIBS=""
+- SO_LIB_EXT=".so"
+- ;;
+- Darwin*)
++ *-darwin*)
+ DYNAMIC_LDFLAGS="-dynamiclib -install_name \$(GS_SONAME_MAJOR_MINOR)"
+ DYNAMIC_LIBS=""
+ SO_LIB_EXT=".dylib"
+ ;;
+- SunOS)
++ *-sunos*|*-solaris*)
+ if test $ac_cv_prog_gcc = yes; then
+ DYNAMIC_CFLAGS="-fPIC"
+ else
+@@ -2152,26 +2150,20 @@ case `uname` in
+ DYNAMIC_LIBS=""
+ SO_LIB_EXT=".so"
+ ;;
+- AIX)
++ *-aix*)
+ DYNAMIC_CFLAGS="-fPIC"
+ GCFLAGS="-Wl,-brtl $GCFLAGS"
+ DYNAMIC_LDFLAGS="-shared -Wl,-brtl,-G -fPIC"
+ SO_LIB_EXT=".so"
+ ;;
+- MINGW*)
+- DYNAMIC_CFLAGS="-fPIC"
+- DYNAMIC_LDFLAGS="-fPIC -shared"
+- DYNAMIC_LIBS=""
+- DYNANIC_LIB_EXT="dll"
+- ;;
+ esac
+
+ AC_ARG_ENABLE([dynamic], AC_HELP_STRING([--enable-dynamic],
+ [Enable dynamically loaded drivers]),
+ [
+ if test "x$enable_dynamic" != xno; then
+- case `uname` in
+- Linux*|GNU*)
++ case $host in
++ *-linux*)
+ INSTALL_SHARED="install-shared"
+ if test "x$X_DEVS" != x; then
+ DYNAMIC_DEVS="\$(GLOBJDIR)/X11.so"
+@@ -2183,21 +2175,21 @@ AC_ARG_ENABLE([dynamic], AC_HELP_STRING([--enable-dynamic],
+ OPT_CFLAGS="$DYNAMIC_CFLAGS $OPT_CFLAGS"
+ DBG_CFLAGS="$DYNAMIC_CFLAGS $DBG_CFLAGS"
+ ;;
+- *BSD)
++ *bsd*)
+ DYNAMIC_DEVS="\$(GLOBJDIR)/X11.so"
+ DYNAMIC_FLAGS="-DGS_DEVS_SHARED -DGS_DEVS_SHARED_DIR=\\\"\$(gssharedir)\\\""
+ X11_DEVS=""
+ OPT_CFLAGS="$DYNAMIC_CFLAGS $OPT_CFLAGS"
+ DBG_CFLAGS="$DYNAMIC_CFLAGS $DBG_CFLAGS"
+ ;;
+- Darwin*)
++ *darwin*)
+ INSTALL_SHARED="install-shared"
+ DYNAMIC_FLAGS="-DGS_DEVS_SHARED -DGS_DEVS_SHARED_DIR=\\\"\$(gssharedir)\\\""
+ X11_DEVS=""
+ OPT_CFLAGS="$DYNAMIC_CFLAGS $OPT_CFLAGS"
+ DBG_CFLAGS="$DYNAMIC_CFLAGS $DBG_CFLAGS"
+ ;;
+- SunOS)
++ *-sunos*|*-solaris*)
+ DYNAMIC_DEVS="\$(GLOBJDIR)/X11.so"
+ DYNAMIC_FLAGS="-DGS_DEVS_SHARED -DGS_DEVS_SHARED_DIR=\\\"\$(gssharedir)\\\""
+ OPT_CFLAGS="$DYNAMIC_CFLAGS $OPT_CFLAGS"
+@@ -2316,8 +2308,8 @@ dnl --------------------------------------------------
+ dnl disable the memory header ID code on SPARC
+ dnl --------------------------------------------------
+
+-case `uname -a` in
+- *sparc*)
++case $host in
++ sparc*)
+ GCFLAGS="$GCFLAGS -DGS_USE_MEMORY_HEADER_ID=0"
+ ;;
+ esac
+@@ -2513,8 +2505,8 @@ AC_SUBST(SUB_MAKE_OPTION)
+ # mingw, add the same prefix as the VS build uses
+ # --------------------------------------------------
+ AUXDIRPOSTFIX=""
+-case `uname` in
+- MINGW*|MSYS*)
++case $host in
++ *-mingw*)
+ AUXDIRPOSTFIX="_"
+ CFLAGS="-DGS_NO_UTF8=1 $CFLAGS"
+ ;;
+@@ -2533,8 +2525,8 @@ AC_ARG_WITH([exe-ext], AC_HELP_STRING([--with-exe-ext=EXT],
+ if test "x"$with_exe_ext != "x"; then
+ EXEEXT="$with_exe_ext"
+ else
+- case `uname` in
+- MINGW*|MSYS*)
++ case $host in
++ *-mingw*)
+ EXEEXT=".exe"
+ ;;
+ esac
+@@ -2543,6 +2535,36 @@ fi
+ AC_SUBST(EXEEXT)
+
+ dnl --------------------------------------------------
++dnl AUX and cross compiling
++dnl --------------------------------------------------
++EXEEXTAUX="$EXEEXT"
++CROSS_COMPILING=no
++
++AC_ARG_VAR(CCAUX, [auxilliary C compiler])
++
++if test "$cross_compiling" = yes ; then
++ CROSS_COMPILING=yes
++ case $build in
++ *-mingw*)
++ EXEEXTAUX=".exe"
++ ;;
++ *)
++ EXEEXTAUX=""
++ ;;
++ esac
++ if test "x$CCAUX" = "x" ; then
++ CCAUX="gcc"
++ fi
++else
++ if test "x$CCAUX" = "x" ; then
++ CCAUX="\$(CC)"
++ fi
++fi
++
++AC_SUBST(EXEEXTAUX)
++AC_SUBST(CROSS_COMPILING)
++
++dnl --------------------------------------------------
+ dnl Do substitutions
+ dnl --------------------------------------------------
+ SRCDIR="$srcdir"
+diff --git a/ijs/ijs_exec_unix.c b/ijs/ijs_exec_unix.c
+index 1111111..2222222 100644
+--- a/ijs/ijs_exec_unix.c
++++ b/ijs/ijs_exec_unix.c
+@@ -22,6 +22,12 @@
+ * SOFTWARE.
+ **/
+
++#ifdef __WIN32__
++
++#include "ijs_exec_win.c"
++
++#else
++
+ #include "unistd_.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -101,3 +107,5 @@ ijs_exec_server(const char *server_cmd, int *pfd_to, int *pfd_from,
+
+ return 0;
+ }
++
++#endif /* __WIN32__ */
+diff --git a/psi/iapi.h b/psi/iapi.h
+index 1111111..2222222 100644
+--- a/psi/iapi.h
++++ b/psi/iapi.h
+@@ -68,6 +68,11 @@ extern "C" {
+ # define GSDLLEXPORT
+ # endif
+ # endif
++# ifdef __MINGW32__
++/* export stdcall functions as "name" instead of "_name@ordinal" */
++# undef GSDLLAPI
++# define GSDLLAPI
++# endif
+ # ifndef GSDLLAPI
+ # define GSDLLAPI __stdcall
+ # endif
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Boris Nagaev <bnagaev@gmail.com>
+Date: Tue, 19 Jul 2016 23:58:16 +0300
+Subject: [PATCH] fix noncontribmakefiles if srcdir!=dstdir
+
+See https://github.com/mxe/mxe/pull/1382#issuecomment-233653542
+
+diff --git a/configure.ac b/configure.ac
+index 1111111..2222222 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -2054,7 +2054,7 @@ if test x$enable_threadsafe = xyes; then
+ NTS_EXCLUDES=`echo "$NTS_EXCLUDES" | tr " " "\n" | sort | uniq | tr "\n" " "`
+ fi # x$enable_threadsafe = xyes
+
+-noncontribmakefiles=`find $srcdir -name '*.mak' -print | grep -v '^\./contrib/'`
++noncontribmakefiles=`find $srcdir -name '*.mak' -print | grep -v '/contrib/'`
+
+ # No need to include opvp/oprp driver without iconv/libiconv.
+ if test -n "$P_DEVS0"; then
diff --git a/src/ghostscript-test.c b/src/ghostscript-test.c
new file mode 100644
index 0000000..10e0a54
--- /dev/null
+++ b/src/ghostscript-test.c
@@ -0,0 +1,46 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#ifdef _WIN32
+
+#include <windows.h>
+
+#ifndef _Windows
+# define _Windows
+#endif
+
+#ifndef GSDLLEXPORT
+# ifdef GS_STATIC_LIB
+# define GSDLLEXPORT
+# else
+# define GSDLLEXPORT __declspec(dllimport)
+# endif
+#endif
+
+#endif /* _WIN32 */
+
+#include <iapi.h>
+
+void *minst;
+
+int main(int argc, char *argv[])
+{
+ int code;
+
+ (void)argc;
+ (void)argv;
+
+ code = gsapi_new_instance(&minst, 0);
+ if (code < 0)
+ return 1;
+
+ code = gsapi_exit(minst);
+ if (code < 0)
+ return 1;
+
+ gsapi_delete_instance(minst);
+
+ return 0;
+}
diff --git a/src/ghostscript.mk b/src/ghostscript.mk
new file mode 100644
index 0000000..9c4fd22
--- /dev/null
+++ b/src/ghostscript.mk
@@ -0,0 +1,76 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG := ghostscript
+$(PKG)_IGNORE :=
+$(PKG)_VERSION := 9.19
+$(PKG)_NODOTVER := $(subst .,,$($(PKG)_VERSION))
+$(PKG)_CHECKSUM := f67acdcfcde1f86757ff3553cd719f12eac2d7681a0e96d8bdd1f40a0f47b45b
+$(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_URL := https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs$($(PKG)_NODOTVER)/$($(PKG)_FILE)
+$(PKG)_DEPS := gcc dbus fontconfig freetype lcms libiconv libidn libjpeg-turbo libpaper libpng openjpeg tiff zlib
+
+define $(PKG)_UPDATE
+ $(WGET) -q -O- 'http://ghostscript.com/Releases.html' | \
+ $(SED) -n 's:.*GPL_Ghostscript_::p' | \
+ $(SED) -n 's:\.html.*::p'
+endef
+
+define $(PKG)_BUILD
+ cd '$(SOURCE_DIR)' && rm -rf freetype jpeg lcms2 libpng openjpeg tiff zlib
+ cd '$(SOURCE_DIR)' && $(LIBTOOLIZE) --force --copy --install
+ cd '$(SOURCE_DIR)' && autoconf -f -i
+ cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \
+ $(MXE_CONFIGURE_OPTS) \
+ --disable-contrib \
+ --enable-threading \
+ --enable-fontconfig \
+ --enable-dbus \
+ --enable-freetype \
+ --disable-cups \
+ --enable-openjpeg \
+ --disable-gtk \
+ --with-libiconv=gnu \
+ --with-libidn \
+ --with-libpaper \
+ --with-system-libtiff \
+ --with-ijs \
+ --with-luratech \
+ --with-jbig2dec \
+ --with-omni \
+ --without-x \
+ --with-drivers=ALL \
+ --with-memory-alignment=$(if $(filter x86_64-%,$(TARGET)),8,4)
+ $(MAKE) -C '$(BUILD_DIR)' -j 1 $(if $(BUILD_STATIC),gs.a,so)
+
+ $(INSTALL) -d '$(PREFIX)/$(TARGET)/include/ghostscript'
+ $(INSTALL) '$(SOURCE_DIR)/devices/gdevdsp.h' '$(PREFIX)/$(TARGET)/include/ghostscript/gdevdsp.h'
+ $(INSTALL) '$(SOURCE_DIR)/base/gserrors.h' '$(PREFIX)/$(TARGET)/include/ghostscript/gserrors.h'
+ $(INSTALL) '$(SOURCE_DIR)/psi/iapi.h' '$(PREFIX)/$(TARGET)/include/ghostscript/iapi.h'
+ $(INSTALL) '$(SOURCE_DIR)/psi/ierrors.h' '$(PREFIX)/$(TARGET)/include/ghostscript/ierrors.h'
+
+ $(INSTALL) -d '$(PREFIX)/$(TARGET)/bin'
+ $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib'
+ $(if $(BUILD_STATIC),\
+ $(INSTALL) '$(BUILD_DIR)/gs.a' '$(PREFIX)/$(TARGET)/lib/libgs.a',\
+ $(INSTALL) '$(BUILD_DIR)/sobin/libgs-9.dll' '$(PREFIX)/$(TARGET)/bin/libgs-9.dll' && \
+ $(INSTALL) '$(BUILD_DIR)/sobin/libgs.dll.a' '$(PREFIX)/$(TARGET)/lib/libgs.dll.a')
+
+ $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
+ (echo 'Name: ghostscript'; \
+ echo 'Version: $($(PKG)_VERSION)'; \
+ echo 'Description: Ghostscript library'; \
+ echo 'Cflags: -I"$(PREFIX)/$(TARGET)/include/ghostscript"'; \
+ echo 'Cflags.private: -DGS_STATIC_LIB'; \
+ echo 'Libs: -L"$(PREFIX)/$(TARGET)/lib" -lgs'; \
+ echo 'Requires: libidn libtiff-4 libpng jpeg lcms2 zlib'; \
+ echo '# https://github.com/mxe/mxe/issues/1446'; \
+ echo 'Libs.private: -lm -liconv -lpaper -lopenjp2 -lwinspool';) \
+ > '$(PREFIX)/$(TARGET)/lib/pkgconfig/ghostscript.pc'
+
+ '$(TARGET)-gcc' \
+ -W -Wall -Werror -pedantic \
+ '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-ghostscript.exe' \
+ `$(TARGET)-pkg-config --cflags --libs ghostscript`
+endef
diff --git a/src/libspectre-1-fixes.patch b/src/libspectre-1-fixes.patch
new file mode 100644
index 0000000..50a1d7a
--- /dev/null
+++ b/src/libspectre-1-fixes.patch
@@ -0,0 +1,50 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains ad hoc patches for cross building.
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: darealshinji <djcj@gmx.de>
+Date: Thu, 21 Jul 2016 12:00:00 +0200
+Subject: [PATCH] add PKG_CHECK_MODULES macro to configure.ac
+
+
+diff --git a/configure.ac b/configure.ac
+index 1111111..2222222 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -65,6 +65,7 @@ AC_CHECK_FUNC(_vscprintf, [ AC_DEFINE(HAVE__VSCPRINTF, 1, [Define if the '_vscpr
+
+ LIBGS_REQUIRED="8.62"
+
++PKG_CHECK_MODULES(GHOSTSCRIPT, [ghostscript >= $LIBGS_REQUIRED], [LIB_GS="$GHOSTSCRIPT_LIBS"], [
+ AC_CHECK_LIB(gs, gsapi_new_instance, have_libgs=yes, have_libgs=no)
+ if test "x$have_libgs" = "xyes"; then
+ LIB_GS="-lgs"
+@@ -97,6 +98,7 @@ if test "x$have_libgs" = "xyes"; then
+ else
+ AC_MSG_ERROR([You need libgs in order to compile libspectre])
+ fi
++])
+ AC_SUBST(LIB_GS)
+
+ AC_ARG_ENABLE(asserts,
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: darealshinji <djcj@gmx.de>
+Date: Thu, 21 Jul 2016 12:00:00 +0200
+Subject: [PATCH] enable out-of-tree builds
+
+
+diff --git a/libspectre/Makefile.am b/libspectre/Makefile.am
+index 1111111..2222222 100644
+--- a/libspectre/Makefile.am
++++ b/libspectre/Makefile.am
+@@ -42,6 +42,7 @@ libspectre_la_SOURCES = \
+ $(gv_sources)
+
+ libspectre_la_CPPFLAGS = \
++ -I@top_srcdir@ \
+ $(SPECTRE_CFLAGS)
+
+ libspectre_la_LIBADD = $(LIB_GS)
diff --git a/src/libspectre-test.c b/src/libspectre-test.c
new file mode 100644
index 0000000..79f521e
--- /dev/null
+++ b/src/libspectre-test.c
@@ -0,0 +1,23 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <libspectre/spectre.h>
+
+int main(int argc, char *argv[])
+{
+ SpectreDocument *document;
+ SpectreRenderContext *rc;
+
+ (void)argc;
+ (void)argv;
+
+ document = spectre_document_new();
+ rc = spectre_render_context_new();
+
+ spectre_document_free(document);
+ spectre_render_context_free(rc);
+
+ return 0;
+}
diff --git a/src/libspectre.mk b/src/libspectre.mk
new file mode 100644
index 0000000..f3b1ae5
--- /dev/null
+++ b/src/libspectre.mk
@@ -0,0 +1,32 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG := libspectre
+$(PKG)_IGNORE :=
+$(PKG)_VERSION := 0.2.8
+$(PKG)_CHECKSUM := 65256af389823bbc4ee4d25bfd1cc19023ffc29ae9f9677f2d200fa6e98bc7a8
+$(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL := https://libspectre.freedesktop.org/releases/$($(PKG)_FILE)
+$(PKG)_DEPS := gcc cairo ghostscript
+
+define $(PKG)_UPDATE
+ $(WGET) -q -O- 'https://libspectre.freedesktop.org/releases/' | \
+ $(SED) -n 's:.*>LATEST-libspectre-::p' | \
+ $(SED) -n 's:<.*::p'
+endef
+
+define $(PKG)_BUILD
+ cd '$(SOURCE_DIR)' && autoreconf -f -i
+ cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \
+ $(MXE_CONFIGURE_OPTS) \
+ --disable-silent-rules \
+ --enable-test
+ $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' install
+ echo "Requires: cairo ghostscript" >> '$(PREFIX)/$(TARGET)/lib/pkgconfig/libspectre.pc'
+
+ '$(TARGET)-gcc' \
+ -W -Wall -Werror -ansi -pedantic \
+ '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
+ `'$(TARGET)-pkg-config' $(PKG) --cflags --libs`
+endef
diff --git a/src/ocaml-camlimages-1-fixes.patch b/src/ocaml-camlimages-1-fixes.patch
index 4f87fa5..b6b856e 100644
--- a/src/ocaml-camlimages-1-fixes.patch
+++ b/src/ocaml-camlimages-1-fixes.patch
@@ -3,17 +3,18 @@ See index.html for further information.
Contains ad hoc patches for cross building.
-From c09e9baa34783c7dd44cc5afc65f1f4b4030ebf2 Mon Sep 17 00:00:00 2001
-From: MXE
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "fix@me" <fix@me>
Date: Sun, 12 Aug 2012 20:55:49 +0200
-Subject: [PATCH 1/4] set back configure build system that enables cross compilation (instead of OMake)
+Subject: [PATCH] set back configure build system that enables cross
+ compilation (instead of OMake)
this patch and next ones are taken from camlimages bug tracker :
http://modulogic.inria.fr/bugtracker/view.php?id=7
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
-index 0000000..cdaf30d
+index 1111111..2222222
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,58 @@
@@ -77,7 +78,7 @@ index 0000000..cdaf30d
+# $(INSTALL) -g caml -m g+w $(DISTFILE) $(FTPSITEDIR)
diff --git a/Makefile.rules b/Makefile.rules
new file mode 100644
-index 0000000..a2a41d9
+index 1111111..2222222
--- /dev/null
+++ b/Makefile.rules
@@ -0,0 +1,36 @@
@@ -119,7 +120,7 @@ index 0000000..a2a41d9
+@AMDEP_TRUE@@am__include@ @am__quote@.depend@am__quote@
diff --git a/Makefile.variables b/Makefile.variables
new file mode 100644
-index 0000000..c29c97b
+index 1111111..2222222
--- /dev/null
+++ b/Makefile.variables
@@ -0,0 +1,49 @@
@@ -173,7 +174,7 @@ index 0000000..c29c97b
+ $(OCAMLSOURCES:.ml=.cmi) \
+ $(COBJS)
diff --git a/configure.ac b/configure.ac
-index 06464b3..12269c9 100644
+index 1111111..2222222 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,68 +1,62 @@
@@ -472,7 +473,7 @@ index 06464b3..12269c9 100644
Lablgtk2 support: $SUPPORT_LABLGTK2
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
-index 0000000..3c4ac76
+index 1111111..2222222
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,36 @@
@@ -514,7 +515,7 @@ index 0000000..3c4ac76
+ mv eng.html.tmp eng.html
diff --git a/doc/sphinx/Makefile b/doc/sphinx/Makefile
new file mode 100644
-index 0000000..45073fd
+index 1111111..2222222
--- /dev/null
+++ b/doc/sphinx/Makefile
@@ -0,0 +1,89 @@
@@ -609,7 +610,7 @@ index 0000000..45073fd
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644
-index 0000000..38d4474
+index 1111111..2222222
--- /dev/null
+++ b/examples/Makefile.am
@@ -0,0 +1,37 @@
@@ -652,7 +653,7 @@ index 0000000..38d4474
+endif
diff --git a/examples/converter/Makefile.am b/examples/converter/Makefile.am
new file mode 100644
-index 0000000..1de0339
+index 1111111..2222222
--- /dev/null
+++ b/examples/converter/Makefile.am
@@ -0,0 +1,43 @@
@@ -701,7 +702,7 @@ index 0000000..1de0339
+include ../../Makefile.rules
diff --git a/examples/crop/Makefile.am b/examples/crop/Makefile.am
new file mode 100644
-index 0000000..23e3852
+index 1111111..2222222
--- /dev/null
+++ b/examples/crop/Makefile.am
@@ -0,0 +1,44 @@
@@ -751,7 +752,7 @@ index 0000000..23e3852
+include ../../Makefile.rules
diff --git a/examples/edgedetect/Makefile.am b/examples/edgedetect/Makefile.am
new file mode 100644
-index 0000000..556730a
+index 1111111..2222222
--- /dev/null
+++ b/examples/edgedetect/Makefile.am
@@ -0,0 +1,42 @@
@@ -799,7 +800,7 @@ index 0000000..556730a
+include ../../Makefile.rules
diff --git a/examples/gifanim/Makefile.am b/examples/gifanim/Makefile.am
new file mode 100644
-index 0000000..1c8c5e0
+index 1111111..2222222
--- /dev/null
+++ b/examples/gifanim/Makefile.am
@@ -0,0 +1,50 @@
@@ -855,7 +856,7 @@ index 0000000..1c8c5e0
+include ../../Makefile.rules
diff --git a/examples/imgstat/Makefile.am b/examples/imgstat/Makefile.am
new file mode 100644
-index 0000000..b74f90c
+index 1111111..2222222
--- /dev/null
+++ b/examples/imgstat/Makefile.am
@@ -0,0 +1,42 @@
@@ -903,7 +904,7 @@ index 0000000..b74f90c
+include ../../Makefile.rules
diff --git a/examples/liv-furuse/Makefile.am b/examples/liv-furuse/Makefile.am
new file mode 100644
-index 0000000..7c993d8
+index 1111111..2222222
--- /dev/null
+++ b/examples/liv-furuse/Makefile.am
@@ -0,0 +1,77 @@
@@ -986,7 +987,7 @@ index 0000000..7c993d8
+include ../../Makefile.rules
diff --git a/examples/liv/Makefile.am b/examples/liv/Makefile.am
new file mode 100644
-index 0000000..7c993d8
+index 1111111..2222222
--- /dev/null
+++ b/examples/liv/Makefile.am
@@ -0,0 +1,77 @@
@@ -1069,7 +1070,7 @@ index 0000000..7c993d8
+include ../../Makefile.rules
diff --git a/examples/monochrome/Makefile.am b/examples/monochrome/Makefile.am
new file mode 100644
-index 0000000..9cfb0bc
+index 1111111..2222222
--- /dev/null
+++ b/examples/monochrome/Makefile.am
@@ -0,0 +1,42 @@
@@ -1117,7 +1118,7 @@ index 0000000..9cfb0bc
+include ../../Makefile.rules
diff --git a/examples/normalize/Makefile.am b/examples/normalize/Makefile.am
new file mode 100644
-index 0000000..6af840b
+index 1111111..2222222
--- /dev/null
+++ b/examples/normalize/Makefile.am
@@ -0,0 +1,42 @@
@@ -1165,7 +1166,7 @@ index 0000000..6af840b
+include ../../Makefile.rules
diff --git a/examples/resize/Makefile.am b/examples/resize/Makefile.am
new file mode 100644
-index 0000000..10a181c
+index 1111111..2222222
--- /dev/null
+++ b/examples/resize/Makefile.am
@@ -0,0 +1,42 @@
@@ -1213,7 +1214,7 @@ index 0000000..10a181c
+include ../../Makefile.rules
diff --git a/examples/tiffps/Makefile.am b/examples/tiffps/Makefile.am
new file mode 100644
-index 0000000..56e657d
+index 1111111..2222222
--- /dev/null
+++ b/examples/tiffps/Makefile.am
@@ -0,0 +1,42 @@
@@ -1261,7 +1262,7 @@ index 0000000..56e657d
+include ../../Makefile.rules
diff --git a/examples/ttfimg/Makefile.am b/examples/ttfimg/Makefile.am
new file mode 100644
-index 0000000..32a518d
+index 1111111..2222222
--- /dev/null
+++ b/examples/ttfimg/Makefile.am
@@ -0,0 +1,42 @@
@@ -1308,7 +1309,7 @@ index 0000000..32a518d
+
+include ../../Makefile.rules
diff --git a/ocaml.m4 b/ocaml.m4
-index 9a59648..6431281 100644
+index 1111111..2222222 100644
--- a/ocaml.m4
+++ b/ocaml.m4
@@ -1,279 +1,197 @@
@@ -1787,7 +1788,7 @@ index 9a59648..6431281 100644
+])
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
-index 0000000..6d90c5d
+index 1111111..2222222
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,256 @@
@@ -2049,7 +2050,7 @@ index 0000000..6d90c5d
+include ../Makefile.rules
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
-index 0000000..a02b0bf
+index 1111111..2222222
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,54 @@
@@ -2107,18 +2108,15 @@ index 0000000..a02b0bf
+
+
+include ../Makefile.rules
---
-1.7.2.5
-
-From 79be4b11cf6e32056ac199efb48728fd7a09bbe9 Mon Sep 17 00:00:00 2001
-From: MXE
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "fix@me" <fix@me>
Date: Sun, 12 Aug 2012 20:56:46 +0200
-Subject: [PATCH 2/4] modify META file with ad-hock patch to make it usable in MXE
+Subject: [PATCH] modify META file with ad-hock patch to make it usable in MXE
diff --git a/src/META.in b/src/META.in
-index 45e96d6..e1b1c18 100644
+index 1111111..2222222 100644
--- a/src/META.in
+++ b/src/META.in
@@ -2,68 +2,15 @@ name = "CamlImages"
@@ -2194,18 +2192,16 @@ index 45e96d6..e1b1c18 100644
+ archive(byte) = "camlimages.cma"
+ archive(native) = "camlimages.cmxa"
)
---
-1.7.2.5
-
-From 7ecf7a9c4ca35e5f43514cfc634d09999ee0a099 Mon Sep 17 00:00:00 2001
-From: MXE
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "fix@me" <fix@me>
Date: Sun, 12 Aug 2012 20:58:10 +0200
-Subject: [PATCH 3/4] update gifread.c and gifwrite.c for new giflib-5.0.0, and png for similar purpose
+Subject: [PATCH] update gifread.c and gifwrite.c for new giflib-5.0.0, and png
+ for similar purpose
diff --git a/src/gifread.c b/src/gifread.c
-index ecf40c4..097db1d 100644
+index 1111111..2222222 100644
--- a/src/gifread.c
+++ b/src/gifread.c
@@ -140,7 +140,7 @@ value dGifOpenFileName( value name )
@@ -2232,7 +2228,7 @@ index ecf40c4..097db1d 100644
}
CAMLreturn(buf);
diff --git a/src/gifwrite.c b/src/gifwrite.c
-index 4b6399f..caf04c0 100644
+index 1111111..2222222 100644
--- a/src/gifwrite.c
+++ b/src/gifwrite.c
@@ -25,7 +25,7 @@
@@ -2285,7 +2281,7 @@ index 4b6399f..caf04c0 100644
failwith("EGifPutExtension");
}
diff --git a/src/pngread.c b/src/pngread.c
-index cc576e8..ce25110 100644
+index 1111111..2222222 100644
--- a/src/pngread.c
+++ b/src/pngread.c
@@ -69,7 +69,7 @@ value read_png_file_as_rgb24( name )
@@ -2325,7 +2321,7 @@ index cc576e8..ce25110 100644
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
fclose(fp);
diff --git a/src/pngwrite.c b/src/pngwrite.c
-index 3248562..6937cd8 100644
+index 1111111..2222222 100644
--- a/src/pngwrite.c
+++ b/src/pngwrite.c
@@ -62,7 +62,7 @@ value write_png_file_rgb( name, buffer, width, height, with_alpha )
@@ -2346,18 +2342,16 @@ index 3248562..6937cd8 100644
/* Free all of the memory associated with the png_ptr and info_ptr */
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
---
-1.7.2.5
-
-From f35cfc4a23431f0da77f9fa75f6d102a7b09e094 Mon Sep 17 00:00:00 2001
-From: MXE
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "fix@me" <fix@me>
Date: Wed, 3 Oct 2012 09:37:05 +0200
-Subject: [PATCH 4/4] META : add camlimages.lablgtk2 and camlimages.freetype (referencing camlimages.all_formats)
+Subject: [PATCH] META : add camlimages.lablgtk2 and camlimages.freetype
+ (referencing camlimages.all_formats)
diff --git a/src/META.in b/src/META.in
-index e1b1c18..5994beb 100644
+index 1111111..2222222 100644
--- a/src/META.in
+++ b/src/META.in
@@ -9,8 +9,16 @@ package "core" (
@@ -2378,6 +2372,36 @@ index e1b1c18..5994beb 100644
archive(byte) = "camlimages.cma"
archive(native) = "camlimages.cmxa"
)
---
-1.7.2.5
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tony Theodore <tonyt@logyst.com>
+Date: Sun, 17 Jul 2016 12:16:43 +1000
+Subject: [PATCH] fix for giflib >=5.1
+
+
+diff --git a/src/gifread.c b/src/gifread.c
+index 1111111..2222222 100644
+--- a/src/gifread.c
++++ b/src/gifread.c
+@@ -161,7 +161,7 @@ value dGifCloseFile( value hdl )
+ segmentation faults */
+ ((GifFileType *)hdl)->Image.ColorMap = NULL;
+
+- DGifCloseFile( (GifFileType *) hdl );
++ DGifCloseFile( (GifFileType *) hdl, NULL );
+ CAMLreturn(Val_unit);
+ }
+
+diff --git a/src/gifwrite.c b/src/gifwrite.c
+index 1111111..2222222 100644
+--- a/src/gifwrite.c
++++ b/src/gifwrite.c
+@@ -88,7 +88,7 @@ value eGifCloseFile( value hdl )
+ segmentation faults */
+ ((GifFileType *)hdl)->Image.ColorMap = NULL;
+
+- EGifCloseFile( (GifFileType *) hdl );
++ EGifCloseFile( (GifFileType *) hdl, NULL );
+ CAMLreturn(Val_unit);
+ }
+
diff --git a/src/poppler-1-win32.patch b/src/poppler-1-win32.patch
index e301e24..bd836ef 100644
--- a/src/poppler-1-win32.patch
+++ b/src/poppler-1-win32.patch
@@ -99,3 +99,29 @@ index 1111111..2222222 100644
# define _POPPLER_QT4_LIB_EXPORT __declspec(dllexport)
# define _POPPLER_QT4_LIB_IMPORT __declspec(dllimport)
#elif defined(__GNUC__)
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Boris Nagaev <bnagaev@gmail.com>
+Date: Wed, 27 Jul 2016 10:29:52 +0200
+Subject: [PATCH] do not try to use mman.h (package mman-win32)
+
+fix https://github.com/mxe/mxe/issues/1455
+
+diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
+index 1111111..2222222 100644
+--- a/poppler/CairoFontEngine.cc
++++ b/poppler/CairoFontEngine.cc
+@@ -48,13 +48,6 @@
+ #include "Gfx.h"
+ #include "Page.h"
+
+-#if HAVE_FCNTL_H && HAVE_SYS_MMAN_H && HAVE_SYS_STAT_H
+-#include <fcntl.h>
+-#include <sys/stat.h>
+-#include <sys/mman.h>
+-#define CAN_CHECK_OPEN_FACES 1
+-#endif
+-
+ #ifdef USE_GCC_PRAGMAS
+ #pragma implementation
+ #endif