diff --git a/src/ghostscript-1-fixes.patch b/src/ghostscript-1-fixes.patch index 73e9ab5f..5e5c2ec2 100644 --- a/src/ghostscript-1-fixes.patch +++ b/src/ghostscript-1-fixes.patch @@ -2,80 +2,12 @@ This file is part of MXE. See LICENSE.md for licensing information. Contains ad hoc patches for cross building. -diff --git a/configure.ac b/configure.ac -index 1111111..2222222 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -146,9 +148,16 @@ if test x"$CCAUX" != x"" ; then - echo $AUXFLAGS_MAK_LINE06 >> $AUXFLAGS_MAK.in - echo $AUXFLAGS_MAK_LINE07 >> $AUXFLAGS_MAK.in - -- ../$0 CC="$CCAUX" CFLAGS="$CFLAGSAUX" LDFLAGS="$LDFLAGSAUX" CCAUX= CFLAGSAUX= CFLAGSAUX= MAKEFILE=$AUXFLAGS_MAK --host= --build= --without-libtiff --disable-contrib --disable-fontconfig --disable-dbus --disable-freetype --disable-fapi --disable-cups --disable-openjpeg --disable-gtk --with-libiconv=no --without-libidn --without-libpaper --without-pdftoraster --without-ijs --without-luratech --without-jbig2dec --without-x --with-drivers="" -+ if test "$0" = "./configure" ; then -+ basedir=".." -+ configure="../configure" -+ else -+ basedir="$(basename "$0")" -+ configure="$0" -+ fi -+ "$configure" CC="$CCAUX" CFLAGS="$CFLAGSAUX" LDFLAGS="$LDFLAGSAUX" CCAUX= CFLAGSAUX= CFLAGSAUX= MAKEFILE=$AUXFLAGS_MAK --host= --build= --without-libtiff --disable-contrib --disable-fontconfig --disable-dbus --disable-freetype --disable-fapi --disable-cups --disable-openjpeg --disable-gtk --with-libiconv=no --without-libidn --without-libpaper --without-pdftoraster --without-ijs --without-luratech --without-jbig2dec --without-x --with-drivers="" - status=$? -- cp config.log ../configaux.log -+ cp config.log "$basedir/configaux.log" - if test $status -eq 0 ; then - CCAUX=$(grep CCAUX $AUXFLAGS_MAK | sed "s/CCAUX=//g") - GCFLAGSAUXTMP=$(grep GCFLAGSAUX $AUXFLAGS_MAK | sed "s/GCFLAGSAUX=//g") -@@ -974,7 +983,7 @@ if test x"$enable_fapi" != xno; then - if $PKGCONFIG --atleast-version=12.0.6 freetype2; then - AC_MSG_RESULT(yes) - FT_CFLAGS="$CFLAGS `$PKGCONFIG --cflags freetype2`" -- FT_LIBS="`$PKGCONFIG --libs freetype2`" -+ FT_LIBS="`$PKGCONFIG --libs-only-l freetype2`" - FT_BRIDGE=1 - SHARE_FT=1 - else -@@ -2323,12 +2323,6 @@ - GS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)" - PCL_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(PCL_SONAME_MAJOR)" - XPS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(XPS_SONAME_MAJOR)" -- if test $ac_cv_prog_gcc = yes; then -- # GCC high level flag -- DYNAMIC_LIBS="-rdynamic" -- else -- DYNAMIC_LIBS="" -- fi - SO_LIB_EXT=".so" - else - case `uname` in -@@ -2337,12 +2331,6 @@ - GS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)" - PCL_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(PCL_SONAME_MAJOR)" - XPS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(XPS_SONAME_MAJOR)" -- if test $ac_cv_prog_gcc = yes; then -- # GCC high level flag -- DYNAMIC_LIBS="-rdynamic" -- else -- DYNAMIC_LIBS="" -- fi - SO_LIB_EXT=".so" - ;; - MINGW*|MSYS*) -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 @@ - # 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: darealshinji +Date: Sun, 20 May 2018 12:01:00 +0200 +Subject: [PATCH 1/8] source code fixes + + diff --git a/psi/iapi.c b/psi/iapi.c index 1111111..2222222 100644 --- a/psi/iapi.c @@ -90,15 +22,15 @@ index 1111111..2222222 100644 #include "string_.h" #include "ierrors.h" #include "gscdefs.h" -@@ -42,6 +45,57 @@ static const int gsapi_instance_max = 1; +@@ -41,6 +44,55 @@ static int gsapi_instance_counter = 0; + static const int gsapi_instance_max = 1; #endif - +/* A function to decode the next codepoint of the supplied args from the + * local windows codepage, or -1 for EOF. ++ * (copied from base/gp_win32.c) + */ -+ -+#ifdef __WIN32__ ++#if defined(__WIN32__) && !defined(METRO) +int +gp_local_arg_encoding_get_codepoint(FILE *file, const char **astr) +{ @@ -143,8 +75,671 @@ index 1111111..2222222 100644 + return unicode[0]; +} +#endif /* __WIN32__ */ -+ -+ + /* Return revision numbers and strings of Ghostscript. */ /* Used for determining if wrong GSDLL loaded. */ - /* This may be called before any other function. */ +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: darealshinji +Date: Sun, 20 May 2018 12:02:00 +0200 +Subject: [PATCH 2/8] aux tools will choke on -L linker flags + + +diff --git a/configure.ac b/configure.ac +index 1111111..2222222 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -974,7 +974,7 @@ if test x"$enable_fapi" != xno; then + if $PKGCONFIG --atleast-version=12.0.6 freetype2; then + AC_MSG_RESULT(yes) + FT_CFLAGS="$CFLAGS `$PKGCONFIG --cflags freetype2`" +- FT_LIBS="`$PKGCONFIG --libs freetype2`" ++ FT_LIBS="`$PKGCONFIG --libs-only-l freetype2`" + FT_BRIDGE=1 + SHARE_FT=1 + else + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: darealshinji +Date: Sun, 20 May 2018 12:03:00 +0200 +Subject: [PATCH 3/8] enable out-of-tree builds + + +diff --git a/configure.ac b/configure.ac +index 1111111..2222222 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -146,9 +146,16 @@ if test x"$CCAUX" != x"" ; then + echo $AUXFLAGS_MAK_LINE06 >> $AUXFLAGS_MAK.in + echo $AUXFLAGS_MAK_LINE07 >> $AUXFLAGS_MAK.in + +- ../$0 CC="$CCAUX" CFLAGS="$CFLAGSAUX" LDFLAGS="$LDFLAGSAUX" CCAUX= CFLAGSAUX= CFLAGSAUX= MAKEFILE=$AUXFLAGS_MAK --host= --build= --without-libtiff --disable-contrib --disable-fontconfig --disable-dbus --disable-freetype --disable-fapi --disable-cups --disable-openjpeg --disable-gtk --with-libiconv=no --without-libidn --without-libpaper --without-pdftoraster --without-ijs --without-luratech --without-jbig2dec --without-x --with-drivers="" ++ if test "$0" = "./configure" ; then ++ basedir=".." ++ configure="../configure" ++ else ++ basedir="$(basename "$0")" ++ configure="$0" ++ fi ++ "$configure" CC="$CCAUX" CFLAGS="$CFLAGSAUX" LDFLAGS="$LDFLAGSAUX" CCAUX= CFLAGSAUX= CFLAGSAUX= MAKEFILE=$AUXFLAGS_MAK --host= --build= --without-libtiff --disable-contrib --disable-fontconfig --disable-dbus --disable-freetype --disable-fapi --disable-cups --disable-openjpeg --disable-gtk --with-libiconv=no --without-libidn --without-libpaper --without-pdftoraster --without-ijs --without-luratech --without-jbig2dec --without-x --with-drivers="" + status=$? +- cp config.log ../configaux.log ++ cp config.log "$basedir/configaux.log" + if test $status -eq 0 ; then + CCAUX=$(grep CCAUX $AUXFLAGS_MAK | sed "s/CCAUX=//g") + GCFLAGSAUXTMP=$(grep GCFLAGSAUX $AUXFLAGS_MAK | sed "s/GCFLAGSAUX=//g") + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: darealshinji +Date: Sun, 20 May 2018 12:04:00 +0200 +Subject: [PATCH 4/8] don't rebuild aux tools if they already exist + + +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 +@@ -67,23 +67,29 @@ $(GLOBJ)gp_sysv.$(OBJ): $(GLSRC)gp_sysv.c $(stdio__h) $(time__h) $(AK)\ + # -------------------------- Auxiliary programs --------------------------- # + + $(ECHOGS_XE): $(GLSRC)echogs.c $(AK) $(stdpre_h) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CCAUX_) $(I_)$(GLSRCDIR)$(_I) $(O_)$(ECHOGS_XE) $(GLSRC)echogs.c $(AUXEXTRALIBS) + + $(PACKPS_XE): $(GLSRC)pack_ps.c $(stdpre_h) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CCAUX_) $(I_)$(GLSRCDIR)$(_I) $(O_)$(PACKPS_XE) $(GLSRC)pack_ps.c $(AUXEXTRALIBS) + + # On the RS/6000 (at least), compiling genarch.c with gcc with -O + # produces a buggy executable. + $(GENARCH_XE): $(GLSRC)genarch.c $(AK) $(GENARCH_DEPS) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CCAUX_) $(I_)$(GLSRCDIR)$(_I) $(O_)$(GENARCH_XE) $(GLSRC)genarch.c $(AUXEXTRALIBS) + + $(GENCONF_XE): $(GLSRC)genconf.c $(AK) $(GENCONF_DEPS) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CCAUX_) $(I_)$(GLSRCDIR)$(_I) $(O_)$(GENCONF_XE) $(GLSRC)genconf.c $(AUXEXTRALIBS) + + $(GENDEV_XE): $(GLSRC)gendev.c $(AK) $(GENDEV_DEPS) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CCAUX_) $(I_)$(GLSRCDIR)$(_I) $(O_)$(GENDEV_XE) $(GLSRC)gendev.c $(AUXEXTRALIBS) + + $(GENHT_XE): $(GLSRC)genht.c $(AK) $(GENHT_DEPS) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CCAUX_) $(GENHT_CFLAGS) $(O_)$(GENHT_XE) $(GLSRC)genht.c $(AUXEXTRALIBS) + + # To get GS to use the system zlib, you remove/hide the gs/zlib directory +@@ -94,6 +100,7 @@ MKROMFS_OBJS_0=$(MKROMFS_ZLIB_OBJS) $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \ + $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ) $(AUX)memento.$(OBJ) + + $(MKROMFS_XE)_0: $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS_0) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CCAUX_) $(GENOPTAUX) $(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 +@@ -103,9 +110,11 @@ MKROMFS_OBJS_1=$(AUX)gscdefs.$(OBJ) \ + $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ) + + $(MKROMFS_XE)_1: $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS_1) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CCAUX_) $(GENOPTAUX) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_1 $(MKROMFS_OBJS_1) $(AUXEXTRALIBS) + + $(MKROMFS_XE): $(MKROMFS_XE)_$(SHARE_ZLIB) $(UNIX_AUX_MAK) $(MAKEDIRS) ++ test -e $@ || \ + $(CP_) $(MKROMFS_XE)_$(SHARE_ZLIB) $(MKROMFS_XE) + + # Query the environment to construct gconfig_.h. + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: darealshinji +Date: Sun, 20 May 2018 12:05:00 +0200 +Subject: [PATCH 5/8] replace uname command with $host variable; always enable + directory name workarounds + + +diff --git a/configure.ac b/configure.ac +index 1111111..2222222 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -23,6 +23,7 @@ AC_INIT + AC_PREREQ(2.63) + AC_LANG(C) + AC_CONFIG_SRCDIR(psi/gs.c) ++AC_CANONICAL_HOST + + dnl Inherit compiler flags from the environment... + CFLAGS="${CFLAGS:=}" +@@ -241,18 +242,14 @@ CONTRIBINCLUDE="include $srcdir/contrib/contrib.mak" + INSTALL_CONTRIB="install-contrib-extras" + + if test x"$enable_contrib" = x; then +- if test x"$cross_compiling" = x"yes"; then +- enable_contrib= +- else +- case `uname` in +- MINGW*|MSYS*) ++ case $host in ++ *-mingw*|*-msys*|*-cygwin*) + AC_MSG_WARN([disabling contrib devices]) + enable_contrib=no + ;; + *) + ;; + esac +- fi + fi + + if test x"$enable_contrib" != x"no"; then +@@ -281,33 +278,27 @@ dnl -------------------------------------------------- + CC_OPT_FLAGS_TO_TRY="-O" + SET_DT_SONAME="-soname=" + +-if test x"$cross_compiling" = x"yes"; then +- if test $ac_cv_prog_gcc = yes; then +- CC_OPT_FLAGS_TO_TRY="-O2" +- CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0" +- fi +-else +- case `uname` in +- Linux*|GNU*) ++case $host in ++ *-linux*) + 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) ++ *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) ++ *-sun*) + CC_OPT_FLAGS_TO_TRY="-O2" + # the trailing space is required! + if test $ac_cv_prog_gcc = no; then +@@ -320,15 +311,14 @@ else + 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 + ;; +- esac +-fi ++esac + + AC_SUBST(SET_DT_SONAME) + +@@ -353,18 +343,20 @@ AC_ARG_WITH([arch_h], AC_HELP_STRING([--with-arch_h=], + ARCH_CONF_HEADER= + + if test x"$with_arch_h" = x""; then +- if test x"$cross_compiling" = x"yes"; then +- ARCH_CONF_HEADER="\$(GLSRCDIR)/../$ARCH_AUTOCONF_HEADER" +- else +- case `uname` in +- Darwin*) ++ case $host in ++ *-darwin*) + ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/osx-x86-x86_64-ppc-gcc.h" + ;; ++ x86_64-*-mingw*|x86_64-*-msys*|x86_64-*-cygwin*) ++ ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/windows-x64-msvc.h" ++ ;; ++ *-mingw*|*-msys*|*-cygwin*) ++ ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/windows-x86-msvc.h" ++ ;; + *) + ARCH_CONF_HEADER= + ;; + esac +- fi + else + ARCH_CONF_HEADER=$with_arch_h + fi +@@ -495,13 +487,7 @@ dnl Check for *BSD and apply BSD Make workaround + dnl - BSD Make treats obj special and cd into it first. + dnl -------------------------------------------------- + +-OBJDIR_BSDMAKE_WORKAROUND=obj +- +-case `uname` in +- *BSD) +- OBJDIR_BSDMAKEWORKAOROUND="notobj" +- ;; +-esac ++OBJDIR_BSDMAKE_WORKAROUND=obj_ + AC_SUBST(OBJDIR_BSDMAKE_WORKAROUND) + AC_CHECK_HEADER([sys/window.h]) + +@@ -649,9 +635,7 @@ if test x"$build_alias" != x""; then + SUBCONFIG_OPTS="$SUBCONFIG_OPTS --build=$build_alias" + fi + +-if test x"$host_alias" != x""; then +- SUBCONFIG_OPTS="$SUBCONFIG_OPTS --host=$host_alias" +-fi ++SUBCONFIG_OPTS="$SUBCONFIG_OPTS --host=$host" + + dnl -------------------------------------------------- + dnl Check for libraries +@@ -1500,16 +1484,14 @@ dnl look for IJS implementation + AC_ARG_WITH([ijs], AC_HELP_STRING([--without-ijs], + [disable IJS driver support])) + +-if test x"$cross_compiling" != x"yes"; then +- case `uname` in +- MINGW*|MSYS*) ++case $host in ++ *-mingw*|*-msys*|*-cygwin*) + AC_MSG_WARN([disabling the ijs device]) + with_ijs=no + ;; + *) + ;; +- esac +-fi ++esac + + dnl set safe defaults + IJSDIR=src +@@ -1561,18 +1543,11 @@ if test x$with_luratech != xno; then + SHARE_JBIG2=0 + JBIG2DIR=$srcdir/luratech/ldf_jb2 + +- if test x"$cross_compiling" = x"yes"; then +- if test x"$JBIG2_CFLAGS" != x""; then +- JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -fsigned-char $JBIG2_CFLAGS" +- else +- JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -fsigned-char -DLINUX=1 -DFORTE" +- fi +- else +- case `uname` in +- Darwin*) ++ case $host in ++ *-darwin*) + JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -DMAC -DMAC_OS_X_BUILD -fsigned-char" + ;; +- AIX) ++ *-aix*) + if test $ac_cv_prog_gcc = yes; then + JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -fsigned-char -DLINUX=1 -DFORTE" + else +@@ -1583,7 +1558,6 @@ if test x$with_luratech != xno; then + JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -fsigned-char -DLINUX=1 -DFORTE" + ;; + esac +- fi + + JBIG2FILEDEVS='$(DD)gdevjbig2.dev' + JBIG2DEVS='$(PSD)jbig2.dev' +@@ -1690,18 +1664,11 @@ if test x$with_luratech != xno; then + SHARE_JPX=0 + JPXDIR=$srcdir/luratech/lwf_jp2 + +- if test x"$cross_compiling" = x"yes"; then +- if test x"$JPX_CFLAGS" != x""; then +- JPX_AUTOCONF_CFLAGS="-DUSE_LWF_JP2 $JPX_CFLAGS" +- else +- JPX_AUTOCONF_CFLAGS="-DUSE_LWF_JP2 -DLINUX=1 -DFORTE" +- fi +- else +- 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=1 -DFORTE" + else +@@ -1712,7 +1679,6 @@ if test x$with_luratech != xno; then + JPX_AUTOCONF_CFLAGS="-DUSE_LWF_JP2 -DLINUX=1 -DFORTE" + ;; + esac +- fi + JPXDEVS='$(PSD)jpx.dev' + else + AC_MSG_RESULT([no]) +@@ -2325,21 +2291,8 @@ SO_LIB_EXT=".so" + DLL_EXT="" + SO_LIB_VERSION_SEPARATOR="." + +-if test x"$cross_compiling" = x"yes"; then +- DYNAMIC_CFLAGS="-fPIC" +- GS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)" +- PCL_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(PCL_SONAME_MAJOR)" +- XPS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(XPS_SONAME_MAJOR)" +- if test $ac_cv_prog_gcc = yes; then +- # GCC high level flag +- DYNAMIC_LIBS="-rdynamic" +- else +- DYNAMIC_LIBS="" +- fi +- SO_LIB_EXT=".so" +-else +- case `uname` in +- Linux*|GNU*) ++case $host in ++ *-linux*) + DYNAMIC_CFLAGS="-fPIC" + GS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)" + PCL_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(PCL_SONAME_MAJOR)" +@@ -2352,7 +2305,7 @@ else + fi + SO_LIB_EXT=".so" + ;; +- MINGW*|MSYS*) ++ *-mingw*|*-msys*|*-cygwin*) + DYNAMIC_CFLAGS="" + GS_DYNAMIC_LDFLAGS="-shared -Wl,--out-implib=\$(BINDIR)/lib\$(GS_SO_BASE).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import" + PCL_DYNAMIC_LDFLAGS="-shared -Wl,--out-implib=\$(BINDIR)/lib\$(PCL_SO_BASE).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import" +@@ -2361,7 +2314,7 @@ else + DLL_EXT=".dll" + SO_LIB_VERSION_SEPARATOR="-" + ;; +- *BSD) ++ *bsd*) + DYNAMIC_CFLAGS="-fPIC" + GS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)" + PCL_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(PCL_SONAME_MAJOR)" +@@ -2369,14 +2322,14 @@ else + DYNAMIC_LIBS="" + SO_LIB_EXT=".so" + ;; +- Darwin*) ++ *-darwin*) + GS_DYNAMIC_LDFLAGS="-dynamiclib -install_name \$(GS_SONAME_MAJOR_MINOR)" + PCL_DYNAMIC_LDFLAGS="-dynamiclib -install_name \$(PCL_SONAME_MAJOR_MINOR)" + XPS_DYNAMIC_LDFLAGS="-dynamiclib -install_name \$(XPS_SONAME_MAJOR_MINOR)" + DYNAMIC_LIBS="" + SO_LIB_EXT=".dylib" + ;; +- SunOS) ++ *-sun*) + if test $ac_cv_prog_gcc = yes; then + DYNAMIC_CFLAGS="-fPIC" + else +@@ -2388,7 +2341,7 @@ else + DYNAMIC_LIBS="" + SO_LIB_EXT=".so" + ;; +- AIX) ++ *-aix*) + DYNAMIC_CFLAGS="-fPIC" + GCFLAGS="-Wl,-brtl -D_LARGE_FILES $GCFLAGS" + GS_DYNAMIC_LDFLAGS="-shared -Wl,-brtl,-G -fPIC" +@@ -2396,15 +2349,14 @@ else + XPS_DYNAMIC_LDFLAGS="-shared -Wl,-brtl,-G -fPIC" + SO_LIB_EXT=".so" + ;; +- esac +-fi ++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" +@@ -2416,21 +2368,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) ++ *-sun*) + DYNAMIC_DEVS="\$(GLOBJDIR)/X11.so" + DYNAMIC_FLAGS="-DGS_DEVS_SHARED -DGS_DEVS_SHARED_DIR=\\\"\$(gssharedir)\\\"" + OPT_CFLAGS="$DYNAMIC_CFLAGS $OPT_CFLAGS" +@@ -2536,7 +2488,7 @@ dnl -------------------------------------------------- + dnl disable the memory header ID code on SPARC + dnl -------------------------------------------------- + +-case `uname -a` in ++case $host in + *sparc*) + GCFLAGS="$GCFLAGS -DGS_USE_MEMORY_HEADER_ID=0" + ;; +@@ -2613,19 +2565,11 @@ AC_ARG_WITH(memory-alignment, + [GS_MEMPTR_ALIGNMENT=$with_memory_alignment],[GS_MEMPTR_ALIGNMENT=check]) + + if test x"$GS_MEMPTR_ALIGNMENT" = xcheck ; then +- if test x"$cross_compiling" = x"no"; then +- case `uname` in +- HP-UX) ++ case $host in ++ *-hpux*|*-sun*|*-aix*) + GS_MEMPTR_ALIGNMENT=8 + ;; +- SunOS) +- GS_MEMPTR_ALIGNMENT=8 +- ;; +- AIX) +- GS_MEMPTR_ALIGNMENT=8 +- ;; +- esac +- fi ++ esac + fi + + if test x"$GS_MEMPTR_ALIGNMENT" = xcheck ; then +@@ -2748,15 +2692,7 @@ AC_SUBST(SUB_MAKE_OPTION) + # directory nor file name, so if we're building in + # mingw, add the same prefix as the VS build uses + # -------------------------------------------------- +-AUXDIRPOSTFIX="" +-case `uname` in +- MINGW*|MSYS*) +- AUXDIRPOSTFIX="_" +- if test x"$cross_compiling" != x"yes"; then +- CFLAGS="-DGS_NO_UTF8=1 $CFLAGS" +- fi +- ;; +-esac ++AUXDIRPOSTFIX="_" + AC_SUBST(AUXDIRPOSTFIX) + + # -------------------------------------------------- +@@ -2771,13 +2707,11 @@ 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 +- if test x"$cross_compiling" != x"yes"; then +- case `uname` in +- MINGW*|MSYS*) ++ case $host in ++ *-mingw*|*-msys*|*-cygwin*) + EXEEXT=".exe" + ;; +- esac +- fi ++ esac + fi + + AC_SUBST(EXEEXT) + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: darealshinji +Date: Sun, 20 May 2018 12:06:00 +0200 +Subject: [PATCH 6/8] option to set executable name extention for aux binaries + only + + +diff --git a/Makefile.in b/Makefile.in +index 1111111..2222222 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -184,7 +184,7 @@ GPDL=@GPDL@ + GPDL_SO_BASE=@GPDL@ + + XE=@EXEEXT@ +-XEAUX=@EXEEXT@ ++XEAUX=@AUXEXEEXT@ + + PCL_TARGET=@PCL_TARGET@ + XPS_TARGET=@XPS_TARGET@ +diff --git a/configure.ac b/configure.ac +index 1111111..2222222 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2701,21 +2701,36 @@ AC_SUBST(AUXDIRPOSTFIX) + # -------------------------------------------------- + EXEEXT="" + +-AC_ARG_WITH([exe-ext], AC_HELP_STRING([--with-exe-ext=EXT], +- [set the file name executable extension (must include any separator e.g. the period in ".exe")]),[], [exe_ext=]) ++case $host in ++ *-mingw*|*-msys*|*-cygwin*) ++ EXEEXT=".exe" ++ ;; ++esac + +-if test "x"$with_exe_ext != "x"; then +- EXEEXT="$with_exe_ext" +-else +- case $host in +- *-mingw*|*-msys*|*-cygwin*) +- EXEEXT=".exe" +- ;; +- esac +-fi ++AC_ARG_WITH([exe-ext], AC_HELP_STRING([--with-exe-ext=EXT], ++ [set the file name executable extension (must include any separator e.g. the period in ".exe")]), ++ [EXEEXT="$with_exe_ext"]) + + AC_SUBST(EXEEXT) + ++# -------------------------------------------------- ++# Set executable name extention for aux binaries ++# usually empty on Unix-like systems ++# -------------------------------------------------- ++AUXEXEEXT="" ++ ++case $host in ++ *-mingw*|*-msys*|*-cygwin*) ++ AUXEXEEXT=".exe" ++ ;; ++esac ++ ++AC_ARG_WITH([aux-exe-ext], AC_HELP_STRING([--with-aux-exe-ext=EXT], ++ [set the file name executable extension for auxiliary binaries (must include any separator e.g. the period in ".exe")]), ++ [AUXEXEEXT="$with_aux_exe_ext"]) ++ ++AC_SUBST(AUXEXEEXT) ++ + # -------------------------------------------------- + # Check for disabling of versioned path option. + # By default the versioned path must be enabled! + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: darealshinji +Date: Sun, 20 May 2018 12:07:00 +0200 +Subject: [PATCH 7/8] fix openjpeg detection without pkg-config + + +diff --git a/configure.ac b/configure.ac +index 1111111..2222222 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1753,12 +1753,16 @@ if test "x$JPX_DECODER" = "x"; then + else + AC_MSG_RESULT([no]) + fi +- else ++ fi ++ if test "x$JPX_DECODER" = "x"; then ++ AC_CHECK_HEADER(openjpeg.h, [ + AC_CHECK_LIB(openjp2, opj_stream_set_user_data, + [JPX_AUTOCONF_CFLAGS="$JPX_AUTOCONF_CFLAGS $OPJ_LRINTF_SUBST -DUSE_JPIP -DUSE_OPENJPEG_JP2 $CFLAGS_OPJ_HAVE_STDINT_H $CFLAGS_OPJ_HAVE_INTTYPES_H $CFLAGS_OPJ_BIGENDIAN $CFLAGS_OPJ_HAVE_FSEEKO"; + JPX_AUTOCONF_LIBS="-lopenjp2"; ++ JPX_DECODER=openjpeg + SHARE_JPX=1] + ) ++ ]) + fi + fi + fi + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: darealshinji +Date: Sun, 20 May 2018 21:37:25 +0200 +Subject: [PATCH 8/8] don't use the minor version on DLLs + + +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 +@@ -67,8 +67,15 @@ GS_SOEXT=$(SO_LIB_EXT) + GS_DLLEXT=$(DLL_EXT) + + GS_SONAME=$(GS_SONAME_BASE)$(GS_SOEXT)$(GS_DLLEXT) ++ifeq ($(DLL_EXT),.dll) ++# for Windows we make libgs-A-B.dll a symbolic link to libgs-A.dll to ensure that programs ++# always import the DLL without the minor version in its name ++GS_SONAME_MAJOR=$(GS_SONAME_BASE)$(GS_SOEXT)$(SO_LIB_VERSION_SEPARATOR)$(GS_VERSION_MAJOR)$(SO_LIB_VERSION_SEPARATOR)$(GS_VERSION_MINOR)$(GS_DLLEXT) ++GS_SONAME_MAJOR_MINOR=$(GS_SONAME_BASE)$(GS_SOEXT)$(SO_LIB_VERSION_SEPARATOR)$(GS_VERSION_MAJOR)$(GS_DLLEXT) ++else + GS_SONAME_MAJOR=$(GS_SONAME_BASE)$(GS_SOEXT)$(SO_LIB_VERSION_SEPARATOR)$(GS_VERSION_MAJOR)$(GS_DLLEXT) + GS_SONAME_MAJOR_MINOR=$(GS_SONAME_BASE)$(GS_SOEXT)$(SO_LIB_VERSION_SEPARATOR)$(GS_VERSION_MAJOR)$(SO_LIB_VERSION_SEPARATOR)$(GS_VERSION_MINOR)$(GS_DLLEXT) ++endif + + PCL_SONAME=$(PCL_SONAME_BASE)$(GS_SOEXT)$(GS_DLLEXT) + PCL_SONAME_MAJOR=$(PCL_SONAME_BASE)$(GS_SOEXT)$(SO_LIB_VERSION_SEPARATOR)$(GS_VERSION_MAJOR)$(GS_DLLEXT) diff --git a/src/ghostscript-test.c b/src/ghostscript-test.c index f7101b68..ec148c6f 100644 --- a/src/ghostscript-test.c +++ b/src/ghostscript-test.c @@ -2,31 +2,15 @@ * This file is part of MXE. See LICENSE.md for licensing information. */ -#ifdef _WIN32 - +#ifdef __WIN32__ #include - -#ifndef _Windows -# define _Windows #endif - -#ifndef GSDLLEXPORT -# ifdef GS_STATIC_LIB -# define GSDLLEXPORT -# else -# define GSDLLEXPORT __declspec(dllimport) -# endif -#endif - -#endif /* _WIN32 */ - #include -void *minst; - int main(int argc, char *argv[]) { int code; + void *minst = NULL; (void)argc; (void)argv; diff --git a/src/ghostscript.mk b/src/ghostscript.mk index 68c8f30a..4131ade1 100644 --- a/src/ghostscript.mk +++ b/src/ghostscript.mk @@ -18,24 +18,44 @@ define $(PKG)_UPDATE endef define $(PKG)_BUILD - cd '$(SOURCE_DIR)' && rm -rf freetype jpeg lcms2art libpng openjpeg tiff zlib + cp -f $(SOURCE_DIR)/libpng/{config.guess,config.sub,install-sh} '$(SOURCE_DIR)' cd '$(SOURCE_DIR)' && autoreconf -f -i - cd '$(BUILD_DIR)' && CCAUX='$(BUILD_CC)' \ - CPPFLAGS='$(CPPFLAGS) -DHAVE_SYS_TIMES_H=0' \ + cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \ + --without-libtiff \ + --disable-contrib \ + --disable-fontconfig \ + --disable-dbus \ + --disable-freetype \ + --disable-fapi \ + --disable-cups \ + --disable-openjpeg \ + --disable-gtk \ + --with-libiconv=no \ + --without-libidn \ + --without-libpaper \ + --without-pdftoraster \ + --without-ijs \ + --without-luratech \ + --without-jbig2dec \ + --without-x \ + --with-drivers='' + $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' obj_/aux_/{echogs,genarch,genconf,gendev,mkromfs,packps} + rm -f $(BUILD_DIR)/obj_/*.h + cp -r '$(BUILD_DIR)/obj_' '$(BUILD_DIR)/soobj_' + cd '$(SOURCE_DIR)' && rm -rf freetype jpeg lcms2art libpng openjpeg tiff zlib + + cd '$(BUILD_DIR)' && CFLAGS='$(CFLAGS) -I$(PREFIX)/$(TARGET)/include/openjpeg-2.3' \ + CPPFLAGS='$(CPPFLAGS) -I$(PREFIX)/$(TARGET)/include/openjpeg-2.3' \ $(SOURCE_DIR)/configure \ $(MXE_CONFIGURE_OPTS) \ - --with-drivers=ALL \ - --with-arch_h='$(SOURCE_DIR)/arch/windows-x$(if $(filter x86_64-%,$(TARGET)),64,86)-msvc.h' \ - --with-memory-alignment='$(if $(filter x86_64-%,$(TARGET)),8,4)' \ + --with-drivers=ALL,display \ --disable-contrib \ --disable-cups \ --disable-gtk \ --with-libiconv=gnu \ - --without-ijs - $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' so CFLAGS_SO='' \ - GS_LDFLAGS_SO='-shared -Wl,--out-implib=sobin/libgs.dll.a' \ - GS_SONAME_MAJOR='libgs-ignore-me.dll' \ - GS_SONAME_MAJOR_MINOR='libgs-9.dll' + --without-ijs \ + --with-aux-exe-ext='' + $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(if $(BUILD_STATIC),libgs,so) $(INSTALL) -d '$(PREFIX)/$(TARGET)/include/ghostscript' $(INSTALL) '$(SOURCE_DIR)/devices/gdevdsp.h' '$(PREFIX)/$(TARGET)/include/ghostscript/gdevdsp.h' @@ -45,12 +65,7 @@ define $(PKG)_BUILD $(INSTALL) -d '$(PREFIX)/$(TARGET)/bin' $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib' - $(if $(BUILD_STATIC),\ - cd '$(BUILD_DIR)' && \ - '$(PREFIX)/bin/$(TARGET)-ar' qc libgs.a `cat soobj/ldt.tr | tr ' ' '\n' | grep '^\./soobj/.*\.o$$'` && \ - '$(PREFIX)/bin/$(TARGET)-ranlib' libgs.a && \ - $(INSTALL) libgs.a '$(PREFIX)/$(TARGET)/lib/libgs.a' \ - ,\ + $(if $(BUILD_STATIC),$(INSTALL) '$(BUILD_DIR)/bin/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') @@ -59,7 +74,6 @@ define $(PKG)_BUILD 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: fontconfig freetype2 libidn libtiff-4 libpng jpeg lcms2 zlib'; \ echo '# https://github.com/mxe/mxe/issues/1446'; \