Skip to content

Instantly share code, notes, and snippets.

@witwall
Last active August 29, 2015 14:13
Show Gist options
  • Save witwall/e81d8724718b7fc754fb to your computer and use it in GitHub Desktop.
Save witwall/e81d8724718b7fc754fb to your computer and use it in GitHub Desktop.
make i686-w64-mingw32 shared poppler with openjpeg support by using mxe
#https://github.com/mxe/mxe/blob/master/src/devil.mk
#http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/devel/devIL/patches/patch-include_IL_il.h
--- orig/devil.mk 2015-05-05 17:23:30.482151365 +0800
+++ devil.mk 2015-05-05 17:24:20.766152608 +0800
@@ -19,6 +19,7 @@
define $(PKG)_BUILD
$(SED) -i 's,__declspec(dllimport),,' '$(1)/include/IL/il.h'
+ $(SED) -i 's,#ifdef RESTRICT_KEYWORD,#if defined(RESTRICT_KEYWORD) \&\& !defined(__cplusplus),' '$(1)/include/IL/il.h'
cd '$(1)' && ./configure \
--host='$(TARGET)' \
--build="`config.guess`" \
--- FindTIFF.cmake 2014-01-16 17:15:08.000000000 +0000
+++ /usr/share/cmake-2.8/Modules/FindTIFF.cmake 2015-01-13 09:07:42.393839468 +0000
@@ -20,6 +20,15 @@
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
+# TIFF has conditional dependencies on zlib ,lzma and jpeg
+IF(TIFF_FIND_QUIETLY)
+ SET(_FIND_QUIETLY_ARG QUIET)
+ENDIF(TIFF_FIND_QUIETLY)
+
+FIND_PACKAGE(ZLIB ${_FIND_QUIETLY_ARG})
+FIND_PACKAGE(JPEG ${_FIND_QUIETLY_ARG})
+FIND_PACKAGE(LibLZMA ${_FIND_QUIETLY_ARG})
+
find_path(TIFF_INCLUDE_DIR tiff.h)
set(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3)
@@ -42,7 +51,7 @@
VERSION_VAR TIFF_VERSION_STRING)
if(TIFF_FOUND)
- set( TIFF_LIBRARIES ${TIFF_LIBRARY} )
+ set( TIFF_LIBRARIES ${TIFF_LIBRARY} ${JPEG_LIBRARY} ${LIBLZMA_LIBRARIES} )
endif()
mark_as_advanced(TIFF_INCLUDE_DIR TIFF_LIBRARY)
--- mxe-master/index.html 2015-01-06 03:39:49.000000000 +0000
+++ mxe/index.html 2015-01-09 07:22:55.450610846 +0000
@@ -2541,6 +2541,11 @@
<td class="package">zziplib</td>
<td class="website"><a href="http://zziplib.sourceforge.net/">ZZIPlib</a></td>
</tr>
+
+ <tr>
+ <td class="package">openjpeg</td>
+ <td class="website"><a href="https://code.google.com/p/openjpeg/">openjpeg</a></td>
+ </tr>
</table>
<script>
# This file is part of MXE.
# See index.html for further information.
PKG := openjpeg
$(PKG)_IGNORE :=
$(PKG)_VERSION := 2.1.0
$(PKG)_CHECKSUM := c2a255f6b51ca96dc85cd6e85c89d300018cb1cb
$(PKG)_SUBDIR := openjpeg-$($(PKG)_VERSION)
$(PKG)_FILE := $($(PKG)_SUBDIR).tar.gz
$(PKG)_URL := https://sourceforge.net/projects/openjpeg.mirror/files/$($(PKG)_VERSION)/$($(PKG)_FILE)
$(PKG)_DEPS := gcc tiff libpng zlib lcms
#git commit 3d95bcf
define $(PKG)_UPDATE
$(WGET) -q -O- 'https://sourceforge.net/projects/openjpeg.mirror/files/' | \
$(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
head -1
endef
define $(PKG)_BUILD
mkdir '$(1).build'
cd '$(1).build' && cmake \
-DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
-DBUILD_SHARED_LIBS=$(if $(BUILD_STATIC),FALSE,TRUE) \
-DBUILD_TESTING=FALSE \
-DBUILD_PKGCONFIG_FILES=ON \
-DBUILD_MJ2:bool=ON \
-DBUILD_JPWL:bool=ON \
-DBUILD_JPIP:bool=ON \
-DBUILD_JP3D:bool=ON \
-DBUILD_DOC:bool=OFF \
'$(1)'
$(MAKE) -C '$(1).build' install
endef
--- openjpeg-2.1.0/CMakeLists.txt 2014-04-29 07:15:05.000000000 +0000
+++ CMakeLists.txt 2015-01-13 10:25:16.301910740 +0000
@@ -324,11 +324,15 @@
#-----------------------------------------------------------------------------
# pkgconfig support
# enabled by default on Unix, disabled by default on other platforms
-if(UNIX)
- option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
-else()
- option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
-endif()
+#if(UNIX)
+# option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
+#else()
+# option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
+#endif()
+# enabled on Unix, disabled otherwise unless BUILD_PKGCONFIG_FILES is set
+include(CMakeDependentOption)
+CMAKE_DEPENDENT_OPTION(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF "NOT UNIX" ON)
+
if(BUILD_PKGCONFIG_FILES)
# install in lib and not share (see multi-arch note above)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/libopenjp2.pc.cmake.in
# This file is part of MXE.
# See index.html for further information.
PKG := poppler
$(PKG)_IGNORE :=
$(PKG)_VERSION := 0.30.0
$(PKG)_CHECKSUM := 6040e46b5f27e2562227232ba956c815cc2878e2
$(PKG)_SUBDIR := poppler-$($(PKG)_VERSION)
$(PKG)_FILE := poppler-$($(PKG)_VERSION).tar.xz
$(PKG)_URL := http://poppler.freedesktop.org/$($(PKG)_FILE)
$(PKG)_DEPS := gcc glib cairo libpng lcms jpeg tiff freetype zlib curl qt openjpeg
define $(PKG)_UPDATE
$(WGET) -q -O- 'http://poppler.freedesktop.org/' | \
$(SED) -n 's,.*"poppler-\([0-9.]\+\)\.tar\.xz".*,\1,p' | \
head -1
endef
define $(PKG)_BUILD
# Note: Specifying LIBS explicitly is necessary for configure to properly
# pick up libtiff (otherwise linking a minimal test program fails not
# because libtiff is not found, but because some references are
# undefined)
cd '$(1)' \
&& PATH='$(PREFIX)/$(TARGET)/qt/bin:$(PATH)' \
./configure \
--host='$(TARGET)' \
--build="`config.guess`" \
--prefix='$(PREFIX)/$(TARGET)' \
--disable-silent-rules \
--disable-shared \
--enable-static \
--enable-xpdf-headers \
--enable-poppler-qt4 \
--enable-zlib \
--enable-cms=lcms2 \
--enable-libcurl \
--enable-libtiff \
--enable-libjpeg \
--enable-libpng \
--enable-poppler-glib \
--enable-poppler-cpp \
--enable-cairo-output \
--enable-splash-output \
--enable-compile-warnings=yes \
--enable-introspection=auto \
--disable-gtk-test \
--disable-utils \
--disable-gtk-doc \
--disable-gtk-doc-html \
--disable-gtk-doc-pdf \
--with-font-configuration=win32 \
PKG_CONFIG_PATH_$(subst .,_,$(subst -,_,$(TARGET)))='$(PREFIX)/$(TARGET)/qt/lib/pkgconfig' \
CXXFLAGS=-D_WIN32_WINNT=0x0500 \
LIBTIFF_LIBS="`'$(TARGET)-pkg-config' libtiff-4 --libs`"
PATH='$(PREFIX)/$(TARGET)/qt/bin:$(PATH)' \
$(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
$(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
# Test program
'$(TARGET)-g++' \
-W -Wall -Werror -ansi -pedantic \
'$(2).cxx' -o '$(PREFIX)/$(TARGET)/bin/test-poppler.exe' \
`'$(TARGET)-pkg-config' poppler poppler-cpp --cflags --libs`
endef
#$(PKG)_BUILD_SHARED =
define $(PKG)_BUILD_SHARED
# Note: Specifying LIBS explicitly is necessary for configure to properly
# pick up libtiff (otherwise linking a minimal test program fails not
# because libtiff is not found, but because some references are
# undefined)
cd '$(1)' \
&& PATH='$(PREFIX)/$(TARGET)/qt/bin:$(PATH)' \
./configure \
--host='$(TARGET)' \
--build="`config.guess`" \
--prefix='$(PREFIX)/$(TARGET)' \
--disable-silent-rules \
--enable-shared \
--disable-static \
--enable-xpdf-headers \
--enable-poppler-qt4 \
--enable-zlib \
--enable-cms=lcms2 \
--enable-libcurl \
--enable-libtiff \
--enable-libjpeg \
--enable-libpng \
--enable-poppler-glib \
--enable-poppler-cpp \
--enable-cairo-output \
--enable-splash-output \
--enable-compile-warnings=yes \
--enable-introspection=auto \
--disable-gtk-test \
--disable-utils \
--disable-gtk-doc \
--disable-gtk-doc-html \
--disable-gtk-doc-pdf \
--with-font-configuration=win32 \
PKG_CONFIG_PATH_$(subst .,_,$(subst -,_,$(TARGET)))='$(PREFIX)/$(TARGET)/qt/lib/pkgconfig' \
CXXFLAGS=-D_WIN32_WINNT=0x0500 \
LIBTIFF_LIBS="`'$(TARGET)-pkg-config' libtiff-4 --libs`"
PATH='$(PREFIX)/$(TARGET)/qt/bin:$(PATH)' \
$(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
$(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
# Test program
'$(TARGET)-g++' \
-W -Wall -Werror -ansi -pedantic \
'$(2).cxx' -o '$(PREFIX)/$(TARGET)/bin/test-poppler.exe' \
`'$(TARGET)-pkg-config' poppler poppler-cpp --cflags --libs`
endef
--- src/poppler.mk.0 2015-01-12 08:12:19.948465406 +0000
+++ src/poppler.mk 2015-01-12 08:14:52.560467743 +0000
@@ -8,7 +8,7 @@
$(PKG)_SUBDIR := poppler-$($(PKG)_VERSION)
$(PKG)_FILE := poppler-$($(PKG)_VERSION).tar.xz
$(PKG)_URL := http://poppler.freedesktop.org/$($(PKG)_FILE)
-$(PKG)_DEPS := gcc glib cairo libpng lcms jpeg tiff freetype zlib curl qt
+$(PKG)_DEPS := gcc glib cairo libpng lcms jpeg tiff freetype zlib curl qt openjpeg
define $(PKG)_UPDATE
$(WGET) -q -O- 'http://poppler.freedesktop.org/' | \
@@ -44,7 +44,6 @@
--enable-splash-output \
--enable-compile-warnings=yes \
--enable-introspection=auto \
- --disable-libopenjpeg \
--disable-gtk-test \
--disable-utils \
--disable-gtk-doc \
@@ -65,5 +64,51 @@
`'$(TARGET)-pkg-config' poppler poppler-cpp --cflags --libs`
endef
-$(PKG)_BUILD_SHARED =
+#$(PKG)_BUILD_SHARED =
+define $(PKG)_BUILD_SHARED
+ # Note: Specifying LIBS explicitly is necessary for configure to properly
+ # pick up libtiff (otherwise linking a minimal test program fails not
+ # because libtiff is not found, but because some references are
+ # undefined)
+ cd '$(1)' \
+ && PATH='$(PREFIX)/$(TARGET)/qt/bin:$(PATH)' \
+ ./configure \
+ --host='$(TARGET)' \
+ --build="`config.guess`" \
+ --prefix='$(PREFIX)/$(TARGET)' \
+ --disable-silent-rules \
+ --enable-shared \
+ --disable-static \
+ --enable-xpdf-headers \
+ --enable-poppler-qt4 \
+ --enable-zlib \
+ --enable-cms=lcms2 \
+ --enable-libcurl \
+ --enable-libtiff \
+ --enable-libjpeg \
+ --enable-libpng \
+ --enable-poppler-glib \
+ --enable-poppler-cpp \
+ --enable-cairo-output \
+ --enable-splash-output \
+ --enable-compile-warnings=yes \
+ --enable-introspection=auto \
+ --disable-gtk-test \
+ --disable-utils \
+ --disable-gtk-doc \
+ --disable-gtk-doc-html \
+ --disable-gtk-doc-pdf \
+ --with-font-configuration=win32 \
+ PKG_CONFIG_PATH_$(subst .,_,$(subst -,_,$(TARGET)))='$(PREFIX)/$(TARGET)/qt/lib/pkgconfig' \
+ CXXFLAGS=-D_WIN32_WINNT=0x0500 \
+ LIBTIFF_LIBS="`'$(TARGET)-pkg-config' libtiff-4 --libs`"
+ PATH='$(PREFIX)/$(TARGET)/qt/bin:$(PATH)' \
+ $(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+ $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+ # Test program
+ '$(TARGET)-g++' \
+ -W -Wall -Werror -ansi -pedantic \
+ '$(2).cxx' -o '$(PREFIX)/$(TARGET)/bin/test-poppler.exe' \
+ `'$(TARGET)-pkg-config' poppler poppler-cpp --cflags --libs`
+endef
sudo su
apt-get update
apt-get -y install autoconf automake bash bison bzip2 \
cmake flex gettext git g++ intltool \
libffi-dev libtool libltdl-dev libssl-dev \
libxml-parser-perl make openssl patch perl \
pkg-config scons sed unzip wget xz-utils \
g++-multilib libc6-dev-i386 autopoint gperf ruby
git clone https://github.com/mxe/mxe.git
cd /opt/mxe
wget https://gist.github.com/witwall/e81d8724718b7fc754fb/raw/e87595cbc1c512e1bbb65b84c1b9fe029b4bcea4/openjpeg.mk -O src/openjpeg.mk
wget https://gist.githubusercontent.com/witwall/e81d8724718b7fc754fb/raw/5523ceeec458cf614a09fb5fc018b50a27df9046/index.html.patch
patch index.html index.html.patch
wget https://gist.github.com/witwall/e81d8724718b7fc754fb/raw/cdc1fc00cde5d6b1172aace98761e5c409dafab0/poppler.mk.patch
patch src/poppler.mk poppler.mk.patch
make poppler MXE_TARGETS='i686-w64-mingw32.shared i686-w64-mingw32.static'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment