diff -Naur ghostscript-9.10-orig/base/gp_mswin.c ghostscript-9.10/base/gp_mswin.c --- ghostscript-9.10-orig/base/gp_mswin.c 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/gp_mswin.c 2014-01-22 20:16:23.009800000 +0400 @@ -866,6 +866,7 @@ return((bool)S_ISREG(s.st_mode)); } +#ifndef __MINGW64_VERSION_MAJOR /* ------------------------- _snprintf -----------------------------*/ /* Microsoft Visual C++ 2005 doesn't properly define snprintf, @@ -885,3 +886,4 @@ } else return 0; } +#endif diff -Naur ghostscript-9.10-orig/base/gp_mswin.h ghostscript-9.10/base/gp_mswin.h --- ghostscript-9.10-orig/base/gp_mswin.h 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/gp_mswin.h 2014-01-22 17:21:46.232600000 +0400 @@ -56,4 +56,13 @@ #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 -Naur ghostscript-9.10-orig/base/gs.mak ghostscript-9.10/base/gs.mak --- ghostscript-9.10-orig/base/gs.mak 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/gs.mak 2014-01-22 17:21:46.248200000 +0400 @@ -440,6 +440,7 @@ # save our set of makefile variables that are defined in every build (paths, etc.) $(gconfigd_h) : $(ECHOGS_XE) $(GS_MAK) $(TOP_MAKEFILES) $(GLSRCDIR)$(D)version.mak $(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 -Naur ghostscript-9.10-orig/base/lib.mak ghostscript-9.10/base/lib.mak --- ghostscript-9.10-orig/base/lib.mak 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/lib.mak 2014-01-23 06:33:46.689000000 +0400 @@ -41,13 +41,13 @@ # 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 -Naur ghostscript-9.10-orig/base/mingw-fp.sh ghostscript-9.10/base/mingw-fp.sh --- ghostscript-9.10-orig/base/mingw-fp.sh 1970-01-01 03:00:00.000000000 +0300 +++ ghostscript-9.10/base/mingw-fp.sh 2014-01-22 22:30:58.082800000 +0400 @@ -0,0 +1 @@ +sed -i -e 's?\\?/?g' $1 diff -Naur ghostscript-9.10-orig/base/mingw-fs.mak ghostscript-9.10/base/mingw-fs.mak --- ghostscript-9.10-orig/base/mingw-fs.mak 1970-01-01 03:00:00.000000000 +0300 +++ ghostscript-9.10/base/mingw-fs.mak 2014-01-22 17:21:46.248200000 +0400 @@ -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 -Naur ghostscript-9.10-orig/base/mingwlib.mak ghostscript-9.10/base/mingwlib.mak --- ghostscript-9.10-orig/base/mingwlib.mak 1970-01-01 03:00:00.000000000 +0300 +++ ghostscript-9.10/base/mingwlib.mak 2014-01-22 17:21:46.248200000 +0400 @@ -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 -Naur ghostscript-9.10-orig/base/time_.h ghostscript-9.10/base/time_.h --- ghostscript-9.10-orig/base/time_.h 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/time_.h 2014-01-22 22:04:50.786200000 +0400 @@ -78,7 +78,7 @@ #endif /* Some System V environments, and Posix environments, need . */ -#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 # define use_times_for_usertime 1 /* Posix 1003.1b-1993 section 4.8.1.5 says that diff -Naur ghostscript-9.10-orig/base/unix-aux.mak ghostscript-9.10/base/unix-aux.mak --- ghostscript-9.10-orig/base/unix-aux.mak 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/unix-aux.mak 2014-01-22 20:08:25.945400000 +0400 @@ -66,6 +66,13 @@ $(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) +$(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) $(MAKEDIRS) @@ -88,18 +95,31 @@ # 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) $(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) $(CCAUX_) $(GENOPT) $(CFLAGS) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_1 $(MKROMFS_OBJS_1) $(AUXEXTRALIBS) diff -Naur ghostscript-9.10-orig/base/unix-dll.mak ghostscript-9.10/base/unix-dll.mak --- ghostscript-9.10-orig/base/unix-dll.mak 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/unix-dll.mak 2014-01-22 23:27:18.357000000 +0400 @@ -33,17 +33,38 @@ # 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) @@ -80,27 +101,27 @@ # Create symbolic links to the Ghostscript interpreter library -$(GS_SO): $(GS_SO_MAJOR) +$(GS_SO): $(GS_SO_MAJOR_MINOR) $(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) - $(RM_) $(GS_SO_MAJOR) - ln -s $(GS_SONAME_MAJOR_MINOR) $(GS_SO_MAJOR) +$(GS_SO_MAJOR_MINOR): $(GS_SO_MAJOR) + $(RM_) $(GS_SO_MAJOR_MINOR) + ln -s $(GS_SONAME_MAJOR) $(GS_SO_MAJOR_MINOR) # Build the small Ghostscript loaders, with Gtk+ and without $(GSSOC_XE): $(GS_SO) $(PSSRC)$(SOC_LOADER) - $(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): $(GS_SO) $(PSSRC)$(SOC_LOADER) $(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) @@ -158,11 +179,16 @@ -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) $(PSSRC)iapi.h $(DESTDIR)$(gsincludedir)iapi.h $(INSTALL_DATA) $(PSSRC)ierrors.h $(DESTDIR)$(gsincludedir)ierrors.h $(INSTALL_DATA) $(DEVSRC)gdevdsp.h $(DESTDIR)$(gsincludedir)gdevdsp.h diff -Naur ghostscript-9.10-orig/base/unix-gcc.mak ghostscript-9.10/base/unix-gcc.mak --- ghostscript-9.10-orig/base/unix-gcc.mak 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/unix-gcc.mak 2014-01-22 22:02:03.959800000 +0400 @@ -57,13 +57,13 @@ INSTALL_PROGRAM = $(INSTALL) -m 755 INSTALL_DATA = $(INSTALL) -m 644 -prefix = /usr/local +prefix = /usr exec_prefix = $(prefix) bindir = $(exec_prefix)/bin scriptdir = $(bindir) includedir = $(prefix)/include libdir = $(exec_prefix)/lib -mandir = $(prefix)/man +mandir = $(prefix)/share/man man1ext = 1 datadir = $(prefix)/share gsdir = $(datadir)/ghostscript @@ -71,7 +71,7 @@ gssharedir = $(libdir)/ghostscript/$(GS_DOT_VERSION) gsincludedir = $(includedir)/ghostscript/ -docdir=$(gsdatadir)/doc +docdir=$(gsdatadir)/doc/ghostscript-$(GS_DOT_VERSION) exdir=$(gsdatadir)/examples GS_DOCDIR=$(docdir) diff -Naur ghostscript-9.10-orig/base/unixhead.mak ghostscript-9.10/base/unixhead.mak --- ghostscript-9.10-orig/base/unixhead.mak 2013-08-30 14:37:28.000000000 +0400 +++ ghostscript-9.10/base/unixhead.mak 2014-01-22 20:26:04.888400000 +0400 @@ -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 @@ # 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 -Naur ghostscript-9.10-orig/configure.ac ghostscript-9.10/configure.ac --- ghostscript-9.10-orig/configure.ac 2013-08-30 14:37:29.000000000 +0400 +++ ghostscript-9.10/configure.ac 2014-01-22 19:17:58.671800000 +0400 @@ -180,6 +180,26 @@ CC_DBG_FLAGS_TO_TRY="-g -O0" 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) @@ -1403,12 +1423,41 @@ 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 @@ -1441,9 +1490,15 @@ 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], @@ -1920,6 +1975,12 @@ DYNAMIC_LIBS="" 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], @@ -1992,6 +2053,20 @@ 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" diff -Naur ghostscript-9.10-orig/Makefile.in ghostscript-9.10/Makefile.in --- ghostscript-9.10-orig/Makefile.in 2013-08-30 14:37:29.000000000 +0400 +++ ghostscript-9.10/Makefile.in 2014-01-22 22:30:09.450000000 +0400 @@ -38,6 +38,14 @@ PSOBJDIR=./$(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 @@ -146,7 +154,16 @@ # Define the name of the executable file. -GS=@GS@@EXEEXT@ +ifeq ($(MINGW_BUILD), 1) + # On Windows, building a shared object and the accompanying thin loaders is the recommended method, + # so we need to eliminate the .exe from the dll's name. + # At the same time, should a user want to use the basic make, + # he/she may simply pass --with-gs='gs.exe' or --with-gs='gswin32.exe' to ./configure + GS=@GS@ +else + # define GS in all other platforms + GS=@GS@@EXEEXT@ +endif GS_SO_BASE=@GS@ XE=@EXEEXT@ XEAUX=@EXEEXT@ @@ -387,8 +404,8 @@ # Solaris may need -lnsl -lsocket -lposix4. # (Libraries required by individual drivers are handled automatically.) -EXTRALIBS=$(XTRALIBS) @LIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ -AUXEXTRALIBS=$(XTRALIBS) @LIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ @AUX_SHARED_ZLIB@ +EXTRALIBS=$(XTRALIBS) @LIBS@ @MINGW_XTLIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ +AUXEXTRALIBS=$(XTRALIBS) @LIBS@ @MINGW_XTLIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ @AUX_SHARED_ZLIB@ # Define the standard libraries to search at the end of linking. # Most platforms require -lpthread for the POSIX threads library; @@ -438,9 +455,10 @@ 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 @@ -568,7 +586,17 @@ 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_) @@ -622,6 +650,12 @@ @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)