diff --git a/Makefile.am b/Makefile.am index fe9fd38..3534ac6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,4 +11,15 @@ diff_pdf_SOURCES = \ diff_pdf_CXXFLAGS = $(POPPLER_CFLAGS) $(WX_CXXFLAGS) diff_pdf_LDADD = $(POPPLER_LIBS) $(WX_LIBS) -EXTRA_DIST = gtk-zoom-in.xpm gtk-zoom-out.xpm +EXTRA_DIST = gtk-zoom-in.xpm gtk-zoom-out.xpm win32/fonts.conf win32/collect-dlls.sh + +windows-dist: diff-pdf-$(VERSION).zip + +diff-pdf-$(VERSION).zip: all + rm -rf $@ windist + $(srcdir)/win32/collect-dlls.sh windist diff-pdf.exe + mkdir -p windist/fonts && cp -a $(srcdir)/win32/fonts.conf windist/fonts/ + (cd windist && zip -9r ../$@ .) + rm -rf windist + +.PHONY: windows-dist diff --git a/Makefile.mingw b/Makefile.mingw deleted file mode 100644 index 4c8c623..0000000 --- a/Makefile.mingw +++ /dev/null @@ -1,293 +0,0 @@ - -# Versions of dependency packages to install. Prebuilt packages are -# installed from http://www.gtk.org/download/win32.php - -POPPLER_VERSION := 0.18.4 -WXWIDGETS_VERSION := 2.9.3 - -LIBTIFF_VERSION := 3.9.6 -OPENJPEG_VERSION := 1.5.0 - -CAIRO_VERSION := 1.10.2-2 -GLIB_VERSION := 2.28.8-1 -PKG_CONFIG_VERSION := 0.26-1 -ZLIB_VERSION := 1.2.5-2 -LIBPNG_VERSION := 1.4.3-1 -JPEG_VERSION := 8-1 -FREETYPE_VERSION := 2.4.2-1 -FONTCONFIG_VERSION := 2.8.0-2 -GETTEXT_VERSION := 0.18.1.1-2 - -CONFIGURE_PATHS = PKG_CONFIG_PATH=$(ROOTDIR)/lib/pkgconfig \ - CPPFLAGS="-I$(ROOTDIR)/include" \ - LDFLAGS="-L$(ROOTDIR)/lib" -CONFIGURE_FLAGS = --prefix=$(ROOTDIR) \ - --disable-static --enable-shared \ - $(CONFIGURE_PATHS) -WX_CONFIGURE_FLAGS = --enable-debug \ - --enable-stl \ - --disable-svg \ - --without-libpng \ - --without-libjpeg \ - --without-libtiff -POPPLER_CONFIGURE_FLAGS = --disable-utils \ - CPPFLAGS="-I$(ROOTDIR)/include -DOPJ_STATIC" -OPENJPEG_CONFIGURE_FLAGS = --disable-doc --disable-png --disable-tiff \ - --enable-static --disable-shared - - -POPPLER_FILE := poppler-$(POPPLER_VERSION).tar.gz -POPPLER_URL := http://poppler.freedesktop.org/$(POPPLER_FILE) - -WXWIDGETS_FILE := wxWidgets-$(WXWIDGETS_VERSION).tar.bz2 -WXWIDGETS_URL := http://sourceforge.net/projects/wxwindows/files/$(WXWIDGETS_VERSION)/$(WXWIDGETS_FILE) - -LIBTIFF_FILE := tiff-$(LIBTIFF_VERSION).tar.gz -LIBTIFF_URL := ftp://ftp.remotesensing.org/pub/libtiff/$(LIBTIFF_FILE) - -OPENJPEG_FILE := openjpeg-$(OPENJPEG_VERSION).tar.gz -OPENJPEG_URL := http://openjpeg.googlecode.com/files/$(OPENJPEG_FILE) - -WXWIDGETS_VERSION_TAG := $(subst .,,$(WXWIDGETS_VERSION)) - -# Helper functions: - -majorver = $(word 1,$(subst ., ,$1)).$(word 2,$(subst ., ,$1)) -gtk-url = http://ftp.gnome.org/pub/gnome/binaries/win32/$1/$2$4_$3_win32.zip -tar-basename = $(subst .tar.gz,,$(subst .tar.bz2,,$1)) - -# Internal variables: - -WGET := /bin/wget.exe -UNZIP := /bin/unzip.exe - -WORKDIR := $(CURDIR)/mingw -DOWNLOADS := $(WORKDIR)/downloads -BUILDDIR := $(WORKDIR)/builddir -ROOTDIR := $(WORKDIR)/root -MANIFESTS := $(ROOTDIR)/manifest -PRODUCTS := $(WORKDIR)/Products - -# add root's directory to the path, this will be used by the shell too: -PATH := $(ROOTDIR)/bin:$(PATH) - -make-workdir := $(WORKDIR)/stamp -dependencies-stamp := $(MANIFESTS)/deps.installed -bin-dependencies-stamp := $(MANIFESTS)/prebuilt.installed - - -all: stage - - -$(WORKDIR)/stamp: - mkdir -p $(WORKDIR) - mkdir -p $(DOWNLOADS) - mkdir -p $(BUILDDIR) - mkdir -p $(ROOTDIR) - mkdir -p $(MANIFESTS) - mkdir -p $(PRODUCTS) - touch $(WORKDIR)/stamp - -clean: - rm -rf $(WORKDIR) - - -# ----------------------------------------------------------------------------------------------- -# Build diff-pdf itself: -# ----------------------------------------------------------------------------------------------- - -DIFFPDF_BUILDDIR := $(BUILDDIR)/diff-pdf - -diff-pdf: $(DIFFPDF_BUILDDIR)/diff-pdf.exe - -$(DIFFPDF_BUILDDIR)/diff-pdf.exe: $(DIFFPDF_BUILDDIR)/Makefile - $(MAKE) -C $(DIFFPDF_BUILDDIR) - -$(DIFFPDF_BUILDDIR)/Makefile: Makefile.am configure $(dependencies-stamp) - mkdir -p $(DIFFPDF_BUILDDIR) - cd $(DIFFPDF_BUILDDIR) && $(CURDIR)/configure --prefix=$(PRODUCTS) --bindir=$(PRODUCTS) $(CONFIGURE_PATHS) - - -# ----------------------------------------------------------------------------------------------- -# stage files -# ----------------------------------------------------------------------------------------------- - -REQUIRED_FILES := \ - wxbase$(WXWIDGETS_VERSION_TAG)u_gcc_custom.dll \ - wxmsw$(WXWIDGETS_VERSION_TAG)u_core_gcc_custom.dll \ - freetype6.dll \ - zlib1.dll \ - intl.dll \ - libjpeg-8.dll \ - libpng14-14.dll \ - libtiff-3.dll \ - libcairo-2.dll \ - libexpat-1.dll \ - libfontconfig-1.dll \ - libglib-2.0-0.dll \ - libgobject-2.0-0.dll \ - libgthread-2.0-0.dll \ - libpoppler-19.dll \ - libpoppler-glib-8.dll \ - libgcc_s_dw2-1.dll \ - libstdc++-6.dll \ - fonts/fonts.conf \ - diff-pdf.exe - -stage: $(addprefix $(PRODUCTS)/,$(REQUIRED_FILES)) - -$(PRODUCTS)/diff-pdf.exe: $(DIFFPDF_BUILDDIR)/diff-pdf.exe - cp -f $< $@ - strip $@ - -$(PRODUCTS)/fonts/fonts.conf: fonts/fonts.conf - mkdir -p $(PRODUCTS)/fonts - cp -f $< $@ - -$(PRODUCTS)/%.dll: %.dll - cp -f $< $@ - strip $@ - -MINGW_BINDIR := $(dir $(shell which mingw-get)) -vpath %.dll $(MINGW_BINDIR):$(ROOTDIR)/bin:$(ROOTDIR)/lib - - -# ----------------------------------------------------------------------------------------------- -# build distribution archive -# ----------------------------------------------------------------------------------------------- - -DIST_ARCHIVE := diff-pdf-$(shell date +%F).zip - -dist: stage - @echo "creating $(DIST_ARCHIVE)..." - @rm -f $(DIST_ARCHIVE) - @cd $(PRODUCTS) && zip -9 $(CURDIR)/$(DIST_ARCHIVE) $(REQUIRED_FILES) - - -# ----------------------------------------------------------------------------------------------- -# build dependencies -# ----------------------------------------------------------------------------------------------- - -dependencies: $(dependencies-stamp) -bin-dependencies: $(bin-dependencies-stamp) - -$(dependencies-stamp): $(make-workdir) $(bin-dependencies-stamp) - touch $@ - -$(bin-dependencies-stamp): $(make-workdir) - touch $@ - -# download dependencies files: -download: $(make-workdir) - -# Download of prebuilt dependencies from Win32 GTK+ port: -define gtk-download-rules-impl -$(dependencies-stamp): $(MANIFESTS)/$2$4_$3_win32.mft -$(bin-dependencies-stamp): $(MANIFESTS)/$2$4_$3_win32.mft -download: $(DOWNLOADS)/$2$4_$3_win32.zip -$(DOWNLOADS)/$2$4_$3_win32.zip: $(WGET) $(make-workdir) - $$(WGET) --output-document=$$@ $(call gtk-url,$1,$2,$3,$4) - @touch $$@ -endef - -define gtk-download-rules -$(call gtk-download-rules-impl,$1,$2,$3,) -$(call gtk-download-rules-impl,$1,$2,$3,-dev) -endef - -$(eval $(call gtk-download-rules,dependencies,pkg-config,$(PKG_CONFIG_VERSION))) -$(eval $(call gtk-download-rules,dependencies,cairo,$(CAIRO_VERSION))) -$(eval $(call gtk-download-rules,dependencies,zlib,$(ZLIB_VERSION))) -$(eval $(call gtk-download-rules,dependencies,libpng,$(LIBPNG_VERSION))) -$(eval $(call gtk-download-rules,dependencies,jpeg,$(JPEG_VERSION))) -$(eval $(call gtk-download-rules,dependencies,freetype,$(FREETYPE_VERSION))) -$(eval $(call gtk-download-rules,dependencies,fontconfig,$(FONTCONFIG_VERSION))) -$(eval $(call gtk-download-rules,dependencies,gettext-runtime,$(GETTEXT_VERSION))) -$(eval $(call gtk-download-rules,glib/$(call majorver,$(GLIB_VERSION)),glib,$(GLIB_VERSION))) - -$(MANIFESTS)/%.mft: $(DOWNLOADS)/%.zip $(UNZIP) - unzip -o -DD $< -d $(ROOTDIR) - $(RUN_FIXUP_COMMANDS) - -# Some packages must be built from sources and downloaded and unpacked manually: - -# $1 - file, $2 - url -define download-and-build-rules -download: $(DOWNLOADS)/$1 -$(DOWNLOADS)/$1: $(WGET) $(make-workdir) - $$(WGET) --output-document=$$@ $2 - @touch $$@ -$(dependencies-stamp): $(MANIFESTS)/$(call tar-basename,$1).installed -$(BUILDDIR)/$(call tar-basename,$1)/.unpack: $(DOWNLOADS)/$1 - tar -x -C $(BUILDDIR) -f $$< - $$(RUN_FIXUP_COMMANDS) - touch $$@ -endef - -$(eval $(call download-and-build-rules,$(WXWIDGETS_FILE),$(WXWIDGETS_URL))) -$(eval $(call download-and-build-rules,$(POPPLER_FILE),$(POPPLER_URL))) -$(eval $(call download-and-build-rules,$(LIBTIFF_FILE),$(LIBTIFF_URL))) -$(eval $(call download-and-build-rules,$(OPENJPEG_FILE),$(OPENJPEG_URL))) - -WXWIDGETS_DIR = $(call tar-basename,$(WXWIDGETS_FILE)) -POPPLER_DIR = $(call tar-basename,$(POPPLER_FILE)) -LIBTIFF_DIR = $(call tar-basename,$(LIBTIFF_FILE)) -OPENJPEG_DIR = $(call tar-basename,$(OPENJPEG_FILE)) - -$(BUILDDIR)/$(WXWIDGETS_DIR)/.conf: CONFIGURE_FLAGS += $(WX_CONFIGURE_FLAGS) -$(BUILDDIR)/$(POPPLER_DIR)/.conf: CONFIGURE_FLAGS += $(POPPLER_CONFIGURE_FLAGS) -$(BUILDDIR)/$(OPENJPEG_DIR)/.conf: CONFIGURE_FLAGS += $(OPENJPEG_CONFIGURE_FLAGS) - -$(BUILDDIR)/%.conf: $(BUILDDIR)/%.unpack $(bin-dependencies-stamp) - cd $(dir $@) && ./configure $(CONFIGURE_FLAGS) - touch $@ - -$(BUILDDIR)/%/.build: $(BUILDDIR)/%/.conf - $(MAKE) -C $(dir $@) - touch $@ - -$(MANIFESTS)/%.installed: $(BUILDDIR)/%/.build - $(MAKE) -C $(dir $<) install - $(RUN_FIXUP_COMMANDS) - touch $@ - -# fix broken libjpeg headers - they define boolean type, -# which conflicts with mingw headers -JPEG_FIXUP_CMD := sed --in-place=.orig -e 's/boolean/jpeg_boolean/g' -$(MANIFESTS)/jpeg-dev_$(JPEG_VERSION)_win32.mft: RUN_FIXUP_COMMANDS := \ - $(JPEG_FIXUP_CMD) $(ROOTDIR)/include/j*.h -$(BUILDDIR)/$(POPPLER_DIR)/.unpack: RUN_FIXUP_COMMANDS = \ - $(JPEG_FIXUP_CMD) $(dir $@)poppler/DCTStream.cc -$(BUILDDIR)/$(LIBTIFF_DIR)/.unpack: RUN_FIXUP_COMMANDS = \ - $(JPEG_FIXUP_CMD) $(dir $@)libtiff/*jpeg*.c - -# openjpeg built with static library breaks libtool, nuke the .la file: -$(MANIFESTS)/$(OPENJPEG_DIR).installed: RUN_FIXUP_COMMANDS = \ - rm -f $(ROOTDIR)/lib/libopenjpeg.la - -# additional dependencies between the deps packages: -$(BUILDDIR)/$(POPPLER_DIR)/.conf: $(MANIFESTS)/$(LIBTIFF_DIR).installed -$(BUILDDIR)/$(POPPLER_DIR)/.conf: $(MANIFESTS)/$(OPENJPEG_DIR).installed - - -$(WGET): - @echo " " - @echo "Please install wget by running the following command:" - @echo "" - @echo " mingw-get install msys-wget" - @echo "" - @exit 1 - -$(UNZIP): - @echo " " - @echo "Please install wget by running the following command:" - @echo "" - @echo " mingw-get install msys-unzip" - @echo "" - @exit 1 - -.PHONY: all clean dependencies bin-dependencies download diff-pdf stage dist - - -# Unpacking rules: - diff --git a/README.md b/README.md index 924ba10..ba9642b 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ See the output of `$ diff-pdf --help` for complete list of options. ## Obtaining the binaries -Precompiled version of the tool for Windows is available from our -[downloads](http://www.tt-solutions.com/downloads/diff-pdf-2012-02-28.zip) -section -- the ZIP archive contains everything you need to run diff-pdf. It will +Precompiled version of the tool for Windows is available as part of +[the latest release](https://github.com/vslavik/diff-pdf/releases/tag/v0.3) +as a ZIP archive, which contains everything you need to run diff-pdf. It will work from any place you unpack it to. On Mac, if you use [Homebrew](https://brew.sh), you can use it to install diff-pdf with it: @@ -84,7 +84,7 @@ $ sudo apt-get install make automake g++ $ sudo apt-get install libpoppler-glib-dev poppler-utils wxgtk3.0-dev ``` -#### OSX: +#### macOS: Install Command Line Tools for Xcode: ``` @@ -108,40 +108,37 @@ libraries Cairo and Poppler use are normally available. At the time of writing, transitive cover of the above dependencies included fontconfig, freetype, glib, libpng, pixman, gettext, libiconv, libjpeg and zlib. -Precompiled version of the dependencies for Windows, built with MinGW, are -available from our [downlods](http://github.com/vslavik/diff-pdf/downloads) -section (wxWidgets is not included, as it supports MinGW well). +### Compiling on Windows using MSYS + MinGW -### Compiling on Windows using MinGW +1. First of all, you will need working MinGW installation with MSYS2 environment +and C++ compiler. Install MSYS2 by following [their instructions](https://www.msys2.org). -1. First of all, you will need working MinGW installation with MSYS environment -and C++ compiler. The instructions on installing MinGW can be found in the -[MinGW website](http://www.mingw.org/wiki/Getting_Started): - -1. Once installed, launch the MinGW Shell tool. It will open a terminal window; -type `$ cd /c/directory/with/diff-pdf` to do to the directory with diff-pdf +1. Once installed, launch the MSYS2 MinGW shell. It will open a terminal window; +type `cd /c/directory/with/diff-pdf` to go to the directory with diff-pdf sources. -1. You will need to install additional MinGW components that are not normally -included with MinGW, using these commands: +1. You will need to install additional MSYS components that are not normally +included with MSYS, using these commands: ``` - $ mingw-get install msys-wget - $ mingw-get install msys-unzip - $ mingw-get install msys-perl + $ pacman -Syu + $ pacman -S automake autoconf pkg-config make zip + $ pacman -S pacman -S mingw-w64-i686-{gcc,poppler,wxWidgets} ``` -1. It's time to build the software now and give it some time to finish (Note -that this step requires Internet connectivity, as it downloads some dependencies -packages): +1. Build diff-pdf in the same way as in the instructions for Unix above: ``` - $ make -f Makefile.mingw + $ ./bootstrap # only if building from git repository + $ ./configure + $ make ``` -1. If everything went well, diff-pdf is now in the `mingw\Products\` -directory. +1. To build a ZIP archive will all DLLs, run + ``` + $ make windows-dist + ``` ## Installing @@ -150,4 +147,4 @@ On Unix, the usual `make install` is sufficient. On Windows, installation is not necessary, just copy the files somewhere. If you built it following the instructions above, all the necessary files will be -in the `mingw\Products\` directory. +in the created ZIP archive. diff --git a/win32/collect-dlls.sh b/win32/collect-dlls.sh new file mode 100755 index 0000000..f7c78ec --- /dev/null +++ b/win32/collect-dlls.sh @@ -0,0 +1,26 @@ +#!/bin/sh -e + +if [[ -z $1 || ! -f $2 ]]; then + echo "Usage: $0 outputPath binary.exe" >&2 + exit 1 +fi + +OUTPUT=$1 +EXE=$2 + +mkdir -p $OUTPUT +rm -rf $OUTPUT/* + +cp -a $EXE $OUTPUT +last_file_count=0 + +while true ; do + file_count=`ls -1 $OUTPUT/* | wc -l` + echo "count=$file_count" + if [ $file_count -eq $last_file_count ] ; then break ; fi + last_file_count=$file_count + + objdump -x $OUTPUT/* | grep "DLL Name" | cut -d: -f2 | sort | uniq | while read dll ; do + cp -anv /mingw32/bin/$dll $OUTPUT 2>/dev/null || true + done +done diff --git a/fonts/fonts.conf b/win32/fonts.conf similarity index 100% rename from fonts/fonts.conf rename to win32/fonts.conf