changeset 2797:71a1673c1e9c

Merge branch 'stable'
author Volker Grabsch <vog@notjusthosting.com>
date Mon, 08 Oct 2012 22:34:44 +0200
parents e5245ccc4485 (diff) a35bc5f99e0e (current diff)
children d7570a06e60e
files index.html
diffstat 283 files changed, 19451 insertions(+), 2413 deletions(-) [+]
line wrap: on
line diff
--- a/.gitignore	Mon Oct 08 22:34:18 2012 +0200
+++ b/.gitignore	Mon Oct 08 22:34:44 2012 +0200
@@ -1,3 +1,4 @@
+/settings.mk
 /usr/
 /log/
 /pkg
--- a/Makefile	Mon Oct 08 22:34:18 2012 +0200
+++ b/Makefile	Mon Oct 08 22:34:44 2012 +0200
@@ -4,6 +4,8 @@
 JOBS               := 1
 TARGET             := i686-pc-mingw32
 SOURCEFORGE_MIRROR := freefr.dl.sourceforge.net
+PKG_MIRROR         := s3.amazonaws.com/mxe-pkg
+PKG_CDN            := d1yihgixbnrglp.cloudfront.net
 
 PWD        := $(shell pwd)
 SHELL      := bash
@@ -13,6 +15,9 @@
 LIBTOOLIZE := $(shell glibtoolize --help >/dev/null 2>&1 && echo g)libtoolize
 PATCH      := $(shell gpatch --help >/dev/null 2>&1 && echo g)patch
 SED        := $(shell gsed --help >/dev/null 2>&1 && echo g)sed
+WGET       := wget --no-check-certificate \
+                   --user-agent=$(shell wget --version | \
+                   $(SED) -n 's,GNU \(Wget\) \([0-9.]*\).*,\1/\2,p')
 
 REQUIREMENTS := autoconf automake bash bison bzip2 cmake flex \
                 gcc intltoolize $(LIBTOOL) $(LIBTOOLIZE) \
@@ -26,7 +31,7 @@
 TMP_DIR     = $(PWD)/tmp-$(1)
 MAKEFILE   := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
 TOP_DIR    := $(patsubst %/,%,$(dir $(MAKEFILE)))
-PKGS       := $(shell $(SED) -n 's/^.* id="\([^"]*\)-package".*$$/\1/p' '$(TOP_DIR)/index.html')
+PKGS       := $(shell $(SED) -n 's/^.* id="\([^"]*\)-package">.*$$/\1/p' '$(TOP_DIR)/index.html')
 PATH       := $(PREFIX)/bin:$(PATH)
 
 CMAKE_TOOLCHAIN_FILE := $(PREFIX)/$(TARGET)/share/cmake/mxe-conf.cmake
@@ -61,12 +66,29 @@
 DOWNLOAD_PKG_ARCHIVE = \
     mkdir -p '$(PKG_DIR)' && \
     $(if $($(1)_URL_2), \
-        ( wget -T 30 -t 3 --no-check-certificate -O- '$($(1)_URL)' || wget --no-check-certificate -O- '$($(1)_URL_2)' ), \
-        wget --no-check-certificate -O- '$($(1)_URL)') \
+        ( $(WGET) -T 30 -t 3 -O- '$($(1)_URL)' || \
+          $(WGET) -O- '$($(1)_URL_2)' || \
+          $(WGET) -O- '$(PKG_MIRROR)/$($(1)_FILE)' || \
+          $(WGET) -O- '$(PKG_CDN)/$($(1)_FILE)' ), \
+        ( $(WGET) -O- '$($(1)_URL)' || \
+          $(WGET) -O- '$(PKG_MIRROR)/$($(1)_FILE)' || \
+          $(WGET) -O- '$(PKG_CDN)/$($(1)_FILE)' )) \
     $(if $($(1)_FIX_GZIP), \
         | gzip -d | gzip -9n, \
         ) \
-    > '$(PKG_DIR)/$($(1)_FILE)'
+    > '$(PKG_DIR)/$($(1)_FILE)' || rm -f '$(PKG_DIR)/$($(1)_FILE)'
+
+ifeq ($(IGNORE_SETTINGS),yes)
+    $(info [ignore settings.mk])
+else ifeq ($(wildcard $(PWD)/settings.mk),$(PWD)/settings.mk)
+    include $(PWD)/settings.mk
+else
+    $(info [create settings.mk])
+    $(shell { \
+        echo '#JOBS = $(JOBS)'; \
+        echo '#PKGS ='; \
+    } >'$(PWD)/settings.mk')
+endif
 
 .PHONY: all
 all: $(PKGS)
@@ -169,6 +191,7 @@
 	@echo '[done]     $(1)'
 
 .PHONY: build-only-$(1)
+build-only-$(1): PKG = $(1)
 build-only-$(1):
 	$(if $(value $(1)_BUILD),
 	    rm -rf   '$(2)'
--- a/index.html	Mon Oct 08 22:34:18 2012 +0200
+++ b/index.html	Mon Oct 08 22:34:44 2012 +0200
@@ -668,7 +668,7 @@
     <!-- http://www.debian.org/distrib/packages#search_packages -->
     <pre>aptitude install -R autoconf automake bash bison bzip2 \
                     cmake flex gettext git g++ intltool \
-                    libtool libltdl-dev openssl libssl-dev \
+                    libffi-dev libtool libltdl-dev openssl libssl-dev \
                     libxml-parser-perl make patch perl \
                     pkg-config scons sed unzip wget \
                     xz-utils yasm</pre>
@@ -683,7 +683,7 @@
     <!-- https://admin.fedoraproject.org/pkgdb/ -->
     <pre>yum install autoconf automake bash bison bzip2 cmake \
             flex gcc-c++ gettext git intltool make sed \
-            libtool openssl-devel patch perl pkgconfig \
+            libffi-devel libtool openssl-devel patch perl pkgconfig \
             scons yasm unzip wget xz</pre>
 
     <p>
@@ -695,7 +695,7 @@
 
     <!-- http://www.freshports.org/ -->
     <pre>pkg_add -r automake111 autoconf268 bash bison cmake \
-           flex gettext git gmake gsed intltool libtool \
+           flex gettext git gmake gsed intltool libffi libtool \
            openssl patch perl p5-XML-Parser pkg-config \
            scons unzip wget yasm</pre>
 
@@ -719,7 +719,7 @@
 
     <!-- http://www.frugalware.org/packages -->
     <pre>pacman-g2 -S autoconf automake bash bzip2 bison cmake \
-             flex gcc gettext git intltool make sed libtool \
+             flex gcc gettext git intltool make sed libffi libtool \
              openssl patch perl perl-xml-parser pkgconfig \
              scons unzip wget xz xz-lzma yasm</pre>
 
@@ -736,7 +736,7 @@
        dev-util/cmake sys-devel/flex sys-devel/gcc \
        sys-devel/gettext dev-vcs/git \
        dev-util/intltool sys-devel/make sys-apps/sed \
-       sys-devel/libtool dev-libs/openssl sys-devel/patch \
+       dev-libs/libffi sys-devel/libtool dev-libs/openssl sys-devel/patch \
        dev-lang/perl dev-perl/XML-Parser \
        dev-util/pkgconfig dev-util/scons app-arch/unzip \
        net-misc/wget app-arch/xz-utils dev-lang/yasm</pre>
@@ -752,7 +752,7 @@
     </p>
     <!-- http://www.macports.org/ports.php -->
     <pre>sudo port install autoconf automake bison cmake flex \
-                  gettext git-core gsed intltool libtool \
+                  gettext git-core gsed intltool libffi libtool \
                   openssl p5-xml-parser pkgconfig scons \
                   wget xz yasm</pre>
     <p>
@@ -764,7 +764,7 @@
     <!-- http://software.opensuse.org/113/en -->
     <pre>zypper install -R autoconf automake bash bison bzip2 \
                   cmake flex gcc-c++ gettext-tools git \
-                  intltool libtool make openssl \
+                  intltool libffi-devel libtool make openssl \
                   libopenssl-devel patch perl \
                   perl-XML-Parser pkg-config scons \
                   sed unzip wget xz yasm</pre>
@@ -914,8 +914,23 @@
         <td id="agg-website"><a href="http://www.antigrain.com/">Anti-Grain Geometry</a></td>
     </tr>
     <tr>
+        <td id="apr-util-package">apr-util</td>
+        <td id="apr-util-version">1.3.10</td>
+        <td id="apr-util-website"><a href="http://apr.apache.org/">APR-util</a></td>
+    </tr>
+    <tr>
+        <td id="apr-package">apr</td>
+        <td id="apr-version">1.4.2</td>
+        <td id="apr-website"><a href="http://apr.apache.org/">APR</a></td>
+    </tr>
+    <tr>
+        <td id="armadillo-package">armadillo</td>
+        <td id="armadillo-version">3.4.3</td>
+        <td id="armadillo-website"><a href="http://armadillo.sf.net/">Armadillo C++ linear algebra library</a></td>
+    </tr>
+    <tr>
         <td id="atk-package">atk</td>
-        <td id="atk-version">2.2.0</td>
+        <td id="atk-version">2.4.0</td>
         <td id="atk-website"><a href="http://www.gtk.org/">ATK</a></td>
     </tr>
     <tr>
@@ -945,7 +960,7 @@
     </tr>
     <tr>
         <td id="boost-package">boost</td>
-        <td id="boost-version">1.49.0</td>
+        <td id="boost-version">1.51.0</td>
         <td id="boost-website"><a href="http://www.boost.org/">Boost C++ Library</a></td>
     </tr>
     <tr>
@@ -955,7 +970,7 @@
     </tr>
     <tr>
         <td id="cairo-package">cairo</td>
-        <td id="cairo-version">1.10.2</td>
+        <td id="cairo-version">1.12.2</td>
         <td id="cairo-website"><a href="http://cairographics.org/">cairo</a></td>
     </tr>
     <tr>
@@ -970,10 +985,15 @@
     </tr>
     <tr>
         <td id="cgal-package">cgal</td>
-        <td id="cgal-version">4.0</td>
+        <td id="cgal-version">4.0.2</td>
         <td id="cgal-website"><a href="http://www.cgal.org/">cgal</a></td>
     </tr>
     <tr>
+        <td id="cminpack-package">cminpack</td>
+        <td id="cminpack-version">1.2.0</td>
+        <td id="cminpack-website"><a href="http://devernay.free.fr/hacks/cminpack/cminpack.html">cminpack</a></td>
+    </tr>
+    <tr>
         <td id="cppunit-package">cppunit</td>
         <td id="cppunit-version">1.12.1</td>
         <td id="cppunit-website"><a href="http://apps.sourceforge.net/mediawiki/cppunit/">CppUnit</a></td>
@@ -985,12 +1005,12 @@
     </tr>
     <tr>
         <td id="curl-package">curl</td>
-        <td id="curl-version">7.25.0</td>
+        <td id="curl-version">7.27.0</td>
         <td id="curl-website"><a href="http://curl.haxx.se/libcurl/">cURL</a></td>
     </tr>
     <tr>
         <td id="dbus-package">dbus</td>
-        <td id="dbus-version">1.5.12</td>
+        <td id="dbus-version">1.6.8</td>
         <td id="dbus-website"><a href="http://dbus.freedesktop.org/">dbus</a></td>
     </tr>
     <tr>
@@ -1025,12 +1045,12 @@
     </tr>
     <tr>
         <td id="ffmpeg-package">ffmpeg</td>
-        <td id="ffmpeg-version">0.10.2</td>
+        <td id="ffmpeg-version">1.0</td>
         <td id="ffmpeg-website"><a href="http://www.ffmpeg.org/">ffmpeg</a></td>
     </tr>
     <tr>
         <td id="fftw-package">fftw</td>
-        <td id="fftw-version">3.3.1</td>
+        <td id="fftw-version">3.3.2</td>
         <td id="fftw-website"><a href="http://www.fftw.org/">fftw</a></td>
     </tr>
     <tr>
@@ -1050,7 +1070,7 @@
     </tr>
     <tr>
         <td id="fontconfig-package">fontconfig</td>
-        <td id="fontconfig-version">2.9.0</td>
+        <td id="fontconfig-version">2.10.1</td>
         <td id="fontconfig-website"><a href="http://fontconfig.org/">fontconfig</a></td>
     </tr>
     <tr>
@@ -1070,12 +1090,12 @@
     </tr>
     <tr>
         <td id="freetype-package">freetype</td>
-        <td id="freetype-version">2.4.9</td>
+        <td id="freetype-version">2.4.10</td>
         <td id="freetype-website"><a href="http://freetype.sourceforge.net/">freetype</a></td>
     </tr>
     <tr>
         <td id="fribidi-package">fribidi</td>
-        <td id="fribidi-version">0.19.2</td>
+        <td id="fribidi-version">0.19.4</td>
         <td id="fribidi-website"><a href="http://fribidi.org/">FriBidi</a></td>
     </tr>
     <tr>
@@ -1085,27 +1105,27 @@
     </tr>
     <tr>
         <td id="gc-package">gc</td>
-        <td id="gc-version">7.1</td>
+        <td id="gc-version">7.2d</td>
         <td id="gc-website"><a href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/">gc</a></td>
     </tr>
     <tr>
         <td id="gcc-package">gcc</td>
-        <td id="gcc-version">4.7.0</td>
+        <td id="gcc-version">4.7.2</td>
         <td id="gcc-website"><a href="http://gcc.gnu.org/">GCC</a></td>
     </tr>
     <tr>
         <td id="gcc-gmp-package">gcc-gmp</td>
-        <td id="gcc-gmp-version">5.0.4</td>
+        <td id="gcc-gmp-version">5.0.5</td>
         <td id="gcc-gmp-website"><a href="http://www.gmplib.org/">GMP for GCC</a></td>
     </tr>
     <tr>
         <td id="gcc-mpc-package">gcc-mpc</td>
-        <td id="gcc-mpc-version">0.9</td>
+        <td id="gcc-mpc-version">1.0.1</td>
         <td id="gcc-mpc-website"><a href="http://www.multiprecision.org/">MPC for GCC</a></td>
     </tr>
     <tr>
         <td id="gcc-mpfr-package">gcc-mpfr</td>
-        <td id="gcc-mpfr-version">3.1.0</td>
+        <td id="gcc-mpfr-version">3.1.1</td>
         <td id="gcc-mpfr-website"><a href="http://www.mpfr.org/">MPFR for GCC</a></td>
     </tr>
     <tr>
@@ -1115,22 +1135,22 @@
     </tr>
     <tr>
         <td id="gdal-package">gdal</td>
-        <td id="gdal-version">1.9.0</td>
+        <td id="gdal-version">1.9.1</td>
         <td id="gdal-website"><a href="http://www.gdal.org/">GDAL</a></td>
     </tr>
     <tr>
         <td id="gdb-package">gdb</td>
-        <td id="gdb-version">7.4</td>
+        <td id="gdb-version">7.5</td>
         <td id="gdb-website"><a href="http://www.gnu.org/software/gdb/">gdb</a></td>
     </tr>
     <tr>
         <td id="gdk-pixbuf-package">gdk-pixbuf</td>
-        <td id="gdk-pixbuf-version">2.22.1</td>
+        <td id="gdk-pixbuf-version">2.26.1</td>
         <td id="gdk-pixbuf-website"><a href="http://www.gdk-pixbuf.org/">GDK-pixbuf</a></td>
     </tr>
     <tr>
         <td id="geos-package">geos</td>
-        <td id="geos-version">3.3.2</td>
+        <td id="geos-version">3.3.5</td>
         <td id="geos-website"><a href="http://trac.osgeo.org/geos/">GEOS</a></td>
     </tr>
     <tr>
@@ -1140,37 +1160,37 @@
     </tr>
     <tr>
         <td id="giflib-package">giflib</td>
-        <td id="giflib-version">4.1.6</td>
+        <td id="giflib-version">5.0.0</td>
         <td id="giflib-website"><a href="http://sourceforge.net/projects/libungif/">giflib</a></td>
     </tr>
     <tr>
         <td id="glew-package">glew</td>
-        <td id="glew-version">1.7.0</td>
+        <td id="glew-version">1.9.0</td>
         <td id="glew-website"><a href="http://glew.sourceforge.net/">GLEW</a></td>
     </tr>
     <tr>
         <td id="glib-package">glib</td>
-        <td id="glib-version">2.28.8</td>
+        <td id="glib-version">2.32.3</td>
         <td id="glib-website"><a href="http://www.gtk.org/">GLib</a></td>
     </tr>
     <tr>
         <td id="glibmm-package">glibmm</td>
-        <td id="glibmm-version">2.28.2</td>
+        <td id="glibmm-version">2.32.0</td>
         <td id="glibmm-website"><a href="http://www.gtkmm.org/">GLibmm</a></td>
     </tr>
     <tr>
         <td id="gmp-package">gmp</td>
-        <td id="gmp-version">5.0.4</td>
+        <td id="gmp-version">5.0.5</td>
         <td id="gmp-website"><a href="http://www.gmplib.org/">GMP</a></td>
     </tr>
     <tr>
         <td id="gnutls-package">gnutls</td>
-        <td id="gnutls-version">3.0.17</td>
+        <td id="gnutls-version">3.1.2</td>
         <td id="gnutls-website"><a href="http://www.gnu.org/software/gnutls/">GnuTLS</a></td>
     </tr>
     <tr>
         <td id="graphicsmagick-package">graphicsmagick</td>
-        <td id="graphicsmagick-version">1.3.14</td>
+        <td id="graphicsmagick-version">1.3.16</td>
         <td id="graphicsmagick-website"><a href="http://www.graphicsmagick.org/">GraphicsMagick</a></td>
     </tr>
     <tr>
@@ -1180,35 +1200,40 @@
     </tr>
     <tr>
         <td id="gsoap-package">gsoap</td>
-        <td id="gsoap-version">2.8.8</td>
+        <td id="gsoap-version">2.8.10</td>
         <td id="gsoap-website"><a href="http://gsoap2.sourceforge.net/">gSOAP</a></td>
     </tr>
     <tr>
         <td id="gst-plugins-base-package">gst-plugins-base</td>
-        <td id="gst-plugins-base-version">0.10.35</td>
+        <td id="gst-plugins-base-version">0.10.36</td>
         <td id="gst-plugins-base-website"><a href="http://gstreamer.freedesktop.org/">gst-plugins-base</a></td>
     </tr>
     <tr>
         <td id="gst-plugins-good-package">gst-plugins-good</td>
-        <td id="gst-plugins-good-version">0.10.30</td>
+        <td id="gst-plugins-good-version">0.10.31</td>
         <td id="gst-plugins-good-website"><a href="http://gstreamer.freedesktop.org/">gst-plugins-good</a></td>
     </tr>
     <tr>
         <td id="gstreamer-package">gstreamer</td>
-        <td id="gstreamer-version">0.10.35</td>
+        <td id="gstreamer-version">0.10.36</td>
         <td id="gstreamer-website"><a href="http://gstreamer.freedesktop.org/">gstreamer</a></td>
     </tr>
     <tr>
         <td id="gta-package">gta</td>
-        <td id="gta-version">1.0.2</td>
+        <td id="gta-version">1.0.3</td>
         <td id="gta-website"><a href="http://gta.nongnu.org/">gta</a></td>
     </tr>
     <tr>
         <td id="gtk2-package">gtk2</td>
-        <td id="gtk2-version">2.24.4</td>
+        <td id="gtk2-version">2.24.10</td>
         <td id="gtk2-website"><a href="http://www.gtk.org/">GTK+</a></td>
     </tr>
     <tr>
+        <td id="gtkglarea-package">gtkGLArea</td>
+        <td id="gtkglarea-version">2.0.1</td>
+        <td id="gtkglarea-website"><a href="http://www.mono-project.com/GtkGLArea/">GtkGLArea</a></td>
+    </tr>
+    <tr>
         <td id="gtkglext-package">gtkglext</td>
         <td id="gtkglext-version">1.2.0</td>
         <td id="gtkglext-website"><a href="http://gtkglext.sourceforge.net/">GtkGLExt</a></td>
@@ -1230,7 +1255,7 @@
     </tr>
     <tr>
         <td id="gtksourceviewmm2-package">gtksourceviewmm2</td>
-        <td id="gtksourceviewmm2-version">2.10.1</td>
+        <td id="gtksourceviewmm2-version">2.10.3</td>
         <td id="gtksourceviewmm2-website"><a href="http://projects.gnome.org/gtksourceviewmm/">GtkSourceViewmm</a></td>
     </tr>
     <tr>
@@ -1239,6 +1264,11 @@
         <td id="guile-website"><a href="http://www.gnu.org/software/guile/">GNU Guile</a></td>
     </tr>
     <tr>
+        <td id="hunspell-package">hunspell</td>
+        <td id="hunspell-version">1.3.2</td>
+        <td id="hunspell-website"><a href="http://hunspell.sourceforge.net/">Hunspell</a></td>
+    </tr>
+    <tr>
         <td id="id3lib-package">id3lib</td>
         <td id="id3lib-version">3.8.3</td>
         <td id="id3lib-website"><a href="http://id3lib.sourceforge.net/">id3lib</a></td>
@@ -1265,7 +1295,7 @@
     </tr>
     <tr>
         <td id="json-c-package">json-c</td>
-        <td id="json-c-version">0.9</td>
+        <td id="json-c-version">0.10</td>
         <td id="json-c-website"><a href="http://oss.metaparadigm.com/json-c/">json-c</a></td>
     </tr>
     <tr>
@@ -1275,12 +1305,12 @@
     </tr>
     <tr>
         <td id="lapack-package">lapack</td>
-        <td id="lapack-version">3.4.0</td>
+        <td id="lapack-version">3.4.2</td>
         <td id="lapack-website"><a href="http://www.netlib.org/lapack/">lapack</a></td>
     </tr>
     <tr>
         <td id="lcms-package">lcms</td>
-        <td id="lcms-version">2.3</td>
+        <td id="lcms-version">2.4</td>
         <td id="lcms-website"><a href="http://www.littlecms.com/">lcms</a></td>
     </tr>
     <tr>
@@ -1289,6 +1319,11 @@
         <td id="lcms1-website"><a href="http://www.littlecms.com/">lcms1</a></td>
     </tr>
     <tr>
+        <td id="levmar-package">levmar</td>
+        <td id="levmar-version">2.6</td>
+        <td id="levmar-website"><a href="http://www.ics.forth.gr/~lourakis/levmar">levmar</a></td>
+    </tr>
+    <tr>
         <td id="libarchive-package">libarchive</td>
         <td id="libarchive-version">3.0.3</td>
         <td id="libarchive-website"><a href="http://code.google.com/p/libarchive/">Libarchive</a></td>
@@ -1310,12 +1345,17 @@
     </tr>
     <tr>
         <td id="libevent-package">libevent</td>
-        <td id="libevent-version">2.0.18</td>
+        <td id="libevent-version">2.0.20</td>
         <td id="libevent-website"><a href="http://libevent.org/">libevent</a></td>
     </tr>
     <tr>
+        <td id="libf2c-package">libf2c</td>
+        <td id="libf2c-version">1</td>
+        <td id="libf2c-website"><a href="http://www.netlib.org/f2c/">libf2c</a></td>
+    </tr>
+    <tr>
         <td id="libffi-package">libffi</td>
-        <td id="libffi-version">3.0.10</td>
+        <td id="libffi-version">3.0.11</td>
         <td id="libffi-website"><a href="http://sourceware.org/libffi/">libffi</a></td>
     </tr>
     <tr>
@@ -1324,16 +1364,31 @@
         <td id="libgcrypt-website"><a href="ftp://ftp.gnupg.org/gcrypt/libgcrypt/">libgcrypt</a></td>
     </tr>
     <tr>
+        <td id="libgda-package">libgda</td>
+        <td id="libgda-version">4.2.13</td>
+        <td id="libgda-website"><a href="http://www.gnome-db.org/">libgda</a></td>
+    </tr>
+    <tr>
+        <td id="libgdamm-package">libgdamm</td>
+        <td id="libgdamm-version">4.1.3</td>
+        <td id="libgdamm-website"><a href="https://launchpad.net/libgdamm">libgdamm</a></td>
+    </tr>
+    <tr>
         <td id="libgee-package">libgee</td>
         <td id="libgee-version">0.5.0</td>
         <td id="libgee-website"><a href="http://live.gnome.org/Libgee">libgee</a></td>
     </tr>
     <tr>
         <td id="libgeotiff-package">libgeotiff</td>
-        <td id="libgeotiff-version">1.3.0</td>
+        <td id="libgeotiff-version">1.4.0</td>
         <td id="libgeotiff-website"><a href="http://trac.osgeo.org/geotiff/">GeoTiff</a></td>
     </tr>
     <tr>
+        <td id="libglade-package">libglade</td>
+        <td id="libglade-version">2.6.4</td>
+        <td id="libglade-website"><a href="http://glade.gnome.org/">glade</a></td>
+    </tr>
+    <tr>
         <td id="libgnurx-package">libgnurx</td>
         <td id="libgnurx-version">2.5.1</td>
         <td id="libgnurx-website"><a href="http://sourceforge.net/projects/mingw/files/UserContributed/regex/">libgnurx</a></td>
@@ -1350,12 +1405,12 @@
     </tr>
     <tr>
         <td id="libgsasl-package">libgsasl</td>
-        <td id="libgsasl-version">1.6.1</td>
+        <td id="libgsasl-version">1.8.0</td>
         <td id="libgsasl-website"><a href="http://www.gnu.org/software/gsasl/">Libgsasl</a></td>
     </tr>
     <tr>
         <td id="libgsf-package">libgsf</td>
-        <td id="libgsf-version">1.14.22</td>
+        <td id="libgsf-version">1.14.23</td>
         <td id="libgsf-website"><a href="http://projects.gnome.org/libgsf/">libgsf</a></td>
     </tr>
     <tr>
@@ -1380,7 +1435,7 @@
     </tr>
     <tr>
         <td id="libidn-package">libidn</td>
-        <td id="libidn-version">1.24</td>
+        <td id="libidn-version">1.25</td>
         <td id="libidn-website"><a href="http://www.gnu.org/software/libidn/">Libidn</a></td>
     </tr>
     <tr>
@@ -1409,13 +1464,18 @@
         <td id="libmng-website"><a href="http://www.libmng.com/">libmng</a></td>
     </tr>
     <tr>
+        <td id="libmodplug-package">libmodplug</td>
+        <td id="libmodplug-version">0.8.8.4</td>
+        <td id="libmodplug-website"><a href="http://modplug-xmms.sourceforge.net/">libmodplug</a></td>
+    </tr>
+    <tr>
         <td id="libntlm-package">libntlm</td>
         <td id="libntlm-version">1.3</td>
         <td id="libntlm-website"><a href="http://www.nongnu.org/libntlm/">Libntlm</a></td>
     </tr>
     <tr>
         <td id="liboauth-package">liboauth</td>
-        <td id="liboauth-version">0.9.6</td>
+        <td id="liboauth-version">0.9.7</td>
         <td id="liboauth-website"><a href="http://liboauth.sourceforge.net/">liboauth</a></td>
     </tr>
     <tr>
@@ -1435,18 +1495,23 @@
     </tr>
     <tr>
         <td id="libpaper-package">libpaper</td>
-        <td id="libpaper-version">1.1.24+nmu1</td>
+        <td id="libpaper-version">1.1.24+nmu2</td>
         <td id="libpaper-website"><a href="http://packages.debian.org/unstable/libpaper1">libpaper</a></td>
     </tr>
     <tr>
         <td id="libpng-package">libpng</td>
-        <td id="libpng-version">1.5.10</td>
+        <td id="libpng-version">1.5.13</td>
         <td id="libpng-website"><a href="http://www.libpng.org/">libpng</a></td>
     </tr>
     <tr>
         <td id="librsvg-package">librsvg</td>
-        <td id="librsvg-version">2.36.0</td>
+        <td id="librsvg-version">2.36.3</td>
         <td id="librsvg-website"><a href="http://librsvg.sourceforge.net/">librsvg</a></td>
+	</tr>
+    <tr>
+        <td id="librtmp-package">librtmp</td>
+        <td id="librtmp-version">2.4</td>
+        <td id="librtmp-website"><a href="http://rtmpdump.mplayerhq.hu/">librtmp</a></td>
     </tr>
     <tr>
         <td id="libsamplerate-package">libsamplerate</td>
@@ -1455,12 +1520,12 @@
     </tr>
     <tr>
         <td id="libshout-package">libshout</td>
-        <td id="libshout-version">2.2.2</td>
+        <td id="libshout-version">2.3.1</td>
         <td id="libshout-website"><a href="http://www.icecast.org/">libshout</a></td>
     </tr>
     <tr>
         <td id="libsigc++-package">libsigc++</td>
-        <td id="libsigc++-version">2.2.10</td>
+        <td id="libsigc++-version">2.2.11</td>
         <td id="libsigc++-website"><a href="http://libsigc.sourceforge.net/">libsigc++</a></td>
     </tr>
     <tr>
@@ -1470,7 +1535,7 @@
     </tr>
     <tr>
         <td id="libssh2-package">libssh2</td>
-        <td id="libssh2-version">1.4.0</td>
+        <td id="libssh2-version">1.4.2</td>
         <td id="libssh2-website"><a href="http://www.libssh2.org">libssh2</a></td>
     </tr>
     <tr>
@@ -1490,22 +1555,22 @@
     </tr>
     <tr>
         <td id="libvpx-package">libvpx</td>
-        <td id="libvpx-version">1.0.0</td>
+        <td id="libvpx-version">1.1.0</td>
         <td id="libvpx-website"><a href="http://code.google.com/p/webm/">vpx</a></td>
     </tr>
     <tr>
         <td id="libxml++-package">libxml++</td>
-        <td id="libxml++-version">2.35.2</td>
+        <td id="libxml++-version">2.35.3</td>
         <td id="libxml++-website"><a href="http://libxmlplusplus.sourceforge.net/">libxml2</a></td>
     </tr>
     <tr>
         <td id="libxml2-package">libxml2</td>
-        <td id="libxml2-version">2.7.8</td>
+        <td id="libxml2-version">2.8.0</td>
         <td id="libxml2-website"><a href="http://www.xmlsoft.org/">libxml2</a></td>
     </tr>
     <tr>
         <td id="libxslt-package">libxslt</td>
-        <td id="libxslt-version">1.1.26</td>
+        <td id="libxslt-version">1.1.27</td>
         <td id="libxslt-website"><a href="http://xmlsoft.org/XSLT/">libxslt</a></td>
     </tr>
     <tr>
@@ -1514,8 +1579,13 @@
         <td id="llvm-website"><a href="http://llvm.org/">llvm</a></td>
     </tr>
     <tr>
+        <td id="log4cxx-package">log4cxx</td>
+        <td id="log4cxx-version">0.10.0</td>
+        <td id="log4cxx-website"><a href="http://logging.apache.org/log4cxx/">log4cxx</a></td>
+    </tr>
+    <tr>
         <td id="lua-package">lua</td>
-        <td id="lua-version">5.1.4</td>
+        <td id="lua-version">5.2.0</td>
         <td id="lua-website"><a href="http://www.lua.org/">Lua</a></td>
     </tr>
     <tr>
@@ -1529,23 +1599,28 @@
         <td id="matio-website"><a href="http://sourceforge.net/projects/matio/">matio</a></td>
     </tr>
     <tr>
+        <td id="mdbtools-package">mdbtools</td>
+        <td id="mdbtools-version">0.7</td>
+        <td id="mdbtools-website"><a href="http://sourceforge.net/projects/mdbtools/">mdbtools</a></td>
+    </tr>
+    <tr>
         <td id="mingw-utils-package">mingw-utils</td>
         <td id="mingw-utils-version">0.4-1</td>
         <td id="mingw-utils-website"><a href="http://www.mingw.org/">MinGW Utilities</a></td>
     </tr>
     <tr>
         <td id="mingwrt-package">mingwrt</td>
-        <td id="mingwrt-version">3.20</td>
+        <td id="mingwrt-version">3.20-2</td>
         <td id="mingwrt-website"><a href="http://www.mingw.org/">MinGW Runtime</a></td>
     </tr>
     <tr>
         <td id="mpfr-package">mpfr</td>
-        <td id="mpfr-version">3.1.0</td>
+        <td id="mpfr-version">3.1.1</td>
         <td id="mpfr-website"><a href="http://www.mpfr.org/">mpfr</a></td>
     </tr>
     <tr>
         <td id="muparser-package">muparser</td>
-        <td id="muparser-version">1.34</td>
+        <td id="muparser-version">2.2.2</td>
         <td id="muparser-website"><a href="http://muparser.sourceforge.net/">muParser</a></td>
     </tr>
     <tr>
@@ -1554,8 +1629,13 @@
         <td id="mxml-website"><a href="http://www.minixml.org/">Mini-XML</a></td>
     </tr>
     <tr>
+        <td id="ncurses-package">ncurses</td>
+        <td id="ncurses-version">5.9</td>
+        <td id="ncurses-website"><a href="http://www.gnu.org/software/ncurses/">Ncurses</a></td>
+    </tr>
+    <tr>
         <td id="nettle-package">nettle</td>
-        <td id="nettle-version">2.4</td>
+        <td id="nettle-version">2.5</td>
         <td id="nettle-website"><a href="http://www.lysator.liu.se/~nisse/nettle/">nettle</a></td>
     </tr>
     <tr>
@@ -1575,7 +1655,7 @@
     </tr>
     <tr>
         <td id="openal-package">openal</td>
-        <td id="openal-version">1.13</td>
+        <td id="openal-version">1.14</td>
         <td id="openal-website"><a href="http://kcat.strangesoft.net/openal.html">openal</a></td>
     </tr>
     <tr>
@@ -1600,22 +1680,22 @@
     </tr>
     <tr>
         <td id="openssl-package">openssl</td>
-        <td id="openssl-version">1.0.1</td>
+        <td id="openssl-version">1.0.1c</td>
         <td id="openssl-website"><a href="http://www.openssl.org/">openssl</a></td>
     </tr>
     <tr>
         <td id="pango-package">pango</td>
-        <td id="pango-version">1.29.3</td>
+        <td id="pango-version">1.30.1</td>
         <td id="pango-website"><a href="http://www.pango.org/">Pango</a></td>
     </tr>
     <tr>
         <td id="pangomm-package">pangomm</td>
-        <td id="pangomm-version">2.28.2</td>
+        <td id="pangomm-version">2.28.4</td>
         <td id="pangomm-website"><a href="http://www.pango.org/">Pangomm</a></td>
     </tr>
     <tr>
         <td id="pcre-package">pcre</td>
-        <td id="pcre-version">8.30</td>
+        <td id="pcre-version">8.31</td>
         <td id="pcre-website"><a href="http://www.pcre.org/">PCRE</a></td>
     </tr>
     <tr>
@@ -1624,8 +1704,13 @@
         <td id="pdcurses-website"><a href="http://pdcurses.sourceforge.net/">PDcurses</a></td>
     </tr>
     <tr>
+        <td id="plibc-package">plibc</td>
+        <td id="plibc-version">0.1.7</td>
+        <td id="plibc-website"><a href="http://plibc.sourceforge.net/">Plibc</a></td>
+    </tr>
+    <tr>
         <td id="pdflib_lite-package">pdflib_lite</td>
-        <td id="pdflib_lite-version">7.0.5</td>
+        <td id="pdflib_lite-version">7.0.5p3</td>
         <td id="pdflib_lite-website"><a href="http://www.pdflib.com/download/free-software/pdflib-lite-7/">PDFlib Lite</a></td>
     </tr>
     <tr>
@@ -1640,7 +1725,7 @@
     </tr>
     <tr>
         <td id="pixman-package">pixman</td>
-        <td id="pixman-version">0.25.2</td>
+        <td id="pixman-version">0.27.2</td>
         <td id="pixman-website"><a href="http://cairographics.org/">pixman</a></td>
     </tr>
     <tr>
@@ -1659,18 +1744,23 @@
         <td id="poco-website"><a href="http://pocoproject.org/">POCO C++ Libraries</a></td>
     </tr>
     <tr>
+        <td id="poppler-package">poppler</td>
+        <td id="poppler-version">0.20.4</td>
+        <td id="poppler-website"><a href="http://poppler.freedesktop.org/">poppler</a></td>
+    </tr>
+    <tr>
         <td id="popt-package">popt</td>
         <td id="popt-version">1.16</td>
         <td id="popt-website"><a href="http://freshmeat.net/projects/popt/">popt</a></td>
     </tr>
     <tr>
         <td id="portaudio-package">portaudio</td>
-        <td id="portaudio-version">19_20071207</td>
+        <td id="portaudio-version">19_20111121</td>
         <td id="portaudio-website"><a href="http://www.portaudio.com/">portaudio</a></td>
     </tr>
     <tr>
         <td id="postgresql-package">postgresql</td>
-        <td id="postgresql-version">9.1.3</td>
+        <td id="postgresql-version">9.2.1</td>
         <td id="postgresql-website"><a href="http://www.postgresql.org/">PostgreSQL</a></td>
     </tr>
     <tr>
@@ -1679,21 +1769,36 @@
         <td id="proj-website"><a href="http://trac.osgeo.org/proj/">proj</a></td>
     </tr>
     <tr>
+        <td id="protobuf-package">protobuf</td>
+        <td id="protobuf-version">2.4.1</td>
+        <td id="protobuf-website"><a href="http://code.google.com/p/protobuf"/>protobuf</a></td>
+    </tr>
+    <tr>
         <td id="pthreads-package">pthreads</td>
-        <td id="pthreads-version">2-8-0</td>
+        <td id="pthreads-version">2-9-1</td>
         <td id="pthreads-website"><a href="http://sourceware.org/pthreads-win32/">Pthreads-w32</a></td>
     </tr>
     <tr>
+        <td id="qdbm-package">qdbm</td>
+        <td id="qdbm-version">1.8.78</td>
+        <td id="qdbm-website"><a href="http://fallabs.com/qdbm/">QDBM</a></td>
+    </tr>
+    <tr>
         <td id="qjson-package">qjson</td>
         <td id="qjson-version">0.7.1</td>
         <td id="qjson-website"><a href="http://qjson.sourceforge.net/">QJson</a></td>
     </tr>
     <tr>
         <td id="qt-package">qt</td>
-        <td id="qt-version">4.8.1</td>
+        <td id="qt-version">4.8.3</td>
         <td id="qt-website"><a href="http://qt.nokia.com/">Qt</a></td>
     </tr>
     <tr>
+        <td id="qwt-package">qwt</td>
+        <td id="qwt-version">6.0.1</td>
+        <td id="qwt-website"><a href="http://qwt.sourceforge.net/">Qwt</a></td>
+    </tr>
+    <tr>
         <td id="qwtplot3d-package">qwtplot3d</td>
         <td id="qwtplot3d-version">0.2.7</td>
         <td id="qwtplot3d-website"><a href="http://qwtplot3d.sourceforge.net/">QwtPlot3D</a></td>
@@ -1744,18 +1849,23 @@
         <td id="smpeg-website"><a href="http://icculus.org/smpeg/">smpeg</a></td>
     </tr>
     <tr>
+        <td id="sox-package">sox</td>
+        <td id="sox-version">14.4.0</td>
+        <td id="sox-website"><a href="http://sox.sourceforge.net/">SoX</a></td>
+    </tr>
+    <tr>
         <td id="speex-package">speex</td>
         <td id="speex-version">1.2rc1</td>
         <td id="speex-website"><a href="http://www.speex.org/">Speex</a></td>
     </tr>
     <tr>
         <td id="sqlite-package">sqlite</td>
-        <td id="sqlite-version">3071100</td>
+        <td id="sqlite-version">3071401</td>
         <td id="sqlite-website"><a href="http://www.sqlite.org/">SQLite</a></td>
     </tr>
     <tr>
         <td id="suitesparse-package">suitesparse</td>
-        <td id="suitesparse-version">3.7.0</td>
+        <td id="suitesparse-version">4.0.2</td>
         <td id="suitesparse-website"><a href="http://www.cise.ufl.edu/research/sparse/SuiteSparse/">SuiteSparse</a></td>
     </tr>
     <tr>
@@ -1765,7 +1875,7 @@
     </tr>
     <tr>
         <td id="taglib-package">taglib</td>
-        <td id="taglib-version">1.7.1</td>
+        <td id="taglib-version">1.7.2</td>
         <td id="taglib-website"><a href="http://developer.kde.org/~wheeler/taglib.html">TagLib</a></td>
     </tr>
     <tr>
@@ -1775,7 +1885,7 @@
     </tr>
     <tr>
         <td id="tiff-package">tiff</td>
-        <td id="tiff-version">4.0.1</td>
+        <td id="tiff-version">4.0.3</td>
         <td id="tiff-website"><a href="http://www.remotesensing.org/libtiff/">LibTIFF</a></td>
     </tr>
     <tr>
@@ -1800,7 +1910,7 @@
     </tr>
     <tr>
         <td id="vorbis-package">vorbis</td>
-        <td id="vorbis-version">1.3.2</td>
+        <td id="vorbis-version">1.3.3</td>
         <td id="vorbis-website"><a href="http://www.vorbis.com/">Vorbis</a></td>
     </tr>
     <tr>
@@ -1820,7 +1930,7 @@
     </tr>
     <tr>
         <td id="wt-package">wt</td>
-        <td id="wt-version">3.2.0</td>
+        <td id="wt-version">3.2.2-p1</td>
         <td id="wt-website"><a href="http://witty.sourceforge.net/">Wt</a></td>
     </tr>
     <tr>
@@ -1834,18 +1944,23 @@
         <td id="x264-website"><a href="http://www.videolan.org/developers/x264.html">x264</a></td>
     </tr>
     <tr>
+        <td id="xapian-core-package">xapian-core</td>
+        <td id="xapian-core-version">1.2.10</td>
+        <td id="xapian-core-website"><a href="http://xapian.org/">Xapian-Core</a></td>
+    </tr>
+    <tr>
         <td id="xerces-package">xerces</td>
         <td id="xerces-version">3.1.1</td>
         <td id="xerces-website"><a href="http://xerces.apache.org/xerces-c/">Xerces-C++</a></td>
     </tr>
     <tr>
         <td id="xine-lib-package">xine-lib</td>
-        <td id="xine-lib-version">1.1.20.1</td>
+        <td id="xine-lib-version">1.1.21</td>
         <td id="xine-lib-website"><a href="http://www.xine-project.org/">xine-lib</a></td>
     </tr>
     <tr>
         <td id="xmlwrapp-package">xmlwrapp</td>
-        <td id="xmlwrapp-version">0.6.2</td>
+        <td id="xmlwrapp-version">0.6.3</td>
         <td id="xmlwrapp-website"><a href="http://sourceforge.net/projects/xmlwrapp/">xmlwrapp</a></td>
     </tr>
     <tr>
@@ -1855,12 +1970,12 @@
     </tr>
     <tr>
         <td id="xz-package">xz</td>
-        <td id="xz-version">5.0.3</td>
+        <td id="xz-version">5.0.4</td>
         <td id="xz-website"><a href="http://tukaani.org/xz/">XZ</a></td>
     </tr>
     <tr>
         <td id="zlib-package">zlib</td>
-        <td id="zlib-version">1.2.6</td>
+        <td id="zlib-version">1.2.7</td>
         <td id="zlib-website"><a href="http://zlib.net/">zlib</a></td>
     </tr>
     <tr>
@@ -1944,6 +2059,23 @@
 
     <li>
         <p>
+            Add your package to the <a href="#packages">list of packages</a>.
+        </p>
+        <p>
+            Each package gets its own table row element with table cells having IDs
+            specifying your .mk file, package version and website:
+        </p>
+        <pre>
+&lt;tr&gt;
+    &lt;td id="gettext-package"&gt;gettext&lt;/td&gt;
+    &lt;td id="gettext-version"&gt;0.18.1.1&lt;/td&gt;
+    &lt;td id="gettext-website"&gt;&lt;a href="http://www.gnu.org/software/gettext/"&gt;gettext&lt;/a&gt;&lt;/td&gt;
+&lt;/tr&gt;
+        </pre>
+    </li>
+
+    <li>
+        <p>
         Write your <code>$(PKG)_BUILD</code>.
         If your library has a <code>./configure</code> script,
         enable/disable all dependency libraries explicitly
@@ -2058,6 +2190,7 @@
             <tr><td><code>make</code></td>      <td>&rarr;</td><td><code>$(MAKE)</code></td></tr>
             <tr><td><code>patch</code></td>     <td>&rarr;</td><td><code>$(PATCH)</code></td></tr>
             <tr><td><code>sed</code></td>       <td>&rarr;</td><td><code>$(SED)</code></td></tr>
+            <tr><td><code>wget</code></td>      <td>&rarr;</td><td><code>$(WGET)</code></td></tr>
         </table>
     </li>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/agg-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,27 @@
+This file is part of MXE.
+See index.html for further information.
+
+From 2617d6a743ad197dc7ae0278a9c7015cc7dff61f Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Tue, 12 Jun 2012 17:05:49 +0200
+Subject: [PATCH] automake 1.12 compatibility fix
+
+---
+ configure.in |    1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/configure.in b/configure.in
+index fceca82..317e17b 100644
+--- a/configure.in
++++ b/configure.in
+@@ -8,7 +8,6 @@ dnl Checks for programs.
+ AC_PROG_CC
+ AC_PROG_CXX
+ AC_ISC_POSIX
+-AM_C_PROTOTYPES
+ if test "x$U" != "x"; then
+   AC_MSG_ERROR(Compiler not ANSI compliant)
+ fi
+-- 
+1.7.10.4
+
--- a/src/agg.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/agg.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freetype sdl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.antigrain.com/download/index.html' | \
+    $(WGET) -q -O- 'http://www.antigrain.com/download/index.html' | \
     $(SED) -n 's,.*<A href="http://www.antigrain.com/agg-\([0-9.]*\).tar.gz".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/apr-util.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,33 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := apr-util
+$(PKG)_IGNORE   := 1.4.1
+$(PKG)_CHECKSUM := f5aaf15542209fee479679299dc4cb1ac0924a59
+$(PKG)_SUBDIR   := apr-util-$($(PKG)_VERSION)
+$(PKG)_FILE     := apr-util-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://mirror.apache-kr.org/apr/$($(PKG)_FILE)
+$(PKG)_URL_2    := http://archive.apache.org/dist/apr/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc apr expat libiconv
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://apr.apache.org/download.cgi' | \
+    grep 'aprutil1.*best' |
+    $(SED) -n 's,.*APR-util \([0-9.]*\).*,\1,p'
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared \
+        --enable-static \
+        --without-pgsql \
+        --without-sqlite2 \
+        --without-sqlite3 \
+        --with-apr='$(PREFIX)/$(TARGET)' \
+        CFLAGS=-D_WIN32_WINNT=0x0500
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= man_MANS=
+    ln -sf '$(PREFIX)/$(TARGET)/bin/apu-1-config' '$(PREFIX)/bin/$(TARGET)-apu-1-config'
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/apr.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,33 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := apr
+$(PKG)_IGNORE   := 1.4.6
+$(PKG)_CHECKSUM := d48324efb0280749a5d7ccbb053d68545c568b4b
+$(PKG)_SUBDIR   := apr-$($(PKG)_VERSION)
+$(PKG)_FILE     := apr-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://mirror.apache-kr.org/apr/$($(PKG)_FILE)
+$(PKG)_URL_2    := http://archive.apache.org/dist/apr/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://apr.apache.org/download.cgi' | \
+    grep 'apr1.*best' |
+    $(SED) -n 's,.*APR \([0-9.]*\).*,\1,p'
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared \
+        --enable-static \
+        ac_cv_sizeof_off_t=4 \
+        ac_cv_sizeof_pid_t=4 \
+        ac_cv_sizeof_size_t=4 \
+        ac_cv_sizeof_ssize_t=4 \
+        CFLAGS=-D_WIN32_WINNT=0x0500
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= man_MANS=
+    ln -sf '$(PREFIX)/$(TARGET)/bin/apr-1-config' '$(PREFIX)/bin/$(TARGET)-apr-1-config'
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/armadillo-1-staticlib.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,24 @@
+This file is part of MXE.
+See index.html for further information.
+
+diff -urN a/CMakeLists.txt b/CMakeLists.txt
+--- a/CMakeLists.txt	2012-09-14 16:43:20.000000000 +0200
++++ b/CMakeLists.txt	2012-09-20 20:39:05.073039124 +0200
+@@ -40,7 +40,7 @@
+ set(ARMA_USE_ATLAS   false)
+ set(ARMA_USE_BOOST   false)
+ set(ARMA_USE_HDF5    false)
+-set(ARMA_USE_WRAPPER true )  # set this to false if you prefer to directly link with LAPACK and/or BLAS (eg. -llapack -lblas) instead of -larmadillo
++set(ARMA_USE_WRAPPER false )  # set this to false if you prefer to directly link with LAPACK and/or BLAS (eg. -llapack -lblas) instead of -larmadillo
+ 
+ 
+ if(WIN32)
+@@ -263,7 +263,7 @@
+ #set(CMAKE_INSTALL_RPATH_USE_LINK_PATH  TRUE)
+ 
+ 
+-add_library( armadillo SHARED src/wrap_libs )
++add_library( armadillo STATIC src/wrap_libs )
+ target_link_libraries( armadillo ${ARMA_LIBS} )
+ 
+ set_target_properties(armadillo PROPERTIES VERSION ${ARMA_MAJOR}.${ARMA_MINOR}.${ARMA_PATCH} SOVERSION 3)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/armadillo-test.cpp	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,24 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <armadillo>
+
+using namespace arma;
+
+int main()
+{
+	mat A = randu<mat>(50,50);
+	mat B = trans(A)*A;  // generate a symmetric matrix
+	
+	vec eigval;
+	mat eigvec;
+	
+	// use standard algorithm by default
+	eig_sym(eigval, eigvec, B);
+	
+	// use divide & conquer algorithm
+	eig_sym(eigval, eigvec, B, "dc");
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/armadillo.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,29 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# armadillo
+PKG             := armadillo
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := a89adc51fa01640bfe463d9120cae57b2c073f8e
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/arma/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc boost blas lapack
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/arma/files/' | \
+    $(SED) -n 's,.*/armadillo-\([0-9.]*\)[.]tar.*".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && cmake . -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install VERBOSE=1
+
+    # note: don't use -Werror with GCC 4.7.0 and .1
+    '$(TARGET)-g++' \
+        -W -Wall \
+        '$(2).cpp' -o '$(PREFIX)/$(TARGET)/bin/test-armadillo.exe' \
+        -larmadillo -llapack -lblas -lgfortran
+        -lboost_serialization-mt -lboost_thread_win32-mt -lboost_system-mt
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/atk-1-DllMain.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,12 @@
+diff -uNr atk-2.2.0-orig/atk/atkobject.c atk-2.2.0/atk/atkobject.c
+--- atk-2.2.0-orig/atk/atkobject.c	2011-09-19 19:06:54.000000000 +0200
++++ atk-2.2.0/atk/atkobject.c	2012-04-14 20:26:12.763814596 +0200
+@@ -366,7 +366,7 @@
+ static HMODULE atk_dll;
+ 
+ BOOL WINAPI
+-DllMain (HINSTANCE hinstDLL,
++atk_DllMain (HINSTANCE hinstDLL,
+ 	 DWORD     fdwReason,
+ 	 LPVOID    lpvReserved)
+ {
--- a/src/atk.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/atk.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := atk
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3f4daf31f99b6e0c12ce9675400f2f02dbf1b820
+$(PKG)_CHECKSUM := ca13d01660bdcd5262ef6cedb8a64542ff8aa804
 $(PKG)_SUBDIR   := atk-$($(PKG)_VERSION)
-$(PKG)_FILE     := atk-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := atk-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/atk/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib gettext
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/atk/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/atk/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=ATK_\\([0-9]*_[0-9]*[02468]_[^<]*\\)'.*,\\1,p" | \
     $(SED) 's,_,.,g' | \
@@ -18,9 +18,9 @@
 endef
 
 define $(PKG)_BUILD
-    $(SED) -i 's,DllMain,static _disabled_DllMain,' '$(1)/atk/atkobject.c'
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-glibtest \
--- a/src/atkmm.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/atkmm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := atkmm
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 9ca44756821f4d431c554e1cf8184989bb25ce12
+$(PKG)_CHECKSUM := 2af04a30dd1f6250d3d35f616bbc34c264b7b327
 $(PKG)_SUBDIR   := atkmm-$($(PKG)_VERSION)
-$(PKG)_FILE     := atkmm-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := atkmm-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/atkmm/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc atk glibmm
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/atkmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/atkmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/aubio.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/aubio.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc fftw libsamplerate libsndfile
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.aubio.org/download' | \
+    $(WGET) -q -O- 'http://www.aubio.org/download' | \
     $(SED) -n 's,.*aubio-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/binutils.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/binutils.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/binutils/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/binutils/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="binutils-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v '^2\.1' | \
     head -1
--- a/src/boost.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/boost.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,23 +3,25 @@
 
 PKG             := boost
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 26a52840e9d12f829e3008589abf0a925ce88524
+$(PKG)_CHECKSUM := 52ef06895b97cc9981b8abf1997c375ca79f30c5
 $(PKG)_SUBDIR   := boost_$(subst .,_,$($(PKG)_VERSION))
 $(PKG)_FILE     := boost_$(subst .,_,$($(PKG)_VERSION)).tar.bz2
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/boost/boost/$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib bzip2 expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.boost.org/users/download/' | \
+    $(WGET) -q -O- 'http://www.boost.org/users/download/' | \
     $(SED) -n 's,.*/boost/\([0-9][^"/]*\)/".*,\1,p' | \
     grep -v beta | \
     head -1
 endef
 
 define $(PKG)_BUILD
+    # context switched library introduced in boost 1.51.0 does not build
+    rm -r '$(1)/libs/context'
+    # old version appears to interfere
+    rm -rf '$(PREFIX)/$(TARGET)/include/boost/'
     echo 'using gcc : : $(TARGET)-g++ : <rc>$(TARGET)-windres <archiver>$(TARGET)-ar ;' > '$(1)/user-config.jam'
-    # make the build script generate .a library files instead of .lib
-    $(SED) -i 's,<target-os>windows : lib ;,<target-os>windows : a ;,' '$(1)/tools/build/v2/tools/types/lib.jam'
     # compile boost jam
     cd '$(1)/tools/build/v2/engine' && ./build.sh
     cd '$(1)' && tools/build/v2/engine/bin.*/bjam \
@@ -45,5 +47,8 @@
         -W -Wall -Werror -ansi -U__STRICT_ANSI__ -pedantic \
         '$(2).cpp' -o '$(PREFIX)/$(TARGET)/bin/test-boost.exe' \
         -DBOOST_THREAD_USE_LIB \
-        -lboost_serialization-mt -lboost_thread_win32-mt
+        -lboost_serialization-mt \
+        -lboost_thread_win32-mt \
+        -lboost_system-mt \
+        -lboost_chrono-mt
 endef
--- a/src/bzip2.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/bzip2.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.bzip.org/downloads.html' | \
+    $(WGET) -q -O- 'http://www.bzip.org/downloads.html' | \
     grep 'bzip2-' | \
     $(SED) -n 's,.*bzip2-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cairo-1-ssize-t-defined.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,18 @@
+This file is part of MXE.
+See index.html for further information.
+
+Insist that ssize_t is defined.
+
+diff --git a/util/cairo-missing/cairo-missing.h b/util/cairo-missing/cairo-missing.h
+index 7e4f0a3..c20b869 100644
+--- a/util/cairo-missing/cairo-missing.h
++++ b/util/cairo-missing/cairo-missing.h
+@@ -37,6 +37,8 @@
+ #include <string.h>
+ #include <sys/types.h>
+ 
++#define _SSIZE_T_DEFINED 1
++
+ #ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cairo-2-static-init.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,27 @@
+This file is part of MXE.
+See index.html for further information.
+
+When DllMain is not being run, we need to initialize the font face mutex before using it.
+
+diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
+index a65d81b..31d854d 100644
+--- a/src/win32/cairo-win32-font.c
++++ b/src/win32/cairo-win32-font.c
+@@ -1912,6 +1912,8 @@ _cairo_win32_font_face_hash_table_destroy (void)
+ {
+     cairo_hash_table_t *hash_table;
+ 
++    CAIRO_MUTEX_INITIALIZE ();
++
+     /* We manually acquire the lock rather than calling
+      * _cairo_win32_font_face_hash_table_lock simply to avoid creating
+      * the table only to destroy it again. */
+@@ -1927,6 +1929,8 @@ _cairo_win32_font_face_hash_table_destroy (void)
+ static cairo_hash_table_t *
+ _cairo_win32_font_face_hash_table_lock (void)
+ {
++    CAIRO_MUTEX_INITIALIZE ();
++
+     CAIRO_MUTEX_LOCK (_cairo_win32_font_face_mutex);
+ 
+     if (unlikely (cairo_win32_font_face_hash_table == NULL))
--- a/src/cairo.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/cairo.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := cairo
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := ccce5ae03f99c505db97c286a0c9a90a926d3c6e
+$(PKG)_CHECKSUM := bc2ee50690575f16dab33af42a2e6cdc6451e3f9
 $(PKG)_SUBDIR   := cairo-$($(PKG)_VERSION)
-$(PKG)_FILE     := cairo-$($(PKG)_VERSION).tar.gz
+$(PKG)_FILE     := cairo-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://cairographics.org/releases/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib libpng fontconfig freetype pixman
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cairographics.org/releases/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://cairographics.org/releases/?C=M;O=D' | \
     $(SED) -n 's,.*"cairo-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -20,6 +20,7 @@
     $(SED) -i 's,^\(Libs:.*\),\1 @CAIRO_NONPKGCONFIG_LIBS@,' '$(1)/src/cairo.pc.in'
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-gtk-doc \
@@ -33,7 +34,6 @@
         --disable-quartz-image \
         --disable-os2 \
         --disable-beos \
-        --disable-glitz \
         --disable-directfb \
         --disable-atomic \
         --enable-win32 \
@@ -44,6 +44,7 @@
         --enable-pdf \
         --enable-svg \
         --disable-pthread \
+        CFLAGS="$(CFLAGS) -DCAIRO_WIN32_STATIC_BUILD" \
         LIBS="-lmsimg32 -lgdi32 `$(TARGET)-pkg-config pixman-1 --libs`"
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
 endef
--- a/src/cairomm.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/cairomm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc cairo libsigc++
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cairographics.org/releases/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://cairographics.org/releases/?C=M;O=D' | \
     $(SED) -n 's,.*"cairomm-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v '^1\.8\.' | \
     head -1
--- a/src/cgal-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/cgal-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,19 +1,17 @@
 This file is part of MXE.
 See index.html for further information.
 
-Contains ad hoc patches for cross building.
-
-From a2df8b5dea68d02643faa69b7119628eb1751d5e Mon Sep 17 00:00:00 2001
-From: MXE
+From 036e8f90ce7f2f1302a2603b89ae7661211c090d Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
 Date: Fri, 21 Oct 2011 23:08:52 +0200
-Subject: [PATCH 1/3] adjustments for MXE
+Subject: [PATCH 1/4] adjustments for mingw-cross-env
 
 
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index a0ef19a..bb8c02f 100644
+index af8be68..61a5ee7 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -359,6 +359,8 @@ message( STATUS "System: ${CMAKE_SYSTEM_NAME}" )
+@@ -400,6 +400,8 @@ message( STATUS "System: ${CMAKE_SYSTEM_NAME}" )
  #
  #--------------------------------------------------------------------------------------------------
  
@@ -249,7 +247,7 @@
        ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
        ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
 diff --git a/include/CGAL/Constrained_Delaunay_triangulation_2.h b/include/CGAL/Constrained_Delaunay_triangulation_2.h
-index bb59f8c..9cebb51 100644
+index c89e7f7..57a5d40 100644
 --- a/include/CGAL/Constrained_Delaunay_triangulation_2.h
 +++ b/include/CGAL/Constrained_Delaunay_triangulation_2.h
 @@ -390,7 +390,7 @@ is_flipable(Face_handle f, int i, bool perturb) const
@@ -271,13 +269,13 @@
   
    if (os == ON_ORIENTED_BOUNDARY && is_infinite(fh)) {
 -- 
-1.7.7
+1.7.10.4
 
 
-From 7393c43ef7534fc8a9289992cdcb9ebefa293680 Mon Sep 17 00:00:00 2001
-From: MXE
+From a455aa3d21f432831ccafcffc90bc7baf766ce6b Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
 Date: Fri, 18 Nov 2011 00:08:25 +0100
-Subject: [PATCH 2/3] prevent Qt's moc from choking on BOOST_JOIN
+Subject: [PATCH 2/4] prevent Qt's moc from choking on BOOST_JOIN
 
 Taken from:
 https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2011-11/msg00087.html
@@ -300,32 +298,52 @@
          else()
          
 -- 
-1.7.7
+1.7.10.4
+
+
+From 7225ba1e69c3e4501706e73e2f1e61e3d1313bfa Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Fri, 6 Jul 2012 09:27:49 +0200
+Subject: [PATCH 3/4] update "detected" Qt version
 
 
-From ac8a99188725f1cb848c6cec3e33c52363754797 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Wed, 28 Mar 2012 00:25:48 +1100
-Subject: [PATCH 3/3] Cmake min version 2.8.6 is only for Windows DLLs
+diff --git a/TryRunResults.cgal.cmake b/TryRunResults.cgal.cmake
+index 299de90..f11ddc6 100644
+--- a/TryRunResults.cgal.cmake
++++ b/TryRunResults.cgal.cmake
+@@ -192,7 +192,7 @@ SET( ZLIB_RUN_RES__TRYRUN_OUTPUT
+      CACHE STRING "version=1.2.5" FORCE)
+ SET( QT4_RUN_RES
+      0
+-     CACHE STRING "version=4.8.0" FORCE)
++     CACHE STRING "version=4.8.2" FORCE)
+ SET( QT4_RUN_RES__TRYRUN_OUTPUT
+      0
+-     CACHE STRING "version=4.8.0" FORCE)
++     CACHE STRING "version=4.8.2" FORCE)
+-- 
+1.7.10.4
 
-http://www.cgal.org/Manual/latest/doc_html/installation_manual/Chapter_installation_manual.html
-
-Section 3:
-"On Windows, CMake version 2.8.6 or higher is required, for a proper support of DLLs generation."
 
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index bb8c02f..1f0a4cb 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -6,7 +6,7 @@
- project(CGAL CXX)
- 
- # Minimal version of CMake:
--if(WIN32)
-+if(WIN32 AND BUILD_SHARED_LIBS)
-   cmake_minimum_required(VERSION 2.8.6)
- else()
-   cmake_minimum_required(VERSION 2.6.2)
+From c6a34b69b8c538456fa23d07f2914aef6395bcf7 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Wed, 18 Jul 2012 00:43:17 +0200
+Subject: [PATCH 4/4] boost 1.50 compatibility
+
+
+diff --git a/cmake/modules/CGAL_SetupBoost.cmake b/cmake/modules/CGAL_SetupBoost.cmake
+index fc3dc11..d72074fd 100644
+--- a/cmake/modules/CGAL_SetupBoost.cmake
++++ b/cmake/modules/CGAL_SetupBoost.cmake
+@@ -3,7 +3,7 @@ if ( NOT CGAL_Boost_Setup )
+   include(CGAL_TweakFindBoost)
+   # In the documentation, we say we require Boost-1.39, but technically we
+   # require 1.33.1. Some packages may require more recent versions, though.
+-  find_package( Boost 1.33.1 REQUIRED thread )
++  find_package( Boost 1.33.1 REQUIRED thread system chrono )
+   
+   message( STATUS "Boost include:     ${Boost_INCLUDE_DIRS}" )
+   message( STATUS "Boost libraries:   ${Boost_LIBRARIES}" )
 -- 
-1.7.7
+1.7.10.4
 
--- a/src/cgal.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/cgal.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := cgal
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := d1f3f328bc5cb026ddb825cb585c7ae27a8856f7
+$(PKG)_CHECKSUM := 20c58ebc021754e8be35237bcda43b0084f60617
 $(PKG)_SUBDIR   := CGAL-$($(PKG)_VERSION)
 $(PKG)_FILE     := CGAL-$($(PKG)_VERSION).tar.xz
-$(PKG)_URL      := https://gforge.inria.fr/frs/download.php/30385/$($(PKG)_FILE)
+$(PKG)_URL      := https://gforge.inria.fr/frs/download.php/31176/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc boost gmp mpfr qt
 
 define $(PKG)_UPDATE
-    wget -q --no-check-certificate -O- 'https://gforge.inria.fr/frs/?group_id=52' | \
+    $(WGET) -q -O- 'https://gforge.inria.fr/frs/?group_id=52' | \
     grep 'CGAL-' | \
     $(SED) -n 's,.*CGAL-\([0-9][^>a-z]*\)\.tar.*,\1,p' | \
     head -1
@@ -19,7 +19,6 @@
 define $(PKG)_BUILD
     cd '$(1)' && cmake \
         -DCGAL_INSTALL_CMAKE_DIR:STRING="lib/CGAL" \
-        -DCMAKE_BUILD_TYPE:STRING="Release" \
         -DCGAL_INSTALL_INC_DIR:STRING="include" \
         -DCGAL_INSTALL_DOC_DIR:STRING="share/doc/CGAL-3.9" \
         -DCGAL_INSTALL_BIN_DIR:STRING="bin" \
@@ -41,6 +40,7 @@
         -DBOOST_USE_STATIC_LIBS=1 \
         -DBUILD_SHARED_LIBS=0 \
         -DCGAL_DIR:STRING="../.." .
+
     $(MAKE) -C '$(1)/examples/AABB_tree' -j $(JOBS)
     $(MAKE) -C '$(1)' -j $(JOBS) install
     $(INSTALL) '$(1)/examples/AABB_tree/AABB_polyhedron_edge_example.exe' '$(PREFIX)/$(TARGET)/bin/test-cgal.exe'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cminpack.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,27 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := cminpack
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 7ac79d8623d0bc6c95c61e0c364ca9e38e8a13ca
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://devernay.free.fr/hacks/cminpack/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://devernay.free.fr/hacks/cminpack/cminpack.html' | \
+    $(SED) -n 's,.*cminpack-\([0-9.]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && cmake \
+        -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)'
+    $(MAKE) -C '$(1)' -j $(JOBS)
+
+    $(INSTALL) -d                         '$(PREFIX)/$(TARGET)/lib'
+    $(INSTALL) -m644 '$(1)/libcminpack.a' '$(PREFIX)/$(TARGET)/lib/'
+    $(INSTALL) -d                         '$(PREFIX)/$(TARGET)/include'
+    $(INSTALL) -m644 '$(1)/cminpack.h'    '$(PREFIX)/$(TARGET)/include/'
+endef
--- a/src/cppunit.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/cppunit.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/cppunit/files/cppunit/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/cppunit/files/cppunit/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/cunit.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/cunit.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/cunit/files/CUnit/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/cunit/files/CUnit/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/curl-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/curl-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,33 +1,31 @@
 This file is part of MXE.
 See index.html for further information.
 
-Commits backported (cherry-picked) from upstream.
-http://github.com/bagder/curl
-Also contains MXE specific fixes.
+From 29c2441e39372b34dfac348954385d2fecb361d1 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 6 Aug 2012 15:04:25 +0200
+Subject: [PATCH] gtls: fix build failure by including nettle-specific headers
 
-From ee69c33117cf616c19e9cd288f08eb4c91bf190d Mon Sep 17 00:00:00 2001
-From: Volker Grabsch <vog@notjusthosting.com>
-Date: Fri, 28 Oct 2011 13:48:04 +0200
-Subject: [PATCH] static linking for MXE
-
----
- include/curl/curlbuild.h.in |    3 +++
- 1 files changed, 3 insertions(+), 0 deletions(-)
+Bug: http://curl.haxx.se/bug/view.cgi?id=3554668
+Reported by: Anthony G. Basile
+(cherry picked from commit 986c7949c0638bebb99bd08d63216433254c2185)
 
-diff --git a/include/curl/curlbuild.h.in b/include/curl/curlbuild.h.in
-index fe348f4..c428273 100644
---- a/include/curl/curlbuild.h.in
-+++ b/include/curl/curlbuild.h.in
-@@ -111,6 +111,9 @@
- /*  EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY  */
- /* ================================================================ */
+diff --git a/lib/gtls.c b/lib/gtls.c
+index d981ef1..c750a6f 100644
+--- a/lib/gtls.c
++++ b/lib/gtls.c
+@@ -34,7 +34,10 @@
  
-+/* Configure process defines this to 1 when static linking is requested. */
-+#undef CURL_STATICLIB
-+
- /* Configure process defines this to 1 when it finds out that system  */
- /* header file ws2tcpip.h must be included by the external interface. */
- #undef CURL_PULL_WS2TCPIP_H
+ #include <gnutls/gnutls.h>
+ #include <gnutls/x509.h>
+-#ifndef USE_GNUTLS_NETTLE
++#ifdef USE_GNUTLS_NETTLE
++#include <gnutls/crypto.h>
++#include <nettle/md5.h>
++#else
+ #include <gcrypt.h>
+ #endif
+ 
 -- 
-1.7.8.3
+1.7.10.4
 
--- a/src/curl.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/curl.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,20 +3,19 @@
 
 PKG             := curl
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := f6016a24051d98806ca3ddf754592701cb66e00c
+$(PKG)_CHECKSUM := 51f563587720b71047b6e307412d49ce24ad7bfb
 $(PKG)_SUBDIR   := curl-$($(PKG)_VERSION)
 $(PKG)_FILE     := curl-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://curl.haxx.se/download/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gnutls libidn libssh2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://curl.haxx.se/download/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://curl.haxx.se/download/?C=M;O=D' | \
     $(SED) -n 's,.*curl-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && ./buildconf
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
         --build="`config.guess`" \
--- a/src/dbus-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/dbus-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -3,32 +3,10 @@
 
 Contains ad hoc patches for cross building.
 
-From 9c99802fc9d0e3b2c90b00ba877ae8be9bab615f Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Tue, 4 Jan 2011 00:47:49 +0100
-Subject: [PATCH 1/2] always static in MXE
-
-
-diff --git a/dbus/dbus-macros.h b/dbus/dbus-macros.h
-index dcd3eeb..8324278 100644
---- a/dbus/dbus-macros.h
-+++ b/dbus/dbus-macros.h
-@@ -172,6 +172,7 @@
-  */
- 
- #if defined(_WIN32)
-+#  define DBUS_STATIC_BUILD
- #  if defined(DBUS_STATIC_BUILD)
- #  define DBUS_EXPORT
- #  elif defined(dbus_1_EXPORTS)
--- 
-1.7.6.3
-
-
 From d7bc1aff67132c09d154999c282e1b391bbe7a39 Mon Sep 17 00:00:00 2001
 From: MXE
 Date: Fri, 23 Sep 2011 16:24:46 +0200
-Subject: [PATCH 2/2] add missing MemoryBarrier (MXE specific)
+Subject: [PATCH 1/1] add missing MemoryBarrier (MXE specific)
 
 Windows API has this, but it's not in MinGW.
 See http://lists-archives.org/mingw-users/15935-missing-definition-of-memorybarrier.html
--- a/src/dbus.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/dbus.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := dbus
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3140ea452337d664dbe6d30f0d990c756d101694
+$(PKG)_CHECKSUM := d9634807d1de9b64727ae2178e3af2227fca0fca
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://$(PKG).freedesktop.org/releases/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/dbus/dbus/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/dbus/dbus/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     grep -v '^1\.[01234]\.' | \
     head -1
@@ -26,6 +26,7 @@
         --disable-verbose-mode \
         --disable-asserts \
         --disable-shared \
+        --disable-maintainer-mode \
         --enable-static \
         --disable-silent-rules
     $(MAKE) -C '$(1)' -j '$(JOBS)' install
--- a/src/dcmtk.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/dcmtk.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc openssl tiff libpng libxml2 zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://dicom.offis.de/dcmtk.php.en' | \
+    $(WGET) -q -O- 'http://dicom.offis.de/dcmtk.php.en' | \
     $(SED) -n 's,.*/dcmtk-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/devil.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/devil.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freeglut zlib openexr jpeg jasper lcms libmng libpng tiff sdl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://openil.svn.sourceforge.net/viewvc/openil/tags/?sortby=date' | \
+    $(WGET) -q -O- 'http://openil.svn.sourceforge.net/viewvc/openil/tags/?sortby=date' | \
     grep '<a name="' | \
     $(SED) -n 's,.*<a name="release-\([0-9][^"]*\)".*,\1,p' | \
     head -1
--- a/src/eigen.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/eigen.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://eigen.tuxfamily.org/index.php?title=Main_Page#Download' | \
+    $(WGET) -q -O- 'http://eigen.tuxfamily.org/index.php?title=Main_Page#Download' | \
     grep 'eigen/get/' | \
     $(SED) -n 's,.*eigen/get/\(2[^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/exiv2.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/exiv2.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv zlib expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.exiv2.org/download.html' | \
+    $(WGET) -q -O- 'http://www.exiv2.org/download.html' | \
     grep 'href="exiv2-' | \
     $(SED) -n 's,.*exiv2-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/expat.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/expat.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/expat/files/expat/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/expat/files/expat/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/faad2.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/faad2.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/faac/files/faad2-src/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/faac/files/faad2-src/' | \
     $(SED) -n 's,.*faad2-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/ffmpeg-1-pkgconfig.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch adds a libswresample dependency to libavfilter.pc, and a libavfilter
-dependency to libavdevice.pc. Both issues have patches upstream, so this patch
-can be dropped for the next FFmpeg version.
-
---- ffmpeg-0.10/configure.orig	2012-03-09 21:18:38.403806202 +0100
-+++ ffmpeg-0.10/configure	2012-03-09 21:19:37.175808737 +0100
-@@ -3749,8 +3749,8 @@
- pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBM"
- pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
- pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
--pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
--pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
-+pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION, libavfilter = $LIBAVFILTER_VERSION"
-+pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libswresample = $LIBSWRESAMPLE_VERSION"
- pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
- pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"
- pkgconfig_generate libswresample "FFmpeg audio rescaling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"
--- a/src/ffmpeg.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/ffmpeg.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := ffmpeg
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 743f44a71f93b14c9b26ca2424b0da8457cef4be
+$(PKG)_CHECKSUM := bf1f917c4fa26cf225616f2063e60c33cac546be
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://www.ffmpeg.org/releases/$($(PKG)_FILE)
@@ -11,12 +11,13 @@
 $(PKG)_DEPS     := gcc bzip2 lame libvpx opencore-amr sdl speex theora vorbis x264 xvidcore zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.ffmpeg.org/download.html' | \
+    $(WGET) -q -O- 'http://www.ffmpeg.org/download.html' | \
     $(SED) -n 's,.*ffmpeg-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
+    '$(SED)' -i "s^[-]lvpx^`'$(TARGET)'-pkg-config --libs-only-l vpx`^g;" $(1)/configure
     cd '$(1)' && ./configure \
         --cross-prefix='$(TARGET)'- \
         --enable-cross-compile \
--- a/src/fftw.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/fftw.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := fftw
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3fecc492f576503a6a509d2073bd82b3fe0aef13
+$(PKG)_CHECKSUM := 11a8c31186ff5a7d686a79a3f21b2530888e0dc2
 $(PKG)_SUBDIR   := fftw-$($(PKG)_VERSION)
 $(PKG)_FILE     := fftw-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.fftw.org/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.fftw.org/download.html' | \
+    $(WGET) -q -O- 'http://www.fftw.org/download.html' | \
     $(SED) -n 's,.*fftw-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v alpha | \
     grep -v beta | \
@@ -20,6 +20,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --enable-threads \
@@ -29,6 +30,7 @@
 
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --enable-threads \
@@ -38,6 +40,7 @@
 
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --enable-threads \
--- a/src/file.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/file.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libgnurx
 
 define $(PKG)_UPDATE
-    wget -q -O- 'ftp://ftp.astron.com/pub/file/' | \
+    $(WGET) -q -O- 'ftp://ftp.astron.com/pub/file/' | \
     grep 'file-' | \
     $(SED) -n 's,.*file-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
--- a/src/flac.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/flac.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv ogg
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://flac.cvs.sourceforge.net/viewvc/flac/flac/' | \
+    $(WGET) -q -O- 'http://flac.cvs.sourceforge.net/viewvc/flac/flac/' | \
     grep '<option>FLAC_RELEASE_' | \
     $(SED) -n 's,.*FLAC_RELEASE_\([0-9][0-9_]*\)__.*,\1,p' | \
     $(SED) 's,_,.,g' | \
--- a/src/fltk.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/fltk.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib jpeg libpng pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.fltk.org/' | \
+    $(WGET) -q -O- 'http://www.fltk.org/' | \
     $(SED) -n 's,.*>v\([0-9][^<]*\)<.*,\1,p' | \
     grep -v '^1\.1\.' | \
     head -1
--- a/src/fontconfig.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/fontconfig.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,30 +3,25 @@
 
 PKG             := fontconfig
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 1ab2f437c2261028ae7969892277af2d8d8db489
+$(PKG)_CHECKSUM := c51c9865047a9546f41cedefbf955cc9bd846517
 $(PKG)_SUBDIR   := fontconfig-$($(PKG)_VERSION)
-$(PKG)_FILE     := fontconfig-$($(PKG)_VERSION).tar.gz
+$(PKG)_FILE     := fontconfig-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://fontconfig.org/release/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc freetype expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://fontconfig.org/release/' | \
+    $(WGET) -q -O- 'http://fontconfig.org/release/' | \
     $(SED) -n 's,.*fontconfig-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
 endef
 
 define $(PKG)_BUILD
-    # ensure there is no (buggy) attempt to install the *.dll.a file
-    # (remove this line of you want to link dynamically)
-    $(SED) -i 's,^install-data-local:.*,install-data-local:,' '$(1)/src/Makefile.in'
-    $(SED) -i 's,^\(Libs:.*\),\1 @EXPAT_LIBS@ @FREETYPE_LIBS@,' '$(1)/fontconfig.pc.in'
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
         --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-arch='$(TARGET)' \
-        --with-freetype-config='$(PREFIX)/$(TARGET)/bin/freetype-config' \
         --with-expat='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
     $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
--- a/src/freeglut.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/freeglut.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/freeglut/files/freeglut/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/freeglut/files/freeglut/' | \
     $(SED) -n 's,.*freeglut-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/freeimage.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/freeimage.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/freeimage/files/Source Distribution/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/freeimage/files/Source Distribution/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/freetds.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/freetds.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -6,7 +6,7 @@
 $(PKG)_CHECKSUM := 3ab06c8e208e82197dc25d09ae353d9f3be7db52
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://ibiblio.org/pub/Linux/ALPHA/$(PKG)/stable/$($(PKG)_FILE)
+$(PKG)_URL      := ftp://ftp.freetds.org/pub/$(PKG)/stable/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libiconv gnutls
 
 define $(PKG)_UPDATE
@@ -14,7 +14,7 @@
     echo $(freetds_VERSION)
 endef
 define $(PKG)_UPDATE_orig
-    wget -q -O- 'http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/' | \
+    $(WGET) -q -O- 'http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/' | \
     grep '<option>R' | \
     $(SED) -n 's,.*R\([0-9][0-9_]*\)<.*,\1,p' | \
     $(SED) 's,_,.,g' | \
--- a/src/freetype.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/freetype.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := freetype
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 5cb80ab9d369c4e81a2221bcf45adcea2c996b9b
+$(PKG)_CHECKSUM := 73b2c28fcaf1ff5b8beef3af4c5abe4cb1ecb7dc
 $(PKG)_SUBDIR   := freetype-$($(PKG)_VERSION)
 $(PKG)_FILE     := freetype-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/freetype/freetype2/$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/freetype/files/freetype2/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/freetype/files/freetype2/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
@@ -18,6 +18,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && GNUMAKE=$(MAKE) ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install
--- a/src/fribidi-1-fix-gassert.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-diff -ru fribidi-0.19.2.orig/lib/fribidi-common.h fribidi-0.19.2/lib/fribidi-common.h
---- fribidi-0.19.2.orig/lib/fribidi-common.h	2007-04-05 18:13:24.000000000 +0200
-+++ fribidi-0.19.2/lib/fribidi-common.h	2010-02-24 17:20:47.000000000 +0100
-@@ -63,6 +63,7 @@
- #if FRIBIDI_USE_GLIB+0
- # ifndef __FRIBIDI_DOC
- #  include <glib/gmacros.h>
-+#  include <glib/gtestutils.h>
- # endif	/* !__FRIBIDI_DOC */
- # define FRIBIDI_BEGIN_DECLS		G_BEGIN_DECLS
- # define FRIBIDI_END_DECLS		G_END_DECLS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fribidi-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,38 @@
+This file is part of MXE.
+See index.html for further information.
+
+From c4dc7b368af33821eca1be8a4ec88929b44f3d06 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Tue, 17 Jul 2012 10:07:07 +0200
+Subject: [PATCH] only include glib.h
+
+
+diff --git a/charset/fribidi-char-sets.c b/charset/fribidi-char-sets.c
+index 5d45e74..e596dee 100644
+--- a/charset/fribidi-char-sets.c
++++ b/charset/fribidi-char-sets.c
+@@ -114,7 +114,7 @@ static FriBidiCharSetHandler char_sets[FRIBIDI_CHAR_SETS_NUM + 1] = {
+ };
+ 
+ #if FRIBIDI_USE_GLIB+0
+-# include <glib/gstrfuncs.h>
++# include <glib.h>
+ # define fribidi_strcasecmp g_ascii_strcasecmp
+ #else /* !FRIBIDI_USE_GLIB */
+ static char
+diff --git a/lib/mem.h b/lib/mem.h
+index c875e0b..031fcc3 100644
+--- a/lib/mem.h
++++ b/lib/mem.h
+@@ -42,7 +42,7 @@
+ #if FRIBIDI_USE_GLIB+0
+ 
+ #ifndef __FRIBIDI_DOC
+-# include <glib/gmem.h>
++# include <glib.h>
+ #endif /* !__FRIBIDI_DOC */
+ 
+ #define FriBidiMemChunk GMemChunk
+-- 
+1.7.10.4
+
--- a/src/fribidi.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/fribidi.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := fribidi
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3889469d96dbca3d8522231672e14cca77de4d5e
+$(PKG)_CHECKSUM := 23d1adf1e929a3fb159345d509918ad109e925ad
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://fribidi.org/download/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://fribidi.org/download/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://fribidi.org/download/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="fribidi-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -19,6 +19,7 @@
     $(SED) -i 's,__declspec(dllimport),,' '$(1)/lib/fribidi-common.h'
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-debug \
--- a/src/ftgl.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/ftgl.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freetype
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/ftgl/files/FTGL Source/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/ftgl/files/FTGL Source/' | \
     $(SED) -n 's,.*<tr title="\([0-9][^"]*\)".*,\1,p' | \
     head -1
 endef
--- a/src/gc.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gc.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gc
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := e84cba5d18f4ea5ed4e5fd3f1dc6a46bc190ff6f
-$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_CHECKSUM := b43573800e27361da78f05a2e98394521cfa04fc
+$(PKG)_SUBDIR   := $(PKG)-7.2
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.hpl.hp.com/personal/Hans_Boehm/$(PKG)/$(PKG)_source/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/?C=M;O=D' | \
     grep '<a href="gc-' | \
     $(SED) -n 's,.*<a href="gc-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v 'alpha' | \
@@ -20,6 +20,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
         --enable-threads=win32 \
--- a/src/gcc-mpc.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gcc-mpc.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := gcc-mpc
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 229722d553030734d49731844abfef7617b64f1a
+$(PKG)_CHECKSUM := 8c7e19ad0dd9b3b5cc652273403423d6cf0c5edf
 $(PKG)_SUBDIR   := mpc-$($(PKG)_VERSION)
 $(PKG)_FILE     := mpc-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.multiprecision.org/mpc/download/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    wget -q --no-check-certificate -O- 'https://gforge.inria.fr/scm/viewvc.php/tags/?root=mpc&sortby=date' | \
+    $(WGET) -q -O- 'https://gforge.inria.fr/scm/viewvc.php/tags/?root=mpc&sortby=date' | \
     $(SED) -n 's,.*<a name="\([0-9][^"]*\)".*,\1,p' | \
     head -1
 endef
--- a/src/gcc.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gcc.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,15 +3,15 @@
 
 PKG             := gcc
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 03b8241477a9f8a34f6efe7273d92b9b6dd9fe82
+$(PKG)_CHECKSUM := a464ba0f26eef24c29bcd1e7489421117fb9ee35
 $(PKG)_SUBDIR   := gcc-$($(PKG)_VERSION)
 $(PKG)_FILE     := gcc-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := ftp://ftp.gnu.org/pub/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_URL_2    := ftp://ftp.cs.tu-berlin.de/pub/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_URL_2    := ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := mingwrt w32api binutils gcc-gmp gcc-mpc gcc-mpfr
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/gcc/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/gcc/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="gcc-\([0-9][^"]*\)/".*,\1,p' | \
     grep -v '^4\.[543]\.' | \
     head -1
@@ -47,7 +47,8 @@
         --disable-libgomp \
         --disable-libmudflap \
         --with-mpfr-include='$(1)/mpfr/src' \
-        --with-mpfr-lib='$(1).build/mpfr/src/.libs'
+        --with-mpfr-lib='$(1).build/mpfr/src/.libs' \
+        $(shell [ `uname -s` == Darwin ] && echo "LDFLAGS='-Wl,-no_pie'")
     $(MAKE) -C '$(1).build' -j '$(JOBS)'
     $(MAKE) -C '$(1).build' -j 1 install
 
@@ -59,9 +60,10 @@
 
     # create the CMake toolchain file
     [ -d '$(dir $(CMAKE_TOOLCHAIN_FILE))' ] || mkdir -p '$(dir $(CMAKE_TOOLCHAIN_FILE))'
-    (echo 'set(BUILD_SHARED_LIBS OFF)'; \
-     echo 'set(CMAKE_SYSTEM_NAME Windows)'; \
+    (echo 'set(CMAKE_SYSTEM_NAME Windows)'; \
      echo 'set(MSYS 1)'; \
+     echo 'set(BUILD_SHARED_LIBS OFF)'; \
+     echo 'set(CMAKE_BUILD_TYPE Release)'; \
      echo 'set(CMAKE_FIND_ROOT_PATH $(PREFIX)/$(TARGET))'; \
      echo 'set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)'; \
      echo 'set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)'; \
--- a/src/gd.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gd.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -15,7 +15,7 @@
     echo $(gd_VERSION)
 endef
 define $(PKG)_UPDATE_orig
-    wget -q -O- 'http://www.libgd.org/releases/' | \
+    $(WGET) -q -O- 'http://www.libgd.org/releases/' | \
     $(SED) -n 's,.*gd-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gdal-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,231 @@
+This file is part of MXE.
+See index.html for further information.
+
+From a0c0640eb7e98db4a9cbe5104abef8425d975712 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Wed, 4 Jul 2012 10:05:33 +0200
+Subject: [PATCH 1/2] giflib compatibility
+
+Taken from http://trac.osgeo.org/gdal/changeset/24491?format=diff&new=24491
+---
+ frmts/gif/gifdataset.cpp |   30 ++++++++++++++++++++++++------
+ 1 file changed, 24 insertions(+), 6 deletions(-)
+
+diff --git a/frmts/gif/gifdataset.cpp b/frmts/gif/gifdataset.cpp
+index c89f34c..1947edd 100644
+--- a/frmts/gif/gifdataset.cpp
++++ b/frmts/gif/gifdataset.cpp
+@@ -470,6 +470,28 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
+ }
+ 
+ /************************************************************************/
++/*                        GDALPrintGifError()                           */
++/************************************************************************/
++
++static void GDALPrintGifError(const char* pszMsg)
++{
++/* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
++/* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
++#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
++        ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
++    /* Static string actually, hence the const char* cast */
++    const char* pszGIFLIBError = (const char*) GifErrorString();
++    if (pszGIFLIBError == NULL)
++        pszGIFLIBError = "Unknown error";
++    CPLError( CE_Failure, CPLE_AppDefined,
++              "%s. GIFLib Error : %s", pszMsg, pszGIFLIBError );
++#else
++    PrintGifError();
++    CPLError( CE_Failure, CPLE_AppDefined, "%s", pszMsg );
++#endif
++}
++
++/************************************************************************/
+ /*                             CreateCopy()                             */
+ /************************************************************************/
+ 
+@@ -596,9 +618,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+                           psGifCT->ColorCount, 255, psGifCT) == GIF_ERROR)
+     {
+         FreeMapObject(psGifCT);
+-        PrintGifError();
+-        CPLError( CE_Failure, CPLE_AppDefined, 
+-                  "Error writing gif file." );
++        GDALPrintGifError("Error writing gif file.");
+         EGifCloseFile(hGifFile);
+         VSIFCloseL( fp );
+         return NULL;
+@@ -622,9 +642,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+ 
+     if (EGifPutImageDesc(hGifFile, 0, 0, nXSize, nYSize, bInterlace, NULL) == GIF_ERROR )
+     {
+-        PrintGifError();
+-        CPLError( CE_Failure, CPLE_AppDefined, 
+-                  "Error writing gif file." );
++        GDALPrintGifError("Error writing gif file.");
+         EGifCloseFile(hGifFile);
+         VSIFCloseL( fp );
+         return NULL;
+-- 
+1.7.10.4
+
+
+From 7411f59dd769a72a79838e932d1a0988b04dc4d5 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Wed, 4 Jul 2012 10:42:33 +0200
+Subject: [PATCH 2/2] giflib 5 compatibility
+
+taken from
+http://trac.osgeo.org/gdal/changeset/24627
+---
+ frmts/gif/biggifdataset.cpp |    5 +++++
+ frmts/gif/gifdataset.cpp    |   43 ++++++++++++++++++++++++++++++++++++-------
+ 2 files changed, 41 insertions(+), 7 deletions(-)
+
+diff --git a/frmts/gif/biggifdataset.cpp b/frmts/gif/biggifdataset.cpp
+index e3029e5..6bed0dc 100644
+--- a/frmts/gif/biggifdataset.cpp
++++ b/frmts/gif/biggifdataset.cpp
+@@ -371,7 +371,12 @@ CPLErr BIGGIFDataset::ReOpen()
+     VSIFSeekL( fp, 0, SEEK_SET );
+ 
+     nLastLineRead = -1;
++#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
++    int nError;
++    hGifFile = DGifOpen( fp, VSIGIFReadFunc, &nError );
++#else
+     hGifFile = DGifOpen( fp, VSIGIFReadFunc );
++#endif
+     if( hGifFile == NULL )
+     {
+         CPLError( CE_Failure, CPLE_OpenFailed, 
+diff --git a/frmts/gif/gifdataset.cpp b/frmts/gif/gifdataset.cpp
+index 1947edd..0b99158 100644
+--- a/frmts/gif/gifdataset.cpp
++++ b/frmts/gif/gifdataset.cpp
+@@ -36,8 +36,17 @@ CPL_CVSID("$Id: gifdataset.cpp 23621 2011-12-20 23:26:56Z rouault $");
+ CPL_C_START
+ void	GDALRegister_GIF(void);
+ 
++#if !(defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5)
++
+ // This prototype seems to have been messed up!
+ GifFileType * EGifOpen(void* userData, OutputFunc writeFunc);
++
++// Define alias compatible with giflib >= 5.0.0
++#define GifMakeMapObject MakeMapObject
++#define GifFreeMapObject FreeMapObject
++
++#endif // defined(GIFLIB_MAJOR) && GIFLIB_MAJOR < 5
++
+ CPL_C_END
+ 
+ static const int InterlacedOffset[] = { 0, 4, 2, 1 }; 
+@@ -322,7 +331,12 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
+     if( fp == NULL )
+         return NULL;
+ 
++#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
++    int nError;
++    hGifFile = DGifOpen( fp, VSIGIFReadFunc, &nError );
++#else
+     hGifFile = DGifOpen( fp, VSIGIFReadFunc );
++#endif
+     if( hGifFile == NULL )
+     {
+         VSIFCloseL( fp );
+@@ -380,7 +394,12 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
+     DGifCloseFile( hGifFile );
+ 
+     VSIFSeekL( fp, 0, SEEK_SET);
++
++#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
++    hGifFile = DGifOpen( fp, VSIGIFReadFunc, &nError );
++#else
+     hGifFile = DGifOpen( fp, VSIGIFReadFunc );
++#endif
+     if( hGifFile == NULL )
+     {
+         VSIFCloseL( fp );
+@@ -473,14 +492,19 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
+ /*                        GDALPrintGifError()                           */
+ /************************************************************************/
+ 
+-static void GDALPrintGifError(const char* pszMsg)
++static void GDALPrintGifError(GifFileType *hGifFile, const char* pszMsg)
+ {
+ /* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
+ /* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
+ #if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
+         ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
+     /* Static string actually, hence the const char* cast */
++
++#if GIFLIB_MAJOR >= 5
++    const char* pszGIFLIBError = (const char*) GifErrorString(hGifFile->Error);
++#else
+     const char* pszGIFLIBError = (const char*) GifErrorString();
++#endif
+     if (pszGIFLIBError == NULL)
+         pszGIFLIBError = "Unknown error";
+     CPLError( CE_Failure, CPLE_AppDefined,
+@@ -557,7 +581,12 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+         return NULL;
+     }
+ 
++#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
++    int nError;
++    hGifFile = EGifOpen( fp, VSIGIFWriteFunc, &nError );
++#else
+     hGifFile = EGifOpen( fp, VSIGIFWriteFunc );
++#endif
+     if( hGifFile == NULL )
+     {
+         VSIFCloseL( fp );
+@@ -577,7 +606,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+ 
+     if( poBand->GetColorTable() == NULL )
+     {
+-        psGifCT = MakeMapObject( 256, NULL );
++        psGifCT = GifMakeMapObject( 256, NULL );
+         for( iColor = 0; iColor < 256; iColor++ )
+         {
+             psGifCT->Colors[iColor].Red = (GifByteType) iColor;
+@@ -593,7 +622,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+         while( nFullCount < poCT->GetColorEntryCount() )
+             nFullCount = nFullCount * 2;
+ 
+-        psGifCT = MakeMapObject( nFullCount, NULL );
++        psGifCT = GifMakeMapObject( nFullCount, NULL );
+         for( iColor = 0; iColor < poCT->GetColorEntryCount(); iColor++ )
+         {
+             GDALColorEntry	sEntry;
+@@ -617,14 +646,14 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+     if (EGifPutScreenDesc(hGifFile, nXSize, nYSize, 
+                           psGifCT->ColorCount, 255, psGifCT) == GIF_ERROR)
+     {
+-        FreeMapObject(psGifCT);
+-        GDALPrintGifError("Error writing gif file.");
++        GifFreeMapObject(psGifCT);
++        GDALPrintGifError(hGifFile, "Error writing gif file.");
+         EGifCloseFile(hGifFile);
+         VSIFCloseL( fp );
+         return NULL;
+     }
+     
+-    FreeMapObject(psGifCT);
++    GifFreeMapObject(psGifCT);
+     psGifCT = NULL;
+ 
+     /* Support for transparency */
+@@ -642,7 +671,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+ 
+     if (EGifPutImageDesc(hGifFile, 0, 0, nXSize, nYSize, bInterlace, NULL) == GIF_ERROR )
+     {
+-        GDALPrintGifError("Error writing gif file.");
++        GDALPrintGifError(hGifFile, "Error writing gif file.");
+         EGifCloseFile(hGifFile);
+         VSIFCloseL( fp );
+         return NULL;
+-- 
+1.7.10.4
+
--- a/src/gdal.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gdal.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := gdal
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := e2eaaf0fba39137b40c0d3069ac41dfb6f3c76db
+$(PKG)_CHECKSUM := c1eae556398ff7b9332afe9d3022dcd931130808
 $(PKG)_SUBDIR   := gdal-$($(PKG)_VERSION)
 $(PKG)_FILE     := gdal-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://download.osgeo.org/gdal/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib libpng tiff libgeotiff jpeg jasper giflib expat sqlite curl geos postgresql gta
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://trac.osgeo.org/gdal/wiki/DownloadSource' | \
+    $(WGET) -q -O- 'http://trac.osgeo.org/gdal/wiki/DownloadSource' | \
     $(SED) -n 's,.*gdal-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -20,6 +20,7 @@
     # The option '--without-threads' means native win32 threading without pthread.
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-bsb \
@@ -65,7 +66,6 @@
         --without-ingres \
         --without-dods-root \
         --without-dwgdirect \
-        --without-dwg-plt \
         --without-idb \
         --without-sde \
         --without-epsilon \
@@ -73,7 +73,6 @@
         --without-php \
         --without-ruby \
         --without-python \
-        --without-macosx-framework \
         LIBS="-ljpeg -lsecur32 `'$(TARGET)-pkg-config' --libs openssl libtiff-4`"
     $(MAKE) -C '$(1)'       -j 1 lib-target
     $(MAKE) -C '$(1)'       -j 1 install-lib
--- a/src/gdb-2-fix-makeinfo.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://sourceware.org/bugzilla/show_bug.cgi?id=13638
-
-===================================================================
-RCS file: /cvs/src/src/gdb/configure,v
-retrieving revision 1.335.2.2
-retrieving revision 1.335.2.3
-diff -u -r1.335.2.2 -r1.335.2.3
---- src/gdb/configure	2012/02/21 22:03:47	1.335.2.2
-+++ src/gdb/configure	2012/02/21 22:07:40	1.335.2.3
-@@ -995,6 +995,8 @@
- LIBS
- CPPFLAGS
- CPP
-+MAKEINFO
-+MAKEINFOFLAGS
- YACC
- YFLAGS
- XMKMF'
-@@ -1696,6 +1698,9 @@
-   CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
-               you have headers in a nonstandard directory <include dir>
-   CPP         C preprocessor
-+  MAKEINFO    Parent configure detects if it is of sufficient version.
-+  MAKEINFOFLAGS
-+              Parameters for MAKEINFO.
-   YACC        The `Yet Another C Compiler' implementation to use. Defaults to
-               the first program found out of: `bison -y', `byacc', `yacc'.
-   YFLAGS      The list of arguments that will be passed by default to $YACC.
-@@ -7158,59 +7163,9 @@
- 
- 
- 
--# Do we have a single-tree copy of texinfo?  Even if we do, we can't
--# rely on it - libiberty is built before texinfo.
--# Extract the first word of "makeinfo", so it can be a program name with args.
--set dummy makeinfo; ac_word=$2
--{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
--$as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_prog_MAKEINFO+set}" = set; then :
--  $as_echo_n "(cached) " >&6
--else
--  if test -n "$MAKEINFO"; then
--  ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test.
--else
--as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
--for as_dir in $PATH
--do
--  IFS=$as_save_IFS
--  test -z "$as_dir" && as_dir=.
--    for ac_exec_ext in '' $ac_executable_extensions; do
--  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--    ac_cv_prog_MAKEINFO="makeinfo"
--    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--    break 2
--  fi
--done
--  done
--IFS=$as_save_IFS
--
--fi
--fi
--MAKEINFO=$ac_cv_prog_MAKEINFO
--if test -n "$MAKEINFO"; then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKEINFO" >&5
--$as_echo "$MAKEINFO" >&6; }
--else
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
--$as_echo "no" >&6; }
--fi
--
--
--if test "x$MAKEINFO" = "x"; then
--  as_fn_error "makeinfo is required for compilation" "$LINENO" 5
--else
--  case "$MAKEINFO" in
--    */missing\ makeinfo*)
--      as_fn_error "makeinfo is required for compilation" "$LINENO" 5
--      ;;
--  esac
--fi
--
-+# We never need to detect it in this sub-configure.
-+# But preserve it for config.status --recheck.
- 
--# --split-size=5000000 may be already in $MAKEINFO from parent configure.
--# Re-running configure in gdb/ would lose it so ensure it stays present.
--MAKEINFOFLAGS=${MAKEINFOFLAGS---split-size=5000000}
- 
- 
- MAKEINFO_EXTRA_FLAGS=""
--- a/src/gdb.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gdb.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -2,7 +2,7 @@
 # See index.html for further information.
 
 PKG             := gdb
-$(PKG)_CHECKSUM := 43a3ee582eae4d69c2babea4f8700b7bec8e37fa
+$(PKG)_CHECKSUM := 79b61152813e5730fa670c89e5fc3c04b670b02c
 $(PKG)_SUBDIR   := gdb-$($(PKG)_VERSION)
 $(PKG)_FILE     := gdb-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := ftp://ftp.gnu.org/pub/gnu/$(PKG)/$($(PKG)_FILE)
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc expat libiconv zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/gdb/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/gdb/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="gdb-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v '^7\.3a' | \
     sort -r | \
@@ -20,6 +20,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         CONFIG_SHELL=$(SHELL)
--- a/src/gdk-pixbuf-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gdk-pixbuf-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -27,7 +27,7 @@
  
  BOOL WINAPI
 -DllMain (HINSTANCE hinstDLL,
-+static _disabled_DllMain (HINSTANCE hinstDLL,
++gdkpixbuf_DllMain (HINSTANCE hinstDLL,
           DWORD     fdwReason,
           LPVOID    lpvReserved)
  {
@@ -35,99 +35,3 @@
 1.7.8
 
 
-From 076713fb334bd200d41b056001f7e44fcae695fb Mon Sep 17 00:00:00 2001
-From: Maarten Bosmans <mkbosmans@gmail.com>
-Date: Mon, 24 Jan 2011 10:39:22 +0000
-Subject: [PATCH 2/3] Use png_jmpbuf macro
-
-This makes the png loader compatible with libpng 1.5
----
- gdk-pixbuf/io-png.c |   12 ++++++------
- 1 files changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
-index 79c81fd..76f3304 100644
---- a/gdk-pixbuf/io-png.c
-+++ b/gdk-pixbuf/io-png.c
-@@ -183,7 +183,7 @@ png_simple_error_callback(png_structp png_save_ptr,
-                              error_msg);
-         }
- 
--        longjmp (png_save_ptr->jmpbuf, 1);
-+        longjmp (png_jmpbuf(png_save_ptr), 1);
- }
- 
- static void
-@@ -287,7 +287,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
- 		return NULL;
- 	}
- 
--	if (setjmp (png_ptr->jmpbuf)) {
-+	if (setjmp (png_jmpbuf(png_ptr))) {
- 	    	g_free (rows);
- 
- 		if (pixbuf)
-@@ -459,7 +459,7 @@ gdk_pixbuf__png_image_begin_load (GdkPixbufModuleSizeFunc size_func,
-                 return NULL;
-         }
-         
--	if (setjmp (lc->png_read_ptr->jmpbuf)) {
-+	if (setjmp (png_jmpbuf(lc->png_read_ptr))) {
- 		if (lc->png_info_ptr)
- 			png_destroy_read_struct(&lc->png_read_ptr, NULL, NULL);
-                 g_free(lc);
-@@ -531,7 +531,7 @@ gdk_pixbuf__png_image_load_increment(gpointer context,
-         lc->error = error;
-         
-         /* Invokes our callbacks as needed */
--	if (setjmp (lc->png_read_ptr->jmpbuf)) {
-+	if (setjmp (png_jmpbuf(lc->png_read_ptr))) {
-                 lc->error = NULL;
- 		return FALSE;
- 	} else {
-@@ -769,7 +769,7 @@ png_error_callback(png_structp png_read_ptr,
-                              error_msg);
-         }
- 
--        longjmp (png_read_ptr->jmpbuf, 1);
-+        longjmp (png_jmpbuf(png_read_ptr), 1);
- }
- 
- static void
-@@ -978,7 +978,7 @@ static gboolean real_save_png (GdkPixbuf        *pixbuf,
- 	       success = FALSE;
- 	       goto cleanup;
-        }
--       if (setjmp (png_ptr->jmpbuf)) {
-+       if (setjmp (png_jmpbuf(png_ptr))) {
- 	       success = FALSE;
- 	       goto cleanup;
-        }
--- 
-1.7.8
-
-
-From 98b7ca46c998a497a1bc6cd563e0201d0cd65de0 Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Fri, 23 Dec 2011 18:54:01 +0100
-Subject: [PATCH 3/3] add libtiff-4 to Requires.private
-
----
- gdk-pixbuf-2.0.pc.in |    1 +
- 1 files changed, 1 insertions(+), 0 deletions(-)
-
-diff --git a/gdk-pixbuf-2.0.pc.in b/gdk-pixbuf-2.0.pc.in
-index 7e61775..bc33627 100644
---- a/gdk-pixbuf-2.0.pc.in
-+++ b/gdk-pixbuf-2.0.pc.in
-@@ -12,6 +12,7 @@ Name: GdkPixbuf
- Description: Image loading and scaling
- Version: @VERSION@
- Requires: gobject-2.0 gmodule-no-export-2.0 @PNG_DEP_CFLAGS_PACKAGES@
-+Requires.private: libtiff-4
- Libs: -L${libdir} -lgdk_pixbuf-@GDK_PIXBUF_API_VERSION@ @GDK_PIXBUF_EXTRA_LIBS@
- Cflags: -I${includedir}/gdk-pixbuf-@GDK_PIXBUF_API_VERSION@ @GDK_PIXBUF_EXTRA_CFLAGS@
- 
--- 
-1.7.8
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gdk-pixbuf-2-libtiff.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,13 @@
+diff --git a/gdk-pixbuf-2.0.pc.in b/gdk-pixbuf-2.0.pc.in
+index 7addefc..a07a46f 100644
+--- a/gdk-pixbuf-2.0.pc.in
++++ b/gdk-pixbuf-2.0.pc.in
+@@ -12,7 +12,7 @@ Name: GdkPixbuf
+ Description: Image loading and scaling
+ Version: @VERSION@
+ Requires: gobject-2.0
+-Requires.private: gmodule-no-export-2.0 @PNG_DEP_CFLAGS_PACKAGES@
++Requires.private: gmodule-no-export-2.0 @PNG_DEP_CFLAGS_PACKAGES@ libtiff-4
+ Libs: -L${libdir} -lgdk_pixbuf-@GDK_PIXBUF_API_VERSION@
+ Libs.private: @GDK_PIXBUF_EXTRA_LIBS@
+ Cflags: -I${includedir}/gdk-pixbuf-@GDK_PIXBUF_API_VERSION@ @GDK_PIXBUF_EXTRA_CFLAGS@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gdk-pixbuf-3-allow-static.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,31 @@
+diff --git a/configure.ac b/configure.ac
+index d929c84..20f8121 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -126,16 +126,16 @@ case $host in
+     ;;
+ esac
+ 
+-if test "$os_win32" = "yes"; then
+-  if test x$enable_static = xyes -o x$enable_static = x; then
+-    AC_MSG_WARN([Disabling static library build, must build as DLL on Windows.])
+-    enable_static=no
+-  fi
+-  if test x$enable_shared = xno; then
+-    AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows.])
+-  fi
+-  enable_shared=yes
+-fi
++dnl if test "$os_win32" = "yes"; then
++dnl   if test x$enable_static = xyes -o x$enable_static = x; then
++dnl     AC_MSG_WARN([Disabling static library build, must build as DLL on Windows.])
++dnl     enable_static=no
++dnl   fi
++dnl   if test x$enable_shared = xno; then
++dnl     AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows.])
++dnl   fi
++dnl   enable_shared=yes
++dnl fi
+ 
+ dnl Initialize libtool
+ LT_PREREQ([2.2.6])
--- a/src/gdk-pixbuf.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gdk-pixbuf.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gdk-pixbuf
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := b452208963ddd84f7280865695b50255fcafaa2e
+$(PKG)_CHECKSUM := 43e4fe5bd8d19bc7d7b853f71c85c193392cb2f7
 $(PKG)_SUBDIR   := gdk-pixbuf-$($(PKG)_VERSION)
-$(PKG)_FILE     := gdk-pixbuf-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := gdk-pixbuf-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib libpng jpeg tiff jasper libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/gdk-pixbuf/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/gdk-pixbuf/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     grep -v '^2\.9' | \
@@ -18,13 +18,15 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && ./configure \
+    cd '$(1)' && autoreconf && ./configure \
         --host='$(TARGET)' \
         --build="`config.guess`" \
+        --enable-static \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-modules \
         --with-included-loaders \
+        --without-gdiplus \
         LIBS="`'$(TARGET)-pkg-config' --libs libtiff-4`"
     $(MAKE) -C '$(1)' -j '$(JOBS)' install
 endef
--- a/src/geos.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/geos.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := geos
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 942b0bbc61a059bd5269fddd4c0b44a508670cb3
+$(PKG)_CHECKSUM := 791e2b36a9a6114c7f213fae3fc995960c35a428
 $(PKG)_SUBDIR   := geos-$($(PKG)_VERSION)
 $(PKG)_FILE     := geos-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://download.osgeo.org/geos/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://geos.refractions.net/' | \
+    $(WGET) -q -O- 'http://geos.refractions.net/' | \
     $(SED) -n 's,.*geos-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -19,9 +19,9 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
-        --prefix='$(PREFIX)/$(TARGET)' \
-        --disable-swig
+        --prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
 
     '$(TARGET)-gcc' \
--- a/src/gettext.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gettext.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.gnu.org/software/gettext/' | \
+    $(WGET) -q -O- 'http://www.gnu.org/software/gettext/' | \
     grep 'gettext-' | \
     $(SED) -n 's,.*gettext-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/giflib-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,32 @@
+This file is part of MXE.
+See index.html for further information.
+
+From e0bcec52c73afb97b91449f1e91cd4da8bf1582f Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Wed, 4 Jul 2012 08:58:48 +0200
+Subject: [PATCH] fix dir delimiter for mingw
+
+---
+ lib/egif_lib.c |    3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/lib/egif_lib.c b/lib/egif_lib.c
+index 47be4d9..0e50b06 100644
+--- a/lib/egif_lib.c
++++ b/lib/egif_lib.c
+@@ -17,11 +17,10 @@ two modules will be linked.  Preserve this property!
+ 
+ #ifdef _WIN32
+ #include <io.h>
+-#include <sys\stat.h>
+ #else
+ #include <sys/types.h>
+-#include <sys/stat.h>
+ #endif /* _WIN32 */
++#include <sys/stat.h>
+ 
+ #include "gif_lib.h"
+ #include "gif_lib_private.h"
+-- 
+1.7.10.4
+
--- a/src/giflib.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/giflib.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,24 +3,30 @@
 
 PKG             := giflib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 22680f604ec92065f04caf00b1c180ba74fb8562
+$(PKG)_CHECKSUM := 0b032c2104a0956e2f91b6c11ff8c5515421cd8b
 $(PKG)_SUBDIR   := giflib-$($(PKG)_VERSION)
 $(PKG)_FILE     := giflib-$($(PKG)_VERSION).tar.bz2
-$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/giflib/giflib-4.x/giflib-$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/giflib/giflib-5.x/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/giflib/files/giflib 4.x/' | \
-    $(SED) -n 's,.*/giflib-\([0-9][^"]*\)/".*,\1,p' | \
+    $(WGET) -q -O- 'http://giflib.git.sourceforge.net/git/gitweb.cgi?p=giflib/giflib;a=tags' | \
+    grep '<a class="list name"' | \
+    $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
+    grep -v alpha | \
+    grep -v beta | \
+    grep -v rc | \
     head -1
 endef
 
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
-        --prefix='$(PREFIX)/$(TARGET)' \
         --without-x \
         CPPFLAGS='-D_OPEN_BINARY'
+    echo 'all:' > '$(1)/doc/Makefile'
     $(MAKE) -C '$(1)/lib' -j '$(JOBS)' install
 endef
--- a/src/glew.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/glew.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := glew
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 9266f2360c1687a96f2ea06419671d370b2928d1
+$(PKG)_CHECKSUM := 9291f5c5afefd482c7f3e91ffb3cd4716c6c9ffe
 $(PKG)_SUBDIR   := glew-$($(PKG)_VERSION)
 $(PKG)_FILE     := glew-$($(PKG)_VERSION).tgz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/glew/glew/$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/glew/files/glew/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/glew/files/glew/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/glib-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/glib-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -3,40 +3,21 @@
 
 Contains ad hoc patches for cross building.
 
-From 4693f62d3f01f7b7d26607e6eed843202cbf90f7 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Thu, 23 Sep 2010 21:36:04 +0200
-Subject: [PATCH 1/5] no gtk doc check
+From 2a15b5d8c570d34e44d315116219bcd731054a54 Mon Sep 17 00:00:00 2001
+From: "a@mxe.cc" <a@mxe.cc>
+Date: Thu, 23 Sep 2010 21:41:51 +0200
+Subject: [PATCH 1/8] optional gettext
 
+---
+ configure.ac |    4 ++--
+ glib/gi18n.h |    5 +++++
+ 2 files changed, 7 insertions(+), 2 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
-index a821267..2e541d2 100644
+index cadd925..241284d 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -2741,8 +2741,6 @@ dnl **************************
- dnl *** Checks for gtk-doc ***
- dnl **************************
- 
--GTK_DOC_CHECK([1.15])
--
- AC_ARG_ENABLE(man,
-               [AC_HELP_STRING([--enable-man],
-                               [regenerate man pages from Docbook [default=no]])],enable_man=yes,
--- 
-1.7.1
-
-
-From 46d0d473e6fb32c5204d063cad5f5073d2a139a5 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Thu, 23 Sep 2010 21:41:51 +0200
-Subject: [PATCH 2/5] optional gettext
-
-
-diff --git a/configure.ac b/configure.ac
-index 2e541d2..18c2dea 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -464,8 +464,8 @@ AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS'])
+@@ -479,8 +479,8 @@ AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS'])
  GLIB_GNU_GETTEXT
  
  if test "$gt_cv_have_gettext" != "yes" ; then
@@ -65,17 +46,20 @@
  
  #define  _(String) gettext (String)
 -- 
-1.7.1
+1.7.10.4
 
 
-From 3473b5183b2e59d247cd1db053efc6c9ecaf2aab Mon Sep 17 00:00:00 2001
-From: MXE
+From 6e19d772238eb429fe0ea77b65dbc9d8a5d89afa Mon Sep 17 00:00:00 2001
+From: "a@mxe.cc" <a@mxe.cc>
 Date: Thu, 23 Sep 2010 21:42:46 +0200
-Subject: [PATCH 3/5] fix tool paths
+Subject: [PATCH 2/8] fix tool paths
 
+---
+ glib-2.0.pc.in |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/glib-2.0.pc.in b/glib-2.0.pc.in
-index 3d1ac12..58e1ecf 100644
+index 4a8898e..5164bae 100644
 --- a/glib-2.0.pc.in
 +++ b/glib-2.0.pc.in
 @@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@
@@ -92,60 +76,1155 @@
  Name: GLib
  Description: C Utility Library
 -- 
-1.7.1
+1.7.10.4
 
 
-From 0e57514812500d5d4dee03e1be8059a25876dd99 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Thu, 23 Sep 2010 21:45:50 +0200
-Subject: [PATCH 4/5] fix dependency libs
+From 556504bac07f4d80c0d9e50be1090f3ae02a653b Mon Sep 17 00:00:00 2001
+From: Hans Petter Jansson <hpj@cl.no>
+Date: Fri, 15 Jun 2012 15:25:01 +0200
+Subject: [PATCH 3/8] Avoid DllMain symbol conflict when linking statically
+
+---
+ gio/giomodule.c  |    6 +-----
+ glib/glib-init.c |    6 +++---
+ 2 files changed, 4 insertions(+), 8 deletions(-)
+
+diff --git a/gio/giomodule.c b/gio/giomodule.c
+index d8ce138..679279f 100644
+--- a/gio/giomodule.c
++++ b/gio/giomodule.c
+@@ -782,10 +782,8 @@ extern GType _g_network_monitor_netlink_get_type (void);
+ 
+ static HMODULE gio_dll = NULL;
+ 
+-#ifdef DLL_EXPORT
+-
+ BOOL WINAPI
+-DllMain (HINSTANCE hinstDLL,
++gio_DllMain (HINSTANCE hinstDLL,
+ 	 DWORD     fdwReason,
+ 	 LPVOID    lpvReserved)
+ {
+@@ -801,8 +799,6 @@ _g_io_win32_get_module (void)
+   return gio_dll;
+ }
+ 
+-#endif
+-
+ #undef GIO_MODULE_DIR
+ 
+ /* GIO_MODULE_DIR is used only in code called just once,
+diff --git a/glib/glib-init.c b/glib/glib-init.c
+index f4edd5c..02bf678 100644
+--- a/glib/glib-init.c
++++ b/glib/glib-init.c
+@@ -226,9 +226,9 @@ glib_init (void)
+ HMODULE glib_dll;
+ 
+ BOOL WINAPI
+-DllMain (HINSTANCE hinstDLL,
+-         DWORD     fdwReason,
+-         LPVOID    lpvReserved)
++glib_DllMain (HINSTANCE hinstDLL,
++              DWORD     fdwReason,
++              LPVOID    lpvReserved)
+ {
+   switch (fdwReason)
+     {
+-- 
+1.7.10.4
 
 
+From a83efeaa712bdfe43a1fcada6775ce2c89781631 Mon Sep 17 00:00:00 2001
+From: Hans Petter Jansson <hpj@cl.no>
+Date: Fri, 15 Jun 2012 15:27:22 +0200
+Subject: [PATCH 4/8] Allow building without inotify support
+
+---
+ configure.ac |   13 ++++++++++---
+ 1 file changed, 10 insertions(+), 3 deletions(-)
+
 diff --git a/configure.ac b/configure.ac
-index 18c2dea..e472768 100644
+index 241284d..04d8590 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1700,11 +1700,18 @@ dnl *****************************
+ dnl ** Check for inotify (GIO) **
+ dnl *****************************
+ inotify_support=no
+-AC_CHECK_HEADERS([sys/inotify.h],
+-[
++
++AC_ARG_ENABLE(inotify,
++              AC_HELP_STRING([--disable-inotify],
++                             [build without inotify support]))
++
++if test "x$enable_inotify" != "xno"; then
++ AC_CHECK_HEADERS([sys/inotify.h],
++ [
+ 	inotify_support=yes
+ 	AC_CHECK_FUNCS(inotify_init1)
+-])
++ ])
++fi
+ 
+ AM_CONDITIONAL(HAVE_INOTIFY, [test "$inotify_support" = "yes"])
+ 
+-- 
+1.7.10.4
+
+
+From e3d193f7e4f3d1ada0d65ccdccab1f28ef6d23d3 Mon Sep 17 00:00:00 2001
+From: Hans Petter Jansson <hpj@cl.no>
+Date: Fri, 15 Jun 2012 15:28:14 +0200
+Subject: [PATCH 5/8] Make sure STDC_HEADERS is set for AC_CHECK_ALIGNOF.
+ Backported from upstream
+
+---
+ configure.ac |    2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index 04d8590..29b6252 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -2698,7 +2698,7 @@ case $host in
- 	G_LIBS_EXTRA="-luser32 -lkernel32"
-     ;;
-   *-*-mingw*)
--	G_LIBS_EXTRA="-lws2_32 -lole32"
-+	G_LIBS_EXTRA="-lws2_32 -lole32 -lshlwapi"
-     ;;
-   *)
- 	G_LIBS_EXTRA=""
-diff --git a/glib-2.0.pc.in b/glib-2.0.pc.in
-index 58e1ecf..17b2133 100644
---- a/glib-2.0.pc.in
-+++ b/glib-2.0.pc.in
-@@ -11,5 +11,5 @@ Name: GLib
- Description: C Utility Library
+@@ -452,6 +452,8 @@ fi
+ 
+ AC_MSG_RESULT($enable_iconv_cache)
+ 
++# Make sure STDC_HEADERS is set for AC_CHECK_ALIGNOF
++AS_IF([false], [AC_CHECK_HEADER([stdint.h])])
+ 
+ dnl
+ dnl zlib support
+-- 
+1.7.10.4
+
+
+From 08b493b8480f360ab21a0ce5c79b096392a389a8 Mon Sep 17 00:00:00 2001
+From: Hans Petter Jansson <hpj@cl.no>
+Date: Fri, 15 Jun 2012 15:29:06 +0200
+Subject: [PATCH 6/8] Link with dnsapi
+
+---
+ gio-2.0.pc.in |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gio-2.0.pc.in b/gio-2.0.pc.in
+index 9f7123f..b0d5779 100644
+--- a/gio-2.0.pc.in
++++ b/gio-2.0.pc.in
+@@ -13,6 +13,6 @@ Description: glib I/O library
  Version: @VERSION@
- Libs: -L${libdir} -lglib-2.0 @INTLLIBS@
--Libs.private: @ICONV_LIBS@
-+Libs.private: @G_THREAD_LIBS@ @G_LIBS_EXTRA@ @PCRE_LIBS@ @INTLLIBS@ @ICONV_LIBS@
- Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include @GLIB_EXTRA_CFLAGS@
+ Requires: glib-2.0 gobject-2.0
+ Requires.private: gmodule-no-export-2.0
+-Libs: -L${libdir} -lgio-2.0
++Libs: -L${libdir} -lgio-2.0 -ldnsapi
+ Libs.private: @ZLIB_LIBS@ @NETWORK_LIBS@
+ Cflags:
 -- 
-1.7.1
+1.7.10.4
+
+
+From 645849d2055b1c7a46132a8b83739290b316ffba Mon Sep 17 00:00:00 2001
+From: Hans Petter Jansson <hpj@cl.no>
+Date: Fri, 15 Jun 2012 15:29:38 +0200
+Subject: [PATCH 7/8] Ensure globals are initialized even when DllMain is not
+ being run
+
+---
+ glib/gmain.c         |    6 +++
+ glib/gthread-win32.c |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 112 insertions(+)
+
+diff --git a/glib/gmain.c b/glib/gmain.c
+index 760f179..878ac14 100644
+--- a/glib/gmain.c
++++ b/glib/gmain.c
+@@ -1981,12 +1981,15 @@ g_get_real_time (void)
+ #ifdef G_OS_WIN32
+ static ULONGLONG (*g_GetTickCount64) (void) = NULL;
+ static guint32 g_win32_tick_epoch = 0;
++static gboolean g_win32_clock_is_initialized;
+ 
+ G_GNUC_INTERNAL void
+ g_clock_win32_init (void)
+ {
+   HMODULE kernel32;
+ 
++  g_win32_clock_is_initialized = TRUE;
++
+   g_GetTickCount64 = NULL;
+   kernel32 = GetModuleHandle ("KERNEL32.DLL");
+   if (kernel32 != NULL)
+@@ -2105,6 +2108,9 @@ g_get_monotonic_time (void)
+    *    timeBeginPeriod() to increase it as much as they want
+    */
+ 
++  if (!g_win32_clock_is_initialized)
++    g_clock_win32_init ();
++
+   if (g_GetTickCount64 != NULL)
+     {
+       guint32 ticks_as_32bit;
+diff --git a/glib/gthread-win32.c b/glib/gthread-win32.c
+index 5a9ac97..e4d1d48 100644
+--- a/glib/gthread-win32.c
++++ b/glib/gthread-win32.c
+@@ -117,18 +117,28 @@ typedef struct
+   void     (__stdcall * WakeConditionVariable)       (gpointer cond);
+ } GThreadImplVtable;
+ 
++/* Needed for static builds where DllMain initializer doesn't get called */
++static gboolean g_threads_is_initialized;
++G_GNUC_INTERNAL void g_thread_win32_init (void);
++
+ static GThreadImplVtable g_thread_impl_vtable;
+ 
+ /* {{{1 GMutex */
+ void
+ g_mutex_init (GMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.InitializeSRWLock (mutex);
+ }
+ 
+ void
+ g_mutex_clear (GMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   if (g_thread_impl_vtable.DeleteSRWLock != NULL)
+     g_thread_impl_vtable.DeleteSRWLock (mutex);
+ }
+@@ -136,18 +146,27 @@ g_mutex_clear (GMutex *mutex)
+ void
+ g_mutex_lock (GMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.AcquireSRWLockExclusive (mutex);
+ }
+ 
+ gboolean
+ g_mutex_trylock (GMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   return g_thread_impl_vtable.TryAcquireSRWLockExclusive (mutex);
+ }
+ 
+ void
+ g_mutex_unlock (GMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.ReleaseSRWLockExclusive (mutex);
+ }
+ 
+@@ -158,6 +177,9 @@ g_rec_mutex_impl_new (void)
+ {
+   CRITICAL_SECTION *cs;
+ 
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   cs = g_slice_new (CRITICAL_SECTION);
+   InitializeCriticalSection (cs);
+ 
+@@ -168,6 +190,10 @@ static void
+ g_rec_mutex_impl_free (CRITICAL_SECTION *cs)
+ {
+   DeleteCriticalSection (cs);
++
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_slice_free (CRITICAL_SECTION, cs);
+ }
+ 
+@@ -176,6 +202,9 @@ g_rec_mutex_get_impl (GRecMutex *mutex)
+ {
+   CRITICAL_SECTION *impl = mutex->p;
+ 
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   if G_UNLIKELY (mutex->p == NULL)
+     {
+       impl = g_rec_mutex_impl_new ();
+@@ -190,30 +219,45 @@ g_rec_mutex_get_impl (GRecMutex *mutex)
+ void
+ g_rec_mutex_init (GRecMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   mutex->p = g_rec_mutex_impl_new ();
+ }
+ 
+ void
+ g_rec_mutex_clear (GRecMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_rec_mutex_impl_free (mutex->p);
+ }
+ 
+ void
+ g_rec_mutex_lock (GRecMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   EnterCriticalSection (g_rec_mutex_get_impl (mutex));
+ }
+ 
+ void
+ g_rec_mutex_unlock (GRecMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   LeaveCriticalSection (mutex->p);
+ }
+ 
+ gboolean
+ g_rec_mutex_trylock (GRecMutex *mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   return TryEnterCriticalSection (g_rec_mutex_get_impl (mutex));
+ }
+ 
+@@ -222,12 +266,18 @@ g_rec_mutex_trylock (GRecMutex *mutex)
+ void
+ g_rw_lock_init (GRWLock *lock)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.InitializeSRWLock (lock);
+ }
+ 
+ void
+ g_rw_lock_clear (GRWLock *lock)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   if (g_thread_impl_vtable.DeleteSRWLock != NULL)
+     g_thread_impl_vtable.DeleteSRWLock (lock);
+ }
+@@ -235,36 +285,54 @@ g_rw_lock_clear (GRWLock *lock)
+ void
+ g_rw_lock_writer_lock (GRWLock *lock)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.AcquireSRWLockExclusive (lock);
+ }
+ 
+ gboolean
+ g_rw_lock_writer_trylock (GRWLock *lock)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   return g_thread_impl_vtable.TryAcquireSRWLockExclusive (lock);
+ }
+ 
+ void
+ g_rw_lock_writer_unlock (GRWLock *lock)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.ReleaseSRWLockExclusive (lock);
+ }
+ 
+ void
+ g_rw_lock_reader_lock (GRWLock *lock)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.AcquireSRWLockShared (lock);
+ }
+ 
+ gboolean
+ g_rw_lock_reader_trylock (GRWLock *lock)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   return g_thread_impl_vtable.TryAcquireSRWLockShared (lock);
+ }
+ 
+ void
+ g_rw_lock_reader_unlock (GRWLock *lock)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.ReleaseSRWLockShared (lock);
+ }
+ 
+@@ -272,12 +340,18 @@ g_rw_lock_reader_unlock (GRWLock *lock)
+ void
+ g_cond_init (GCond *cond)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.InitializeConditionVariable (cond);
+ }
+ 
+ void
+ g_cond_clear (GCond *cond)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   if (g_thread_impl_vtable.DeleteConditionVariable)
+     g_thread_impl_vtable.DeleteConditionVariable (cond);
+ }
+@@ -285,12 +359,18 @@ g_cond_clear (GCond *cond)
+ void
+ g_cond_signal (GCond *cond)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.WakeConditionVariable (cond);
+ }
+ 
+ void
+ g_cond_broadcast (GCond *cond)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.WakeAllConditionVariable (cond);
+ }
+ 
+@@ -298,6 +378,9 @@ void
+ g_cond_wait (GCond  *cond,
+              GMutex *entered_mutex)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   g_thread_impl_vtable.SleepConditionVariableSRW (cond, entered_mutex, INFINITE, 0);
+ }
+ 
+@@ -308,6 +391,9 @@ g_cond_wait_until (GCond  *cond,
+ {
+   gint64 span;
+ 
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   span = end_time - g_get_monotonic_time ();
+ 
+   if G_UNLIKELY (span < 0)
+@@ -340,6 +426,9 @@ g_private_get_impl (GPrivate *key)
+ 
+   if G_UNLIKELY (impl == 0)
+     {
++      if (!g_threads_is_initialized)
++        g_thread_win32_init ();
++
+       EnterCriticalSection (&g_private_lock);
+       impl = (DWORD) key->p;
+       if (impl == 0)
+@@ -433,6 +522,9 @@ g_system_thread_free (GRealThread *thread)
+ {
+   GThreadWin32 *wt = (GThreadWin32 *) thread;
+ 
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   win32_check_for_error (CloseHandle (wt->handle));
+   g_slice_free (GThreadWin32, wt);
+ }
+@@ -440,6 +532,9 @@ g_system_thread_free (GRealThread *thread)
+ void
+ g_system_thread_exit (void)
+ {
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   _endthreadex (0);
+ }
+ 
+@@ -448,6 +543,9 @@ g_thread_win32_proxy (gpointer data)
+ {
+   GThreadWin32 *self = data;
+ 
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   self->proxy (self);
+ 
+   g_system_thread_exit ();
+@@ -465,6 +563,9 @@ g_system_thread_new (GThreadFunc   func,
+   GThreadWin32 *thread;
+   guint ignore;
+ 
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   thread = g_slice_new0 (GThreadWin32);
+   thread->proxy = func;
+ 
+@@ -494,6 +595,9 @@ g_system_thread_wait (GRealThread *thread)
+ {
+   GThreadWin32 *wt = (GThreadWin32 *) thread;
+ 
++  if (!g_threads_is_initialized)
++    g_thread_win32_init ();
++
+   win32_check_for_error (WAIT_FAILED != WaitForSingleObject (wt->handle, INFINITE));
+ }
+ 
+@@ -985,6 +1089,8 @@ g_thread_lookup_native_funcs (void)
+ G_GNUC_INTERNAL void
+ g_thread_win32_init (void)
+ {
++  g_threads_is_initialized = TRUE;
++
+   if (!g_thread_lookup_native_funcs ())
+     g_thread_xp_init ();
+ 
+-- 
+1.7.10.4
 
 
-From 87931c81f6401fb0c25064ec0ba2edca9ec53924 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Sat, 25 Sep 2010 00:07:33 +0200
-Subject: [PATCH 5/5] add -ldnsapi to gio-2.0.pc
+From e6c9e1075e9c176d0184cff07d6f2eef224ab608 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Mon, 18 Jun 2012 16:02:12 +0200
+Subject: [PATCH 8/8] kill docs and gtk-doc dependence (mxe-specific)
 
+---
+ Makefile.am                                        |    5 +-
+ autogen.sh                                         |    7 -
+ configure.ac                                       |    2 -
+ docs/Makefile.am                                   |   11 --
+ docs/reference/Makefile.am                         |    3 -
+ docs/reference/gio/Makefile.am                     |  181 --------------------
+ .../gio/gdbus-object-manager-example/Makefile.am   |   68 --------
+ docs/reference/glib/Makefile.am                    |  129 --------------
+ docs/reference/gobject/Makefile.am                 |  103 -----------
+ 9 files changed, 2 insertions(+), 507 deletions(-)
+ delete mode 100644 docs/Makefile.am
+ delete mode 100644 docs/reference/Makefile.am
+ delete mode 100644 docs/reference/gio/Makefile.am
+ delete mode 100644 docs/reference/gio/gdbus-object-manager-example/Makefile.am
+ delete mode 100644 docs/reference/glib/Makefile.am
+ delete mode 100644 docs/reference/gobject/Makefile.am
 
-diff --git a/gio-2.0.pc.in b/gio-2.0.pc.in
-index 92cda85..7a4e224 100644
---- a/gio-2.0.pc.in
-+++ b/gio-2.0.pc.in
-@@ -10,6 +10,6 @@ Name: GIO
- Description: glib I/O library
- Version: @VERSION@
- Requires: glib-2.0,gobject-2.0,gmodule-no-export-2.0
--Libs: -L${libdir} -lgio-2.0
-+Libs: -L${libdir} -lgio-2.0 -ldnsapi
- Libs.private: @ZLIB_LIBS@ @LIBASYNCNS_LIBADD@
- Cflags: 
+diff --git a/Makefile.am b/Makefile.am
+index f5c510d..28d77c6 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -6,7 +6,7 @@ include $(top_srcdir)/Makefile.decl
+ 
+ ACLOCAL_AMFLAGS = -I m4macros ${ACLOCAL_FLAGS}
+ 
+-SUBDIRS = . m4macros glib gmodule gthread gobject gio tests po docs
++SUBDIRS = . m4macros glib gmodule gthread gobject gio tests po
+ DIST_SUBDIRS = $(SUBDIRS) build
+ 
+ bin_SCRIPTS = glib-gettextize
+@@ -62,8 +62,7 @@ BUILT_EXTRA_DIST = 		\
+ 	README			\
+ 	INSTALL			\
+ 	ChangeLog		\
+-	config.h.win32		\
+-	gtk-doc.make
++	config.h.win32
+ 
+ CONFIGURE_DEPENDENCIES = acglib.m4
+ 
+diff --git a/autogen.sh b/autogen.sh
+index 01011d9..bc0ab0b 100755
+--- a/autogen.sh
++++ b/autogen.sh
+@@ -7,12 +7,6 @@ test -n "$srcdir" || srcdir=.
+ olddir=`pwd`
+ cd "$srcdir"
+ 
+-GTKDOCIZE=`which gtkdocize`
+-if test -z $GTKDOCIZE; then
+-        echo "*** No GTK-Doc found, please install it ***"
+-        exit 1
+-fi
+-
+ AUTORECONF=`which autoreconf`
+ if test -z $AUTORECONF; then
+         echo "*** No autoreconf found, please install it ***"
+@@ -24,7 +18,6 @@ fi
+ # regenerated from their corresponding *.in files by ./configure anyway.
+ touch README INSTALL
+ 
+-gtkdocize || exit $?
+ autoreconf --force --install --verbose || exit $?
+ 
+ cd "$olddir"
+diff --git a/configure.ac b/configure.ac
+index 29b6252..24a0c3c 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -2598,8 +2598,6 @@ dnl **************************
+ dnl *** Checks for gtk-doc ***
+ dnl **************************
+ 
+-GTK_DOC_CHECK([1.15], [--flavour no-tmpl])
+-
+ AC_ARG_ENABLE(man,
+               [AC_HELP_STRING([--enable-man],
+                               [regenerate man pages from Docbook [default=no]])],enable_man=yes,
+diff --git a/docs/Makefile.am b/docs/Makefile.am
+deleted file mode 100644
+index 2349f44..0000000
+--- a/docs/Makefile.am
++++ /dev/null
+@@ -1,11 +0,0 @@
+-## Process this file with automake to produce Makefile.in
+-include $(top_srcdir)/Makefile.decl
+-
+-SUBDIRS = reference
+-
+-EXTRA_DIST += debugging.txt macros.txt
+-
+-files:
+-	@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
+-	  echo $$p; \
+-	done
+diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
+deleted file mode 100644
+index 63cf90d..0000000
+--- a/docs/reference/Makefile.am
++++ /dev/null
+@@ -1,3 +0,0 @@
+-include $(top_srcdir)/Makefile.decl
+-
+-SUBDIRS = glib gobject gio
+diff --git a/docs/reference/gio/Makefile.am b/docs/reference/gio/Makefile.am
+deleted file mode 100644
+index 7d2d264..0000000
+--- a/docs/reference/gio/Makefile.am
++++ /dev/null
+@@ -1,181 +0,0 @@
+-include $(top_srcdir)/Makefile.decl
+-NULL =
+-
+-SUBDIRS = gdbus-object-manager-example
+-
+-# The name of the module.
+-DOC_MODULE=gio
+-
+-# The top-level SGML file.
+-DOC_MAIN_SGML_FILE=gio-docs.xml
+-
+-# Extra options to supply to gtkdoc-scan
+-SCAN_OPTIONS=--deprecated-guards="G_DISABLE_DEPRECATED" \
+-             --ignore-decorators="G_GNUC_WARN_UNUSED_RESULT"
+-
+-# The directory containing the source code. Relative to $(srcdir)
+-DOC_SOURCE_DIR=$(top_srcdir)/gio
+-
+-BUILT_HFILES=gioenumtypes.h
+-HFILE_GLOB=$(top_srcdir)/gio/*.h
+-CFILE_GLOB=$(top_srcdir)/gio/*.c
+-
+-IGNORE_HFILES = \
+-	fam				\
+-	fen				\
+-	gdbus-2.0			\
+-	gvdb				\
+-	inotify				\
+-	libasyncns			\
+-	tests				\
+-	win32				\
+-	xdgmime				\
+-	gapplicationimpl.h		\
+-	gasynchelper.h			\
+-	gcontenttypeprivate.h		\
+-	gdbusauth.h			\
+-	gdbusauthmechanismanon.h	\
+-	gdbusauthmechanismexternal.h	\
+-	gdbusauthmechanism.h		\
+-	gdbusauthmechanismsha1.h	\
+-	gdbusprivate.h			\
+-	gdelayedsettingsbackend.h	\
+-	gdummyfile.h			\
+-	gdummyproxyresolver.h		\
+-	gdummytlsbackend.h		\
+-	gfileattribute-priv.h		\
+-	gfileinfo-priv.h		\
+-	giomodule-priv.h		\
+-	glocaldirectorymonitor.h	\
+-	glocalfileenumerator.h		\
+-	glocalfile.h			\
+-	glocalfileinfo.h		\
+-	glocalfileinputstream.h		\
+-	glocalfileiostream.h		\
+-	glocalfilemonitor.h		\
+-	glocalfileoutputstream.h	\
+-	glocalvfs.h			\
+-	gmountprivate.h			\
+-	gnativevolumemonitor.h		\
+-	gnetworkingprivate.h		\
+-	gnetworkmonitorbase.h		\
+-	gnetworkmonitornetlink.h	\
+-	gpollfilemonitor.h		\
+-	gregistrysettingsbackend.h	\
+-	gsettingsbackendinternal.h	\
+-	gsettings-mapping.h		\
+-	gsettingsschema-internal.h	\
+-	gsocketinputstream.h		\
+-	gsocketoutputstream.h		\
+-	gsocks4aproxy.h			\
+-	gsocks4proxy.h			\
+-	gsocks5proxy.h			\
+-	gthreadedresolver.h		\
+-	gunionvolumemonitor.h		\
+-	gunixmount.h			\
+-	gunixresolver.h			\
+-	gunixvolume.h			\
+-	gunixvolumemonitor.h		\
+-	gwin32appinfo.h			\
+-	gwin32mount.h			\
+-	gwin32resolver.h		\
+-	gwin32volumemonitor.h
+-
+-
+-# CFLAGS and LDFLAGS for compiling scan program. Only needed
+-# if $(DOC_MODULE).types is non-empty.
+-INCLUDES = \
+-	$(gio_INCLUDES)			\
+-	$(GLIB_DEBUG_FLAGS)
+-
+-GTKDOC_LIBS = \
+-	$(top_builddir)/glib/libglib-2.0.la		\
+-	$(top_builddir)/gobject/libgobject-2.0.la	\
+-	$(top_builddir)/gmodule/libgmodule-2.0.la	\
+-	$(top_builddir)/gio/libgio-2.0.la		\
+-	$(NULL)
+-
+-# Extra options to supply to gtkdoc-mkdb
+-MKDB_OPTIONS = --output-format=xml --sgml-mode --name-space=g \
+-	--ignore-files='libasyncns tests'
+-
+-# Images to copy into HTML directory
+-HTML_IMAGES =			\
+-	gvfs-overview.png	\
+-	menu-example.png	\
+-	menu-model.png
+-
+-content_files =			\
+-	version.xml		\
+-	overview.xml		\
+-	migrating-posix.xml	\
+-	migrating-gnome-vfs.xml	\
+-	migrating-gconf.xml	\
+-	migrating-gdbus.xml	\
+-	gio-querymodules.xml	\
+-	glib-compile-schemas.xml\
+-	glib-compile-resources.xml	\
+-	gsettings.xml		\
+-	gresource.xml		\
+-	gdbus.xml		\
+-	gdbus-codegen.xml	\
+-	$(NULL)
+-
+-expand_content_files =		\
+-	overview.xml		\
+-	migrating-posix.xml	\
+-	migrating-gnome-vfs.xml	\
+-	migrating-gconf.xml	\
+-	migrating-gdbus.xml	\
+-	gdbus-codegen.xml	\
+-	$(NULL)
+-
+-extra_files =			\
+-	version.xml.in		\
+-	gvfs-overview.odg
+-
+-# Extra options to supply to gtkdoc-fixref
+-FIXXREF_OPTIONS=--extra-dir=$(srcdir)/../glib/html --extra-dir=$(srcdir)/../gobject/html
+-
+-include $(top_srcdir)/gtk-doc.make
+-
+-EXTRA_DIST +=			\
+-	version.xml.in
+-
+-man_MANS =			\
+-	gio-querymodules.1	\
+-	glib-compile-schemas.1	\
+-	glib-compile-resources.1	\
+-	gsettings.1		\
+-	gresource.1		\
+-	gdbus.1			\
+-	gdbus-codegen.1
+-
+-if ENABLE_MAN
+-
+-.xml.1:
+-	@XSLTPROC@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+-
+-dist-local-check-mans-enabled:
+-	if grep "Man generation disabled" $(man_MANS) >/dev/null; then $(RM) $(man_MANS); fi
+-
+-else
+-
+-$(man_MANS):
+-	echo Man generation disabled.  Creating dummy $@.  Configure with --enable-man to enable it.
+-	echo Man generation disabled.  Remove this file, configure with --enable-man, and rebuild > $@
+-
+-dist-local-check-mans-enabled:
+-	echo "*** --enable-man must be used in order to make dist"
+-	false
+-
+-endif
+-
+-MAINTAINERCLEANFILES = $(man_MANS) $(BUILT_SOURCES)
+-
+-EXTRA_DIST += $(man_MANS)
+-
+-dist-hook-local: dist-local-check-mans-enabled all-local
+-
+-gio-docs-clean: clean
+-	cd $(srcdir) && rm -rf xml html
+diff --git a/docs/reference/gio/gdbus-object-manager-example/Makefile.am b/docs/reference/gio/gdbus-object-manager-example/Makefile.am
+deleted file mode 100644
+index 90c10aa..0000000
+--- a/docs/reference/gio/gdbus-object-manager-example/Makefile.am
++++ /dev/null
+@@ -1,68 +0,0 @@
+-include $(top_srcdir)/Makefile.decl
+-NULL =
+-
+-# The name of the module.
+-DOC_MODULE=gdbus-object-manager-example
+-
+-# The top-level SGML file.
+-DOC_MAIN_SGML_FILE=gdbus-object-manager-example-docs.xml
+-
+-# Extra options to supply to gtkdoc-scan
+-SCAN_OPTIONS=--deprecated-guards="G_DISABLE_DEPRECATED"
+-
+-# The directory containing the source code. Relative to $(srcdir)
+-DOC_SOURCE_DIR=$(top_builddir)/gio/tests/gdbus-object-manager-example
+-
+-HFILE_GLOB=$(top_builddir)/gio/tests/gdbus-object-manager-example/*.h
+-CFILE_GLOB=$(top_builddir)/gio/tests/gdbus-object-manager-example/*.c
+-
+-# Headers to ignore
+-IGNORE_HFILES=				\
+-	$(NULL)
+-
+-# CFLAGS and LDFLAGS for compiling scan program. Only needed
+-# if $(DOC_MODULE).types is non-empty.
+-INCLUDES = \
+-	$(gio_INCLUDES)			\
+-	$(GLIB_DEBUG_FLAGS)
+-
+-GTKDOC_LIBS = \
+-	$(top_builddir)/glib/libglib-2.0.la		\
+-	$(top_builddir)/gobject/libgobject-2.0.la	\
+-	$(top_builddir)/gmodule/libgmodule-2.0.la	\
+-	$(top_builddir)/gio/libgio-2.0.la		\
+-	$(top_builddir)/gio/tests/gdbus-object-manager-example/libgdbus-example-objectmanager.la \
+-	$(NULL)
+-
+-# Extra options to supply to gtkdoc-mkdb
+-MKDB_OPTIONS = --output-format=xml --sgml-mode --name-space=g \
+-	$(NULL)
+-
+-# Images to copy into HTML directory
+-HTML_IMAGES =			\
+-	$(NULL)
+-
+-content_files =			\
+-	$(NULL)
+-
+-expand_content_files =		\
+-	$(NULL)
+-
+-extra_files =			\
+-	$(NULL)
+-
+-include $(top_srcdir)/gtk-doc.make
+-
+-EXTRA_DIST +=			\
+-	$(NULL)
+-
+-MAINTAINERCLEANFILES = $(BUILT_SOURCES)
+-
+-dist-hook-local: all-local
+-
+-gdbus-object-manager-example-docs-clean: clean
+-	cd $(srcdir) && rm -rf xml html
+-
+-# Nuke installed docs (don't know how to avoid installing them)
+-install-data-hook :
+-	rm -rf $(DESTDIR)$(datadir)/gtk-doc/html/gdbus-object-manager-example
+diff --git a/docs/reference/glib/Makefile.am b/docs/reference/glib/Makefile.am
+deleted file mode 100644
+index 2ceae09..0000000
+--- a/docs/reference/glib/Makefile.am
++++ /dev/null
+@@ -1,129 +0,0 @@
+-## Process this file with automake to produce Makefile.in
+-include $(top_srcdir)/Makefile.decl
+-
+-AUTOMAKE_OPTIONS = 1.6
+-
+-# The name of the module.
+-DOC_MODULE=glib
+-
+-# The top-level SGML file.
+-DOC_MAIN_SGML_FILE=glib-docs.sgml
+-
+-# The directory containing the source code. Relative to $(srcdir)
+-DOC_SOURCE_DIR=$(top_srcdir)/glib $(top_srcdir)/gmodule
+-
+-# Extra options to supply to gtkdoc-scan
+-SCAN_OPTIONS=--deprecated-guards="G_DISABLE_DEPRECATED" --ignore-decorators="GLIB_VAR|G_GNUC_WARN_UNUSED_RESULT"
+-
+-# Extra options to supply to gtkdoc-mkdb
+-MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space=g
+-
+-# Used for dependencies
+-HFILE_GLOB=$(top_srcdir)/glib/*.h $(top_srcdir)/gmodule/*.h
+-CFILE_GLOB=$(top_srcdir)/glib/*.c $(top_srcdir)/gmodule/*.c
+-
+-# Ignore some private headers
+-IGNORE_HFILES = \
+-	gallocator.h		\
+-	gdatasetprivate.h	\
+-	glibintl.h		\
+-	gbsearcharray.h		\
+-	glib-private.h		\
+-	gmoduleconf.h		\
+-	gthreadprivate.h	\
+-	gunibreak.h		\
+-	gunicomp.h		\
+-	gunidecomp.h		\
+-	gunichartables.h	\
+-	glib_probes.h		\
+-	glib_trace.h		\
+-	libcharset.h		\
+-	gdebug.h		\
+-	gprintfint.h		\
+-	gmirroringtable.h	\
+-	gscripttable.h		\
+-	glib-mirroring-tab	\
+-	gnulib			\
+-	pcre			\
+-	update-pcre		\
+-	gbytesprivate.h		\
+-	gvariant-internal.h	\
+-	gvariant-serialiser.h	\
+-	gvariant-core.h		\
+-	gvarianttypeinfo.h	\
+-	gwakeup.h
+-
+-# Images to copy into HTML directory
+-HTML_IMAGES =  				\
+-	file-name-encodings.png		\
+-	mainloop-states.gif
+-
+-# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE)
+-content_files =				\
+-	cross.sgml			\
+-	running.sgml			\
+-	building.sgml			\
+-	changes.sgml			\
+-	compiling.sgml			\
+-	resources.sgml			\
+-	regex-syntax.sgml		\
+-	version.xml			\
+-	glib-gettextize.xml		\
+-	gtester.xml			\
+-	gtester-report.xml		\
+-	gvariant-varargs.xml		\
+-	gvariant-text.xml
+-
+-expand_content_files = 			\
+-	compiling.sgml
+-
+-# Extra options to supply to gtkdoc-fixref
+-FIXXREF_OPTIONS=--extra-dir=$(srcdir)/../gobject/html --extra-dir=$(srcdir)/../gio/html
+-
+-# include common portion ...
+-include $(top_srcdir)/gtk-doc.make
+-
+-# Other files to distribute
+-EXTRA_DIST +=				\
+-	file-name-encodings.png		\
+-	file-name-encodings.sxd		\
+-	mainloop-states.fig		\
+-	mainloop-states.png		\
+-	mainloop-states.eps		\
+-	version.xml.in
+-
+-########################################################################
+-
+-man_MANS =		  	\
+-	glib-gettextize.1 	\
+-	gtester.1		\
+-	gtester-report.1
+-
+-if ENABLE_MAN
+-
+-.xml.1:
+-	@XSLTPROC@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+-
+-dist-local-check-mans-enabled:
+-	if grep "Man generation disabled" $(man_MANS) >/dev/null; then $(RM) $(man_MANS); fi
+-
+-else
+-
+-$(man_MANS):
+-	echo Man generation disabled.  Creating dummy $@.  Configure with --enable-man to enable it.
+-	echo Man generation disabled.  Remove this file, configure with --enable-man, and rebuild > $@
+-
+-dist-local-check-mans-enabled:
+-	echo "*** --enable-man must be used in order to make dist"
+-	false
+-
+-endif
+-
+-MAINTAINERCLEANFILES = $(man_MANS) $(BUILT_SOURCES)
+-
+-EXTRA_DIST += $(man_MANS)
+-
+-dist-hook-local: dist-local-check-mans-enabled all-local
+-
+-glib-docs-clean: clean
+-	cd $(srcdir) && rm -rf xml html
+diff --git a/docs/reference/gobject/Makefile.am b/docs/reference/gobject/Makefile.am
+deleted file mode 100644
+index 3a637b7..0000000
+--- a/docs/reference/gobject/Makefile.am
++++ /dev/null
+@@ -1,103 +0,0 @@
+-## Process this file with automake to produce Makefile.in
+-include $(top_srcdir)/Makefile.decl
+-
+-AUTOMAKE_OPTIONS = 1.6
+-
+-# The name of the module.
+-DOC_MODULE=gobject
+-
+-# The top-level SGML file.
+-DOC_MAIN_SGML_FILE=gobject-docs.sgml
+-
+-# The directory containing the source code. Relative to $(srcdir)
+-DOC_SOURCE_DIR=$(top_srcdir)/gobject
+-
+-# Extra options to supply to gtkdoc-scan
+-SCAN_OPTIONS=--deprecated-guards="G_DISABLE_DEPRECATED" \
+-             --ignore-decorators="G_GNUC_INTERNAL|G_GNUC_WARN_UNUSED_RESULT"
+-
+-# Extra options to supply to gtkdoc-mkdb
+-MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space=g
+-
+-# Used for dependencies
+-HFILE_GLOB=$(top_srcdir)/gobject/*.h
+-CFILE_GLOB=$(top_srcdir)/gobject/*.c
+-
+-# Headers to ignore
+-IGNORE_HFILES = \
+-	tests			\
+-	gobject_trace.h		\
+-	gatomicarray.h
+-
+-
+-# CFLAGS and LDFLAGS for compiling scan program. Only needed
+-# if $(DOC_MODULE).types is non-empty.
+-INCLUDES = \
+-	-I$(srcdir) 			\
+-	$(gobject_INCLUDES) 		\
+-	$(GLIB_DEBUG_FLAGS)
+-GTKDOC_LIBS = \
+-	$(top_builddir)/glib/libglib-2.0.la	\
+-	$(top_builddir)/gobject/libgobject-2.0.la
+-
+-# Images to copy into HTML directory
+-HTML_IMAGES =  \
+-	images/glue.png
+-
+-# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE)
+-content_files = version.xml 		\
+-		glib-mkenums.xml 	\
+-		glib-genmarshal.xml	\
+-		gobject-query.xml \
+-		tut_gobject.xml \
+-		tut_gsignal.xml \
+-		tut_gtype.xml \
+-		tut_howto.xml \
+-		tut_intro.xml \
+-		tut_tools.xml
+-
+-# Extra options to supply to gtkdoc-fixref
+-FIXXREF_OPTIONS=--extra-dir=$(srcdir)/../glib/html
+-
+-include $(top_srcdir)/gtk-doc.make
+-
+-# Other files to distribute
+-EXTRA_DIST += 		\
+-	gobject.cI	\
+-	version.xml.in
+-
+-########################################################################
+-
+-man_MANS = 			\
+-	glib-mkenums.1 		\
+-	glib-genmarshal.1 	\
+-	gobject-query.1
+-
+-if ENABLE_MAN
+-
+-.xml.1:
+-	@XSLTPROC@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+-
+-dist-local-check-mans-enabled:
+-	if grep "Man generation disabled" $(man_MANS) >/dev/null; then $(RM) $(man_MANS); fi
+-
+-else
+-
+-$(man_MANS):
+-	echo Man generation disabled.  Creating dummy $@.  Configure with --enable-man to enable it.
+-	echo Man generation disabled.  Remove this file, configure with --enable-man, and rebuild > $@
+-
+-dist-local-check-mans-enabled:
+-	echo "*** --enable-man must be used in order to make dist"
+-	false
+-
+-endif
+-
+-MAINTAINERCLEANFILES = $(man_MANS) $(BUILT_SOURCES)
+-
+-EXTRA_DIST += $(man_MANS)
+-
+-dist-hook-local: dist-local-check-mans-enabled all-local
+-
+-gobject-docs-clean: clean
+-	cd $(srcdir) && rm -rf xml html
 -- 
-1.7.1
+1.7.10.4
+
--- a/src/glib.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/glib.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,22 +3,19 @@
 
 PKG             := glib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 20cd63705a8805260da0320c65b979233f2e3c18
+$(PKG)_CHECKSUM := 429355327aaf69d2c21cbefcb20c61db94e0acec
 $(PKG)_SUBDIR   := glib-$($(PKG)_VERSION)
-$(PKG)_FILE     := glib-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := glib-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/glib/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc gettext pcre libiconv zlib dbus
+$(PKG)_DEPS     := gcc gettext pcre libiconv zlib libffi dbus
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/glib/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/glib/refs/tags' | \
     $(SED) -n "s,.*tag/?id=\([0-9]\+\.[0-9]*[02468]\.[^']*\).*,\1,p" | \
     head -1
 endef
 
-define $(PKG)_BUILD
-    cd '$(1)' && aclocal
-    cd '$(1)' && $(LIBTOOLIZE) --force
-    cd '$(1)' && autoconf
+define $(PKG)_NATIVE_BUILD
     cp -Rp '$(1)' '$(1).native'
 
     # native build of libiconv (used by glib-genmarshal)
@@ -35,6 +32,7 @@
         --enable-regex \
         --disable-threads \
         --disable-selinux \
+        --disable-inotify \
         --disable-fam \
         --disable-xattr \
         --disable-dtrace \
@@ -45,10 +43,30 @@
     $(SED) -i 's,#define G_ATOMIC.*,,' '$(1).native/config.h'
     $(MAKE) -C '$(1).native/glib'    -j '$(JOBS)'
     $(MAKE) -C '$(1).native/gthread' -j '$(JOBS)'
+    $(MAKE) -C '$(1).native/gmodule' -j '$(JOBS)'
     $(MAKE) -C '$(1).native/gobject' -j '$(JOBS)' lib_LTLIBRARIES= install-exec
+    $(MAKE) -C '$(1).native/gio/xdgmime'     -j '$(JOBS)'
     $(MAKE) -C '$(1).native/gio'     -j '$(JOBS)' glib-compile-schemas
+    $(MAKE) -C '$(1).native/gio'     -j '$(JOBS)' glib-compile-resources
     $(INSTALL) -m755 '$(1).native/gio/glib-compile-schemas' '$(PREFIX)/$(TARGET)/bin/'
+    $(INSTALL) -m755 '$(1).native/gio/glib-compile-resources' '$(PREFIX)/$(TARGET)/bin/'
+endef
 
+define $(PKG)_SYMLINK
+    ln -sf `which glib-genmarshal`        '$(PREFIX)/$(TARGET)/bin/'
+    ln -sf `which glib-compile-schemas`   '$(PREFIX)/$(TARGET)/bin/'
+    ln -sf `which glib-compile-resources` '$(PREFIX)/$(TARGET)/bin/'
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./autogen.sh
+    rm -f '$(PREFIX)/$(TARGET)/bin/glib-*'
+    $(if $(findstring y,\
+            $(shell [ -x "`which glib-genmarshal`" ] && \
+                    [ -x "`which glib-compile-schemas`" ] && \
+                    [ -x "`which glib-compile-resources`" ] && echo y)), \
+        $($(PKG)_SYMLINK), \
+        $($(PKG)_NATIVE_BUILD))
     # cross build
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
@@ -58,10 +76,12 @@
         --with-threads=win32 \
         --with-pcre=system \
         --with-libiconv=gnu \
+        --disable-inotify \
         CXX='$(TARGET)-c++' \
         PKG_CONFIG='$(PREFIX)/bin/$(TARGET)-pkg-config' \
         GLIB_GENMARSHAL='$(PREFIX)/$(TARGET)/bin/glib-genmarshal' \
-        GLIB_COMPILE_SCHEMAS='$(PREFIX)/$(TARGET)/bin/glib-compile-schemas'
+        GLIB_COMPILE_SCHEMAS='$(PREFIX)/$(TARGET)/bin/glib-compile-schemas' \
+        GLIB_COMPILE_RESOURCES='$(PREFIX)/$(TARGET)/bin/glib-compile-resources'
     $(MAKE) -C '$(1)/glib'    -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
     $(MAKE) -C '$(1)/gmodule' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
     $(MAKE) -C '$(1)/gthread' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
--- a/src/glibmm.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/glibmm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := glibmm
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := d15bc0fed7dea6fec73746370653687f74e02592
+$(PKG)_CHECKSUM := 2928a334664433186d92d9099b9bbf3f051a2645
 $(PKG)_SUBDIR   := glibmm-$($(PKG)_VERSION)
-$(PKG)_FILE     := glibmm-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := glibmm-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/glibmm/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib libsigc++
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/glibmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/glibmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     head -1
--- a/src/gmp.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gmp.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := gmp
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := ea4ea7c3f10436ef5ae7a75b3fad163a8b86edc0
+$(PKG)_CHECKSUM := 12a662456033e21aed3e318aef4177f4000afe3b
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := ftp://ftp.gmplib.org/pub/$(PKG)-$($(PKG)_VERSION)/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.gmplib.org/' | \
+    $(WGET) -q -O- 'http://www.gmplib.org/' | \
     grep '<a href="' | \
     $(SED) -n 's,.*gmp-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v '^4\.' | \
@@ -21,6 +21,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && CC_FOR_BUILD=gcc ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
         --enable-cxx \
--- a/src/gnutls-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gnutls-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -3,10 +3,10 @@
 
 Contains ad hoc patches for cross building.
 
-From 2192552e7e1321b985803eca20a433c19b9384d1 Mon Sep 17 00:00:00 2001
+From 7cc6a28af1fde387b055cfafe2b73f7e33b48acc Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Fri, 28 Oct 2011 09:23:41 +0200
-Subject: [PATCH 1/4] add missing static library linking
+Subject: [PATCH 1/6] add missing static library linking
 
 
 diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in
@@ -25,14 +25,14 @@
 1.7.10.4
 
 
-From b11d2c59f0c8793717d8c718c8d4836fcae86a2b Mon Sep 17 00:00:00 2001
+From b444c40c36670329480354b1e51b4f24d4f617bf Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 24 Nov 2011 15:06:06 +0100
-Subject: [PATCH 2/4] disable doc and test (MXE specific)
+Subject: [PATCH 2/6] disable doc and test (mingw-cross-env specific)
 
 
 diff --git a/Makefile.am b/Makefile.am
-index 0afe4bd..da7436a 100644
+index e866bd3..8fc5d5d 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -23,7 +23,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --disable-valgrind-tests
@@ -48,16 +48,41 @@
 1.7.10.4
 
 
-From 49019993012db5eea6d9b3f37c4d2c9b4c619a8a Mon Sep 17 00:00:00 2001
+From f7f6a76620f805a7c5f207a1870049719f66d855 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Tue, 3 Apr 2012 13:58:42 +0200
+Subject: [PATCH 3/6] Revert "make dist will also make lzip compressed
+ tarball"
+
+This reverts commit 97ac1bc58274f651338444693bd75441ba12f46f.
+
+diff --git a/configure.ac b/configure.ac
+index d3bec26..23a4d6a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -25,7 +25,7 @@ AC_INIT([GnuTLS], [3.1.2], [bug-gnutls@gnu.org])
+ AC_CONFIG_AUX_DIR([build-aux])
+ AC_CONFIG_MACRO_DIR([m4])
+ 
+-AM_INIT_AUTOMAKE([1.11.3 no-dist-gzip dist-xz dist-lzip -Wall -Werror -Wno-override])
++AM_INIT_AUTOMAKE([1.11.3 no-dist-gzip dist-xz -Wall -Werror -Wno-override])
+ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+ AM_CONFIG_HEADER(config.h)
+ 
+-- 
+1.7.10.4
+
+
+From 51a9cc85a5fda679b63a70fd6d22ccceef02fcc2 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Wed, 6 Jun 2012 09:57:24 +0200
-Subject: [PATCH 3/4] AM_PROG_AR for automake 1.12 compatibility
+Subject: [PATCH 4/6] AM_PROG_AR for automake 1.12 compatibility
 
 Taken from
 http://lists.gnu.org/archive/html/automake/2012-05/msg00014.html
 
 diff --git a/configure.ac b/configure.ac
-index 83c3577..6e2897b 100644
+index 23a4d6a..63760b3 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -37,6 +37,7 @@ dnl Checks for programs.
@@ -72,25 +97,47 @@
 1.7.10.4
 
 
-From 82e1e1d59d357dfdebbe88575a440d0d7675533d Mon Sep 17 00:00:00 2001
+From e91df6db4077b54c0003ca23ace3eba48402af1c Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
-Date: Wed, 18 Jul 2012 00:58:59 +0200
-Subject: [PATCH 4/4] relax automake
+Date: Thu, 16 Aug 2012 11:13:47 +0200
+Subject: [PATCH 5/6] allow automake warnings not to be errors
 
 
 diff --git a/configure.ac b/configure.ac
-index 6e2897b..024d31e 100644
+index 63760b3..4f7622a 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -25,7 +25,7 @@ AC_INIT([GnuTLS], [3.0.17], [bug-gnutls@gnu.org])
+@@ -25,7 +25,7 @@ AC_INIT([GnuTLS], [3.1.2], [bug-gnutls@gnu.org])
  AC_CONFIG_AUX_DIR([build-aux])
  AC_CONFIG_MACRO_DIR([m4])
  
--AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz -Wall -Werror -Wno-override])
-+AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz -Wall -Wno-override])
+-AM_INIT_AUTOMAKE([1.11.3 no-dist-gzip dist-xz -Wall -Werror -Wno-override])
++AM_INIT_AUTOMAKE([1.11.3 no-dist-gzip dist-xz -Wall -Wno-override])
  m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  AM_CONFIG_HEADER(config.h)
  
 -- 
 1.7.10.4
 
+
+From 969e618b7945e786fe23bc5a3643bf5e9e8adbd4 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Thu, 20 Sep 2012 12:59:19 +0200
+Subject: [PATCH 6/6] add missing libs to Libs.private
+
+
+diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in
+index 57d0dbb..02a6ef7 100644
+--- a/lib/gnutls.pc.in
++++ b/lib/gnutls.pc.in
+@@ -19,6 +19,6 @@ Description: Transport Security Layer implementation for the GNU system
+ URL: http://www.gnu.org/software/gnutls/
+ Version: @VERSION@
+ Libs: -L${libdir} -lgnutls
+-Libs.private: @LTLIBNETTLE@ @LIBS@
++Libs.private: @LTLIBNETTLE@ @LIBS@ -lcrypt32 -lws2_32
+ @GNUTLS_REQUIRES_PRIVATE@
+ Cflags: -I${includedir}
+-- 
+1.7.10.4
+
--- a/src/gnutls.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gnutls.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -2,17 +2,16 @@
 # See index.html for further information.
 
 PKG             := gnutls
-$(PKG)_CHECKSUM := 2e2adc41e0c75d8170fdca5955bd007ae93ceada
+$(PKG)_CHECKSUM := 38591da6484e7f47effaf301adde5fec00b18c2d
 $(PKG)_SUBDIR   := gnutls-$($(PKG)_VERSION)
 $(PKG)_FILE     := gnutls-$($(PKG)_VERSION).tar.xz
-$(PKG)_URL      := ftp://ftp.gnutls.org/pub/gnutls/$($(PKG)_FILE)
-$(PKG)_URL_2    := ftp://ftp.gnupg.org/gcrypt/gnutls/$($(PKG)_FILE)
+$(PKG)_URL      := http://ftp.gnu.org/gnu/gnutls/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc nettle zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=tags' | \
     grep '<a class="list name"' | \
-    $(SED) -n 's,.*<a[^>]*>gnutls_\([0-9]*_[0-9]*[02468]_[^<]*\)<.*,\1,p' | \
+    $(SED) -n 's,.*<a[^>]*>gnutls_\([0-9]*_[0-9]*[012468]_[^<]*\)<.*,\1,p' | \
     $(SED) 's,_,.,g' | \
     grep -v '^2\.' | \
     head -1
@@ -27,6 +26,7 @@
     # Value taken from http://msdn.microsoft.com/en-us/library/windows/desktop/ms737530%28v=vs.85%29.aspx
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --enable-static \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
@@ -36,7 +36,7 @@
         --with-included-libcfg \
         --without-p11-kit \
         --disable-silent-rules \
-        CPPFLAGS='-DWINVER=0x0501 -DAI_ADDRCONFIG=0x0400' \
+        CPPFLAGS='-DWINVER=0x0501 -DAI_ADDRCONFIG=0x0400 -DIPV6_V6ONLY=27' \
         LIBS='-lws2_32' \
         ac_cv_prog_AR='$(TARGET)-ar'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install
--- a/src/graphicsmagick-1-fix-xml2-config.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/graphicsmagick-1-fix-xml2-config.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -38,9 +38,10 @@
 index 5757b37..87e3fd4 100644
 --- a/magick/GraphicsMagick.pc.in
 +++ b/magick/GraphicsMagick.pc.in
-@@ -8,4 +8,5 @@ Name: GraphicsMagick
+@@ -8,4 +8,6 @@ Name: GraphicsMagick
  Version: @PACKAGE_VERSION@
  Description: GraphicsMagick image processing library
++Requires.private: libxml-2.0
  Libs: -L${libdir} -lGraphicsMagick
 +Libs.private: @MAGICK_API_LDFLAGS@ @MAGICK_API_LIBS@
  Cflags: -I${includedir} @MAGICK_API_PC_CPPFLAGS@
--- a/src/graphicsmagick.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/graphicsmagick.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := graphicsmagick
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 7ef5711a18da0a3b6b143548a2a7822597ea416d
+$(PKG)_CHECKSUM := 3949030b101d66811242a0d30abc9965481ed035
 $(PKG)_SUBDIR   := GraphicsMagick-$($(PKG)_VERSION)
-$(PKG)_FILE     := GraphicsMagick-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := GraphicsMagick-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc pthreads libtool zlib bzip2 jpeg jasper lcms1 libpng tiff freetype libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
@@ -20,6 +20,7 @@
     cd '$(1)' && autoconf
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --without-modules \
--- a/src/gsl.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gsl.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>[^0-9>]*\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/gsoap-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gsoap-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -3,17 +3,14 @@
 
 Contains ad hoc patches for cross building.
 
-From a4e9166bc8d78b2aee3c25757d479d4c2e53c7be Mon Sep 17 00:00:00 2001
+From 538418ded4554eec40b6a889d58cfbb493cd9a2c Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sun, 23 Oct 2011 21:36:53 +0200
 Subject: [PATCH 1/3] support static linking to ntlm
 
----
- configure |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/configure b/configure
-index ad1830d..be95edf 100755
+index 6ac9ee7..0570bb6 100755
 --- a/configure
 +++ b/configure
 @@ -4822,7 +4822,7 @@ case "${host}" in
@@ -26,22 +23,14 @@
          *-*-freebsd*)   platform=FREEBSD ;;
          *-*-openbsd*)   platform=OPENBSD ;;
 -- 
-1.7.7
+1.7.11.4
 
 
-From da0eb2fc386be0fd914ef8f9a7d6bf73004ea230 Mon Sep 17 00:00:00 2001
+From 41c709c382a1aa268c85d98df65562eb4563d640 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Mon, 24 Oct 2011 11:17:13 +0200
 Subject: [PATCH 2/3] ntlm support in .pc files
 
----
- gsoap++.pc.in    |    2 +-
- gsoap.pc.in      |    2 +-
- gsoapck++.pc.in  |    2 +-
- gsoapck.pc.in    |    2 +-
- gsoapssl++.pc.in |    2 +-
- gsoapssl.pc.in   |    2 +-
- 6 files changed, 6 insertions(+), 6 deletions(-)
 
 diff --git a/gsoap++.pc.in b/gsoap++.pc.in
 index 035afd9..3411d55 100644
@@ -104,6 +93,37 @@
 -Cflags: @SOAPCPP2_IPV6@ -DWITH_OPENSSL -DWITH_DOM -DWITH_COOKIES -DWITH_GZIP -I${includedir}
 +Cflags: @SOAPCPP2_IPV6@ -DWITH_OPENSSL -DWITH_DOM -DWITH_NTLM -DWITH_COOKIES -DWITH_GZIP -I${includedir}
 -- 
-1.7.7
+1.7.11.4
 
 
+From 3b8d0a7db13b9c607e66c6a9d5455f26576d80fd Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Mon, 20 Aug 2012 13:12:49 +0200
+Subject: [PATCH 3/3] fix MINGW compatibility
+
+taken from
+https://sourceforge.net/tracker/?func=detail&aid=3559816&group_id=52781&atid=468023
+
+diff --git a/gsoap/stdsoap2.h b/gsoap/stdsoap2.h
+index 8718592..ab5bed4 100644
+--- a/gsoap/stdsoap2.h
++++ b/gsoap/stdsoap2.h
+@@ -2195,13 +2195,13 @@ soap_wchar soap_get1(struct soap*);
+  SOAP_FMAC1 unsigned long SOAP_FMAC2 soap_strtoul(const char *s, char **t, int b);
+ #endif
+ 
+-#ifdef WIN32
++#if defined(WIN32) && !defined(__MINGW32__)
+ # define soap_strtoll _strtoi64
+ #else
+ # define soap_strtoll strtoll
+ #endif
+ 
+-#ifdef WIN32
++#if defined(WIN32) && !defined(__MINGW32__)
+ # define soap_strtoull _strtoui64
+ #else
+ # define soap_strtoull strtoull
+-- 
+1.7.11.4
+
--- a/src/gsoap.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gsoap.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,19 +3,22 @@
 
 PKG             := gsoap
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 011b507e667d7bb76e30fc8a31055e8cf323311d
+$(PKG)_CHECKSUM := 18cedfdabb79ad4e006db64ffd24d72f0d1fd6ba
 $(PKG)_SUBDIR   := gsoap-$(call SHORT_PKG_VERSION,$(PKG))
 $(PKG)_FILE     := gsoap_$($(PKG)_VERSION).zip
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/gsoap2/gSOAP/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gnutls libgcrypt libntlm
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/gsoap2/files/gSOAP/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/gsoap2/files/gSOAP/' | \
     $(SED) -n 's,.*gsoap_\([0-9][^>]*\)\.zip.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
+    # avoid reconfiguration
+    cd '$(1)' && touch configure config.h.in
+
     # Native build to get tools wsdl2h and soapcpp2
     cd '$(1)' && ./configure
 
--- a/src/gst-plugins-base.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gst-plugins-base.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gst-plugins-base
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 6d7dc463fed5dd43f79a53ad523fcbd6d0916303
+$(PKG)_CHECKSUM := 2c4b34245107395bc9103649bb2af1c1088a3f7c
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://gstreamer.freedesktop.org/src/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib libxml2 gstreamer liboil pango ogg vorbis theora
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/gstreamer/gst-plugins-base/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/gstreamer/gst-plugins-base/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
@@ -21,6 +21,7 @@
         -exec $(SED) -i 's,glib-genmarshal,$(PREFIX)/$(TARGET)/bin/glib-genmarshal,g' {} \;
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
         --disable-debug \
--- a/src/gst-plugins-good.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gst-plugins-good.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gst-plugins-good
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 9c78a751bb2f20ad50a1daf6860e0098e0495f5a
+$(PKG)_CHECKSUM := 15addda7c6322a42c904aaf1c1d0b5d5a63f908b
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://gstreamer.freedesktop.org/src/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib libxml2 gstreamer gst-plugins-base liboil libshout cairo flac gtk2 jpeg libpng speex taglib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/gstreamer/gst-plugins-good/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/gstreamer/gst-plugins-good/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
@@ -24,11 +24,11 @@
     #   http://lists.mplayerhq.hu/pipermail/mplayer-cvslog/2004-August/019283.html
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
         --disable-debug \
         --disable-examples \
-        --disable-esd \
         --disable-aalib \
         --disable-x \
         --mandir='$(1)/sink' \
--- a/src/gstreamer.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gstreamer.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gstreamer
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := ad03b8aca7b2415929b6ecc4c140b178acef39de
+$(PKG)_CHECKSUM := 27931b00eb5d50bc477e32e2dda7440f4179e7ac
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://gstreamer.freedesktop.org/src/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/gstreamer/gstreamer/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/gstreamer/gstreamer/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
@@ -20,6 +20,7 @@
     $(SED) -i 's,glib-genmarshal,$(PREFIX)/$(TARGET)/bin/glib-genmarshal,g' '$(1)'/gst/Makefile.in
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
         --disable-debug \
--- a/src/gta.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gta.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gta
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 9020944bcd40bd986a879d454d21920a1eb48db7
+$(PKG)_CHECKSUM := dffeb65b0dad66860ab62df1cf8570ea23517c2c
 $(PKG)_SUBDIR   := libgta-$($(PKG)_VERSION)
 $(PKG)_FILE     := libgta-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://download.savannah.gnu.org/releases/gta/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib bzip2 xz
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gta.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gta.git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>libgta-\([0-9.]*\)<.*,\1,p' | \
     head -1
--- a/src/gtk2-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gtk2-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -18,7 +18,7 @@
  
  int __stdcall
 -DllMain (HINSTANCE hinstDLL,
-+static _disabled_DllMain (HINSTANCE hinstDLL,
++gdk_DllMain (HINSTANCE hinstDLL,
  	 DWORD     dwReason,
  	 LPVOID    reserved)
  {
@@ -31,7 +31,7 @@
  
  BOOL WINAPI
 -DllMain (HINSTANCE hinstDLL,
-+static _disabled_DllMain (HINSTANCE hinstDLL,
++gtk_DllMain (HINSTANCE hinstDLL,
  	 DWORD     fdwReason,
  	 LPVOID    lpvReserved)
  {
--- a/src/gtk2.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gtk2.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gtk2
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := c15a25ba49eb459b2c4cdc46baedf6cecf08cbcf
+$(PKG)_CHECKSUM := baf5c73e186352cad767392a6b55840be0326ddc
 $(PKG)_SUBDIR   := gtk+-$($(PKG)_VERSION)
-$(PKG)_FILE     := gtk+-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := gtk+-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/gtk+/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gettext libpng jpeg tiff jasper glib atk pango cairo gdk-pixbuf
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/gtk+/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/gtk+/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     grep -v '^2\.9' | \
@@ -25,18 +25,12 @@
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --enable-explicit-deps \
-        --disable-gdiplus \
         --disable-glibtest \
         --disable-modules \
         --disable-cups \
         --disable-test-print-backend \
         --disable-gtk-doc \
         --disable-man \
-        --with-libpng \
-        --with-libjpeg \
-        --with-libtiff \
-        --with-libjasper \
-        --with-included-loaders \
         --with-included-immodules \
         --without-x
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gtkglarea-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,109 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains ad hoc patches for cross building.
+
+From 8ca212a3a9fa7a034b1fa3680422e9a7cad21d4a Mon Sep 17 00:00:00 2001
+From: MXE
+Date: Sun, 17 Jun 2012 09:05:56 +0200
+Subject: [PATCH] deactivates dll build which is not supported by mxe, and
+ introduce option --disable-shared to handle it.
+
+taken from
+https://github.com/GNOME/gtkglarea/pull/1
+
+diff --git a/configure.ac b/configure.ac
+index 07be73f..2728c10 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -53,6 +53,16 @@ if test "$native_win32" = "yes"; then
+ fi
+ AM_CONDITIONAL(MS_LIB_AVAILABLE, test x$ms_librarian = xyes)
+ 
++
++dnl
++dnl  Check if shared libs are enabled
++dnl
++AC_ARG_ENABLE(shared,
++  [AS_HELP_STRING([--disable-shared],[disable support for shared libraries])],
++  [],
++  [])
++AM_CONDITIONAL(USE_SHARED, test x$enable_shared != xno)
++
+ dnl
+ dnl  Check for GTK libraries
+ dnl
+@@ -172,7 +182,7 @@ AC_C_CONST
+ 
+ dnl Checks for library functions.
+ 
+-AC_OUTPUT(
++AC_CONFIG_FILES([
+   Makefile
+   gtkgl-2.0.pc
+   gtkgl/Makefile
+@@ -180,8 +190,8 @@ AC_OUTPUT(
+   docs/Makefile
+   examples/Makefile
+   examples/makefile.mingw
+-)
+-
++])
++AC_OUTPUT
+ 
+ echo "---"
+ echo "Configuration summary"
+diff --git a/gtkgl/Makefile.am b/gtkgl/Makefile.am
+index c7e65cd..23d4fdb 100644
+--- a/gtkgl/Makefile.am
++++ b/gtkgl/Makefile.am
+@@ -1,28 +1,28 @@
+ ## gtkgl directory
+ 
++INSTALL_EXTRA=
++UNINSTALL_EXTRA=
++
+ if OS_WIN32
+ export_symbols = -export-symbols gtkgl.def
+-
++if USE_SHARED
+ install-libtool-import-lib:
+ 	$(INSTALL) .libs/libgtkgl-2.0.dll.a $(DESTDIR)$(libdir)
+ uninstall-libtool-import-lib:
+ 	-rm $(DESTDIR)$(libdir)/libgtkgl-2.0.dll.a
+-else
+-install-libtool-import-lib:
+-uninstall-libtool-import-lib:
++INSTALL_EXTRA += install-libtool-import-lib
++UNINSTALL_EXTRA += uninstall-libtool-import-lib
++endif
+ endif
+ 
+ if MS_LIB_AVAILABLE
+ noinst_DATA = gtkgl-2.0.lib
+-
+ install-ms-lib:
+ 	$(INSTALL) gtkgl-2.0.lib $(DESTDIR)$(libdir)
+-
+ uninstall-ms-lib:
+ 	-rm $(DESTDIR)$(libdir)/gtkgl-2.0.lib
+-else
+-install-ms-lib:
+-uninstall-ms-lib:
++INSTALL_EXTRA += install-ms-lib
++UNINSTALL_EXTRA += uninstall-ms-lib
+ endif
+ 
+ EXTRA_DIST = makefile.mingw makefile.mingw.in gtkgl.def
+@@ -42,6 +42,6 @@ libgtkgl_2_0_la_LIBADD = $(GTK_LIBS) $(GL_LIBS)
+ gtkgl-2.0.lib: libgtkgl-2.0.la gtkgl.def
+ 	lib -name:libgtkgl-2.0-@LT_CURRENT_MINUS_AGE@.dll -def:gtkgl.def -out:$@
+ 
+-install-data-local: install-ms-lib install-libtool-import-lib
++install-data-local: $(INSTALL_EXTRA)
+ 
+-uninstall-local: uninstall-ms-lib uninstall-libtool-import-lib
++uninstall-local: $(UNINSTALL_EXTRA)
+-- 
+1.7.9.5
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gtkglarea.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,27 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := gtkglarea
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := db12f2bb9a3d28d69834832e2e04a255acfd8a6d
+$(PKG)_SUBDIR   := gtkglarea-$($(PKG)_VERSION)
+$(PKG)_FILE     := gtkglarea-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://mirrors.ircam.fr/pub/GNOME/sources/gtkglarea/2.0/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc gtk2 freeglut
+
+define $(PKG)_UPDATE
+    wget -q -O- 'mirrors.ircam.fr/pub/GNOME/sources/gtkglarea/2.0' | \
+    $(SED) -n 's,.*gtkglarea-\(2[^>]*\)\.tar.*,\1,ip' | \
+    sort | \
+    tail -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && autoreconf -fi # to be removed if patch is integrated upstream
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --disable-shared
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+endef
--- a/src/gtkglext.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gtkglext.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtk2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/cgit/gtkglext/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/cgit/gtkglext/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     grep -v '1\.1\.' | \
--- a/src/gtkglextmm.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gtkglextmm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtkglext gtkmm2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/cgit/gtkglextmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/cgit/gtkglextmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     grep -v '1\.1\.' | \
--- a/src/gtkmm2.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gtkmm2.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtk2 libsigc++ pangomm cairomm atkmm
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/gtkmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/gtkmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     grep -v '^2\.9' | \
--- a/src/gtksourceview.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gtksourceview.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtk2 libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/gtksourceview/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/gtksourceview/refs/tags' | \
     $(SED) -n 's,.*>GTKSOURCEVIEW_\([0-9]\+_[0-9]*[02468]_[^<]*\)<.*,\1,p' | \
     $(SED) 's,_,.,g' | \
     grep -v '^2\.9[0-9]\.' | \
--- a/src/gtksourceviewmm2.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/gtksourceviewmm2.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gtksourceviewmm2
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 7f6fb046427054d85c791a4b1fc0f742a3313c8a
+$(PKG)_CHECKSUM := 17d5daf33d2b6bc21c48c5c730abaae70e027566
 $(PKG)_SUBDIR   := gtksourceviewmm-$($(PKG)_VERSION)
-$(PKG)_FILE     := $($(PKG)_SUBDIR).tar.gz
+$(PKG)_FILE     := $($(PKG)_SUBDIR).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/gtksourceviewmm/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gtkmm2 gtksourceview
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/cgit/gtksourceviewmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/cgit/gtksourceviewmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=gtksourceviewmm-\\([0-9][^']*\\)'.*,\\1,p" | \
     grep -v '^2\.9[0-9]\.' | \
--- a/src/guile.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/guile.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libtool gmp libiconv gettext libunistring gc libffi readline
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>[^0-9>]*\([0-9][^< ]*\)\.<.*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hunspell-test.cpp	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,37 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <iostream>
+#include <fstream>
+#include <hunspell.hxx>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    std::ofstream dic ("hunspell-test.dic");
+    dic << "2\nHello\nWorld";
+    dic.close();
+    std::ofstream aff ("hunspell-test.aff");
+    aff << "SET UTF-8\nTRY loredWH\nMAXDIFF 1";
+    aff.close();
+    Hunspell h("hunspell-test.aff", "hunspell-test.dic");
+
+    if (h.spell("Hello") == 0)
+    {
+        std::cerr << "Error: hunspell marked correct word as wrong" << std::endl;
+    }
+    if (h.spell("wrld") != 0)
+    {
+        std::cerr << "Error: hunspell marked wrong word as correct" << std::endl;
+    }
+
+    char ** result;
+    int n = h.suggest(&result, "ell");
+    for (int i = 0; i < n; i++) std::cout << result[i];
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hunspell.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,36 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := hunspell
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 902c76d2b55a22610e2227abc4fd26cbe606a51c
+$(PKG)_SUBDIR   := hunspell-$($(PKG)_VERSION)
+$(PKG)_FILE     := hunspell-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/hunspell/Hunspell/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc libiconv gettext readline pthreads
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/hunspell/files/Hunspell/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    # Note: the configure file doesn't pick up pdcurses, so "ui" is disabled
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --enable-static \
+        --disable-shared \
+        --with-warnings \
+        --without-ui \
+        --with-readline \
+        --prefix='$(PREFIX)/$(TARGET)'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+
+
+    # Test
+    '$(TARGET)-g++' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).cpp' -o '$(PREFIX)/$(TARGET)/bin/test-hunspell.exe' \
+        `'$(TARGET)-pkg-config' hunspell --cflags --libs`
+endef
--- a/src/id3lib.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/id3lib.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/id3lib/files/id3lib/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/id3lib/files/id3lib/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/ilmbase.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/ilmbase.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.openexr.com/downloads.html' | \
+    $(WGET) -q -O- 'http://www.openexr.com/downloads.html' | \
     grep 'ilmbase-' | \
     $(SED) -n 's,.*ilmbase-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/imagemagick.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/imagemagick.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc bzip2 ffmpeg fftw freetype jasper jpeg lcms libpng libtool openexr pthreads tiff
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.imagemagick.org/' | \
+    $(WGET) -q -O- 'http://www.imagemagick.org/' | \
     $(SED) -n 's,.*<p>The current release is ImageMagick \([0-9][^<]*\).</p>.*,\1,p' | \
     head -1
 endef
--- a/src/jasper.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/jasper.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.ece.uvic.ca/~mdadams/jasper/' | \
+    $(WGET) -q -O- 'http://www.ece.uvic.ca/~mdadams/jasper/' | \
     grep 'jasper-' | \
     $(SED) -n 's,.*jasper-\([0-9][^>]*\)\.zip.*,\1,p' | \
     head -1
--- a/src/jpeg.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/jpeg.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.ijg.org/' | \
+    $(WGET) -q -O- 'http://www.ijg.org/' | \
     $(SED) -n 's,.*jpegsrc\.v\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/json-c-1-patch-missingfile.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,15 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains a fix for issue 35 on json-c (https://github.com/json-c/json-c/issues/35)
+
+--- a/Makefile.am	2012-07-17 22:52:19.000000000 +0200
++++ b/Makefile.am	2012-07-17 22:54:09.000000000 +0200
+@@ -17,6 +17,7 @@
+ 	json_config.h \
+ 	json_inttypes.h \
+ 	json_object.h \
++	json_object_iterator.h \
+ 	json_object_private.h \
+ 	json_tokener.h \
+ 	json_util.h \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/json-c-2-patch-remove-rpl.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,16 @@
+This file is part of MXE.
+See index.html for further information.
+
+see http://lists.fedoraproject.org/pipermail/mingw/2009-May/001567.html
+
+--- a/configure.in	2012-07-12 01:57:09.000000000 +0200
++++ b/configure.in	2012-07-12 01:59:06.000000000 +0200
+@@ -25,8 +25,6 @@
+ # Checks for library functions.
+ AC_FUNC_VPRINTF
+ AC_FUNC_MEMCMP
+-AC_FUNC_MALLOC
+-AC_FUNC_REALLOC
+ AC_CHECK_FUNCS(strndup strerror vsnprintf vasprintf open vsyslog strncasecmp)
+ 
+ AM_PROG_LIBTOOL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/json-c-test.c	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,23 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <json/json.h>
+#include <stdio.h> 
+
+int main(int argc, char *argv[])
+{
+    json_object *jobj;
+
+    (void)argc;
+    (void)argv;
+
+    jobj = json_object_new_object();
+    if (!jobj) {
+        return 1;
+    }
+    json_object_object_add(jobj, "key", json_object_new_string("value"));
+    printf("%s", json_object_to_json_string(jobj));
+    return 0;
+}
--- a/src/json-c.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/json-c.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,23 +3,31 @@
 
 PKG             := json-c
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := daaf5eb960fa98e137abc5012f569b83c79be90f
+$(PKG)_CHECKSUM := f90f643c8455da21d57b3e8866868a944a93c596
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://oss.metaparadigm.com/$(PKG)/$($(PKG)_FILE)
+$(PKG)_URL      := https://github.com/downloads/$(PKG)/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://oss.metaparadigm.com/json-c/?C=M;O=D' | \
-    $(SED) -n 's,.*json-c-\([0-9][^>]*\)\.tar.*,\1,p' | \
+    $(WGET) - q -O 'https://github.com/json-c/json-c/downloads' | \
+    grep '<a href="/downloads/json-c/json-c/' | \
+    $(SED) -n -s,.*href="/downloads/json-c/json-c/json-c-\([0-9.]*\).tar.gz,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
+    cd '$(1)' && ./autogen.sh
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
         --prefix='$(PREFIX)/$(TARGET)' \
         --build="`config.guess`"\
+        --disable-shared
         CFLAGS=-Wno-error
     $(MAKE) -C '$(1)' -j '$(JOBS)' install
+	
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-json-c.exe' \
+        `'$(TARGET)-pkg-config' json --cflags --libs`
 endef
--- a/src/lame.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/lame.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/lame/files/lame/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/lame/files/lame/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/lapack.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/lapack.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -2,8 +2,7 @@
 # See index.html for further information.
 
 PKG             := lapack
-$(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 910109a931524f8dcc2734ce23fe927b00ca199f
+$(PKG)_CHECKSUM := 93a6e4e6639aaf00571d53a580ddc415416e868b
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tgz
 $(PKG)_URL      := http://www.netlib.org/$(PKG)/$($(PKG)_FILE)
@@ -11,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.netlib.org/lapack/' | \
+    $(WGET) -q -O- 'http://www.netlib.org/lapack/' | \
     $(SED) -n 's_.*>LAPACK, version \([0-9]\.[0-9]\.[0-9]\).*_\1_ip' | \
     head -1
 endef
--- a/src/lcms.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/lcms.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := lcms
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 67d5fabda2f5777ca8387766539b9c871d993133
+$(PKG)_CHECKSUM := 9944902864283af49e4e21a1ca456db4e04ea7c2
 $(PKG)_SUBDIR   := $(PKG)$(word 1,$(subst ., ,$($(PKG)_VERSION)))-$(subst a,,$($(PKG)_VERSION))
 $(PKG)_FILE     := $(PKG)$(word 1,$(subst ., ,$($(PKG)_VERSION)))-$(subst a,,$($(PKG)_VERSION)).tar.gz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$(subst a,,$($(PKG)_VERSION))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc jpeg tiff zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/lcms/files/lcms/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/lcms/files/lcms/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/lcms1.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/lcms1.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg tiff zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/lcms/files/lcms/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/lcms/files/lcms/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     grep '^1\.' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/levmar.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,25 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := levmar
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 118bd20b55ab828d875f1b752cb5e1238258950b
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tgz
+$(PKG)_URL      := http://www.ics.forth.gr/~lourakis/$(PKG)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc lapack blas libf2c
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- "http://www.ics.forth.gr/~lourakis/levmar/"  | \
+    $(SED) -n 's_.*Latest:.*levmar-\([0-9]\.[0-9]\).*_\1_ip' | \
+    head -1;
+endef
+
+define $(PKG)_BUILD
+    $(MAKE) -C '$(1)' -j '$(JOBS)' liblevmar.a \
+        CC=$(TARGET)-gcc \
+        AR=$(TARGET)-ar \
+        RANLIB=$(TARGET)-ranlib
+    $(INSTALL) -m644 '$(1)/levmar.h'    '$(PREFIX)/$(TARGET)/include/'
+    $(INSTALL) -m644 '$(1)/liblevmar.a' '$(PREFIX)/$(TARGET)/lib/'
+endef
--- a/src/libarchive.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libarchive.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc bzip2 libiconv libxml2 openssl xz zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://code.google.com/p/libarchive/downloads/list?sort=-uploaded' | \
+    $(WGET) -q -O- 'http://code.google.com/p/libarchive/downloads/list?sort=-uploaded' | \
     $(SED) -n 's,.*libarchive-\([0-9][^<]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libass.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libass.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freetype fontconfig fribidi
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://code.google.com/p/libass/downloads/list?sort=-uploaded' | \
+    $(WGET) -q -O- 'http://code.google.com/p/libass/downloads/list?sort=-uploaded' | \
     $(SED) -n 's,.*libass-\([0-9][^<]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libcroco.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libcroco.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libcroco/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libcroco/refs/tags' | \
     $(SED) -n 's,.*<a[^>]*>LIBCROCO_\([0-9][0-9_]*\)<.*,\1,p' | \
     $(SED) 's,_,.,g' | \
     head -1
--- a/src/libdnet.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libdnet.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc winpcap
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/libdnet/files/libdnet/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/libdnet/files/libdnet/' | \
     $(SED) -n 's,.*/libdnet-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libevent.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libevent.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libevent
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2a2cc87ce1945f43dfa5a5f9575fef3d14a8f57a
+$(PKG)_CHECKSUM := 20bb4a1a296ac93c08dfc32ae19ab874cab67a0c
 $(PKG)_SUBDIR   := libevent-$($(PKG)_VERSION)-stable
 $(PKG)_FILE     := libevent-$($(PKG)_VERSION)-stable.tar.gz
 $(PKG)_URL      := https://github.com/downloads/$(PKG)/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://libevent.org/' | \
+    $(WGET) -q -O- 'http://libevent.org/' | \
     grep 'libevent-' | \
     $(SED) -n 's,.*libevent-\([0-9][^>]*\)-stable\.tar.*,\1,p' | \
     head -1
@@ -19,6 +19,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= defexec_DATA=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libf2c-1.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,59 @@
+This file is part of MXE.
+See index.html for further information.
+
+diff -ur libf2c.orig/makefile.u libf2c/makefile.u
+--- libf2c.orig/makefile.u	2012-05-04 01:39:36.000000000 +1000
++++ libf2c/makefile.u	2012-05-04 01:45:30.000000000 +1000
+@@ -20,7 +20,7 @@
+ # compile, then strip unnecessary symbols
+ .c.o:
+ 	$(CC) -c -DSkip_f2c_Undefs $(CFLAGS) $*.c
+-	ld -r -x -o $*.xxx $*.o
++	$(LD) -r -x -o $*.xxx $*.o
+ 	mv $*.xxx $*.o
+ ## Under Solaris (and other systems that do not understand ld -x),
+ ## omit -x in the ld line above.
+@@ -72,8 +72,8 @@
+ all: f2c.h signal1.h sysdep1.h libf2c.a
+
+ libf2c.a: $(OFILES)
+-	ar r libf2c.a $?
+-	-ranlib libf2c.a
++	$(AR) r libf2c.a $?
++	-$(RANLIB) libf2c.a
+
+ ## Shared-library variant: the following rule works on Linux
+ ## systems.  Details are system-dependent.  Under Linux, -fPIC
+@@ -123,7 +123,7 @@
+
+ install: libf2c.a
+ 	cp libf2c.a $(LIBDIR)
+-	-ranlib $(LIBDIR)/libf2c.a
++	-$(RANLIB) $(LIBDIR)/libf2c.a
+
+ clean:
+ 	rm -f libf2c.a *.o arith.h signal1.h sysdep1.h
+@@ -182,12 +182,6 @@
+ xwsne.o:	lio.h
+ xwsne.o:	fmt.h
+
+-arith.h: arithchk.c
+-	$(CC) $(CFLAGS) -DNO_FPINIT arithchk.c -lm ||\
+-	 $(CC) -DNO_LONG_LONG $(CFLAGS) -DNO_FPINIT arithchk.c -lm
+-	./a.out >arith.h
+-	rm -f a.out arithchk.o
+-
+ check:
+ 	xsum Notice README abort_.c arithchk.c backspac.c c_abs.c c_cos.c \
+ 	c_div.c c_exp.c c_log.c c_sin.c c_sqrt.c cabs.c close.c comptry.bat \
+
+diff -urN tmp-libf2c.orig/arith.h tmp-libf2c/arith.h
+--- tmp-libf2c.orig/arith.h	1970-01-01 10:00:00.000000000 +1000
++++ tmp-libf2c/arith.h	2012-05-04 01:16:16.000000000 +1000
+@@ -0,0 +1,5 @@
++#define IEEE_8087
++#define Arith_Kind_ASL 1
++#define Double_Align
++#define QNaN0 0x0
++#define QNaN1 0xfff80000
++
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libf2c.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,25 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := libf2c
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := f71066b41695738dec2261de71eaf02a1aaffe8b
+$(PKG)_SUBDIR   :=
+$(PKG)_FILE     := $(PKG).zip
+$(PKG)_URL      := http://www.netlib.org/f2c/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    echo 1
+endef
+
+define $(PKG)_BUILD
+    $(MAKE) -C '$(1)' -j '$(JOBS)' -f makefile.u \
+        CC=$(TARGET)-gcc \
+        AR=$(TARGET)-ar \
+        LD=$(TARGET)-ld \
+        RANLIB=$(TARGET)-ranlib \
+        CFLAGS='-O -DUSE_CLOCK'
+    $(INSTALL) -m644 '$(1)/libf2c.a' '$(PREFIX)/$(TARGET)/lib'
+    $(INSTALL) -m644 '$(1)/f2c.h'    '$(PREFIX)/$(TARGET)/include'
+endef
--- a/src/libffi.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libffi.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libffi
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 97abf70e6a6d315d9259d58ac463663051d471e1
+$(PKG)_CHECKSUM := bff6a6c886f90ad5e30dee0b46676e8e0297d81d
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://sourceware.org/pub/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q --no-check-certificate -O- 'https://github.com/atgreen/libffi/tags' | \
+    $(WGET) -q -O- 'https://github.com/atgreen/libffi/tags' | \
     grep '<a href="/atgreen/libffi/tarball/' | \
     $(SED) -n 's,.*href="/atgreen/libffi/tarball/v\([0-9][^"]*\)".*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libgcrypt-test.c	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,32 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <stdio.h>
+#include <gcrypt.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    if (!gcry_check_version (GCRYPT_VERSION)) {
+        fputs ("libgcrypt version mismatch\n", stderr);
+        exit (2);
+    }
+
+    gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
+    gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
+    gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
+    gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+
+    if (!gcry_control (GCRYCTL_INITIALIZATION_FINISHED_P)) {
+       fputs ("libgcrypt has not been initialized\n", stderr);
+       abort ();
+    }
+
+    printf("gcrypt version: %s", GCRYPT_VERSION );
+
+    return 0;
+}
--- a/src/libgcrypt.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgcrypt.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libgpg_error
 
 define $(PKG)_UPDATE
-    wget -q -O- 'ftp://ftp.gnupg.org/gcrypt/libgcrypt/' | \
+    $(WGET) -q -O- 'ftp://ftp.gnupg.org/gcrypt/libgcrypt/' | \
     $(SED) -n 's,.*libgcrypt-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v '^1\.4\.' | \
     tail -1
@@ -24,4 +24,10 @@
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-gpg-error-prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+    ln -sf '$(PREFIX)/$(TARGET)/bin/libgcrypt-config' '$(PREFIX)/bin/$(TARGET)-libgcrypt-config'
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libgcrypt.exe' \
+        `$(TARGET)-libgcrypt-config --cflags --libs`
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libgda.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,38 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# LibGDA
+PKG             := libgda
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 61d0b498202b780750633cc2e957c40325d6c705
+$(PKG)_SUBDIR   := libgda-$($(PKG)_VERSION)
+$(PKG)_FILE     := libgda-$($(PKG)_VERSION).tar.xz
+$(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/libgda/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc glib libxml2 mdbtools postgresql
+
+define $(PKG)_UPDATE
+    echo 'TODO: Updates for package libgda need to be fixed.' >&2;
+    echo $(libgda_VERSION)
+endef
+
+define $(PKG)_BUILD
+    $(SED) -i 's,glib-mkenums,'$(PREFIX)/$(TARGET)/bin/glib-mkenums',g' '$(1)/libgda/Makefile.in'
+    $(SED) -i 's,glib-mkenums,'$(PREFIX)/$(TARGET)/bin/glib-mkenums',g' '$(1)/libgda/sql-parser/Makefile.in'
+    $(SED) -i 's,glib-mkenums,'$(PREFIX)/$(TARGET)/bin/glib-mkenums',g' '$(1)/libgda-ui/Makefile.in'
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --disable-shared \
+        --disable-gtk-doc \
+        --without-bdb \
+        --with-mdb \
+        --without-oracle \
+        --without-mysql \
+        --without-firebird \
+        --without-java \
+        --enable-binreloc \
+        --disable-crypto \
+        GLIB_GENMARSHAL='$(PREFIX)/$(TARGET)/bin/glib-genmarshal'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libgdamm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,28 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# libgdamm
+PKG             := libgdamm
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := f6126d7b46720e3ea4f3d49e03add2e52da233be
+$(PKG)_SUBDIR   := libgdamm-$($(PKG)_VERSION)
+$(PKG)_FILE     := libgdamm-$($(PKG)_VERSION).tar.xz
+$(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/libgdamm/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc libgda glibmm
+
+define $(PKG)_UPDATE
+    echo 'TODO: Updates for package libgdamm need to be fixed.' >&2;
+    echo $(libgdamm_VERSION)
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        CXX='$(TARGET)-c++' \
+        PKG_CONFIG='$(PREFIX)/bin/$(TARGET)-pkg-config' \
+        MAKE=$(MAKE)
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+endef
--- a/src/libgee.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgee.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libgee/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libgee/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=LIBGEE_\\([0-9]*_[0-9]*_[^<]*\\)'.*,\\1,p" | \
     $(SED) 's,_,.,g' | \
--- a/src/libgeotiff.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgeotiff.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := libgeotiff
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := b8cde5014cf82fe4683fa35fc81a5ea8d64b940f
+$(PKG)_CHECKSUM := 4c6f405869826bb7d9f35f1d69167e3b44a57ef0
 $(PKG)_SUBDIR   := libgeotiff-$($(PKG)_VERSION)
 $(PKG)_FILE     := libgeotiff-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://download.osgeo.org/geotiff/libgeotiff/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib jpeg tiff proj
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://trac.osgeo.org/geotiff/' | \
+    $(WGET) -q -O- 'http://trac.osgeo.org/geotiff/' | \
     $(SED) -n 's,.*libgeotiff-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libglade.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,27 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := libglade
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 3cc65ed13c10025780488935313329170baa33c6
+$(PKG)_SUBDIR   := libglade-$($(PKG)_VERSION)
+$(PKG)_FILE     := libglade-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://ftp.gnome.org/pub/GNOME/sources/libglade/2.6/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc libxml2 atk glib gtk2
+
+define $(PKG)_UPDATE
+    wget -q -O- 'http://ftp.gnome.org/pub/GNOME/sources/libglade/2.6/' | \
+    $(SED) -n 's,.*"libglade-\([0-9][^"]*\)\.tar.gz.*,\1,p' | \
+    tail -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        PKG_CONFIG='$(PREFIX)/bin/$(TARGET)-pkg-config'
+    $(MAKE) -C '$(1)' -j '$(JOBS)'
+    $(MAKE) -C '$(1)' -j 1 install-exec
+endef
--- a/src/libgnurx.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgnurx.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mingw/files/Other/UserContributed/regex/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw/files/Other/UserContributed/regex/' | \
     grep 'mingw-regex-' | \
     $(SED) -n 's,.*mingw-regex-\([0-9\.]*\).*,\1,p' | \
     sort | \
--- a/src/libgpg_error.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgpg_error.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'ftp://ftp.gnupg.org/gcrypt/libgpg-error/' | \
+    $(WGET) -q -O- 'ftp://ftp.gnupg.org/gcrypt/libgpg-error/' | \
     $(SED) -n 's,.*libgpg-error-\([1-9]\.[1-9][0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
 endef
--- a/src/libgsasl-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgsasl-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -13,7 +13,7 @@
 index 7fec454..d9b62cd 100644
 --- a/gl/memxor.c
 +++ b/gl/memxor.c
-@@ -23,7 +23,7 @@
+@@ -22,7 +22,7 @@
  #include "memxor.h"
  
  void *
--- a/src/libgsasl.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgsasl.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libgsasl
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2942886514f14801193e505fc5367330d5c6b7de
+$(PKG)_CHECKSUM := 08fd5dfdd3d88154cf06cb0759a732790c47b4f7
 $(PKG)_SUBDIR   := libgsasl-$($(PKG)_VERSION)
 $(PKG)_FILE     := libgsasl-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://ftp.gnu.org/gnu/gsasl/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libiconv libidn libntlm libgcrypt nettle
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gsasl.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gsasl.git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     head -1
--- a/src/libgsf-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgsf-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -13,7 +13,7 @@
 index d7a7247..cc52d99 100644
 --- a/gsf/gsf-utils.c
 +++ b/gsf/gsf-utils.c
-@@ -119,9 +119,9 @@ static GTypeModule *static_type_module = NULL;
+@@ -115,9 +115,9 @@ static GTypeModule *static_type_module = NULL;
  #include <windows.h>
  static HMODULE gsf_dll_hmodule;
  BOOL WINAPI
--- a/src/libgsf.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libgsf.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libgsf
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := ca1c5aa92a840e322d7cafd9f2dede3d38a69660
+$(PKG)_CHECKSUM := 4f19933342b2d42246200e3522b0797a032fdf19
 $(PKG)_SUBDIR   := libgsf-$($(PKG)_VERSION)
 $(PKG)_FILE     := libgsf-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/libgsf/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib bzip2 glib libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libgsf/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libgsf/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=LIBGSF_\\([0-9]*_[0-9]*[02468]_[^<]*\\)'.*,\\1,p" | \
     $(SED) 's,_,.,g' | \
@@ -22,14 +22,12 @@
     echo 'Libs.private: -lz -lbz2'          >> '$(1)'/libgsf-1.pc.in
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-nls \
         --disable-gtk-doc \
-        --disable-schemas-install \
         --without-python \
-        --without-gnome-vfs \
-        --without-bonobo \
         --with-zlib \
         --with-bz2 \
         --with-gio \
--- a/src/libharu.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libharu.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib libpng
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://libharu.org/files/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://libharu.org/files/?C=M;O=D' | \
     $(SED) -n 's,.*libharu-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v 'rc' | \
     head -1
--- a/src/libical.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libical.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -9,7 +9,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/freeassociation/files/$(PKG)/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/freeassociation/files/$(PKG)/' | \
     $(SED) -n 's,.*/$(PKG)-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libiconv.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libiconv.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.gnu.org/software/libiconv/' | \
+    $(WGET) -q -O- 'http://www.gnu.org/software/libiconv/' | \
     grep 'libiconv-' | \
     $(SED) -n 's,.*libiconv-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/libidn.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libidn.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libidn
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 4251c108966375ede4df15d76a1bd9a4440f44ee
+$(PKG)_CHECKSUM := 92e64fd5a6428bda6ade2c3cde475b76455cd7dd
 $(PKG)_SUBDIR   := libidn-$($(PKG)_VERSION)
 $(PKG)_FILE     := libidn-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://ftp.gnu.org/gnu/libidn/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gettext libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=libidn.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=libidn.git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/libircclient.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libircclient.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/libircclient/files/libircclient/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/libircclient/files/libircclient/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/liblo.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/liblo.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/liblo/files/liblo/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/liblo/files/liblo/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libmad.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libmad.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mad/files/libmad/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mad/files/libmad/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libmikmod.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libmikmod.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://mikmod.raphnet.net/' | \
+    $(WGET) -q -O- 'http://mikmod.raphnet.net/' | \
     $(SED) -n 's,.*libmikmod-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libmng.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libmng.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib jpeg lcms1
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/libmng/files/libmng-devel/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/libmng/files/libmng-devel/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libmodplug-test.c	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,17 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <modplug.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    ModPlug_Settings settings;
+    ModPlug_GetSettings(&settings);
+    ModPlug_SetSettings(&settings);
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libmodplug.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,31 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# libmodplug
+PKG             := libmodplug
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := df4deffe542b501070ccb0aee37d875ebb0c9e22
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/modplug-xmms/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/modplug-xmms/files/libmodplug/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --disable-shared \
+        --enable-static \
+        --prefix='$(PREFIX)/$(TARGET)'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+
+    '$(TARGET)-gcc' \
+        -W -Wall -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libmodplug.exe' \
+        `'$(TARGET)-pkg-config' libmodplug --cflags --libs`
+endef
--- a/src/libntlm.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libntlm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=libntlm.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=libntlm.git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/liboauth.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/liboauth.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := liboauth
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 9182ca5d7e127589d132377b807d0c8a8878b122
+$(PKG)_CHECKSUM := a5a957ac1538b23a286de4e39a2c9f98ef4c3c0e
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://liboauth.sourceforge.net/pool/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc curl openssl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://liboauth.sourceforge.net/' | \
+    $(WGET) -q -O- 'http://liboauth.sourceforge.net/' | \
     $(SED) -n 's,.*liboauth-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libodbc++.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libodbc++.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://libodbcxx.svn.sourceforge.net/viewvc/libodbcxx/tags/?sortby=date' | \
+    $(WGET) -q -O- 'http://libodbcxx.svn.sourceforge.net/viewvc/libodbcxx/tags/?sortby=date' | \
     grep '<a name="' | \
     $(SED) -n 's,.*<a name="libodbc++-\([0-9][^"]*\)".*,\1,p' | \
     head -1
--- a/src/liboil.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/liboil.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/liboil/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/liboil/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
--- a/src/libpano13.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libpano13.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg tiff libpng zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/api/file/index/project-id/96188/rss?path=/libpano13' | \
+    $(WGET) -q -O- 'http://sourceforge.net/api/file/index/project-id/96188/rss?path=/libpano13' | \
     $(SED) -n 's,.*libpano13-\([0-9].*\)\.tar.*,\1,p' | \
     tail -1
 endef
--- a/src/libpaper.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libpaper.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := libpaper
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 1f7a810a433a5a68b099aa92777cc2d0b3d03b42
+$(PKG)_CHECKSUM := 40f16453d7752bf5e3c9e74515650eb37edbb3fe
 $(PKG)_SUBDIR   := libpaper-$($(PKG)_VERSION)
 $(PKG)_FILE     := libpaper_$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://ftp.debian.org/debian/pool/main/libp/$(PKG)/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://packages.debian.org/unstable/source/libpaper' | \
+    $(WGET) -q -O- 'http://packages.debian.org/unstable/source/libpaper' | \
     $(SED) -n 's,.*libpaper_\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -19,6 +19,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
--- a/src/libpng.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libpng.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := libpng
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := bfa655f04965545a54dc974e50c2325968ca5a71
+$(PKG)_CHECKSUM := a6c0fc33b2031e4a9154da03c7d4e7807bc039e7
 $(PKG)_SUBDIR   := libpng-$($(PKG)_VERSION)
 $(PKG)_FILE     := libpng-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)$(subst .,,$(call SHORT_PKG_VERSION,$(PKG)))/older-releases/$($(PKG)_VERSION)/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng/libpng;a=tags' | \
+    $(WGET) -q -O- 'http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng/libpng;a=tags' | \
     grep '<a class="list name"' | \
     $(SED) -n 's,.*<a[^>]*>v\([0-9][^<]*\)<.*,\1,p' | \
     grep -v alpha | \
@@ -24,6 +24,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
--- a/src/librsvg-test.c	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/librsvg-test.c	Mon Oct 08 22:34:44 2012 +0200
@@ -14,7 +14,7 @@
 
     g_type_init();
     handle = rsvg_handle_new();
-    rsvg_handle_free(handle);
+    g_object_unref(handle);
 
     return 0;
 }
--- a/src/librsvg.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/librsvg.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := librsvg
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 11a2dc00c813da13532d7f16a822b414201e8b1b
+$(PKG)_CHECKSUM := 8ac22591c9db273355cf895f7e87aac149f64437
 $(PKG)_SUBDIR   := librsvg-$($(PKG)_VERSION)
 $(PKG)_FILE     := librsvg-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/GNOME/sources/librsvg/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib libgsf cairo pango gtk2 libcroco
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/librsvg/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/librsvg/refs/tags' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/librtmp-1-v2.4.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,2699 @@
+From 272a91d06d71c2a326996f62797ed9ab42f69859 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Wed, 30 Jun 2010 22:34:59 +0000
+Subject: [PATCH 01/34] zlib dependency is only when CRYPTO is enabled
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@536 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile          |    9 +++++----
+ librtmp/hashswf.c |    4 ++--
+ 2 files changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 7470eb4..c7767b4 100644
+--- a/Makefile
++++ b/Makefile
+@@ -11,9 +11,10 @@ SYS=posix
+ CRYPTO=OPENSSL
+ #CRYPTO=POLARSSL
+ #CRYPTO=GNUTLS
+-LIB_GNUTLS=-lgnutls -lgcrypt
+-LIB_OPENSSL=-lssl -lcrypto
+-LIB_POLARSSL=-lpolarssl
++LIBZ=-lz
++LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
++LIB_OPENSSL=-lssl -lcrypto$ (LIBZ)
++LIB_POLARSSL=-lpolarssl $(LIBZ)
+ CRYPTO_LIB=$(LIB_$(CRYPTO))
+ DEF_=-DNO_CRYPTO
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+@@ -33,7 +34,7 @@ MANDIR=$(DESTDIR)$(mandir)
+ 
+ LIBS_posix=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIBS=$(CRYPTO_LIB) -lz $(LIBS_$(SYS)) $(XLIBS)
++LIBS=$(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
+ THREADLIB_mingw=
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 06d2bbb..277f21c 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -66,10 +66,10 @@
+ extern void RTMP_TLS_Init();
+ extern TLS_CTX RTMP_TLS_ctx;
+ 
+-#endif /* CRYPTO */
+-
+ #include <zlib.h>
+ 
++#endif /* CRYPTO */
++
+ #define	AGENT	"Mozilla/5.0"
+ 
+ HTTPResult
+-- 
+1.7.10.4
+
+
+From 6556b9f9328acb1199dc1cc3f22fa82c86b51c8a Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 1 Jul 2010 12:00:43 +0000
+Subject: [PATCH 02/34] Fix typo
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@537 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index c7767b4..1fcdd78 100644
+--- a/Makefile
++++ b/Makefile
+@@ -13,7 +13,7 @@ CRYPTO=OPENSSL
+ #CRYPTO=GNUTLS
+ LIBZ=-lz
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+-LIB_OPENSSL=-lssl -lcrypto$ (LIBZ)
++LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ CRYPTO_LIB=$(LIB_$(CRYPTO))
+ DEF_=-DNO_CRYPTO
+-- 
+1.7.10.4
+
+
+From 8a5901c8a74280c898deb4ebf1a2f5d6f68bce42 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Sat, 3 Jul 2010 10:25:48 +0000
+Subject: [PATCH 03/34] Document the escape coding used for special characters
+ in values
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@538 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/librtmp.3 |   11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/librtmp/librtmp.3 b/librtmp/librtmp.3
+index 055b52b..a5a7558 100644
+--- a/librtmp/librtmp.3
++++ b/librtmp/librtmp.3
+@@ -57,14 +57,19 @@ The session handle is freed using
+ .BR RTMP_Free ().
+ 
+ All data is transferred using FLV format. The basic session requires
+-an RTMP URL. Additional options may be specified by appending
+-space-separated key=value pairs to the URL. The RTMP URL format
+-is of the form
++an RTMP URL.  The RTMP URL format is of the form
+ .nf
+   rtmp[t][e|s]://hostname[:port][/app[/playpath]]
+ .fi
+ 
+ Plain rtmp, as well as tunneled and encrypted sessions are supported.
++
++Additional options may be specified by appending space-separated
++key=value pairs to the URL. Special characters in values may need
++to be escaped to prevent misinterpretation by the option parser.
++The escape encoding uses a backslash followed by two hexadecimal digits
++representing the ASCII value of the character. E.g., spaces must
++be escaped as \fB\\20\fP and backslashes must be escaped as \fB\\5c\fP.
+ .SH OPTIONS
+ .SS "Network Parameters"
+ These options define how to connect to the media server.
+-- 
+1.7.10.4
+
+
+From c41568f57bec297581e8508a7e6a3d1e470dc81d Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Sat, 3 Jul 2010 10:28:57 +0000
+Subject: [PATCH 04/34] Update from prev commit
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@539 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/librtmp.3      |    2 +-
+ librtmp/librtmp.3.html |   13 +++++++++----
+ 2 files changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/librtmp/librtmp.3 b/librtmp/librtmp.3
+index a5a7558..66197d5 100644
+--- a/librtmp/librtmp.3
++++ b/librtmp/librtmp.3
+@@ -1,4 +1,4 @@
+-.TH LIBRTMP 3 "2010-05-29" "RTMPDump v2.2e"
++.TH LIBRTMP 3 "2010-07-03" "RTMPDump v2.3"
+ .\" Copyright 2010 Howard Chu.
+ .\" Copying permitted according to the GNU General Public License V2.
+ .SH NAME
+diff --git a/librtmp/librtmp.3.html b/librtmp/librtmp.3.html
+index daf636f..e5e6f4b 100644
+--- a/librtmp/librtmp.3.html
++++ b/librtmp/librtmp.3.html
+@@ -6,7 +6,7 @@
+ <tr><td>LIBRTMP(3)<td align="center"><td align="right">LIBRTMP(3)
+ </thead>
+ <tfoot>
+-<tr><td>RTMPDump v2.2e<td align="center">2010-05-29<td align="right">LIBRTMP(3)
++<tr><td>RTMPDump v2.3<td align="center">2010-07-03<td align="right">LIBRTMP(3)
+ </tfoot>
+ <tbody><tr><td colspan="3"><br><br><ul>
+ <!-- Copyright 2010 Howard Chu.
+@@ -75,14 +75,19 @@ The session handle is freed using
+ <b>RTMP_Free</b>().
+ <p>
+ All data is transferred using FLV format. The basic session requires
+-an RTMP URL. Additional options may be specified by appending
+-space-separated key=value pairs to the URL. The RTMP URL format
+-is of the form
++an RTMP URL.  The RTMP URL format is of the form
+ <pre>
+   rtmp[t][e|s]://hostname[:port][/app[/playpath]]
+ </pre>
+ <p>
+ Plain rtmp, as well as tunneled and encrypted sessions are supported.
++<p>
++Additional options may be specified by appending space-separated
++key=value pairs to the URL. Special characters in values may need
++to be escaped to prevent misinterpretation by the option parser.
++The escape encoding uses a backslash followed by two hexadecimal digits
++representing the ASCII value of the character. E.g., spaces must
++be escaped as <b>\20</b> and backslashes must be escaped as <b>\5c</b>.
+ </ul>
+ 
+ <h3>OPTIONS</h3><ul>
+-- 
+1.7.10.4
+
+
+From f1c4f0ed07659cbeae4ffaa78ca8cce7500afa58 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 5 Jul 2010 20:07:39 +0000
+Subject: [PATCH 05/34] Hide strtime()
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@541 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/hashswf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 277f21c..23e754b 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -435,7 +435,7 @@ make_unix_time(char *s)
+ /* Convert a Unix time to a network time string
+  * Weekday, DD-MMM-YYYY HH:MM:SS GMT
+  */
+-void
++static void
+ strtime(time_t * t, char *s)
+ {
+   struct tm *tm;
+-- 
+1.7.10.4
+
+
+From da78eba764eda23fb3bf9aa91bd6c5fee1839932 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 5 Jul 2010 20:16:55 +0000
+Subject: [PATCH 06/34] Remove obsolete XBOX defs
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@542 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp_sys.h |   11 ++++-------
+ 1 file changed, 4 insertions(+), 7 deletions(-)
+
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index 0874cbe..6a3f215 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -24,17 +24,14 @@
+ 
+ #ifdef _WIN32
+ 
+-#ifdef _XBOX
+-#include <xtl.h>
+-#include <winsockx.h>
++#include <winsock2.h>
++#include <ws2tcpip.h>
++
++#ifdef _MSC_VER	/* MSVC */
+ #define snprintf _snprintf
+ #define strcasecmp stricmp
+ #define strncasecmp strnicmp
+ #define vsnprintf _vsnprintf
+-
+-#else /* !_XBOX */
+-#include <winsock2.h>
+-#include <ws2tcpip.h>
+ #endif
+ 
+ #define GetSockError()	WSAGetLastError()
+-- 
+1.7.10.4
+
+
+From eef87483b92036a1631c98c9c85dc3cae66411ee Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 5 Jul 2010 20:17:16 +0000
+Subject: [PATCH 07/34] Update XBOX/XBMC support
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@543 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/hashswf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 23e754b..3c56b69 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -466,7 +466,7 @@ RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash,
+ 
+   date[0] = '\0';
+ #ifdef _WIN32
+-#ifdef _XBOX
++#ifdef XBMC4XBOX
+   hpre.av_val = "Q:";
+   hpre.av_len = 2;
+   home.av_val = "\\UserData";
+-- 
+1.7.10.4
+
+
+From 24f7e724fc10d737a0f14c7741711b6b542c9d45 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 8 Jul 2010 10:38:33 +0000
+Subject: [PATCH 08/34] Don't link explicitly against static library
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@544 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile |   27 +++++++++++++--------------
+ 1 file changed, 13 insertions(+), 14 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 1fcdd78..741e438 100644
+--- a/Makefile
++++ b/Makefile
+@@ -34,7 +34,7 @@ MANDIR=$(DESTDIR)$(mandir)
+ 
+ LIBS_posix=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIBS=$(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
++LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
+ THREADLIB_mingw=
+@@ -48,9 +48,11 @@ EXT_posix=
+ EXT_mingw=.exe
+ EXT=$(EXT_$(SYS))
+ 
+-all:	$(LIBRTMP) progs
++PROGS=rtmpdump rtmpgw rtmpsrv rtmpsuck
+ 
+-progs:	rtmpdump rtmpgw rtmpsrv rtmpsuck
++all:	$(LIBRTMP) $(PROGS)
++
++$(PROGS): $(LIBRTMP)
+ 
+ install:	progs
+ 	-mkdir -p $(BINDIR) $(SBINDIR) $(MANDIR)/man1 $(MANDIR)/man8
+@@ -69,20 +71,17 @@ FORCE:
+ $(LIBRTMP): FORCE
+ 	@cd librtmp; $(MAKE) all
+ 
+-# note: $^ is GNU Make's equivalent to BSD $>
+-# we use both since either make will ignore the one it doesn't recognize
+-
+-rtmpdump: rtmpdump.o $(LIBRTMP)
+-	$(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(LIBS)
++rtmpdump: rtmpdump.o
++	$(CC) $(LDFLAGS) -o $@$(EXT) $@.o $(LIBS)
+ 
+-rtmpsrv: rtmpsrv.o thread.o $(LIBRTMP)
+-	$(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
++rtmpsrv: rtmpsrv.o thread.o
++	$(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
+ 
+-rtmpsuck: rtmpsuck.o thread.o $(LIBRTMP)
+-	$(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
++rtmpsuck: rtmpsuck.o thread.o
++	$(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
+ 
+-rtmpgw: rtmpgw.o thread.o $(LIBRTMP)
+-	$(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
++rtmpgw: rtmpgw.o thread.o
++	$(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
+ 
+ rtmpgw.o: rtmpgw.c $(INCRTMP) Makefile
+ rtmpdump.o: rtmpdump.c $(INCRTMP) Makefile
+-- 
+1.7.10.4
+
+
+From 5a3d6003a9745595583015c5b3b24e7bea818790 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 8 Jul 2010 11:11:47 +0000
+Subject: [PATCH 09/34] Fix install target
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@545 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 741e438..75628dd 100644
+--- a/Makefile
++++ b/Makefile
+@@ -54,7 +54,7 @@ all:	$(LIBRTMP) $(PROGS)
+ 
+ $(PROGS): $(LIBRTMP)
+ 
+-install:	progs
++install:	$(PROGS)
+ 	-mkdir -p $(BINDIR) $(SBINDIR) $(MANDIR)/man1 $(MANDIR)/man8
+ 	cp rtmpdump$(EXT) $(BINDIR)
+ 	cp rtmpgw$(EXT) rtmpsrv$(EXT) rtmpsuck$(EXT) $(SBINDIR)
+-- 
+1.7.10.4
+
+
+From 2340f0e27cd21d624d5f915fc42182750be6fca6 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 12 Jul 2010 08:20:04 +0000
+Subject: [PATCH 10/34] MacOSX/Darwin shared library flags
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@546 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile         |    3 +++
+ README           |    6 +++++-
+ librtmp/Makefile |   11 ++++++++++-
+ 3 files changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 75628dd..fda3c74 100644
+--- a/Makefile
++++ b/Makefile
+@@ -33,10 +33,12 @@ SBINDIR=$(DESTDIR)$(sbindir)
+ MANDIR=$(DESTDIR)$(mandir)
+ 
+ LIBS_posix=
++LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+ LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
++THREADLIB_darwin=-lpthread
+ THREADLIB_mingw=
+ THREADLIB=$(THREADLIB_$(SYS))
+ SLIBS=$(THREADLIB) $(LIBS)
+@@ -45,6 +47,7 @@ LIBRTMP=librtmp/librtmp.a
+ INCRTMP=librtmp/rtmp_sys.h librtmp/rtmp.h librtmp/log.h librtmp/amf.h
+ 
+ EXT_posix=
++EXT_darwin=
+ EXT_mingw=.exe
+ EXT=$(EXT_$(SYS))
+ 
+diff --git a/README b/README
+index 6607a1d..5689853 100644
+--- a/README
++++ b/README
+@@ -10,7 +10,11 @@ To compile type "make" with SYS=<platform name>, e.g.
+ 
+   $ make SYS=posix
+ 
+-for Linux, MacOSX, Unix, etc. or
++for Linux, Unix, etc. or
++
++  $ make SYS=darwin
++
++for MacOSX or
+ 
+   $ make SYS=mingw
+ 
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 6774db7..2fd5869 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -17,6 +17,7 @@ REQ_GNUTLS=gnutls
+ REQ_OPENSSL=libssl,libcrypto
+ LIBZ=-lz
+ LIBS_posix=
++LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+@@ -26,9 +27,16 @@ CRYPTO_REQ=$(REQ_$(CRYPTO))
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ 
+ SO_posix=so.0
++SO_darwin=so.0
+ SO_mingw=dll
+ SO_EXT=$(SO_$(SYS))
+ 
++SO_LDFLAGS_posix=-shared -Wl,-soname,$@
++SO_LDFLAGS_darwin=-bundle -flat_namespace -undefined suppress -fno-common \
++	-headerpad_max_install_names
++SO_LDFLAGS_mingw=
++SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
++
+ SHARED=yes
+ SODEF_yes=-fPIC
+ SOLIB_yes=librtmp.$(SO_EXT)
+@@ -40,6 +48,7 @@ SO_INST=$(SOINST_$(SHARED))
+ DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF)
+ OPT=-O2
+ CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
++LDFLAGS=$(XLDFLAGS)
+ 
+ incdir=$(prefix)/include/librtmp
+ bindir=$(prefix)/bin
+@@ -61,7 +70,7 @@ librtmp.a: $(OBJS)
+ 	$(AR) rs $@ $?
+ 
+ librtmp.$(SO_EXT): $(OBJS)
+-	$(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
++	$(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
+ 	ln -sf $@ librtmp.so
+ 
+ log.o: log.c log.h Makefile
+-- 
+1.7.10.4
+
+
+From 13798268e10fc8c56eecf5fce297375f7fca1526 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 9 Aug 2010 21:46:31 +0000
+Subject: [PATCH 11/34] Fixes for Darwin - use dylib, not bundle for shared
+ lib
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@547 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile         |    2 +-
+ librtmp/Makefile |   17 +++++++++++------
+ 2 files changed, 12 insertions(+), 7 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index fda3c74..c322e9a 100644
+--- a/Makefile
++++ b/Makefile
+@@ -35,7 +35,7 @@ MANDIR=$(DESTDIR)$(mandir)
+ LIBS_posix=
+ LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
++LIBS=-Llibrtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
+ THREADLIB_darwin=-lpthread
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 2fd5869..a4bf67e 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -26,13 +26,14 @@ CRYPTO_LIB=$(LIB_$(CRYPTO)) $(LIBS_$(SYS))
+ CRYPTO_REQ=$(REQ_$(CRYPTO))
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ 
+-SO_posix=so.0
+-SO_darwin=so.0
++SO_VERSION=0
++SO_posix=so.$(SO_VERSION)
++SO_darwin=$(SO_VERSION).dylib
+ SO_mingw=dll
+ SO_EXT=$(SO_$(SYS))
+ 
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+-SO_LDFLAGS_darwin=-bundle -flat_namespace -undefined suppress -fno-common \
++SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+ 	-headerpad_max_install_names
+ SO_LDFLAGS_mingw=
+ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+@@ -92,9 +93,13 @@ install_base:	librtmp.a librtmp.pc
+ 	cp librtmp.pc $(LIBDIR)/pkgconfig
+ 	cp librtmp.3 $(MANDIR)/man3
+ 
+-install_so.0:	librtmp.so.0
+-	cp librtmp.so.0 $(LIBDIR)
+-	cd $(LIBDIR); ln -sf librtmp.so.0 librtmp.so
++install_so.$(SO_VERSION):	librtmp.$(SO_EXT)
++	cp librtmp.$(SO_EXT) $(LIBDIR)
++	cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.so
++
++install_$(SO_VERSION).dylib:	librtmp.$(SO_EXT)
++	cp librtmp.$(SO_EXT) $(LIBDIR)
++	cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.dylib
+ 
+ install_dll:	librtmp.dll
+ 	cp librtmp.dll $(BINDIR)
+-- 
+1.7.10.4
+
+
+From eb806247dc8eab25d8a675a4f633d3feaf2b2045 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Tue, 10 Aug 2010 06:41:50 +0000
+Subject: [PATCH 12/34] More dynlib tweaks
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@548 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/Makefile |   48 ++++++++++++++++++++++++++----------------------
+ 1 file changed, 26 insertions(+), 22 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index a4bf67e..6a1b08b 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -2,6 +2,15 @@ VERSION=v2.3
+ 
+ prefix=/usr/local
+ 
++incdir=$(prefix)/include/librtmp
++bindir=$(prefix)/bin
++libdir=$(prefix)/lib
++mandir=$(prefix)/man
++BINDIR=$(DESTDIR)$(bindir)
++INCDIR=$(DESTDIR)$(incdir)
++LIBDIR=$(DESTDIR)$(libdir)
++MANDIR=$(DESTDIR)$(mandir)
++
+ CC=$(CROSS_COMPILE)gcc
+ LD=$(CROSS_COMPILE)ld
+ AR=$(CROSS_COMPILE)ar
+@@ -27,11 +36,20 @@ CRYPTO_REQ=$(REQ_$(CRYPTO))
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ 
+ SO_VERSION=0
+-SO_posix=so.$(SO_VERSION)
+-SO_darwin=$(SO_VERSION).dylib
++SOX_posix=so
++SOX_darwin=dylib
++SOX_mingw=so	# useless
++SOX=$(SOX_$(SYS))
++SO_posix=$(SOX).$(SO_VERSION)
++SO_darwin=$(SO_VERSION).$(SOX)
+ SO_mingw=dll
+ SO_EXT=$(SO_$(SYS))
+ 
++SODIR_posix=$(LIBDIR)
++SODIR_darwin=$(LIBDIR)
++SODIR_mingw=$(BINDIR)
++SODIR=$(SODIR_$(SYS))
++
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+ SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+ 	-headerpad_max_install_names
+@@ -41,7 +59,7 @@ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+ SHARED=yes
+ SODEF_yes=-fPIC
+ SOLIB_yes=librtmp.$(SO_EXT)
+-SOINST_yes=install_$(SO_EXT)
++SOINST_yes=install_so
+ SO_DEF=$(SODEF_$(SHARED))
+ SO_LIB=$(SOLIB_$(SHARED))
+ SO_INST=$(SOINST_$(SHARED))
+@@ -51,28 +69,20 @@ OPT=-O2
+ CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
+ LDFLAGS=$(XLDFLAGS)
+ 
+-incdir=$(prefix)/include/librtmp
+-bindir=$(prefix)/bin
+-libdir=$(prefix)/lib
+-mandir=$(prefix)/man
+-BINDIR=$(DESTDIR)$(bindir)
+-INCDIR=$(DESTDIR)$(incdir)
+-LIBDIR=$(DESTDIR)$(libdir)
+-MANDIR=$(DESTDIR)$(mandir)
+ 
+ OBJS=rtmp.o log.o amf.o hashswf.o parseurl.o
+ 
+ all:	librtmp.a $(SO_LIB)
+ 
+ clean:
+-	rm -f *.o *.a *.so *.$(SO_EXT)
++	rm -f *.o *.a *.$(SOX) *.$(SO_EXT)
+ 
+ librtmp.a: $(OBJS)
+ 	$(AR) rs $@ $?
+ 
+ librtmp.$(SO_EXT): $(OBJS)
+ 	$(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
+-	ln -sf $@ librtmp.so
++	ln -sf $@ librtmp.$(SOX)
+ 
+ log.o: log.c log.h Makefile
+ rtmp.o: rtmp.c rtmp.h rtmp_sys.h handshake.h dh.h log.h amf.h Makefile
+@@ -93,13 +103,7 @@ install_base:	librtmp.a librtmp.pc
+ 	cp librtmp.pc $(LIBDIR)/pkgconfig
+ 	cp librtmp.3 $(MANDIR)/man3
+ 
+-install_so.$(SO_VERSION):	librtmp.$(SO_EXT)
+-	cp librtmp.$(SO_EXT) $(LIBDIR)
+-	cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.so
+-
+-install_$(SO_VERSION).dylib:	librtmp.$(SO_EXT)
+-	cp librtmp.$(SO_EXT) $(LIBDIR)
+-	cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.dylib
++install_so:	librtmp.$(SO_EXT)
++	cp librtmp.$(SO_EXT) $(SODIR)
++	cd $(SODIR); ln -sf librtmp.$(SO_EXT) librtmp.$(SOX)
+ 
+-install_dll:	librtmp.dll
+-	cp librtmp.dll $(BINDIR)
+-- 
+1.7.10.4
+
+
+From 08bdebed5423602d195fa981b3f2663e62820677 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 13 Aug 2010 20:05:35 +0000
+Subject: [PATCH 13/34] Substitute libdir in pkgconfig file
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@549 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/Makefile      |    3 ++-
+ librtmp/librtmp.pc.in |    2 +-
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 6a1b08b..7cba62a 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -91,7 +91,8 @@ hashswf.o: hashswf.c http.h rtmp.h rtmp_sys.h Makefile
+ parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile
+ 
+ librtmp.pc: librtmp.pc.in Makefile
+-	sed -e "s;@prefix@;$(prefix);" -e "s;@VERSION@;$(VERSION);" \
++	sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
++		-e "s;@VERSION@;$(VERSION);" \
+ 		-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" librtmp.pc.in > $@
+ 
+ install:	install_base $(SO_INST)
+diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
+index d58e269..70bd268 100644
+--- a/librtmp/librtmp.pc.in
++++ b/librtmp/librtmp.pc.in
+@@ -1,6 +1,6 @@
+ prefix=@prefix@
+ exec_prefix=${prefix}
+-libdir=${exec_prefix}/lib
++libdir=@libdir@
+ incdir=${prefix}/include
+ 
+ Name: librtmp
+-- 
+1.7.10.4
+
+
+From 59ca19036ed45667b08d98f09e4d4a7a727b77b3 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 13 Aug 2010 20:34:58 +0000
+Subject: [PATCH 14/34] Less case-sensitive check for Content-length: header
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@550 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index f152648..5c678fd 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -3664,11 +3664,15 @@ HTTP_read(RTMP *r, int fill)
+     return -1;
+   if (strncmp(r->m_sb.sb_start, "HTTP/1.1 200 ", 13))
+     return -1;
+-  ptr = strstr(r->m_sb.sb_start, "Content-Length:");
++  ptr = r->m_sb.sb_start + sizeof("HTTP/1.1 200");
++  while ((ptr = strstr(ptr, "Content-"))) {
++    if (!strncasecmp(ptr+8, "length:", 7)) break;
++    ptr += 8;
++  }
+   if (!ptr)
+     return -1;
+   hlen = atoi(ptr+16);
+-  ptr = strstr(ptr, "\r\n\r\n");
++  ptr = strstr(ptr+16, "\r\n\r\n");
+   if (!ptr)
+     return -1;
+   ptr += 4;
+-- 
+1.7.10.4
+
+
+From 8afb3681407a0a83dcb1fec449b83854da440738 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 8 Oct 2010 07:45:54 +0000
+Subject: [PATCH 15/34] Log error message for unsupported SWF Verification
+ types
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@551 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 5c678fd..3e4e00a 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -2789,11 +2789,17 @@ HandleCtrl(RTMP *r, const RTMPPacket *packet)
+   if (nType == 0x1A)
+     {
+       RTMP_Log(RTMP_LOGDEBUG, "%s, SWFVerification ping received: ", __FUNCTION__);
++      if (packet->m_nBodySize > 2 && packet->m_body[2] > 0x01)
++	{
++	  RTMP_Log(RTMP_LOGERROR,
++            "%s: SWFVerification Type %d request not supported! Patches welcome...",
++	    __FUNCTION__, packet->m_body[2]);
++	}
+ #ifdef CRYPTO
+       /*RTMP_LogHex(packet.m_body, packet.m_nBodySize); */
+ 
+       /* respond with HMAC SHA256 of decompressed SWF, key is the 30byte player key, also the last 30 bytes of the server handshake are applied */
+-      if (r->Link.SWFSize)
++      else if (r->Link.SWFSize)
+ 	{
+ 	  RTMP_SendCtrl(r, 0x1B, 0, 0);
+ 	}
+-- 
+1.7.10.4
+
+
+From 9ca7e22d94c6e07e8ef05acbf636809a5914f50c Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Tue, 26 Oct 2010 23:51:10 +0000
+Subject: [PATCH 16/34] Timeout fix from Antti Ajanki
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@552 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    3 +++
+ rtmpdump.c     |    2 +-
+ 2 files changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 3e4e00a..db882dc 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -1019,6 +1019,9 @@ RTMP_ToggleStream(RTMP *r)
+ 
+   if (!r->m_pausing)
+     {
++      if (RTMP_IsTimedout(r) && r->m_read.status == RTMP_READ_EOF)
++        r->m_read.status = 0;
++
+       res = RTMP_SendPause(r, TRUE, r->m_pauseStamp);
+       if (!res)
+ 	return res;
+diff --git a/rtmpdump.c b/rtmpdump.c
+index 7aa19ab..c1cd95b 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -583,7 +583,7 @@ Download(RTMP * rtmp,		// connected RTMP object
+ #endif
+ 
+     }
+-  while (!RTMP_ctrlC && nRead > -1 && RTMP_IsConnected(rtmp));
++  while (!RTMP_ctrlC && nRead > -1 && RTMP_IsConnected(rtmp) && !RTMP_IsTimedout(rtmp));
+   free(buffer);
+   if (nRead < 0)
+     nRead = rtmp->m_read.status;
+-- 
+1.7.10.4
+
+
+From 1379a2c0d22f238d97970a7e7420287a9bd794de Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 24 Dec 2010 22:35:35 +0000
+Subject: [PATCH 17/34] Fix infinite loop on Error/Close
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@554 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index db882dc..e6e8ed8 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -3395,10 +3395,10 @@ RTMP_Close(RTMP *r)
+     {
+       if (r->m_stream_id > 0)
+         {
+-          if ((r->Link.protocol & RTMP_FEATURE_WRITE))
+-	    SendFCUnpublish(r);
+ 	  i = r->m_stream_id;
+ 	  r->m_stream_id = 0;
++          if ((r->Link.protocol & RTMP_FEATURE_WRITE))
++	    SendFCUnpublish(r);
+ 	  SendDeleteStream(r, i);
+ 	}
+       if (r->m_clientID.av_val)
+-- 
+1.7.10.4
+
+
+From 8c713f4c5c8e72369b48d15772e19d1c9ebd5a19 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 25 Feb 2011 05:51:40 +0000
+Subject: [PATCH 18/34] Fix FLV timestamps during resume
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@557 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index e6e8ed8..e2925a7 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -4083,7 +4083,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	  /* grab first timestamp and see if it needs fixing */
+ 	  nTimeStamp = AMF_DecodeInt24(packetBody + 4);
+ 	  nTimeStamp |= (packetBody[7] << 24);
+-	  delta = packet.m_nTimeStamp - nTimeStamp;
++	  delta = packet.m_nTimeStamp - nTimeStamp + r->m_read.nResumeTS;
+ 
+ 	  while (pos + 11 < nPacketLen)
+ 	    {
+-- 
+1.7.10.4
+
+
+From bca1ef01727cac659f7ac171c791490efe4e48d6 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 10 Mar 2011 14:30:06 +0000
+Subject: [PATCH 19/34] Add Libs.private to pkgconfig for Windows
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@558 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/Makefile      |    6 ++++--
+ librtmp/librtmp.pc.in |    1 +
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 7cba62a..87618af 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -31,7 +31,8 @@ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+-CRYPTO_LIB=$(LIB_$(CRYPTO)) $(LIBS_$(SYS))
++PRIVATE_LIBS=$(LIBS_$(SYS))
++CRYPTO_LIB=$(LIB_$(CRYPTO)) $(PRIVATE_LIBS)
+ CRYPTO_REQ=$(REQ_$(CRYPTO))
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ 
+@@ -93,7 +94,8 @@ parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile
+ librtmp.pc: librtmp.pc.in Makefile
+ 	sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
+ 		-e "s;@VERSION@;$(VERSION);" \
+-		-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" librtmp.pc.in > $@
++		-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \
++		-e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS));" librtmp.pc.in > $@
+ 
+ install:	install_base $(SO_INST)
+ 
+diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
+index 70bd268..5933ca1 100644
+--- a/librtmp/librtmp.pc.in
++++ b/librtmp/librtmp.pc.in
+@@ -9,4 +9,5 @@ Version: @VERSION@
+ Requires: @CRYPTO_REQ@
+ URL: http://rtmpdump.mplayerhq.hu
+ Libs: -L${libdir} -lrtmp -lz
++Libs.private; @PRIVATE_LIBS@
+ Cflags: -I${incdir}
+-- 
+1.7.10.4
+
+
+From 25447a0f675cc6e9eefc8eb420ad3a2725be8ab1 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 10 Mar 2011 14:33:32 +0000
+Subject: [PATCH 20/34] Fix typos in prev commit
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@559 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/Makefile      |    2 +-
+ librtmp/librtmp.pc.in |    2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 87618af..1ea31a0 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -95,7 +95,7 @@ librtmp.pc: librtmp.pc.in Makefile
+ 	sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
+ 		-e "s;@VERSION@;$(VERSION);" \
+ 		-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \
+-		-e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS));" librtmp.pc.in > $@
++		-e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS);" librtmp.pc.in > $@
+ 
+ install:	install_base $(SO_INST)
+ 
+diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
+index 5933ca1..a82beca 100644
+--- a/librtmp/librtmp.pc.in
++++ b/librtmp/librtmp.pc.in
+@@ -9,5 +9,5 @@ Version: @VERSION@
+ Requires: @CRYPTO_REQ@
+ URL: http://rtmpdump.mplayerhq.hu
+ Libs: -L${libdir} -lrtmp -lz
+-Libs.private; @PRIVATE_LIBS@
++Libs.private: @PRIVATE_LIBS@
+ Cflags: -I${incdir}
+-- 
+1.7.10.4
+
+
+From 0a219ffeeb0094111fd00c509fce3ddd6eba2de2 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 14 Mar 2011 06:48:09 +0000
+Subject: [PATCH 21/34] Bump up play command buffer sizes
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@560 400ebc74-4327-4243-bc38-086b20814532
+---
+ rtmpsrv.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index f2af85b..4d5699f 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -266,7 +266,7 @@ static int
+ SendPlayStart(RTMP *r)
+ {
+   RTMPPacket packet;
+-  char pbuf[384], *pend = pbuf+sizeof(pbuf);
++  char pbuf[512], *pend = pbuf+sizeof(pbuf);
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+@@ -298,7 +298,7 @@ static int
+ SendPlayStop(RTMP *r)
+ {
+   RTMPPacket packet;
+-  char pbuf[384], *pend = pbuf+sizeof(pbuf);
++  char pbuf[512], *pend = pbuf+sizeof(pbuf);
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-- 
+1.7.10.4
+
+
+From a1bcab1da064cca8a534d26970333220b57a72f0 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Wed, 16 Mar 2011 12:11:21 +0000
+Subject: [PATCH 22/34] Fix rtmpt read hangs
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@561 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |   17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index e2925a7..3042c7f 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -877,7 +877,13 @@ RTMP_Connect1(RTMP *r, RTMPPacket *cp)
+       r->m_clientID.av_val = NULL;
+       r->m_clientID.av_len = 0;
+       HTTP_Post(r, RTMPT_OPEN, "", 1);
+-      HTTP_read(r, 1);
++      if (HTTP_read(r, 1) != 0)
++	{
++	  r->m_msgCounter = 0;
++	  RTMP_Log(RTMP_LOGDEBUG, "%s, Could not connect for handshake", __FUNCTION__);
++	  RTMP_Close(r);
++	  return 0;
++	}
+       r->m_msgCounter = 0;
+     }
+   RTMP_Log(RTMP_LOGDEBUG, "%s, ... connected, handshaking", __FUNCTION__);
+@@ -1284,7 +1290,12 @@ ReadN(RTMP *r, char *buffer, int n)
+ 		      return 0;
+ 		    }
+ 		}
+-	      HTTP_read(r, 0);
++	      if (HTTP_read(r, 0) == -1)
++		{
++		  RTMP_Log(RTMP_LOGDEBUG, "%s, No valid HTTP response found", __FUNCTION__);
++		  RTMP_Close(r);
++		  return 0;
++		}
+ 	    }
+ 	  if (r->m_resplen && !r->m_sb.sb_size)
+ 	    RTMPSockBuf_Fill(&r->m_sb);
+@@ -3670,7 +3681,7 @@ HTTP_read(RTMP *r, int fill)
+   if (fill)
+     RTMPSockBuf_Fill(&r->m_sb);
+   if (r->m_sb.sb_size < 144)
+-    return -1;
++    return -2;
+   if (strncmp(r->m_sb.sb_start, "HTTP/1.1 200 ", 13))
+     return -1;
+   ptr = r->m_sb.sb_start + sizeof("HTTP/1.1 200");
+-- 
+1.7.10.4
+
+
+From aa2825fbb1d1f70652d558a730baed28149ebbdd Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Sat, 19 Mar 2011 23:32:53 +0000
+Subject: [PATCH 23/34] Drop back on the handshake version, avoid rtmpe 9
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@562 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/handshake.h |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index 958579a..d4d2913 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -400,8 +400,10 @@ HandShake(RTMP * r, int FP9HandShake)
+       /* set version to at least 9.0.115.0 */
+       if (encrypted)
+ 	{
+-	  clientsig[4] = 128;
+-	  clientsig[6] = 3;
++/* 	  clientsig[4] = 128;
++	  clientsig[6] = 3; */
++	  clientsig[4] = 0x7c;
++	  clientsig[6] = 0x2;
+ 	}
+       else
+         {
+-- 
+1.7.10.4
+
+
+From ac1843db901184bef349615e3b67d7d2fcebdb7f Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Tue, 22 Mar 2011 15:13:18 +0000
+Subject: [PATCH 24/34] Fix prev commit
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@563 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/handshake.h |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index d4d2913..b172dbf 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -402,8 +402,8 @@ HandShake(RTMP * r, int FP9HandShake)
+ 	{
+ /* 	  clientsig[4] = 128;
+ 	  clientsig[6] = 3; */
+-	  clientsig[4] = 0x7c;
+-	  clientsig[6] = 0x2;
++	  clientsig[4] = 9;
++	  clientsig[6] = 0x7c;
+ 	}
+       else
+         {
+-- 
+1.7.10.4
+
+
+From 495e1e64106f10a7a1c15f0e2f870a02aa90605c Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 7 Apr 2011 19:07:31 +0000
+Subject: [PATCH 25/34] Handle Play.PublishNotify like Play.Start
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@566 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 3042c7f..286b6ae 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -2282,6 +2282,8 @@ static const AVal av_NetStream_Play_Complete = AVC("NetStream.Play.Complete");
+ static const AVal av_NetStream_Play_Stop = AVC("NetStream.Play.Stop");
+ static const AVal av_NetStream_Seek_Notify = AVC("NetStream.Seek.Notify");
+ static const AVal av_NetStream_Pause_Notify = AVC("NetStream.Pause.Notify");
++static const AVal av_NetStream_Play_PublishNotify =
++AVC("NetStream.Play.PublishNotify");
+ static const AVal av_NetStream_Play_UnpublishNotify =
+ AVC("NetStream.Play.UnpublishNotify");
+ static const AVal av_NetStream_Publish_Start = AVC("NetStream.Publish.Start");
+@@ -2449,7 +2451,8 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ 	  RTMP_Log(RTMP_LOGERROR, "Closing connection: %s", code.av_val);
+ 	}
+ 
+-      else if (AVMATCH(&code, &av_NetStream_Play_Start))
++      else if (AVMATCH(&code, &av_NetStream_Play_Start)
++           || AVMATCH(&code, &av_NetStream_Play_PublishNotify))
+ 	{
+ 	  int i;
+ 	  r->m_bPlaying = TRUE;
+-- 
+1.7.10.4
+
+
+From 041cf3f2c927b26dc4b27b5e802fbb89362ea3e2 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 7 Apr 2011 19:11:13 +0000
+Subject: [PATCH 26/34] Handle multiple sessions at once (ugly)
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@567 400ebc74-4327-4243-bc38-086b20814532
+---
+ rtmpsuck.c |   13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/rtmpsuck.c b/rtmpsuck.c
+index ce6d879..3293e8b 100644
+--- a/rtmpsuck.c
++++ b/rtmpsuck.c
+@@ -718,15 +718,15 @@ controlServerThread(void *unused)
+   TFRET();
+ }
+ 
+-void doServe(STREAMING_SERVER * server,	// server socket and state (our listening socket)
+-  int sockfd	// client connection socket
+-  )
++TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+ {
++  STREAMING_SERVER *server = arg;
+   RTMPPacket pc = { 0 }, ps = { 0 };
+   RTMPChunk rk = { 0 };
+   char *buf = NULL;
+   unsigned int buflen = 131072;
+   int paused = FALSE;
++  int sockfd = server->socket;
+ 
+   // timeout for http requests
+   fd_set rfds;
+@@ -990,7 +990,7 @@ quit:
+   if (server->state == STREAMING_IN_PROGRESS)
+     server->state = STREAMING_ACCEPTING;
+ 
+-  return;
++  TFRET();
+ }
+ 
+ TFTYPE
+@@ -1003,6 +1003,7 @@ serverThread(void *arg)
+     {
+       struct sockaddr_in addr;
+       socklen_t addrlen = sizeof(struct sockaddr_in);
++      STREAMING_SERVER *srv2 = malloc(sizeof(STREAMING_SERVER));
+       int sockfd =
+ 	accept(server->socket, (struct sockaddr *) &addr, &addrlen);
+ 
+@@ -1020,8 +1021,10 @@ serverThread(void *arg)
+ 	  RTMP_Log(RTMP_LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
+ 	      inet_ntoa(addr.sin_addr));
+ #endif
++	  *srv2 = *server;
++	  srv2->socket = sockfd;
+ 	  /* Create a new thread and transfer the control to that */
+-	  doServe(server, sockfd);
++	  ThreadCreate(doServe, srv2);
+ 	  RTMP_Log(RTMP_LOGDEBUG, "%s: processed request\n", __FUNCTION__);
+ 	}
+       else
+-- 
+1.7.10.4
+
+
+From 6155179b296f9749f713bb9bf47e9ca1fdb1a201 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 7 Apr 2011 19:33:28 +0000
+Subject: [PATCH 27/34] Use symbolic constants for packet types. From Peter
+ Miller @ opensource.org.au
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@568 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |  132 ++++++++++++++++++++++++++++++--------------------------
+ librtmp/rtmp.h |   26 +++++++++--
+ rtmpsrv.c      |    8 ++--
+ rtmpsuck.c     |  112 ++++++++++++++++++++++++++---------------------
+ 4 files changed, 161 insertions(+), 117 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 286b6ae..5ef3ae9 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -1103,32 +1103,32 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+   int bHasMediaPacket = 0;
+   switch (packet->m_packetType)
+     {
+-    case 0x01:
++    case RTMP_PACKET_TYPE_CHUNK_SIZE:
+       /* chunk size */
+       HandleChangeChunkSize(r, packet);
+       break;
+ 
+-    case 0x03:
++    case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
+       /* bytes read report */
+       RTMP_Log(RTMP_LOGDEBUG, "%s, received: bytes read report", __FUNCTION__);
+       break;
+ 
+-    case 0x04:
++    case RTMP_PACKET_TYPE_CONTROL:
+       /* ctrl */
+       HandleCtrl(r, packet);
+       break;
+ 
+-    case 0x05:
++    case RTMP_PACKET_TYPE_SERVER_BW:
+       /* server bw */
+       HandleServerBW(r, packet);
+       break;
+ 
+-    case 0x06:
++    case RTMP_PACKET_TYPE_CLIENT_BW:
+       /* client bw */
+       HandleClientBW(r, packet);
+       break;
+ 
+-    case 0x08:
++    case RTMP_PACKET_TYPE_AUDIO:
+       /* audio data */
+       /*RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize); */
+       HandleAudio(r, packet);
+@@ -1139,7 +1139,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	r->m_mediaStamp = packet->m_nTimeStamp;
+       break;
+ 
+-    case 0x09:
++    case RTMP_PACKET_TYPE_VIDEO:
+       /* video data */
+       /*RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize); */
+       HandleVideo(r, packet);
+@@ -1150,19 +1150,22 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	r->m_mediaStamp = packet->m_nTimeStamp;
+       break;
+ 
+-    case 0x0F:			/* flex stream send */
++    case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
++      /* flex stream send */
+       RTMP_Log(RTMP_LOGDEBUG,
+ 	  "%s, flex stream send, size %lu bytes, not supported, ignoring",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       break;
+ 
+-    case 0x10:			/* flex shared object */
++    case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
++      /* flex shared object */
+       RTMP_Log(RTMP_LOGDEBUG,
+ 	  "%s, flex shared object, size %lu bytes, not supported, ignoring",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       break;
+ 
+-    case 0x11:			/* flex message */
++    case RTMP_PACKET_TYPE_FLEX_MESSAGE:
++      /* flex message */
+       {
+ 	RTMP_Log(RTMP_LOGDEBUG,
+ 	    "%s, flex message, size %lu bytes, not fully supported",
+@@ -1185,7 +1188,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	  bHasMediaPacket = 2;
+ 	break;
+       }
+-    case 0x12:
++    case RTMP_PACKET_TYPE_INFO:
+       /* metadata (notify) */
+       RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %lu bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+@@ -1193,12 +1196,12 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	bHasMediaPacket = 1;
+       break;
+ 
+-    case 0x13:
++    case RTMP_PACKET_TYPE_SHARED_OBJECT:
+       RTMP_Log(RTMP_LOGDEBUG, "%s, shared object, not supported, ignoring",
+ 	  __FUNCTION__);
+       break;
+ 
+-    case 0x14:
++    case RTMP_PACKET_TYPE_INVOKE:
+       /* invoke */
+       RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+@@ -1208,7 +1211,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	bHasMediaPacket = 2;
+       break;
+ 
+-    case 0x16:
++    case RTMP_PACKET_TYPE_FLASH_VIDEO:
+       {
+ 	/* go through FLV packets and handle metadata packets */
+ 	unsigned int pos = 0;
+@@ -1448,7 +1451,7 @@ SendConnectPacket(RTMP *r, RTMPPacket *cp)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1559,7 +1562,7 @@ SendBGHasStream(RTMP *r, double dId, AVal *playpath)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1591,7 +1594,7 @@ RTMP_SendCreateStream(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1617,7 +1620,7 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
+   char *enc;
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1649,7 +1652,7 @@ SendReleaseStream(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1679,7 +1682,7 @@ SendFCPublish(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1709,7 +1712,7 @@ SendFCUnpublish(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1741,7 +1744,7 @@ SendPublish(RTMP *r)
+ 
+   packet.m_nChannel = 0x04;	/* source channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = r->m_stream_id;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1776,7 +1779,7 @@ SendDeleteStream(RTMP *r, double dStreamId)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1805,7 +1808,7 @@ RTMP_SendPause(RTMP *r, int DoPause, int iTime)
+ 
+   packet.m_nChannel = 0x08;	/* video channel */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* invoke */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1842,7 +1845,7 @@ RTMP_SendSeek(RTMP *r, int iTime)
+ 
+   packet.m_nChannel = 0x08;	/* video channel */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* invoke */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1870,7 +1873,7 @@ RTMP_SendServerBW(RTMP *r)
+ 
+   packet.m_nChannel = 0x02;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x05;	/* Server BW */
++  packet.m_packetType = RTMP_PACKET_TYPE_SERVER_BW;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1890,7 +1893,7 @@ RTMP_SendClientBW(RTMP *r)
+ 
+   packet.m_nChannel = 0x02;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x06;	/* Client BW */
++  packet.m_packetType = RTMP_PACKET_TYPE_CLIENT_BW;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1911,7 +1914,7 @@ SendBytesReceived(RTMP *r)
+ 
+   packet.m_nChannel = 0x02;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x03;	/* bytes in */
++  packet.m_packetType = RTMP_PACKET_TYPE_BYTES_READ_REPORT;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1937,7 +1940,7 @@ SendCheckBW(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;	/* RTMP_GetTime(); */
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1965,7 +1968,7 @@ SendCheckBWResult(RTMP *r, double txn)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0x16 * r->m_nBWCheckCounter;	/* temp inc value. till we figure it out. */
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1994,7 +1997,7 @@ SendPong(RTMP *r, double txn)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0x16 * r->m_nBWCheckCounter;	/* temp inc value. till we figure it out. */
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -2021,7 +2024,7 @@ SendPlay(RTMP *r)
+ 
+   packet.m_nChannel = 0x08;	/* we make 8 our stream channel */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = r->m_stream_id;	/*0x01000000; */
+   packet.m_hasAbsTimestamp = 0;
+@@ -2089,7 +2092,7 @@ SendPlaylist(RTMP *r)
+ 
+   packet.m_nChannel = 0x08;	/* we make 8 our stream channel */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = r->m_stream_id;	/*0x01000000; */
+   packet.m_hasAbsTimestamp = 0;
+@@ -2127,7 +2130,7 @@ SendSecureTokenResponse(RTMP *r, AVal *resp)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -2174,7 +2177,7 @@ RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject, unsigned int nTime)
+ 
+   packet.m_nChannel = 0x02;	/* control channel (ping) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x04;	/* ctrl */
++  packet.m_packetType = RTMP_PACKET_TYPE_CONTROL;
+   packet.m_nTimeStamp = 0;	/* RTMP_GetTime(); */
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -3372,7 +3375,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue)
+     }
+ 
+   /* we invoked a remote method */
+-  if (packet->m_packetType == 0x14)
++  if (packet->m_packetType == RTMP_PACKET_TYPE_INVOKE)
+     {
+       AVal method;
+       char *ptr;
+@@ -3748,8 +3751,8 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+       char *packetBody = packet.m_body;
+       unsigned int nPacketLen = packet.m_nBodySize;
+ 
+-      /* Return -3 if this was completed nicely with invoke message
+-       * Play.Stop or Play.Complete
++      /* Return RTMP_READ_COMPLETE if this was completed nicely with
++       * invoke message Play.Stop or Play.Complete
+        */
+       if (rtnGetNextMediaPacket == 2)
+ 	{
+@@ -3760,17 +3763,17 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	  break;
+ 	}
+ 
+-      r->m_read.dataType |= (((packet.m_packetType == 0x08) << 2) |
+-			     (packet.m_packetType == 0x09));
++      r->m_read.dataType |= (((packet.m_packetType == RTMP_PACKET_TYPE_AUDIO) << 2) |
++			     (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO));
+ 
+-      if (packet.m_packetType == 0x09 && nPacketLen <= 5)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO && nPacketLen <= 5)
+ 	{
+ 	  RTMP_Log(RTMP_LOGDEBUG, "ignoring too small video packet: size: %d",
+ 	      nPacketLen);
+ 	  ret = RTMP_READ_IGNORE;
+ 	  break;
+ 	}
+-      if (packet.m_packetType == 0x08 && nPacketLen <= 1)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_AUDIO && nPacketLen <= 1)
+ 	{
+ 	  RTMP_Log(RTMP_LOGDEBUG, "ignoring too small audio packet: size: %d",
+ 	      nPacketLen);
+@@ -3787,7 +3790,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+       RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms, abs TS: %d",
+ 	  packet.m_packetType, nPacketLen, packet.m_nTimeStamp,
+ 	  packet.m_hasAbsTimestamp);
+-      if (packet.m_packetType == 0x09)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO)
+ 	RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
+ #endif
+ 
+@@ -3797,7 +3800,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	  if (packet.m_nTimeStamp == 0)
+ 	    {
+ 	      if (r->m_read.nMetaHeaderSize > 0
+-		  && packet.m_packetType == 0x12)
++		  && packet.m_packetType == RTMP_PACKET_TYPE_INFO)
+ 		{
+ 		  AMFObject metaObj;
+ 		  int nRes =
+@@ -3858,7 +3861,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 		   * in the first FLV stream chunk and we have to compare
+ 		   * it and filter it out !!
+ 		   */
+-		  if (packet.m_packetType == 0x16)
++		  if (packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 		    {
+ 		      /* basically we have to find the keyframe with the
+ 		       * correct TS being nResumeTS
+@@ -3970,7 +3973,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	   * (seeking might put us somewhere before it)
+ 	   */
+ 	  if (!(r->m_read.flags & RTMP_READ_GOTKF) &&
+-	  	packet.m_packetType != 0x16)
++	  	packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	    {
+ 	      RTMP_Log(RTMP_LOGWARNING,
+ 		  "Stream does not start with requested frame, ignoring data... ");
+@@ -3983,7 +3986,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	    }
+ 	  /* ok, do the same for FLV streams */
+ 	  if (!(r->m_read.flags & RTMP_READ_GOTFLVK) &&
+-	  	packet.m_packetType == 0x16)
++	  	packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	    {
+ 	      RTMP_Log(RTMP_LOGWARNING,
+ 		  "Stream does not start with requested FLV frame, ignoring data... ");
+@@ -4002,9 +4005,11 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	   * the preceding if clause)
+ 	   */
+ 	  if (!(r->m_read.flags & RTMP_READ_NO_IGNORE) &&
+-	  	packet.m_packetType != 0x16)
+-	    {			/* exclude type 0x16 (FLV) since it can
+-				 * contain several FLV packets */
++	  	packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
++	    {
++              /* exclude type RTMP_PACKET_TYPE_FLASH_VIDEO since it can
++               * contain several FLV packets
++               */
+ 	      if (packet.m_nTimeStamp == 0)
+ 		{
+ 		  ret = RTMP_READ_IGNORE;
+@@ -4020,9 +4025,10 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 
+       /* calculate packet size and allocate slop buffer if necessary */
+       size = nPacketLen +
+-	((packet.m_packetType == 0x08 || packet.m_packetType == 0x09
+-	  || packet.m_packetType == 0x12) ? 11 : 0) +
+-	(packet.m_packetType != 0x16 ? 4 : 0);
++	((packet.m_packetType == RTMP_PACKET_TYPE_AUDIO
++          || packet.m_packetType == RTMP_PACKET_TYPE_VIDEO
++	  || packet.m_packetType == RTMP_PACKET_TYPE_INFO) ? 11 : 0) +
++	(packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO ? 4 : 0);
+ 
+       if (size + 4 > buflen)
+ 	{
+@@ -4048,8 +4054,9 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 
+       /* audio (0x08), video (0x09) or metadata (0x12) packets :
+        * construct 11 byte header then add rtmp packet's data */
+-      if (packet.m_packetType == 0x08 || packet.m_packetType == 0x09
+-	  || packet.m_packetType == 0x12)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_AUDIO
++          || packet.m_packetType == RTMP_PACKET_TYPE_VIDEO
++	  || packet.m_packetType == RTMP_PACKET_TYPE_INFO)
+ 	{
+ 	  nTimeStamp = r->m_read.nResumeTS + packet.m_nTimeStamp;
+ 	  prevTagSize = 11 + nPacketLen;
+@@ -4059,7 +4066,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	  ptr = AMF_EncodeInt24(ptr, pend, nPacketLen);
+ 
+ #if 0
+-	    if(packet.m_packetType == 0x09) { /* video */
++	    if(packet.m_packetType == RTMP_PACKET_TYPE_VIDEO) {
+ 
+ 	     /* H264 fix: */
+ 	     if((packetBody[0] & 0x0f) == 7) { /* CodecId = H264 */
+@@ -4089,7 +4096,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+       len = nPacketLen;
+ 
+       /* correct tagSize and obtain timestamp if we have an FLV stream */
+-      if (packet.m_packetType == 0x16)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	{
+ 	  unsigned int pos = 0;
+ 	  int delta;
+@@ -4167,7 +4174,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	}
+       ptr += len;
+ 
+-      if (packet.m_packetType != 0x16)
++      if (packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	{
+ 	  /* FLV tag packets contain their own prevTagSize */
+ 	  AMF_EncodeInt32(ptr, pend, prevTagSize);
+@@ -4352,11 +4359,12 @@ RTMP_Write(RTMP *r, const char *buf, int size)
+ 	  buf += 3;
+ 	  s2 -= 11;
+ 
+-	  if (((pkt->m_packetType == 0x08 || pkt->m_packetType == 0x09) &&
+-	    !pkt->m_nTimeStamp) || pkt->m_packetType == 0x12)
++	  if (((pkt->m_packetType == RTMP_PACKET_TYPE_AUDIO
++                || pkt->m_packetType == RTMP_PACKET_TYPE_VIDEO) &&
++            !pkt->m_nTimeStamp) || pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
+ 	    {
+ 	      pkt->m_headerType = RTMP_PACKET_SIZE_LARGE;
+-	      if (pkt->m_packetType == 0x12)
++	      if (pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
+ 		pkt->m_nBodySize += 16;
+ 	    }
+ 	  else
+@@ -4371,7 +4379,7 @@ RTMP_Write(RTMP *r, const char *buf, int size)
+ 	    }
+ 	  enc = pkt->m_body;
+ 	  pend = enc + pkt->m_nBodySize;
+-	  if (pkt->m_packetType == 0x12)
++	  if (pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
+ 	    {
+ 	      enc = AMF_EncodeString(enc, pend, &av_setDataFrame);
+ 	      pkt->m_nBytesRead = enc - pkt->m_body;
+diff --git a/librtmp/rtmp.h b/librtmp/rtmp.h
+index de0b795..1ece207 100644
+--- a/librtmp/rtmp.h
++++ b/librtmp/rtmp.h
+@@ -71,9 +71,29 @@ extern "C"
+ 
+   uint32_t RTMP_GetTime(void);
+ 
+-#define RTMP_PACKET_TYPE_AUDIO 0x08
+-#define RTMP_PACKET_TYPE_VIDEO 0x09
+-#define RTMP_PACKET_TYPE_INFO  0x12
++/*      RTMP_PACKET_TYPE_...                0x00 */
++#define RTMP_PACKET_TYPE_CHUNK_SIZE         0x01
++/*      RTMP_PACKET_TYPE_...                0x02 */
++#define RTMP_PACKET_TYPE_BYTES_READ_REPORT  0x03
++#define RTMP_PACKET_TYPE_CONTROL            0x04
++#define RTMP_PACKET_TYPE_SERVER_BW          0x05
++#define RTMP_PACKET_TYPE_CLIENT_BW          0x06
++/*      RTMP_PACKET_TYPE_...                0x07 */
++#define RTMP_PACKET_TYPE_AUDIO              0x08
++#define RTMP_PACKET_TYPE_VIDEO              0x09
++/*      RTMP_PACKET_TYPE_...                0x0A */
++/*      RTMP_PACKET_TYPE_...                0x0B */
++/*      RTMP_PACKET_TYPE_...                0x0C */
++/*      RTMP_PACKET_TYPE_...                0x0D */
++/*      RTMP_PACKET_TYPE_...                0x0E */
++#define RTMP_PACKET_TYPE_FLEX_STREAM_SEND   0x0F
++#define RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT 0x10
++#define RTMP_PACKET_TYPE_FLEX_MESSAGE       0x11
++#define RTMP_PACKET_TYPE_INFO               0x12
++#define RTMP_PACKET_TYPE_SHARED_OBJECT      0x13
++#define RTMP_PACKET_TYPE_INVOKE             0x14
++/*      RTMP_PACKET_TYPE_...                0x15 */
++#define RTMP_PACKET_TYPE_FLASH_VIDEO        0x16
+ 
+ #define RTMP_MAX_HEADER_SIZE 18
+ 
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index 4d5699f..f1b6c66 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -175,7 +175,7 @@ SendConnectResult(RTMP *r, double txn)
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-  packet.m_packetType = 0x14;   // INVOKE
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -236,7 +236,7 @@ SendResultNumber(RTMP *r, double txn, double ID)
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-  packet.m_packetType = 0x14;   // INVOKE
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -270,7 +270,7 @@ SendPlayStart(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-  packet.m_packetType = 0x14;   // INVOKE
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -302,7 +302,7 @@ SendPlayStop(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-  packet.m_packetType = 0x14;   // INVOKE
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+diff --git a/rtmpsuck.c b/rtmpsuck.c
+index 3293e8b..661e64b 100644
+--- a/rtmpsuck.c
++++ b/rtmpsuck.c
+@@ -461,67 +461,71 @@ ServePacket(STREAMING_SERVER *server, int which, RTMPPacket *packet)
+ 
+   switch (packet->m_packetType)
+     {
+-    case 0x01:
++    case RTMP_PACKET_TYPE_CHUNK_SIZE:
+       // chunk size
+ //      HandleChangeChunkSize(r, packet);
+       break;
+ 
+-    case 0x03:
++    case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
+       // bytes read report
+       break;
+ 
+-    case 0x04:
++    case RTMP_PACKET_TYPE_CONTROL:
+       // ctrl
+ //      HandleCtrl(r, packet);
+       break;
+ 
+-    case 0x05:
++    case RTMP_PACKET_TYPE_SERVER_BW:
+       // server bw
+ //      HandleServerBW(r, packet);
+       break;
+ 
+-    case 0x06:
++    case RTMP_PACKET_TYPE_CLIENT_BW:
+       // client bw
+  //     HandleClientBW(r, packet);
+       break;
+ 
+-    case 0x08:
++    case RTMP_PACKET_TYPE_AUDIO:
+       // audio data
+       //RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
+       break;
+ 
+-    case 0x09:
++    case RTMP_PACKET_TYPE_VIDEO:
+       // video data
+       //RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
+       break;
+ 
+-    case 0x0F:			// flex stream send
++    case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
++      // flex stream send
+       break;
+ 
+-    case 0x10:			// flex shared object
++    case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
++      // flex shared object
+       break;
+ 
+-    case 0x11:			// flex message
++    case RTMP_PACKET_TYPE_FLEX_MESSAGE:
++      // flex message
+       {
+ 	ret = ServeInvoke(server, which, packet, packet->m_body + 1);
+ 	break;
+       }
+-    case 0x12:
++    case RTMP_PACKET_TYPE_INFO:
+       // metadata (notify)
+       break;
+ 
+-    case 0x13:
++    case RTMP_PACKET_TYPE_SHARED_OBJECT:
+       /* shared object */
+       break;
+ 
+-    case 0x14:
++    case RTMP_PACKET_TYPE_INVOKE:
+       // invoke
+       ret = ServeInvoke(server, which, packet, packet->m_body);
+       break;
+ 
+-    case 0x16:
++    case RTMP_PACKET_TYPE_FLASH_VIDEO:
+       /* flv */
+ 	break;
++
+     default:
+       RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
+ 	  packet->m_packetType);
+@@ -547,21 +551,21 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+       unsigned int nPacketLen = packet->m_nBodySize;
+ 
+       // skip video info/command packets
+-      if (packet->m_packetType == 0x09 &&
++      if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO &&
+ 	  nPacketLen == 2 && ((*packetBody & 0xf0) == 0x50))
+ 	{
+ 	  ret = 0;
+ 	  break;
+ 	}
+ 
+-      if (packet->m_packetType == 0x09 && nPacketLen <= 5)
++      if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO && nPacketLen <= 5)
+ 	{
+ 	  RTMP_Log(RTMP_LOGWARNING, "ignoring too small video packet: size: %d",
+ 	      nPacketLen);
+ 	  ret = 0;
+ 	  break;
+ 	}
+-      if (packet->m_packetType == 0x08 && nPacketLen <= 1)
++      if (packet->m_packetType == RTMP_PACKET_TYPE_AUDIO && nPacketLen <= 1)
+ 	{
+ 	  RTMP_Log(RTMP_LOGWARNING, "ignoring too small audio packet: size: %d",
+ 	      nPacketLen);
+@@ -571,19 +575,22 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ #ifdef _DEBUG
+       RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms", packet->m_packetType,
+ 	  nPacketLen, packet->m_nTimeStamp);
+-      if (packet->m_packetType == 0x09)
++      if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO)
+ 	RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
+ #endif
+ 
+       // calculate packet size and reallocate buffer if necessary
+       unsigned int size = nPacketLen
+ 	+
+-	((packet->m_packetType == 0x08 || packet->m_packetType == 0x09
+-	  || packet->m_packetType == 0x12) ? 11 : 0) + (packet->m_packetType !=
+-						       0x16 ? 4 : 0);
++	((packet->m_packetType == RTMP_PACKET_TYPE_AUDIO
++          || packet->m_packetType == RTMP_PACKET_TYPE_VIDEO
++	  || packet->m_packetType == RTMP_PACKET_TYPE_INFO) ? 11 : 0)
++        + (packet->m_packetType != 0x16 ? 4 : 0);
+ 
+       if (size + 4 > len)
+-	{			// the extra 4 is for the case of an FLV stream without a last prevTagSize (we need extra 4 bytes to append it)
++	{
++          /* The extra 4 is for the case of an FLV stream without a last
++           * prevTagSize (we need extra 4 bytes to append it).  */
+ 	  *buf = (char *) realloc(*buf, size + 4);
+ 	  if (*buf == 0)
+ 	    {
+@@ -594,13 +601,15 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ 	}
+       char *ptr = *buf, *pend = ptr + size+4;
+ 
+-      // audio (0x08), video (0x09) or metadata (0x12) packets :
+-      // construct 11 byte header then add rtmp packet's data
+-      if (packet->m_packetType == 0x08 || packet->m_packetType == 0x09
+-	  || packet->m_packetType == 0x12)
++      /* audio (RTMP_PACKET_TYPE_AUDIO), video (RTMP_PACKET_TYPE_VIDEO)
++       * or metadata (RTMP_PACKET_TYPE_INFO) packets: construct 11 byte
++       * header then add rtmp packet's data.  */
++      if (packet->m_packetType == RTMP_PACKET_TYPE_AUDIO
++          || packet->m_packetType == RTMP_PACKET_TYPE_VIDEO
++	  || packet->m_packetType == RTMP_PACKET_TYPE_INFO)
+ 	{
+ 	  // set data type
+-	  //*dataType |= (((packet->m_packetType == 0x08)<<2)|(packet->m_packetType == 0x09));
++	  //*dataType |= (((packet->m_packetType == RTMP_PACKET_TYPE_AUDIO)<<2)|(packet->m_packetType == RTMP_PACKET_TYPE_VIDEO));
+ 
+ 	  (*nTimeStamp) = packet->m_nTimeStamp;
+ 	  prevTagSize = 11 + nPacketLen;
+@@ -619,7 +628,7 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+       unsigned int len = nPacketLen;
+ 
+       // correct tagSize and obtain timestamp if we have an FLV stream
+-      if (packet->m_packetType == 0x16)
++      if (packet->m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	{
+ 	  unsigned int pos = 0;
+ 
+@@ -629,8 +638,11 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ 	      *nTimeStamp = AMF_DecodeInt24(packetBody + pos + 4);
+ 	      *nTimeStamp |= (packetBody[pos + 7] << 24);
+ 
+-	      // set data type
+-	      //*dataType |= (((*(packetBody+pos) == 0x08)<<2)|(*(packetBody+pos) == 0x09));
++#if 0
++	      /* set data type */
++	      *dataType |= (((*(packetBody+pos) == RTMP_PACKET_TYPE_AUDIO) << 2)
++                            | (*(packetBody+pos) == RTMP_PACKET_TYPE_VIDEO));
++#endif
+ 
+ 	      if (pos + 11 + dataSize + 4 > nPacketLen)
+ 		{
+@@ -680,7 +692,7 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ 	}
+       ptr += len;
+ 
+-      if (packet->m_packetType != 0x16)
++      if (packet->m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	{			// FLV tag packets contain their own prevTagSize
+ 	  AMF_EncodeInt32(ptr, pend, prevTagSize);
+ 	  //ptr += 4;
+@@ -828,7 +840,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+             if (RTMPPacket_IsReady(&ps))
+               {
+                 /* change chunk size */
+-                if (ps.m_packetType == 0x01)
++                if (ps.m_packetType == RTMP_PACKET_TYPE_CHUNK_SIZE)
+                   {
+                     if (ps.m_nBodySize >= 4)
+                       {
+@@ -839,7 +851,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                       }
+                   }
+                 /* bytes received */
+-                else if (ps.m_packetType == 0x03)
++                else if (ps.m_packetType == RTMP_PACKET_TYPE_BYTES_READ_REPORT)
+                   {
+                     if (ps.m_nBodySize >= 4)
+                       {
+@@ -849,7 +861,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                       }
+                   }
+                 /* ctrl */
+-                else if (ps.m_packetType == 0x04)
++                else if (ps.m_packetType == RTMP_PACKET_TYPE_CONTROL)
+                   {
+                     short nType = AMF_DecodeInt16(ps.m_body);
+                     /* UpdateBufferMS */
+@@ -875,13 +887,16 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                           }
+                       }
+                   }
+-                else if (ps.m_packetType == 0x11 || ps.m_packetType == 0x14)
+-                  if (ServePacket(server, 0, &ps) && server->f_cur)
+-                    {
+-                      fclose(server->f_cur->f_file);
+-                      server->f_cur->f_file = NULL;
+-                      server->f_cur = NULL;
+-                    }
++                else if (ps.m_packetType == RTMP_PACKET_TYPE_FLEX_MESSAGE
++                         || ps.m_packetType == RTMP_PACKET_TYPE_INVOKE)
++                  {
++                    if (ServePacket(server, 0, &ps) && server->f_cur)
++                      {
++                        fclose(server->f_cur->f_file);
++                        server->f_cur->f_file = NULL;
++                        server->f_cur = NULL;
++                      }
++                  }
+                 RTMP_SendPacket(&server->rc, &ps, FALSE);
+                 RTMPPacket_Free(&ps);
+                 break;
+@@ -902,7 +917,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                       server->rc.m_pausing = 0;
+                     }
+                   /* change chunk size */
+-                  if (pc.m_packetType == 0x01)
++                  if (pc.m_packetType == RTMP_PACKET_TYPE_CHUNK_SIZE)
+                     {
+                       if (pc.m_nBodySize >= 4)
+                         {
+@@ -912,7 +927,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                           server->rs.m_outChunkSize = server->rc.m_inChunkSize;
+                         }
+                     }
+-                  else if (pc.m_packetType == 0x04)
++                  else if (pc.m_packetType == RTMP_PACKET_TYPE_CONTROL)
+                     {
+                       short nType = AMF_DecodeInt16(pc.m_body);
+                       /* SWFverification */
+@@ -929,17 +944,18 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+ #endif
+                     }
+                   else if (server->f_cur && (
+-                       pc.m_packetType == 0x08 ||
+-                       pc.m_packetType == 0x09 ||
+-                       pc.m_packetType == 0x12 ||
+-                       pc.m_packetType == 0x16) &&
++                       pc.m_packetType == RTMP_PACKET_TYPE_AUDIO ||
++                       pc.m_packetType == RTMP_PACKET_TYPE_VIDEO ||
++                       pc.m_packetType == RTMP_PACKET_TYPE_INFO ||
++                       pc.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO) &&
+                        RTMP_ClientPacket(&server->rc, &pc))
+                     {
+                       int len = WriteStream(&buf, &buflen, &server->stamp, &pc);
+                       if (len > 0 && fwrite(buf, 1, len, server->f_cur->f_file) != len)
+                         goto cleanup;
+                     }
+-                  else if ( pc.m_packetType == 0x11 || pc.m_packetType == 0x14)
++                  else if (pc.m_packetType == RTMP_PACKET_TYPE_FLEX_MESSAGE ||
++                           pc.m_packetType == RTMP_PACKET_TYPE_INVOKE)
+                     {
+                       if (ServePacket(server, 1, &pc) && server->f_cur)
+                         {
+-- 
+1.7.10.4
+
+
+From e09abc08504988e5c286ffc9c92da3ba76f95a20 Mon Sep 17 00:00:00 2001
+From: Compn <tempn@twmi.rr.com>
+Date: Tue, 5 Jul 2011 09:48:23 -0400
+Subject: [PATCH 28/34] add -shared to mingw ldflags, fixes compilation error
+ patch by Martin Storsjo
+
+---
+ librtmp/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 1ea31a0..785e869 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -54,7 +54,7 @@ SODIR=$(SODIR_$(SYS))
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+ SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+ 	-headerpad_max_install_names
+-SO_LDFLAGS_mingw=
++SO_LDFLAGS_mingw=-shared
+ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+ 
+ SHARED=yes
+-- 
+1.7.10.4
+
+
+From 0e9b4917c1163227c48cd83e081aa972ed7d3111 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 14:41:11 -0700
+Subject: [PATCH 29/34] Revert "Drop back on the handshake version, avoid
+ rtmpe 9"
+
+This reverts commit aa2825fbb1d1f70652d558a730baed28149ebbdd.
+
+Conflicts:
+
+	librtmp/handshake.h
+---
+ librtmp/handshake.h |    6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index b172dbf..958579a 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -400,10 +400,8 @@ HandShake(RTMP * r, int FP9HandShake)
+       /* set version to at least 9.0.115.0 */
+       if (encrypted)
+ 	{
+-/* 	  clientsig[4] = 128;
+-	  clientsig[6] = 3; */
+-	  clientsig[4] = 9;
+-	  clientsig[6] = 0x7c;
++	  clientsig[4] = 128;
++	  clientsig[6] = 3;
+ 	}
+       else
+         {
+-- 
+1.7.10.4
+
+
+From d1f14b147e03aa17c968b96d6573320410a5252c Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 16:12:39 -0700
+Subject: [PATCH 30/34] Add RTMPE type 9 handshake signature
+
+---
+ librtmp/handshake.h |  349 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 336 insertions(+), 13 deletions(-)
+
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index 958579a..98bf3c8 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -358,6 +358,337 @@ static void rtmpe8_sig(uint8_t *in, uint8_t *out, int keyid)
+   out[7] = v1;
+ }
+ 
++/* RTMPE type 9 uses Blowfish on the regular signature
++ * http://en.wikipedia.org/wiki/Blowfish_(cipher)
++ */
++#define	BF_ROUNDS	16
++typedef struct bf_key {
++	uint32_t s[4][256];
++	uint32_t p[BF_ROUNDS+2];
++} bf_key;
++
++static const uint32_t bf_sinit[][256] = {
++
++  /* S-Box 0 */
++  { 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96,
++    0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
++    0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
++    0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
++    0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e,
++    0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
++    0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6,
++    0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
++    0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
++    0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
++    0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1,
++    0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
++    0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
++    0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
++    0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
++    0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
++    0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706,
++    0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
++    0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b,
++    0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
++    0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
++    0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
++    0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
++    0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
++    0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760,
++    0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
++    0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
++    0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
++    0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33,
++    0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
++    0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0,
++    0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
++    0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
++    0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
++    0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705,
++    0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
++    0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e,
++    0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
++    0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
++    0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
++    0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
++    0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
++    0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, },
++
++  /* S-Box 1 */
++  { 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
++    0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
++    0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
++    0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
++    0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
++    0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
++    0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
++    0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
++    0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
++    0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
++    0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
++    0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
++    0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
++    0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
++    0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
++    0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
++    0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
++    0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
++    0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
++    0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
++    0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
++    0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
++    0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
++    0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
++    0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
++    0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
++    0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
++    0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
++    0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
++    0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
++    0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
++    0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
++    0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
++    0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
++    0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
++    0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
++    0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
++    0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
++    0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
++    0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
++    0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
++    0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
++    0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, },
++
++  /* S-Box 2 */
++  { 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
++    0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
++    0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
++    0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
++    0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4,
++    0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
++    0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
++    0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
++    0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
++    0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
++    0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
++    0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
++    0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22,
++    0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
++    0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60,
++    0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
++    0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
++    0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
++    0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74,
++    0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
++    0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
++    0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
++    0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979,
++    0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
++    0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
++    0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
++    0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
++    0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
++    0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24,
++    0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
++    0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
++    0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
++    0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
++    0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
++    0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe,
++    0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
++    0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0,
++    0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
++    0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188,
++    0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
++    0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
++    0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
++    0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, },
++
++  /* S-Box 3 */
++  { 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
++    0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
++    0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
++    0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
++    0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
++    0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
++    0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
++    0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
++    0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
++    0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
++    0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
++    0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
++    0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
++    0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
++    0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
++    0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
++    0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
++    0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
++    0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
++    0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
++    0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
++    0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
++    0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
++    0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
++    0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
++    0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
++    0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
++    0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
++    0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
++    0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
++    0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
++    0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
++    0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
++    0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
++    0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
++    0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
++    0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
++    0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
++    0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
++    0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
++    0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
++    0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
++    0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6, },
++};
++
++static const uint32_t bf_pinit[] = {
++  /* P-Box */
++  0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
++  0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
++  0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b,
++};
++
++#define KEYBYTES	24
++
++static const unsigned char rtmpe9_keys[16][KEYBYTES] = {
++ { 0x79, 0x34, 0x77, 0x4c, 0x67, 0xd1, 0x38, 0x3a, 0xdf, 0xb3, 0x56, 0xbe,
++   0x8b, 0x7b, 0xd0, 0x24, 0x38, 0xe0, 0x73, 0x58, 0x41, 0x5d, 0x69, 0x67, },
++ { 0x46, 0xf6, 0xb4, 0xcc, 0x01, 0x93, 0xe3, 0xa1, 0x9e, 0x7d, 0x3c, 0x65,
++   0x55, 0x86, 0xfd, 0x09, 0x8f, 0xf7, 0xb3, 0xc4, 0x6f, 0x41, 0xca, 0x5c, },
++ { 0x1a, 0xe7, 0xe2, 0xf3, 0xf9, 0x14, 0x79, 0x94, 0xc0, 0xd3, 0x97, 0x43,
++   0x08, 0x7b, 0xb3, 0x84, 0x43, 0x2f, 0x9d, 0x84, 0x3f, 0x21, 0x01, 0x9b, },
++ { 0xd3, 0xe3, 0x54, 0xb0, 0xf7, 0x1d, 0xf6, 0x2b, 0x5a, 0x43, 0x4d, 0x04,
++   0x83, 0x64, 0x3e, 0x0d, 0x59, 0x2f, 0x61, 0xcb, 0xb1, 0x6a, 0x59, 0x0d, },
++ { 0xc8, 0xc1, 0xe9, 0xb8, 0x16, 0x56, 0x99, 0x21, 0x7b, 0x5b, 0x36, 0xb7,
++   0xb5, 0x9b, 0xdf, 0x06, 0x49, 0x2c, 0x97, 0xf5, 0x95, 0x48, 0x85, 0x7e, },
++ { 0xeb, 0xe5, 0xe6, 0x2e, 0xa4, 0xba, 0xd4, 0x2c, 0xf2, 0x16, 0xe0, 0x8f,
++   0x66, 0x23, 0xa9, 0x43, 0x41, 0xce, 0x38, 0x14, 0x84, 0x95, 0x00, 0x53, },
++ { 0x66, 0xdb, 0x90, 0xf0, 0x3b, 0x4f, 0xf5, 0x6f, 0xe4, 0x9c, 0x20, 0x89,
++   0x35, 0x5e, 0xd2, 0xb2, 0xc3, 0x9e, 0x9f, 0x7f, 0x63, 0xb2, 0x28, 0x81, },
++ { 0xbb, 0x20, 0xac, 0xed, 0x2a, 0x04, 0x6a, 0x19, 0x94, 0x98, 0x9b, 0xc8,
++   0xff, 0xcd, 0x93, 0xef, 0xc6, 0x0d, 0x56, 0xa7, 0xeb, 0x13, 0xd9, 0x30, },
++ { 0xbc, 0xf2, 0x43, 0x82, 0x09, 0x40, 0x8a, 0x87, 0x25, 0x43, 0x6d, 0xe6,
++   0xbb, 0xa4, 0xb9, 0x44, 0x58, 0x3f, 0x21, 0x7c, 0x99, 0xbb, 0x3f, 0x24, },
++ { 0xec, 0x1a, 0xaa, 0xcd, 0xce, 0xbd, 0x53, 0x11, 0xd2, 0xfb, 0x83, 0xb6,
++   0xc3, 0xba, 0xab, 0x4f, 0x62, 0x79, 0xe8, 0x65, 0xa9, 0x92, 0x28, 0x76, },
++ { 0xc6, 0x0c, 0x30, 0x03, 0x91, 0x18, 0x2d, 0x7b, 0x79, 0xda, 0xe1, 0xd5,
++   0x64, 0x77, 0x9a, 0x12, 0xc5, 0xb1, 0xd7, 0x91, 0x4f, 0x96, 0x4c, 0xa3, },
++ { 0xd7, 0x7c, 0x2a, 0xbf, 0xa6, 0xe7, 0x85, 0x7c, 0x45, 0xad, 0xff, 0x12,
++   0x94, 0xd8, 0xde, 0xa4, 0x5c, 0x3d, 0x79, 0xa4, 0x44, 0x02, 0x5d, 0x22, },
++ { 0x16, 0x19, 0x0d, 0x81, 0x6a, 0x4c, 0xc7, 0xf8, 0xb8, 0xf9, 0x4e, 0xcd,
++   0x2c, 0x9e, 0x90, 0x84, 0xb2, 0x08, 0x25, 0x60, 0xe1, 0x1e, 0xae, 0x18, },
++ { 0xe9, 0x7c, 0x58, 0x26, 0x1b, 0x51, 0x9e, 0x49, 0x82, 0x60, 0x61, 0xfc,
++   0xa0, 0xa0, 0x1b, 0xcd, 0xf5, 0x05, 0xd6, 0xa6, 0x6d, 0x07, 0x88, 0xa3, },
++ { 0x2b, 0x97, 0x11, 0x8b, 0xd9, 0x4e, 0xd9, 0xdf, 0x20, 0xe3, 0x9c, 0x10,
++   0xe6, 0xa1, 0x35, 0x21, 0x11, 0xf9, 0x13, 0x0d, 0x0b, 0x24, 0x65, 0xb2, },
++ { 0x53, 0x6a, 0x4c, 0x54, 0xac, 0x8b, 0x9b, 0xb8, 0x97, 0x29, 0xfc, 0x60,
++   0x2c, 0x5b, 0x3a, 0x85, 0x68, 0xb5, 0xaa, 0x6a, 0x44, 0xcd, 0x3f, 0xa7, },
++};
++
++#define	BF_ENC(X,S) \
++	(((S[0][X>>24] + S[1][X>>16 & 0xff]) ^ S[2][(X>>8) & 0xff]) + S[3][X & 0xff])
++
++static void bf_enc(uint32_t *x, bf_key *key)
++{
++  uint32_t  Xl;
++  uint32_t  Xr;
++  uint32_t  temp;
++  int	i;
++
++  Xl = x[0];
++  Xr = x[1];
++
++  for (i = 0; i < BF_ROUNDS; ++i) {
++    Xl ^= key->p[i];
++    Xr ^= BF_ENC(Xl,key->s);
++
++    temp = Xl;
++    Xl = Xr;
++    Xr = temp;
++  }
++
++  Xl ^= key->p[BF_ROUNDS];
++  Xr ^= key->p[BF_ROUNDS + 1];
++
++  x[0] = Xr;
++  x[1] = Xl;
++}
++
++static void bf_setkey(const unsigned char *kp, int keybytes, bf_key *key)
++{
++  int          i;
++  int          j;
++  int          k;
++  uint32_t  data;
++  uint32_t  d[2];
++
++  memcpy(key->p, bf_pinit, sizeof(key->p));
++  memcpy(key->s, bf_sinit, sizeof(key->s));
++
++  j = 0;
++  for (i = 0; i < BF_ROUNDS + 2; ++i) {
++    data = 0x00000000;
++	for (k = 0; k < 4; ++k) {
++	  data = (data << 8) | kp[j];
++	  j = j + 1;
++	  if (j >= keybytes) {
++	    j = 0;
++	  }
++	}
++	key->p[i] ^= data;
++  }
++
++  d[0] = 0x00000000;
++  d[1] = 0x00000000;
++
++  for (i = 0; i < BF_ROUNDS + 2; i += 2) {
++    bf_enc(d, key);
++
++	key->p[i] = d[0];
++	key->p[i + 1] = d[1];
++  }
++
++  for (i = 0; i < 4; ++i) {
++	for (j = 0; j < 256; j += 2) {
++
++	  bf_enc(d, key);
++
++	  key->s[i][j] = d[0];
++	  key->s[i][j + 1] = d[1];
++	}
++  }
++}
++
++static void rtmpe9_sig(uint8_t *in, uint8_t *out, int keyid)
++{
++  uint32_t d[2];
++  bf_key key;
++
++  bf_setkey(rtmpe9_keys[keyid], KEYBYTES, &key);
++
++  /* input is little-endian */
++  d[0] = in[0] | (in[1] << 8) | (in[2] << 16) | (in[3] << 24);
++  d[1] = in[4] | (in[5] << 8) | (in[6] << 16) | (in[7] << 24);
++  bf_enc(d, &key);
++  out[0] = d[0] & 0xff;
++  out[1] = (d[0] >> 8) & 0xff;
++  out[2] = (d[0] >> 16) & 0xff;
++  out[3] = (d[0] >> 24) & 0xff;
++  out[4] = d[1] & 0xff;
++  out[5] = (d[1] >> 8) & 0xff;
++  out[6] = (d[1] >> 16) & 0xff;
++  out[7] = (d[1] >> 24) & 0xff;
++}
++
+ static int
+ HandShake(RTMP * r, int FP9HandShake)
+ {
+@@ -605,8 +936,7 @@ HandShake(RTMP * r, int FP9HandShake)
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+ 	    rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+-#if 0
+-      else if (type == 9))
++      else if (type == 9)
+         {
+ 	  uint8_t *dptr = digestResp;
+ 	  uint8_t *sig = signatureResp;
+@@ -615,7 +945,6 @@ HandShake(RTMP * r, int FP9HandShake)
+             rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+ #endif
+-#endif
+       RTMP_Log(RTMP_LOGDEBUG, "%s: Client signature calculated:", __FUNCTION__);
+       RTMP_LogHex(RTMP_LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
+     }
+@@ -680,7 +1009,6 @@ HandShake(RTMP * r, int FP9HandShake)
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+ 	    rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+-#if 0
+       else if (type == 9)
+         {
+ 	  uint8_t *dptr = digest;
+@@ -690,7 +1018,6 @@ HandShake(RTMP * r, int FP9HandShake)
+             rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+ #endif
+-#endif
+       RTMP_Log(RTMP_LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
+       RTMP_LogHex(RTMP_LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
+       if (memcmp
+@@ -964,8 +1291,7 @@ SHandShake(RTMP * r)
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+ 	    rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+-#if 0
+-      else if (type == 9))
++      else if (type == 9)
+         {
+ 	  uint8_t *dptr = digestResp;
+ 	  uint8_t *sig = signatureResp;
+@@ -974,7 +1300,6 @@ SHandShake(RTMP * r)
+             rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+ #endif
+-#endif
+ 
+       /* some info output */
+       RTMP_Log(RTMP_LOGDEBUG,
+@@ -1030,17 +1355,15 @@ SHandShake(RTMP * r)
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+ 	    rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+-#if 0
+-      else if (type == 9))
++      else if (type == 9)
+         {
+-	  uint8_t *dptr = digestResp;
+-	  uint8_t *sig = signatureResp;
++	  uint8_t *dptr = digest;
++	  uint8_t *sig = signature;
+ 	  /* encrypt signatureResp */
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+             rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+ #endif
+-#endif
+ 
+       /* show some information */
+       RTMP_Log(RTMP_LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
+-- 
+1.7.10.4
+
+
+From be0590a86af80df528e3556b86f110ad4b5cbb27 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 16:41:28 -0700
+Subject: [PATCH 31/34] Add LIB_RTMP macro
+
+Allows changing to static linking on the cmd line
+---
+ Makefile |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index c322e9a..1597be8 100644
+--- a/Makefile
++++ b/Makefile
+@@ -35,7 +35,8 @@ MANDIR=$(DESTDIR)$(mandir)
+ LIBS_posix=
+ LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIBS=-Llibrtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
++LIB_RTMP=-Llibrtmp -lrtmp
++LIBS=$(LIB_RTMP) $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
+ THREADLIB_darwin=-lpthread
+-- 
+1.7.10.4
+
+
+From 4028a5aa7f72cac44a62b4aac596ff3c82e6e019 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 17:19:25 -0700
+Subject: [PATCH 32/34] Additional credit for RTMPE 9 keys
+
+---
+ README |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/README b/README
+index 5689853..865c6c4 100644
+--- a/README
++++ b/README
+@@ -1,7 +1,8 @@
+-RTMP Dump v2.3
++RTMP Dump v2.4
+ (C) 2009 Andrej Stepanchuk
+-(C) 2009-2010 Howard Chu
++(C) 2009-2011 Howard Chu
+ (C) 2010 2a665470ced7adb7156fcef47f8199a6371c117b8a79e399a2771e0b36384090
++(C) 2011 33ae1ce77301f4b4494faaa5f609f3c48b9dcf82
+ License: GPLv2
+ librtmp license: LGPLv2.1
+ http://rtmpdump.mplayerhq.hu/
+-- 
+1.7.10.4
+
+
+From 3121324046e4ca1934e7e28293fc8326475d5053 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 17:22:43 -0700
+Subject: [PATCH 33/34] Version bump
+
+---
+ Makefile         |    2 +-
+ librtmp/Makefile |    2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 1597be8..6ef5742 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,4 +1,4 @@
+-VERSION=v2.3
++VERSION=v2.4
+ 
+ prefix=/usr/local
+ 
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 785e869..d61e7a4 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -1,4 +1,4 @@
+-VERSION=v2.3
++VERSION=v2.4
+ 
+ prefix=/usr/local
+ 
+-- 
+1.7.10.4
+
+
+From c28f1bab7822de97353849e7787b59e50bbb1428 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 17:24:33 -0700
+Subject: [PATCH 34/34] v2.4 changes
+
+---
+ ChangeLog |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index f57c580..fb2319f 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,9 +1,12 @@
+ RTMPDump
+ Copyright 2008-2009 Andrej Stepanchuk; Distributed under the GPL v2
+-Copyright 2009-2010 Howard Chu
++Copyright 2009-2011 Howard Chu
+ Copyright 2009 The Flvstreamer Team
+ http://rtmpdump.mplayerhq.hu/
+ 
++11 July 2011, v2.4
++- add RTMPE type 9 handshake support
++
+ 30 June 2010, v2.3
+ - fix RC4 cleanup for GnuTLS/gcrypt
+ - declare RTMP_Write buf as const
+-- 
+1.7.10.4
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/librtmp-2-master.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,2356 @@
+From dc762e41a090b5c238bd7daedab13def69eb140b Mon Sep 17 00:00:00 2001
+From: toine512 <toine512@gmail.com>
+Date: Thu, 21 Jul 2011 17:10:13 -0700
+Subject: [PATCH 01/33] Squashed commit of the following:
+
+commit 84b160fdc8e6aaff9b5b214d90e8f002cc4185dd
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 23:09:26 2011 +0200
+
+    Updates man .. again
+
+commit 717c562b844595f5b24da268a5f5203d921ebc89
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 21:00:44 2011 +0200
+
+    More updates in man files, regenerating HTML files needed
+
+commit 8196cf03b2ff7b9483166302bf79a0760fed2772
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 20:42:41 2011 +0200
+
+    Updates ChangeLog
+
+commit 7a6931cffd0ffd2d0997ffed2bd7609e9a043387
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 20:37:40 2011 +0200
+
+    Updates man files, regenerating HTML files is needed
+
+commit 1cb67af20bb4085b87123299956c6b4d2d2b1484
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 20:03:16 2011 +0200
+
+    Implements Justin.tv support (NetStream.Authenticate.UsherToken)
+---
+ ChangeLog         |    3 +++
+ librtmp/librtmp.3 |    7 +++++--
+ librtmp/rtmp.c    |   44 ++++++++++++++++++++++++++++++++++++++++++++
+ librtmp/rtmp.h    |    2 ++
+ rtmpdump.1        |    9 +++++++--
+ rtmpdump.c        |   11 +++++++++--
+ rtmpgw.8          |    9 +++++++--
+ rtmpgw.c          |   11 +++++++++--
+ rtmpsrv.c         |    1 +
+ 9 files changed, 87 insertions(+), 10 deletions(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index fb2319f..c3b1a14 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -4,6 +4,9 @@ Copyright 2009-2011 Howard Chu
+ Copyright 2009 The Flvstreamer Team
+ http://rtmpdump.mplayerhq.hu/
+ 
++20 July 2011
++- add NetStream.Authenticate.UsherToken for Justin.tv
++
+ 11 July 2011, v2.4
+ - add RTMPE type 9 handshake support
+ 
+diff --git a/librtmp/librtmp.3 b/librtmp/librtmp.3
+index 66197d5..7c424aa 100644
+--- a/librtmp/librtmp.3
++++ b/librtmp/librtmp.3
+@@ -1,5 +1,5 @@
+-.TH LIBRTMP 3 "2010-07-03" "RTMPDump v2.3"
+-.\" Copyright 2010 Howard Chu.
++.TH LIBRTMP 3 "2011-07-20" "RTMPDump v2.4"
++.\" Copyright 2011 Howard Chu.
+ .\" Copying permitted according to the GNU General Public License V2.
+ .SH NAME
+ librtmp \- RTMPDump Real-Time Messaging Protocol API
+@@ -161,6 +161,9 @@ These options handle additional authentication requests from the server.
+ Key for SecureToken response, used if the server requires SecureToken
+ authentication.
+ .TP
++.BI jtv= JSON
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++.TP
+ .BI swfVfy= 0|1
+ If the value is 1 or TRUE, the SWF player is retrieved from the
+ specified
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 5ef3ae9..adcff1f 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -96,6 +96,7 @@ static int SendDeleteStream(RTMP *r, double dStreamId);
+ static int SendFCSubscribe(RTMP *r, AVal *subscribepath);
+ static int SendPlay(RTMP *r);
+ static int SendBytesReceived(RTMP *r);
++static int SendUsherToken(RTMP *r, AVal *usherToken);
+ 
+ #if 0				/* unused */
+ static int SendBGHasStream(RTMP *r, double dId, AVal *playpath);
+@@ -335,6 +336,7 @@ RTMP_SetupStream(RTMP *r,
+ 		 uint32_t swfSize,
+ 		 AVal *flashVer,
+ 		 AVal *subscribepath,
++		 AVal *usherToken,
+ 		 int dStart,
+ 		 int dStop, int bLiveStream, long int timeout)
+ {
+@@ -355,6 +357,8 @@ RTMP_SetupStream(RTMP *r,
+     RTMP_Log(RTMP_LOGDEBUG, "auth     : %s", auth->av_val);
+   if (subscribepath && subscribepath->av_val)
+     RTMP_Log(RTMP_LOGDEBUG, "subscribepath : %s", subscribepath->av_val);
++  if (usherToken && usherToken->av_val)
++    RTMP_Log(RTMP_LOGDEBUG, "NetStream.Authenticate.UsherToken : %s", usherToken->av_val);
+   if (flashVer && flashVer->av_val)
+     RTMP_Log(RTMP_LOGDEBUG, "flashVer : %s", flashVer->av_val);
+   if (dStart > 0)
+@@ -420,6 +424,8 @@ RTMP_SetupStream(RTMP *r,
+     r->Link.flashVer = RTMP_DefaultFlashVer;
+   if (subscribepath && subscribepath->av_len)
+     r->Link.subscribepath = *subscribepath;
++  if (usherToken && usherToken->av_len)
++    r->Link.usherToken = *usherToken;
+   r->Link.seekTime = dStart;
+   r->Link.stopTime = dStop;
+   if (bLiveStream)
+@@ -477,6 +483,8 @@ static struct urlopt {
+   	"Stream is live, no seeking possible" },
+   { AVC("subscribe"), OFF(Link.subscribepath), OPT_STR, 0,
+   	"Stream to subscribe to" },
++  { AVC("jtv"), OFF(Link.usherToken),          OPT_STR, 0,
++  	"Justin.tv authentication token" },
+   { AVC("token"),     OFF(Link.token),	       OPT_STR, 0,
+   	"Key for SecureToken response" },
+   { AVC("swfVfy"),    OFF(Link.lFlags),        OPT_BOOL, RTMP_LF_SWFV,
+@@ -1641,6 +1649,39 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
+   return RTMP_SendPacket(r, &packet, TRUE);
+ }
+ 
++//Justin.tv specific authentication
++static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken"); //SAVC() isn't suitable for that
++
++static int
++SendUsherToken(RTMP *r, AVal *usherToken)
++{
++  RTMPPacket packet;
++  char pbuf[1024], *pend = pbuf + sizeof(pbuf);
++  char *enc;
++  packet.m_nChannel = 0x03;	/* control channel (invoke) */
++  packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
++  packet.m_nTimeStamp = 0;
++  packet.m_nInfoField2 = 0;
++  packet.m_hasAbsTimestamp = 0;
++  packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;
++
++  RTMP_Log(RTMP_LOGDEBUG, "UsherToken: %s", usherToken->av_val);
++  enc = packet.m_body;
++  enc = AMF_EncodeString(enc, pend, &av_NetStream_Authenticate_UsherToken);
++  enc = AMF_EncodeNumber(enc, pend, ++r->m_numInvokes);
++  *enc++ = AMF_NULL;
++  enc = AMF_EncodeString(enc, pend, usherToken);
++
++  if (!enc)
++    return FALSE;
++
++  packet.m_nBodySize = enc - packet.m_body;
++
++  return RTMP_SendPacket(r, &packet, FALSE);
++}
++/******************************************/
++
+ SAVC(releaseStream);
+ 
+ static int
+@@ -2364,6 +2405,9 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ 
+ 	  if (!(r->Link.protocol & RTMP_FEATURE_WRITE))
+ 	    {
++	      /* Authenticate on Justin.tv legacy servers before sending FCSubscribe */
++	      if (r->Link.usherToken.av_len)
++	        SendUsherToken(r, &r->Link.usherToken);
+ 	      /* Send the FCSubscribe if live stream or if subscribepath is set */
+ 	      if (r->Link.subscribepath.av_len)
+ 	        SendFCSubscribe(r, &r->Link.subscribepath);
+diff --git a/librtmp/rtmp.h b/librtmp/rtmp.h
+index 1ece207..6b2ae5b 100644
+--- a/librtmp/rtmp.h
++++ b/librtmp/rtmp.h
+@@ -155,6 +155,7 @@ extern "C"
+     AVal auth;
+     AVal flashVer;
+     AVal subscribepath;
++    AVal usherToken;
+     AVal token;
+     AMFObject extras;
+     int edepth;
+@@ -297,6 +298,7 @@ extern "C"
+ 			uint32_t swfSize,
+ 			AVal *flashVer,
+ 			AVal *subscribepath,
++			AVal *usherToken,
+ 			int dStart,
+ 			int dStop, int bLiveStream, long int timeout);
+ 
+diff --git a/rtmpdump.1 b/rtmpdump.1
+index 2395de9..0d9de8d 100644
+--- a/rtmpdump.1
++++ b/rtmpdump.1
+@@ -1,5 +1,5 @@
+-.TH RTMPDUMP 1 "2010-05-02" "RTMPDump v2.2e"
+-.\" Copyright 2010 Howard Chu.
++.TH RTMPDUMP 1 "2011-07-20" "RTMPDump v2.4"
++.\" Copyright 2011 Howard Chu.
+ .\" Copying permitted according to the GNU General Public License V2.
+ .SH NAME
+ rtmpdump \- RTMP streaming media client
+@@ -51,6 +51,8 @@ rtmpdump \- RTMP streaming media client
+ [\c
+ .BI \-T \ key\fR]
+ [\c
++.BI \-j \ JSON\fR]
++[\c
+ .BI \-w \ swfHash\fR]
+ [\c
+ .BI \-x \ swfSize\fR]
+@@ -210,6 +212,9 @@ These options handle additional authentication requests from the server.
+ Key for SecureToken response, used if the server requires SecureToken
+ authentication.
+ .TP
++\fB\-\-jtv		\-j\fP\ \fIJSON\fP
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++.TP
+ \fB\-\-swfhash		\-w\fP\ \fIhexstring\fP
+ SHA256 hash of the decompressed SWF file. This option may be needed if
+ the server uses SWF Verification, but see the
+diff --git a/rtmpdump.c b/rtmpdump.c
+index c1cd95b..ec1de85 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -692,6 +692,8 @@ void usage(char *prog)
+ 	  RTMP_LogPrintf
+ 	    ("--token|-T key          Key for SecureToken response\n");
+ 	  RTMP_LogPrintf
++	    ("--jtv|-j JSON           Authentication token for Justin.tv legacy servers\n");
++	  RTMP_LogPrintf
+ 	    ("--hashes|-#             Display progress with hashes, not with the byte counter\n");
+ 	  RTMP_LogPrintf
+ 	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n",
+@@ -738,6 +740,7 @@ main(int argc, char **argv)
+   AVal hostname = { 0, 0 };
+   AVal playpath = { 0, 0 };
+   AVal subscribepath = { 0, 0 };
++  AVal usherToken = { 0, 0 }; //Justin.tv auth token
+   int port = -1;
+   int protocol = RTMP_PROTOCOL_UNDEFINED;
+   int retries = 0;
+@@ -839,12 +842,13 @@ main(int argc, char **argv)
+     {"debug", 0, NULL, 'z'},
+     {"quiet", 0, NULL, 'q'},
+     {"verbose", 0, NULL, 'V'},
++    {"jtv", 1, NULL, 'j'},
+     {0, 0, 0, 0}
+   };
+ 
+   while ((opt =
+ 	  getopt_long(argc, argv,
+-		      "hVveqzr:s:t:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#",
++		      "hVveqzr:s:t:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#j:",
+ 		      longopts, NULL)) != -1)
+     {
+       switch (opt)
+@@ -1051,6 +1055,9 @@ main(int argc, char **argv)
+ 	case 'S':
+ 	  STR2AVAL(sockshost, optarg);
+ 	  break;
++    case 'j':
++      STR2AVAL(usherToken, optarg);
++      break;
+ 	default:
+ 	  RTMP_LogPrintf("unknown option: %c\n", opt);
+ 	  usage(argv[0]);
+@@ -1167,7 +1174,7 @@ main(int argc, char **argv)
+ 
+   RTMP_SetupStream(&rtmp, protocol, &hostname, port, &sockshost, &playpath,
+ 		   &tcUrl, &swfUrl, &pageUrl, &app, &auth, &swfHash, swfSize,
+-		   &flashVer, &subscribepath, dSeek, dStopOffset, bLiveStream, timeout);
++		   &flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout);
+ 
+   /* Try to keep the stream moving if it pauses on us */
+   if (!bLiveStream && !(protocol & RTMP_FEATURE_HTTP))
+diff --git a/rtmpgw.8 b/rtmpgw.8
+index 197a2d6..0a231b4 100644
+--- a/rtmpgw.8
++++ b/rtmpgw.8
+@@ -1,5 +1,5 @@
+-.TH RTMPGW 8 "2010-05-02" "RTMPDump v2.2e"
+-.\" Copyright 2010 Howard Chu.
++.TH RTMPGW 8 "2011-07-20" "RTMPDump v2.4"
++.\" Copyright 2011 Howard Chu.
+ .\" Copying permitted according to the GNU General Public License V2.
+ .SH NAME
+ rtmpgw \- RTMP streaming media gateway
+@@ -50,6 +50,8 @@ rtmpgw \- RTMP streaming media gateway
+ [\c
+ .BI \-T \ key\fR]
+ [\c
++.BI \-j \ JSON\fR]
++[\c
+ .BI \-w \ swfHash\fR]
+ [\c
+ .BI \-x \ swfSize\fR]
+@@ -193,6 +195,9 @@ These options handle additional authentication requests from the server.
+ Key for SecureToken response, used if the server requires SecureToken
+ authentication.
+ .TP
++\fB\-\-jtv		\-j\fP\ \fIJSON\fP
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++.TP
+ \fB\-\-swfhash		\-w\fP\ \fIhexstring\fP
+ SHA256 hash of the decompressed SWF file. This option may be needed if
+ the server uses SWF Verification, but see the
+diff --git a/rtmpgw.c b/rtmpgw.c
+index 10a99e8..ce7319a 100644
+--- a/rtmpgw.c
++++ b/rtmpgw.c
+@@ -95,6 +95,7 @@ typedef struct
+   AVal flashVer;
+   AVal token;
+   AVal subscribepath;
++  AVal usherToken; //Justin.tv auth token
+   AVal sockshost;
+   AMFObject extras;
+   int edepth;
+@@ -552,7 +553,7 @@ void processTCPrequest(STREAMING_SERVER * server,	// server socket and state (ou
+   RTMP_Init(&rtmp);
+   RTMP_SetBufferMS(&rtmp, req.bufferTime);
+   RTMP_SetupStream(&rtmp, req.protocol, &req.hostname, req.rtmpport, &req.sockshost,
+-		   &req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, dSeek, req.dStopOffset,
++		   &req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, &req.usherToken, dSeek, req.dStopOffset,
+ 		   req.bLiveStream, req.timeout);
+   /* backward compatibility, we always sent this as true before */
+   if (req.auth.av_len)
+@@ -953,6 +954,9 @@ ParseOption(char opt, char *arg, RTMP_REQUEST * req)
+     case 'z':
+       RTMP_debuglevel = RTMP_LOGALL;
+       break;
++    case 'j':
++      STR2AVAL(req->usherToken, arg);
++      break;
+     default:
+       RTMP_LogPrintf("unknown option: %c, arg: %s\n", opt, arg);
+       return FALSE;
+@@ -1023,6 +1027,7 @@ main(int argc, char **argv)
+     {"debug", 0, NULL, 'z'},
+     {"quiet", 0, NULL, 'q'},
+     {"verbose", 0, NULL, 'V'},
++    {"jtv", 1, NULL, 'j'},
+     {0, 0, 0, 0}
+   };
+ 
+@@ -1035,7 +1040,7 @@ main(int argc, char **argv)
+ 
+   while ((opt =
+ 	  getopt_long(argc, argv,
+-		      "hvqVzr:s:t:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:", longopts,
++		      "hvqVzr:s:t:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:j:", longopts,
+ 		      NULL)) != -1)
+     {
+       switch (opt)
+@@ -1095,6 +1100,8 @@ main(int argc, char **argv)
+ 	    ("--stop|-B num           Stop at num seconds into stream\n");
+ 	  RTMP_LogPrintf
+ 	    ("--token|-T key          Key for SecureToken response\n");
++      RTMP_LogPrintf
++	    ("--jtv|-j JSON           Authentication token for Justin.tv legacy servers\n");
+ 	  RTMP_LogPrintf
+ 	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n\n",
+ 	     defaultRTMPRequest.bufferTime);
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index f1b6c66..cf52bfa 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -116,6 +116,7 @@ typedef struct
+   AVal swfHash;
+   AVal flashVer;
+   AVal subscribepath;
++  AVal usherToken;
+   uint32_t swfSize;
+ 
+   uint32_t dStartOffset;
+-- 
+1.7.10.4
+
+
+From a2fb387404cb0da99cf439d58478fff701398700 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Thu, 21 Jul 2011 17:31:14 -0700
+Subject: [PATCH 02/33] Regenerate HTML docs, minor tweaks
+
+---
+ librtmp/librtmp.3.html |   10 ++++++++--
+ librtmp/rtmp.c         |    6 +++---
+ rtmpdump.1.html        |   11 +++++++++--
+ rtmpdump.c             |    6 +++---
+ rtmpgw.8.html          |   11 +++++++++--
+ rtmpgw.c               |    2 +-
+ rtmpsrv.c              |    1 -
+ 7 files changed, 33 insertions(+), 14 deletions(-)
+
+diff --git a/librtmp/librtmp.3.html b/librtmp/librtmp.3.html
+index e5e6f4b..6f59851 100644
+--- a/librtmp/librtmp.3.html
++++ b/librtmp/librtmp.3.html
+@@ -6,10 +6,10 @@
+ <tr><td>LIBRTMP(3)<td align="center"><td align="right">LIBRTMP(3)
+ </thead>
+ <tfoot>
+-<tr><td>RTMPDump v2.3<td align="center">2010-07-03<td align="right">LIBRTMP(3)
++<tr><td>RTMPDump v2.4<td align="center">2011-07-20<td align="right">LIBRTMP(3)
+ </tfoot>
+ <tbody><tr><td colspan="3"><br><br><ul>
+-<!-- Copyright 2010 Howard Chu.
++<!-- Copyright 2011 Howard Chu.
+  Copying permitted according to the GNU General Public License V2.-->
+ </ul>
+ 
+@@ -238,6 +238,12 @@ authentication.
+ </dl>
+ <p>
+ <dl compact><dt>
++<b>jtv=</b><i>JSON</i>
++<dd>
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++</dl>
++<p>
++<dl compact><dt>
+ <b>swfVfy=</b><i>0|1</i>
+ <dd>
+ If the value is 1 or TRUE, the SWF player is retrieved from the
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index adcff1f..8d76164 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -484,7 +484,7 @@ static struct urlopt {
+   { AVC("subscribe"), OFF(Link.subscribepath), OPT_STR, 0,
+   	"Stream to subscribe to" },
+   { AVC("jtv"), OFF(Link.usherToken),          OPT_STR, 0,
+-  	"Justin.tv authentication token" },
++	"Justin.tv authentication token" },
+   { AVC("token"),     OFF(Link.token),	       OPT_STR, 0,
+   	"Key for SecureToken response" },
+   { AVC("swfVfy"),    OFF(Link.lFlags),        OPT_BOOL, RTMP_LF_SWFV,
+@@ -1649,8 +1649,8 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
+   return RTMP_SendPacket(r, &packet, TRUE);
+ }
+ 
+-//Justin.tv specific authentication
+-static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken"); //SAVC() isn't suitable for that
++/* Justin.tv specific authentication */
++static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken");
+ 
+ static int
+ SendUsherToken(RTMP *r, AVal *usherToken)
+diff --git a/rtmpdump.1.html b/rtmpdump.1.html
+index 7f17636..826f722 100644
+--- a/rtmpdump.1.html
++++ b/rtmpdump.1.html
+@@ -6,10 +6,10 @@
+ <tr><td>RTMPDUMP(1)<td align="center"><td align="right">RTMPDUMP(1)
+ </thead>
+ <tfoot>
+-<tr><td>RTMPDump v2.2e<td align="center">2010-05-02<td align="right">RTMPDUMP(1)
++<tr><td>RTMPDump v2.4<td align="center">2011-07-20<td align="right">RTMPDUMP(1)
+ </tfoot>
+ <tbody><tr><td colspan="3"><br><br><ul>
+-<!-- Copyright 2010 Howard Chu.
++<!-- Copyright 2011 Howard Chu.
+  Copying permitted according to the GNU General Public License V2.-->
+ </ul>
+ 
+@@ -42,6 +42,7 @@ rtmpdump &minus; RTMP streaming media client
+ [<b>&minus;b</b><i>&nbsp;buffer</i>]
+ [<b>&minus;m</b><i>&nbsp;timeout</i>]
+ [<b>&minus;T</b><i>&nbsp;key</i>]
++[<b>&minus;j</b><i>&nbsp;JSON</i>]
+ [<b>&minus;w</b><i>&nbsp;swfHash</i>]
+ [<b>&minus;x</b><i>&nbsp;swfSize</i>]
+ [<b>&minus;W</b><i>&nbsp;swfUrl</i>]
+@@ -275,6 +276,12 @@ authentication.
+ </dl>
+ <p>
+ <dl compact><dt>
++<b>&minus;&minus;jtv		&minus;j</b>&nbsp;<i>JSON</i>
++<dd>
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++</dl>
++<p>
++<dl compact><dt>
+ <b>&minus;&minus;swfhash		&minus;w</b>&nbsp;<i>hexstring</i>
+ <dd>
+ SHA256 hash of the decompressed SWF file. This option may be needed if
+diff --git a/rtmpdump.c b/rtmpdump.c
+index ec1de85..89c053a 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -1055,9 +1055,9 @@ main(int argc, char **argv)
+ 	case 'S':
+ 	  STR2AVAL(sockshost, optarg);
+ 	  break;
+-    case 'j':
+-      STR2AVAL(usherToken, optarg);
+-      break;
++	case 'j':
++	  STR2AVAL(usherToken, optarg);
++	  break;
+ 	default:
+ 	  RTMP_LogPrintf("unknown option: %c\n", opt);
+ 	  usage(argv[0]);
+diff --git a/rtmpgw.8.html b/rtmpgw.8.html
+index 58b8f35..68d6734 100644
+--- a/rtmpgw.8.html
++++ b/rtmpgw.8.html
+@@ -6,10 +6,10 @@
+ <tr><td>RTMPGW(8)<td align="center"><td align="right">RTMPGW(8)
+ </thead>
+ <tfoot>
+-<tr><td>RTMPDump v2.2e<td align="center">2010-05-02<td align="right">RTMPGW(8)
++<tr><td>RTMPDump v2.4<td align="center">2011-07-20<td align="right">RTMPGW(8)
+ </tfoot>
+ <tbody><tr><td colspan="3"><br><br><ul>
+-<!-- Copyright 2010 Howard Chu.
++<!-- Copyright 2011 Howard Chu.
+  Copying permitted according to the GNU General Public License V2.-->
+ </ul>
+ 
+@@ -41,6 +41,7 @@ rtmpgw &minus; RTMP streaming media gateway
+ [<b>&minus;b</b><i>&nbsp;buffer</i>]
+ [<b>&minus;m</b><i>&nbsp;timeout</i>]
+ [<b>&minus;T</b><i>&nbsp;key</i>]
++[<b>&minus;j</b><i>&nbsp;JSON</i>]
+ [<b>&minus;w</b><i>&nbsp;swfHash</i>]
+ [<b>&minus;x</b><i>&nbsp;swfSize</i>]
+ [<b>&minus;W</b><i>&nbsp;swfUrl</i>]
+@@ -249,6 +250,12 @@ authentication.
+ </dl>
+ <p>
+ <dl compact><dt>
++<b>&minus;&minus;jtv		&minus;j</b>&nbsp;<i>JSON</i>
++<dd>
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++</dl>
++<p>
++<dl compact><dt>
+ <b>&minus;&minus;swfhash		&minus;w</b>&nbsp;<i>hexstring</i>
+ <dd>
+ SHA256 hash of the decompressed SWF file. This option may be needed if
+diff --git a/rtmpgw.c b/rtmpgw.c
+index ce7319a..733e105 100644
+--- a/rtmpgw.c
++++ b/rtmpgw.c
+@@ -1100,7 +1100,7 @@ main(int argc, char **argv)
+ 	    ("--stop|-B num           Stop at num seconds into stream\n");
+ 	  RTMP_LogPrintf
+ 	    ("--token|-T key          Key for SecureToken response\n");
+-      RTMP_LogPrintf
++	  RTMP_LogPrintf
+ 	    ("--jtv|-j JSON           Authentication token for Justin.tv legacy servers\n");
+ 	  RTMP_LogPrintf
+ 	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n\n",
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index cf52bfa..f1b6c66 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -116,7 +116,6 @@ typedef struct
+   AVal swfHash;
+   AVal flashVer;
+   AVal subscribepath;
+-  AVal usherToken;
+   uint32_t swfSize;
+ 
+   uint32_t dStartOffset;
+-- 
+1.7.10.4
+
+
+From ed99ad05b34031fac74230760c77d4d1a6a9e706 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Sat, 30 Apr 2011 14:29:58 +0300
+Subject: [PATCH 03/33] Remove the generated pkg-config file on make clean
+
+---
+ librtmp/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index d61e7a4..c95c8a6 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -76,7 +76,7 @@ OBJS=rtmp.o log.o amf.o hashswf.o parseurl.o
+ all:	librtmp.a $(SO_LIB)
+ 
+ clean:
+-	rm -f *.o *.a *.$(SOX) *.$(SO_EXT)
++	rm -f *.o *.a *.$(SOX) *.$(SO_EXT) librtmp.pc
+ 
+ librtmp.a: $(OBJS)
+ 	$(AR) rs $@ $?
+-- 
+1.7.10.4
+
+
+From 749018b7c7c4e0090ea17c104dc094ab74326c08 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Sat, 30 Apr 2011 14:30:00 +0300
+Subject: [PATCH 04/33] Create the SODIR, too
+
+When SYS=mingw, this differs from LIBDIR.
+---
+ librtmp/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index c95c8a6..aa4a339 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -100,7 +100,7 @@ librtmp.pc: librtmp.pc.in Makefile
+ install:	install_base $(SO_INST)
+ 
+ install_base:	librtmp.a librtmp.pc
+-	-mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3
++	-mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3 $(SODIR)
+ 	cp amf.h http.h log.h rtmp.h $(INCDIR)
+ 	cp librtmp.a $(LIBDIR)
+ 	cp librtmp.pc $(LIBDIR)/pkgconfig
+-- 
+1.7.10.4
+
+
+From 9931c44867d157621ae10cf489ba336091dfab6b Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Sat, 30 Apr 2011 14:30:01 +0300
+Subject: [PATCH 05/33] Generate and install an import lib for the built DLL
+
+---
+ librtmp/Makefile |    8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index aa4a339..b88baf4 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -54,9 +54,14 @@ SODIR=$(SODIR_$(SYS))
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+ SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+ 	-headerpad_max_install_names
+-SO_LDFLAGS_mingw=-shared
++SO_LDFLAGS_mingw=-shared -Wl,--out-implib,librtmp.dll.a
+ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+ 
++INSTALL_IMPLIB_posix=
++INSTALL_IMPLIB_darwin=
++INSTALL_IMPLIB_mingw=cp librtmp.dll.a $(LIBDIR)
++INSTALL_IMPLIB=$(INSTALL_IMPLIB_$(SYS))
++
+ SHARED=yes
+ SODEF_yes=-fPIC
+ SOLIB_yes=librtmp.$(SO_EXT)
+@@ -108,5 +113,6 @@ install_base:	librtmp.a librtmp.pc
+ 
+ install_so:	librtmp.$(SO_EXT)
+ 	cp librtmp.$(SO_EXT) $(SODIR)
++	$(INSTALL_IMPLIB)
+ 	cd $(SODIR); ln -sf librtmp.$(SO_EXT) librtmp.$(SOX)
+ 
+-- 
+1.7.10.4
+
+
+From 060206d121657d7e45c01ac022dd071c877b4caa Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Fri, 15 Jul 2011 13:46:02 +0300
+Subject: [PATCH 06/33] Check the return value from RTMP_SendBytesReceived()
+
+This avoids double frees in RTMP_Close(), if the
+RTMP_SendBytesReceived() call failed, which earlier led
+to RTMP_ReadPacket() writing back an already freed buffer
+(freed by RTMP_Close() within WriteN()) into m_vecChannelsIn.
+---
+ librtmp/rtmp.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 8d76164..f85cd83 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -1338,7 +1338,8 @@ ReadN(RTMP *r, char *buffer, int n)
+ 	  r->m_nBytesIn += nRead;
+ 	  if (r->m_bSendCounter
+ 	      && r->m_nBytesIn > r->m_nBytesInSent + r->m_nClientBW / 2)
+-	    SendBytesReceived(r);
++	    if (!SendBytesReceived(r))
++	        return FALSE;
+ 	}
+       /*RTMP_Log(RTMP_LOGDEBUG, "%s: %d bytes\n", __FUNCTION__, nBytes); */
+ #ifdef _DEBUG
+-- 
+1.7.10.4
+
+
+From 159a06ebe6d82ef20f2c77c497d55af00d2e0b78 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Fri, 15 Jul 2011 13:46:03 +0300
+Subject: [PATCH 07/33] Don't try to close an already closed socket
+
+This could happen if WriteN() (called within SendBytesReceived())
+failed.
+---
+ librtmp/rtmp.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index f85cd83..df2cb27 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -3626,7 +3626,9 @@ RTMPSockBuf_Close(RTMPSockBuf *sb)
+       sb->sb_ssl = NULL;
+     }
+ #endif
+-  return closesocket(sb->sb_socket);
++  if (sb->sb_socket != -1)
++      return closesocket(sb->sb_socket);
++  return 0;
+ }
+ 
+ #define HEX2BIN(a)	(((a)&0x40)?((a)&0xf)+9:((a)&0xf))
+-- 
+1.7.10.4
+
+
+From 530d02fccf24f98e2e318418b2fa3e3420056fda Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Fri, 22 Jul 2011 18:04:05 -0700
+Subject: [PATCH 08/33] Fix MDH_free() for PolarSSL
+
+Reported by Reijo Tomperi <aggro80@users.sourceforge.net>
+---
+ librtmp/dh.h |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/dh.h b/librtmp/dh.h
+index 8e285a6..efef0fd 100644
+--- a/librtmp/dh.h
++++ b/librtmp/dh.h
+@@ -53,7 +53,7 @@ typedef struct MDH {
+ } MDH;
+ 
+ #define MDH_new()	calloc(1,sizeof(MDH))
+-#define MDH_free(vp)	{MDH *dh = vp; dhm_free(&dh->ctx); MP_free(dh->p); MP_free(dh->g); MP_free(dh->pub_key); MP_free(dh->priv_key); free(dh);}
++#define MDH_free(vp)	{MDH *_dh = vp; dhm_free(&_dh->ctx); MP_free(_dh->p); MP_free(_dh->g); MP_free(_dh->pub_key); MP_free(_dh->priv_key); free(_dh);}
+ 
+ static int MDH_generate_key(MDH *dh)
+ {
+-- 
+1.7.10.4
+
+
+From b627335dc37fd5265ac6d23a441ee2d89ab503c8 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Fri, 22 Jul 2011 18:06:27 -0700
+Subject: [PATCH 09/33] Plug potential memleak
+
+Reported by Reijo Tomperi <aggro80@users.sourceforge.net>
+---
+ rtmpdump.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index 89c053a..e506fa9 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -444,7 +444,7 @@ Download(RTMP * rtmp,		// connected RTMP object
+ {
+   int32_t now, lastUpdate;
+   int bufferSize = 64 * 1024;
+-  char *buffer = (char *) malloc(bufferSize);
++  char *buffer;
+   int nRead = 0;
+   off_t size = ftello(file);
+   unsigned long lastPercent = 0;
+@@ -505,6 +505,8 @@ Download(RTMP * rtmp,		// connected RTMP object
+   rtmp->m_read.nMetaHeaderSize = nMetaHeaderSize;
+   rtmp->m_read.nInitialFrameSize = nInitialFrameSize;
+ 
++  buffer = (char *) malloc(bufferSize);
++
+   now = RTMP_GetTime();
+   lastUpdate = now - 1000;
+   do
+-- 
+1.7.10.4
+
+
+From ec422962d58b8e0d9bfcf0af6e450e0e349947da Mon Sep 17 00:00:00 2001
+From: "Scott D. Davilla" <davilla@xbmc.org>
+Date: Fri, 29 Jul 2011 11:26:35 -0700
+Subject: [PATCH 10/33] Darwin dylib updates
+
+Bring in line with current practice for Darwin dynamic libs
+---
+ librtmp/Makefile |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index b88baf4..a0125f1 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -52,8 +52,8 @@ SODIR_mingw=$(BINDIR)
+ SODIR=$(SODIR_$(SYS))
+ 
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+-SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+-	-headerpad_max_install_names
++SO_LDFLAGS_darwin=-dynamiclib -twolevel_namespace -undefined dynamic_lookup \
++	-fno-common -headerpad_max_install_names -install_name $(libdir)/$@
+ SO_LDFLAGS_mingw=-shared -Wl,--out-implib,librtmp.dll.a
+ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+ 
+-- 
+1.7.10.4
+
+
+From 024d201c36e1b40f4f4d473e87d405e1b411230f Mon Sep 17 00:00:00 2001
+From: KSV <faltuvisitor@yahoo.co.in>
+Date: Sun, 31 Jul 2011 12:33:46 -0700
+Subject: [PATCH 11/33] Justin.TV usherToken detection
+
+---
+ rtmpsrv.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 59 insertions(+), 2 deletions(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index f1b6c66..805ce0d 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -95,6 +95,7 @@ STREAMING_SERVER *rtmpServer = 0;	// server structure pointer
+ 
+ STREAMING_SERVER *startStreaming(const char *address, int port);
+ void stopStreaming(STREAMING_SERVER * server);
++char *strreplace(char *srcstr, int srclen, char *orig, char *repl);
+ 
+ typedef struct
+ {
+@@ -261,6 +262,7 @@ static const AVal av_NetStream_Play_Stop = AVC("NetStream.Play.Stop");
+ static const AVal av_Stopped_playing = AVC("Stopped playing");
+ SAVC(details);
+ SAVC(clientid);
++static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken");
+ 
+ static int
+ SendPlayStart(RTMP *r)
+@@ -575,6 +577,13 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+     {
+       SendResultNumber(r, txn, 10.0);
+     }
++  else if (AVMATCH(&method, &av_NetStream_Authenticate_UsherToken))
++    {
++      AMFObjectProperty *prop = AMF_GetProp(&obj, NULL, 3);
++      AMFProp_GetString(prop, &r->Link.usherToken);
++      prop->p_vu.p_aval.av_len = 0;
++      prop->p_vu.p_aval.av_val = NULL;
++    }
+   else if (AVMATCH(&method, &av_play))
+     {
+       char *file, *p, *q, *cmd, *ptr;
+@@ -591,10 +600,11 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+       if (r->Link.tcUrl.av_len)
+ 	{
+ 	  len = server->arglen + r->Link.playpath.av_len + 4 +
+-	    sizeof("rtmpdump") + r->Link.playpath.av_len + 12;
++	    sizeof("rtmpdump") + r->Link.playpath.av_len + 12 +
++	    r->Link.usherToken.av_len + 64;
+ 	  server->argc += 5;
+ 
+-	  cmd = malloc(len + server->argc * sizeof(AVal));
++	  cmd = malloc(len + (server->argc + 2) * sizeof(AVal));
+ 	  ptr = cmd;
+ 	  argv = (AVal *)(cmd + len);
+ 	  argv[0].av_val = cmd;
+@@ -640,6 +650,17 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+ 	      ptr += sprintf(ptr, " -p \"%s\"", r->Link.pageUrl.av_val);
+ 	      argv[argc++].av_len = r->Link.pageUrl.av_len;
+ 	    }
++          if (r->Link.usherToken.av_val)
++            {
++              char *usherToken = strreplace(r->Link.usherToken.av_val, r->Link.usherToken.av_len, "\"", "\\\"");
++	      argv[argc].av_val = ptr + 1;
++	      argv[argc++].av_len = 5;
++	      argv[argc].av_val = ptr + 8;
++              ptr += sprintf(ptr, " --jtv \"%s\"", usherToken);
++	      argv[argc++].av_len = strlen(usherToken);
++              server->argc += 2;
++              free(usherToken);
++            }
+ 	  if (r->Link.extras.o_num) {
+ 	    ptr = dumpAMF(&r->Link.extras, ptr, argv, &argc);
+ 	    AMF_Reset(&r->Link.extras);
+@@ -1111,3 +1132,39 @@ main(int argc, char **argv)
+ #endif
+   return nStatus;
+ }
++
++char *
++strreplace(char *srcstr, int srclen, char *orig, char *repl)
++{
++  char *ptr = NULL, *srcstrstart = srcstr;
++  int origlen = strlen(orig);
++  int repllen = strlen(repl);
++  if (!srclen)
++    srclen = strlen(srcstr);
++  char *srcend = srcstr + srclen;
++  int deststrbuffer = srclen / origlen * repllen;
++  if (deststrbuffer < srclen)
++    deststrbuffer = srclen;
++  char *deststr = calloc(deststrbuffer + 1, sizeof(char));
++  char *deststrstart = deststr;
++
++  if ( (ptr = strstr(srcstr, orig)) )
++  {
++    do
++    {
++      int len = ptr - srcstrstart;
++      memcpy(deststrstart, srcstrstart, len);
++      srcstrstart += len + origlen;
++      deststrstart += len;
++      memcpy(deststrstart, repl, repllen);
++      deststrstart += repllen;
++      ptr = strstr(srcstrstart, orig);
++    }
++    while (ptr && (ptr < srcend));
++    strncpy(deststrstart, srcstrstart, srcend-srcstrstart);
++    return deststr;
++  }
++
++  strncpy(deststr, srcstr, srclen);
++  return deststr;
++}
+-- 
+1.7.10.4
+
+
+From f1abda046ca5a3f1efa63033c542e686b43dbcf3 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Sun, 31 Jul 2011 13:21:12 -0700
+Subject: [PATCH 12/33] Cleanup previous commit
+
+---
+ rtmpsrv.c |  111 ++++++++++++++++++++++++++++++++++---------------------------
+ 1 file changed, 62 insertions(+), 49 deletions(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index 805ce0d..b45aae3 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -1,6 +1,6 @@
+ /*  Simple RTMP Server
+  *  Copyright (C) 2009 Andrej Stepanchuk
+- *  Copyright (C) 2009 Howard Chu
++ *  Copyright (C) 2009-2011 Howard Chu
+  *
+  *  This Program is free software; you can redistribute it and/or modify
+  *  it under the terms of the GNU General Public License as published by
+@@ -95,7 +95,10 @@ STREAMING_SERVER *rtmpServer = 0;	// server structure pointer
+ 
+ STREAMING_SERVER *startStreaming(const char *address, int port);
+ void stopStreaming(STREAMING_SERVER * server);
+-char *strreplace(char *srcstr, int srclen, char *orig, char *repl);
++void AVreplace(AVal *src, const AVal *orig, const AVal *repl);
++
++static const AVal av_dquote = AVC("\"");
++static const AVal av_escdquote = AVC("\\\"");
+ 
+ typedef struct
+ {
+@@ -579,10 +582,12 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+     }
+   else if (AVMATCH(&method, &av_NetStream_Authenticate_UsherToken))
+     {
+-      AMFObjectProperty *prop = AMF_GetProp(&obj, NULL, 3);
+-      AMFProp_GetString(prop, &r->Link.usherToken);
+-      prop->p_vu.p_aval.av_len = 0;
+-      prop->p_vu.p_aval.av_val = NULL;
++      AVal usherToken;
++      AMFProp_GetString(AMF_GetProp(&obj, NULL, 3), &usherToken);
++      AVreplace(&usherToken, &av_dquote, &av_escdquote);
++      server->arglen += 6 + usherToken.av_len;
++      server->argc += 2;
++      r->Link.usherToken = usherToken;
+     }
+   else if (AVMATCH(&method, &av_play))
+     {
+@@ -600,11 +605,10 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+       if (r->Link.tcUrl.av_len)
+ 	{
+ 	  len = server->arglen + r->Link.playpath.av_len + 4 +
+-	    sizeof("rtmpdump") + r->Link.playpath.av_len + 12 +
+-	    r->Link.usherToken.av_len + 64;
++	    sizeof("rtmpdump") + r->Link.playpath.av_len + 12;
+ 	  server->argc += 5;
+ 
+-	  cmd = malloc(len + (server->argc + 2) * sizeof(AVal));
++	  cmd = malloc(len + server->argc * sizeof(AVal));
+ 	  ptr = cmd;
+ 	  argv = (AVal *)(cmd + len);
+ 	  argv[0].av_val = cmd;
+@@ -650,17 +654,17 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+ 	      ptr += sprintf(ptr, " -p \"%s\"", r->Link.pageUrl.av_val);
+ 	      argv[argc++].av_len = r->Link.pageUrl.av_len;
+ 	    }
+-          if (r->Link.usherToken.av_val)
+-            {
+-              char *usherToken = strreplace(r->Link.usherToken.av_val, r->Link.usherToken.av_len, "\"", "\\\"");
++	  if (r->Link.usherToken.av_val)
++	    {
+ 	      argv[argc].av_val = ptr + 1;
+-	      argv[argc++].av_len = 5;
+-	      argv[argc].av_val = ptr + 8;
+-              ptr += sprintf(ptr, " --jtv \"%s\"", usherToken);
+-	      argv[argc++].av_len = strlen(usherToken);
+-              server->argc += 2;
+-              free(usherToken);
+-            }
++	      argv[argc++].av_len = 2;
++	      argv[argc].av_val = ptr + 5;
++	      ptr += sprintf(ptr, " -j \"%s\"", r->Link.usherToken.av_val);
++	      argv[argc++].av_len = r->Link.usherToken.av_len;
++	      free(r->Link.usherToken.av_val);
++	      r->Link.usherToken.av_val = NULL;
++	      r->Link.usherToken.av_len = 0;
++	    }
+ 	  if (r->Link.extras.o_num) {
+ 	    ptr = dumpAMF(&r->Link.extras, ptr, argv, &argc);
+ 	    AMF_Reset(&r->Link.extras);
+@@ -932,6 +936,11 @@ cleanup:
+   rtmp.Link.pageUrl.av_val = NULL;
+   rtmp.Link.app.av_val = NULL;
+   rtmp.Link.flashVer.av_val = NULL;
++  if (rtmp.Link.usherToken.av_val)
++    {
++      free(rtmp.Link.usherToken.av_val);
++      rtmp.Link.usherToken.av_val = NULL;
++    }
+   RTMP_LogPrintf("done!\n\n");
+ 
+ quit:
+@@ -1133,38 +1142,42 @@ main(int argc, char **argv)
+   return nStatus;
+ }
+ 
+-char *
+-strreplace(char *srcstr, int srclen, char *orig, char *repl)
++void
++AVreplace(AVal *src, const AVal *orig, const AVal *repl)
+ {
+-  char *ptr = NULL, *srcstrstart = srcstr;
+-  int origlen = strlen(orig);
+-  int repllen = strlen(repl);
+-  if (!srclen)
+-    srclen = strlen(srcstr);
+-  char *srcend = srcstr + srclen;
+-  int deststrbuffer = srclen / origlen * repllen;
+-  if (deststrbuffer < srclen)
+-    deststrbuffer = srclen;
+-  char *deststr = calloc(deststrbuffer + 1, sizeof(char));
+-  char *deststrstart = deststr;
+-
+-  if ( (ptr = strstr(srcstr, orig)) )
+-  {
+-    do
++  char *srcbeg = src->av_val;
++  char *srcend = src->av_val + src->av_len;
++  char *dest, *sptr, *dptr;
++  int n = 0;
++
++  /* count occurrences of orig in src */
++  sptr = src->av_val;
++  while (sptr < srcend && (sptr = strstr(sptr, orig->av_val)))
+     {
+-      int len = ptr - srcstrstart;
+-      memcpy(deststrstart, srcstrstart, len);
+-      srcstrstart += len + origlen;
+-      deststrstart += len;
+-      memcpy(deststrstart, repl, repllen);
+-      deststrstart += repllen;
+-      ptr = strstr(srcstrstart, orig);
++      n++;
++      sptr += orig->av_len;
+     }
+-    while (ptr && (ptr < srcend));
+-    strncpy(deststrstart, srcstrstart, srcend-srcstrstart);
+-    return deststr;
+-  }
++  if (!n)
++    return;
+ 
+-  strncpy(deststr, srcstr, srclen);
+-  return deststr;
++  dest = malloc(src->av_len + 1 + (repl->av_len - orig->av_len) * n);
++
++  sptr = src->av_val;
++  dptr = dest;
++  while (sptr < srcend && (sptr = strstr(sptr, orig->av_val)))
++    {
++      n = sptr - srcbeg;
++      memcpy(dptr, srcbeg, n);
++      srcbeg += n;
++      dptr += n;
++      memcpy(dptr, repl->av_val, repl->av_len);
++      dptr += repl->av_len;
++      sptr += orig->av_len;
++    }
++  n = srcend - srcbeg;
++  memcpy(dptr, srcbeg, n);
++  dptr += n;
++  *dptr = '\0';
++  src->av_val = dest;
++  src->av_len = dptr - dest;
+ }
+-- 
+1.7.10.4
+
+
+From 8880d1456b282ee79979adbe7b6a6eb8ad371081 Mon Sep 17 00:00:00 2001
+From: Chris Larsen <clarsen@euphoriaaudio.com>
+Date: Tue, 2 Aug 2011 12:33:44 -0400
+Subject: [PATCH 13/33] Unexpected BW Response Fix
+
+Bug: SendCheckBWResult sends an invalid bw response due to casting issues
+from a double to an int.
+---
+ librtmp/rtmp.c |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index df2cb27..5311a8a 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -2339,7 +2339,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ {
+   AMFObject obj;
+   AVal method;
+-  int txn;
++  double txn;
+   int ret = 0, nRes;
+   if (body[0] != 0x02)		/* make sure it is a string method name we start with */
+     {
+@@ -2357,7 +2357,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ 
+   AMF_Dump(&obj);
+   AMFProp_GetString(AMF_GetProp(&obj, NULL, 0), &method);
+-  txn = (int)AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 1));
++  txn = AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 1));
+   RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val);
+ 
+   if (AVMATCH(&method, &av__result))
+@@ -2366,7 +2366,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+       int i;
+ 
+       for (i=0; i<r->m_numCalls; i++) {
+-  	if (r->m_methodCalls[i].num == txn) {
++	if (r->m_methodCalls[i].num == (int)txn) {
+ 	  methodInvoked = r->m_methodCalls[i].name;
+ 	  AV_erase(r->m_methodCalls, &r->m_numCalls, i, FALSE);
+ 	  break;
+-- 
+1.7.10.4
+
+
+From c528451068de033d7cc76eb1c5a606c10215fcfb Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Wed, 3 Aug 2011 11:46:07 -0700
+Subject: [PATCH 14/33] Fix <arpa/inet.h> include order
+
+---
+ librtmp/rtmp_sys.h |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index 6a3f215..638374f 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -46,10 +46,10 @@
+ #include <sys/socket.h>
+ #include <sys/times.h>
+ #include <netdb.h>
+-#include <arpa/inet.h>
+ #include <unistd.h>
+ #include <netinet/in.h>
+ #include <netinet/tcp.h>
++#include <arpa/inet.h>
+ #define GetSockError()	errno
+ #define SetSockError(e)	errno = e
+ #undef closesocket
+-- 
+1.7.10.4
+
+
+From a1114e09bf0d74ef1d575eb88f3aa36bc7c6d790 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 9 Aug 2011 14:44:14 -0700
+Subject: [PATCH 15/33] Fix AVreplace for usherToken
+
+---
+ rtmpsrv.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index b45aae3..91fc4da 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -1168,11 +1168,11 @@ AVreplace(AVal *src, const AVal *orig, const AVal *repl)
+     {
+       n = sptr - srcbeg;
+       memcpy(dptr, srcbeg, n);
+-      srcbeg += n;
+       dptr += n;
+       memcpy(dptr, repl->av_val, repl->av_len);
+       dptr += repl->av_len;
+       sptr += orig->av_len;
++      srcbeg = sptr;
+     }
+   n = srcend - srcbeg;
+   memcpy(dptr, srcbeg, n);
+-- 
+1.7.10.4
+
+
+From c58cfb3e9208c6e6bc1aa18f1b1d650d799084e5 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Thu, 11 Aug 2011 18:02:10 -0700
+Subject: [PATCH 16/33] Add RD_NO_CONNECT return code for Connect failures
+
+---
+ rtmpdump.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index e506fa9..01decf9 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -46,6 +46,7 @@
+ #define RD_SUCCESS		0
+ #define RD_FAILED		1
+ #define RD_INCOMPLETE		2
++#define RD_NO_CONNECT		3
+ 
+ #define DEF_TIMEOUT	30	/* seconds */
+ #define DEF_BUFTIME	(10 * 60 * 60 * 1000)	/* 10 hours default */
+@@ -1253,7 +1254,7 @@ main(int argc, char **argv)
+ 
+ 	  if (!RTMP_Connect(&rtmp, NULL))
+ 	    {
+-	      nStatus = RD_FAILED;
++	      nStatus = RD_NO_CONNECT;
+ 	      break;
+ 	    }
+ 
+-- 
+1.7.10.4
+
+
+From 6230845ab0fba07289d4b2d9b97269e4b2d90766 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Sun, 25 Sep 2011 03:07:14 -0700
+Subject: [PATCH 17/33] PolarSSL support now requires version 1.0.0.
+
+---
+ README             |    1 +
+ librtmp/dh.h       |    7 +++----
+ librtmp/rtmp_sys.h |    3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/README b/README
+index 865c6c4..dcf5f52 100644
+--- a/README
++++ b/README
+@@ -50,6 +50,7 @@ library. You can also turn it off if desired
+ The rtmpdump programs still link to the static library, regardless.
+ 
+ Note that if using OpenSSL, you must have version 0.9.8 or newer.
++For Polar SSL you must have version 1.0.0 or newer.
+ 
+ Credit goes to team boxee for the XBMC RTMP code originally used in RTMPDumper.
+ The current code is based on the XBMC code but rewritten in C by Howard Chu.
+diff --git a/librtmp/dh.h b/librtmp/dh.h
+index efef0fd..a9f3763 100644
+--- a/librtmp/dh.h
++++ b/librtmp/dh.h
+@@ -30,14 +30,14 @@
+ #ifdef USE_POLARSSL
+ #include <polarssl/dhm.h>
+ typedef mpi * MP_t;
+-#define MP_new(m)	m = malloc(sizeof(mpi)); mpi_init(m, NULL)
++#define MP_new(m)	m = malloc(sizeof(mpi)); mpi_init(m)
+ #define MP_set_w(mpi, w)	mpi_lset(mpi, w)
+ #define MP_cmp(u, v)	mpi_cmp_mpi(u, v)
+ #define MP_set(u, v)	mpi_copy(u, v)
+ #define MP_sub_w(mpi, w)	mpi_sub_int(mpi, mpi, w)
+ #define MP_cmp_1(mpi)	mpi_cmp_int(mpi, 1)
+ #define MP_modexp(r, y, q, p)	mpi_exp_mod(r, y, q, p, NULL)
+-#define MP_free(mpi)	mpi_free(mpi, NULL); free(mpi)
++#define MP_free(mpi)	mpi_free(mpi); free(mpi)
+ #define MP_gethex(u, hex, res)	MP_new(u); res = mpi_read_string(u, 16, hex) == 0
+ #define MP_bytes(u)	mpi_size(u)
+ #define MP_setbin(u,buf,len)	mpi_write_binary(u,buf,len)
+@@ -71,9 +71,8 @@ static int MDH_generate_key(MDH *dh)
+ 
+ static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh)
+ {
+-  int n = len;
+   MP_set(&dh->ctx.GY, pub);
+-  dhm_calc_secret(&dh->ctx, secret, &n);
++  dhm_calc_secret(&dh->ctx, secret, &len);
+   return 0;
+ }
+ 
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index 638374f..c3fd4a6 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -71,7 +71,8 @@ typedef struct tls_ctx {
+ #define TLS_CTX tls_ctx *
+ #define TLS_client(ctx,s)	s = malloc(sizeof(ssl_context)); ssl_init(s);\
+ 	ssl_set_endpoint(s, SSL_IS_CLIENT); ssl_set_authmode(s, SSL_VERIFY_NONE);\
+-	ssl_set_rng(s, havege_rand, &ctx->hs); ssl_set_ciphers(s, ssl_default_ciphers);\
++	ssl_set_rng(s, havege_rand, &ctx->hs);\
++	ssl_set_ciphersuites(s, ssl_default_ciphersuites);\
+ 	ssl_set_session(s, 1, 600, &ctx->ssn)
+ #define TLS_setfd(s,fd)	ssl_set_bio(s, net_recv, &fd, net_send, &fd)
+ #define TLS_connect(s)	ssl_handshake(s)
+-- 
+1.7.10.4
+
+
+From 60218d0af0f4bd683ecdebe49986f188820cf8ce Mon Sep 17 00:00:00 2001
+From: Kirill Zorin <cyril.zorin@gmail.com>
+Date: Fri, 30 Sep 2011 13:38:23 -0400
+Subject: [PATCH 18/33] fixed undefined behaviour due to union assignment
+
+---
+ librtmp/amf.c  |    2 +-
+ librtmp/rtmp.c |    4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/librtmp/amf.c b/librtmp/amf.c
+index 7fa289e..ae920e4 100644
+--- a/librtmp/amf.c
++++ b/librtmp/amf.c
+@@ -1111,7 +1111,7 @@ AMF_AddProp(AMFObject *obj, const AMFObjectProperty *prop)
+   if (!(obj->o_num & 0x0f))
+     obj->o_props =
+       realloc(obj->o_props, (obj->o_num + 16) * sizeof(AMFObjectProperty));
+-  obj->o_props[obj->o_num++] = *prop;
++  memcpy(&obj->o_props[obj->o_num++], prop, sizeof(AMFObjectProperty));
+ }
+ 
+ int
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 5311a8a..4b17a49 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -2584,7 +2584,7 @@ RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name,
+ 
+       if (AVMATCH(&prop->p_name, name))
+ 	{
+-	  *p = *prop;
++	  memcpy(p, prop, sizeof(*prop));
+ 	  return TRUE;
+ 	}
+ 
+@@ -2610,7 +2610,7 @@ RTMP_FindPrefixProperty(AMFObject *obj, const AVal *name,
+       if (prop->p_name.av_len > name->av_len &&
+       	  !memcmp(prop->p_name.av_val, name->av_val, name->av_len))
+ 	{
+-	  *p = *prop;
++	  memcpy(p, prop, sizeof(*prop));
+ 	  return TRUE;
+ 	}
+ 
+-- 
+1.7.10.4
+
+
+From c90c05892cbaebfb1b2095759597d9fb38238c64 Mon Sep 17 00:00:00 2001
+From: KSV <faltuvistor@yahoo.co.in>
+Date: Mon, 7 Nov 2011 11:38:27 -0800
+Subject: [PATCH 19/33] Fix bytes-received report
+
+---
+ librtmp/rtmp.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 4b17a49..a9c1bc1 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -1337,7 +1337,7 @@ ReadN(RTMP *r, char *buffer, int n)
+ 	  nBytes = nRead;
+ 	  r->m_nBytesIn += nRead;
+ 	  if (r->m_bSendCounter
+-	      && r->m_nBytesIn > r->m_nBytesInSent + r->m_nClientBW / 2)
++	      && r->m_nBytesIn > ( r->m_nBytesInSent + r->m_nClientBW / 10))
+ 	    if (!SendBytesReceived(r))
+ 	        return FALSE;
+ 	}
+-- 
+1.7.10.4
+
+
+From b3467069ad7c26d748ca13ce0ee88a41f85b22dd Mon Sep 17 00:00:00 2001
+From: Jeff Johnson <jeff@rogueamoeba.com>
+Date: Mon, 7 Nov 2011 11:43:26 -0800
+Subject: [PATCH 20/33] Fix getting swf hash with https URLs
+
+---
+ librtmp/hashswf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 3c56b69..5576730 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -163,7 +163,7 @@ HTTP_get(struct HTTP_ctx *http, const char *url, HTTP_read_callback *cb)
+ #else
+       TLS_client(RTMP_TLS_ctx, sb.sb_ssl);
+       TLS_setfd(sb.sb_ssl, sb.sb_socket);
+-      if ((i = TLS_connect(sb.sb_ssl)) < 0)
++      if (TLS_connect(sb.sb_ssl) < 0)
+ 	{
+ 	  RTMP_Log(RTMP_LOGERROR, "%s, TLS_Connect failed", __FUNCTION__);
+ 	  ret = HTTPRES_LOST_CONNECTION;
+-- 
+1.7.10.4
+
+
+From 90799efbb67f415ff930d68905e8267d5aa5dc4e Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 8 Nov 2011 02:04:01 -0800
+Subject: [PATCH 21/33] Increase tcUrl buffer size
+
+---
+ rtmpdump.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index 01decf9..a8fa128 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -1152,9 +1152,9 @@ main(int argc, char **argv)
+ 
+   if (tcUrl.av_len == 0)
+     {
+-      char str[512] = { 0 };
++      char str[1024];
+ 
+-      tcUrl.av_len = snprintf(str, 511, "%s://%.*s:%d/%.*s",
++      tcUrl.av_len = snprintf(str, sizeof(str), "%s://%.*s:%d/%.*s",
+ 	  	   RTMPProtocolStringsLower[protocol], hostname.av_len,
+ 		   hostname.av_val, port, app.av_len, app.av_val);
+       tcUrl.av_val = (char *) malloc(tcUrl.av_len + 1);
+-- 
+1.7.10.4
+
+
+From 9df7959a71ec33cc9c83c9d3ef25c17b1c527f0e Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 8 Nov 2011 02:05:01 -0800
+Subject: [PATCH 22/33] Spell Referer according to RFC1945
+
+---
+ librtmp/hashswf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 5576730..0320480 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -141,7 +141,7 @@ HTTP_get(struct HTTP_ctx *http, const char *url, HTTP_read_callback *cb)
+     return HTTPRES_LOST_CONNECTION;
+   i =
+     sprintf(sb.sb_buf,
+-	    "GET %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\nReferrer: %.*s\r\n",
++	    "GET %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\nReferer: %.*s\r\n",
+ 	    path, AGENT, host, (int)(path - url + 1), url);
+   if (http->date[0])
+     i += sprintf(sb.sb_buf + i, "If-Modified-Since: %s\r\n", http->date);
+-- 
+1.7.10.4
+
+
+From 1c77ff43439068981d2ad9872952922a1ee37f89 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 8 Nov 2011 02:13:14 -0800
+Subject: [PATCH 23/33] Calculate tcUrl length
+
+---
+ rtmpdump.c |    9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index a8fa128..892a8bc 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -1152,13 +1152,12 @@ main(int argc, char **argv)
+ 
+   if (tcUrl.av_len == 0)
+     {
+-      char str[1024];
+-
+-      tcUrl.av_len = snprintf(str, sizeof(str), "%s://%.*s:%d/%.*s",
++	  tcUrl.av_len = strlen(RTMPProtocolStringsLower[protocol]) +
++	  	hostname.av_len + app.av_len + sizeof("://:65535/");
++      tcUrl.av_val = (char *) malloc(tcUrl.av_len);
++      tcUrl.av_len = snprintf(tcUrl.av_val, tcUrl.av_len, "%s://%.*s:%d/%.*s",
+ 	  	   RTMPProtocolStringsLower[protocol], hostname.av_len,
+ 		   hostname.av_val, port, app.av_len, app.av_val);
+-      tcUrl.av_val = (char *) malloc(tcUrl.av_len + 1);
+-      strcpy(tcUrl.av_val, str);
+     }
+ 
+   int first = 1;
+-- 
+1.7.10.4
+
+
+From 30fcf46fc82f96ca41b710fc38bbc15f2489795e Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 8 Nov 2011 02:14:21 -0800
+Subject: [PATCH 24/33] Check for malloc failure in prev commit
+
+---
+ rtmpdump.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index 892a8bc..c37def2 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -1155,6 +1155,8 @@ main(int argc, char **argv)
+ 	  tcUrl.av_len = strlen(RTMPProtocolStringsLower[protocol]) +
+ 	  	hostname.av_len + app.av_len + sizeof("://:65535/");
+       tcUrl.av_val = (char *) malloc(tcUrl.av_len);
++	  if (!tcUrl.av_val)
++	    return RD_FAILED;
+       tcUrl.av_len = snprintf(tcUrl.av_val, tcUrl.av_len, "%s://%.*s:%d/%.*s",
+ 	  	   RTMPProtocolStringsLower[protocol], hostname.av_len,
+ 		   hostname.av_val, port, app.av_len, app.av_val);
+-- 
+1.7.10.4
+
+
+From 83e701eef0d7947713280fe3e7561bed1e7195f5 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Mon, 14 Nov 2011 16:09:26 -0800
+Subject: [PATCH 25/33] Fix missing log message parameter
+
+---
+ librtmp/rtmp.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index a9c1bc1..4da318b 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -974,7 +974,7 @@ SocksNegotiate(RTMP *r)
+       }
+     else
+       {
+-        RTMP_Log(RTMP_LOGERROR, "%s, SOCKS returned error code %d", packet[1]);
++        RTMP_Log(RTMP_LOGERROR, "%s, SOCKS returned error code %d", __FUNCTION__, packet[1]);
+         return FALSE;
+       }
+   }
+-- 
+1.7.10.4
+
+
+From 949da84ab1f659597d6e7fa1ef0ab8fc1ca8e246 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Mon, 14 Nov 2011 16:11:13 -0800
+Subject: [PATCH 26/33] Tell gcc about log format strings
+
+---
+ librtmp/log.h |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/librtmp/log.h b/librtmp/log.h
+index 97c9aac..2adb111 100644
+--- a/librtmp/log.h
++++ b/librtmp/log.h
+@@ -48,9 +48,15 @@ extern RTMP_LogLevel RTMP_debuglevel;
+ typedef void (RTMP_LogCallback)(int level, const char *fmt, va_list);
+ void RTMP_LogSetCallback(RTMP_LogCallback *cb);
+ void RTMP_LogSetOutput(FILE *file);
++#ifdef __GNUC__
++void RTMP_LogPrintf(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
++void RTMP_LogStatus(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
++void RTMP_Log(int level, const char *format, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
++#else
+ void RTMP_LogPrintf(const char *format, ...);
+ void RTMP_LogStatus(const char *format, ...);
+ void RTMP_Log(int level, const char *format, ...);
++#endif
+ void RTMP_LogHex(int level, const uint8_t *data, unsigned long len);
+ void RTMP_LogHexString(int level, const uint8_t *data, unsigned long len);
+ void RTMP_LogSetLevel(RTMP_LogLevel lvl);
+-- 
+1.7.10.4
+
+
+From 45556fb3b372402d7bd5235832176f58dede90ae Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Mon, 14 Nov 2011 16:12:26 -0800
+Subject: [PATCH 27/33] Fix mismatched format string conversions
+
+---
+ librtmp/amf.c  |    4 ++--
+ librtmp/rtmp.c |   22 +++++++++++-----------
+ 2 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/librtmp/amf.c b/librtmp/amf.c
+index ae920e4..f9ecf21 100644
+--- a/librtmp/amf.c
++++ b/librtmp/amf.c
+@@ -586,7 +586,7 @@ AMF3Prop_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+     case AMF3_ARRAY:
+     case AMF3_BYTE_ARRAY:
+     default:
+-      RTMP_Log(RTMP_LOGDEBUG, "%s - AMF3 unknown/unsupported datatype 0x%02x, @0x%08X",
++      RTMP_Log(RTMP_LOGDEBUG, "%s - AMF3 unknown/unsupported datatype 0x%02x, @%p",
+ 	  __FUNCTION__, (unsigned char)(*pBuffer), pBuffer);
+       return -1;
+     }
+@@ -772,7 +772,7 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+ 	break;
+       }
+     default:
+-      RTMP_Log(RTMP_LOGDEBUG, "%s - unknown datatype 0x%02x, @0x%08X", __FUNCTION__,
++      RTMP_Log(RTMP_LOGDEBUG, "%s - unknown datatype 0x%02x, @%p", __FUNCTION__,
+ 	  prop->p_type, pBuffer - 1);
+       return -1;
+     }
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 4da318b..52d0254 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -185,7 +185,7 @@ void
+ RTMPPacket_Dump(RTMPPacket *p)
+ {
+   RTMP_Log(RTMP_LOGDEBUG,
+-      "RTMP PACKET: packet type: 0x%02x. channel: 0x%02x. info 1: %d info 2: %d. Body size: %lu. body: 0x%02x",
++      "RTMP PACKET: packet type: 0x%02x. channel: 0x%02x. info 1: %d info 2: %d. Body size: %u. body: 0x%02x",
+       p->m_packetType, p->m_nChannel, p->m_nTimeStamp, p->m_nInfoField2,
+       p->m_nBodySize, p->m_body ? (unsigned char)p->m_body[0] : 0);
+ }
+@@ -367,7 +367,7 @@ RTMP_SetupStream(RTMP *r,
+     RTMP_Log(RTMP_LOGDEBUG, "StopTime      : %d msec", dStop);
+ 
+   RTMP_Log(RTMP_LOGDEBUG, "live     : %s", bLiveStream ? "yes" : "no");
+-  RTMP_Log(RTMP_LOGDEBUG, "timeout  : %d sec", timeout);
++  RTMP_Log(RTMP_LOGDEBUG, "timeout  : %ld sec", timeout);
+ 
+ #ifdef CRYPTO
+   if (swfSHA256Hash != NULL && swfSize > 0)
+@@ -376,7 +376,7 @@ RTMP_SetupStream(RTMP *r,
+       r->Link.SWFSize = swfSize;
+       RTMP_Log(RTMP_LOGDEBUG, "SWFSHA256:");
+       RTMP_LogHex(RTMP_LOGDEBUG, r->Link.SWFHash, sizeof(r->Link.SWFHash));
+-      RTMP_Log(RTMP_LOGDEBUG, "SWFSize  : %lu", r->Link.SWFSize);
++      RTMP_Log(RTMP_LOGDEBUG, "SWFSize  : %u", r->Link.SWFSize);
+     }
+   else
+     {
+@@ -1161,14 +1161,14 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+     case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
+       /* flex stream send */
+       RTMP_Log(RTMP_LOGDEBUG,
+-	  "%s, flex stream send, size %lu bytes, not supported, ignoring",
++	  "%s, flex stream send, size %u bytes, not supported, ignoring",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       break;
+ 
+     case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
+       /* flex shared object */
+       RTMP_Log(RTMP_LOGDEBUG,
+-	  "%s, flex shared object, size %lu bytes, not supported, ignoring",
++	  "%s, flex shared object, size %u bytes, not supported, ignoring",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       break;
+ 
+@@ -1176,7 +1176,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+       /* flex message */
+       {
+ 	RTMP_Log(RTMP_LOGDEBUG,
+-	    "%s, flex message, size %lu bytes, not fully supported",
++	    "%s, flex message, size %u bytes, not fully supported",
+ 	    __FUNCTION__, packet->m_nBodySize);
+ 	/*RTMP_LogHex(packet.m_body, packet.m_nBodySize); */
+ 
+@@ -1198,7 +1198,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+       }
+     case RTMP_PACKET_TYPE_INFO:
+       /* metadata (notify) */
+-      RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %lu bytes", __FUNCTION__,
++      RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %u bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+       if (HandleMetadata(r, packet->m_body, packet->m_nBodySize))
+ 	bHasMediaPacket = 1;
+@@ -1211,7 +1211,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 
+     case RTMP_PACKET_TYPE_INVOKE:
+       /* invoke */
+-      RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
++      RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %u bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+       /*RTMP_LogHex(packet.m_body, packet.m_nBodySize); */
+ 
+@@ -2373,7 +2373,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ 	}
+       }
+       if (!methodInvoked.av_val) {
+-        RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %d without matching request",
++        RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %f without matching request",
+ 	  __FUNCTION__, txn);
+ 	goto leave;
+       }
+@@ -3055,7 +3055,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
+ 
+   if (ReadN(r, packet->m_body + packet->m_nBytesRead, nChunk) != nChunk)
+     {
+-      RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet body. len: %lu",
++      RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet body. len: %u",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       return FALSE;
+     }
+@@ -4176,7 +4176,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 		  if (pos + 11 + dataSize > nPacketLen)
+ 		    {
+ 		      RTMP_Log(RTMP_LOGERROR,
+-			  "Wrong data size (%lu), stream corrupted, aborting!",
++			  "Wrong data size (%u), stream corrupted, aborting!",
+ 			  dataSize);
+ 		      ret = RTMP_READ_ERROR;
+ 		      break;
+-- 
+1.7.10.4
+
+
+From 5d03a4f0d6216da92830306436eae7eb318d5115 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Mon, 14 Nov 2011 16:17:27 -0800
+Subject: [PATCH 28/33] Fix log messages
+
+---
+ rtmpdump.c |    4 ++--
+ rtmpgw.c   |    6 +++---
+ rtmpsrv.c  |    8 ++++----
+ rtmpsuck.c |    6 +++---
+ 4 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index c37def2..34bfdba 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -686,7 +686,7 @@ void usage(char *prog)
+ 	  RTMP_LogPrintf
+ 	    ("--resume|-e             Resume a partial RTMP download\n");
+ 	  RTMP_LogPrintf
+-	    ("--timeout|-m num        Timeout connection num seconds (default: %lu)\n",
++	    ("--timeout|-m num        Timeout connection num seconds (default: %u)\n",
+ 	     DEF_TIMEOUT);
+ 	  RTMP_LogPrintf
+ 	    ("--start|-A num          Start at num seconds into stream (not valid when using --live)\n");
+@@ -699,7 +699,7 @@ void usage(char *prog)
+ 	  RTMP_LogPrintf
+ 	    ("--hashes|-#             Display progress with hashes, not with the byte counter\n");
+ 	  RTMP_LogPrintf
+-	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n",
++	    ("--buffer|-b             Buffer time in milliseconds (default: %u)\n",
+ 	     DEF_BUFTIME);
+ 	  RTMP_LogPrintf
+ 	    ("--skip|-k num           Skip num keyframes when looking for last keyframe to resume from. Useful if resume fails (default: %d)\n\n",
+diff --git a/rtmpgw.c b/rtmpgw.c
+index 733e105..0cf56bb 100644
+--- a/rtmpgw.c
++++ b/rtmpgw.c
+@@ -563,7 +563,7 @@ void processTCPrequest(STREAMING_SERVER * server,	// server socket and state (ou
+   rtmp.Link.token = req.token;
+   rtmp.m_read.timestamp = dSeek;
+ 
+-  RTMP_LogPrintf("Connecting ... port: %d, app: %s\n", req.rtmpport, req.app);
++  RTMP_LogPrintf("Connecting ... port: %d, app: %s\n", req.rtmpport, req.app.av_val);
+   if (!RTMP_Connect(&rtmp, NULL))
+     {
+       RTMP_LogPrintf("%s, failed to connect!\n", __FUNCTION__);
+@@ -738,7 +738,7 @@ stopStreaming(STREAMING_SERVER * server)
+ 
+       if (closesocket(server->socket))
+ 	RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
+-	    GetSockError());
++	    __FUNCTION__, GetSockError());
+ 
+       server->state = STREAMING_STOPPED;
+     }
+@@ -1103,7 +1103,7 @@ main(int argc, char **argv)
+ 	  RTMP_LogPrintf
+ 	    ("--jtv|-j JSON           Authentication token for Justin.tv legacy servers\n");
+ 	  RTMP_LogPrintf
+-	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n\n",
++	    ("--buffer|-b             Buffer time in milliseconds (default: %u)\n\n",
+ 	     defaultRTMPRequest.bufferTime);
+ 
+ 	  RTMP_LogPrintf
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index 91fc4da..b662d54 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -765,7 +765,7 @@ ServePacket(STREAMING_SERVER *server, RTMP *r, RTMPPacket *packet)
+ {
+   int ret = 0;
+ 
+-  RTMP_Log(RTMP_LOGDEBUG, "%s, received packet type %02X, size %lu bytes", __FUNCTION__,
++  RTMP_Log(RTMP_LOGDEBUG, "%s, received packet type %02X, size %u bytes", __FUNCTION__,
+     packet->m_packetType, packet->m_nBodySize);
+ 
+   switch (packet->m_packetType)
+@@ -812,7 +812,7 @@ ServePacket(STREAMING_SERVER *server, RTMP *r, RTMPPacket *packet)
+ 
+     case 0x11:			// flex message
+       {
+-	RTMP_Log(RTMP_LOGDEBUG, "%s, flex message, size %lu bytes, not fully supported",
++	RTMP_Log(RTMP_LOGDEBUG, "%s, flex message, size %u bytes, not fully supported",
+ 	    __FUNCTION__, packet->m_nBodySize);
+ 	//RTMP_LogHex(packet.m_body, packet.m_nBodySize);
+ 
+@@ -840,7 +840,7 @@ ServePacket(STREAMING_SERVER *server, RTMP *r, RTMPPacket *packet)
+ 
+     case 0x14:
+       // invoke
+-      RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
++      RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %u bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+       //RTMP_LogHex(packet.m_body, packet.m_nBodySize);
+ 
+@@ -1053,7 +1053,7 @@ stopStreaming(STREAMING_SERVER * server)
+ 
+       if (closesocket(server->socket))
+ 	RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
+-	    GetSockError());
++	    __FUNCTION__, GetSockError());
+ 
+       server->state = STREAMING_STOPPED;
+     }
+diff --git a/rtmpsuck.c b/rtmpsuck.c
+index 661e64b..e886179 100644
+--- a/rtmpsuck.c
++++ b/rtmpsuck.c
+@@ -456,7 +456,7 @@ ServePacket(STREAMING_SERVER *server, int which, RTMPPacket *packet)
+ {
+   int ret = 0;
+ 
+-  RTMP_Log(RTMP_LOGDEBUG, "%s, %s sent packet type %02X, size %lu bytes", __FUNCTION__,
++  RTMP_Log(RTMP_LOGDEBUG, "%s, %s sent packet type %02X, size %u bytes", __FUNCTION__,
+     cst[which], packet->m_packetType, packet->m_nBodySize);
+ 
+   switch (packet->m_packetType)
+@@ -649,7 +649,7 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ 		  if (pos + 11 + dataSize > nPacketLen)
+ 		    {
+ 		      RTMP_Log(RTMP_LOGERROR,
+-			  "Wrong data size (%lu), stream corrupted, aborting!",
++			  "Wrong data size (%u), stream corrupted, aborting!",
+ 			  dataSize);
+ 		      ret = -2;
+ 		      break;
+@@ -1117,7 +1117,7 @@ stopStreaming(STREAMING_SERVER * server)
+ 
+       if (fd && closesocket(fd))
+ 	RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
+-	    GetSockError());
++	    __FUNCTION__, GetSockError());
+ 
+       server->state = STREAMING_STOPPED;
+     }
+-- 
+1.7.10.4
+
+
+From 4e06e218e230a86608637b613499984703a342cf Mon Sep 17 00:00:00 2001
+From: Antti Ajanki <antti.ajanki@iki.fi>
+Date: Thu, 22 Dec 2011 17:54:10 -0800
+Subject: [PATCH 29/33] Support decoding AMF_XML_DOC
+
+MF_XML_DOC data is an XML document which is encoded similarly to a
+long string.
+---
+ librtmp/amf.c |   10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/librtmp/amf.c b/librtmp/amf.c
+index f9ecf21..659421e 100644
+--- a/librtmp/amf.c
++++ b/librtmp/amf.c
+@@ -735,13 +735,15 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+ 	break;
+       }
+     case AMF_LONG_STRING:
++    case AMF_XML_DOC:
+       {
+ 	unsigned int nStringSize = AMF_DecodeInt32(pBuffer);
+ 	if (nSize < (long)nStringSize + 4)
+ 	  return -1;
+ 	AMF_DecodeLongString(pBuffer, &prop->p_vu.p_aval);
+ 	nSize -= (4 + nStringSize);
+-	prop->p_type = AMF_STRING;
++	if (prop->p_type == AMF_LONG_STRING)
++	  prop->p_type = AMF_STRING;
+ 	break;
+       }
+     case AMF_RECORDSET:
+@@ -750,12 +752,6 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+ 	return -1;
+ 	break;
+       }
+-    case AMF_XML_DOC:
+-      {
+-	RTMP_Log(RTMP_LOGERROR, "AMF_XML_DOC not supported!");
+-	return -1;
+-	break;
+-      }
+     case AMF_TYPED_OBJECT:
+       {
+ 	RTMP_Log(RTMP_LOGERROR, "AMF_TYPED_OBJECT not supported!");
+-- 
+1.7.10.4
+
+
+From adb77ff4d72cea92b7c307ccb64e9aa930d866da Mon Sep 17 00:00:00 2001
+From: Joshua Allmann <joshua.allmann@gmail.com>
+Date: Fri, 24 Feb 2012 13:44:29 -0800
+Subject: [PATCH 30/33] Remove extra object end tag in Connect reply
+
+---
+ rtmpsrv.c |    3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index b662d54..9aa62f3 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -223,9 +223,6 @@ SendConnectResult(RTMP *r, double txn)
+   *enc++ = 0;
+   *enc++ = 0;
+   *enc++ = AMF_OBJECT_END;
+-  *enc++ = 0;
+-  *enc++ = 0;
+-  *enc++ = AMF_OBJECT_END;
+ 
+   packet.m_nBodySize = enc - packet.m_body;
+ 
+-- 
+1.7.10.4
+
+
+From 2ad1d5d133a46ceeaaa05c9375e293f332871f3b Mon Sep 17 00:00:00 2001
+From: Josh Allmann <joshua.allmann@gmail.com>
+Date: Fri, 24 Feb 2012 13:46:59 -0800
+Subject: [PATCH 31/33] Fix upper bound check in AMF_GetProp
+
+---
+ librtmp/amf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/amf.c b/librtmp/amf.c
+index 659421e..ce84f81 100644
+--- a/librtmp/amf.c
++++ b/librtmp/amf.c
+@@ -1121,7 +1121,7 @@ AMF_GetProp(AMFObject *obj, const AVal *name, int nIndex)
+ {
+   if (nIndex >= 0)
+     {
+-      if (nIndex <= obj->o_num)
++      if (nIndex < obj->o_num)
+ 	return &obj->o_props[nIndex];
+     }
+   else
+-- 
+1.7.10.4
+
+
+From eea470fa5f9a5481a36dedd257549595ef7480d6 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Thu, 8 Mar 2012 23:10:11 -0800
+Subject: [PATCH 32/33] Add support for building with gnutls with nettle as
+ backend
+
+---
+ Makefile            |    1 +
+ librtmp/Makefile    |    3 +++
+ librtmp/dh.h        |   20 +++++++++++++++++++-
+ librtmp/handshake.h |   20 ++++++++++++++++++++
+ librtmp/hashswf.c   |   11 +++++++++++
+ librtmp/rtmp.c      |    4 ++--
+ librtmp/rtmp_sys.h  |    2 +-
+ 7 files changed, 57 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 6ef5742..0cf41be 100644
+--- a/Makefile
++++ b/Makefile
+@@ -13,6 +13,7 @@ CRYPTO=OPENSSL
+ #CRYPTO=GNUTLS
+ LIBZ=-lz
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
++LIB_GNUTLS_NETTLE=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ CRYPTO_LIB=$(LIB_$(CRYPTO))
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index a0125f1..353c6c8 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -21,14 +21,17 @@ CRYPTO=OPENSSL
+ DEF_POLARSSL=-DUSE_POLARSSL
+ DEF_OPENSSL=-DUSE_OPENSSL
+ DEF_GNUTLS=-DUSE_GNUTLS
++DEF_GNUTLS_NETTLE=-DUSE_GNUTLS_NETTLE
+ DEF_=-DNO_CRYPTO
+ REQ_GNUTLS=gnutls
++REQ_GNUTLS_NETTLE=gnutls
+ REQ_OPENSSL=libssl,libcrypto
+ LIBZ=-lz
+ LIBS_posix=
+ LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
++LIB_GNUTLS_NETTLE=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ PRIVATE_LIBS=$(LIBS_$(SYS))
+diff --git a/librtmp/dh.h b/librtmp/dh.h
+index a9f3763..830000e 100644
+--- a/librtmp/dh.h
++++ b/librtmp/dh.h
+@@ -76,7 +76,8 @@ static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh)
+   return 0;
+ }
+ 
+-#elif defined(USE_GNUTLS)
++#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
++#ifdef USE_GNUTLS
+ #include <gcrypt.h>
+ typedef gcry_mpi_t MP_t;
+ #define MP_new(m)	m = gcry_mpi_new(1)
+@@ -91,6 +92,23 @@ typedef gcry_mpi_t MP_t;
+ #define MP_bytes(u)	(gcry_mpi_get_nbits(u) + 7) / 8
+ #define MP_setbin(u,buf,len)	gcry_mpi_print(GCRYMPI_FMT_USG,buf,len,NULL,u)
+ #define MP_getbin(u,buf,len)	gcry_mpi_scan(&u,GCRYMPI_FMT_USG,buf,len,NULL)
++#else
++#include <gmp.h>
++#include <nettle/bignum.h>
++typedef mpz_ptr MP_t;
++#define MP_new(m)	m = malloc(sizeof(*m)); mpz_init2(m, 1)
++#define MP_set_w(mpi, w)	mpz_set_ui(mpi, w)
++#define MP_cmp(u, v)	mpz_cmp(u, v)
++#define MP_set(u, v)	mpz_set(u, v)
++#define MP_sub_w(mpi, w)	mpz_sub_ui(mpi, mpi, w)
++#define MP_cmp_1(mpi)	mpz_cmp_ui(mpi, 1)
++#define MP_modexp(r, y, q, p)	mpz_powm(r, y, q, p)
++#define MP_free(mpi)	mpz_clear(mpi); free(mpi)
++#define MP_gethex(u, hex, res)	u = malloc(sizeof(*u)); mpz_init2(u, 1); res = (mpz_set_str(u, hex, 16) == 0)
++#define MP_bytes(u)	(mpz_sizeinbase(u, 2) + 7) / 8
++#define MP_setbin(u,buf,len)	nettle_mpz_get_str_256(len,buf,u)
++#define MP_getbin(u,buf,len)	u = malloc(sizeof(*u)); mpz_init2(u, 1); nettle_mpz_set_str_256_u(u,len,buf)
++#endif
+ 
+ typedef struct MDH {
+   MP_t p;
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index 98bf3c8..4c2ea7f 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -59,6 +59,26 @@ typedef gcry_cipher_hd_t	RC4_handle;
+ #define RC4_encrypt2(h,l,s,d)	gcry_cipher_encrypt(h,(void *)d,l,(void *)s,l)
+ #define RC4_free(h)	gcry_cipher_close(h)
+ 
++#elif defined(USE_GNUTLS_NETTLE)
++#include <nettle/hmac.h>
++#include <nettle/arcfour.h>
++#ifndef SHA256_DIGEST_LENGTH
++#define SHA256_DIGEST_LENGTH    32
++#endif
++#undef HMAC_CTX
++#define HMAC_CTX	struct hmac_sha256_ctx
++#define HMAC_setup(ctx, key, len)	hmac_sha256_set_key(&ctx, len, key)
++#define HMAC_crunch(ctx, buf, len)	hmac_sha256_update(&ctx, len, buf)
++#define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig)
++#define HMAC_close(ctx)
++
++typedef struct arcfour_ctx*	RC4_handle;
++#define RC4_alloc(h)	*h = malloc(sizeof(struct arcfour_ctx))
++#define RC4_setkey(h,l,k)	arcfour_set_key(h, l, k)
++#define RC4_encrypt(h,l,d)	arcfour_crypt(h,l,(uint8_t *)d,(uint8_t *)d)
++#define RC4_encrypt2(h,l,s,d)	arcfour_crypt(h,l,(uint8_t *)d,(uint8_t *)s)
++#define RC4_free(h)	free(h)
++
+ #else	/* USE_OPENSSL */
+ #include <openssl/sha.h>
+ #include <openssl/hmac.h>
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 0320480..8cefd3b 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -52,6 +52,17 @@
+ #define HMAC_crunch(ctx, buf, len)	gcry_md_write(ctx, buf, len)
+ #define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen)
+ #define HMAC_close(ctx)	gcry_md_close(ctx)
++#elif defined(USE_GNUTLS_NETTLE)
++#include <nettle/hmac.h>
++#ifndef SHA256_DIGEST_LENGTH
++#define SHA256_DIGEST_LENGTH	32
++#endif
++#undef HMAC_CTX
++#define HMAC_CTX	struct hmac_sha256_ctx
++#define HMAC_setup(ctx, key, len)	hmac_sha256_set_key(&ctx, len, key)
++#define HMAC_crunch(ctx, buf, len)	hmac_sha256_update(&ctx, len, buf)
++#define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig)
++#define HMAC_close(ctx)
+ #else	/* USE_OPENSSL */
+ #include <openssl/ssl.h>
+ #include <openssl/sha.h>
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 52d0254..5cd7b8d 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -34,7 +34,7 @@
+ #ifdef CRYPTO
+ #ifdef USE_POLARSSL
+ #include <polarssl/havege.h>
+-#elif defined(USE_GNUTLS)
++#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
+ #include <gnutls/gnutls.h>
+ #else	/* USE_OPENSSL */
+ #include <openssl/ssl.h>
+@@ -204,7 +204,7 @@ RTMP_TLS_Init()
+   /* Do this regardless of NO_SSL, we use havege for rtmpe too */
+   RTMP_TLS_ctx = calloc(1,sizeof(struct tls_ctx));
+   havege_init(&RTMP_TLS_ctx->hs);
+-#elif defined(USE_GNUTLS) && !defined(NO_SSL)
++#elif (defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)) && !defined(NO_SSL)
+   /* Technically we need to initialize libgcrypt ourselves if
+    * we're not going to call gnutls_global_init(). Ignoring this
+    * for now.
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index c3fd4a6..478c59f 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -81,7 +81,7 @@ typedef struct tls_ctx {
+ #define TLS_shutdown(s)	ssl_close_notify(s)
+ #define TLS_close(s)	ssl_free(s); free(s)
+ 
+-#elif defined(USE_GNUTLS)
++#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
+ #include <gnutls/gnutls.h>
+ typedef struct tls_ctx {
+ 	gnutls_certificate_credentials_t cred;
+-- 
+1.7.10.4
+
+
+From 7340f6dbc6b3c8e552baab2e5a891c2de75cddcc Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Thu, 8 Mar 2012 23:19:45 -0800
+Subject: [PATCH 33/33] Cleanup prev commit, drop gcrypt support
+
+---
+ Makefile            |    3 +--
+ librtmp/Makefile    |    5 +----
+ librtmp/dh.h        |   19 +------------------
+ librtmp/handshake.h |   19 +------------------
+ librtmp/hashswf.c   |   11 -----------
+ librtmp/rtmp.c      |    4 ++--
+ librtmp/rtmp_sys.h  |    2 +-
+ 7 files changed, 7 insertions(+), 56 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 0cf41be..a1595a8 100644
+--- a/Makefile
++++ b/Makefile
+@@ -12,8 +12,7 @@ CRYPTO=OPENSSL
+ #CRYPTO=POLARSSL
+ #CRYPTO=GNUTLS
+ LIBZ=-lz
+-LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+-LIB_GNUTLS_NETTLE=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
++LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ CRYPTO_LIB=$(LIB_$(CRYPTO))
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 353c6c8..74ee3b5 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -21,17 +21,14 @@ CRYPTO=OPENSSL
+ DEF_POLARSSL=-DUSE_POLARSSL
+ DEF_OPENSSL=-DUSE_OPENSSL
+ DEF_GNUTLS=-DUSE_GNUTLS
+-DEF_GNUTLS_NETTLE=-DUSE_GNUTLS_NETTLE
+ DEF_=-DNO_CRYPTO
+ REQ_GNUTLS=gnutls
+-REQ_GNUTLS_NETTLE=gnutls
+ REQ_OPENSSL=libssl,libcrypto
+ LIBZ=-lz
+ LIBS_posix=
+ LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+-LIB_GNUTLS_NETTLE=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
++LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ PRIVATE_LIBS=$(LIBS_$(SYS))
+diff --git a/librtmp/dh.h b/librtmp/dh.h
+index 830000e..9959532 100644
+--- a/librtmp/dh.h
++++ b/librtmp/dh.h
+@@ -76,23 +76,7 @@ static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh)
+   return 0;
+ }
+ 
+-#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
+-#ifdef USE_GNUTLS
+-#include <gcrypt.h>
+-typedef gcry_mpi_t MP_t;
+-#define MP_new(m)	m = gcry_mpi_new(1)
+-#define MP_set_w(mpi, w)	gcry_mpi_set_ui(mpi, w)
+-#define MP_cmp(u, v)	gcry_mpi_cmp(u, v)
+-#define MP_set(u, v)	gcry_mpi_set(u, v)
+-#define MP_sub_w(mpi, w)	gcry_mpi_sub_ui(mpi, mpi, w)
+-#define MP_cmp_1(mpi)	gcry_mpi_cmp_ui(mpi, 1)
+-#define MP_modexp(r, y, q, p)	gcry_mpi_powm(r, y, q, p)
+-#define MP_free(mpi)	gcry_mpi_release(mpi)
+-#define MP_gethex(u, hex, res)	res = (gcry_mpi_scan(&u, GCRYMPI_FMT_HEX, hex, 0, 0) == 0)
+-#define MP_bytes(u)	(gcry_mpi_get_nbits(u) + 7) / 8
+-#define MP_setbin(u,buf,len)	gcry_mpi_print(GCRYMPI_FMT_USG,buf,len,NULL,u)
+-#define MP_getbin(u,buf,len)	gcry_mpi_scan(&u,GCRYMPI_FMT_USG,buf,len,NULL)
+-#else
++#elif defined(USE_GNUTLS)
+ #include <gmp.h>
+ #include <nettle/bignum.h>
+ typedef mpz_ptr MP_t;
+@@ -108,7 +92,6 @@ typedef mpz_ptr MP_t;
+ #define MP_bytes(u)	(mpz_sizeinbase(u, 2) + 7) / 8
+ #define MP_setbin(u,buf,len)	nettle_mpz_get_str_256(len,buf,u)
+ #define MP_getbin(u,buf,len)	u = malloc(sizeof(*u)); mpz_init2(u, 1); nettle_mpz_set_str_256_u(u,len,buf)
+-#endif
+ 
+ typedef struct MDH {
+   MP_t p;
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index 4c2ea7f..0438486 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -43,27 +43,10 @@ typedef arc4_context *	RC4_handle;
+ #define RC4_free(h)	free(h)
+ 
+ #elif defined(USE_GNUTLS)
+-#include <gcrypt.h>
+-#ifndef SHA256_DIGEST_LENGTH
+-#define SHA256_DIGEST_LENGTH	32
+-#endif
+-#define HMAC_CTX	gcry_md_hd_t
+-#define HMAC_setup(ctx, key, len)	gcry_md_open(&ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC); gcry_md_setkey(ctx, key, len)
+-#define HMAC_crunch(ctx, buf, len)	gcry_md_write(ctx, buf, len)
+-#define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen); gcry_md_close(ctx)
+-
+-typedef gcry_cipher_hd_t	RC4_handle;
+-#define	RC4_alloc(h)	gcry_cipher_open(h, GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM, 0)
+-#define RC4_setkey(h,l,k)	gcry_cipher_setkey(h,k,l)
+-#define RC4_encrypt(h,l,d)	gcry_cipher_encrypt(h,(void *)d,l,NULL,0)
+-#define RC4_encrypt2(h,l,s,d)	gcry_cipher_encrypt(h,(void *)d,l,(void *)s,l)
+-#define RC4_free(h)	gcry_cipher_close(h)
+-
+-#elif defined(USE_GNUTLS_NETTLE)
+ #include <nettle/hmac.h>
+ #include <nettle/arcfour.h>
+ #ifndef SHA256_DIGEST_LENGTH
+-#define SHA256_DIGEST_LENGTH    32
++#define SHA256_DIGEST_LENGTH	32
+ #endif
+ #undef HMAC_CTX
+ #define HMAC_CTX	struct hmac_sha256_ctx
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 8cefd3b..9f4e2c0 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -42,17 +42,6 @@
+ #define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig)
+ #define HMAC_close(ctx)
+ #elif defined(USE_GNUTLS)
+-#include <gnutls/gnutls.h>
+-#include <gcrypt.h>
+-#ifndef SHA256_DIGEST_LENGTH
+-#define SHA256_DIGEST_LENGTH	32
+-#endif
+-#define HMAC_CTX	gcry_md_hd_t
+-#define HMAC_setup(ctx, key, len)	gcry_md_open(&ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC); gcry_md_setkey(ctx, key, len)
+-#define HMAC_crunch(ctx, buf, len)	gcry_md_write(ctx, buf, len)
+-#define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen)
+-#define HMAC_close(ctx)	gcry_md_close(ctx)
+-#elif defined(USE_GNUTLS_NETTLE)
+ #include <nettle/hmac.h>
+ #ifndef SHA256_DIGEST_LENGTH
+ #define SHA256_DIGEST_LENGTH	32
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 5cd7b8d..52d0254 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -34,7 +34,7 @@
+ #ifdef CRYPTO
+ #ifdef USE_POLARSSL
+ #include <polarssl/havege.h>
+-#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
++#elif defined(USE_GNUTLS)
+ #include <gnutls/gnutls.h>
+ #else	/* USE_OPENSSL */
+ #include <openssl/ssl.h>
+@@ -204,7 +204,7 @@ RTMP_TLS_Init()
+   /* Do this regardless of NO_SSL, we use havege for rtmpe too */
+   RTMP_TLS_ctx = calloc(1,sizeof(struct tls_ctx));
+   havege_init(&RTMP_TLS_ctx->hs);
+-#elif (defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)) && !defined(NO_SSL)
++#elif defined(USE_GNUTLS) && !defined(NO_SSL)
+   /* Technically we need to initialize libgcrypt ourselves if
+    * we're not going to call gnutls_global_init(). Ignoring this
+    * for now.
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index 478c59f..c3fd4a6 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -81,7 +81,7 @@ typedef struct tls_ctx {
+ #define TLS_shutdown(s)	ssl_close_notify(s)
+ #define TLS_close(s)	ssl_free(s); free(s)
+ 
+-#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
++#elif defined(USE_GNUTLS)
+ #include <gnutls/gnutls.h>
+ typedef struct tls_ctx {
+ 	gnutls_certificate_credentials_t cred;
+-- 
+1.7.10.4
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/librtmp.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,25 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := librtmp
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := b65ce7708ae79adb51d1f43dd0b6d987076d7c42
+$(PKG)_SUBDIR   := rtmpdump-2.3
+$(PKG)_FILE     := rtmpdump-2.3.tgz
+$(PKG)_URL      := http://rtmpdump.mplayerhq.hu/download/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc gnutls
+
+define $(PKG)_UPDATE
+    echo 'Warning: Updates are temporarily disabled for package librtmp.' >&2;
+    echo $(librtmp_VERSION)
+endef
+
+define $(PKG)_BUILD
+    $(MAKE) -C '$(1)' \
+        CROSS_COMPILE='$(TARGET)-' \
+        prefix='$(PREFIX)/$(TARGET)' \
+        SYS=mingw \
+        CRYPTO=GNUTLS \
+        SHARED=no \
+        -j '$(JOBS)' install
+endef
--- a/src/libsamplerate.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libsamplerate.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.mega-nerd.com/SRC/download.html' | \
+    $(WGET) -q -O- 'http://www.mega-nerd.com/SRC/download.html' | \
     $(SED) -n 's,.*libsamplerate-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v alpha | \
     grep -v beta | \
--- a/src/libshout-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libshout-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -3,44 +3,17 @@
 
 Contains ad hoc patches for cross building.
 
-From 25255ff19813e122e6442518b29a55c15860d3a3 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Fri, 1 Oct 2010 17:20:29 +0200
+From b05b2d82333e13f637dffb93f821907f775eb585 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 20 May 2012 23:23:37 +0200
 Subject: [PATCH] mingw fixes
 
+---
+ include/shout/shout.h.in |    2 ++
+ 1 file changed, 2 insertions(+)
 
-diff --git a/examples/nonblocking.c b/examples/nonblocking.c
-index 0f4aa68..49a3d36 100644
---- a/examples/nonblocking.c
-+++ b/examples/nonblocking.c
-@@ -68,7 +68,11 @@ int main()
- 
- 	while (ret == SHOUTERR_BUSY) {
- 	  printf("Connection pending. Sleeping...\n");
-+#ifdef __MINGW32__
-+	  Sleep(1000);
-+#else
- 	  sleep(1);
-+#endif
- 	  ret = shout_get_connected(shout);
- 	}
- 	
-diff --git a/include/os.h b/include/os.h
-index 7d065b3..d7ae425 100755
---- a/include/os.h
-+++ b/include/os.h
-@@ -1,7 +1,9 @@
- #ifdef _WIN32
-+#ifndef __MINGW32__
- typedef __int64 int64_t;
- typedef unsigned __int64 uint64_t;
- typedef unsigned __int32 uint32_t;
- typedef __int32 int32_t;
- typedef int  ssize_t;
- #endif
-+#endif
 diff --git a/include/shout/shout.h.in b/include/shout/shout.h.in
-index 43b0e7a..b026c10 100644
+index 682ad49..f412cdc 100644
 --- a/include/shout/shout.h.in
 +++ b/include/shout/shout.h.in
 @@ -23,8 +23,10 @@
@@ -55,5 +28,5 @@
  #define SHOUTERR_SUCCESS	(0)
  #define SHOUTERR_INSANE		(-1)
 -- 
-1.7.1
+1.7.9.2
 
--- a/src/libshout.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libshout.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libshout
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := cabc409e63f55383f4d85fac26d3056bf0365aac
+$(PKG)_CHECKSUM := 147c5670939727420d0e2ad6a20468e2c2db1e20
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://downloads.us.xiph.org/releases/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc vorbis ogg theora speex
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.icecast.org/download.php' | \
+    $(WGET) -q -O- 'http://www.icecast.org/download.php' | \
     $(SED) -n 's,.*libshout-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -18,9 +18,9 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
-        --disable-debug \
         --disable-thread \
         --infodir='$(1)/sink' \
         --mandir='$(1)/sink'
--- a/src/libsigc++.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libsigc++.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libsigc++
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 240d3e0a02e764a6362f6ce1b32de71401e50844
+$(PKG)_CHECKSUM := bbec3d8c54a17f19d63f9decbb91b0d79ea0d02e
 $(PKG)_SUBDIR   := libsigc++-$($(PKG)_VERSION)
-$(PKG)_FILE     := libsigc++-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := libsigc++-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/libsigc++/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libsigc++2/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libsigc++2/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/libsndfile.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libsndfile.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sqlite flac ogg vorbis
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.mega-nerd.com/libsndfile/' | \
+    $(WGET) -q -O- 'http://www.mega-nerd.com/libsndfile/' | \
     grep '<META NAME="Version"' | \
     $(SED) -n 's,.*CONTENT="libsndfile-\([0-9][^"]*\)">.*,\1,p' | \
     head -1
--- a/src/libssh2-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libssh2-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,32 +1,52 @@
 This file is part of MXE.
 See index.html for further information.
 
-From b3ade9a63e881e69b4c9cfe7b5dbad78dcc4a0e0 Mon Sep 17 00:00:00 2001
-From: Peter Stuge <peter@stuge.se>
-Date: Wed, 1 Feb 2012 09:53:44 +0100
-Subject: [PATCH] Fix undefined reference to _libssh_error in libgcrypt
- backend
+From 0e2179c67d0cd618be29b30425bda18c23a2ddf0 Mon Sep 17 00:00:00 2001
+From: Dmitry Smirnov <onlyjob@member.fsf.org>
+Date: Mon, 13 Aug 2012 23:34:51 +0200
+Subject: [PATCH 1/2] configure: gcrypt doesn't come with pkg-config support
 
-Commit 209de22299b4b58e582891dfba70f57e1e0492db introduced a function
-call to a non-existing function, and since then the libgcrypt backend
-has not been buildable.
----
- src/libgcrypt.c |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
+... so use plain old -lgcrypt to the linker to link with it.
+
+Fixes #225
+(cherry picked from commit e470738a0cf302abfd2891b80dbac4ac3e7eedd2)
 
-diff --git a/src/libgcrypt.c b/src/libgcrypt.c
-index 1bda5ee..5c2787b 100644
---- a/src/libgcrypt.c
-+++ b/src/libgcrypt.c
-@@ -581,7 +581,7 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
-                           const char *privatekey,
-                           const char *passphrase)
- {
--    return _libssh_error(session, LIBSSH2_ERROR_FILE,
-+    return _libssh2_error(session, LIBSSH2_ERROR_FILE,
-                          "Unable to extract public key from private key file: "
-                          "Method unimplemented in libgcrypt backend");
- }
+diff --git a/configure.ac b/configure.ac
+index aa9d397..dfc6988 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,7 +102,7 @@ fi
+ # Look for libgcrypt
+ if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
+   AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
+-  LIBSREQUIRED=libgcrypt
++  LIBS="$LIBS -lgcrypt"
+ fi
+ 
+ AC_SUBST(LIBSREQUIRED)
 -- 
-1.7.8.3
+1.7.10.4
+
+
+From 75ecbf4e5ca3c977418f60db42ba03c13d0e68f9 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 2 Sep 2012 00:55:28 +0200
+Subject: [PATCH 2/2] include gpg-error with gcrypt for static linking
+ (mxe-specific)
+
 
+diff --git a/configure.ac b/configure.ac
+index dfc6988..748dd21 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -103,6 +103,7 @@ fi
+ if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
+   AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
+   LIBS="$LIBS -lgcrypt"
++  LIBS="$LIBS `${prefix}/bin/gpg-error-config --libs`"
+ fi
+ 
+ AC_SUBST(LIBSREQUIRED)
+-- 
+1.7.10.4
+
--- a/src/libssh2.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libssh2.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,28 +3,28 @@
 
 PKG             := libssh2
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 53428b4935ab6eb843d45f1593dc434cb287b93e
+$(PKG)_CHECKSUM := 7fc084254dabe14a9bc90fa3d569faa7ee943e19
 $(PKG)_SUBDIR   := libssh2-$($(PKG)_VERSION)
 $(PKG)_FILE     := libssh2-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.libssh2.org/download/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libgcrypt zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.libssh2.org/download/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://www.libssh2.org/download/?C=M;O=D' | \
     grep 'libssh2-' | \
     $(SED) -n 's,.*libssh2-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
+    cd '$(1)' && ./buildconf
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --without-openssl \
         --with-libgcrypt \
-        PKG_CONFIG='$(TARGET)-pkg-config' \
-        LIBS="-lgcrypt `$(PREFIX)/$(TARGET)/bin/gpg-error-config --libs`"
+        PKG_CONFIG='$(TARGET)-pkg-config'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= html_DATA=
 
     '$(TARGET)-gcc' \
--- a/src/libtool.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libtool.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/libtool/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/libtool/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="libtool-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libunistring.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libunistring.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
     grep '<a class="list name"' | \
     $(SED) -n 's,.*<a[^>]*>v\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/libusb.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libusb.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libvpx-1-config.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-# This file is part of MXE.
-# See index.html for further information.
-
-diff --git a/configure b/configure
---- a/configure
-+++ b/configure
-@@ -465,9 +465,6 @@ process_detect() {
-         }
-     fi
-     check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
--    check_ld <<EOF || die "Toolchain is unable to link executables"
--int main(void) {return 0;}
--EOF
-     # check system headers
-     check_header stdint.h
-     check_header pthread.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libvpx-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,165 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains ad hoc patches for cross building.
+
+From 01c0e284b4d458fade9f8b2288863f3dd4dbc81a Mon Sep 17 00:00:00 2001
+From: MXE
+Date: Fri, 25 May 2012 23:36:41 +0200
+Subject: [PATCH 1/4] add Libs.private to vpx.pc
+
+
+diff --git a/libs.mk b/libs.mk
+index e2ba737..209f77e 100644
+--- a/libs.mk
++++ b/libs.mk
+@@ -242,6 +242,7 @@ vpx.pc: config.mk libs.mk
+ 	$(qexec)echo 'Requires:' >> $@
+ 	$(qexec)echo 'Conflicts:' >> $@
+ 	$(qexec)echo 'Libs: -L$${libdir} -lvpx' >> $@
++	$(qexec)echo 'Libs.private: -lpthread' >> $@
+ 	$(qexec)echo 'Cflags: -I$${includedir}' >> $@
+ INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
+ INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
+-- 
+1.7.11.5
+
+
+From 73c1c32c41b75a432fbe092fb621474a760d0f51 Mon Sep 17 00:00:00 2001
+From: MXE
+Date: Fri, 25 May 2012 23:40:00 +0200
+Subject: [PATCH 2/4] linking as test is not good for cross compiling
+
+
+diff --git a/configure b/configure
+index 62e1ffb..0c4faf9 100755
+--- a/configure
++++ b/configure
+@@ -481,9 +481,6 @@ process_detect() {
+         }
+     fi
+     check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
+-    check_ld <<EOF || die "Toolchain is unable to link executables"
+-int main(void) {return 0;}
+-EOF
+     # check system headers
+     check_header stdint.h
+     check_header pthread.h
+-- 
+1.7.11.5
+
+
+From 88bedac576559c599f3084b4eaa61a2ef85cfd06 Mon Sep 17 00:00:00 2001
+From: MXE
+Date: Fri, 25 May 2012 23:40:55 +0200
+Subject: [PATCH 3/4] fix bin/bash
+
+
+diff --git a/build/make/armlink_adapter.sh b/build/make/armlink_adapter.sh
+index b53669c..71cf7e9 100755
+--- a/build/make/armlink_adapter.sh
++++ b/build/make/armlink_adapter.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/configure.sh b/build/make/configure.sh
+index 3c772e5..032b5e8 100755
+--- a/build/make/configure.sh
++++ b/build/make/configure.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  configure.sh
+ ##
+diff --git a/build/make/gen_asm_deps.sh b/build/make/gen_asm_deps.sh
+index 717f870..81b7095 100755
+--- a/build/make/gen_asm_deps.sh
++++ b/build/make/gen_asm_deps.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/gen_msvs_def.sh b/build/make/gen_msvs_def.sh
+index 4defcc2..12e3573 100755
+--- a/build/make/gen_msvs_def.sh
++++ b/build/make/gen_msvs_def.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/gen_msvs_proj.sh b/build/make/gen_msvs_proj.sh
+index 6d42941..4418034 100755
+--- a/build/make/gen_msvs_proj.sh
++++ b/build/make/gen_msvs_proj.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/gen_msvs_sln.sh b/build/make/gen_msvs_sln.sh
+index 240678b..2089f68 100755
+--- a/build/make/gen_msvs_sln.sh
++++ b/build/make/gen_msvs_sln.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/version.sh b/build/make/version.sh
+index 3efb956..b3a9c23 100755
+--- a/build/make/version.sh
++++ b/build/make/version.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/configure b/configure
+index 0c4faf9..5d1db69 100755
+--- a/configure
++++ b/configure
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  configure
+ ##
+-- 
+1.7.11.5
+
+
+From 3d905203699e813027233bd0f19b05d44b98470d Mon Sep 17 00:00:00 2001
+From: MXE
+Date: Mon, 17 Sep 2012 20:23:14 +1000
+Subject: [PATCH 4/4] Fix for building on OSX
+
+Taken from:
+https://gerrit.chromium.org/gerrit/#/c/26027/
+
+diff --git a/build/make/gen_asm_deps.sh b/build/make/gen_asm_deps.sh
+index 81b7095..158ec34 100755
+--- a/build/make/gen_asm_deps.sh
++++ b/build/make/gen_asm_deps.sh
+@@ -42,7 +42,7 @@ done
+ 
+ [ -n "$srcfile" ] || show_help
+ sfx=${sfx:-asm}
+-includes=$(LC_ALL=C egrep -i "include +\"?+[a-z0-9_/]+\.${sfx}" $srcfile |
++includes=$(LC_ALL=C egrep -i "include +\"?[a-z0-9_/]+\.${sfx}" $srcfile |
+            perl -p -e "s;.*?([a-z0-9_/]+.${sfx}).*;\1;")
+ #" restore editor state
+ for inc in ${includes}; do
+-- 
+1.7.11.5
+
--- a/src/libvpx-2-fix-bin-bash.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://code.google.com/p/webm/issues/detail?id=54
-
-diff --git a/build/make/armlink_adapter.sh b/build/make/armlink_adapter.sh
---- a/build/make/armlink_adapter.sh
-+++ b/build/make/armlink_adapter.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/configure.sh b/build/make/configure.sh
---- a/build/make/configure.sh
-+++ b/build/make/configure.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  configure.sh
- ##
-diff --git a/build/make/gen_asm_deps.sh b/build/make/gen_asm_deps.sh
---- a/build/make/gen_asm_deps.sh
-+++ b/build/make/gen_asm_deps.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/gen_msvs_def.sh b/build/make/gen_msvs_def.sh
---- a/build/make/gen_msvs_def.sh
-+++ b/build/make/gen_msvs_def.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/gen_msvs_proj.sh b/build/make/gen_msvs_proj.sh
---- a/build/make/gen_msvs_proj.sh
-+++ b/build/make/gen_msvs_proj.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/gen_msvs_sln.sh b/build/make/gen_msvs_sln.sh
---- a/build/make/gen_msvs_sln.sh
-+++ b/build/make/gen_msvs_sln.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/version.sh b/build/make/version.sh
---- a/build/make/version.sh
-+++ b/build/make/version.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/configure b/configure
---- a/configure
-+++ b/configure
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  configure
- ##
--- a/src/libvpx.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libvpx.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libvpx
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2919e11074fef72fc61ef1a75160050ffaad6074
+$(PKG)_CHECKSUM := 356af5f770c50cd021c60863203d8f30164f6021
 $(PKG)_SUBDIR   := $(PKG)-v$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-v$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://webm.googlecode.com/files/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc
+$(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://code.google.com/p/webm/downloads/list?sort=-uploaded' | \
+    $(WGET) -q -O- 'http://code.google.com/p/webm/downloads/list?sort=-uploaded' | \
     $(SED) -n 's,.*libvpx-v\([0-9][^<]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libxml++.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libxml++.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libxml++
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 112d6e26a8ce1426aa8931f26ea593484b2081f0
+$(PKG)_CHECKSUM := b2e5ba6066e7fb96cca88e7c37e1e4848552c245
 $(PKG)_SUBDIR   := libxml++-$($(PKG)_VERSION)
 $(PKG)_FILE     := libxml++-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/GNOME/sources/libxml++/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libxml2 glibmm
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libxml++/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libxml++/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
@@ -19,6 +19,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && CXX="$(TARGET)-g++ -mthreads" ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         MAKE=$(MAKE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libxml2-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,24 @@
+From 8c3eedd79a80d08a1634ad09d4e343da7dc14759 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sat, 16 Jun 2012 19:44:21 +0200
+Subject: [PATCH] .pc requires.private liblzma
+
+---
+ libxml-2.0.pc.in |    1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libxml-2.0.pc.in b/libxml-2.0.pc.in
+index 31a1b8c..44e3cbf 100644
+--- a/libxml-2.0.pc.in
++++ b/libxml-2.0.pc.in
+@@ -8,6 +8,7 @@ Name: libXML
+ Version: @VERSION@
+ Description: libXML library version2.
+ Requires:
++Requires.private: liblzma
+ Libs: -L${libdir} -lxml2
+ Libs.private: @THREAD_LIBS@ @Z_LIBS@ @ICONV_LIBS@ @M_LIBS@ @WIN32_EXTRA_LIBADD@ @LIBS@
+ Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
+-- 
+1.7.10.4
+
--- a/src/libxml2.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libxml2.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libxml2
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 859dd535edbb851cc15b64740ee06551a7a17d40
+$(PKG)_CHECKSUM := a0c553bd51ba79ab6fff26dc700004c6a41f5250
 $(PKG)_SUBDIR   := libxml2-$($(PKG)_VERSION)
 $(PKG)_FILE     := libxml2-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://xmlsoft.org/libxml2/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc
+$(PKG)_DEPS     := gcc xz
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libxml2/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libxml2/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=v\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
@@ -20,6 +20,7 @@
     $(SED) -i 's,`uname`,MinGW,g' '$(1)/xml2-config.in'
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --without-debug \
         --prefix='$(PREFIX)/$(TARGET)' \
--- a/src/libxslt.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/libxslt.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libxslt
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 69f74df8228b504a87e2b257c2d5238281c65154
+$(PKG)_CHECKSUM := f8072177f1ffe1b9bb8759a9e3e6349e1eac1f66
 $(PKG)_SUBDIR   := libxslt-$($(PKG)_VERSION)
 $(PKG)_FILE     := libxslt-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://xmlsoft.org/libxslt/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libxml2 libgcrypt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libxslt/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libxslt/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=v\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
--- a/src/llvm.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/llvm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://llvm.org/releases/download.html' | \
+    $(WGET) -q -O- 'http://llvm.org/releases/download.html' | \
     grep 'Download LLVM' | \
     $(SED) -n 's,.*\([0-9]\.[0-9]\).*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-1-gcc.4.4.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,47 @@
+This file is part of MXE.
+See index.html for further information.
+
+These changes have already been applied to log4cxx trunk to update inclusions
+for recent gcc's.
+
+diff -NBaur vanilla/src/examples/cpp/console.cpp mingw_cross/src/examples/cpp/console.cpp
+--- vanilla/src/examples/cpp/console.cpp	2008-04-01 07:34:52.000000000 +0900
++++ mingw_cross/src/examples/cpp/console.cpp	2011-05-09 10:27:52.923808248 +0900
+@@ -15,6 +15,7 @@
+  * limitations under the License.
+  */
+ 
++#include <cstdio>
+ #include <stdlib.h>
+ #include <log4cxx/logger.h>
+ #include <log4cxx/consoleappender.h>
+@@ -22,6 +23,7 @@
+ #include <log4cxx/logmanager.h>
+ #include <iostream>
+ #include <locale.h>
++#include <string.h>
+ 
+ using namespace log4cxx;
+ using namespace log4cxx::helpers;
+diff -NBaur vanilla/src/main/cpp/inputstreamreader.cpp mingw_cross/src/main/cpp/inputstreamreader.cpp
+--- vanilla/src/main/cpp/inputstreamreader.cpp	2008-04-01 07:34:09.000000000 +0900
++++ mingw_cross/src/main/cpp/inputstreamreader.cpp	2011-05-09 10:27:27.991842868 +0900
+@@ -20,6 +20,7 @@
+ #include <log4cxx/helpers/exception.h>
+ #include <log4cxx/helpers/pool.h>
+ #include <log4cxx/helpers/bytebuffer.h>
++#include <string.h>
+ 
+ using namespace log4cxx;
+ using namespace log4cxx::helpers;
+diff -NBaur vanilla/src/main/cpp/socketoutputstream.cpp mingw_cross/src/main/cpp/socketoutputstream.cpp
+--- vanilla/src/main/cpp/socketoutputstream.cpp	2008-04-01 07:34:09.000000000 +0900
++++ mingw_cross/src/main/cpp/socketoutputstream.cpp	2011-05-09 10:27:27.999058156 +0900
+@@ -19,6 +19,7 @@
+ #include <log4cxx/helpers/socketoutputstream.h>
+ #include <log4cxx/helpers/socket.h>
+ #include <log4cxx/helpers/bytebuffer.h>
++#include <string.h>
+ 
+ using namespace log4cxx;
+ using namespace log4cxx::helpers;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-2-pkgconfig.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,19 @@
+This file is part of MXE.
+See index.html for further information.
+
+This patch ensures that the correct dependencies can always be found for
+static mingw builds. Submitted upstream: 
+
+   https://issues.apache.org/jira/browse/LOGCXX-381
+
+diff -NBaur vanilla/liblog4cxx.pc.in mingw_cross/liblog4cxx.pc.in
+--- vanilla/liblog4cxx.pc.in	2008-04-01 07:34:52.000000000 +0900
++++ mingw_cross/liblog4cxx.pc.in	2011-05-09 10:31:00.175584637 +0900
+@@ -20,6 +20,7 @@
+ Name: log4cxx
+ Description: log4cxx C++ logging framework
+ Version: @VERSION@
++Requires: apr-util-1, apr-1
+ Libs: -L${libdir} -llog4cxx
+ Cflags: -I${includedir}
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-3-warnings.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,20 @@
+This file is part of MXE.
+See index.html for further information.
+
+Already applied to log4cxx trunk.
+
+diff -NBaur vanilla/src/main/include/log4cxx/helpers/objectptr.h mingw_cross/src/main/include/log4cxx/helpers/objectptr.h
+--- vanilla/src/main/include/log4cxx/helpers/objectptr.h	2008-04-01 07:34:26.000000000 +0900
++++ mingw_cross/src/main/include/log4cxx/helpers/objectptr.h	2011-05-09 10:30:03.767560165 +0900
+@@ -28,9 +28,9 @@
+ //   switching between the initialization styles.
+ //
+ #if LOG4CXX_HELGRIND
+-#define _LOG4CXX_OBJECTPTR_INIT(x) { exchange(x); 
++#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase() { exchange(x); 
+ #else
+-#define _LOG4CXX_OBJECTPTR_INIT(x) : p(x) {
++#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase(), p(x) {
+ #endif
+ 
+ namespace log4cxx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-4-mingw.definitions.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,28 @@
+This file is part of MXE.
+See index.html for further information.
+
+Fixes a problem with the mismatched calling conventions in apr and log4cxx.
+See http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg02671.html
+Submitted upstream:
+
+  https://issues.apache.org/jira/browse/LOGCXX-382
+
+diff -NBaur vanilla/src/main/include/log4cxx/helpers/thread.h mingw_cross/src/main/include/log4cxx/helpers/thread.h
+--- vanilla/src/main/include/log4cxx/helpers/thread.h	2008-04-01 07:34:26.000000000 +0900
++++ mingw_cross/src/main/include/log4cxx/helpers/thread.h	2011-05-09 11:08:23.123558232 +0900
+@@ -23,9 +23,13 @@
+ 
+ #if !defined(LOG4CXX_THREAD_FUNC)
+ #if defined(_WIN32)
+-#define LOG4CXX_THREAD_FUNC __stdcall
++  #if defined(__MINGW32__)
++    #define LOG4CXX_THREAD_FUNC
++  #else
++    #define LOG4CXX_THREAD_FUNC __stdcall
++  #endif
+ #else
+-#define LOG4CXX_THREAD_FUNC
++  #define LOG4CXX_THREAD_FUNC
+ #endif
+ #endif
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-5-cmake.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,17 @@
+This file is part of MXE.
+See index.html for further information.
+
+diff -NBaur vanilla/log4cxx-config.cmake mingw_cross/log4cxx-config.cmake
+--- vanilla/log4cxx-config.cmake	1970-01-01 09:00:00.000000000 +0900
++++ mingw_cross/log4cxx-config.cmake	2012-03-14 15:29:54.706247316 +0900
+@@ -0,0 +1,10 @@
++
++set(LOG4CXX_VERSION 0.10.0)
++
++get_filename_component(LOG4CXX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
++
++set(LOG4CXX_INCLUDE_DIR "${LOG4CXX_CMAKE_DIR}/../../../include" CACHE FILEPATH "Log4cxx include directory")
++set(LOG4CXX_INCLUDE_DIRS "${LOG4CXX_INCLUDE_DIR}")
++set(LOG4CXX_LIBRARY_DIRS "${LOG4CXX_CMAKE_DIR}/../../../lib")
++set(LOG4CXX_LIBRARIES "log4cxx;aprutil-1;iconv;expat;apr-1;rpcrt4;shell32;ws2_32;advapi32;kernel32;msvcrt")
++
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-test.cpp	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,33 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <cstdlib>
+#include "log4cxx/logger.h"
+#include "log4cxx/basicconfigurator.h"
+#include "log4cxx/helpers/exception.h"
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+
+LoggerPtr logger(Logger::getLogger("MXE"));
+
+int main(int argc, char **argv)
+{
+    (void)argc;
+    (void)argv;
+
+    int result = EXIT_SUCCESS;
+    try
+    {
+        BasicConfigurator::configure();
+        LOG4CXX_INFO(logger, "Hello World!");
+    }
+    catch(Exception&)
+    {
+        result = EXIT_FAILURE;
+    }
+
+    return result;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,37 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := log4cxx
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := d79c053e8ac90f66c5e873b712bb359fd42b648d
+$(PKG)_SUBDIR   := apache-log4cxx-$($(PKG)_VERSION)
+$(PKG)_FILE     := apache-log4cxx-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://apache.naggo.co.kr/logging/log4cxx/0.10.0/$($(PKG)_FILE)
+$(PKG)_URL_2    := http://apache.mirror.cdnetworks.com//logging/log4cxx/0.10.0/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc apr-util
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://logging.apache.org/log4cxx/download.html' | \
+    $(SED) -n 's,.*log4cxx-\([0-9.]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --host='$(TARGET)' \
+        --disable-shared \
+        --enable-static \
+        --with-apr='$(PREFIX)/$(TARGET)' \
+        --with-apr-util='$(PREFIX)/$(TARGET)' \
+        CFLAGS=-D_WIN32_WINNT=0x0500 \
+        CXXFLAGS=-D_WIN32_WINNT=0x0500
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= man_MANS=
+    mkdir -p '$(PREFIX)/$(TARGET)/share/cmake/log4cxx'
+    cp '$(1)/log4cxx-config.cmake' '$(PREFIX)/$(TARGET)/share/cmake/log4cxx/log4cxx-config.cmake'
+
+    '$(TARGET)-g++' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).cpp' -o '$(PREFIX)/$(TARGET)/bin/test-log4cxx.exe' \
+        `$(TARGET)-pkg-config liblog4cxx --libs`
+endef
--- a/src/lua-test.c	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/lua-test.c	Mon Oct 08 22:34:44 2012 +0200
@@ -14,7 +14,7 @@
     (void)argc;
     (void)argv;
 
-    L = lua_open();
+    L = luaL_newstate();
     lua_close(L);
     return 0;
 }
--- a/src/lua.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/lua.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := lua
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2b11c8e60306efb7f0734b747588f57995493db7
+$(PKG)_CHECKSUM := 08f84c355cdd646f617f09cebea48bd832415829
 $(PKG)_SUBDIR   := lua-$($(PKG)_VERSION)
 $(PKG)_FILE     := lua-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.lua.org/ftp/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.lua.org/download.html' | \
+    $(WGET) -q -O- 'http://www.lua.org/download.html' | \
     $(SED) -n 's,.*lua-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -29,12 +29,9 @@
         TO_BIN='lua.h' \
         INSTALL='$(INSTALL)' \
         install
-    $(SED) -i 's,^prefix=.*,prefix=$(PREFIX)/$(TARGET),' '$(1)/etc/lua.pc'
-    $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
-    $(INSTALL) -m644 '$(1)/etc/lua.pc' '$(PREFIX)/$(TARGET)/lib/pkgconfig/lua.pc'
 
     '$(TARGET)-gcc' \
         -W -Wall -Werror -ansi -pedantic \
         '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-lua.exe' \
-        `'$(TARGET)-pkg-config' lua --cflags --libs`
+        -llua
 endef
--- a/src/lzo.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/lzo.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.oberhumer.com/opensource/lzo/download/' | \
+    $(WGET) -q -O- 'http://www.oberhumer.com/opensource/lzo/download/' | \
     grep 'lzo-' | \
     grep -v 'minilzo-' | \
     $(SED) -n 's,.*lzo-\([0-9][^>]*\)\.tar.*,\1,p' | \
--- a/src/matio.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/matio.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/matio/files/matio/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/matio/files/matio/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mdbtools.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,30 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# mdbtools
+PKG             := mdbtools
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 62fe0703fd8691e4536e1012317406bdb72594cf
+$(PKG)_SUBDIR   := brianb-mdbtools-004cc9f
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://github.com/brianb/$(PKG)/tarball/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc glib
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'https://github.com/brianb/mdbtools/tags' | \
+    grep '<a href="/brianb/mdbtools/tarball/' | \
+    $(SED) -n 's,.*href="/brianb/mdbtools/tarball/\([0-9][^"_]*\)".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    '$(SED)' -i 's/libtooloze/libtoolize/g;' '$(1)/autogen.sh'
+    cd '$(1)' && NOCONFIGURE=1 ./autogen.sh
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        PKG_CONFIG='$(PREFIX)/bin/$(TARGET)-pkg-config'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= html_DATA=
+endef
--- a/src/mingw-utils.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/mingw-utils.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Extension/mingw-utils/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Extension/mingw-utils/' | \
     $(SED) -n 's,.*mingw-utils-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/mingwrt.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/mingwrt.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := mingwrt
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 7c63f3695968054b7236282f35562bb3a2c388d4
+$(PKG)_CHECKSUM := cc6c1f841ab255e52e60f9c967cea6acf29354db
 $(PKG)_SUBDIR   := .
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION)-mingw32-dev.tar.gz
-$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/mingw/MinGW/Base/mingw-rt/$(PKG)-$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION)-mingw32-dev.tar.lzma
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/mingw/MinGW/Base/mingw-rt/mingwrt-3.20/$($(PKG)_FILE)
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/' | \
     $(SED) -n 's,.*mingwrt-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/mpfr.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/mpfr.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,15 +3,15 @@
 
 PKG             := mpfr
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 9ba6dfe62dad298f0570daf182db31660f7f016c
+$(PKG)_CHECKSUM := 7527c322b91fe8e6055ead551e1b46b9f1712ccd
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnu.org/pub/gnu/$(PKG)/$($(PKG)_FILE)
 $(PKG)_URL_2    := http://www.mpfr.org/mpfr-$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gmp
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.mpfr.org/mpfr-current/#download' | \
+    $(WGET) -q -O- 'http://www.mpfr.org/mpfr-current/#download' | \
     grep 'mpfr-' | \
     $(SED) -n 's,.*mpfr-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/muparser.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/muparser.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := muparser
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := d6d834d3ba2bd3c316c9b3070369d32701703f78
-$(PKG)_SUBDIR   := $(PKG)_v$(subst .,,$($(PKG)_VERSION))
-$(PKG)_FILE     := $(PKG)_v$(subst .,,$($(PKG)_VERSION)).tar.gz
+$(PKG)_CHECKSUM := 830383b1bcfa706be5a6ac8b7ba43f32f16a1497
+$(PKG)_SUBDIR   := $(PKG)_v$(subst .,_,$($(PKG)_VERSION))
+$(PKG)_FILE     := $(PKG)_v$(subst .,_,$($(PKG)_VERSION)).zip
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/Version $($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/muparser/files/muparser/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/muparser/files/muparser/' | \
     $(SED) -n 's,.*Version%20\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/mxml.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/mxml.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.easysw.com/pub/mxml/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.easysw.com/pub/mxml/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="\([0-9][^"]*\)/.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ncurses.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,35 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# ncurses
+PKG             := ncurses
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 3e042e5f2c7223bffdaac9646a533b8c758b65b5
+$(PKG)_SUBDIR   := ncurses-$($(PKG)_VERSION)
+$(PKG)_FILE     := ncurses-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://ftp.gnu.org/pub/gnu/ncurses/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://ftp.gnu.org/pub/gnu/ncurses/?C=M;O=D' | \
+    $(SED) -n 's,.*<a href="ncurses-\([0-9][^"]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --prefix=$(PREFIX)/$(TARGET) \
+        --disable-home-terminfo \
+        --enable-sp-funcs \
+        --enable-term-driver \
+        --enable-interop \
+        --without-debug \
+        --without-ada \
+        --without-manpages \
+        --enable-pc-files \
+        --with-normal \
+        --without-shared
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+endef
--- a/src/nettle.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/nettle.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := nettle
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 1df0cd013e83f73b78a5521411a67e331de3dfa6
+$(PKG)_CHECKSUM := 1061754feb69dd01354525fa7eb6154b28ac887d
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.lysator.liu.se/~nisse/archive/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gmp
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.lysator.liu.se/~nisse/archive/' | \
+    $(WGET) -q -O- 'http://www.lysator.liu.se/~nisse/archive/' | \
     $(SED) -n 's,.*nettle-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v 'pre' | \
     tail -1
@@ -19,8 +19,9 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
-        --enable-static \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' getopt.o getopt1.o
     $(MAKE) -C '$(1)' -j '$(JOBS)' install
 endef
--- a/src/nsis-1-explicit-mingw-cross-prefix.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://sourceforge.net/tracker/index.php?func=detail&aid=3305366&group_id=22049&atid=373085
-
---- a/SCons/Tools/crossmingw.py
-+++ b/SCons/Tools/crossmingw.py
-@@ -61,6 +61,9 @@ prefixes = SCons.Util.Split("""
- """)
- 
- def find(env):
-+    if env.has_key('MINGW_CROSS_PREFIX'):
-+        return env['MINGW_CROSS_PREFIX']
-+
-     for prefix in prefixes:
-         # First search in the SCons path and then the OS path:
-         if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'):
-diff --git a/SConstruct b/SConstruct
-index 80872bc..4f113dd 100755
---- a/SConstruct
-+++ b/SConstruct
-@@ -59,6 +59,7 @@ doc = [
- 
- path = ARGUMENTS.get('PATH', '')
- toolset = ARGUMENTS.get('TOOLSET', '')
-+mingw_cross_prefix = ARGUMENTS.get('MINGW_CROSS_PREFIX', '')
- 
- if toolset and path:
- 	defenv = Environment(ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip'])
-@@ -69,6 +70,8 @@ else:
- 		defenv = Environment(TOOLS = toolset.split(',') + ['zip'])
- if not toolset and not path:
- 	defenv = Environment()
-+if mingw_cross_prefix:
-+	defenv['MINGW_CROSS_PREFIX'] = mingw_cross_prefix
- 
- Export('defenv')
- 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nsis-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,71 @@
+This file is part of MXE.
+See index.html for further information.
+
+From 1cc3dd0dfd47bab82e06be916f9e57ef783406f9 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 12 Aug 2012 12:33:26 +0200
+Subject: [PATCH 1/2] explicit mingw cross prefix
+
+This patch has been taken from:
+http://sourceforge.net/tracker/index.php?func=detail&aid=3305366&group_id=22049&atid=373085
+
+diff --git a/SCons/Tools/crossmingw.py b/SCons/Tools/crossmingw.py
+index d27e01c..fef9150 100755
+--- a/SCons/Tools/crossmingw.py
++++ b/SCons/Tools/crossmingw.py
+@@ -61,6 +61,9 @@ prefixes = SCons.Util.Split("""
+ """)
+ 
+ def find(env):
++    if env.has_key('MINGW_CROSS_PREFIX'):
++        return env['MINGW_CROSS_PREFIX']
++
+     for prefix in prefixes:
+         # First search in the SCons path and then the OS path:
+         if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'):
+diff --git a/SConstruct b/SConstruct
+index 80872bc..4f113dd 100755
+--- a/SConstruct
++++ b/SConstruct
+@@ -59,6 +59,7 @@ doc = [
+ 
+ path = ARGUMENTS.get('PATH', '')
+ toolset = ARGUMENTS.get('TOOLSET', '')
++mingw_cross_prefix = ARGUMENTS.get('MINGW_CROSS_PREFIX', '')
+ 
+ if toolset and path:
+ 	defenv = Environment(ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip'])
+@@ -69,6 +70,8 @@ else:
+ 		defenv = Environment(TOOLS = toolset.split(',') + ['zip'])
+ if not toolset and not path:
+ 	defenv = Environment()
++if mingw_cross_prefix:
++	defenv['MINGW_CROSS_PREFIX'] = mingw_cross_prefix
+ 
+ Export('defenv')
+ 
+-- 
+1.7.10.4
+
+
+From 7df0fa80a65279ee7d99da8ec6abdddff7e040b0 Mon Sep 17 00:00:00 2001
+From: freeman <free.man.uu@gmail.com>
+Date: Sun, 12 Aug 2012 12:36:39 +0200
+Subject: [PATCH 2/2] add missing header
+
+
+diff --git a/Source/util.h b/Source/util.h
+index 4259a6a..664923e 100755
+--- a/Source/util.h
++++ b/Source/util.h
+@@ -25,6 +25,7 @@
+ #ifndef _WIN32
+ #  include <iconv.h>
+ #  include <stdio.h>
++#  include <unistd.h>
+ #endif
+ 
+ 
+-- 
+1.7.10.4
+
--- a/src/nsis.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/nsis.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://nsis.svn.sourceforge.net/viewvc/nsis/NSIS/tags/?sortby=date' | \
+    $(WGET) -q -O- 'http://nsis.svn.sourceforge.net/viewvc/nsis/NSIS/tags/?sortby=date' | \
     grep '<a name="' | \
     $(SED) -n 's,.*<a name="v\([0-9]\)\([^"]*\)".*,\1.\2,p' | \
     head -1
--- a/src/ogg.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/ogg.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.xiph.org/downloads/' | \
+    $(WGET) -q -O- 'http://www.xiph.org/downloads/' | \
     $(SED) -n 's,.*libogg-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/old.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/old.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://blitiri.com.ar/p/old/' | \
+    $(WGET) -q -O- 'http://blitiri.com.ar/p/old/' | \
     grep 'old-' | \
     $(SED) -n 's,.*old-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/openal-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,29 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains ad hoc patches for cross building.
+
+From b5c7c4853307964f0b8e11e2c9edb5bf0f8511f7 Mon Sep 17 00:00:00 2001
+From: Tony Theodore <tonyt@logyst.com>
+Date: Tue, 3 Apr 2012 14:36:58 +0200
+Subject: [PATCH] add static private dependencies to pkg-config for cmake
+
+---
+ CMakeLists.txt |    1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index ef3d08d..88de1e5 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -543,6 +543,7 @@ IF(DSOUND)
+                 SET(BACKENDS  "${BACKENDS} DirectSound \(linked\),")
+                 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
+             ENDIF()
++            SET(PKG_CONFIG_LIBS "${PKG_CONFIG_LIBS} -luuid -lole32")
+         ENDIF()
+     ENDIF()
+ ENDIF()
+-- 
+1.7.9.2
+
--- a/src/openal-1-luuid-pkg-config.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-
-
-diff -ur openal-soft-1.13.orig/CMakeLists.txt openal-soft-1.13/CMakeLists.txt
---- openal-soft-1.13.orig/CMakeLists.txt	2011-02-16 07:05:40.000000000 +1100
-+++ openal-soft-1.13/CMakeLists.txt	2011-03-02 15:40:02.000000000 +1100
-@@ -393,6 +393,7 @@
-                 SET(BACKENDS  "${BACKENDS} DirectSound \(linked\),")
-                 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
-             ENDIF()
-+            SET(PKG_CONFIG_LIBS "${PKG_CONFIG_LIBS} -luuid")
-         ENDIF()
-     ENDIF()
- ENDIF()
--- a/src/openal-2-guid-static-link.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-
-
---- openal-soft-1.13.orig/Alc/dsound.c	2011-02-08 01:44:06.000000000 -0500
-+++ openal-soft-1.13/Alc/dsound.c	2011-03-02 22:57:58.000000000 -0500
-@@ -21,7 +21,6 @@
- #include "config.h"
- 
- #define _WIN32_WINNT 0x0500
--#define INITGUID
- #include <stdlib.h>
- #include <stdio.h>
- #include <memory.h>
-@@ -45,8 +44,8 @@
- #define DSSPEAKER_7POINT1       7
- #endif
- 
--DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
--DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
-+const GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010,{0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-+const GUID KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
- 
- static void *ds_handle;
- static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter);
--- a/src/openal.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/openal.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := openal
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 0e2449375a12cee65a9cea354533dcaabf9d5068
+$(PKG)_CHECKSUM := e6d69db13ec15465b83a45ef89978e8a0f55beca
 $(PKG)_SUBDIR   := openal-soft-$($(PKG)_VERSION)
 $(PKG)_FILE     := openal-soft-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://kcat.strangesoft.net/openal-releases/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc portaudio
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://kcat.strangesoft.net/openal-releases/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://kcat.strangesoft.net/openal-releases/?C=M;O=D' | \
     $(SED) -n 's,.*"openal-soft-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -18,7 +18,8 @@
 define $(PKG)_BUILD
     cd '$(1)/build' && cmake .. \
         -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
-        -DLIBTYPE=STATIC
+        -DLIBTYPE=STATIC \
+        -DEXAMPLES=FALSE
     $(MAKE) -C '$(1)/build' -j '$(JOBS)' install
 
     '$(TARGET)-gcc' \
--- a/src/opencore-amr.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/opencore-amr.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/opencore-amr/files/opencore-amr/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/opencore-amr/files/opencore-amr/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/opencsg.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/opencsg.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freeglut glew qt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.opencsg.org/#download' | \
+    $(WGET) -q -O- 'http://www.opencsg.org/#download' | \
     grep 'OpenCSG-' | \
     $(SED) -n 's,.*OpenCSG-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/openexr.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/openexr.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc ilmbase pthreads zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.openexr.com/downloads.html' | \
+    $(WGET) -q -O- 'http://www.openexr.com/downloads.html' | \
     grep 'openexr-' | \
     $(SED) -n 's,.*openexr-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/openscenegraph.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/openscenegraph.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc curl ffmpeg freetype gdal giflib jasper jpeg libpng openexr tiff xine-lib zlib dcmtk qt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/tags?order=date&desc=1' | \
+    $(WGET) -q -O- 'http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/tags?order=date&desc=1' | \
     grep '<a ' | \
     $(SED) -n 's,.*>OpenSceneGraph-\([0-9][^<]*\)<.*,\1,p' | \
     grep -v '^2\.9\.' | \
--- a/src/openssl.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/openssl.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := openssl
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := a6476d33fd38c2e7dfb438d1e3be178cc242c907
+$(PKG)_CHECKSUM := 91b684de947cb021ac61b8c51027cc4b63d894ce
 $(PKG)_SUBDIR   := openssl-$($(PKG)_VERSION)
 $(PKG)_FILE     := openssl-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.openssl.org/source/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib libgcrypt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.openssl.org/source/' | \
+    $(WGET) -q -O- 'http://www.openssl.org/source/' | \
     $(SED) -n 's,.*openssl-\([0-9][0-9a-z.]*\)\.tar.*,\1,p' | \
     grep -v '^0\.9\.' | \
     head -1
--- a/src/pango-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pango-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,178 +1,188 @@
-This file is part of MXE.
-See index.html for further information.
-
-Contains ad hoc patches for cross building.
+From 971738e2fc2bc3faae52952dd08ee08b34ff4b86 Mon Sep 17 00:00:00 2001
+From: Matthias Gehre <M.Gehre@gmx.de>
+Date: Mon, 9 Jul 2012 13:13:49 +0200
+Subject: [PATCH 1/4] Rename DllMain to pango_DllMain
 
-From 987d02305fd8187bd10bfd292db38f7da705a7f3 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Wed, 29 Sep 2010 00:52:59 +0200
-Subject: [PATCH 1/4] s,DllMain,static _disabled_DllMain,
-
+---
+ pango/pango-utils.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/pango/pango-utils.c b/pango/pango-utils.c
-index 44ec353..72e13f1 100644
+index c68e2d4..47ca433 100644
 --- a/pango/pango-utils.c
 +++ b/pango/pango-utils.c
-@@ -658,12 +658,12 @@ pango_config_key_get (const char *key)
+@@ -692,12 +692,12 @@ pango_config_key_get (const char *key)
  
  #ifdef G_OS_WIN32
  
 -/* DllMain function needed to tuck away the DLL handle */
-+/* static _disabled_DllMain function needed to tuck away the DLL handle */
++/* pango_DllMain function needed to tuck away the DLL handle */
  
  static HMODULE pango_dll;
  
  BOOL WINAPI
 -DllMain (HINSTANCE hinstDLL,
-+static _disabled_DllMain (HINSTANCE hinstDLL,
++pango_DllMain (HINSTANCE hinstDLL,
  	 DWORD     fdwReason,
  	 LPVOID    lpvReserved)
  {
 -- 
-1.7.7.3
-
-
-From f0c5d358e54fd9d69133eeff972fdb05592789f3 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Wed, 29 Sep 2010 00:55:07 +0200
-Subject: [PATCH 2/4] static, not shared
+1.7.9.5
 
 
-diff --git a/configure b/configure
-index fb173ce..beb3290 100755
---- a/configure
-+++ b/configure
-@@ -5832,9 +5832,9 @@ if test "${enable_static+set}" = set; then :
-   enableval=$enable_static; p=${PACKAGE-default}
-     case $enableval in
-     yes) enable_static=yes ;;
--    no) enable_static=no ;;
-+    no) enable_static=yes ;;
-     *)
--     enable_static=no
-+     enable_static=yes
-       # Look at the argument we got.  We use all the common list separators.
-       lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-       for pkg in $enableval; do
-@@ -5847,7 +5847,7 @@ if test "${enable_static+set}" = set; then :
-       ;;
-     esac
- else
--  enable_static=no
-+  enable_static=yes
- fi
- 
- 
-@@ -5861,15 +5861,15 @@ fi
- 
- if test "$pango_os_win32" = "yes"; then
-   if test x$enable_static = xyes -o x$enable_static = x; then
--    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Disabling static library build, must build as DLL on Windows." >&5
--$as_echo "$as_me: WARNING: Disabling static library build, must build as DLL on Windows." >&2;}
--    enable_static=no
-+    { $as_echo "(disabled warning)" >&5
-+$as_echo "(disabled warning)" >&2;}
-+    enable_static=yes
-   fi
-   if test x$enable_shared = xno; then
--    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Enabling shared library build, must build as DLL on Windows." >&5
--$as_echo "$as_me: WARNING: Enabling shared library build, must build as DLL on Windows." >&2;}
-+    { $as_echo "(disabled warning)" >&5
-+$as_echo "(disabled warning)" >&2;}
-   fi
--  enable_shared=yes
-+  enable_shared=no
- fi
- 
- case `pwd` in
-@@ -8968,7 +8968,7 @@ func_stripname_cnf ()
- if test "${enable_shared+set}" = set; then :
-   enableval=$enable_shared; p=${PACKAGE-default}
-     case $enableval in
--    yes) enable_shared=yes ;;
-+    yes) enable_shared=no ;;
-     no) enable_shared=no ;;
-     *)
-       enable_shared=no
-@@ -8977,14 +8977,14 @@ if test "${enable_shared+set}" = set; then :
-       for pkg in $enableval; do
- 	IFS="$lt_save_ifs"
- 	if test "X$pkg" = "X$p"; then
--	  enable_shared=yes
-+	  enable_shared=no
- 	fi
-       done
-       IFS="$lt_save_ifs"
-       ;;
-     esac
- else
--  enable_shared=yes
-+  enable_shared=no
- fi
- 
- 
-@@ -12848,7 +12848,7 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
-   # are all built from PIC.
-   case $host_os in
-   aix3*)
--    test "$enable_shared" = yes && enable_static=no
-+    test "$enable_shared" = yes && enable_static=yes
-     if test -n "$RANLIB"; then
-       archive_cmds="$archive_cmds~\$RANLIB \$lib"
-       postinstall_cmds='$RANLIB $lib'
-@@ -12857,7 +12857,7 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
- 
-   aix[4-9]*)
-     if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
--      test "$enable_shared" = yes && enable_static=no
-+      test "$enable_shared" = yes && enable_static=yes
-     fi
-     ;;
-   esac
--- 
-1.7.7.3
+From 779c533bf4354cbc747d82532f4798e6ef006d1b Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Wed, 29 Sep 2010 00:50:08 +0200
+Subject: [PATCH 2/4] add missing lib to pango.pc for static linking
 
-
-From 08292532296e3a0f135f6bcd683851d2f41836c6 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Wed, 29 Sep 2010 00:57:12 +0200
-Subject: [PATCH 3/4] no pango-querymodules
-
-
-diff --git a/modules/Makefile.in b/modules/Makefile.in
-index 49813f7..afc29c5 100644
---- a/modules/Makefile.in
-+++ b/modules/Makefile.in
-@@ -647,7 +647,7 @@ uninstall-am: uninstall-local
- 
- @CROSS_COMPILING_FALSE@all-local: pango.modules
- 
--install-data-local: $(top_builddir)/pango/pango-querymodules$(EXEEXT)
-+install-data-local:
- 	@if $(RUN_QUERY_MODULES_TEST) && test -z "$(DESTDIR)" ; then 	\
- 	  echo $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/pango \&\& 	\
- 	  $(top_builddir)/pango/pango-querymodules$(EXEEXT) 		\
--- 
-1.7.7.3
-
-
-From c646ee7869c20a1e093f63ec8de8e83e7ca88b27 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Wed, 29 Sep 2010 00:50:08 +0200
-Subject: [PATCH 4/4] add missing lib to pango.pc for static linking
-
+---
+ pango.pc.in |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/pango.pc.in b/pango.pc.in
-index 5cc3ef8..745b8f0 100644
+index 17a8b7a..16c5981 100644
 --- a/pango.pc.in
 +++ b/pango.pc.in
-@@ -9,5 +9,5 @@ Name: Pango
- Description: Internationalized text handling
+@@ -10,5 +10,5 @@ Description: Internationalized text handling
  Version: @VERSION@
- Requires: glib-2.0,gobject-2.0,gmodule-no-export-2.0
+ Requires: glib-2.0 gobject-2.0
+ Requires.private: gmodule-no-export-2.0
 -Libs: -L${libdir} -lpango-@PANGO_API_VERSION@ @PKGCONFIG_MATH_LIBS@
 +Libs: -L${libdir} -lpango-@PANGO_API_VERSION@ @PKGCONFIG_MATH_LIBS@ -lusp10
  Cflags: -I${includedir}/pango-1.0
 -- 
-1.7.7.3
+1.7.9.5
+
+
+From 4340125c6b7f26106f7f021ec4c9612f7384e6c1 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Fri, 15 Jun 2012 16:21:40 +0200
+Subject: [PATCH 3/4] do not force shared for win32
+
+---
+ configure.in        |   14 --------------
+ modules/Makefile.am |   17 +----------------
+ 2 files changed, 1 insertion(+), 30 deletions(-)
 
+diff --git a/configure.in b/configure.in
+index 8362280..6a000cc 100644
+--- a/configure.in
++++ b/configure.in
+@@ -147,20 +147,6 @@ CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions"
+ # Win32 stuff
+ #
+ 
+-AC_LIBTOOL_WIN32_DLL
+-AM_DISABLE_STATIC
+-
+-if test "$pango_os_win32" = "yes"; then
+-  if test x$enable_static = xyes -o x$enable_static = x; then
+-    AC_MSG_WARN([Disabling static library build, must build as DLL on Windows.])
+-    enable_static=no
+-  fi
+-  if test x$enable_shared = xno; then
+-    AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows.])
+-  fi
+-  enable_shared=yes
+-fi
+-
+ AM_PROG_LIBTOOL
+ dnl when using libtool 2.x create libtool early, because it's used in configure
+ m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
+diff --git a/modules/Makefile.am b/modules/Makefile.am
+index dc8a2c8..dc22e59 100644
+--- a/modules/Makefile.am
++++ b/modules/Makefile.am
+@@ -26,22 +26,7 @@ RUN_QUERY_MODULES_TEST=true
+ all-local: pango.modules
+ endif
+ 
+-install-data-local: $(top_builddir)/pango/pango-querymodules$(EXEEXT)
+-	@if $(RUN_QUERY_MODULES_TEST) && test -z "$(DESTDIR)" ; then 	\
+-	  echo $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/pango \&\& 	\
+-	  $(top_builddir)/pango/pango-querymodules$(EXEEXT) 		\
+-		\> $(DESTDIR)$(sysconfdir)/pango/pango.modules ;	\
+-	  $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/pango && 		\
+-	  $(top_builddir)/pango/pango-querymodules$(EXEEXT) 		\
+-		> $(DESTDIR)$(sysconfdir)/pango/pango.modules ;		\
+-	else								\
+-	  echo "***" ; 							\
+-	  echo "*** Warning: $(sysconfdir)/pango/pango.modules" ; 	\
+-	  echo "*** not created" ; 					\
+-	  echo "*** Generate this file on the target system" ; 		\
+-	  echo "*** using pango-querymodules" ; 			\
+-	  echo "***" ; 							\
+-	fi
++install-data-local:
+ 
+ uninstall-local:
+ 	$(RM) $(DESTDIR)$(sysconfdir)/pango/pango.modules
+-- 
+1.7.9.5
+
+
+From ff735b2f71b07e7216856a473ed283eb24dd012a Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Mon, 18 Jun 2012 21:36:53 +0200
+Subject: [PATCH 4/4] kill gtk-doc (MXE specific)
+
+---
+ Makefile.am  |    2 +-
+ autogen.sh   |    8 --------
+ configure.in |    9 +--------
+ 3 files changed, 2 insertions(+), 17 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index b0b56ec..663503c 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,6 +1,6 @@
+ ## Process this file with automake to create Makefile.in.
+ 
+-SUBDIRS= pango modules pango-view examples docs tools tests build
++SUBDIRS= pango modules pango-view examples tools tests build
+ 
+ EXTRA_DIST = 			\
+ 	autogen.sh		\
+diff --git a/autogen.sh b/autogen.sh
+index bc7c59c..4e1918c 100755
+--- a/autogen.sh
++++ b/autogen.sh
+@@ -7,14 +7,6 @@ test -n "$srcdir" || srcdir=.
+ olddir=`pwd`
+ cd "$srcdir"
+ 
+-GTKDOCIZE=`which gtkdocize`
+-if test -z $GTKDOCIZE; then
+-	echo "*** No GTK-Doc found, please install it ***"
+-	exit 1
+-else
+-	gtkdocize || exit $?
+-fi
+-
+ AUTORECONF=`which autoreconf`
+ if test -z $AUTORECONF; then
+ 	echo "*** No autoreconf found, please install it ***"
+diff --git a/configure.in b/configure.in
+index 6a000cc..e7538f6 100644
+--- a/configure.in
++++ b/configure.in
+@@ -615,14 +615,7 @@ dnl **************************
+ dnl *** Checks for gtk-doc ***
+ dnl **************************
+ 
+-if $have_cairo ; then : ; else
+-   if  test x$enable_gtk_doc = xyes ; then
+-      AC_MSG_WARN([Cairo not present, disabling doc building])      
+-      enable_gtk_doc=no
+-   fi
+-fi
+-
+-GTK_DOC_CHECK([1.0])
++enable_gtk_doc=no
+ 
+ AC_ARG_ENABLE(man,
+               AC_HELP_STRING([--enable-man],
+-- 
+1.7.9.5
+
--- a/src/pango.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pango.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,20 +3,22 @@
 
 PKG             := pango
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 467a3dacc0f3173e6fd457524b9ccd9772039a62
+$(PKG)_CHECKSUM := f853a35758bed6aba6101e027ba7b4411448236f
 $(PKG)_SUBDIR   := pango-$($(PKG)_VERSION)
-$(PKG)_FILE     := pango-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := pango-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/pango/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc fontconfig freetype cairo glib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/pango/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/pango/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
 
 define $(PKG)_BUILD
+    rm '$(1)'/docs/Makefile.am
+    cd '$(1)' && NOCONFIGURE=1 ./autogen.sh
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
         --build="`config.guess`" \
--- a/src/pangomm.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pangomm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := pangomm
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 31bcbb0c8773fdde6f4ea9b4a79fdf7159f94520
+$(PKG)_CHECKSUM := ee83497485e180708dffbf2e68d633ae8d5a36b4
 $(PKG)_SUBDIR   := pangomm-$($(PKG)_VERSION)
 $(PKG)_FILE     := pangomm-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/pangomm/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc cairomm glibmm pango
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/pangomm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/pangomm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
--- a/src/pcre.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pcre.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := pcre
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 68d28fb383325b8af9e3d481d30f586b46c56022
+$(PKG)_CHECKSUM := 1132276bb8bea7cb0662210fb812fbef7791621f
 $(PKG)_SUBDIR   := pcre-$($(PKG)_VERSION)
 $(PKG)_FILE     := pcre-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/pcre/pcre/$($(PKG)_VERSION)/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/pcre/files/pcre/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/pcre/files/pcre/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/pdcurses.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pdcurses.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/pdcurses/files/pdcurses/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/pdcurses/files/pdcurses/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/pdflib_lite-1-mingw.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pdflib_lite-1-mingw.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,12 +1,21 @@
 This file is part of MXE.
 See index.html for further information.
 
+From ad526da840d636da440ce31a6c7f7909ed7ce61c Mon Sep 17 00:00:00 2001
+From: a <a@mxe.cc>
+Date: Mon, 11 Jun 2012 17:27:15 +0200
+Subject: [PATCH 1/2] fix for mingw
+
 This patch has been taken from:
 http://tech.groups.yahoo.com/group/pdflib/message/20472
+---
+ libs/pdcore/pc_util.c |    6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
 
-diff -urN a/libs/pdcore/pc_util.c b/libs/pdcore/pc_util.c
---- a/libs/pdcore/pc_util.c	2010-04-29 15:50:05.000000000 +0200
-+++ b/libs/pdcore/pc_util.c	2010-05-11 23:59:03.915954995 +0200
+diff --git a/libs/pdcore/pc_util.c b/libs/pdcore/pc_util.c
+index e8d8fec..f874bad 100644
+--- a/libs/pdcore/pc_util.c
++++ b/libs/pdcore/pc_util.c
 @@ -30,8 +30,12 @@
  #include <ieeefp.h>     /* for finite */
  #endif
@@ -21,3 +30,32 @@
  #else /* isfinite */
  
  #if defined(WIN32)
+-- 
+1.7.10.3
+
+
+From 315d17f1b6d050df824a26418b191ca38ebd4602 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Mon, 11 Jun 2012 17:33:04 +0200
+Subject: [PATCH 2/2] force mingw detection
+
+---
+ configure.in |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.in b/configure.in
+index 3944168..de6ec09 100644
+--- a/configure.in
++++ b/configure.in
+@@ -98,7 +98,7 @@ then
+ 	ac_sys_system=next && ac_sys_release=$4
+ 	MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu"
+     else
+-	ac_sys_system=`uname -s`
++	ac_sys_system=MinGW
+ 	if test "$ac_sys_system" = "AIX" ; then
+ 		ac_sys_release=`uname -v`
+ 	else
+-- 
+1.7.10.3
+
--- a/src/pdflib_lite.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pdflib_lite.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,22 +3,24 @@
 
 PKG             := pdflib_lite
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 5b2bf5edc49dba3da0997ade0e191511a37fae01
+$(PKG)_CHECKSUM := 42e0605ae21f4b6d25fa2d20e78fed6df36fbaa9
 $(PKG)_SUBDIR   := PDFlib-Lite-$($(PKG)_VERSION)
 $(PKG)_FILE     := PDFlib-Lite-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := https://distfiles.macports.org/pdflib/$($(PKG)_FILE)
+$(PKG)_URL      := http://www.pdflib.com/binaries/PDFlib/$(subst .,,$(word 1,$(subst p, ,$($(PKG)_VERSION))))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.pdflib.com/download/free-software/pdflib-lite-7/' | \
+    $(WGET) -q -O- 'http://www.pdflib.com/download/free-software/pdflib-lite-7/' | \
     $(SED) -n 's,.*PDFlib-Lite-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
-    $(SED) -i 's,ac_sys_system=`uname -s`,ac_sys_system=MinGW,' '$(1)/configure'
+    cd '$(1)' && aclocal -I config --install
+    cd '$(1)' && autoconf
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --without-openssl \
@@ -27,7 +29,6 @@
         --without-perl \
         --without-ruby \
         --without-tcl \
-        --disable-php \
         --enable-cxx \
         --enable-large-files \
         CFLAGS='-D_IOB_ENTRIES=20'
--- a/src/pfstools.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pfstools.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/pfstools/files/pfstools/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/pfstools/files/pfstools/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/physfs.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/physfs.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://icculus.org/physfs/downloads/?M=D' | \
+    $(WGET) -q -O- 'http://icculus.org/physfs/downloads/?M=D' | \
     $(SED) -n 's,.*<a href="physfs-\([0-9][^"]*\)\.tar.*,\1,pI' | \
     head -1
 endef
--- a/src/pixman.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pixman.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := pixman
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2785cedd25fb6ded0ceac8d427432f16b074dd52
+$(PKG)_CHECKSUM := 7cec4c9df3aacb3e53da45654f9a0943ef4c7c47
 $(PKG)_SUBDIR   := pixman-$($(PKG)_VERSION)
 $(PKG)_FILE     := pixman-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://cairographics.org/snapshots/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cairographics.org/snapshots/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://cairographics.org/snapshots/?C=M;O=D' | \
     $(SED) -n 's,.*"pixman-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/plibc.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,26 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := plibc
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := b545c602dc5b381fcea9d096910dede95168fbeb
+$(PKG)_SUBDIR   := PlibC-$($(PKG)_VERSION)
+$(PKG)_FILE     := plibc-$($(PKG)_VERSION)-src.tar.gz
+$(PKG)_URL      := http://sourceforge.net/projects/plibc/files/plibc/$($(PKG)_VERSION)/$($(PKG)_FILE)/download
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    echo 'TODO: Updates for package plibc  need to be fixed.' >&2;
+    echo $(plibc_VERSION)
+endef
+
+define $(PKG)_BUILD
+    chmod 0755 '$(1)/configure'
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --enable-static \
+        --disable-shared
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+endef
--- a/src/plotmm.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/plotmm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtkmm2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/plotmm/files/plotmm/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/plotmm/files/plotmm/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/plotutils.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/plotutils.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc libpng pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/plotutils/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/plotutils/?C=M;O=D' | \
     grep '<a href="plotutils-' | \
     $(SED) -n 's,.*plotutils-\([0-9][^<]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/poco.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/poco.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://pocoproject.org/download/' | \
+    $(WGET) -q -O- 'http://pocoproject.org/download/' | \
     $(SED) -n 's,.*poco-\([0-9][^>/]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -20,7 +20,7 @@
         --config=MinGW-CrossEnv \
         --static \
         --prefix='$(PREFIX)/$(TARGET)'
-    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install CROSSENV=$(TARGET)
 
     '$(TARGET)-g++' \
         -W -Wall -Werror -ansi -pedantic \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/poppler-1-win32.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,123 @@
+This file is part of MXE.
+See index.html for further information.
+
+From 0cdf3c0c6d2740fa3542d7030878eaffdd4cf7a4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 09:34:46 +0200
+Subject: [PATCH 1/2] Only check for Type1 fonts in custom directory if path
+ is non-NULL
+
+Otherwise, programs using poppler may crash
+Proposed upstream at https://bugs.freedesktop.org/show_bug.cgi?id=49037
+
+diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
+index 527f08e..0739946 100644
+--- a/poppler/GlobalParamsWin.cc
++++ b/poppler/GlobalParamsWin.cc
+@@ -424,7 +424,7 @@ void GlobalParams::setupBaseFonts(char * dir)
+         if (fontFiles->lookup(fontName))
+             continue;
+ 
+-        if (dir) {
++        if (dir && displayFontTab[i].t1FileName) {
+             GooString *fontPath = appendToPath(new GooString(dir), displayFontTab[i].t1FileName);
+             if (FileExists(fontPath->getCString()) ||
+                 FileExists(replaceSuffix(fontPath, ".pfb", ".pfa")->getCString())) {
+-- 
+1.7.10.4
+
+
+From fe1720718e224b0138f3f95c5aa0c72ac85e06b8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 13:19:54 +0200
+Subject: [PATCH 2/2] Don't use dllimport/dllexport
+
+Otherwise static linking fails
+MXE workaround for https://bugs.freedesktop.org/show_bug.cgi?id=49038 (presumably would break shared linking!)
+
+diff --git a/cpp/poppler-global.h b/cpp/poppler-global.h
+index 5650182..6c3e01b 100644
+--- a/cpp/poppler-global.h
++++ b/cpp/poppler-global.h
+@@ -20,13 +20,8 @@
+ #ifndef POPPLER_GLOBAL_H
+ #define POPPLER_GLOBAL_H
+ 
+-#if defined(_WIN32)
+-#  define LIB_EXPORT __declspec(dllexport)
+-#  define LIB_IMPORT __declspec(dllimport)
+-#else
+ #  define LIB_EXPORT
+ #  define LIB_IMPORT
+-#endif
+ 
+ #if defined(poppler_cpp_EXPORTS)
+ #  define POPPLER_CPP_EXPORT LIB_EXPORT
+diff --git a/poppler/XpdfPluginAPI.h b/poppler/XpdfPluginAPI.h
+index b0165c0..5a10595 100644
+--- a/poppler/XpdfPluginAPI.h
++++ b/poppler/XpdfPluginAPI.h
+@@ -42,19 +42,11 @@ extern "C" {
+  */
+ #define xpdfPluginAPIVersion 1
+ 
+-#ifdef _WIN32
+-#  ifdef __cplusplus
+-#    define PLUGINFUNC(retType) extern "C" __declspec(dllexport) retType
+-#  else
+-#    define PLUGINFUNC(retType) extern __declspec(dllexport) retType
+-#  endif
+-#else
+ #  ifdef __cplusplus
+ #    define PLUGINFUNC(retType) extern "C" retType
+ #  else
+ #    define PLUGINFUNC(retType) extern retType
+ #  endif
+-#endif
+ 
+ /*------------------------------------------------------------------------
+  * Plugin setup/cleanup
+@@ -281,22 +273,12 @@ void (*_xpdfRegisterSecurityHandler)(XpdfSecurityHandler *handler);
+ 
+ } XpdfPluginVecTable;
+ 
+-#ifdef _WIN32
+-
+-extern __declspec(dllexport) XpdfPluginVecTable xpdfPluginVecTable;
+-
+-#define xpdfPluginSetup \
+-  extern __declspec(dllexport) \
+-  XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
+-
+-#else
+ 
+ extern XpdfPluginVecTable xpdfPluginVecTable;
+ 
+ #define xpdfPluginSetup \
+   XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
+ 
+-#endif
+ 
+ #define xpdfGetInfoDict (*xpdfPluginVecTable._xpdfGetInfoDict)
+ #define xpdfGetCatalog (*xpdfPluginVecTable._xpdfGetCatalog)
+diff --git a/qt4/src/poppler-export.h b/qt4/src/poppler-export.h
+index 7661fe9..ebb1e18 100644
+--- a/qt4/src/poppler-export.h
++++ b/qt4/src/poppler-export.h
+@@ -2,13 +2,8 @@
+ * This file is used to set the poppler_qt4_EXPORT macros right.
+ * This is needed for setting the visibility on windows, it will have no effect on other platforms.
+ */
+-#if defined(_WIN32)
+-# define LIB_EXPORT __declspec(dllexport)
+-# define LIB_IMPORT __declspec(dllimport)
+-#else
+ # define LIB_EXPORT
+ # define LIB_IMPORT
+-#endif
+ 
+ #ifdef poppler_qt4_EXPORTS
+ # define POPPLER_QT4_EXPORT LIB_EXPORT
+-- 
+1.7.10.4
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/poppler-test.cxx	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,12 @@
+#include <iostream>
+#include <cpp/poppler-version.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    std::cout << "Poppler version: " << poppler::version_string() << std::endl;
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/poppler.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,60 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := poppler
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := fd808cfcd249b7079a09a97f99ffb08db8c62b93
+$(PKG)_SUBDIR   := poppler-$($(PKG)_VERSION)
+$(PKG)_FILE     := poppler-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://poppler.freedesktop.org/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc glib cairo libpng lcms jpeg tiff freetype zlib curl qt
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://poppler.freedesktop.org/' | \
+    $(SED) -n 's,.*"poppler-\([0-9.]\+\)\.tar\.gz".*,\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)' && ./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-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-libopenjpeg \
+        --disable-gtk-test \
+        --disable-utils \
+        --disable-gtk-doc \
+        --disable-gtk-doc-html \
+        --disable-gtk-doc-pdf \
+        --with-font-configuration=win32 \
+        PKG_CONFIG_PATH_$(subst -,_,$(TARGET))='$(PREFIX)/$(TARGET)/qt/lib/pkgconfig' \
+        LIBS="`'$(TARGET)-pkg-config' zlib liblzma --libs` -ljpeg"
+    $(MAKE) -C '$(1)' -j '$(JOBS)' 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
+
--- a/src/popt.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/popt.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc libiconv gettext
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://rpm5.org/files/popt/' | \
+    $(WGET) -q -O- 'http://rpm5.org/files/popt/' | \
     grep 'popt-' | \
     $(SED) -n 's,.*popt-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
--- a/src/portaudio-1-win32.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/portaudio-1-win32.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,89 +1,73 @@
 This file is part of MXE.
 See index.html for further information.
 
-diff -ru portaudio-orig/configure.in portaudio/configure.in
---- portaudio-orig/configure.in	2007-11-13 22:22:56.000000000 +0100
-+++ portaudio/configure.in	2010-01-23 17:04:37.000000000 +0100
-@@ -139,6 +139,7 @@
- 	dnl Mac OS X configuration
- 
- 	AC_DEFINE(PA_USE_COREAUDIO)
-+	CFLAGS="$CFLAGS -I\$(top_srcdir)/src/os/unix"
- 	if [[ -d /Developer/SDKs/MacOSX10.5.sdk ]] ; then
- 		SHARED_FLAGS="-Werror -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon -dynamiclib -arch x86_64 -arch ppc64 -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.3";
- 		CFLAGS="-Werror $CFLAGS -arch x86_64 -arch ppc64 -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.3";
-@@ -167,6 +168,7 @@
-         dnl MingW configuration
- 
-         echo "WINAPI: $with_winapi"
-+        CFLAGS="$CFLAGS -I\$(top_srcdir)/src/os/win"
-         if [[ $with_winapi = "directx" ]] ; then
-             if [[ $with_dxdir ]] ; then
-               DXDIR="$with_dxdir";
-@@ -174,15 +176,15 @@
-               DXDIR="/usr/local/dx7sdk";
-             fi
-             echo "DXDIR: $DXDIR"
--            OTHER_OBJS="src/hostapi/dsound/pa_win_ds.o src/hostapi/dsound/pa_win_ds_dynlink.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o";
-+            OTHER_OBJS="src/hostapi/dsound/pa_win_ds.o src/hostapi/dsound/pa_win_ds_dynlink.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o src/os/win/pa_win_waveformat.o";
-             LIBS="-lwinmm -lm -ldsound -lole32";
-             PADLL="portaudio.dll";
- 	    THREAD_CFLAGS="-mthreads"
-             SHARED_FLAGS="-shared";
--            DLL_LIBS="${DLL_LIBS} -lwinmm -lm -L./dx7sdk/lib -ldsound -lole32";
-+            DLL_LIBS="${DLL_LIBS} -lwinmm -lm -L${DXDIR}/lib -ldsound -lole32";
-             #VC98="\"/c/Program Files/Microsoft Visual Studio/VC98/Include\"";
-             #CFLAGS="$CFLAGS -I$VC98 -DPA_NO_WMME -DPA_NO_ASIO";
--            CFLAGS="$CFLAGS -I\$(top_srcdir)/include -I$DXDIR/include -DPA_NO_WMME -DPA_NO_ASIO" -DPA_NO_WDMKS;
-+            CFLAGS="$CFLAGS -I\$(top_srcdir)/include -I$DXDIR/include -DPA_NO_WMME -DPA_NO_ASIO -DPA_NO_WDMKS";
-         elif [[ $with_winapi = "asio" ]] ; then
-             if [[ $with_asiodir ]] ; then
-               ASIODIR="$with_asiodir";
-@@ -228,9 +230,10 @@
+diff -aur portaudio/src/hostapi/dsound/pa_win_ds.c portaudio-patched/src/hostapi/dsound/pa_win_ds.c
+--- portaudio/src/hostapi/dsound/pa_win_ds.c	2011-11-10 14:51:15.000000000 +0000
++++ portaudio-patched/src/hostapi/dsound/pa_win_ds.c	2012-03-02 21:45:29.000000000 +0000
+@@ -860,6 +860,9 @@
+                             case DSSPEAKER_STEREO:           count = 2; break;
+                             case DSSPEAKER_SURROUND:         count = 4; break;
+                             case DSSPEAKER_5POINT1:          count = 6; break;
++#ifndef DSSPEAKER_7POINT1
++#define DSSPEAKER_7POINT1 0x00000007
++#endif
+                             case DSSPEAKER_7POINT1:          count = 8; break;
+ #ifndef DSSPEAKER_7POINT1_SURROUND
+ #define DSSPEAKER_7POINT1_SURROUND 0x00000008
+diff -aur portaudio/src/hostapi/wdmks/pa_win_wdmks.c portaudio-patched/src/hostapi/wdmks/pa_win_wdmks.c
+--- portaudio/src/hostapi/wdmks/pa_win_wdmks.c	2011-02-17 15:56:04.000000000 +0000
++++ portaudio-patched/src/hostapi/wdmks/pa_win_wdmks.c	2012-03-02 21:49:13.000000000 +0000
+@@ -136,6 +136,7 @@
  
-   cygwin* )
- 	dnl Cygwin configuration
--
-+	CFLAGS="$CFLAGS -I\$(top_srcdir)/src/os/win"
- 	OTHER_OBJS="src/hostapi/wmme/pa_win_wmme.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o";
- 	CFLAGS="$CFLAGS -DPA_NO_DS -DPA_NO_WDMKS -DPA_NO_ASIO -DPA_NO_WASAPI"
-+
- 	LIBS="-lwinmm -lm";
- 	PADLL="portaudio.dll";
- 	THREAD_CFLAGS="-mthreads"
-@@ -242,6 +245,7 @@
- 	dnl SGI IRIX audio library (AL) configuration (Pieter, oct 2-13, 2003).
- 	dnl The 'dmedia' library is needed to read the Unadjusted System Time (UST).
-     dnl
-+	CFLAGS="$CFLAGS -I\$(top_srcdir)/src/os/unix"
- 	AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR([IRIX posix thread library not found!]))
- 	AC_CHECK_LIB(audio,   alOpenPort,     , AC_MSG_ERROR([IRIX audio library not found!]))
- 	AC_CHECK_LIB(dmedia,  dmGetUST,       , AC_MSG_ERROR([IRIX digital media library not found!]))
-@@ -271,6 +275,7 @@
-                 ,
-                 AC_MSG_ERROR([libpthread not found!]))
+ #include <mmreg.h>
+ #include <ks.h>
++#define _WAVEFORMATEXTENSIBLE_
+ #include <ksmedia.h>
+ #include <tchar.h>
+ #include <assert.h>
+--- portaudio/configure.in 14:07:02.000000000 +0000
++++ portaudio-patched/configure.in	2012-05-27 14:08:34.000000000 +0000
+@@ -247,7 +247,7 @@
+         if [[ "x$with_directx" = "xyes" ]]; then
+             DXDIR="$with_dxdir"
+             add_objects src/hostapi/dsound/pa_win_ds.o src/hostapi/dsound/pa_win_ds_dynlink.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o src/os/win/pa_win_coinitialize.o src/os/win/pa_win_waveformat.o
+-            LIBS="-lwinmm -lm -ldsound -lole32"
++            LIBS="$LIBS -lwinmm -lm -ldsound -lole32"
+             DLL_LIBS="${DLL_LIBS} -lwinmm -lm -L$DXDIR/lib -ldsound -lole32"
+             #VC98="\"/c/Program Files/Microsoft Visual Studio/VC98/Include\""
+             #CFLAGS="$CFLAGS -I$VC98 -DPA_NO_WMME -DPA_NO_ASIO"
+@@ -257,7 +257,7 @@
+         if [[ "x$with_asio" = "xyes" ]]; then
+             ASIODIR="$with_asiodir"
+             add_objects src/hostapi/asio/pa_asio.o src/common/pa_ringbuffer.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o src/os/win/pa_win_coinitialize.o src/hostapi/asio/iasiothiscallresolver.o $ASIODIR/common/asio.o $ASIODIR/host/asiodrivers.o $ASIODIR/host/pc/asiolist.o
+-            LIBS="-lwinmm -lm -lole32 -luuid"
++            LIBS="$LIBS -lwinmm -lm -lole32 -luuid"
+             DLL_LIBS="${DLL_LIBS} -lwinmm -lm -lole32 -luuid"
+             CFLAGS="$CFLAGS -ffast-math -fomit-frame-pointer -I\$(top_srcdir)/src/hostapi/asio -I$ASIODIR/host/pc -I$ASIODIR/common -I$ASIODIR/host -UPA_USE_ASIO -DPA_USE_ASIO=1 -DWINDOWS"
  
-+	CFLAGS="$CFLAGS -I\$(top_srcdir)/src/os/unix"
- 	if [[ $have_alsa = "yes" ] && [ $with_alsa != "no" ]] ; then
- 		DLL_LIBS="$DLL_LIBS -lasound"
- 		OTHER_OBJS="$OTHER_OBJS src/hostapi/alsa/pa_linux_alsa.o"
-@@ -305,6 +310,7 @@
-         OTHER_OBJS="$OTHER_OBJS src/os/unix/pa_unix_hostapis.o src/os/unix/pa_unix_util.o"
- esac
- CFLAGS="$CFLAGS $THREAD_CFLAGS"
-+echo "CFLAGS: $CFLAGS"
+@@ -273,7 +273,7 @@
+         if [[ "x$with_wdmks" = "xyes" ]]; then
+             DXDIR="$with_dxdir"
+             add_objects src/hostapi/wdmks/pa_win_wdmks.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o
+-            LIBS="-lwinmm -lm -luuid -lsetupapi -lole32"
++            LIBS="$LIBS -lwinmm -lm -luuid -lsetupapi -lole32"
+             DLL_LIBS="${DLL_LIBS} -lwinmm -lm -L$DXDIR/lib -luuid -lsetupapi -lole32"
+             #VC98="\"/c/Program Files/Microsoft Visual Studio/VC98/Include\""
+             #CFLAGS="$CFLAGS -I$VC98 -DPA_NO_WMME -DPA_NO_ASIO"
+@@ -282,14 +282,14 @@
  
- if test "$enable_cxx" = "yes"; then
-    AC_CONFIG_SUBDIRS([bindings/cpp])
-diff -ru portaudio-orig/Makefile.in portaudio/Makefile.in
---- portaudio-orig/Makefile.in	2007-10-24 17:29:04.000000000 +0200
-+++ portaudio/Makefile.in	2010-01-23 17:00:40.000000000 +0100
-@@ -16,7 +16,7 @@
- libdir = @libdir@
- includedir = @includedir@
- CC = @CC@
--CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/common -I$(top_srcdir)/src/os/unix @CFLAGS@ @DEFS@
-+CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/common @CFLAGS@ @DEFS@
- LIBS = @LIBS@
- AR = @AR@
- RANLIB = @RANLIB@
+         if [[ "x$with_wmme" = "xyes" ]]; then
+             add_objects src/hostapi/wmme/pa_win_wmme.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o src/os/win/pa_win_waveformat.o
+-            LIBS="-lwinmm -lm -lole32 -luuid"
++            LIBS="$LIBS -lwinmm -lm -lole32 -luuid"
+             DLL_LIBS="${DLL_LIBS} -lwinmm"
+             CFLAGS="$CFLAGS -UPA_USE_WMME -DPA_USE_WMME=1"
+         fi
+ 
+         if [[ "x$with_wasapi" = "xyes" ]]; then
+             add_objects src/hostapi/wasapi/pa_win_wasapi.o src/common/pa_ringbuffer.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o src/os/win/pa_win_coinitialize.o src/os/win/pa_win_waveformat.o
+-            LIBS="-lwinmm -lm -lole32 -luuid"
++            LIBS="$LIBS -lwinmm -lm -lole32 -luuid"
+             DLL_LIBS="${DLL_LIBS} -lwinmm -lole32"
+             CFLAGS="$CFLAGS -I\$(top_srcdir)/src/hostapi/wasapi/mingw-include -UPA_USE_WASAPI -DPA_USE_WASAPI=1"
+         fi
--- a/src/portaudio.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/portaudio.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,15 +3,15 @@
 
 PKG             := portaudio
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3841453bb7be672a15b6b632ade6f225eb0a4efc
+$(PKG)_CHECKSUM := f07716c470603729a55b70f5af68f4a6807097eb
 $(PKG)_SUBDIR   := portaudio
-$(PKG)_FILE     := pa_stable_v$($(PKG)_VERSION).tar.gz
+$(PKG)_FILE     := pa_stable_v$($(PKG)_VERSION).tgz
 $(PKG)_URL      := http://www.portaudio.com/archives/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.portaudio.com/download.html' | \
-    $(SED) -n 's,.*pa_stable_v\([0-9][^>]*\)\.tar.*,\1,p' | \
+    $(WGET) -q -O- 'http://www.portaudio.com/download.html' | \
+    $(SED) -n 's,.*pa_stable_v\([0-9][^>]*\)\.tgz,\1,p' | \
     head -1
 endef
 
@@ -22,8 +22,9 @@
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-host_os=mingw \
-        --with-winapi=directx \
-        --with-dxdir=$(PREFIX)/$(TARGET)
+        --with-winapi=wmme,directx,wasapi,wdmks \
+        --with-dxdir=$(PREFIX)/$(TARGET) \
+        ac_cv_path_AR=$(TARGET)-ar
     $(MAKE) -C '$(1)' -j '$(JOBS)' SHARED_FLAGS= TESTS=
     $(MAKE) -C '$(1)' -j 1 install
 
--- a/src/postgresql-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/postgresql-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -3,17 +3,17 @@
 
 Contains ad hoc patches for cross building.
 
-From 7985f049ed030c1f49927828a4b8e3d7552e52a4 Mon Sep 17 00:00:00 2001
-From: MXE
+From 97675e8569c5eb6a13a044b52cb31a120ff61d26 Mon Sep 17 00:00:00 2001
+From: "a@a.org" <a@a.org>
 Date: Mon, 24 Oct 2011 14:02:33 +0200
-Subject: [PATCH 1/2] use unix style names for openssl on MXE
+Subject: [PATCH 1/2] use unix style names for openssl on mingw-cross-env
 
 
 diff --git a/configure.in b/configure.in
-index 7c0e94e..2ee79c7 100644
+index 1024b0d..710ad0c 100644
 --- a/configure.in
 +++ b/configure.in
-@@ -943,13 +943,8 @@ fi
+@@ -926,13 +926,8 @@ fi
  
  if test "$with_openssl" = yes ; then
    dnl Order matters!
@@ -30,30 +30,30 @@
  
  if test "$with_pam" = yes ; then
 -- 
-1.7.9
+1.7.10.4
 
 
-From 9471812a4e7021fea291469d636bdeca6078c1e5 Mon Sep 17 00:00:00 2001
-From: MXE
+From cf2e7bb8d924354cba299ac26b8128b6fb234505 Mon Sep 17 00:00:00 2001
+From: "a@a.org" <a@a.org>
 Date: Mon, 24 Oct 2011 14:09:38 +0200
 Subject: [PATCH 2/2] do not check autoconf version
 
 
 diff --git a/configure.in b/configure.in
-index 2ee79c7..102b95b 100644
+index 710ad0c..8acc307 100644
 --- a/configure.in
 +++ b/configure.in
 @@ -19,10 +19,6 @@ m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
  
- AC_INIT([PostgreSQL], [9.1.3], [pgsql-bugs@postgresql.org])
+ AC_INIT([PostgreSQL], [9.2.1], [pgsql-bugs@postgresql.org])
  
 -m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.63], [], [m4_fatal([Autoconf version 2.63 is required.
 -Untested combinations of 'autoconf' and PostgreSQL versions are not
 -recommended.  You can remove the check from 'configure.in' but it is then
 -your responsibility whether the result works or not.])])
- AC_COPYRIGHT([Copyright (c) 1996-2011, PostgreSQL Global Development Group])
+ AC_COPYRIGHT([Copyright (c) 1996-2012, PostgreSQL Global Development Group])
  AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
  AC_CONFIG_AUX_DIR(config)
 -- 
-1.7.9
+1.7.10.4
 
--- a/src/postgresql.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/postgresql.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,18 +3,18 @@
 
 PKG             := postgresql
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 1cf3044415df807c08bb8ad8e40e24e8d375cf34
+$(PKG)_CHECKSUM := cea9601b3acd1484fd98441b49a15ea1c42057ec
 $(PKG)_SUBDIR   := postgresql-$($(PKG)_VERSION)
 $(PKG)_FILE     := postgresql-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://ftp.postgresql.org/pub/source/v$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib openssl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.postgresql.org/gitweb?p=postgresql.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.postgresql.org/gitweb?p=postgresql.git;a=tags' | \
     grep 'refs/tags/REL9[0-9_]*"' | \
     $(SED) 's,.*refs/tags/REL\(.*\)".*,\1,g;' | \
     $(SED) 's,_,.,g' | \
-    grep -v '^9\.\0' | \
+    grep -v '^9\.[01]' | \
     head -1
 endef
 
@@ -25,6 +25,7 @@
     cd '$(1)' && ./configure \
         --prefix='$(PREFIX)/$(TARGET)' \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --disable-rpath \
         --without-tcl \
--- a/src/proj.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/proj.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://trac.osgeo.org/proj/' | \
+    $(WGET) -q -O- 'http://trac.osgeo.org/proj/' | \
     $(SED) -n 's,.*proj-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/protobuf-test.cpp	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,9 @@
+#include <google/protobuf/stubs/common.h>
+
+int
+main()
+{
+    GOOGLE_PROTOBUF_VERIFY_VERSION;
+    google::protobuf::ShutdownProtobufLibrary();
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/protobuf.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,39 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := protobuf
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := df5867e37a4b51fb69f53a8baf5b994938691d6d
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_URL      := http://protobuf.googlecode.com/files/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc zlib
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://code.google.com/p/protobuf/downloads/list?sort=-uploaded' | \
+    $(SED) -n 's,.*protobuf-\([0-9][^<]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+# First step: Build for host system in order to create "protoc" binary.
+    cd '$(1)' && ./configure \
+        --disable-shared
+    $(MAKE) -C '$(1)' -j '$(JOBS)'
+    cp '$(1)/src/protoc' '$(1)/src/protoc_host'
+    $(MAKE) -C '$(1)' -j 1 distclean
+# Second step: Build for target system.
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --disable-shared \
+        --with-zlib \
+        --with-protoc=src/protoc_host
+    $(MAKE) -C '$(1)' -j '$(JOBS)'
+    $(MAKE) -C '$(1)' -j 1 install
+
+    '$(TARGET)-g++' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).cpp' -o '$(PREFIX)/$(TARGET)/bin/test-protobuf.exe' \
+        `'$(TARGET)-pkg-config' protobuf --cflags --libs`
+endef
--- a/src/pthreads-1-autostatic.patch	Mon Oct 08 22:34:18 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://sourceware.org/ml/pthreads-win32/2010/msg00006.html
-
-diff -ur pthreads-win32-20091019.orig/GNUmakefile pthreads-win32-20091019/GNUmakefile
---- pthreads-win32-20091019.orig/GNUmakefile	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/GNUmakefile	2010-02-01 14:45:28.471432337 -0200
-@@ -63,7 +63,6 @@
- XOPT	=
- 
- RCFLAGS		= --include-dir=.
--LFLAGS		= -lwsock32
- 
- # ----------------------------------------------------------------------
- # The library can be built with some alternative behaviour to
-diff -ur pthreads-win32-20091019.orig/pthread.c pthreads-win32-20091019/pthread.c
---- pthreads-win32-20091019.orig/pthread.c	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/pthread.c	2010-02-01 14:26:48.601487556 -0200
-@@ -49,6 +49,7 @@
- #include "condvar.c"
- #include "create.c"
- #include "dll.c"
-+#include "autostatic.c"
- #include "errno.c"
- #include "exit.c"
- #include "fork.c"
-diff -ur pthreads-win32-20091019.orig/pthread_getspecific.c pthreads-win32-20091019/pthread_getspecific.c
---- pthreads-win32-20091019.orig/pthread_getspecific.c	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/pthread_getspecific.c	2010-02-01 14:28:36.603981857 -0200
-@@ -72,12 +72,10 @@
-   else
-     {
-       int lasterror = GetLastError ();
--      int lastWSAerror = WSAGetLastError ();
- 
-       ptr = TlsGetValue (key->key);
- 
-       SetLastError (lasterror);
--      WSASetLastError (lastWSAerror);
-     }
- 
-   return ptr;
-diff -ur pthreads-win32-20091019.orig/pthread.h pthreads-win32-20091019/pthread.h
---- pthreads-win32-20091019.orig/pthread.h	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/pthread.h	2010-02-02 16:51:05.047931915 -0200
-@@ -533,7 +533,7 @@
-  * do NOT define PTW32_BUILD, and then the variables/functions will
-  * be imported correctly.
-  */
--#ifndef PTW32_STATIC_LIB
-+#if !defined(PTW32_STATIC_LIB) && !defined(__MINGW32__)
- #  ifdef PTW32_BUILD
- #    define PTW32_DLLPORT __declspec (dllexport)
- #  else
-diff -ur pthreads-win32-20091019.orig/sched.h pthreads-win32-20091019/sched.h
---- pthreads-win32-20091019.orig/sched.h	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/sched.h	2010-02-02 16:51:00.665887720 -0200
-@@ -76,7 +76,7 @@
-  * do NOT define PTW32_BUILD, and then the variables/functions will
-  * be imported correctly.
-  */
--#ifndef PTW32_STATIC_LIB
-+#if !defined(PTW32_STATIC_LIB) && !defined(__MINGW32__)
- #  ifdef PTW32_BUILD
- #    define PTW32_DLLPORT __declspec (dllexport)
- #  else
-diff -ur pthreads-win32-20091019.orig/semaphore.h pthreads-win32-20091019/semaphore.h
---- pthreads-win32-20091019.orig/semaphore.h	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/semaphore.h	2010-02-02 16:50:45.916576916 -0200
-@@ -75,7 +75,7 @@
-  * do NOT define PTW32_BUILD, and then the variables/functions will
-  * be imported correctly.
-  */
--#ifndef PTW32_STATIC_LIB
-+#if !defined(PTW32_STATIC_LIB) && !defined(__MINGW32__)
- #  ifdef PTW32_BUILD
- #    define PTW32_DLLPORT __declspec (dllexport)
- #  else
---- /dev/null	2010-01-29 12:57:37.677072272 -0200
-+++ pthreads-win32-20091019/autostatic.c	2010-02-01 14:26:48.601487556 -0200
-@@ -0,0 +1,67 @@
-+/*
-+ * autostatic.c
-+ *
-+ * Description:
-+ * This translation unit implements static library initialisation.
-+ *
-+ * --------------------------------------------------------------------------
-+ *
-+ *      Pthreads-win32 - POSIX Threads Library for Win32
-+ *      Copyright(C) 1998 John E. Bossom
-+ *      Copyright(C) 1999,2005 Pthreads-win32 contributors
-+ * 
-+ *      Contact Email: rpj@callisto.canberra.edu.au
-+ * 
-+ *      The current list of contributors is contained
-+ *      in the file CONTRIBUTORS included with the source
-+ *      code distribution. The list can also be seen at the
-+ *      following World Wide Web location:
-+ *      http://sources.redhat.com/pthreads-win32/contributors.html
-+ * 
-+ *      This library is free software; you can redistribute it and/or
-+ *      modify it under the terms of the GNU Lesser General Public
-+ *      License as published by the Free Software Foundation; either
-+ *      version 2 of the License, or (at your option) any later version.
-+ * 
-+ *      This library is distributed in the hope that it will be useful,
-+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *      Lesser General Public License for more details.
-+ * 
-+ *      You should have received a copy of the GNU Lesser General Public
-+ *      License along with this library in the file COPYING.LIB;
-+ *      if not, write to the Free Software Foundation, Inc.,
-+ *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
-+ */
-+
-+#ifdef PTW32_STATIC_LIB
-+
-+#include "pthread.h"
-+#include "implement.h"
-+
-+static void on_process_init(void)
-+{
-+    pthread_win32_process_attach_np ();
-+}
-+
-+static void on_process_exit(void)
-+{
-+    pthread_win32_thread_detach_np  ();
-+    pthread_win32_process_detach_np ();
-+}
-+
-+#ifdef __MINGW32__
-+#    define attribute_section(a) __attribute__((section(a)))
-+#elif defined(_MSC_VER)
-+#    define attribute_section(a) __pragma(section(a,long,read)); __declspec(allocate(a))
-+#else
-+#error compiler not supported!
-+#endif
-+
-+attribute_section(".CRT$XCU") void *msc_ctor = on_process_init;
-+attribute_section(".CRT$XPU") void *msc_dtor = on_process_exit;
-+
-+attribute_section(".ctors"  ) void *gcc_ctor = on_process_init;
-+attribute_section(".dtors"  ) void *gcc_dtor = on_process_exit;
-+
-+#endif /* PTW32_STATIC_LIB */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pthreads-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,62 @@
+This file is part of MXE.
+See index.html for further information.
+
+From e951f784c852f4cd8298864190936fded1efceba Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 27 May 2012 22:00:19 +0200
+Subject: [PATCH] force static for convenience
+
+---
+ pthread.h   |    4 ++++
+ sched.h     |    4 ++++
+ semaphore.h |    4 ++++
+ 3 files changed, 12 insertions(+)
+
+diff --git a/pthread.h b/pthread.h
+index b4072f7..c88c886 100755
+--- a/pthread.h
++++ b/pthread.h
+@@ -547,6 +547,10 @@ extern "C"
+  * do NOT define PTW32_BUILD, and then the variables/functions will
+  * be imported correctly.
+  */
++
++// MXE: Set this for convenience here since MXE only does static.
++#define PTW32_STATIC_LIB
++
+ #if !defined(PTW32_STATIC_LIB)
+ #  if defined(PTW32_BUILD)
+ #    define PTW32_DLLPORT __declspec (dllexport)
+diff --git a/sched.h b/sched.h
+index f36a97a..1f4f401 100755
+--- a/sched.h
++++ b/sched.h
+@@ -76,6 +76,10 @@
+  * do NOT define PTW32_BUILD, and then the variables/functions will
+  * be imported correctly.
+  */
++
++// MXE: Set this for convenience here since MXE only does static.
++#define PTW32_STATIC_LIB
++
+ #if !defined(PTW32_STATIC_LIB)
+ #  if defined(PTW32_BUILD)
+ #    define PTW32_DLLPORT __declspec (dllexport)
+diff --git a/semaphore.h b/semaphore.h
+index c6e9407..2b64173 100755
+--- a/semaphore.h
++++ b/semaphore.h
+@@ -75,6 +75,10 @@
+  * do NOT define PTW32_BUILD, and then the variables/functions will
+  * be imported correctly.
+  */
++
++// MXE: Set this for convenience here since MXE only does static.
++#define PTW32_STATIC_LIB
++
+ #if !defined(PTW32_STATIC_LIB)
+ #  if defined(PTW32_BUILD)
+ #    define PTW32_DLLPORT __declspec (dllexport)
+-- 
+1.7.9.2
+
--- a/src/pthreads.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/pthreads.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,24 +3,20 @@
 
 PKG             := pthreads
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := da8371cb20e8e238f96a1d0651212f154d84a9ac
+$(PKG)_CHECKSUM := 24d40e89c2e66a765733e8c98d6f94500343da86
 $(PKG)_SUBDIR   := pthreads-w32-$($(PKG)_VERSION)-release
 $(PKG)_FILE     := pthreads-w32-$($(PKG)_VERSION)-release.tar.gz
 $(PKG)_URL      := ftp://sourceware.org/pub/pthreads-win32/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'ftp://sourceware.org/pub/pthreads-win32/Release_notes' | \
+    $(WGET) -q -O- 'ftp://sourceware.org/pub/pthreads-win32/Release_notes' | \
     $(SED) -n 's,^RELEASE \([0-9][^[:space:]]*\).*,\1,p' | \
     tr '.' '-' | \
     head -1
 endef
 
 define $(PKG)_BUILD
-    $(SED) -i '35i\#define PTW32_STATIC_LIB' '$(1)/pthread.h'
-    $(SED) -i '41i\#define PTW32_STATIC_LIB' '$(1)/sched.h'
-    $(SED) -i '41i\#define PTW32_STATIC_LIB' '$(1)/semaphore.h'
-    $(SED) -i 's,#include "config.h",,'      '$(1)/pthread.h'
     $(MAKE) -C '$(1)' -j 1 GC-static CROSS='$(TARGET)-'
     $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib'
     $(INSTALL) -m644 '$(1)/libpthreadGC2.a' '$(PREFIX)/$(TARGET)/lib/libpthread.a'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qdbm-test.c	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,51 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ *
+ * Taken from examples at http://fallabs.com/qdbm/spex.html
+ */
+
+#include <depot.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define NAME     "mikio"
+#define NUMBER   "000-1234-5678"
+#define DBNAME   "book"
+
+int main(int argc, char **argv){
+    DEPOT *depot;
+    char *val;
+
+    (void)argc;
+    (void)argv;
+
+    /* open the database */
+    if(!(depot = dpopen(DBNAME, DP_OWRITER | DP_OCREAT, -1))){
+        fprintf(stderr, "dpopen: %s\n", dperrmsg(dpecode));
+        return 1;
+    }
+
+    /* store the record */
+    if(!dpput(depot, NAME, -1, NUMBER, -1, DP_DOVER)){
+        fprintf(stderr, "dpput: %s\n", dperrmsg(dpecode));
+    }
+
+    /* retrieve the record */
+    if(!(val = dpget(depot, NAME, -1, 0, -1, NULL))){
+        fprintf(stderr, "dpget: %s\n", dperrmsg(dpecode));
+    }
+    else {
+        printf("Name: %s\n", NAME);
+        printf("Number: %s\n", val);
+        free(val);
+    }
+
+    /* close the database */
+    if(!dpclose(depot)){
+        fprintf(stderr, "dpclose: %s\n", dperrmsg(dpecode));
+        return 1;
+    }
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qdbm.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,44 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := qdbm
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 8c2ab938c2dad8067c29b0aa93efc6389f0e7076
+$(PKG)_SUBDIR   := qdbm-$($(PKG)_VERSION)
+$(PKG)_FILE     := qdbm-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://fallabs.com/qdbm/qdbm-1.8.78.tar.gz
+$(PKG)_DEPS     := gcc bzip2 libiconv lzo zlib
+
+define $(PKG)_UPDATE
+    wget -q -O- 'http://fallabs.com/qdbm/' | \
+    grep 'qdbm-' | \
+    $(SED) -n 's,.*qdbm-\([0-9][^>]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --enable-lzo \
+        --enable-bzip \
+        --enable-zlib \
+        --enable-iconv
+    $(MAKE) -C '$(1)' -j '$(JOBS)' \
+        static \
+        MYBINS= \
+        MYLIBS=libqdbm.a \
+        AR=i686-pc-mingw32-ar \
+        RANLIB=i686-pc-mingw32-ranlib
+    $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
+    $(INSTALL) -m644 '$(1)/libqdbm.a' '$(PREFIX)/$(TARGET)/lib/'
+    $(INSTALL) -m644 '$(1)/qdbm.pc'   '$(PREFIX)/$(TARGET)/lib/pkgconfig/'
+    $(INSTALL) -d '$(PREFIX)/$(TARGET)/include'
+    cd '$(1)' && $(INSTALL) -m644 depot.h curia.h relic.h hovel.h \
+        cabin.h villa.h vista.h odeum.h '$(PREFIX)/$(TARGET)/include/'
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-qdbm.exe' \
+        `'$(TARGET)-pkg-config' qdbm --cflags --libs`
+endef
--- a/src/qjson.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/qjson.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc qt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/qjson/files/qjson/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/qjson/files/qjson/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
@@ -20,7 +20,6 @@
     mkdir '$(1)/build'
     cd '$(1)/build' && cmake .. \
         -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
-        -DCMAKE_BUILD_TYPE=Release \
         -DLIBTYPE=STATIC
 
     $(MAKE) -C '$(1)/build' -j '$(JOBS)' install
--- a/src/qt-1-cherrypicks.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/qt-1-cherrypicks.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -5,21 +5,18 @@
 http://qt.gitorious.org/qt
 Also contains MXE specific fixes.
 
-From 16a4f14e8e879a14ae5db47d0731c9199c01a816 Mon Sep 17 00:00:00 2001
+From 2a376d8ff643ec0d40fdba68a25c3a323dbd5be4 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Fri, 13 Jan 2012 00:17:48 +0100
-Subject: [PATCH 01/18] remove trailing whitespace
+Subject: [PATCH 01/24] remove trailing whitespace
 
 backported from qt5/qtbase
 Change-Id: If53a0bd1794e69b4856f993c6e2959369bd007d6
 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
 (cherry picked from commit 0f7a413683ab4358c4ded8bdffb7381459d98068)
----
- src/corelib/codecs/codecs.pri |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 6bc2fa6..9b7967d 100644
+index 9090773..859ec8d 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -42,7 +42,7 @@ unix {
@@ -35,10 +32,10 @@
 1.7.10.4
 
 
-From 162708efc51e40ed59d4e3397d399920c21d03a6 Mon Sep 17 00:00:00 2001
+From f9650fb05bde43a8d710469daa363383e3947e3a Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 30 Jun 2011 10:22:33 +0200
-Subject: [PATCH 02/18] do not detect or configure iconv for Windows
+Subject: [PATCH 02/24] do not detect or configure iconv for Windows
 
 Qt doesn't use iconv on Windows, but configuring it will appear to
 work and the build will complete. The result is that character
@@ -51,15 +48,12 @@
 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
 (cherry picked from commit 9fa2b641ba6ff4f4b3f474b87ddb642cfa5c3d83)
----
- configure |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/configure b/configure
-index a706908..0690822 100755
+index d19f443..520ffc3 100755
 --- a/configure
 +++ b/configure
-@@ -5600,7 +5600,7 @@ fi
+@@ -5682,7 +5682,7 @@ fi
  
  # auto-detect iconv(3) support
  if [ "$CFG_ICONV" != "no" ]; then
@@ -72,21 +66,18 @@
 1.7.10.4
 
 
-From dd34e052a555203b2bfb415bd0ce348ef232aa7e Mon Sep 17 00:00:00 2001
+From 04a44c0d6b3272c6edb08d34cecf36825843c2a0 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Wed, 18 Jan 2012 11:43:10 +0100
-Subject: [PATCH 03/18] fix whitespace
+Subject: [PATCH 03/24] fix whitespace
 
 backported from qt5/qtbase
 Change-Id: I0cfccae085c000d4368386a34f288c1e6f01a88f
 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
 (cherry picked from commit 10f6c5981cd2373c73873f8bace0b2df42a01db8)
----
- src/corelib/codecs/codecs.pri |   33 ++++++++++++++++-----------------
- 1 file changed, 16 insertions(+), 17 deletions(-)
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 9b7967d..836cc34 100644
+index 859ec8d..70cd890 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -1,23 +1,23 @@
@@ -149,10 +140,10 @@
 1.7.10.4
 
 
-From 7f2e5f5e4bc740446f0160ae3246907fa4f6dc2f Mon Sep 17 00:00:00 2001
+From 043a2cdc024dd19685a1cd3694faa0cdbade5a82 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Mon, 4 Jul 2011 00:42:24 +0200
-Subject: [PATCH 04/18] build and load text codecs regardless of iconv and
+Subject: [PATCH 04/24] build and load text codecs regardless of iconv and
  platform
 
 Otherwise applications linking to static Qt may have to import
@@ -168,13 +159,9 @@
 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
 (cherry picked from commit 7ee3d8c8ecb78dd7c5ae09b04ebf1420958f0001)
----
- src/corelib/codecs/codecs.pri     |   38 ++++++++++++++++++-------------------
- src/corelib/codecs/qtextcodec.cpp |   14 +++++---------
- 2 files changed, 24 insertions(+), 28 deletions(-)
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 836cc34..8ff9070 100644
+index 70cd890..c847264 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -10,6 +10,15 @@ HEADERS += \
@@ -237,10 +224,10 @@
  }
  symbian:LIBS += -lcharconv
 diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
-index 74e5e90..2b3100a 100644
+index 08d954c..f267acb 100644
 --- a/src/corelib/codecs/qtextcodec.cpp
 +++ b/src/corelib/codecs/qtextcodec.cpp
-@@ -65,15 +65,14 @@
+@@ -66,15 +66,14 @@
  #  include "qtsciicodec_p.h"
  #  include "qisciicodec_p.h"
  #if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
@@ -258,7 +245,7 @@
  #  if defined(Q_WS_X11) && !defined(QT_BOOTSTRAPPED)
  #    include "qfontlaocodec_p.h"
  #    include "../../plugins/codecs/jp/qfontjpcodec.h"
-@@ -759,8 +758,6 @@ static void setup()
+@@ -751,8 +750,6 @@ static void setup()
  #  if defined(Q_WS_X11) && !defined(QT_BOOTSTRAPPED)
      // no font codecs when bootstrapping
      (void)new QFontLaoCodec;
@@ -267,7 +254,7 @@
      (void)new QFontGb2312Codec;
      (void)new QFontGbkCodec;
      (void)new QFontGb18030_0Codec;
-@@ -769,12 +766,11 @@ static void setup()
+@@ -761,12 +758,11 @@ static void setup()
      (void)new QFontKsc5601Codec;
      (void)new QFontBig5hkscsCodec;
      (void)new QFontBig5Codec;
@@ -282,7 +269,7 @@
      // no asian codecs when bootstrapping, sorry
      (void)new QGb18030Codec;
      (void)new QGbkCodec;
-@@ -786,7 +782,7 @@ static void setup()
+@@ -778,7 +774,7 @@ static void setup()
      (void)new QCP949Codec;
      (void)new QBig5Codec;
      (void)new QBig5hkscsCodec;
@@ -295,10 +282,10 @@
 1.7.10.4
 
 
-From 00db0d7b9b99b18fd08463f86102f1b63eb3a527 Mon Sep 17 00:00:00 2001
+From c9e946e08850c2ea92c818bcef9b4f0ec47fb86f Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Fri, 13 Jan 2012 00:24:13 +0100
-Subject: [PATCH 05/18] move plugin text codecs to QtCore
+Subject: [PATCH 05/24] move plugin text codecs to QtCore
 
 Having plugin text codecs adds considerable complexity to
 configuring Qt. The plugin interface is designed for optional
@@ -323,100 +310,9 @@
 Conflicts:
 
 	src/plugins/plugins.pro
----
- src/corelib/codecs/codecs.pri           |   32 +-
- src/corelib/codecs/cp949codetbl_p.h     |  637 ++
- src/corelib/codecs/qbig5codec.cpp       |12788 +++++++++++++++++++++++++++++++
- src/corelib/codecs/qbig5codec_p.h       |  124 +
- src/corelib/codecs/qeucjpcodec.cpp      |  261 +
- src/corelib/codecs/qeucjpcodec_p.h      |  106 +
- src/corelib/codecs/qeuckrcodec.cpp      | 3571 +++++++++
- src/corelib/codecs/qeuckrcodec_p.h      |  129 +
- src/corelib/codecs/qfontjpcodec.cpp     |  145 +
- src/corelib/codecs/qfontjpcodec_p.h     |   93 +
- src/corelib/codecs/qgb18030codec.cpp    | 9265 ++++++++++++++++++++++
- src/corelib/codecs/qgb18030codec_p.h    |  159 +
- src/corelib/codecs/qjiscodec.cpp        |  367 +
- src/corelib/codecs/qjiscodec_p.h        |  106 +
- src/corelib/codecs/qjpunicode.cpp       |10700 ++++++++++++++++++++++++++
- src/corelib/codecs/qjpunicode_p.h       |  174 +
- src/corelib/codecs/qsjiscodec.cpp       |  229 +
- src/corelib/codecs/qsjiscodec_p.h       |  106 +
- src/corelib/codecs/qtextcodec.cpp       |   14 +-
- src/plugins/codecs/cn/cn.pro            |   16 -
- src/plugins/codecs/cn/main.cpp          |  145 -
- src/plugins/codecs/cn/qgb18030codec.cpp | 9265 ----------------------
- src/plugins/codecs/cn/qgb18030codec.h   |  159 -
- src/plugins/codecs/codecs.pro           |    4 -
- src/plugins/codecs/jp/jp.pro            |   27 -
- src/plugins/codecs/jp/main.cpp          |  149 -
- src/plugins/codecs/jp/qeucjpcodec.cpp   |  261 -
- src/plugins/codecs/jp/qeucjpcodec.h     |  106 -
- src/plugins/codecs/jp/qfontjpcodec.cpp  |  145 -
- src/plugins/codecs/jp/qfontjpcodec.h    |   93 -
- src/plugins/codecs/jp/qjiscodec.cpp     |  367 -
- src/plugins/codecs/jp/qjiscodec.h       |  106 -
- src/plugins/codecs/jp/qjpunicode.cpp    |10700 --------------------------
- src/plugins/codecs/jp/qjpunicode.h      |  174 -
- src/plugins/codecs/jp/qsjiscodec.cpp    |  229 -
- src/plugins/codecs/jp/qsjiscodec.h      |  106 -
- src/plugins/codecs/kr/cp949codetbl.h    |  637 --
- src/plugins/codecs/kr/kr.pro            |   20 -
- src/plugins/codecs/kr/main.cpp          |  131 -
- src/plugins/codecs/kr/qeuckrcodec.cpp   | 3571 ---------
- src/plugins/codecs/kr/qeuckrcodec.h     |  129 -
- src/plugins/codecs/tw/main.cpp          |  138 -
- src/plugins/codecs/tw/qbig5codec.cpp    |12788 -------------------------------
- src/plugins/codecs/tw/qbig5codec.h      |  124 -
- src/plugins/codecs/tw/tw.pro            |   16 -
- src/plugins/plugins.pro                 |    5 -
- 46 files changed, 38984 insertions(+), 39633 deletions(-)
- create mode 100644 src/corelib/codecs/cp949codetbl_p.h
- create mode 100644 src/corelib/codecs/qbig5codec.cpp
- create mode 100644 src/corelib/codecs/qbig5codec_p.h
- create mode 100644 src/corelib/codecs/qeucjpcodec.cpp
- create mode 100644 src/corelib/codecs/qeucjpcodec_p.h
- create mode 100644 src/corelib/codecs/qeuckrcodec.cpp
- create mode 100644 src/corelib/codecs/qeuckrcodec_p.h
- create mode 100644 src/corelib/codecs/qfontjpcodec.cpp
- create mode 100644 src/corelib/codecs/qfontjpcodec_p.h
- create mode 100644 src/corelib/codecs/qgb18030codec.cpp
- create mode 100644 src/corelib/codecs/qgb18030codec_p.h
- create mode 100644 src/corelib/codecs/qjiscodec.cpp
- create mode 100644 src/corelib/codecs/qjiscodec_p.h
- create mode 100644 src/corelib/codecs/qjpunicode.cpp
- create mode 100644 src/corelib/codecs/qjpunicode_p.h
- create mode 100644 src/corelib/codecs/qsjiscodec.cpp
- create mode 100644 src/corelib/codecs/qsjiscodec_p.h
- delete mode 100644 src/plugins/codecs/cn/cn.pro
- delete mode 100644 src/plugins/codecs/cn/main.cpp
- delete mode 100644 src/plugins/codecs/cn/qgb18030codec.cpp
- delete mode 100644 src/plugins/codecs/cn/qgb18030codec.h
- delete mode 100644 src/plugins/codecs/codecs.pro
- delete mode 100644 src/plugins/codecs/jp/jp.pro
- delete mode 100644 src/plugins/codecs/jp/main.cpp
- delete mode 100644 src/plugins/codecs/jp/qeucjpcodec.cpp
- delete mode 100644 src/plugins/codecs/jp/qeucjpcodec.h
- delete mode 100644 src/plugins/codecs/jp/qfontjpcodec.cpp
- delete mode 100644 src/plugins/codecs/jp/qfontjpcodec.h
- delete mode 100644 src/plugins/codecs/jp/qjiscodec.cpp
- delete mode 100644 src/plugins/codecs/jp/qjiscodec.h
- delete mode 100644 src/plugins/codecs/jp/qjpunicode.cpp
- delete mode 100644 src/plugins/codecs/jp/qjpunicode.h
- delete mode 100644 src/plugins/codecs/jp/qsjiscodec.cpp
- delete mode 100644 src/plugins/codecs/jp/qsjiscodec.h
- delete mode 100644 src/plugins/codecs/kr/cp949codetbl.h
- delete mode 100644 src/plugins/codecs/kr/kr.pro
- delete mode 100644 src/plugins/codecs/kr/main.cpp
- delete mode 100644 src/plugins/codecs/kr/qeuckrcodec.cpp
- delete mode 100644 src/plugins/codecs/kr/qeuckrcodec.h
- delete mode 100644 src/plugins/codecs/tw/main.cpp
- delete mode 100644 src/plugins/codecs/tw/qbig5codec.cpp
- delete mode 100644 src/plugins/codecs/tw/qbig5codec.h
- delete mode 100644 src/plugins/codecs/tw/tw.pro
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 8ff9070..02f30f5 100644
+index c847264..a1271b9 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -11,13 +11,14 @@ HEADERS += \
@@ -467,15 +363,14 @@
  	SOURCES += codecs/qfontlaocodec.cpp
 diff --git a/src/corelib/codecs/cp949codetbl_p.h b/src/corelib/codecs/cp949codetbl_p.h
 new file mode 100644
-index 0000000..25723c7
+index 0000000..8bf9204
 --- /dev/null
 +++ b/src/corelib/codecs/cp949codetbl_p.h
 @@ -0,0 +1,637 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -508,6 +403,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -1110,15 +1006,14 @@
 +#endif // CP494CODETBL_H
 diff --git a/src/corelib/codecs/qbig5codec.cpp b/src/corelib/codecs/qbig5codec.cpp
 new file mode 100644
-index 0000000..e30861d
+index 0000000..662aee8
 --- /dev/null
 +++ b/src/corelib/codecs/qbig5codec.cpp
 @@ -0,0 +1,12788 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -1151,6 +1046,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -13904,15 +13800,14 @@
 +QT_END_NAMESPACE
 diff --git a/src/corelib/codecs/qbig5codec_p.h b/src/corelib/codecs/qbig5codec_p.h
 new file mode 100644
-index 0000000..f43b733
+index 0000000..eec1798
 --- /dev/null
 +++ b/src/corelib/codecs/qbig5codec_p.h
 @@ -0,0 +1,124 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -13945,6 +13840,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -14034,15 +13930,14 @@
 +#endif // QBIG5CODEC_H
 diff --git a/src/corelib/codecs/qeucjpcodec.cpp b/src/corelib/codecs/qeucjpcodec.cpp
 new file mode 100644
-index 0000000..4ff5552
+index 0000000..69e314c
 --- /dev/null
 +++ b/src/corelib/codecs/qeucjpcodec.cpp
 @@ -0,0 +1,261 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -14075,6 +13970,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -14301,15 +14197,14 @@
 +QT_END_NAMESPACE
 diff --git a/src/corelib/codecs/qeucjpcodec_p.h b/src/corelib/codecs/qeucjpcodec_p.h
 new file mode 100644
-index 0000000..af02ed9
+index 0000000..d693e04
 --- /dev/null
 +++ b/src/corelib/codecs/qeucjpcodec_p.h
 @@ -0,0 +1,106 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -14342,6 +14237,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -14413,15 +14309,14 @@
 +#endif // QEUCJPCODEC_H
 diff --git a/src/corelib/codecs/qeuckrcodec.cpp b/src/corelib/codecs/qeuckrcodec.cpp
 new file mode 100644
-index 0000000..cc8fca8
+index 0000000..bef4132
 --- /dev/null
 +++ b/src/corelib/codecs/qeuckrcodec.cpp
 @@ -0,0 +1,3571 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -14454,6 +14349,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -17990,15 +17886,14 @@
 +QT_END_NAMESPACE
 diff --git a/src/corelib/codecs/qeuckrcodec_p.h b/src/corelib/codecs/qeuckrcodec_p.h
 new file mode 100644
-index 0000000..9408622
+index 0000000..55a1337
 --- /dev/null
 +++ b/src/corelib/codecs/qeuckrcodec_p.h
 @@ -0,0 +1,129 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -18031,6 +17926,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -18125,15 +18021,14 @@
 +#endif // QEUCKRCODEC_H
 diff --git a/src/corelib/codecs/qfontjpcodec.cpp b/src/corelib/codecs/qfontjpcodec.cpp
 new file mode 100644
-index 0000000..85eae20
+index 0000000..2ac3d6c
 --- /dev/null
 +++ b/src/corelib/codecs/qfontjpcodec.cpp
 @@ -0,0 +1,145 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -18166,6 +18061,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -18276,15 +18172,14 @@
 +QT_END_NAMESPACE
 diff --git a/src/corelib/codecs/qfontjpcodec_p.h b/src/corelib/codecs/qfontjpcodec_p.h
 new file mode 100644
-index 0000000..6b2a6ee
+index 0000000..dfb06bb
 --- /dev/null
 +++ b/src/corelib/codecs/qfontjpcodec_p.h
 @@ -0,0 +1,93 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -18317,6 +18212,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -18375,15 +18271,14 @@
 +#endif // QFONTJPCODEC_H
 diff --git a/src/corelib/codecs/qgb18030codec.cpp b/src/corelib/codecs/qgb18030codec.cpp
 new file mode 100644
-index 0000000..760fcc0
+index 0000000..928bc52
 --- /dev/null
 +++ b/src/corelib/codecs/qgb18030codec.cpp
 @@ -0,0 +1,9265 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -18416,6 +18311,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -27646,15 +27542,14 @@
 +#endif // QT_NO_TEXTCODEC
 diff --git a/src/corelib/codecs/qgb18030codec_p.h b/src/corelib/codecs/qgb18030codec_p.h
 new file mode 100644
-index 0000000..85047f3
+index 0000000..3e082bf
 --- /dev/null
 +++ b/src/corelib/codecs/qgb18030codec_p.h
 @@ -0,0 +1,159 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -27687,6 +27582,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -27811,15 +27707,14 @@
 +#endif // QGB18030CODEC_H
 diff --git a/src/corelib/codecs/qjiscodec.cpp b/src/corelib/codecs/qjiscodec.cpp
 new file mode 100644
-index 0000000..99c756e
+index 0000000..dd80541
 --- /dev/null
 +++ b/src/corelib/codecs/qjiscodec.cpp
 @@ -0,0 +1,367 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -27852,6 +27747,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -28184,15 +28080,14 @@
 +QT_END_NAMESPACE
 diff --git a/src/corelib/codecs/qjiscodec_p.h b/src/corelib/codecs/qjiscodec_p.h
 new file mode 100644
-index 0000000..aaf02a9
+index 0000000..dcdb04d
 --- /dev/null
 +++ b/src/corelib/codecs/qjiscodec_p.h
 @@ -0,0 +1,106 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -28225,6 +28120,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -28296,15 +28192,14 @@
 +#endif // QJISCODEC_H
 diff --git a/src/corelib/codecs/qjpunicode.cpp b/src/corelib/codecs/qjpunicode.cpp
 new file mode 100644
-index 0000000..feb0f41
+index 0000000..ffd8829
 --- /dev/null
 +++ b/src/corelib/codecs/qjpunicode.cpp
 @@ -0,0 +1,10700 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -28337,6 +28232,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -39002,15 +38898,14 @@
 +QT_END_NAMESPACE
 diff --git a/src/corelib/codecs/qjpunicode_p.h b/src/corelib/codecs/qjpunicode_p.h
 new file mode 100644
-index 0000000..069f49a
+index 0000000..a5bdd0c
 --- /dev/null
 +++ b/src/corelib/codecs/qjpunicode_p.h
 @@ -0,0 +1,174 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -39043,6 +38938,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -39182,15 +39078,14 @@
 +#endif // QJPUNICODE_H
 diff --git a/src/corelib/codecs/qsjiscodec.cpp b/src/corelib/codecs/qsjiscodec.cpp
 new file mode 100644
-index 0000000..ac89b33
+index 0000000..f03cd26
 --- /dev/null
 +++ b/src/corelib/codecs/qsjiscodec.cpp
 @@ -0,0 +1,229 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -39223,6 +39118,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -39417,15 +39313,14 @@
 +QT_END_NAMESPACE
 diff --git a/src/corelib/codecs/qsjiscodec_p.h b/src/corelib/codecs/qsjiscodec_p.h
 new file mode 100644
-index 0000000..c56a103
+index 0000000..3d3cde7
 --- /dev/null
 +++ b/src/corelib/codecs/qsjiscodec_p.h
 @@ -0,0 +1,106 @@
 +/****************************************************************************
 +**
 +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-+** All rights reserved.
-+** Contact: Nokia Corporation (qt-info@nokia.com)
++** Contact: http://www.qt-project.org/
 +**
 +** This file is part of the plugins of the Qt Toolkit.
 +**
@@ -39458,6 +39353,7 @@
 +**
 +**
 +**
++**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
@@ -39528,10 +39424,10 @@
 +
 +#endif // QSJISCODEC_H
 diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
-index 2b3100a..3399034 100644
+index f267acb..b6ed5e6 100644
 --- a/src/corelib/codecs/qtextcodec.cpp
 +++ b/src/corelib/codecs/qtextcodec.cpp
-@@ -66,16 +66,16 @@
+@@ -67,16 +67,16 @@
  #  include "qisciicodec_p.h"
  #if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
  #  if !defined(QT_BOOTSTRAPPED)
@@ -39579,15 +39475,14 @@
 -symbian:TARGET.UID3=0x2001E615
 diff --git a/src/plugins/codecs/cn/main.cpp b/src/plugins/codecs/cn/main.cpp
 deleted file mode 100644
-index cf42b97..0000000
+index 93b8b72..0000000
 --- a/src/plugins/codecs/cn/main.cpp
 +++ /dev/null
 @@ -1,145 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -39620,6 +39515,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -39730,15 +39626,14 @@
 -#endif // QT_NO_TEXTCODECPLUGIN
 diff --git a/src/plugins/codecs/cn/qgb18030codec.cpp b/src/plugins/codecs/cn/qgb18030codec.cpp
 deleted file mode 100644
-index 760fcc0..0000000
+index 928bc52..0000000
 --- a/src/plugins/codecs/cn/qgb18030codec.cpp
 +++ /dev/null
 @@ -1,9265 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -39771,6 +39666,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -49001,15 +48897,14 @@
 -#endif // QT_NO_TEXTCODEC
 diff --git a/src/plugins/codecs/cn/qgb18030codec.h b/src/plugins/codecs/cn/qgb18030codec.h
 deleted file mode 100644
-index 85047f3..0000000
+index 3e082bf..0000000
 --- a/src/plugins/codecs/cn/qgb18030codec.h
 +++ /dev/null
 @@ -1,159 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -49042,6 +48937,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -49209,15 +49105,14 @@
 -symbian:TARGET.UID3=0x2001E614
 diff --git a/src/plugins/codecs/jp/main.cpp b/src/plugins/codecs/jp/main.cpp
 deleted file mode 100644
-index b372fb6..0000000
+index 6eee02f..0000000
 --- a/src/plugins/codecs/jp/main.cpp
 +++ /dev/null
 @@ -1,149 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -49250,6 +49145,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -49364,15 +49260,14 @@
 -#endif // QT_NO_TEXTCODECPLUGIN
 diff --git a/src/plugins/codecs/jp/qeucjpcodec.cpp b/src/plugins/codecs/jp/qeucjpcodec.cpp
 deleted file mode 100644
-index 4ff5552..0000000
+index 69e314c..0000000
 --- a/src/plugins/codecs/jp/qeucjpcodec.cpp
 +++ /dev/null
 @@ -1,261 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -49405,6 +49300,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -49631,15 +49527,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/jp/qeucjpcodec.h b/src/plugins/codecs/jp/qeucjpcodec.h
 deleted file mode 100644
-index af02ed9..0000000
+index d693e04..0000000
 --- a/src/plugins/codecs/jp/qeucjpcodec.h
 +++ /dev/null
 @@ -1,106 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -49672,6 +49567,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -49743,15 +49639,14 @@
 -#endif // QEUCJPCODEC_H
 diff --git a/src/plugins/codecs/jp/qfontjpcodec.cpp b/src/plugins/codecs/jp/qfontjpcodec.cpp
 deleted file mode 100644
-index 85eae20..0000000
+index 2ac3d6c..0000000
 --- a/src/plugins/codecs/jp/qfontjpcodec.cpp
 +++ /dev/null
 @@ -1,145 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -49784,6 +49679,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -49894,15 +49790,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/jp/qfontjpcodec.h b/src/plugins/codecs/jp/qfontjpcodec.h
 deleted file mode 100644
-index 6b2a6ee..0000000
+index dfb06bb..0000000
 --- a/src/plugins/codecs/jp/qfontjpcodec.h
 +++ /dev/null
 @@ -1,93 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -49935,6 +49830,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -49993,15 +49889,14 @@
 -#endif // QFONTJPCODEC_H
 diff --git a/src/plugins/codecs/jp/qjiscodec.cpp b/src/plugins/codecs/jp/qjiscodec.cpp
 deleted file mode 100644
-index 99c756e..0000000
+index dd80541..0000000
 --- a/src/plugins/codecs/jp/qjiscodec.cpp
 +++ /dev/null
 @@ -1,367 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -50034,6 +49929,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -50366,15 +50262,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/jp/qjiscodec.h b/src/plugins/codecs/jp/qjiscodec.h
 deleted file mode 100644
-index aaf02a9..0000000
+index dcdb04d..0000000
 --- a/src/plugins/codecs/jp/qjiscodec.h
 +++ /dev/null
 @@ -1,106 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -50407,6 +50302,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -50478,15 +50374,14 @@
 -#endif // QJISCODEC_H
 diff --git a/src/plugins/codecs/jp/qjpunicode.cpp b/src/plugins/codecs/jp/qjpunicode.cpp
 deleted file mode 100644
-index feb0f41..0000000
+index ffd8829..0000000
 --- a/src/plugins/codecs/jp/qjpunicode.cpp
 +++ /dev/null
 @@ -1,10700 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -50519,6 +50414,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -61184,15 +61080,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/jp/qjpunicode.h b/src/plugins/codecs/jp/qjpunicode.h
 deleted file mode 100644
-index 069f49a..0000000
+index a5bdd0c..0000000
 --- a/src/plugins/codecs/jp/qjpunicode.h
 +++ /dev/null
 @@ -1,174 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -61225,6 +61120,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -61364,15 +61260,14 @@
 -#endif // QJPUNICODE_H
 diff --git a/src/plugins/codecs/jp/qsjiscodec.cpp b/src/plugins/codecs/jp/qsjiscodec.cpp
 deleted file mode 100644
-index ac89b33..0000000
+index f03cd26..0000000
 --- a/src/plugins/codecs/jp/qsjiscodec.cpp
 +++ /dev/null
 @@ -1,229 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -61405,6 +61300,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -61599,15 +61495,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/jp/qsjiscodec.h b/src/plugins/codecs/jp/qsjiscodec.h
 deleted file mode 100644
-index c56a103..0000000
+index 3d3cde7..0000000
 --- a/src/plugins/codecs/jp/qsjiscodec.h
 +++ /dev/null
 @@ -1,106 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -61640,6 +61535,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -61711,15 +61607,14 @@
 -#endif // QSJISCODEC_H
 diff --git a/src/plugins/codecs/kr/cp949codetbl.h b/src/plugins/codecs/kr/cp949codetbl.h
 deleted file mode 100644
-index 25723c7..0000000
+index 8bf9204..0000000
 --- a/src/plugins/codecs/kr/cp949codetbl.h
 +++ /dev/null
 @@ -1,637 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -61752,6 +61647,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -62380,15 +62276,14 @@
 -symbian:TARGET.UID3=0x2001B2E5
 diff --git a/src/plugins/codecs/kr/main.cpp b/src/plugins/codecs/kr/main.cpp
 deleted file mode 100644
-index 86cb7c2..0000000
+index cbfd133..0000000
 --- a/src/plugins/codecs/kr/main.cpp
 +++ /dev/null
 @@ -1,131 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -62421,6 +62316,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -62517,15 +62413,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/kr/qeuckrcodec.cpp b/src/plugins/codecs/kr/qeuckrcodec.cpp
 deleted file mode 100644
-index cc8fca8..0000000
+index bef4132..0000000
 --- a/src/plugins/codecs/kr/qeuckrcodec.cpp
 +++ /dev/null
 @@ -1,3571 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -62558,6 +62453,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -66094,15 +65990,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/kr/qeuckrcodec.h b/src/plugins/codecs/kr/qeuckrcodec.h
 deleted file mode 100644
-index 9408622..0000000
+index 55a1337..0000000
 --- a/src/plugins/codecs/kr/qeuckrcodec.h
 +++ /dev/null
 @@ -1,129 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -66135,6 +66030,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -66229,15 +66125,14 @@
 -#endif // QEUCKRCODEC_H
 diff --git a/src/plugins/codecs/tw/main.cpp b/src/plugins/codecs/tw/main.cpp
 deleted file mode 100644
-index 9c993e3..0000000
+index 4536e67..0000000
 --- a/src/plugins/codecs/tw/main.cpp
 +++ /dev/null
 @@ -1,138 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -66270,6 +66165,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -66373,15 +66269,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/tw/qbig5codec.cpp b/src/plugins/codecs/tw/qbig5codec.cpp
 deleted file mode 100644
-index e30861d..0000000
+index 662aee8..0000000
 --- a/src/plugins/codecs/tw/qbig5codec.cpp
 +++ /dev/null
 @@ -1,12788 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -66414,6 +66309,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -79167,15 +79063,14 @@
 -QT_END_NAMESPACE
 diff --git a/src/plugins/codecs/tw/qbig5codec.h b/src/plugins/codecs/tw/qbig5codec.h
 deleted file mode 100644
-index f43b733..0000000
+index eec1798..0000000
 --- a/src/plugins/codecs/tw/qbig5codec.h
 +++ /dev/null
 @@ -1,124 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the plugins of the Qt Toolkit.
 -**
@@ -79208,6 +79103,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -79337,32 +79233,19 @@
 1.7.10.4
 
 
-From 0332650cdfb4c5847a4678a1aebfbe146c850b87 Mon Sep 17 00:00:00 2001
+From 7c457dbd99e5865f13499146e9487e9cb4b86868 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Wed, 18 Jan 2012 21:01:26 +0100
-Subject: [PATCH 06/18] update private header references
+Subject: [PATCH 06/24] update private header references
 
 backported from qt5/qtbase
 Change-Id: I092d879653b6900532a0c4534c1eb2be84e9d0f6
 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
 (cherry picked from commit 15e4df7d83fd30e16f014bc1ddc5d55884b388aa)
----
- src/corelib/codecs/qbig5codec.cpp    |    2 +-
- src/corelib/codecs/qeucjpcodec.cpp   |    2 +-
- src/corelib/codecs/qeucjpcodec_p.h   |    2 +-
- src/corelib/codecs/qeuckrcodec.cpp   |    4 ++--
- src/corelib/codecs/qfontjpcodec.cpp  |    4 ++--
- src/corelib/codecs/qgb18030codec.cpp |    2 +-
- src/corelib/codecs/qjiscodec.cpp     |    2 +-
- src/corelib/codecs/qjiscodec_p.h     |    2 +-
- src/corelib/codecs/qjpunicode.cpp    |    2 +-
- src/corelib/codecs/qsjiscodec.cpp    |    2 +-
- src/corelib/codecs/qsjiscodec_p.h    |    2 +-
- 11 files changed, 13 insertions(+), 13 deletions(-)
 
 diff --git a/src/corelib/codecs/qbig5codec.cpp b/src/corelib/codecs/qbig5codec.cpp
-index e30861d..c1a73f7 100644
+index 662aee8..cd39ea0 100644
 --- a/src/corelib/codecs/qbig5codec.cpp
 +++ b/src/corelib/codecs/qbig5codec.cpp
 @@ -39,7 +39,7 @@
@@ -79375,7 +79258,7 @@
  QT_BEGIN_NAMESPACE
  
 diff --git a/src/corelib/codecs/qeucjpcodec.cpp b/src/corelib/codecs/qeucjpcodec.cpp
-index 4ff5552..f5f4285 100644
+index 69e314c..091ad4d 100644
 --- a/src/corelib/codecs/qeucjpcodec.cpp
 +++ b/src/corelib/codecs/qeucjpcodec.cpp
 @@ -73,7 +73,7 @@
@@ -79388,7 +79271,7 @@
  QT_BEGIN_NAMESPACE
  
 diff --git a/src/corelib/codecs/qeucjpcodec_p.h b/src/corelib/codecs/qeucjpcodec_p.h
-index af02ed9..9cc7c3d 100644
+index d693e04..a5cd119 100644
 --- a/src/corelib/codecs/qeucjpcodec_p.h
 +++ b/src/corelib/codecs/qeucjpcodec_p.h
 @@ -71,7 +71,7 @@
@@ -79401,7 +79284,7 @@
  #include <QtCore/qlist.h>
  
 diff --git a/src/corelib/codecs/qeuckrcodec.cpp b/src/corelib/codecs/qeuckrcodec.cpp
-index cc8fca8..00beebd 100644
+index bef4132..f91442f 100644
 --- a/src/corelib/codecs/qeuckrcodec.cpp
 +++ b/src/corelib/codecs/qeuckrcodec.cpp
 @@ -65,8 +65,8 @@
@@ -79416,7 +79299,7 @@
  QT_BEGIN_NAMESPACE
  
 diff --git a/src/corelib/codecs/qfontjpcodec.cpp b/src/corelib/codecs/qfontjpcodec.cpp
-index 85eae20..6763c88 100644
+index 2ac3d6c..590d72d 100644
 --- a/src/corelib/codecs/qfontjpcodec.cpp
 +++ b/src/corelib/codecs/qfontjpcodec.cpp
 @@ -39,9 +39,9 @@
@@ -79432,7 +79315,7 @@
  QT_BEGIN_NAMESPACE
  
 diff --git a/src/corelib/codecs/qgb18030codec.cpp b/src/corelib/codecs/qgb18030codec.cpp
-index 760fcc0..d5a40df 100644
+index 928bc52..5c0e701 100644
 --- a/src/corelib/codecs/qgb18030codec.cpp
 +++ b/src/corelib/codecs/qgb18030codec.cpp
 @@ -44,7 +44,7 @@
@@ -79445,7 +79328,7 @@
  #ifndef QT_NO_TEXTCODEC
  
 diff --git a/src/corelib/codecs/qjiscodec.cpp b/src/corelib/codecs/qjiscodec.cpp
-index 99c756e..b311646 100644
+index dd80541..1831170 100644
 --- a/src/corelib/codecs/qjiscodec.cpp
 +++ b/src/corelib/codecs/qjiscodec.cpp
 @@ -48,7 +48,7 @@
@@ -79458,7 +79341,7 @@
  
  QT_BEGIN_NAMESPACE
 diff --git a/src/corelib/codecs/qjiscodec_p.h b/src/corelib/codecs/qjiscodec_p.h
-index aaf02a9..3cd7c80 100644
+index dcdb04d..bb59c33 100644
 --- a/src/corelib/codecs/qjiscodec_p.h
 +++ b/src/corelib/codecs/qjiscodec_p.h
 @@ -71,7 +71,7 @@
@@ -79471,7 +79354,7 @@
  #include <QtCore/qlist.h>
  
 diff --git a/src/corelib/codecs/qjpunicode.cpp b/src/corelib/codecs/qjpunicode.cpp
-index feb0f41..67d4630 100644
+index ffd8829..7827ef3 100644
 --- a/src/corelib/codecs/qjpunicode.cpp
 +++ b/src/corelib/codecs/qjpunicode.cpp
 @@ -44,7 +44,7 @@
@@ -79484,7 +79367,7 @@
  #include "qbytearray.h"
  #include <stdlib.h>
 diff --git a/src/corelib/codecs/qsjiscodec.cpp b/src/corelib/codecs/qsjiscodec.cpp
-index ac89b33..b80b494 100644
+index f03cd26..97e6000 100644
 --- a/src/corelib/codecs/qsjiscodec.cpp
 +++ b/src/corelib/codecs/qsjiscodec.cpp
 @@ -48,7 +48,7 @@
@@ -79497,7 +79380,7 @@
  
  QT_BEGIN_NAMESPACE
 diff --git a/src/corelib/codecs/qsjiscodec_p.h b/src/corelib/codecs/qsjiscodec_p.h
-index c56a103..df1449b 100644
+index 3d3cde7..4910bfd 100644
 --- a/src/corelib/codecs/qsjiscodec_p.h
 +++ b/src/corelib/codecs/qsjiscodec_p.h
 @@ -71,7 +71,7 @@
@@ -79513,10 +79396,10 @@
 1.7.10.4
 
 
-From e76298384079852d9cc1e0138a10b0637f34687f Mon Sep 17 00:00:00 2001
+From 2be2accfee23fee3a9d97e5852ff9d2a01a7c33f Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sun, 3 Jul 2011 21:53:27 +0200
-Subject: [PATCH 07/18] cosmetic adjustments for files moved to core/codecs
+Subject: [PATCH 07/24] cosmetic adjustments for files moved to core/codecs
 
 -update old reference to 'plugin'
 -rename multiple inclusion guards
@@ -79527,33 +79410,14 @@
 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
 (cherry picked from commit 712cfb509484599f1586f68cc379e3e7464e9967)
----
- src/corelib/codecs/cp949codetbl_p.h  |   19 +++++++++++++++----
- src/corelib/codecs/qbig5codec.cpp    |    2 +-
- src/corelib/codecs/qbig5codec_p.h    |   19 +++++++++++++++----
- src/corelib/codecs/qeucjpcodec.cpp   |    2 +-
- src/corelib/codecs/qeucjpcodec_p.h   |   19 +++++++++++++++----
- src/corelib/codecs/qeuckrcodec.cpp   |    2 +-
- src/corelib/codecs/qeuckrcodec_p.h   |   19 +++++++++++++++----
- src/corelib/codecs/qfontjpcodec.cpp  |    2 +-
- src/corelib/codecs/qfontjpcodec_p.h  |   19 +++++++++++++++----
- src/corelib/codecs/qgb18030codec.cpp |    2 +-
- src/corelib/codecs/qgb18030codec_p.h |   19 +++++++++++++++----
- src/corelib/codecs/qjiscodec.cpp     |    2 +-
- src/corelib/codecs/qjiscodec_p.h     |   19 +++++++++++++++----
- src/corelib/codecs/qjpunicode.cpp    |    2 +-
- src/corelib/codecs/qjpunicode_p.h    |   19 +++++++++++++++----
- src/corelib/codecs/qsjiscodec.cpp    |    2 +-
- src/corelib/codecs/qsjiscodec_p.h    |   19 +++++++++++++++----
- 17 files changed, 143 insertions(+), 44 deletions(-)
 
 diff --git a/src/corelib/codecs/cp949codetbl_p.h b/src/corelib/codecs/cp949codetbl_p.h
-index 25723c7..0e608fa 100644
+index 8bf9204..228c5ad 100644
 --- a/src/corelib/codecs/cp949codetbl_p.h
 +++ b/src/corelib/codecs/cp949codetbl_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79589,12 +79453,12 @@
 -#endif // CP494CODETBL_H
 +#endif // CP494CODETBL_P_H
 diff --git a/src/corelib/codecs/qbig5codec.cpp b/src/corelib/codecs/qbig5codec.cpp
-index c1a73f7..ecdc84d 100644
+index cd39ea0..13b317f 100644
 --- a/src/corelib/codecs/qbig5codec.cpp
 +++ b/src/corelib/codecs/qbig5codec.cpp
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79602,12 +79466,12 @@
  ** $QT_BEGIN_LICENSE:LGPL$
  ** GNU Lesser General Public License Usage
 diff --git a/src/corelib/codecs/qbig5codec_p.h b/src/corelib/codecs/qbig5codec_p.h
-index f43b733..849ff9d 100644
+index eec1798..674c513 100644
 --- a/src/corelib/codecs/qbig5codec_p.h
 +++ b/src/corelib/codecs/qbig5codec_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79643,12 +79507,12 @@
 -#endif // QBIG5CODEC_H
 +#endif // QBIG5CODEC_P_H
 diff --git a/src/corelib/codecs/qeucjpcodec.cpp b/src/corelib/codecs/qeucjpcodec.cpp
-index f5f4285..c681492 100644
+index 091ad4d..773c473 100644
 --- a/src/corelib/codecs/qeucjpcodec.cpp
 +++ b/src/corelib/codecs/qeucjpcodec.cpp
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79656,12 +79520,12 @@
  ** $QT_BEGIN_LICENSE:LGPL$
  ** GNU Lesser General Public License Usage
 diff --git a/src/corelib/codecs/qeucjpcodec_p.h b/src/corelib/codecs/qeucjpcodec_p.h
-index 9cc7c3d..d34ac7c 100644
+index a5cd119..97d8523 100644
 --- a/src/corelib/codecs/qeucjpcodec_p.h
 +++ b/src/corelib/codecs/qeucjpcodec_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79697,12 +79561,12 @@
 -#endif // QEUCJPCODEC_H
 +#endif // QEUCJPCODEC_P_H
 diff --git a/src/corelib/codecs/qeuckrcodec.cpp b/src/corelib/codecs/qeuckrcodec.cpp
-index 00beebd..2cd472b 100644
+index f91442f..8417bf0 100644
 --- a/src/corelib/codecs/qeuckrcodec.cpp
 +++ b/src/corelib/codecs/qeuckrcodec.cpp
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79710,12 +79574,12 @@
  ** $QT_BEGIN_LICENSE:LGPL$
  ** GNU Lesser General Public License Usage
 diff --git a/src/corelib/codecs/qeuckrcodec_p.h b/src/corelib/codecs/qeuckrcodec_p.h
-index 9408622..f498d7c 100644
+index 55a1337..79647b1 100644
 --- a/src/corelib/codecs/qeuckrcodec_p.h
 +++ b/src/corelib/codecs/qeuckrcodec_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79751,12 +79615,12 @@
 -#endif // QEUCKRCODEC_H
 +#endif // QEUCKRCODEC_P_H
 diff --git a/src/corelib/codecs/qfontjpcodec.cpp b/src/corelib/codecs/qfontjpcodec.cpp
-index 6763c88..156ec3a 100644
+index 590d72d..3d39524 100644
 --- a/src/corelib/codecs/qfontjpcodec.cpp
 +++ b/src/corelib/codecs/qfontjpcodec.cpp
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79764,12 +79628,12 @@
  ** $QT_BEGIN_LICENSE:LGPL$
  ** GNU Lesser General Public License Usage
 diff --git a/src/corelib/codecs/qfontjpcodec_p.h b/src/corelib/codecs/qfontjpcodec_p.h
-index 6b2a6ee..981a086 100644
+index dfb06bb..9e9b8dd 100644
 --- a/src/corelib/codecs/qfontjpcodec_p.h
 +++ b/src/corelib/codecs/qfontjpcodec_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79805,12 +79669,12 @@
 -#endif // QFONTJPCODEC_H
 +#endif // QFONTJPCODEC_P_H
 diff --git a/src/corelib/codecs/qgb18030codec.cpp b/src/corelib/codecs/qgb18030codec.cpp
-index d5a40df..2b56018 100644
+index 5c0e701..c5daef6 100644
 --- a/src/corelib/codecs/qgb18030codec.cpp
 +++ b/src/corelib/codecs/qgb18030codec.cpp
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79818,12 +79682,12 @@
  ** $QT_BEGIN_LICENSE:LGPL$
  ** GNU Lesser General Public License Usage
 diff --git a/src/corelib/codecs/qgb18030codec_p.h b/src/corelib/codecs/qgb18030codec_p.h
-index 85047f3..6c3cb31 100644
+index 3e082bf..0f66211 100644
 --- a/src/corelib/codecs/qgb18030codec_p.h
 +++ b/src/corelib/codecs/qgb18030codec_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79859,12 +79723,12 @@
 -#endif // QGB18030CODEC_H
 +#endif // QGB18030CODEC_P_H
 diff --git a/src/corelib/codecs/qjiscodec.cpp b/src/corelib/codecs/qjiscodec.cpp
-index b311646..7b5fb4e 100644
+index 1831170..83c4329 100644
 --- a/src/corelib/codecs/qjiscodec.cpp
 +++ b/src/corelib/codecs/qjiscodec.cpp
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79872,12 +79736,12 @@
  ** $QT_BEGIN_LICENSE:LGPL$
  ** GNU Lesser General Public License Usage
 diff --git a/src/corelib/codecs/qjiscodec_p.h b/src/corelib/codecs/qjiscodec_p.h
-index 3cd7c80..4a0fc43 100644
+index bb59c33..daccf57 100644
 --- a/src/corelib/codecs/qjiscodec_p.h
 +++ b/src/corelib/codecs/qjiscodec_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79913,12 +79777,12 @@
 -#endif // QJISCODEC_H
 +#endif // QJISCODEC_P_H
 diff --git a/src/corelib/codecs/qjpunicode.cpp b/src/corelib/codecs/qjpunicode.cpp
-index 67d4630..03db950 100644
+index 7827ef3..1e4883f 100644
 --- a/src/corelib/codecs/qjpunicode.cpp
 +++ b/src/corelib/codecs/qjpunicode.cpp
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79926,12 +79790,12 @@
  ** $QT_BEGIN_LICENSE:LGPL$
  ** GNU Lesser General Public License Usage
 diff --git a/src/corelib/codecs/qjpunicode_p.h b/src/corelib/codecs/qjpunicode_p.h
-index 069f49a..82b3d2c 100644
+index a5bdd0c..07b5b25 100644
 --- a/src/corelib/codecs/qjpunicode_p.h
 +++ b/src/corelib/codecs/qjpunicode_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79967,12 +79831,12 @@
 -#endif // QJPUNICODE_H
 +#endif // QJPUNICODE_P_H
 diff --git a/src/corelib/codecs/qsjiscodec.cpp b/src/corelib/codecs/qsjiscodec.cpp
-index b80b494..c4438e3 100644
+index 97e6000..27121ad 100644
 --- a/src/corelib/codecs/qsjiscodec.cpp
 +++ b/src/corelib/codecs/qsjiscodec.cpp
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -79980,12 +79844,12 @@
  ** $QT_BEGIN_LICENSE:LGPL$
  ** GNU Lesser General Public License Usage
 diff --git a/src/corelib/codecs/qsjiscodec_p.h b/src/corelib/codecs/qsjiscodec_p.h
-index df1449b..f8efcae 100644
+index 4910bfd..d57f94b 100644
 --- a/src/corelib/codecs/qsjiscodec_p.h
 +++ b/src/corelib/codecs/qsjiscodec_p.h
-@@ -4,7 +4,7 @@
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
+@@ -3,7 +3,7 @@
+ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/
  **
 -** This file is part of the plugins of the Qt Toolkit.
 +** This file is part of the QtCore module of the Qt Toolkit.
@@ -80024,10 +79888,10 @@
 1.7.10.4
 
 
-From 16ea320980842c9c16d380f3bdd84c5a413dbd21 Mon Sep 17 00:00:00 2001
+From eeecdea8f15353aa0461ec09f7064f456849a3c3 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 12 Jan 2012 10:43:29 +0100
-Subject: [PATCH 08/18] remove obsolete codec plugin loading code
+Subject: [PATCH 08/24] remove obsolete codec plugin loading code
 
 backported from qt5/qtbase
 Change-Id: I1f3dbb5c10009413f701947b1b89ed3dbc94bf3d
@@ -80038,22 +79902,9 @@
 Conflicts:
 
 	dist/changes-5.0.0
----
- src/corelib/codecs/codecs.pri           |    8 +-
- src/corelib/codecs/qtextcodec.cpp       |   87 +----------------
- src/corelib/codecs/qtextcodecplugin.cpp |  161 -------------------------------
- src/corelib/codecs/qtextcodecplugin.h   |   96 ------------------
- src/corelib/global/qconfig-medium.h     |    3 -
- src/corelib/global/qconfig-minimal.h    |    3 -
- src/corelib/global/qconfig-nacl.h       |    3 -
- src/corelib/global/qconfig-small.h      |    3 -
- src/corelib/global/qfeatures.h          |    5 -
- 9 files changed, 4 insertions(+), 365 deletions(-)
- delete mode 100644 src/corelib/codecs/qtextcodecplugin.cpp
- delete mode 100644 src/corelib/codecs/qtextcodecplugin.h
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 02f30f5..76e8d5e 100644
+index a1271b9..9274eda 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -7,11 +7,9 @@ HEADERS += \
@@ -80083,13 +79934,13 @@
      codecs/qjpunicode.cpp \
      codecs/qeucjpcodec.cpp \
 diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
-index 3399034..552a195 100644
+index b6ed5e6..55e5b83 100644
 --- a/src/corelib/codecs/qtextcodec.cpp
 +++ b/src/corelib/codecs/qtextcodec.cpp
-@@ -47,11 +47,6 @@
- 
+@@ -48,11 +48,6 @@
  #include "qlist.h"
  #include "qfile.h"
+ #include "qvarlengtharray.h"
 -#ifndef QT_NO_LIBRARY
 -# include "qcoreapplication.h"
 -# include "qtextcodecplugin.h"
@@ -80098,7 +79949,7 @@
  #include "qstringlist.h"
  
  #ifdef Q_OS_UNIX
-@@ -104,11 +99,6 @@
+@@ -105,11 +100,6 @@
  
  QT_BEGIN_NAMESPACE
  
@@ -80110,7 +79961,7 @@
  //Cache for QTextCodec::codecForName and codecForMib.
  typedef QHash<QByteArray, QTextCodec *> QTextCodecCache;
  Q_GLOBAL_STATIC(QTextCodecCache, qTextCodecCache)
-@@ -150,39 +140,6 @@ static bool nameMatch(const QByteArray &name, const QByteArray &test)
+@@ -151,39 +141,6 @@ static bool nameMatch(const QByteArray &name, const QByteArray &test)
  }
  
  
@@ -80150,7 +80001,7 @@
  static QList<QTextCodec*> *all = 0;
  #ifdef Q_DEBUG_TEXTCODEC
  static bool destroying_is_ok = false;
-@@ -967,10 +924,6 @@ QTextCodec::ConverterState::~ConverterState()
+@@ -959,10 +916,6 @@ QTextCodec::ConverterState::~ConverterState()
           \o Converts a Unicode string to an 8-bit character string.
      \endtable
  
@@ -80161,7 +80012,7 @@
      \sa QTextStream, QTextDecoder, QTextEncoder, {Codecs Example}
  */
  
-@@ -1063,10 +1016,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
+@@ -1055,10 +1008,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
              }
      }
  
@@ -80173,7 +80024,7 @@
  }
  
  
-@@ -1103,16 +1053,7 @@ QTextCodec* QTextCodec::codecForMib(int mib)
+@@ -1095,16 +1045,7 @@ QTextCodec* QTextCodec::codecForMib(int mib)
          }
      }
  
@@ -80191,7 +80042,7 @@
  }
  
  /*!
-@@ -1145,18 +1086,6 @@ QList<QByteArray> QTextCodec::availableCodecs()
+@@ -1137,18 +1078,6 @@ QList<QByteArray> QTextCodec::availableCodecs()
      locker.unlock();
  #endif
  
@@ -80210,7 +80061,7 @@
      return codecs;
  }
  
-@@ -1185,18 +1114,6 @@ QList<int> QTextCodec::availableMibs()
+@@ -1177,18 +1106,6 @@ QList<int> QTextCodec::availableMibs()
      locker.unlock();
  #endif
  
@@ -80231,15 +80082,14 @@
  
 diff --git a/src/corelib/codecs/qtextcodecplugin.cpp b/src/corelib/codecs/qtextcodecplugin.cpp
 deleted file mode 100644
-index 4eb075c..0000000
+index b164f31..0000000
 --- a/src/corelib/codecs/qtextcodecplugin.cpp
 +++ /dev/null
 @@ -1,161 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the QtCore module of the Qt Toolkit.
 -**
@@ -80272,6 +80122,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -80398,15 +80249,14 @@
 -#endif // QT_NO_TEXTCODECPLUGIN
 diff --git a/src/corelib/codecs/qtextcodecplugin.h b/src/corelib/codecs/qtextcodecplugin.h
 deleted file mode 100644
-index 9a00bbc..0000000
+index 2873b0e..0000000
 --- a/src/corelib/codecs/qtextcodecplugin.h
 +++ /dev/null
 @@ -1,96 +0,0 @@
 -/****************************************************************************
 -**
 -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--** All rights reserved.
--** Contact: Nokia Corporation (qt-info@nokia.com)
+-** Contact: http://www.qt-project.org/
 -**
 -** This file is part of the QtCore module of the Qt Toolkit.
 -**
@@ -80439,6 +80289,7 @@
 -**
 -**
 -**
+-**
 -** $QT_END_LICENSE$
 -**
 -****************************************************************************/
@@ -80499,7 +80350,7 @@
 -
 -#endif // QTEXTCODECPLUGIN_H
 diff --git a/src/corelib/global/qconfig-medium.h b/src/corelib/global/qconfig-medium.h
-index 96207d1..779d4ef 100644
+index 170b2c3..9ed73aa 100644
 --- a/src/corelib/global/qconfig-medium.h
 +++ b/src/corelib/global/qconfig-medium.h
 @@ -91,9 +91,6 @@
@@ -80513,7 +80364,7 @@
  #  define QT_NO_TRANSLATION
  #endif
 diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h
-index da2bf14..dc963a7 100644
+index 6781c60..707e6b1 100644
 --- a/src/corelib/global/qconfig-minimal.h
 +++ b/src/corelib/global/qconfig-minimal.h
 @@ -167,9 +167,6 @@
@@ -80527,7 +80378,7 @@
  #  define QT_NO_TRANSLATION
  #endif
 diff --git a/src/corelib/global/qconfig-nacl.h b/src/corelib/global/qconfig-nacl.h
-index d97e666..ecaad4f 100644
+index eb4632f..7fecfec 100644
 --- a/src/corelib/global/qconfig-nacl.h
 +++ b/src/corelib/global/qconfig-nacl.h
 @@ -128,9 +128,6 @@
@@ -80541,7 +80392,7 @@
  #  define QT_NO_TRANSLATION
  #endif
 diff --git a/src/corelib/global/qconfig-small.h b/src/corelib/global/qconfig-small.h
-index fefbfb6..d0a7029 100644
+index 988dc6f..dda6567 100644
 --- a/src/corelib/global/qconfig-small.h
 +++ b/src/corelib/global/qconfig-small.h
 @@ -128,9 +128,6 @@
@@ -80555,7 +80406,7 @@
  #  define QT_NO_TRANSLATION
  #endif
 diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h
-index 844101a..4ea4227 100644
+index 9612778..493269d 100644
 --- a/src/corelib/global/qfeatures.h
 +++ b/src/corelib/global/qfeatures.h
 @@ -643,11 +643,6 @@
@@ -80574,10 +80425,10 @@
 1.7.10.4
 
 
-From 5a5ae1066dbcf8a663e7f292d8679aae2ccd7b73 Mon Sep 17 00:00:00 2001
+From c94d9111ef83683ea2b7db6e4070594c4a332f1c Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Mon, 23 Jan 2012 23:12:46 +0100
-Subject: [PATCH 09/18] remove vestiges of text codec plugins
+Subject: [PATCH 09/24] remove vestiges of text codec plugins
 
 follow-up to 3a3356a85079d734dfa57205a00e1996afc033df
 
@@ -80585,9 +80436,6 @@
 Change-Id: Iba84958cbcd105ec702568752090719cc108e101
 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
 (cherry picked from commit 38d4618eb5f9b7293513267f9f5749aa2568e08c)
----
- src/corelib/global/qfeatures.txt |    7 -------
- 1 file changed, 7 deletions(-)
 
 diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt
 index dea05e0..12cd8ea 100644
@@ -80611,15 +80459,12 @@
 1.7.10.4
 
 
-From 90daa3f753c91a3efde3dfdc9151f9a639c653d0 Mon Sep 17 00:00:00 2001
+From 415466a4ac2a87522569544a9b9ba7115fc4acf7 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 3 Nov 2011 15:10:26 +0100
-Subject: [PATCH 10/18] use pkg-config for libmng (MXE specific)
+Subject: [PATCH 10/24] use pkg-config for libmng (MXE specific)
 
 Change-Id: Ifce956d5cad06d5273088656b8500b87980063f4
----
- src/gui/image/qmnghandler.pri |    4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
 
 diff --git a/src/gui/image/qmnghandler.pri b/src/gui/image/qmnghandler.pri
 index ffb98de..6aab68f 100644
@@ -80640,15 +80485,12 @@
 1.7.10.4
 
 
-From 1d4c3643de6eea011e74ed73dc2290c58f41d865 Mon Sep 17 00:00:00 2001
+From 1cac3150930d5353455b560792f7e76fe180ad26 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 3 Nov 2011 14:11:02 +0100
-Subject: [PATCH 11/18] use pkg-config for libtiff-4 (MXE specific)
+Subject: [PATCH 11/24] use pkg-config for libtiff-4 (MXE specific)
 
 Change-Id: I5e89e66fc1606d425553e781c9e62db703136957
----
- src/gui/image/qtiffhandler.pri |    4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
 
 diff --git a/src/gui/image/qtiffhandler.pri b/src/gui/image/qtiffhandler.pri
 index e1cc3ee..71cbab1 100644
@@ -80669,10 +80511,10 @@
 1.7.10.4
 
 
-From a3c87e93fd4aa06163eb157b060e155c44fbbe14 Mon Sep 17 00:00:00 2001
+From 28ad5f9d9c70feba6475652c6445bbe263998d3d Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sat, 5 Jun 2010 23:41:04 +0200
-Subject: [PATCH 12/18] restore support for static linking of QtWebKit (MXE
+Subject: [PATCH 12/24] restore support for static linking of QtWebKit (MXE
  specific)
 
 Support was removed by 4221d629e2cf37ee8c5ba7cb595b05ab8c82f113.
@@ -80684,19 +80526,12 @@
 Don't build Qt WebKit tests to avoid static linking problems.
 
 Change-Id: Ia969b8e3f2b656a5057c7ebf748f272d74f014da
----
- configure                                                  |    6 ------
- .../webkit/Source/JavaScriptCore/JavaScriptCore.pri        |   12 ++++++++++++
- src/3rdparty/webkit/Source/WebCore/WebCore.pri             |   12 ++++++++++++
- src/3rdparty/webkit/Source/WebCore/WebCore.pro             |    2 +-
- src/3rdparty/webkit/Source/WebKit.pro                      |    2 +-
- 5 files changed, 26 insertions(+), 8 deletions(-)
 
 diff --git a/configure b/configure
-index 0690822..2837eec 100755
+index 520ffc3..e018443 100755
 --- a/configure
 +++ b/configure
-@@ -7599,12 +7599,6 @@ if [ "$CFG_GUI" = "no" ]; then
+@@ -7683,12 +7683,6 @@ if [ "$CFG_GUI" = "no" ]; then
      canBuildWebKit="no"
  fi
  
@@ -80779,10 +80614,10 @@
 1.7.10.4
 
 
-From 0f6cab5fff9eb2e0cfc173eaf71e068f9b82e9d3 Mon Sep 17 00:00:00 2001
+From ab04bc59d7caf5d04bb87bd75d2bbe98da89d599 Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:47:10 +0200
-Subject: [PATCH 13/18] fix building on GNU/kFreeBSD (MXE specific)
+Subject: [PATCH 13/24] fix building on GNU/kFreeBSD (MXE specific)
 
 This patch has been taken from:
 
@@ -80792,12 +80627,9 @@
 Author: Pino Toscano <pino@kde.org>
 Description: Fixes FTBFS on GNU/kFreeBSD by creating new Q_OS_FREEBSD_KERNEL.
 Last-Update: 2010-10-06
----
- src/corelib/global/qglobal.h |    2 ++
- 1 file changed, 2 insertions(+)
 
 diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
-index ed8f9eb..e571c4e 100644
+index b3d4852..1a6a4a4 100644
 --- a/src/corelib/global/qglobal.h
 +++ b/src/corelib/global/qglobal.h
 @@ -226,6 +226,8 @@ namespace QT_NAMESPACE {}
@@ -80813,10 +80645,10 @@
 1.7.10.4
 
 
-From 3b9839cc26fc7997b043a74c7d30fc3b0b81ad83 Mon Sep 17 00:00:00 2001
+From 28bf082efa51789d404e33bfbfdbe17a8261af87 Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:49:47 +0200
-Subject: [PATCH 14/18] fix missing platform when building on GNU/kFreeBSD
+Subject: [PATCH 14/24] fix missing platform when building on GNU/kFreeBSD
  (MXE specific)
 
 This patch is inspired by:
@@ -80825,15 +80657,12 @@
 For the time being, glibc-g++ is simply a copy of linux-g++.
 
 Change-Id: I1bebe2e6eef878318142ca5ed3525afc167b0a95
----
- configure |    3 +++
- 1 file changed, 3 insertions(+)
 
 diff --git a/configure b/configure
-index 2837eec..8b4e5e8 100755
+index e018443..b600744 100755
 --- a/configure
 +++ b/configure
-@@ -2749,6 +2749,9 @@ if [ -z "$PLATFORM" ]; then
+@@ -2845,6 +2845,9 @@ if [ -z "$PLATFORM" ]; then
       GNU:*)
          PLATFORM=hurd-g++
          ;;
@@ -80847,24 +80676,21 @@
 1.7.10.4
 
 
-From e15286869c4e9b5714209ec38686f63c8b2ff44c Mon Sep 17 00:00:00 2001
+From f32c0852485615d6938d1cde1e0b4dc4e6262a7e Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:51:50 +0200
-Subject: [PATCH 15/18] fix building on dragonfly (MXE specific)
+Subject: [PATCH 15/24] fix building on dragonfly (MXE specific)
 
 This patch is inspired by:
 http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/x11/qt4-libs/Makefile.common?rev=1.27&content-type=text/x-cvsweb-markup
 
 Change-Id: I9743a39ac35950cb15af915c3ae527433bc6b56d
----
- configure |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/configure b/configure
-index 8b4e5e8..99948d1 100755
+index b600744..599203d 100755
 --- a/configure
 +++ b/configure
-@@ -2761,7 +2761,7 @@ if [ -z "$PLATFORM" ]; then
+@@ -2857,7 +2857,7 @@ if [ -z "$PLATFORM" ]; then
       ULTRIX:*)
          PLATFORM=ultrix-g++
          ;;
@@ -80877,89 +80703,380 @@
 1.7.10.4
 
 
-From 87952077f0d192d2ce15ea111be3f320bc03be40 Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Fri, 23 Mar 2012 16:29:57 +0100
-Subject: [PATCH 16/18] gcc 4.7.0 compatibility fix for javascript
-
-taken from http://qt-project.org/forums/viewthread/15071
-
-Change-Id: I701fb5a8d754afe9fcd6b327d779365673e07b5d
----
- src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h  |    2 +-
- .../javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h      |    2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h
-index 7c20272..9eb86e7 100644
---- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h
-+++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h
-@@ -59,7 +59,7 @@ namespace JSC {
-     protected:
-         using JSVariableObject::JSVariableObjectData;
- 
--        struct JSGlobalObjectData : public JSVariableObjectData {
-+        struct JSGlobalObjectData : public JSVariableObject::JSVariableObjectData {
-             // We use an explicit destructor function pointer instead of a
-             // virtual destructor because we want to avoid adding a vtable
-             // pointer to this struct. Adding a vtable pointer would force the
-diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h
-index 2542878..3cb66a0 100644
---- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h
-+++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h
-@@ -33,7 +33,7 @@ namespace JSC{
-     class JSStaticScopeObject : public JSVariableObject {
-     protected:
-         using JSVariableObject::JSVariableObjectData;
--        struct JSStaticScopeObjectData : public JSVariableObjectData {
-+        struct JSStaticScopeObjectData : public JSVariableObject::JSVariableObjectData {
-             JSStaticScopeObjectData()
-                 : JSVariableObjectData(&symbolTable, &registerStore + 1)
-             {
+From 67da309cbc542e765d2254bd2e2c64a78c7cd35f Mon Sep 17 00:00:00 2001
+From: Yuchen Deng <loaden@gmail.com>
+Date: Sun, 19 Aug 2012 15:38:44 +0800
+Subject: [PATCH 16/24] Add -pipe option of win32-g++'s QMAKE_CFLAGS
+
+cherry-picked from qt5/qtbase commit 2b57a8ebfeb6e3495b63fac619631896ca670f11
+
+Change-Id: Idccab648df1a9456a4ee19f1acfdb0544d40a928
+Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
+(cherry picked from commit 9fbdb93d3aa1cad8859325814e28f014acd18f10)
+
+diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf
+index d174634..6d631fc 100644
+--- a/mkspecs/win32-g++/qmake.conf
++++ b/mkspecs/win32-g++/qmake.conf
+@@ -25,7 +25,7 @@ QMAKE_LEX		= flex
+ QMAKE_LEXFLAGS		=
+ QMAKE_YACC		= byacc
+ QMAKE_YACCFLAGS		= -d
+-QMAKE_CFLAGS		=
++QMAKE_CFLAGS		= -pipe
+ QMAKE_CFLAGS_DEPS	= -M
+ QMAKE_CFLAGS_WARN_ON	= -Wall -Wextra
+ QMAKE_CFLAGS_WARN_OFF	= -w
 -- 
 1.7.10.4
 
 
-From 4de5298ed5b06dea106f054ef110146a45f06b6f Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Thu, 19 Apr 2012 14:48:34 +0200
-Subject: [PATCH 17/18] fix static library names when generating .pc files for
- pkgconfig
-
-c354d16cc64cf516a0b5149cdc9ef74de096a998 added the version extension
-which only occurs on the DLL import library.
-
-cherry-picked from qt5/qtbase 8e053a5dfc9b4c8f100b1e77335439774f52fc61
-Change-Id: Ie913adf039d7f3a9aadf43f4af014289a8aeacbe
+From eeeadca6963f3dedd6ea3626409199f49afa839f Mon Sep 17 00:00:00 2001
+From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
+Date: Mon, 10 Sep 2012 12:08:51 +0200
+Subject: [PATCH 17/24] find qdevice.pri even for installed qt builds
+
+Change-Id: Ife18068974227d70c52e7cb0d06e6136827ac562
 Reviewed-by: Mark Brand <mabrand@mabrand.nl>
-Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
-(cherry picked from commit 51a2b0fde9bf635482fd2463b901139c82ed0dc4)
----
- qmake/generators/makefile.cpp |    3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
-index 66c6d49..447943a 100644
---- a/qmake/generators/makefile.cpp
-+++ b/qmake/generators/makefile.cpp
-@@ -3258,7 +3258,8 @@ MakefileGenerator::writePkgConfigFile()
-     } else {
-         pkgConfiglibDir = "-L${libdir}";
-         pkgConfiglibName = "-l" + lname.left(lname.length()-Option::libtool_ext.length());
--        pkgConfiglibName += project->first("TARGET_VERSION_EXT");
-+        if (project->isActiveConfig("shared"))
-+            pkgConfiglibName += project->first("TARGET_VERSION_EXT");
-     }
-     t << pkgConfiglibDir << " " << pkgConfiglibName << " " << endl;
+(cherry picked from commit ffac77f7de433f67570ff0da9656bce6481be920)
+
+diff --git a/mkspecs/features/device_config.prf b/mkspecs/features/device_config.prf
+index f7aeb07..7da3fe5 100644
+--- a/mkspecs/features/device_config.prf
++++ b/mkspecs/features/device_config.prf
+@@ -1,6 +1,6 @@
+ # Load generated qdevice.pri
+ isEmpty(QT_BUILD_TREE): QT_BUILD_TREE = $$fromfile($$_QMAKE_CACHE_, QT_BUILD_TREE)
+-isEmpty(QT_BUILD_TREE): QT_BUILD_TREE = . # where to get?
++isEmpty(QT_BUILD_TREE): QT_BUILD_TREE = $$[QT_INSTALL_DATA]
+ 
+ DEVICE_PRI = $$QT_BUILD_TREE/mkspecs/qdevice.pri
  
 -- 
 1.7.10.4
 
 
-From ba6f43c6ab66d00fb11e83a00e5e4364cf664131 Mon Sep 17 00:00:00 2001
+From 2519a7dd92f14031c7d11775caa0645384febd87 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Wed, 12 Sep 2012 00:22:28 +0200
+Subject: [PATCH 18/24] Partial Revert "Disable pkg-config, when x-compiling
+ for mingw"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This partially reverts commit c7d5071afc6c76925c90ff35041dc4eb86511271.
+
+Despite what the commit message said, pkg-config previously worked
+and was useful, particularly for static Qt. Qt itself even installs
+its own .pc files.
+
+Note: The mkspec win32-g++-cross had a PKG_CONFIG definition to avoid
+using the pkg-config installation on the build machine.
+
+cherry-picked from qt5/qtbase commit 7d9b5e8e7d2094dedbe7e3e2f961544f233ce57e
+Change-Id: I6c6ed81b2ab42c9cf7f7e250feeeb9c34c8877e7
+Reviewed-by: Peter Kümmel <syntheticpp@gmx.net>
+Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
+(cherry picked from commit 57069f1bd5e8cd5450f1d1ceae0d6d315b4a66c8)
+
+diff --git a/configure b/configure
+index 599203d..a0786da 100755
+--- a/configure
++++ b/configure
+@@ -1684,7 +1684,6 @@ while [ "$#" -gt 0 ]; do
+         case `basename "$XPLATFORM"` in win32-g++*)
+             XPLATFORM_MINGW=yes
+             CFG_RPATH=no
+-            PKG_CONFIG=no
+             CFG_REDUCE_EXPORTS=no
+             ;;
+         esac
+-- 
+1.7.10.4
+
+
+From 03f7a56af4020aaead73c9d0de389d32fd4ddb24 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Peter=20K=C3=BCmmel?= <syntheticpp@gmx.net>
+Date: Wed, 12 Sep 2012 11:13:44 +0200
+Subject: [PATCH 19/24] When x-compiling on Linux the host tools doesn't have
+ Windows' executable suffix
+
+patch not needed for Qt5
+
+Change-Id: I26a6cd8de91dc6df7d31a9f38187f7b1e8209cc1
+Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
+(cherry picked from commit 95c55b8a913fd7aaa23a44f1f9aa568342b25e07)
+
+diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf
+index 6d631fc..2cd2214 100644
+--- a/mkspecs/win32-g++/qmake.conf
++++ b/mkspecs/win32-g++/qmake.conf
+@@ -11,6 +11,8 @@ MAKEFILE_GENERATOR	= MINGW
+ 
+ load(device_config)
+ 
++equals(QMAKE_HOST.os, Windows): EXE_SUFFIX = .exe
++
+ TEMPLATE		= app
+ CONFIG			+= qt warn_on release link_prl copy_dir_files debug_and_release debug_and_release_target precompile_header
+ QT			+= core gui
+@@ -101,9 +103,9 @@ QMAKE_LIBS_QT_ENTRY     = -lmingw32 -lqtmain
+     QMAKE_CHK_DIR_EXISTS	= if not exist
+ }
+ 
+-QMAKE_MOC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe
+-QMAKE_UIC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe
+-QMAKE_IDC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe
++QMAKE_MOC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc$${EXE_SUFFIX}
++QMAKE_UIC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic$${EXE_SUFFIX}
++QMAKE_IDC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc$${EXE_SUFFIX}
+ 
+ QMAKE_IDL		= midl
+ QMAKE_LIB		= $${CROSS_COMPILE}ar -ru
+-- 
+1.7.10.4
+
+
+From 32415e3cb482c55b16d5953e37865ded1885869d Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Tue, 11 Sep 2012 23:45:02 +0200
+Subject: [PATCH 20/24] smuggle QT_BUILD_TREE to device_config.prf even during
+ tests
+
+Otherwise CROSS_COMPILE is not available for config.tests
+because qdevice.pri is not found in such configurations as:
+
+./configure -xplatform win32-g++-4.6 \
+            -device-option CROSS_COMPILE=$TARGET \
+            -prefix=$PREFIX/$TARGET \
+            -prefix-install
+
+Normally, we don't want to use .qmake.cache during tests,
+but we need that mechanism here.
+
+Change-Id: If255f9657fa4206c4875a730f467d58b8a1c6ac1
+Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
+(cherry picked from commit a0c6987dbb139829f9ea61a66cb863b1baa1f183)
+
+diff --git a/config.tests/unix/compile.test b/config.tests/unix/compile.test
+index f4a7f29..b8f6743 100755
+--- a/config.tests/unix/compile.test
++++ b/config.tests/unix/compile.test
+@@ -68,7 +68,8 @@ test -r Makefile && $MAKE distclean >/dev/null 2>&1
+ # Make sure output from possible previous tests is gone
+ rm -f "$EXE" "${EXE}.exe"
+ 
+-"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG-=debug_and_release" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "QT_BUILD_TREE=$OUTDIR" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile"
++echo "QT_BUILD_TREE = $OUTDIR" > "$OUTDIR/$TEST/.qmake.cache"
++"$OUTDIR/bin/qmake" -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG-=debug_and_release" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile"
+ 
+ if [ "$VERBOSE" = "yes" ]; then
+     $MAKE
+-- 
+1.7.10.4
+
+
+From b0481b3c70c42136df1904de68a8f8fc797591e2 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 16 Sep 2012 00:12:53 +0200
+Subject: [PATCH 21/24] configure: postpone pkg-config detection until after
+ qmake is built
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+pkg-config isn't used before qmake is built, so these tests can take
+place afterward.
+
+This is preparation for using qmake to resolve PKG_CONFIG in mkspecs.
+
+Change-Id: Icedf9ebd80bbac3fe1e5d7eeca358cb0fc9de072
+Reviewed-by: Peter Kümmel <syntheticpp@gmx.net>
+Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
+(cherry picked from commit 1861f0317d4058482667154131f8eb6488db407e)
+
+diff --git a/configure b/configure
+index a0786da..53d0506 100755
+--- a/configure
++++ b/configure
+@@ -3330,64 +3330,9 @@ if [ "$OPT_VERBOSE" = "yes" ]; then
+ fi
+ 
+ #-------------------------------------------------------------------------------
+-# write out device config before we run the test.
+-#-------------------------------------------------------------------------------
+-DEVICE_VARS_OUTFILE="$outpath/mkspecs/qdevice.pri"
+-if cmp -s "$DEVICE_VARS_FILE" "$DEVICE_VARS_OUTFILE"; then
+-    rm -f "$DEVICE_VARS_FILE"
+-else
+-    mv -f $DEVICE_VARS_FILE "$DEVICE_VARS_OUTFILE"
+-    DEVICE_VARS_FILE="$DEVICE_VARS_OUTFILE"
+-fi
+-
+-#-------------------------------------------------------------------------------
+ # tests that don't need qmake (must be run before displaying help)
+ #-------------------------------------------------------------------------------
+ 
+-if [ -z "$PKG_CONFIG" ]; then
+-    # See if PKG_CONFIG is set in the mkspec:
+-    PKG_CONFIG=`getXQMakeConf PKG_CONFIG`
+-fi
+-if [ -z "$PKG_CONFIG" ]; then
+-    PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
+-fi
+-
+-# Work out if we can use pkg-config
+-if [ "$QT_CROSS_COMPILE" = "yes" ]; then
+-    if [ "$QT_FORCE_PKGCONFIG" = "yes" ]; then
+-        echo >&2 ""
+-        echo >&2 "You have asked to use pkg-config and are cross-compiling."
+-        echo >&2 "Please make sure you have a correctly set-up pkg-config"
+-        echo >&2 "environment!"
+-        echo >&2 ""
+-        if [ -z "$PKG_CONFIG_PATH" ]; then
+-            echo >&2 ""
+-            echo >&2 "Warning: PKG_CONFIG_PATH has not been set.  This could mean"
+-            echo >&2 "the host compiler's .pc files will be used. This is probably"
+-            echo >&2 "not what you want."
+-            echo >&2 ""
+-        elif [ -z "$PKG_CONFIG_SYSROOT" ] && [ -z "$PKG_CONFIG_SYSROOT_DIR" ]; then
+-            echo >&2 ""
+-            echo >&2 "Warning: PKG_CONFIG_SYSROOT/PKG_CONFIG_SYSROOT_DIR has not"
+-            echo >&2 "been set. This means your toolchain's .pc files must contain"
+-            echo >&2 "the paths to the toolchain's libraries & headers. If configure"
+-            echo >&2 "tests are failing, please check these files."
+-            echo >&2 ""
+-        fi
+-    else
+-        echo >&2 ""
+-        echo >&2 "You have not explicitly asked to use pkg-config and are cross-compiling."
+-        echo >&2 "pkg-config will not be used to automatically query cflag/lib parameters for"
+-        echo >&2 "dependencies"
+-        echo >&2 ""
+-        PKG_CONFIG=""
+-    fi
+-fi
+-
+-if [ ! -n "$PKG_CONFIG" ]; then
+-    QT_CONFIG="$QT_CONFIG no-pkg-config"
+-fi
+-
+ # process CFG_MAC_ARCHS
+ if [ "$PLATFORM_MAC" = "yes" ]; then
+ #   check -arch arguments for validity.
+@@ -5058,6 +5003,61 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
+ fi # Build qmake
+ 
+ #-------------------------------------------------------------------------------
++# write out device config before we run the test.
++#-------------------------------------------------------------------------------
++DEVICE_VARS_OUTFILE="$outpath/mkspecs/qdevice.pri"
++if cmp -s "$DEVICE_VARS_FILE" "$DEVICE_VARS_OUTFILE"; then
++    rm -f "$DEVICE_VARS_FILE"
++else
++    mv -f $DEVICE_VARS_FILE "$DEVICE_VARS_OUTFILE"
++    DEVICE_VARS_FILE="$DEVICE_VARS_OUTFILE"
++fi
++
++if [ -z "$PKG_CONFIG" ]; then
++    # See if PKG_CONFIG is set in the mkspec:
++    PKG_CONFIG=`getXQMakeConf PKG_CONFIG`
++fi
++if [ -z "$PKG_CONFIG" ]; then
++    PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
++fi
++
++# Work out if we can use pkg-config
++if [ "$QT_CROSS_COMPILE" = "yes" ]; then
++    if [ "$QT_FORCE_PKGCONFIG" = "yes" ]; then
++        echo >&2 ""
++        echo >&2 "You have asked to use pkg-config and are cross-compiling."
++        echo >&2 "Please make sure you have a correctly set-up pkg-config"
++        echo >&2 "environment!"
++        echo >&2 ""
++        if [ -z "$PKG_CONFIG_PATH" ]; then
++            echo >&2 ""
++            echo >&2 "Warning: PKG_CONFIG_PATH has not been set.  This could mean"
++            echo >&2 "the host compiler's .pc files will be used. This is probably"
++            echo >&2 "not what you want."
++            echo >&2 ""
++        elif [ -z "$PKG_CONFIG_SYSROOT" ] && [ -z "$PKG_CONFIG_SYSROOT_DIR" ]; then
++            echo >&2 ""
++            echo >&2 "Warning: PKG_CONFIG_SYSROOT/PKG_CONFIG_SYSROOT_DIR has not"
++            echo >&2 "been set. This means your toolchain's .pc files must contain"
++            echo >&2 "the paths to the toolchain's libraries & headers. If configure"
++            echo >&2 "tests are failing, please check these files."
++            echo >&2 ""
++        fi
++    else
++        echo >&2 ""
++        echo >&2 "You have not explicitly asked to use pkg-config and are cross-compiling."
++        echo >&2 "pkg-config will not be used to automatically query cflag/lib parameters for"
++        echo >&2 "dependencies"
++        echo >&2 ""
++        PKG_CONFIG=""
++    fi
++fi
++
++if [ ! -n "$PKG_CONFIG" ]; then
++    QT_CONFIG="$QT_CONFIG no-pkg-config"
++fi
++
++#-------------------------------------------------------------------------------
+ # tests that need qmake
+ #-------------------------------------------------------------------------------
+ 
+-- 
+1.7.10.4
+
+
+From b0638daae7481b9770e4a88bb7509f6cbbfee0e8 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Fri, 14 Sep 2012 10:03:18 +0200
+Subject: [PATCH 22/24] use qmake to get PKG_CONFIG in configure script
+
+The value of PKG_CONFIG might depend on device options.
+For example, "-device-option PKG_CONFIG" might be used with configure
+or a mkspec might prefix PKG_CONFIG with CROSS_COMPILE which is
+specified as a device option.
+
+The shell functions of configure for parsing mkspecs do not take
+device options into account, but qmake is pretty good at it now.
+
+backport of qt5/qtbase 01864d4854557d2cf8b067e229d77cd7c9c553ee
+
+Change-Id: I1c9558e550c48e8441ebdac34b82066473c2ce3a
+Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
+(cherry picked from commit d8f1f7a29c277c9a643fd048b87f530e37773676)
+
+diff --git a/configure b/configure
+index 53d0506..723502e 100755
+--- a/configure
++++ b/configure
+@@ -5014,8 +5014,12 @@ else
+ fi
+ 
+ if [ -z "$PKG_CONFIG" ]; then
+-    # See if PKG_CONFIG is set in the mkspec:
+-    PKG_CONFIG=`getXQMakeConf PKG_CONFIG`
++    # See if PKG_CONFIG is set in the mkspec or device options
++    (echo TEMPLATE = subdirs
++     echo 'message($$PKG_CONFIG)') > "$outpath/dummy.pro"
++    echo "QT_BUILD_TREE = $outpath" > "$outpath/.qmake.cache.pkgconfig"
++    PKG_CONFIG=`"$outpath/bin/qmake" -cache "$outpath/.qmake.cache.pkgconfig" -spec "$XQMAKESPEC" "$outpath/dummy.pro" -o /dev/null 2>&1 > /dev/null | sed -n -e 's,Project MESSAGE: \(.*\),\1,p'`
++    rm "$outpath/.qmake.cache.pkgconfig" "$outpath/dummy.pro"
+ fi
+ if [ -z "$PKG_CONFIG" ]; then
+     PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
+-- 
+1.7.10.4
+
+
+From 4814e4ff8a6d245eff8761113ac2ae8f37abf71a Mon Sep 17 00:00:00 2001
 From: Richard Moore <rich@kde.org>
 Date: Fri, 14 Sep 2012 00:13:08 +0100
-Subject: [PATCH 18/18] Disable SSL compression by default.
+Subject: [PATCH 23/24] Disable SSL compression by default.
 
 Disable SSL compression by default since this appears to be the a likely
 cause of the currently hyped CRIME attack.
@@ -80970,14 +81087,9 @@
 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
 Reviewed-by: Peter Hartmann <phartmann@rim.com>
 (cherry picked from commit d41dc3e101a694dec98d7bbb582d428d209e5401)
----
- src/network/ssl/qssl.cpp              |    5 +++--
- src/network/ssl/qsslconfiguration.cpp |    4 +++-
- src/network/ssl/qsslconfiguration_p.h |    4 +++-
- 3 files changed, 9 insertions(+), 4 deletions(-)
 
 diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp
-index e225984..322bbae 100644
+index 49e086f..9578178 100644
 --- a/src/network/ssl/qssl.cpp
 +++ b/src/network/ssl/qssl.cpp
 @@ -148,8 +148,9 @@ QT_BEGIN_NAMESPACE
@@ -80993,7 +81105,7 @@
      Note: Availability of above options depends on the version of the SSL
      backend in use.
 diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp
-index 0eb01b8..968b3f6 100644
+index 24c7b77..3a05f54 100644
 --- a/src/network/ssl/qsslconfiguration.cpp
 +++ b/src/network/ssl/qsslconfiguration.cpp
 @@ -201,7 +201,9 @@ bool QSslConfiguration::isNull() const
@@ -81008,7 +81120,7 @@
  
  /*!
 diff --git a/src/network/ssl/qsslconfiguration_p.h b/src/network/ssl/qsslconfiguration_p.h
-index b2a76d4..7ee34ea 100644
+index 74f17cd..c36b651 100644
 --- a/src/network/ssl/qsslconfiguration_p.h
 +++ b/src/network/ssl/qsslconfiguration_p.h
 @@ -83,7 +83,9 @@ public:
@@ -81025,3 +81137,40 @@
 -- 
 1.7.10.4
 
+
+From 08f8d25243a021fb17bfce06cd2b1f96dea7454d Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Tue, 18 Sep 2012 21:40:22 +0200
+Subject: [PATCH 24/24] configure: mac features don't belong on cross mingw
+ target
+
+CFG_MAC_DWARF2 and CFG_MAC_XARCH options are for targetting macs, not
+bulding on them.
+
+qt5/qtbase commit 7a67c822e3e552d0d881f0409a5316de07dbb8c7
+removed CFG_MAC_DWARF2.
+
+qt5/qtbase commit 59d5c26075724a581ed276d62d884b44d2ca4489
+removed CFG_MAC_XARCH.
+
+Change-Id: Idb789ed9a8aa9b824a4c2191a9c39e741ca49574
+
+diff --git a/configure b/configure
+index 723502e..0978939 100755
+--- a/configure
++++ b/configure
+@@ -3421,6 +3421,11 @@ elif [ "$CFG_PRECOMPILE" = "yes" ] && [ `echo "$CFG_MAC_ARCHS" | wc -w` -gt 1 ];
+     CFG_PRECOMPILE=no
+ fi
+ 
++if [ "$XPLATFORM_MINGW" = "yes" ]; then
++    CFG_MAC_DWARF2=no
++    CFG_MAC_XARCH=no
++fi
++
+ #auto-detect DWARF2 on the mac
+ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_DWARF2" = "auto" ]; then
+     if "$mactests/dwarf2.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests" ; then
+-- 
+1.7.10.4
+
--- a/src/qt.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/qt.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := qt
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := a074d0f605f009e23c63e0a4cb9b71c978146ffc
+$(PKG)_CHECKSUM := bc352a283610e0cd2fe0dbedbc45613844090fcb
 $(PKG)_SUBDIR   := $(PKG)-everywhere-opensource-src-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-everywhere-opensource-src-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://get.qt.nokia.com/qt/source/$($(PKG)_FILE)
+$(PKG)_URL      := http://releases.qt-project.org/qt4/source/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libodbc++ postgresql freetds openssl zlib libpng jpeg libmng tiff sqlite dbus
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://qt.gitorious.org/qt/qt/commits' | \
+    $(WGET) -q -O- 'http://qt.gitorious.org/qt/qt/commits' | \
     grep '<li><a href="/qt/qt/commit/' | \
     $(SED) -n 's,.*<a[^>]*>v\([0-9][^<-]*\)<.*,\1,p' | \
     tail -1
@@ -18,7 +18,6 @@
 
 define $(PKG)_BUILD
     cd '$(1)' && QTDIR='$(1)' ./bin/syncqt
-
     cd '$(1)' && \
         OPENSSL_LIBS="`'$(TARGET)-pkg-config' --libs-only-l openssl`" \
         PSQL_LIBS="-lpq -lsecur32 `'$(TARGET)-pkg-config' --libs-only-l openssl` -lws2_32" \
@@ -27,17 +26,19 @@
         -opensource \
         -confirm-license \
         -fast \
-        -xplatform unsupported/win32-g++-4.6-cross \
+        -xplatform win32-g++-4.6 \
+        -device-option CROSS_COMPILE=$(TARGET)- \
+        -device-option PKG_CONFIG='$(TARGET)-pkg-config' \
         -force-pkg-config \
         -release \
         -exceptions \
         -static \
-        -prefix '$(PREFIX)/$(TARGET)' \
+        -prefix '$(PREFIX)/$(TARGET)/qt' \
         -prefix-install \
         -script \
         -no-iconv \
         -opengl desktop \
-        -webkit \
+        -no-webkit \
         -no-glib \
         -no-gstreamer \
         -no-phonon \
@@ -64,12 +65,18 @@
         -v
 
     $(MAKE) -C '$(1)' -j '$(JOBS)'
-    rm -rf '$(PREFIX)/$(TARGET)/mkspecs'
+    rm -rf '$(PREFIX)/$(TARGET)/qt'
     $(MAKE) -C '$(1)' -j 1 install
-    $(INSTALL) -m755 '$(1)/bin/moc'   '$(PREFIX)/bin/$(TARGET)-moc'
-    $(INSTALL) -m755 '$(1)/bin/rcc'   '$(PREFIX)/bin/$(TARGET)-rcc'
-    $(INSTALL) -m755 '$(1)/bin/uic'   '$(PREFIX)/bin/$(TARGET)-uic'
-    $(INSTALL) -m755 '$(1)/bin/qmake' '$(PREFIX)/bin/$(TARGET)-qmake'
+    ln -fs '$(PREFIX)/$(TARGET)/qt/bin/moc' '$(PREFIX)/bin/$(TARGET)-moc'
+    ln -fs '$(PREFIX)/$(TARGET)/qt/bin/rcc' '$(PREFIX)/bin/$(TARGET)-roc'
+    ln -fs '$(PREFIX)/$(TARGET)/qt/bin/uic' '$(PREFIX)/bin/$(TARGET)-uic'
+    ln -fs '$(PREFIX)/$(TARGET)/qt/bin/qmake' '$(PREFIX)/bin/$(TARGET)-qmake'
+
+    cd '$(1)/tools/assistant' && '$(1)/bin/qmake' assistant.pro
+    $(MAKE) -C '$(1)/tools/assistant' -j '$(JOBS)' install
+
+    cd '$(1)/tools/designer' && '$(1)/bin/qmake' designer.pro
+    $(MAKE) -C '$(1)/tools/designer' -j '$(JOBS)' install
 
     # at least some of the qdbus tools are useful on target
     cd '$(1)/tools/qdbus' && '$(1)/bin/qmake' qdbus.pro
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qwt-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,23 @@
+This file is part of MXE.
+See index.html for further information.
+
+--- qwt-6.0.1/qwtconfig.pri	2011-08-01 16:34:05.000000000 +0200
++++ qwt-6.0.1/qwtconfig.pri	2011-12-03 10:14:53.371757822 +0100
+@@ -23,7 +23,7 @@
+ }
+ 
+ win32 {
+-    QWT_INSTALL_PREFIX    = C:/Qwt-$$QWT_VERSION
++#    QWT_INSTALL_PREFIX    = C:/Qwt-$$QWT_VERSION
+ }
+ 
+ QWT_INSTALL_DOCS      = $${QWT_INSTALL_PREFIX}/doc
+@@ -58,7 +58,7 @@
+ # it will be a static library.
+ ######################################################################
+ 
+-QWT_CONFIG           += QwtDll
++#QWT_CONFIG           += QwtDll
+ 
+ ######################################################################
+ # QwtPlot enables all classes, that are needed to use the QwtPlot 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qwt.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,30 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# Qwt - Qt widgets for technical applications
+PKG             := qwt
+$(PKG)_CHECKSUM := 7ea84ee47339809c671a456b5363d941c45aea92
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $($(PKG)_SUBDIR).zip
+$(PKG)_WEBSITE  := http://qwt.sourceforge.net/
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc qt
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/qwt/files/qwt/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    # build
+    cd '$(1)/src' && $(PREFIX)/bin/$(TARGET)-qmake
+    $(MAKE) -C '$(1)/src' -f 'Makefile.Release' -j '$(JOBS)' install
+
+    #build sinusplot example to test linkage
+    cd '$(1)/examples/sinusplot' && $(PREFIX)/bin/$(TARGET)-qmake
+    $(MAKE) -C '$(1)/examples/sinusplot' -f 'Makefile.Release' -j '$(JOBS)'
+
+    # install
+    $(INSTALL) -m755 '$(1)/examples/bin/sinusplot.exe' '$(PREFIX)/$(TARGET)/bin/test-qwt.exe'
+endef
--- a/src/qwtplot3d.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/qwtplot3d.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc qt zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/$(PKG)/files/$(PKG)/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/$(PKG)/files/$(PKG)/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/readline.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/readline.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pdcurses
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://tiswww.case.edu/php/chet/readline/rltop.html' | \
+    $(WGET) -q -O- 'http://tiswww.case.edu/php/chet/readline/rltop.html' | \
     grep 'readline-' | \
     $(SED) -n 's,.*readline-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/sdl.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/sdl.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.libsdl.org/SDL/tags' | \
+    $(WGET) -q -O- 'http://hg.libsdl.org/SDL/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- a/src/sdl_image.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/sdl_image.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl jpeg libpng tiff
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.libsdl.org/SDL_image/tags' | \
+    $(WGET) -q -O- 'http://hg.libsdl.org/SDL_image/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- a/src/sdl_mixer.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/sdl_mixer.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -7,10 +7,10 @@
 $(PKG)_SUBDIR   := SDL_mixer-$($(PKG)_VERSION)
 $(PKG)_FILE     := SDL_mixer-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.libsdl.org/projects/SDL_mixer/release/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc sdl libmikmod ogg vorbis smpeg
+$(PKG)_DEPS     := gcc sdl libmodplug ogg vorbis smpeg
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.libsdl.org/SDL_mixer/tags' | \
+    $(WGET) -q -O- 'http://hg.libsdl.org/SDL_mixer/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
@@ -19,7 +19,7 @@
     $(SED) -i 's,^\(Requires:.*\),\1 vorbisfile,' '$(1)/SDL_mixer.pc.in'
     echo \
         'Libs.private:' \
-        "`$(PREFIX)/$(TARGET)/bin/libmikmod-config --libs`" \
+        "`$(TARGET)-pkg-config libmodplug --libs`" \
         "`$(PREFIX)/$(TARGET)/bin/smpeg-config     --libs`" \
         >> '$(1)/SDL_mixer.pc.in'
     $(SED) -i 's,for path in /usr/local; do,for path in; do,' '$(1)/configure'
@@ -29,7 +29,8 @@
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-sdl-prefix='$(PREFIX)/$(TARGET)' \
         --disable-sdltest \
-        --enable-music-mod \
+        --disable-music-mod \
+        --enable-music-mod-modplug \
         --enable-music-ogg \
         --disable-music-flac \
         --enable-music-mp3 \
@@ -39,7 +40,6 @@
         --disable-music-mp3-shared \
         --disable-smpegtest \
         --with-smpeg-prefix='$(PREFIX)/$(TARGET)' \
-        LIBMIKMOD_CONFIG='$(PREFIX)/$(TARGET)/bin/libmikmod-config' \
         LIBS='-lvorbis -logg'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
 
--- a/src/sdl_net.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/sdl_net.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.libsdl.org/projects/SDL_net/release/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://www.libsdl.org/projects/SDL_net/release/?C=M;O=D' | \
     $(SED) -n 's,.*SDL_net-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/sdl_pango.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/sdl_pango.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl pango
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/sdlpango/files/SDL_Pango/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/sdlpango/files/SDL_Pango/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/sdl_sound.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/sdl_sound.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl libmikmod ogg vorbis flac speex
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.icculus.org/icculus/SDL_sound/tags' | \
+    $(WGET) -q -O- 'http://hg.icculus.org/icculus/SDL_sound/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- a/src/sdl_ttf.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/sdl_ttf.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl freetype
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.libsdl.org/SDL_ttf/tags' | \
+    $(WGET) -q -O- 'http://hg.libsdl.org/SDL_ttf/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- a/src/smpeg.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/smpeg.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://packages.debian.org/unstable/source/smpeg' | \
+    $(WGET) -q -O- 'http://packages.debian.org/unstable/source/smpeg' | \
     $(SED) -n 's,.*smpeg_\([0-9][^>]*\)\.orig\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sox-test.c	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,15 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <sox.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    sox_format_init();
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sox.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,39 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# sox
+PKG             := sox
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := d809cab382c7a9d015491c69051a9d1c1a1a44f1
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc ffmpeg flac lame libgomp libmad libsndfile vorbis
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/sox/files/sox/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    # set pkg-config cflags and libs
+    $(SED) -i 's,^\(Cflags:.*\),\1 -fopenmp,' '$(1)/sox.pc.in'
+    $(SED) -i '/Libs.private/d'               '$(1)/sox.pc.in'
+    echo Libs.private: `grep sox_LDADD '$(1)/src/optional-fmts.am' | \
+    $(SED) 's, sox_LDADD += ,,g' | tr -d '\n'` >>'$(1)/sox.pc.in'
+
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared
+
+    $(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= EXTRA_PROGRAMS=
+    $(MAKE) -C '$(1)' -j 1 install
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-sox.exe' \
+        `'$(TARGET)-pkg-config' sox --cflags --libs`
+endef
--- a/src/speex.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/speex.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.xiph.org/?p=speex.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.xiph.org/?p=speex.git;a=tags' | \
     grep '<a class="list name"' | \
     $(SED) -n 's,.*<a[^>]*>Speex-\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/sqlite.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/sqlite.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := sqlite
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := a768f76b10df84d6a2c66178544d42725a8fdaf0
+$(PKG)_CHECKSUM := c464e0e3efe98227c6546b9b1e786b51b8b642fc
 $(PKG)_SUBDIR   := $(PKG)-autoconf-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-autoconf-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.sqlite.org/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.sqlite.org/download.html' | \
+    $(WGET) -q -O- 'http://www.sqlite.org/download.html' | \
     $(SED) -n 's,.*sqlite-autoconf-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -18,6 +18,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-readline \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/suitesparse-1.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,42 @@
+This file is part of MXE.
+See index.html for further information.
+
+From 169f88aef7ff1d302aa3eac48d779d009780b87f Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 20 May 2012 23:41:27 +0200
+Subject: [PATCH] build lib not demo
+
+---
+ CHOLMOD/Makefile |    2 +-
+ UMFPACK/Makefile |    2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/CHOLMOD/Makefile b/CHOLMOD/Makefile
+index 97911ef..4a3bcae 100644
+--- a/CHOLMOD/Makefile
++++ b/CHOLMOD/Makefile
+@@ -14,7 +14,7 @@ include ../SuiteSparse_config/SuiteSparse_config.mk
+ 
+ # Compile the C-callable libraries and the Demo programs.
+ all:
+-	( cd Demo ; $(MAKE) )
++	( cd Lib ; $(MAKE) )
+ 
+ # Compile the C-callable libraries only.
+ library:
+diff --git a/UMFPACK/Makefile b/UMFPACK/Makefile
+index 622ee39..e19cd2f 100644
+--- a/UMFPACK/Makefile
++++ b/UMFPACK/Makefile
+@@ -12,7 +12,7 @@ include ../SuiteSparse_config/SuiteSparse_config.mk
+ 
+ # compile all C code (except hb, fortran, and fortran64), incl. AMD and demos
+ all:
+-	( cd Demo   ; $(MAKE) )
++	( cd Lib    ; $(MAKE) )
+ 
+ # compile just the C-callable UMFPACK library
+ library:
+-- 
+1.7.10.4
+
--- a/src/suitesparse.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/suitesparse.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -2,14 +2,15 @@
 # See index.html for further information.
 
 PKG             := suitesparse
-$(PKG)_CHECKSUM := d0eb24b43ee2f7def032e80eaa7a589f94f546fc
+$(PKG)_CHECKSUM := 46b24a28eef4b040ea5a02d2c43e82e28b7d6195
 $(PKG)_SUBDIR   := SuiteSparse
 $(PKG)_FILE     := SuiteSparse-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.cise.ufl.edu/research/sparse/SuiteSparse/$($(PKG)_FILE)
+$(PKG)_URL_2    := https://distfiles.macports.org/SuiteSparse/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc blas lapack
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.cise.ufl.edu/research/sparse/SuiteSparse/' | \
+    $(WGET) -q -O- 'http://www.cise.ufl.edu/research/sparse/SuiteSparse/' | \
     $(SED) -n 's,.*SuiteSparse-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -24,7 +25,7 @@
         CC='$(TARGET)-gcc' \
         CPLUSPLUS='$(TARGET)-g++' \
         F77='$(TARGET)-gfortran' \
-        AR='$(TARGET)-ar cr' \
+        AR='$(TARGET)-ar' \
         RANLIB='$(TARGET)-ranlib' \
         BLAS='-lblas -lgfortran -lgfortranbegin' \
         CHOLMOD_CONFIG='-DNPARTITION'
@@ -36,16 +37,17 @@
 
     # install include files
     $(INSTALL) -d                                '$(PREFIX)/$(TARGET)/include/suitesparse/'
+    $(INSTALL) -m644 '$(1)/SuiteSparse_config/'*.h '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/AMD/Include/'*.h      '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/BTF/Include/'*.h      '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/CAMD/Include/'*.h     '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/CCOLAMD/Include/'*.h  '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/CHOLMOD/Include/'*.h  '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/COLAMD/Include/'*.h   '$(PREFIX)/$(TARGET)/include/suitesparse/'
+    $(INSTALL) -m644 '$(1)/CSparse/Include/'*.h  '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/CXSparse/Include/'*.h '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/KLU/Include/'*.h      '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/LDL/Include/'*.h      '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/SPQR/Include/'*       '$(PREFIX)/$(TARGET)/include/suitesparse/'
-    $(INSTALL) -m644 '$(1)/UFconfig/'*.h         '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/UMFPACK/Include/'*.h  '$(PREFIX)/$(TARGET)/include/suitesparse/'
 endef
--- a/src/t4k_common.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/t4k_common.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl sdl_mixer sdl_image sdl_net sdl_pango sdl_ttf libpng librsvg libxml2 pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://alioth.debian.org/frs/?group_id=31080' | \
+    $(WGET) -q -O- 'http://alioth.debian.org/frs/?group_id=31080' | \
     $(SED) -n 's,.*t4k_common-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/taglib.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/taglib.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := taglib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := bafe0958eb884981cade83d45c18ee34165479b8
+$(PKG)_CHECKSUM := e657384ccf3284db2daba32dccece74534286012
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://developer.kde.org/~wheeler/files/src/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://developer.kde.org/~wheeler/files/src/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://developer.kde.org/~wheeler/files/src/?C=M;O=D' | \
     $(SED) -n 's,.*"taglib-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/theora.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/theora.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc ogg vorbis
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.xiph.org/downloads/' | \
+    $(WGET) -q -O- 'http://www.xiph.org/downloads/' | \
     $(SED) -n 's,.*libtheora-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/tiff.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/tiff.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := tiff
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 8baf382231c9051a1b3eb294581289aa21447171
+$(PKG)_CHECKSUM := 652e97b78f1444237a82cbcfe014310e776eb6f0
 $(PKG)_SUBDIR   := tiff-$($(PKG)_VERSION)
 $(PKG)_FILE     := tiff-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://download.osgeo.org/libtiff/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib jpeg xz
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.remotesensing.org/libtiff/' | \
+    $(WGET) -q -O- 'http://www.remotesensing.org/libtiff/' | \
     $(SED) -n 's,.*>v\([0-9][^<]*\)<.*,\1,p' | \
     head -1
 endef
@@ -19,6 +19,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --without-x
--- a/src/tinyxml.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/tinyxml.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/tinyxml/files/tinyxml/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/tinyxml/files/tinyxml/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/tre.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/tre.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://laurikari.net/tre/download.html' | \
+    $(WGET) -q -O- 'http://laurikari.net/tre/download.html' | \
     $(SED) -n 's,.*tre-\([a-z0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/vigra.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/vigra.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg tiff libpng openexr
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hci.iwr.uni-heidelberg.de/vigra/' | \
+    $(WGET) -q -O- 'http://hci.iwr.uni-heidelberg.de/vigra/' | \
     grep 'Sources' | \
     grep '<a href="vigra' | \
     $(SED) -n 's,.*"vigra-\([0-9][^"]*\)-src.*,\1,p' | \
--- a/src/vmime-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/vmime-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,49 +1,14 @@
 This file is part of MXE.
 See index.html for further information.
 
-Cherry picked fixes from svn
-http://sourceforge.net/projects/vmime/develop
-
-Produced with this script:
-#--------------------------------------------------------------------#
-#!/usr/bin/env bash
-
-(
-  echo "This file is part of MXE."
-  echo "See index.html for further information."
-  echo
-  echo "Cherry picked fixes from svn"
-  echo "http://sourceforge.net/projects/vmime/develop"
-  echo
-  echo "Produced with this script:"
-  echo "#--------------------------------------------------------------------#"
-  cat "$0"
-  echo "#--------------------------------------------------------------------#"
-) > src/vmime-1-fixes.patch
-
-# setup git svn clone
-#cd ~/projects/vmime/git
-#git svn clone -s https://vmime.svn.sourceforge.net/svnroot/vmime
-#git reset --hard
-# get updates
-#git svn fetch
-#git svn rebase
-
-GITDIR=~/projects/vmime/git/vmime
-
-(
-  cd $GITDIR
-  echo
-  git format-patch -p --relative=vmime --stdout ":/Version 0.9.1"..master-fixed
-) >> src/vmime-1-fixes.patch
-#--------------------------------------------------------------------#
-
-From ed4451fd3c86faf9ecc03a59ba9f1ad78417a9f9 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+Commits from master branch of git://github.com/kisli/vmime
+rebased onto version 0.9.1 tarball files.
+
+From 17ff5157ffdc749f60b8285f84e64ac5e06d4283 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 16 Nov 2010 13:28:05 +0000
-Subject: [PATCH 01/27] Started version 0.9.2.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@576 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 01/42] Started version 0.9.2.
+
 
 diff --git a/ChangeLog b/ChangeLog
 index 871d055..8fdcdb0 100644
@@ -76,15 +41,14 @@
  # API version number (libtool)
  #
 -- 
-1.7.7.3
-
-
-From bf282a05cdbbb538a1cafbd7305cece14f5b1571 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From c12ee2b267b9dcfd092a298dfd9a8eec81ab3a0b Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 30 Nov 2010 14:57:03 +0000
-Subject: [PATCH 02/27] Initialize and delete object.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@577 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 02/42] Initialize and delete object.
+
 
 diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp
 index 0f3e9ec..d71c3ca 100644
@@ -110,29 +74,16 @@
  
  		void go(IMAPParser& parser, string& line, string::size_type* currentPos)
 -- 
-1.7.7.3
-
-
-From 941b10bca8e89ca61eebee1345ee3e5cbebd7530 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
-Date: Mon, 6 Dec 2010 11:57:44 +0000
-Subject: [PATCH 03/27] Updated deprecated function.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@578 5301114d-f842-0410-bbdd-996ee0417009
-
-SKIPPED
--- 
-1.7.7.3
-
-
-From 4a4c3a94db671ff7750b32ebf2c998a914717367 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From fd277afe87485c9d3377964794b76006c6d36a56 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Wed, 8 Dec 2010 08:52:54 +0000
-Subject: [PATCH 04/27] No extra space between ':' and '<' in MAIL FROM and
+Subject: [PATCH 03/42] No extra space between ':' and '<' in MAIL FROM and
  RCPT TO. Wait for server response after QUIT and
  before closing connection.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@579 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
 index 204daae..d9fb7b8 100644
@@ -165,15 +116,14 @@
  		if ((resp = readResponse())->getCode() != 250)
  		{
 -- 
-1.7.7.3
-
-
-From 4ea325c953f0cdc669b932aa4961a434656f3ecf Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From d64da50e879c0e480d2e65c43e3b903c3e80101f Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 10 Dec 2010 16:24:06 +0000
-Subject: [PATCH 05/27] Fixed unit test after bug fix.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@580 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 04/42] Fixed unit test after bug fix.
+
 
 diff --git a/tests/net/smtp/SMTPTransportTest.cpp b/tests/net/smtp/SMTPTransportTest.cpp
 index 5015552..6552f9e 100644
@@ -189,16 +139,15 @@
  				localSend("250 OK\r\n");
  			}
 -- 
-1.7.7.3
-
-
-From ff207927a5aab002f38af0224133b345ab458144 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 130d0aabda2a9988913ad201390796775dc16a65 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 10 Dec 2010 16:54:38 +0000
-Subject: [PATCH 06/27] Fixed boundary parsing (thanks to John van der Kamp,
+Subject: [PATCH 05/42] Fixed boundary parsing (thanks to John van der Kamp,
  Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@581 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/body.cpp b/src/body.cpp
 index 13dff6b..738d3e7 100644
@@ -278,16 +227,15 @@
  
  		vmime::bodyPart p;
 -- 
-1.7.7.3
-
-
-From 3f5172e47f75f64952adef349bec875416ae9b89 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From c63f37c888798f0e7e99aa03afda16445a72b7b2 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 21 Jan 2011 15:28:06 +0000
-Subject: [PATCH 07/27] Fixed possible infinite loop (thanks to John van der
+Subject: [PATCH 06/42] Fixed possible infinite loop (thanks to John van der
  Kamp, Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@582 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/word.cpp b/src/word.cpp
 index db720dc..1c1c1a6 100644
@@ -331,16 +279,15 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 4e9eb3191066dec7f17592c2ce099b16e6329941 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 1fafad8f913e700b350e6915de8be710fc2d1ced Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 28 Jan 2011 12:11:08 +0000
-Subject: [PATCH 08/27] Fixed possible read to invalid memory location (thanks
+Subject: [PATCH 07/42] Fixed possible read to invalid memory location (thanks
  to Alexander Konovalov).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@583 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/word.cpp b/src/word.cpp
 index 1c1c1a6..fa08d33 100644
@@ -356,17 +303,16 @@
  					else
  						state->lastCharIsSpace = false;
 -- 
-1.7.7.3
-
-
-From 07ebf241115eba44675223e307d212c772e1cc08 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 73298423f695d7c4441d44619e4b7f9de75f566e Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Wed, 9 Mar 2011 18:03:31 +0000
-Subject: [PATCH 09/27] Fixed bug #3174903. Fixed word parsing when buffer
+Subject: [PATCH 08/42] Fixed bug #3174903. Fixed word parsing when buffer
  does not end with NL. Fixed 'no encoding' when
  forced.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@584 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/body.cpp b/src/body.cpp
 index 738d3e7..8596833 100644
@@ -563,16 +509,15 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 22ca7dc23b6bbbc8cc6aedd569ec938ecae96e92 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 5f5757b9d4bb0febb1e2183578eb91e801a08038 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 27 Mar 2011 11:26:55 +0000
-Subject: [PATCH 10/27] Allow static linking in MXE. Added 'iconv'
+Subject: [PATCH 09/42] Allow static linking in mingw-cross-env. Added 'iconv'
  and uses 'ws2_32' instead of 'winsock32' (#3213487).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@585 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/SConstruct b/SConstruct
 index 55f9223..177f5b4 100644
@@ -597,16 +542,15 @@
  
  # -- getaddrinfo (POSIX)
 -- 
-1.7.7.3
-
-
-From 9e06cc39d47e2eba8f554b337d472cc995be0d9d Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 2b48b4a68ce3e9b9b1a3f485123af5938a568324 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Thu, 31 Mar 2011 19:13:03 +0000
-Subject: [PATCH 11/27] Flush stateful data from iconv (thanks to John van der
+Subject: [PATCH 10/42] Flush stateful data from iconv (thanks to John van der
  Kamp, Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@586 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/charsetConverter.cpp b/src/charsetConverter.cpp
 index 38b9e5e..2135788 100644
@@ -679,15 +623,14 @@
  	// Conversion to hexadecimal for easier debugging
  	static const vmime::string toHex(const vmime::string str)
 -- 
-1.7.7.3
-
-
-From 418a39a7d33921672bd1c4beb31c8a31bc87d8dd Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 8d2e039c5201e144ff08e2ff7cf9efe77fe4b3d0 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 10 Jun 2011 19:39:09 +0000
-Subject: [PATCH 12/27] Requested email change.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@587 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 11/42] Requested email change.
+
 
 diff --git a/AUTHORS b/AUTHORS
 index 20a0181..bbddb30 100644
@@ -703,15 +646,14 @@
   - Georg Sauthoff <gsauthof@techfak.uni-bielefeld.de>
   - Pierre Thierry <nowhere.man@levallois.eu.org> (patches for STL algorithms)
 -- 
-1.7.7.3
-
-
-From 4008955783ef566b98b16762c7bfa28df26e9198 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From cc6317f28ae0b61fea36e1bc78b09dc8300579f8 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 14 Jun 2011 18:37:54 +0000
-Subject: [PATCH 13/27] Fixed compilation issue following namespace change.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@588 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 12/42] Fixed compilation issue following namespace change.
+
 
 diff --git a/examples/example7.cpp b/examples/example7.cpp
 index 1ddb3d0..243b1da 100644
@@ -740,16 +682,15 @@
  		std::vector <vmime::string> props = e->getAvailableProperties();
  
 -- 
-1.7.7.3
-
-
-From e80db1ce802a45b71659d16d77ea47368beeabc1 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From a916d12d44ac43fc8e4729e0a91f4d6243f29a11 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 17:51:33 +0000
-Subject: [PATCH 14/27] Fixed parsing of an attachment filename that is
+Subject: [PATCH 13/42] Fixed parsing of an attachment filename that is
  between 66 and 76 characters long (Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@589 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/parameter.cpp b/src/parameter.cpp
 index 91a7e5c..f59d5ab 100644
@@ -766,16 +707,15 @@
  		switch (value[i])
  		{
 -- 
-1.7.7.3
-
-
-From 58316dddddbfe8a7c582aa52e9abff8ca3a227b6 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 9735165c57000a6368e91ce8852206a20930c1ca Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 18:08:12 +0000
-Subject: [PATCH 15/27] Correctly generate attachment names which are long and
+Subject: [PATCH 14/42] Correctly generate attachment names which are long and
  have high characters for Outlook Express (Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@590 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/parameter.cpp b/src/parameter.cpp
 index f59d5ab..d757e1b 100644
@@ -906,15 +846,14 @@
  #endif // !VMIME_ALWAYS_GENERATE_7BIT_PARAMETER
  
 -- 
-1.7.7.3
-
-
-From f7ad17cffea462faf8cbe4f785644da0f3ee812a Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 8d69ad6849d8d6b211674942157f2af8bcd51c26 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 18:16:49 +0000
-Subject: [PATCH 16/27] Alias for UTF-7 charset.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@591 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 15/42] Alias for UTF-7 charset.
+
 
 diff --git a/src/charset.cpp b/src/charset.cpp
 index e043186..0fda450 100644
@@ -942,17 +881,16 @@
  
  	if (newPosition)
 -- 
-1.7.7.3
-
-
-From eac20f47a33a7fdd617f9fd905b8029621259269 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From ccd95daf9cdd7171fc2027afa5d0ad80b0475ded Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 18:39:35 +0000
-Subject: [PATCH 17/27] Fixed messageBuilder to accept an empty mailbox group
+Subject: [PATCH 16/42] Fixed messageBuilder to accept an empty mailbox group
  in 'To:' field, to allow for undisclosed-recipients
  (Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@592 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/messageBuilder.cpp b/src/messageBuilder.cpp
 index 870d59e..3597b3a 100644
@@ -980,17 +918,16 @@
  	if (!m_to.isEmpty())
  		msg->getHeader()->To()->setValue(m_to);
 -- 
-1.7.7.3
-
-
-From 1e5dfa80a63b0a7fe90406ce4a3de1593f2e4045 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 583e25bcdee132e53e0792cd8f0d8e535cabb743 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 18:49:55 +0000
-Subject: [PATCH 18/27] Added support for mailboxes that specify an (encoded)
+Subject: [PATCH 17/42] Added support for mailboxes that specify an (encoded)
  full name with an empty email address, set by a <>
  marker (Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@593 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/mailbox.cpp b/src/mailbox.cpp
 index 5cb0139..fea7479 100644
@@ -1054,15 +991,14 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 960f2195516eb776eea7b7e4f92612192edfdcd9 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 461b92f84d5c16b297d33610fcd89fc7ca5a161a Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 24 Jun 2011 15:46:23 +0000
-Subject: [PATCH 19/27] Added missing libs in pkg-config file.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@594 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 18/42] Added missing libs in pkg-config file.
+
 
 diff --git a/SConstruct b/SConstruct
 index 177f5b4..37c0ac6 100644
@@ -1078,16 +1014,15 @@
  	vmime_pc_in.write("Cflags: -I${includedir}/ @LIBGNUTLS_CFLAGS@\n")
  	vmime_pc_in.close()
 -- 
-1.7.7.3
-
-
-From 9f9084b71b4e3c96edc6513020984ef76fe26e0c Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 2b2c0abd02a17ccff7d49e266b9854f4ea47f8e4 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sat, 25 Jun 2011 17:07:53 +0000
-Subject: [PATCH 20/27] Fixed parsing of empty body parts (thanks to John van
+Subject: [PATCH 19/42] Fixed parsing of empty body parts (thanks to John van
  der Kamp, from Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@595 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/body.cpp b/src/body.cpp
 index 8596833..9d7d57f 100644
@@ -1142,16 +1077,15 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 318848aa87761214a6f21c1ea1a9776a7bcbf83c Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 2648d744da0e2e744c7959999ac513c3016072b4 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 26 Jun 2011 08:19:11 +0000
-Subject: [PATCH 21/27] Use gnutls_priority_set_direct() instead of GNUTLS
+Subject: [PATCH 20/42] Use gnutls_priority_set_direct() instead of GNUTLS
  deprecated functions.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@596 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/SConstruct b/SConstruct
 index 37c0ac6..01ad3f3 100644
@@ -1252,15 +1186,14 @@
  	gnutls_credentials_set(*m_gnutlsSession,
  		GNUTLS_CRD_ANON, g_gnutlsGlobal.anonCred);
 -- 
-1.7.7.3
-
-
-From 70a0282a3f96febf973475a298ac95ffaab82c3c Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 1060121ffd4315c3158ffc001040f4f705514e7a Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 26 Jun 2011 12:47:25 +0000
-Subject: [PATCH 22/27] Fixed encoding of whitespace. Fixed old test case.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@597 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 21/42] Fixed encoding of whitespace. Fixed old test case.
+
 
 diff --git a/src/text.cpp b/src/text.cpp
 index 2454456..66c3b35 100644
@@ -1346,15 +1279,14 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 7d399583a458abe5cd16ce0974bd4dc11daba9f6 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From dc6dc039fc0edccf4630894fa6ed8cd4bf3bb3ce Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sat, 20 Aug 2011 06:35:06 +0000
-Subject: [PATCH 23/27] Use gnutls_strerror() for reporting errors.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@598 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 22/42] Use gnutls_strerror() for reporting errors.
+
 
 diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp
 index af73a05..7426a73 100644
@@ -1497,16 +1429,15 @@
  
  
 -- 
-1.7.7.3
-
-
-From aae321dede5e725140534a08a8b2ee997faa30be Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From 7ea6fc3737ef36407e1c90f3aa05f89a39bdefb7 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 21 Aug 2011 08:55:46 +0000
-Subject: [PATCH 24/27] Removed dependency on gcrypt for gnutls version >=
+Subject: [PATCH 23/42] Removed dependency on gcrypt for gnutls version >=
  2.12.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@599 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp
 index 7426a73..d3f6d49 100644
@@ -1551,16 +1482,15 @@
  
  		gnutls_global_init();
 -- 
-1.7.7.3
-
-
-From af1e5664afb663fb7d26d468adf675fb1b3f8737 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From f21c55be642b166a2f0518ace2b179bed3916b23 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 21 Aug 2011 09:04:46 +0000
-Subject: [PATCH 25/27] Fixed HAVE_GNUTLS_PRIORITY_FUNCS never defined when
+Subject: [PATCH 24/42] Fixed HAVE_GNUTLS_PRIORITY_FUNCS never defined when
  configured with no TLS support.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@600 5301114d-f842-0410-bbdd-996ee0417009
 
 diff --git a/SConstruct b/SConstruct
 index 01ad3f3..11e884b 100644
@@ -1584,15 +1514,14 @@
  
  AC_SUBST(LIBGNUTLS_CFLAGS)
 -- 
-1.7.7.3
-
-
-From 41079b2f188bb4a6d8aea9ec1328653faee3e2c9 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From d4e66226a696745adafa1767210580f8fbb7ae00 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 15 Nov 2011 11:40:42 +0000
-Subject: [PATCH 26/27] GNU TLS 3 has no 'extra' (thanks to mabrand).
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@601 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 25/42] GNU TLS 3 has no 'extra' (thanks to mabrand).
+
 
 diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp
 index d3f6d49..cb50acc 100644
@@ -1609,15 +1538,14 @@
  #include "vmime/config.hpp"
  
 -- 
-1.7.7.3
-
-
-From eafae52d9b8ec9682c229090b6208092b1d1e6f1 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.4
+
+
+From bacbe512e406d22f6acc83597fcdfc2d624cf82b Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 15 Nov 2011 11:46:07 +0000
-Subject: [PATCH 27/27] Set Diffie-Hellman prime size (bug SF#3434852).
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@602 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 26/42] Set Diffie-Hellman prime size (bug SF#3434852).
+
 
 diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp
 index cb50acc..0606808 100644
@@ -1632,5 +1560,8757 @@
  	if ((res = gnutls_priority_set_direct
  		(*m_gnutlsSession, "NORMAL:%SSL3_RECORD_VERSION", NULL)) != 0)
 -- 
-1.7.7.3
-
+1.7.10.4
+
+
+From 6574b60a303c5d864e840aa23959656bb2803485 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 22 Dec 2011 08:51:28 +0000
+Subject: [PATCH 27/42] Updated coding conventions.
+
+
+diff --git a/HACKING b/HACKING
+index 4f35a53..f51d738 100644
+--- a/HACKING
++++ b/HACKING
+@@ -1,10 +1,10 @@
+ 
+-This file contains coding guidelines for VMime. You should follow these
+-guidelines if you want to contribute to VMime. It guarantees some minimal
+-quality of the code.
++This file contains coding guidelines for VMime. You should follow them
++if you want to contribute to VMime. The rules below are not guidelines
++or recommendations, but strict rules.
+ 
+ 
+-1. General guidelines
++1. General rules
+      1.1. Language
+      1.2. Unit tests
+      1.3. CVS
+@@ -18,19 +18,22 @@ quality of the code.
+      2.5. Line length
+      2.6. Spaces and parentheses
+      2.7. End-of-line character
++     2.8. Short functions
++     2.9. Limit Variable Scope
+ 3. Naming conventions
+      3.1. Classes
+      3.2. Variables/parameters/member variables
+      3.3. Member variables
+      3.4. Files
+      3.5. Namespaces
++     3.6. Constants
+ 4. Comments
+ 5. Miscellaneous
+ 
+ 
+ 
+-1. General guidelines
+-=====================
++1. General rules
++================
+ 
+ 1.1. Language
+ -------------
+@@ -50,7 +53,7 @@ When you fix a bug, also add a new test case to ensure the bug will not
+ happen anymore.
+ 
+ 
+-1.3. CVS
++1.3. SVN
+ --------
+ 
+ Each commit MUST be done with a message ('-m' flag) that briefly describes what
+@@ -154,7 +157,11 @@ Except when body spans over multiple lines:
+ 2.5. Line length
+ ----------------
+ 
+-Line length should not exceed 80 characters.
++Each line of text should not exceed 80 characters.
++
++Exception: if a comment line contains an example command or a literal URL
++longer than 100 characters, that line may be longer than 100 characters
++for ease of cut and paste.
+ 
+ 
+ 2.6. Spaces and parentheses
+@@ -193,6 +200,30 @@ Configure your editor to use "\n" (UNIX convention) for end-of-line sequence,
+ and not "\r\n" (Windows), nor "\n\r", nor any other combination.
+ 
+ 
++2.8. Short functions
++--------------------
++
++To the extent that it is feasible, functions should be kept small and focused.
++It is, however, recognized that long functions are sometimes appropriate, so no
++hard limit is placed on method length. If a function exceeds 40 lines or so,
++think about whether it can be broken up without harming the structure of the
++program.
++
++
++2.9. Limit Variable Scope
++-------------------------
++
++The scope of local variables should be kept to a minimum. By doing so, you
++increase the readability and maintainability of your code and reduce the
++likelihood of error. Each variable should be declared in the innermost block
++that encloses all uses of the variable.
++
++Local variables should be declared at the point they are first used. Nearly
++every local variable declaration should contain an initializer. If you don't
++yet have enough information to initialize a variable sensibly, you should
++postpone the declaration until you do.
++
++
+ 
+ 3. Naming conventions
+ =====================
+@@ -255,6 +286,12 @@ Implementation files must be placed in 'src/' directory.
+ Namespaces are named exactly like variables.
+ 
+ 
++3.6. Constants
++--------------
++
++Constants are ALL_CAPS_WITH_UNDERSCORES.
++
++
+ 
+ 4. Comments
+ ===========
+-- 
+1.7.10.4
+
+
+From 130e5223dea0af2f8d9d01cca7845be4e1a08d13 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 11:46:39 +0200
+Subject: [PATCH 28/42] Added function to retrieve sequence numbers of
+ messages whose UID is greater or equal than a
+ specified UID (thanks to Zahi Mashael).
+
+
+diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
+index 0122d21..50a2f2b 100644
+--- a/src/net/imap/IMAPFolder.cpp
++++ b/src/net/imap/IMAPFolder.cpp
+@@ -1772,6 +1772,62 @@ void IMAPFolder::status(int& count, int& unseen)
+ }
+ 
+ 
++std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid& uid)
++{
++	std::vector<int> v;
++
++	std::ostringstream command;
++	command.imbue(std::locale::classic());
++
++	command << "SEARCH UID " << uid;
++
++	// Send the request
++	m_connection->send(true, command.str(), true);
++
++	// Get the response
++	utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
++
++	if (resp->isBad() ||
++	    resp->response_done()->response_tagged()->resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
++	{
++		throw exceptions::command_error("SEARCH",
++			m_connection->getParser()->lastLine(), "bad response");
++	}
++
++	const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList = resp->continue_req_or_response_data();
++
++	for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
++	     it = respDataList.begin() ; it != respDataList.end() ; ++it)
++	{
++		if ((*it)->response_data() == NULL)
++		{
++			throw exceptions::command_error("SEARCH",
++				m_connection->getParser()->lastLine(), "invalid response");
++		}
++
++		const IMAPParser::mailbox_data* mailboxData =
++			(*it)->response_data()->mailbox_data();
++
++		// We are only interested in responses of type "SEARCH"
++		if (mailboxData == NULL ||
++		    mailboxData->type() != IMAPParser::mailbox_data::SEARCH)
++		{
++			continue;
++		}
++
++		for (std::vector <IMAPParser::nz_number*>::const_iterator
++				it = mailboxData->search_nz_number_list().begin() ;
++		     it != mailboxData->search_nz_number_list().end();
++		     ++it)
++		{
++			v.push_back((*it)->value());
++		}
++	}
++
++	return v;
++}
++
++
+ } // imap
+ } // net
+ } // vmime
+diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
+index dd680c9..d11ae3b 100644
+--- a/src/net/maildir/maildirFolder.cpp
++++ b/src/net/maildir/maildirFolder.cpp
+@@ -1363,6 +1363,12 @@ const utility::file::path maildirFolder::getMessageFSPath(const int number) cons
+ }
+ 
+ 
++std::vector <int> maildirFolder::getMessageNumbersStartingOnUID(const message::uid& /* uid */)
++{
++	throw exceptions::operation_not_supported();
++}
++
++
+ } // maildir
+ } // net
+ } // vmime
+diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp
+index d5fc687..e085609 100644
+--- a/src/net/pop3/POP3Folder.cpp
++++ b/src/net/pop3/POP3Folder.cpp
+@@ -843,6 +843,12 @@ void POP3Folder::expunge()
+ }
+ 
+ 
++std::vector <int> POP3Folder::getMessageNumbersStartingOnUID(const message::uid& /* uid */)
++{
++	throw exceptions::operation_not_supported();
++}
++
++
+ } // pop3
+ } // net
+ } // vmime
+diff --git a/vmime/net/folder.hpp b/vmime/net/folder.hpp
+index b20e9c9..df9cbaf 100644
+--- a/vmime/net/folder.hpp
++++ b/vmime/net/folder.hpp
+@@ -383,6 +383,13 @@ public:
+ 	  */
+ 	virtual int getFetchCapabilities() const = 0;
+ 
++	/** Return the sequence numbers of messages whose UID equal or greater than uid
++ 	  *
++ 	  * @param uid the uid of the first message
++ 	  * @throw net_exception if an error occurs
++ 	  */
++	virtual std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid) = 0;
++
+ 	// Event listeners
+ 	void addMessageChangedListener(events::messageChangedListener* l);
+ 	void removeMessageChangedListener(events::messageChangedListener* l);
+diff --git a/vmime/net/imap/IMAPFolder.hpp b/vmime/net/imap/IMAPFolder.hpp
+index dec3878..cc52596 100644
+--- a/vmime/net/imap/IMAPFolder.hpp
++++ b/vmime/net/imap/IMAPFolder.hpp
+@@ -120,6 +120,8 @@ public:
+ 
+ 	int getFetchCapabilities() const;
+ 
++	std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
++
+ private:
+ 
+ 	void registerMessage(IMAPMessage* msg);
+diff --git a/vmime/net/maildir/maildirFolder.hpp b/vmime/net/maildir/maildirFolder.hpp
+index 7474b1a..68b5b89 100644
+--- a/vmime/net/maildir/maildirFolder.hpp
++++ b/vmime/net/maildir/maildirFolder.hpp
+@@ -121,6 +121,8 @@ public:
+ 
+ 	int getFetchCapabilities() const;
+ 
++	std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
++
+ private:
+ 
+ 	void scanFolder();
+diff --git a/vmime/net/pop3/POP3Folder.hpp b/vmime/net/pop3/POP3Folder.hpp
+index abaa8eb..c482908 100644
+--- a/vmime/net/pop3/POP3Folder.hpp
++++ b/vmime/net/pop3/POP3Folder.hpp
+@@ -119,6 +119,8 @@ public:
+ 
+ 	int getFetchCapabilities() const;
+ 
++	std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
++
+ private:
+ 
+ 	void registerMessage(POP3Message* msg);
+-- 
+1.7.10.4
+
+
+From 3f1a565b8b532f0d11a13d3f6d763b00c8ce625b Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 11:55:07 +0200
+Subject: [PATCH 29/42] Added .gitignore.
+
+
+diff --git a/.gitignore b/.gitignore
+new file mode 100644
+index 0000000..44e03a8
+--- /dev/null
++++ b/.gitignore
+@@ -0,0 +1,11 @@
++*.o
++*.swp
++build/
++
++/libvmime.a
++/vmime.pc
++/vmime/config.hpp
++
++# SConstruct
++.sconsign.dblite
++/options.cache
+-- 
+1.7.10.4
+
+
+From 5937bcda0fac9cb80d0cecbaa663ecdfe2839c09 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 12:08:01 +0200
+Subject: [PATCH 30/42] Added check before dereferencing.
+
+
+diff --git a/vmime/utility/smartPtr.hpp b/vmime/utility/smartPtr.hpp
+index c448632..df63685 100644
+--- a/vmime/utility/smartPtr.hpp
++++ b/vmime/utility/smartPtr.hpp
+@@ -338,7 +338,9 @@ protected:
+ 	{
+ 		if (m_ptr)
+ 		{
+-			m_ptr->getRefManager()->releaseStrong();
++			if (m_ptr->getRefManager())
++				m_ptr->getRefManager()->releaseStrong();
++
+ 			m_ptr = 0;
+ 		}
+ 	}
+-- 
+1.7.10.4
+
+
+From b0d74ce63ea9563ef4b218bce2497bd668dfad29 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 12:34:51 +0200
+Subject: [PATCH 31/42] Updated README.
+
+
+diff --git a/README b/README
+index 6921cea..7db9175 100644
+--- a/README
++++ b/README
+@@ -1,2 +1,30 @@
+ 
+-TODO
++VMime is a powerful C++ class library for working with RFC-822 and MIME messages
++and Internet messaging services like IMAP, POP or SMTP.
++
++With VMime you can parse, generate and modify messages, and also connect to store
++and transport services to receive or send messages over the Internet. The library
++offers all the features to build a complete mail client.
++
++Key Features
++------------
++
++* it is free software! GNU GPL license (Commercial licenses available!)
++* fully RFC-compliant implementation
++* object-oriented and modular design
++* very easy-to-use (intuitive design)
++* well documented code
++* very high reliability
++* maximum portability
++
++Features Overview
++-----------------
++
++* RFC-2822 and multipart messages
++* aggregate documents and embedded objects
++* 8-bit MIME and encoded word extensions
++* full support for attachments
++* POP3, IMAP, SMTP, maildir and sendmail
++* SSL/TLS security layer and X.509 certificates (using GNU TLS)
++* SASL authentication (using GNU SASL)
++
+-- 
+1.7.10.4
+
+
+From 350fada21a4f11c2f633a3cde1f2195efefe7e32 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 22:10:54 +0200
+Subject: [PATCH 32/42] Added test: Ensure '7bit' encoding is used when body
+ is 7-bit only.
+
+
+diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
+index 075b8f9..e1d47a3 100644
+--- a/tests/parser/bodyPartTest.cpp
++++ b/tests/parser/bodyPartTest.cpp
+@@ -37,6 +37,7 @@ VMIME_TEST_SUITE_BEGIN
+ 		VMIME_TEST(testPrologEpilog)
+ 		VMIME_TEST(testPrologEncoding)
+ 		VMIME_TEST(testSuccessiveBoundaries)
++		VMIME_TEST(testGenerate7bit)
+ 	VMIME_TEST_LIST_END
+ 
+ 
+@@ -200,5 +201,18 @@ VMIME_TEST_SUITE_BEGIN
+ 		VASSERT_EQ("part2-body", "", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
+ 	}
+ 
++	/** Ensure '7bit' encoding is used when body is 7-bit only. */
++	void testGenerate7bit()
++	{
++		vmime::ref <vmime::plainTextPart> p1 = vmime::create <vmime::plainTextPart>();
++		p1->setText(vmime::create <vmime::stringContentHandler>("Part1 is US-ASCII only."));
++
++		vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
++		p1->generateIn(msg, msg);
++
++		vmime::ref <vmime::header> header1 = msg->getBody()->getPartAt(0)->getHeader();
++		VASSERT_EQ("1", "7bit", header1->ContentTransferEncoding()->getValue()->generate());
++	}
++
+ VMIME_TEST_SUITE_END
+ 
+-- 
+1.7.10.4
+
+
+From 6c877ea41a2e408df61ac6f988c3bae7e0821141 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 22:29:32 +0200
+Subject: [PATCH 33/42] Added tests for Quoted-Printable encoding.
+
+
+diff --git a/tests/utility/encoderTest.cpp b/tests/utility/encoderTest.cpp
+index f2d42b6..b2d6bc8 100644
+--- a/tests/utility/encoderTest.cpp
++++ b/tests/utility/encoderTest.cpp
+@@ -33,6 +33,8 @@ VMIME_TEST_SUITE_BEGIN
+ 	VMIME_TEST_LIST_BEGIN
+ 		VMIME_TEST(testBase64)
+ 		VMIME_TEST(testQuotedPrintable)
++		VMIME_TEST(testQuotedPrintable_SoftLineBreaks)
++		VMIME_TEST(testQuotedPrintable_CRLF)
+ 		VMIME_TEST(testQuotedPrintable_RFC2047)
+ 	VMIME_TEST_LIST_END
+ 
+@@ -288,6 +290,35 @@ VMIME_TEST_SUITE_BEGIN
+ 		}
+ 	}
+ 
++	/** Tests Soft Line Breaks (RFC-2047/6.7(5). */
++	void testQuotedPrintable_SoftLineBreaks()
++	{
++		VASSERT_EQ("1", "Now's the time=\r\n"
++		                " for all folk =\r\n"
++		                "to come to the=\r\n"
++		                " aid of their =\r\n"
++		                "country.",
++		                encode("quoted-printable", "Now's the time for all folk "
++		                                           "to come to the aid of their country.", 15));
++	}
++
++	/** In text mode, ensure line breaks in QP-encoded text are represented
++	  * by a CRLF sequence, as per RFC-2047/6.7(4). */
++	void testQuotedPrintable_CRLF()
++	{
++		vmime::propertySet encProps;
++
++		// in "text" mode
++		encProps["text"] = true;
++		VASSERT_EQ("text", "line1\r\nline2",
++		           encode("quoted-printable", "line1\r\nline2", 80, encProps));
++
++		// in "binary" mode
++		encProps["text"] = false;
++		VASSERT_EQ("binary", "line1=0D=0Aline2",
++		           encode("quoted-printable", "line1\r\nline2", 80, encProps));
++	}
++
+ 	void testQuotedPrintable_RFC2047()
+ 	{
+ 		/*
+-- 
+1.7.10.4
+
+
+From e88f062ab58654aee3cf45f94e8a5dd6c1256279 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 23:15:04 +0200
+Subject: [PATCH 34/42] Fixed wrong encoding of line breaks in QP-encoded text
+ (issue #7).
+
+
+diff --git a/src/encoding.cpp b/src/encoding.cpp
+index 0919d44..b4e79db 100644
+--- a/src/encoding.cpp
++++ b/src/encoding.cpp
+@@ -34,19 +34,28 @@ namespace vmime
+ 
+ 
+ encoding::encoding()
+-	: m_name(encodingTypes::SEVEN_BIT)
++	: m_name(encodingTypes::SEVEN_BIT),
++	  m_usage(USAGE_UNKNOWN)
+ {
+ }
+ 
+ 
+ encoding::encoding(const string& name)
+-	: m_name(utility::stringUtils::toLower(name))
++	: m_name(utility::stringUtils::toLower(name)),
++	  m_usage(USAGE_UNKNOWN)
++{
++}
++
++
++encoding::encoding(const string& name, const EncodingUsage usage)
++	: m_name(utility::stringUtils::toLower(name)),
++	  m_usage(usage)
+ {
+ }
+ 
+ 
+ encoding::encoding(const encoding& enc)
+-	: headerFieldValue(), m_name(enc.m_name)
++	: headerFieldValue(), m_name(enc.m_name), m_usage(enc.m_usage)
+ {
+ }
+ 
+@@ -54,6 +63,8 @@ encoding::encoding(const encoding& enc)
+ void encoding::parse(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
++	m_usage = USAGE_UNKNOWN;
++
+ 	m_name = utility::stringUtils::toLower(utility::stringUtils::trim
+ 		(utility::stringUtils::unquote(utility::stringUtils::trim
+ 			(string(buffer.begin() + position, buffer.begin() + end)))));
+@@ -80,7 +91,14 @@ void encoding::generate(utility::outputStream& os, const string::size_type /* ma
+ 
+ ref <utility::encoder::encoder> encoding::getEncoder() const
+ {
+-	return (utility::encoder::encoderFactory::getInstance()->create(generate()));
++	ref <utility::encoder::encoder> encoder =
++		utility::encoder::encoderFactory::getInstance()->create(generate());
++
++	// FIXME: this should not be here (move me into QP encoder instead?)
++	if (m_usage == USAGE_TEXT && m_name == encodingTypes::QUOTED_PRINTABLE)
++		encoder->getProperties()["text"] = true;
++
++	return encoder;
+ }
+ 
+ 
+@@ -94,6 +112,7 @@ encoding& encoding::operator=(const encoding& other)
+ encoding& encoding::operator=(const string& name)
+ {
+ 	m_name = utility::stringUtils::toLower(name);
++	m_usage = USAGE_UNKNOWN;
+ 	return (*this);
+ }
+ 
+@@ -167,6 +186,8 @@ const encoding encoding::decideImpl
+ const encoding encoding::decide
+ 	(ref <const contentHandler> data, const EncodingUsage usage)
+ {
++	encoding enc;
++
+ 	if (usage == USAGE_TEXT && data->isBuffered() &&
+ 	    data->getLength() > 0 && data->getLength() < 32768)
+ 	{
+@@ -177,12 +198,16 @@ const encoding encoding::decide
+ 		data->extract(os);
+ 		os.flush();
+ 
+-		return decideImpl(buffer.begin(), buffer.end());
++		enc = decideImpl(buffer.begin(), buffer.end());
+ 	}
+ 	else
+ 	{
+-		return encoding(encodingTypes::BASE64);
++		enc = encoding(encodingTypes::BASE64);
+ 	}
++
++	enc.setUsage(usage);
++
++	return enc;
+ }
+ 
+ 
+@@ -194,7 +219,10 @@ const encoding encoding::decide(ref <const contentHandler> data,
+ 		encoding recEncoding;
+ 
+ 		if (chset.getRecommendedEncoding(recEncoding))
++		{
++			recEncoding.setUsage(usage);
+ 			return recEncoding;
++		}
+ 	}
+ 
+ 	return decide(data, usage);
+@@ -227,6 +255,18 @@ void encoding::setName(const string& name)
+ }
+ 
+ 
++encoding::EncodingUsage encoding::getUsage() const
++{
++	return m_usage;
++}
++
++
++void encoding::setUsage(const EncodingUsage usage)
++{
++	m_usage = usage;
++}
++
++
+ const std::vector <ref <const component> > encoding::getChildComponents() const
+ {
+ 	return std::vector <ref <const component> >();
+diff --git a/src/utility/encoder/qpEncoder.cpp b/src/utility/encoder/qpEncoder.cpp
+index aa95022..ab8db2e 100644
+--- a/src/utility/encoder/qpEncoder.cpp
++++ b/src/utility/encoder/qpEncoder.cpp
+@@ -292,14 +292,15 @@ utility::stream::size_type qpEncoder::encode(utility::inputStream& in,
+ 			case 13:  // CR
+ 			case 10:  // LF
+ 			{
+-				// Text mode (where using CRLF or LF or ... does not
+-				// care for a new line...)
+-				if (text)
++				// RFC-2045/6.7(4)
++
++				// Text data
++				if (text && !rfc2047)
+ 				{
+ 					outBuffer[outBufferPos++] = c;
+ 					++curCol;
+ 				}
+-				// Binary mode (where CR and LF bytes are important!)
++				// Binary data
+ 				else
+ 				{
+ 					QP_ENCODE_HEX(c);
+diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
+index e1d47a3..9d51262 100644
+--- a/tests/parser/bodyPartTest.cpp
++++ b/tests/parser/bodyPartTest.cpp
+@@ -38,6 +38,7 @@ VMIME_TEST_SUITE_BEGIN
+ 		VMIME_TEST(testPrologEncoding)
+ 		VMIME_TEST(testSuccessiveBoundaries)
+ 		VMIME_TEST(testGenerate7bit)
++		VMIME_TEST(testTextUsageForQPEncoding)
+ 	VMIME_TEST_LIST_END
+ 
+ 
+@@ -214,5 +215,28 @@ VMIME_TEST_SUITE_BEGIN
+ 		VASSERT_EQ("1", "7bit", header1->ContentTransferEncoding()->getValue()->generate());
+ 	}
+ 
++	void testTextUsageForQPEncoding()
++	{
++		vmime::ref <vmime::plainTextPart> part = vmime::create <vmime::plainTextPart>();
++		part->setText(vmime::create <vmime::stringContentHandler>("Part1-line1\r\nPart1-line2\r\n\x89"));
++
++		vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
++		part->generateIn(msg, msg);
++
++		vmime::ref <vmime::body> body = msg->getBody()->getPartAt(0)->getBody();
++		vmime::ref <vmime::header> header = msg->getBody()->getPartAt(0)->getHeader();
++
++		std::ostringstream oss;
++		vmime::utility::outputStreamAdapter os(oss);
++		body->generate(os, 80);
++
++		VASSERT_EQ("1", "quoted-printable", header->ContentTransferEncoding()->getValue()->generate());
++
++		// This should *NOT* be:
++		//    Part1-line1=0D=0APart1-line2=0D=0A=89
++		VASSERT_EQ("2", "Part1-line1\r\nPart1-line2\r\n=89", oss.str());
++	}
++
++
+ VMIME_TEST_SUITE_END
+ 
+diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp
+index ba78081..42f5246 100644
+--- a/vmime/encoding.hpp
++++ b/vmime/encoding.hpp
+@@ -47,6 +47,7 @@ public:
+ 
+ 	enum EncodingUsage
+ 	{
++		USAGE_UNKNOWN,
+ 		USAGE_TEXT,         /**< Use for body text. */
+ 		USAGE_BINARY_DATA   /**< Use for attachment, image... */
+ 	};
+@@ -54,6 +55,7 @@ public:
+ 
+ 	encoding();
+ 	explicit encoding(const string& name);
++	encoding(const string& name, const EncodingUsage usage);
+ 	encoding(const encoding& enc);
+ 
+ public:
+@@ -72,6 +74,19 @@ public:
+ 	  */
+ 	void setName(const string& name);
+ 
++	/** Return the type of contents this encoding is used for.
++	  * See the EncodingUsage enum.
++	  */
++	EncodingUsage getUsage() const;
++
++	/** Set the type of contents this encoding is used for.
++	  * See the EncodingUsage enum.
++	  *
++	  * @param usage type of contents
++	  */
++	void setUsage(const EncodingUsage usage);
++
++
+ 	encoding& operator=(const encoding& other);
+ 	encoding& operator=(const string& name);
+ 
+@@ -113,6 +128,7 @@ public:
+ private:
+ 
+ 	string m_name;
++	EncodingUsage m_usage;
+ 
+ 	/** Decide which encoding to use based on the specified data.
+ 	  *
+-- 
+1.7.10.4
+
+
+From ea77bdba96588345090e3de81d9d6af116edeeb5 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Fri, 6 Apr 2012 22:26:18 +0200
+Subject: [PATCH 35/42] Fixed memory leak.
+
+
+diff --git a/src/net/tls/TLSSocket.cpp b/src/net/tls/TLSSocket.cpp
+index dab0338..3cccc1e 100644
+--- a/src/net/tls/TLSSocket.cpp
++++ b/src/net/tls/TLSSocket.cpp
+@@ -50,6 +50,12 @@ TLSSocket::TLSSocket(ref <TLSSession> session, ref <socket> sok)
+ 
+ TLSSocket::~TLSSocket()
+ {
++	if (m_ex)
++	{
++		delete m_ex;
++		m_ex = NULL;
++	}
++
+ 	try
+ 	{
+ 		disconnect();
+-- 
+1.7.10.4
+
+
+From 440d491fd6da134fcb5f19416743e8f2044556bf Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Sat, 14 Apr 2012 13:46:05 +0200
+Subject: [PATCH 36/42] Split stream.hpp/.cpp into multiple source files.
+
+
+diff --git a/SConstruct b/SConstruct
+index 11e884b..ea5c4eb 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -144,6 +144,20 @@ libvmime_sources = [
+ 	'utility/smartPtr.cpp', 'utility/smartPtr.hpp',
+ 	'utility/smartPtrInt.cpp', 'utility/smartPtrInt.hpp',
+ 	'utility/stream.cpp', 'utility/stream.hpp',
++	'utility/streamUtils.cpp', 'utility/streamUtils.hpp',
++	'utility/filteredStream.cpp', 'utility/filteredStream.hpp',
++	'utility/inputStream.cpp', 'utility/inputStream.hpp',
++	'utility/inputStreamAdapter.cpp', 'utility/inputStreamAdapter.hpp',
++	'utility/inputStreamByteBufferAdapter.cpp', 'utility/inputStreamByteBufferAdapter.hpp',
++	'utility/inputStreamPointerAdapter.cpp', 'utility/inputStreamPointerAdapter.hpp',
++	'utility/inputStreamSocketAdapter.cpp', 'utility/inputStreamSocketAdapter.hpp',
++	'utility/inputStreamStringAdapter.cpp', 'utility/inputStreamStringAdapter.hpp',
++	'utility/inputStreamStringProxyAdapter.cpp', 'utility/inputStreamStringProxyAdapter.hpp',
++	'utility/outputStream.cpp', 'utility/outputStream.hpp',
++	'utility/outputStreamAdapter.cpp', 'utility/outputStreamAdapter.hpp',
++	'utility/outputStreamByteArrayAdapter.cpp', 'utility/outputStreamByteArrayAdapter.hpp',
++	'utility/outputStreamSocketAdapter.cpp', 'utility/outputStreamSocketAdapter.hpp',
++	'utility/outputStreamStringAdapter.cpp', 'utility/outputStreamStringAdapter.hpp',
+ 	'utility/stringProxy.cpp', 'utility/stringProxy.hpp',
+ 	'utility/stringUtils.cpp', 'utility/stringUtils.hpp',
+ 	'utility/url.cpp', 'utility/url.hpp',
+diff --git a/src/charsetConverter.cpp b/src/charsetConverter.cpp
+index 2135788..cf75bdd 100644
+--- a/src/charsetConverter.cpp
++++ b/src/charsetConverter.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/charsetConverter.hpp"
+ #include "vmime/exception.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
+ 
+ 
+ extern "C"
+diff --git a/src/component.cpp b/src/component.cpp
+index fbf677b..139cf66 100644
+--- a/src/component.cpp
++++ b/src/component.cpp
+@@ -23,6 +23,7 @@
+ 
+ #include "vmime/component.hpp"
+ #include "vmime/base.hpp"
++#include "vmime/utility/outputStreamAdapter.hpp"
+ 
+ #include <sstream>
+ 
+diff --git a/src/encoding.cpp b/src/encoding.cpp
+index b4e79db..5d99ab6 100644
+--- a/src/encoding.cpp
++++ b/src/encoding.cpp
+@@ -24,6 +24,7 @@
+ #include "vmime/encoding.hpp"
+ #include "vmime/contentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamStringAdapter.hpp"
+ #include "vmime/utility/encoder/encoderFactory.hpp"
+ 
+ #include <algorithm>
+diff --git a/src/fileAttachment.cpp b/src/fileAttachment.cpp
+index da7c4b7..cb23cd0 100644
+--- a/src/fileAttachment.cpp
++++ b/src/fileAttachment.cpp
+@@ -28,6 +28,7 @@
+ #include "vmime/exception.hpp"
+ 
+ #include "vmime/streamContentHandler.hpp"
++#include "vmime/utility/inputStreamPointerAdapter.hpp"
+ 
+ #include "vmime/contentDispositionField.hpp"
+ 
+diff --git a/src/generatedMessageAttachment.cpp b/src/generatedMessageAttachment.cpp
+index e9bd1a6..443a9d3 100644
+--- a/src/generatedMessageAttachment.cpp
++++ b/src/generatedMessageAttachment.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/generatedMessageAttachment.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/htmlTextPart.cpp b/src/htmlTextPart.cpp
+index c845b57..98524af 100644
+--- a/src/htmlTextPart.cpp
++++ b/src/htmlTextPart.cpp
+@@ -31,6 +31,8 @@
+ #include "vmime/emptyContentHandler.hpp"
+ #include "vmime/stringContentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/mdn/MDNHelper.cpp b/src/mdn/MDNHelper.cpp
+index b419b85..1dd7ff3 100644
+--- a/src/mdn/MDNHelper.cpp
++++ b/src/mdn/MDNHelper.cpp
+@@ -31,6 +31,8 @@
+ #include "vmime/path.hpp"
+ #include "vmime/dateTime.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace mdn {
+diff --git a/src/mdn/receivedMDNInfos.cpp b/src/mdn/receivedMDNInfos.cpp
+index cff211c..f97a58d 100644
+--- a/src/mdn/receivedMDNInfos.cpp
++++ b/src/mdn/receivedMDNInfos.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/mdn/receivedMDNInfos.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace mdn {
+diff --git a/src/message.cpp b/src/message.cpp
+index 6f4b046..1b4f086 100644
+--- a/src/message.cpp
++++ b/src/message.cpp
+@@ -24,6 +24,8 @@
+ #include "vmime/message.hpp"
+ #include "vmime/options.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <sstream>
+ 
+ 
+diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
+index 50a2f2b..81bf386 100644
+--- a/src/net/imap/IMAPFolder.cpp
++++ b/src/net/imap/IMAPFolder.cpp
+@@ -34,6 +34,8 @@
+ #include "vmime/exception.hpp"
+ #include "vmime/utility/smartPtr.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <algorithm>
+ #include <sstream>
+ 
+diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp
+index bc661ed..702d5f2 100644
+--- a/src/net/imap/IMAPMessage.cpp
++++ b/src/net/imap/IMAPMessage.cpp
+@@ -31,6 +31,8 @@
+ #include "vmime/net/imap/IMAPPart.hpp"
+ #include "vmime/net/imap/IMAPMessagePartContentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <sstream>
+ #include <iterator>
+ #include <typeinfo>
+diff --git a/src/net/imap/IMAPMessagePartContentHandler.cpp b/src/net/imap/IMAPMessagePartContentHandler.cpp
+index 4e6ba97..85c6ec2 100644
+--- a/src/net/imap/IMAPMessagePartContentHandler.cpp
++++ b/src/net/imap/IMAPMessagePartContentHandler.cpp
+@@ -23,6 +23,9 @@
+ 
+ #include "vmime/net/imap/IMAPMessagePartContentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamStringProxyAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace net {
+diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
+index d11ae3b..8c4b275 100644
+--- a/src/net/maildir/maildirFolder.cpp
++++ b/src/net/maildir/maildirFolder.cpp
+@@ -35,6 +35,9 @@
+ #include "vmime/exception.hpp"
+ #include "vmime/platform.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace net {
+diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp
+index 51cd1ba..4ab75e7 100644
+--- a/src/net/maildir/maildirMessage.cpp
++++ b/src/net/maildir/maildirMessage.cpp
+@@ -31,6 +31,8 @@
+ #include "vmime/exception.hpp"
+ #include "vmime/platform.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace net {
+diff --git a/src/net/pop3/POP3Message.cpp b/src/net/pop3/POP3Message.cpp
+index 50f4f87..69ef004 100644
+--- a/src/net/pop3/POP3Message.cpp
++++ b/src/net/pop3/POP3Message.cpp
+@@ -25,6 +25,8 @@
+ #include "vmime/net/pop3/POP3Folder.hpp"
+ #include "vmime/net/pop3/POP3Store.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <sstream>
+ 
+ 
+diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp
+index 9d554c6..793112a 100644
+--- a/src/net/pop3/POP3Store.cpp
++++ b/src/net/pop3/POP3Store.cpp
+@@ -30,6 +30,7 @@
+ #include "vmime/security/digest/messageDigestFactory.hpp"
+ #include "vmime/utility/filteredStream.hpp"
+ #include "vmime/utility/stringUtils.hpp"
++#include "vmime/utility/inputStreamSocketAdapter.hpp"
+ 
+ #include "vmime/net/defaultConnectionInfos.hpp"
+ 
+diff --git a/src/net/sendmail/sendmailTransport.cpp b/src/net/sendmail/sendmailTransport.cpp
+index 53ff0d1..e7762cc 100644
+--- a/src/net/sendmail/sendmailTransport.cpp
++++ b/src/net/sendmail/sendmailTransport.cpp
+@@ -32,6 +32,8 @@
+ #include "vmime/utility/childProcess.hpp"
+ #include "vmime/utility/smartPtr.hpp"
+ 
++#include "vmime/utility/streamUtils.hpp"
++
+ #include "vmime/net/defaultConnectionInfos.hpp"
+ 
+ #include "vmime/config.hpp"
+diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
+index d9fb7b8..bbbea75 100644
+--- a/src/net/smtp/SMTPTransport.cpp
++++ b/src/net/smtp/SMTPTransport.cpp
+@@ -30,6 +30,8 @@
+ 
+ #include "vmime/utility/filteredStream.hpp"
+ #include "vmime/utility/stringUtils.hpp"
++#include "vmime/utility/outputStreamSocketAdapter.hpp"
++#include "vmime/utility/streamUtils.hpp"
+ 
+ #include "vmime/net/defaultConnectionInfos.hpp"
+ 
+diff --git a/src/net/transport.cpp b/src/net/transport.cpp
+index dd4663d..f8ca7b7 100644
+--- a/src/net/transport.cpp
++++ b/src/net/transport.cpp
+@@ -27,6 +27,9 @@
+ #include "vmime/mailboxList.hpp"
+ #include "vmime/message.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace net {
+diff --git a/src/parameter.cpp b/src/parameter.cpp
+index d757e1b..ccbe1a5 100644
+--- a/src/parameter.cpp
++++ b/src/parameter.cpp
+@@ -27,6 +27,9 @@
+ #include "vmime/text.hpp"
+ #include "vmime/encoding.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/parsedMessageAttachment.cpp b/src/parsedMessageAttachment.cpp
+index bde56aa..cb7d71d 100644
+--- a/src/parsedMessageAttachment.cpp
++++ b/src/parsedMessageAttachment.cpp
+@@ -26,6 +26,8 @@
+ #include "vmime/stringContentHandler.hpp"
+ #include "vmime/contentDisposition.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/security/cert/X509Certificate.cpp b/src/security/cert/X509Certificate.cpp
+index 1cd079c..8df4e5e 100644
+--- a/src/security/cert/X509Certificate.cpp
++++ b/src/security/cert/X509Certificate.cpp
+@@ -28,6 +28,8 @@
+ 
+ #include "vmime/security/cert/X509Certificate.hpp"
+ 
++#include "vmime/utility/outputStreamByteArrayAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace security {
+diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp
+index 51c2bed..4bb33c1 100644
+--- a/src/security/sasl/SASLContext.cpp
++++ b/src/security/sasl/SASLContext.cpp
+@@ -33,6 +33,9 @@
+ #include "vmime/utility/encoder/encoderFactory.hpp"
+ 
+ #include "vmime/utility/stream.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamByteBufferAdapter.hpp"
+ 
+ 
+ namespace vmime {
+diff --git a/src/streamContentHandler.cpp b/src/streamContentHandler.cpp
+index 2ebd073..89a36b4 100644
+--- a/src/streamContentHandler.cpp
++++ b/src/streamContentHandler.cpp
+@@ -23,6 +23,10 @@
+ 
+ #include "vmime/streamContentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/streamUtils.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/stringContentHandler.cpp b/src/stringContentHandler.cpp
+index 4e85a6c..5a1e72c 100644
+--- a/src/stringContentHandler.cpp
++++ b/src/stringContentHandler.cpp
+@@ -23,6 +23,10 @@
+ 
+ #include "vmime/stringContentHandler.hpp"
+ 
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringProxyAdapter.hpp"
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/utility/encoder/defaultEncoder.cpp b/src/utility/encoder/defaultEncoder.cpp
+index 4d0ffb5..e2d226e 100644
+--- a/src/utility/encoder/defaultEncoder.cpp
++++ b/src/utility/encoder/defaultEncoder.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/utility/encoder/defaultEncoder.hpp"
+ 
++#include "vmime/utility/streamUtils.hpp"
++
+ 
+ namespace vmime {
+ namespace utility {
+diff --git a/src/utility/inputStream.cpp b/src/utility/inputStream.cpp
+new file mode 100644
+index 0000000..dd0adf4
+--- /dev/null
++++ b/src/utility/inputStream.cpp
+@@ -0,0 +1,33 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamAdapter.cpp b/src/utility/inputStreamAdapter.cpp
+new file mode 100644
+index 0000000..b44b084
+--- /dev/null
++++ b/src/utility/inputStreamAdapter.cpp
+@@ -0,0 +1,70 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamAdapter::inputStreamAdapter(std::istream& is)
++	: m_stream(is)
++{
++}
++
++
++bool inputStreamAdapter::eof() const
++{
++	return (m_stream.eof());
++}
++
++
++void inputStreamAdapter::reset()
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.seekg(0, std::ios::beg);
++	m_stream.clear();
++}
++
++
++stream::size_type inputStreamAdapter::read
++	(value_type* const data, const size_type count)
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.read(data, count);
++	return (m_stream.gcount());
++}
++
++
++stream::size_type inputStreamAdapter::skip(const size_type count)
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.ignore(count);
++	return (m_stream.gcount());
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamByteBufferAdapter.cpp b/src/utility/inputStreamByteBufferAdapter.cpp
+new file mode 100644
+index 0000000..92e779f
+--- /dev/null
++++ b/src/utility/inputStreamByteBufferAdapter.cpp
+@@ -0,0 +1,90 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamByteBufferAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamByteBufferAdapter::inputStreamByteBufferAdapter(const byte_t* buffer, const size_type length)
++	: m_buffer(buffer), m_length(length), m_pos(0)
++{
++}
++
++
++bool inputStreamByteBufferAdapter::eof() const
++{
++	return m_pos >= m_length;
++}
++
++
++void inputStreamByteBufferAdapter::reset()
++{
++	m_pos = 0;
++}
++
++
++stream::size_type inputStreamByteBufferAdapter::read
++	(value_type* const data, const size_type count)
++{
++	const size_type remaining = m_length - m_pos;
++
++	if (remaining < count)
++	{
++		std::copy(m_buffer + m_pos, m_buffer + m_pos + remaining, data);
++		m_pos += remaining;
++
++		return remaining;
++	}
++	else
++	{
++		std::copy(m_buffer + m_pos, m_buffer + m_pos + count, data);
++		m_pos += count;
++
++		return count;
++	}
++}
++
++
++stream::size_type inputStreamByteBufferAdapter::skip(const size_type count)
++{
++	const size_type remaining = m_length - m_pos;
++
++	if (remaining < count)
++	{
++		m_pos += remaining;
++		return remaining;
++	}
++	else
++	{
++		m_pos += count;
++		return count;
++	}
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamPointerAdapter.cpp b/src/utility/inputStreamPointerAdapter.cpp
+new file mode 100644
+index 0000000..4d03e30
+--- /dev/null
++++ b/src/utility/inputStreamPointerAdapter.cpp
+@@ -0,0 +1,46 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamPointerAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamPointerAdapter::inputStreamPointerAdapter(std::istream* is, const bool own)
++	: inputStreamAdapter(*is), m_stream(is), m_own(own)
++{
++}
++
++
++inputStreamPointerAdapter::~inputStreamPointerAdapter()
++{
++	if (m_own)
++		delete (m_stream);
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamSocketAdapter.cpp b/src/utility/inputStreamSocketAdapter.cpp
+new file mode 100644
+index 0000000..b93cc3c
+--- /dev/null
++++ b/src/utility/inputStreamSocketAdapter.cpp
+@@ -0,0 +1,82 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamSocketAdapter.hpp"
++
++
++#if VMIME_HAVE_MESSAGING_FEATURES
++
++
++#include "vmime/net/socket.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamSocketAdapter::inputStreamSocketAdapter(net::socket& sok)
++	: m_socket(sok)
++{
++}
++
++
++bool inputStreamSocketAdapter::eof() const
++{
++	// Can't know...
++	return false;
++}
++
++
++void inputStreamSocketAdapter::reset()
++{
++	// Not supported
++}
++
++
++stream::size_type inputStreamSocketAdapter::read
++	(value_type* const data, const size_type count)
++{
++	return m_socket.receiveRaw(data, count);
++}
++
++
++stream::size_type inputStreamSocketAdapter::skip
++	(const size_type /* count */)
++{
++	// Not supported
++	return 0;
++}
++
++
++stream::size_type inputStreamSocketAdapter::getBlockSize()
++{
++	return m_socket.getBlockSize();
++}
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_HAVE_MESSAGING_FEATURES
++
+diff --git a/src/utility/inputStreamStringAdapter.cpp b/src/utility/inputStreamStringAdapter.cpp
+new file mode 100644
+index 0000000..31c9fda
+--- /dev/null
++++ b/src/utility/inputStreamStringAdapter.cpp
+@@ -0,0 +1,94 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer)
++	: m_buffer(buffer), m_begin(0), m_end(buffer.length()), m_pos(0)
++{
++}
++
++
++inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer,
++	const string::size_type begin, const string::size_type end)
++	: m_buffer(buffer), m_begin(begin), m_end(end), m_pos(begin)
++{
++}
++
++
++bool inputStreamStringAdapter::eof() const
++{
++	return (m_pos >= m_end);
++}
++
++
++void inputStreamStringAdapter::reset()
++{
++	m_pos = m_begin;
++}
++
++
++stream::size_type inputStreamStringAdapter::read
++	(value_type* const data, const size_type count)
++{
++	if (m_pos + count >= m_end)
++	{
++		const size_type remaining = m_end - m_pos;
++
++		std::copy(m_buffer.begin() + m_pos, m_buffer.end(), data);
++		m_pos = m_end;
++		return (remaining);
++	}
++	else
++	{
++		std::copy(m_buffer.begin() + m_pos, m_buffer.begin() + m_pos + count, data);
++		m_pos += count;
++		return (count);
++	}
++}
++
++
++stream::size_type inputStreamStringAdapter::skip(const size_type count)
++{
++	if (m_pos + count >= m_end)
++	{
++		const size_type remaining = m_end - m_pos;
++		m_pos = m_end;
++		return (remaining);
++	}
++	else
++	{
++		m_pos += count;
++		return (count);
++	}
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamStringProxyAdapter.cpp b/src/utility/inputStreamStringProxyAdapter.cpp
+new file mode 100644
+index 0000000..5e4b60b
+--- /dev/null
++++ b/src/utility/inputStreamStringProxyAdapter.cpp
+@@ -0,0 +1,89 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamStringProxyAdapter.hpp"
++#include "vmime/utility/stringProxy.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamStringProxyAdapter::inputStreamStringProxyAdapter(const stringProxy& buffer)
++	: m_buffer(buffer), m_pos(0)
++{
++}
++
++
++bool inputStreamStringProxyAdapter::eof() const
++{
++	return (m_pos >= m_buffer.length());
++}
++
++
++void inputStreamStringProxyAdapter::reset()
++{
++	m_pos = 0;
++}
++
++
++stream::size_type inputStreamStringProxyAdapter::read
++	(value_type* const data, const size_type count)
++{
++	const size_type remaining = m_buffer.length() - m_pos;
++
++	if (count > remaining)
++	{
++		std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_end(), data);
++		m_pos = m_buffer.length();
++		return (remaining);
++	}
++	else
++	{
++		std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_begin() + m_pos + count, data);
++		m_pos += count;
++		return (count);
++	}
++}
++
++
++stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
++{
++	const size_type remaining = m_buffer.length() - m_pos;
++
++	if (count > remaining)
++	{
++		m_pos = m_buffer.length();
++		return (remaining);
++	}
++	else
++	{
++		m_pos += count;
++		return (count);
++	}
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/outputStream.cpp b/src/utility/outputStream.cpp
+new file mode 100644
+index 0000000..8a65db5
+--- /dev/null
++++ b/src/utility/outputStream.cpp
+@@ -0,0 +1,33 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/outputStreamAdapter.cpp b/src/utility/outputStreamAdapter.cpp
+new file mode 100644
+index 0000000..2da94f1
+--- /dev/null
++++ b/src/utility/outputStreamAdapter.cpp
+@@ -0,0 +1,54 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStreamAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStreamAdapter::outputStreamAdapter(std::ostream& os)
++	: m_stream(os)
++{
++}
++
++
++void outputStreamAdapter::write
++	(const value_type* const data, const size_type count)
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.write(data, count);
++}
++
++
++void outputStreamAdapter::flush()
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.flush();
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/outputStreamByteArrayAdapter.cpp b/src/utility/outputStreamByteArrayAdapter.cpp
+new file mode 100644
+index 0000000..97b27d2
+--- /dev/null
++++ b/src/utility/outputStreamByteArrayAdapter.cpp
+@@ -0,0 +1,51 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStreamByteArrayAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStreamByteArrayAdapter::outputStreamByteArrayAdapter(byteArray& array)
++	: m_array(array)
++{
++}
++
++
++void outputStreamByteArrayAdapter::write(const value_type* const data, const size_type count)
++{
++	m_array.insert(m_array.end(), data, data + count);
++}
++
++
++void outputStreamByteArrayAdapter::flush()
++{
++	// Do nothing
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/outputStreamSocketAdapter.cpp b/src/utility/outputStreamSocketAdapter.cpp
+new file mode 100644
+index 0000000..d933e73
+--- /dev/null
++++ b/src/utility/outputStreamSocketAdapter.cpp
+@@ -0,0 +1,68 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStreamSocketAdapter.hpp"
++
++
++#if VMIME_HAVE_MESSAGING_FEATURES
++
++
++#include "vmime/net/socket.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStreamSocketAdapter::outputStreamSocketAdapter(net::socket& sok)
++	: m_socket(sok)
++{
++}
++
++
++void outputStreamSocketAdapter::write
++	(const value_type* const data, const size_type count)
++{
++	m_socket.sendRaw(data, count);
++}
++
++
++void outputStreamSocketAdapter::flush()
++{
++	// Do nothing
++}
++
++
++stream::size_type outputStreamSocketAdapter::getBlockSize()
++{
++	return m_socket.getBlockSize();
++}
++
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_HAVE_MESSAGING_FEATURES
++
+diff --git a/src/utility/outputStreamStringAdapter.cpp b/src/utility/outputStreamStringAdapter.cpp
+new file mode 100644
+index 0000000..62b2a72
+--- /dev/null
++++ b/src/utility/outputStreamStringAdapter.cpp
+@@ -0,0 +1,51 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStreamStringAdapter::outputStreamStringAdapter(string& buffer)
++	: m_buffer(buffer)
++{
++}
++
++
++void outputStreamStringAdapter::write(const value_type* const data, const size_type count)
++{
++	m_buffer.append(data, count);
++}
++
++
++void outputStreamStringAdapter::flush()
++{
++	// Do nothing
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/stream.cpp b/src/utility/stream.cpp
+index ec30b7d..1c940c2 100644
+--- a/src/utility/stream.cpp
++++ b/src/utility/stream.cpp
+@@ -22,503 +22,18 @@
+ //
+ 
+ #include "vmime/utility/stream.hpp"
+-#include "vmime/utility/stringProxy.hpp"
+ 
+-#include <algorithm>  // for std::copy
+-#include <iterator>   // for std::back_inserter
+-
+-#if VMIME_HAVE_MESSAGING_FEATURES
+-   #include "vmime/net/socket.hpp"
+-#endif
+ 
+ 
+ namespace vmime {
+ namespace utility {
+ 
+ 
+-// stream
+-
+ stream::size_type stream::getBlockSize()
+ {
+ 	return 32768;  // 32 KB
+ }
+ 
+ 
+-// Helpers
+-
+-outputStream& operator<<(outputStream& os, const stream::value_type c)
+-{
+-	os.write(&c, 1);
+-	return (os);
+-}
+-
+-
+-outputStream& operator<<(outputStream& os, const string& str)
+-{
+-	os.write(str.data(), str.length());
+-	return (os);
+-}
+-
+-
+-stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os)
+-{
+-	return bufferedStreamCopy(is, os, 0, NULL);
+-}
+-
+-
+-stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
+-	const stream::size_type length, progressListener* progress)
+-{
+-	const stream::size_type blockSize =
+-		std::min(is.getBlockSize(), os.getBlockSize());
+-
+-	std::vector <stream::value_type> vbuffer(blockSize);
+-
+-	stream::value_type* buffer = &vbuffer.front();
+-	stream::size_type total = 0;
+-
+-	if (progress != NULL)
+-		progress->start(length);
+-
+-	while (!is.eof())
+-	{
+-		const stream::size_type read = is.read(buffer, blockSize);
+-
+-		if (read != 0)
+-		{
+-			os.write(buffer, read);
+-			total += read;
+-
+-			if (progress != NULL)
+-				progress->progress(total, std::max(total, length));
+-		}
+-	}
+-
+-	if (progress != NULL)
+-		progress->stop(total);
+-
+-	return (total);
+-}
+-
+-
+-
+-// outputStreamAdapter
+-
+-outputStreamAdapter::outputStreamAdapter(std::ostream& os)
+-	: m_stream(os)
+-{
+-}
+-
+-
+-void outputStreamAdapter::write
+-	(const value_type* const data, const size_type count)
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.write(data, count);
+-}
+-
+-
+-void outputStreamAdapter::flush()
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.flush();
+-}
+-
+-
+-
+-// outputStreamStringAdapter
+-
+-outputStreamStringAdapter::outputStreamStringAdapter(string& buffer)
+-	: m_buffer(buffer)
+-{
+-}
+-
+-
+-void outputStreamStringAdapter::write(const value_type* const data, const size_type count)
+-{
+-	m_buffer.append(data, count);
+-}
+-
+-
+-void outputStreamStringAdapter::flush()
+-{
+-	// Do nothing
+-}
+-
+-
+-
+-// outputStreamByteArrayAdapter
+-
+-outputStreamByteArrayAdapter::outputStreamByteArrayAdapter(byteArray& array)
+-	: m_array(array)
+-{
+-}
+-
+-
+-void outputStreamByteArrayAdapter::write(const value_type* const data, const size_type count)
+-{
+-	m_array.insert(m_array.end(), data, data + count);
+-}
+-
+-
+-void outputStreamByteArrayAdapter::flush()
+-{
+-	// Do nothing
+-}
+-
+-
+-
+-// inputStreamAdapter
+-
+-inputStreamAdapter::inputStreamAdapter(std::istream& is)
+-	: m_stream(is)
+-{
+-}
+-
+-
+-bool inputStreamAdapter::eof() const
+-{
+-	return (m_stream.eof());
+-}
+-
+-
+-void inputStreamAdapter::reset()
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.seekg(0, std::ios::beg);
+-	m_stream.clear();
+-}
+-
+-
+-stream::size_type inputStreamAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.read(data, count);
+-	return (m_stream.gcount());
+-}
+-
+-
+-stream::size_type inputStreamAdapter::skip(const size_type count)
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.ignore(count);
+-	return (m_stream.gcount());
+-}
+-
+-
+-
+-// inputStreamStringAdapter
+-
+-inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer)
+-	: m_buffer(buffer), m_begin(0), m_end(buffer.length()), m_pos(0)
+-{
+-}
+-
+-
+-inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer,
+-	const string::size_type begin, const string::size_type end)
+-	: m_buffer(buffer), m_begin(begin), m_end(end), m_pos(begin)
+-{
+-}
+-
+-
+-bool inputStreamStringAdapter::eof() const
+-{
+-	return (m_pos >= m_end);
+-}
+-
+-
+-void inputStreamStringAdapter::reset()
+-{
+-	m_pos = m_begin;
+-}
+-
+-
+-stream::size_type inputStreamStringAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	if (m_pos + count >= m_end)
+-	{
+-		const size_type remaining = m_end - m_pos;
+-
+-		std::copy(m_buffer.begin() + m_pos, m_buffer.end(), data);
+-		m_pos = m_end;
+-		return (remaining);
+-	}
+-	else
+-	{
+-		std::copy(m_buffer.begin() + m_pos, m_buffer.begin() + m_pos + count, data);
+-		m_pos += count;
+-		return (count);
+-	}
+-}
+-
+-
+-stream::size_type inputStreamStringAdapter::skip(const size_type count)
+-{
+-	if (m_pos + count >= m_end)
+-	{
+-		const size_type remaining = m_end - m_pos;
+-		m_pos = m_end;
+-		return (remaining);
+-	}
+-	else
+-	{
+-		m_pos += count;
+-		return (count);
+-	}
+-}
+-
+-
+-
+-// inputStreamStringProxyAdapter
+-
+-inputStreamStringProxyAdapter::inputStreamStringProxyAdapter(const stringProxy& buffer)
+-	: m_buffer(buffer), m_pos(0)
+-{
+-}
+-
+-
+-bool inputStreamStringProxyAdapter::eof() const
+-{
+-	return (m_pos >= m_buffer.length());
+-}
+-
+-
+-void inputStreamStringProxyAdapter::reset()
+-{
+-	m_pos = 0;
+-}
+-
+-
+-stream::size_type inputStreamStringProxyAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	const size_type remaining = m_buffer.length() - m_pos;
+-
+-	if (count > remaining)
+-	{
+-		std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_end(), data);
+-		m_pos = m_buffer.length();
+-		return (remaining);
+-	}
+-	else
+-	{
+-		std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_begin() + m_pos + count, data);
+-		m_pos += count;
+-		return (count);
+-	}
+-}
+-
+-
+-stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
+-{
+-	const size_type remaining = m_buffer.length() - m_pos;
+-
+-	if (count > remaining)
+-	{
+-		m_pos = m_buffer.length();
+-		return (remaining);
+-	}
+-	else
+-	{
+-		m_pos += count;
+-		return (count);
+-	}
+-}
+-
+-
+-
+-// inputStreamPointerAdapter
+-
+-inputStreamPointerAdapter::inputStreamPointerAdapter(std::istream* is, const bool own)
+-	: m_stream(is), m_own(own)
+-{
+-}
+-
+-
+-inputStreamPointerAdapter::inputStreamPointerAdapter(const inputStreamPointerAdapter&)
+-	: inputStream(), m_stream(NULL), m_own(false)
+-{
+-	// Not copiable
+-}
+-
+-
+-inputStreamPointerAdapter::~inputStreamPointerAdapter()
+-{
+-	if (m_own)
+-		delete (m_stream);
+-}
+-
+-
+-bool inputStreamPointerAdapter::eof() const
+-{
+-	return (m_stream->eof());
+-}
+-
+-
+-void inputStreamPointerAdapter::reset()
+-{
+-	m_stream->exceptions(std::ios_base::badbit);
+-	m_stream->seekg(0, std::ios::beg);
+-	m_stream->clear();
+-}
+-
+-
+-stream::size_type inputStreamPointerAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	m_stream->exceptions(std::ios_base::badbit);
+-	m_stream->read(data, count);
+-	return (m_stream->gcount());
+-}
+-
+-
+-stream::size_type inputStreamPointerAdapter::skip(const size_type count)
+-{
+-	m_stream->exceptions(std::ios_base::badbit);
+-	m_stream->ignore(count);
+-	return (m_stream->gcount());
+-}
+-
+-
+-
+-// inputStreamByteBufferAdapter
+-
+-inputStreamByteBufferAdapter::inputStreamByteBufferAdapter(const byte_t* buffer, const size_type length)
+-	: m_buffer(buffer), m_length(length), m_pos(0)
+-{
+-}
+-
+-
+-bool inputStreamByteBufferAdapter::eof() const
+-{
+-	return m_pos >= m_length;
+-}
+-
+-
+-void inputStreamByteBufferAdapter::reset()
+-{
+-	m_pos = 0;
+-}
+-
+-
+-stream::size_type inputStreamByteBufferAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	const size_type remaining = m_length - m_pos;
+-
+-	if (remaining < count)
+-	{
+-		std::copy(m_buffer + m_pos, m_buffer + m_pos + remaining, data);
+-		m_pos += remaining;
+-
+-		return remaining;
+-	}
+-	else
+-	{
+-		std::copy(m_buffer + m_pos, m_buffer + m_pos + count, data);
+-		m_pos += count;
+-
+-		return count;
+-	}
+-}
+-
+-
+-stream::size_type inputStreamByteBufferAdapter::skip(const size_type count)
+-{
+-	const size_type remaining = m_length - m_pos;
+-
+-	if (remaining < count)
+-	{
+-		m_pos += remaining;
+-		return remaining;
+-	}
+-	else
+-	{
+-		m_pos += count;
+-		return count;
+-	}
+-}
+-
+-
+-
+-#ifdef VMIME_HAVE_MESSAGING_FEATURES
+-
+-
+-// outputStreamSocketAdapter
+-
+-outputStreamSocketAdapter::outputStreamSocketAdapter(net::socket& sok)
+-	: m_socket(sok)
+-{
+-}
+-
+-
+-void outputStreamSocketAdapter::write
+-	(const value_type* const data, const size_type count)
+-{
+-	m_socket.sendRaw(data, count);
+-}
+-
+-
+-void outputStreamSocketAdapter::flush()
+-{
+-	// Do nothing
+-}
+-
+-
+-stream::size_type outputStreamSocketAdapter::getBlockSize()
+-{
+-	return m_socket.getBlockSize();
+-}
+-
+-
+-
+-// inputStreamSocketAdapter
+-
+-inputStreamSocketAdapter::inputStreamSocketAdapter(net::socket& sok)
+-	: m_socket(sok)
+-{
+-}
+-
+-
+-bool inputStreamSocketAdapter::eof() const
+-{
+-	// Can't know...
+-	return false;
+-}
+-
+-
+-void inputStreamSocketAdapter::reset()
+-{
+-	// Not supported
+-}
+-
+-
+-stream::size_type inputStreamSocketAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	return m_socket.receiveRaw(data, count);
+-}
+-
+-
+-stream::size_type inputStreamSocketAdapter::skip
+-	(const size_type /* count */)
+-{
+-	// Not supported
+-	return 0;
+-}
+-
+-
+-stream::size_type inputStreamSocketAdapter::getBlockSize()
+-{
+-	return m_socket.getBlockSize();
+-}
+-
+-
+-#endif // VMIME_HAVE_MESSAGING_FEATURES
+-
+-
+ } // utility
+ } // vmime
+diff --git a/src/utility/streamUtils.cpp b/src/utility/streamUtils.cpp
+new file mode 100644
+index 0000000..f1d3b9d
+--- /dev/null
++++ b/src/utility/streamUtils.cpp
+@@ -0,0 +1,92 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/streamUtils.hpp"
++
++#include <algorithm>  // for std::copy
++#include <iterator>   // for std::back_inserter
++
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStream& operator<<(outputStream& os, const stream::value_type c)
++{
++	os.write(&c, 1);
++	return (os);
++}
++
++
++outputStream& operator<<(outputStream& os, const string& str)
++{
++	os.write(str.data(), str.length());
++	return (os);
++}
++
++
++stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os)
++{
++	return bufferedStreamCopy(is, os, 0, NULL);
++}
++
++
++stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
++	const stream::size_type length, progressListener* progress)
++{
++	const stream::size_type blockSize =
++		std::min(is.getBlockSize(), os.getBlockSize());
++
++	std::vector <stream::value_type> vbuffer(blockSize);
++
++	stream::value_type* buffer = &vbuffer.front();
++	stream::size_type total = 0;
++
++	if (progress != NULL)
++		progress->start(length);
++
++	while (!is.eof())
++	{
++		const stream::size_type read = is.read(buffer, blockSize);
++
++		if (read != 0)
++		{
++			os.write(buffer, read);
++			total += read;
++
++			if (progress != NULL)
++				progress->progress(total, std::max(total, length));
++		}
++	}
++
++	if (progress != NULL)
++		progress->stop(total);
++
++	return (total);
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/stringProxy.cpp b/src/utility/stringProxy.cpp
+index a4ba6d2..74344b5 100644
+--- a/src/utility/stringProxy.cpp
++++ b/src/utility/stringProxy.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/utility/stringProxy.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <iterator>
+ #include <algorithm>
+ 
+diff --git a/src/word.cpp b/src/word.cpp
+index aeaa737..79060a1 100644
+--- a/src/word.cpp
++++ b/src/word.cpp
+@@ -28,6 +28,9 @@
+ #include "vmime/utility/smartPtr.hpp"
+ #include "vmime/parserHelpers.hpp"
+ 
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
+ #include "vmime/utility/encoder/encoder.hpp"
+ #include "vmime/utility/encoder/b64Encoder.hpp"
+ #include "vmime/utility/encoder/qpEncoder.hpp"
+diff --git a/src/wordEncoder.cpp b/src/wordEncoder.cpp
+index 67bd7a1..194a189 100644
+--- a/src/wordEncoder.cpp
++++ b/src/wordEncoder.cpp
+@@ -33,6 +33,9 @@
+ 
+ #include "vmime/utility/stringUtils.hpp"
+ 
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/vmime/base.hpp b/vmime/base.hpp
+index 60e637d..b794031 100644
+--- a/vmime/base.hpp
++++ b/vmime/base.hpp
+@@ -35,7 +35,6 @@
+ #include "vmime/config.hpp"
+ #include "vmime/types.hpp"
+ #include "vmime/constants.hpp"
+-#include "vmime/utility/stream.hpp"
+ #include "vmime/utility/smartPtr.hpp"
+ 
+ 
+@@ -255,7 +254,26 @@ namespace vmime
+ 		return y.dynamicCast <X>();
+ 	}
+ 
++	/** Inherit from this class to indicate the subclass is not copyable,
++	  * ie. you want to prohibit copy construction and copy assignment.
++	  */
++	class noncopyable
++	{
++	protected:
++
++		noncopyable() { }
++		virtual ~noncopyable() { }
++
++	private:
++
++		noncopyable(const noncopyable&);
++		void operator=(const noncopyable&);
++	};
++
+ } // vmime
+ 
+ 
++#include "vmime/utility/stream.hpp"
++
++
+ #endif // VMIME_BASE_HPP_INCLUDED
+diff --git a/vmime/charset.hpp b/vmime/charset.hpp
+index b2e241c..5f5e8e5 100644
+--- a/vmime/charset.hpp
++++ b/vmime/charset.hpp
+@@ -26,6 +26,8 @@
+ 
+ 
+ #include "vmime/base.hpp"
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/outputStream.hpp"
+ #include "vmime/component.hpp"
+ 
+ 
+diff --git a/vmime/component.hpp b/vmime/component.hpp
+index b38127f..12b0406 100644
+--- a/vmime/component.hpp
++++ b/vmime/component.hpp
+@@ -26,6 +26,8 @@
+ 
+ 
+ #include "vmime/base.hpp"
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/outputStream.hpp"
+ 
+ 
+ namespace vmime
+diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp
+index d71c3ca..f430510 100644
+--- a/vmime/net/imap/IMAPParser.hpp
++++ b/vmime/net/imap/IMAPParser.hpp
+@@ -37,6 +37,9 @@
+ #include "vmime/utility/encoder/b64Encoder.hpp"
+ #include "vmime/utility/encoder/qpEncoder.hpp"
+ 
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++
+ #include "vmime/platform.hpp"
+ 
+ #include "vmime/net/timeoutHandler.hpp"
+@@ -3825,7 +3828,7 @@ public:
+ 			: m_date_time(NULL), m_number(NULL), m_envelope(NULL),
+ 			  m_uniqueid(NULL), m_nstring(NULL), m_body(NULL), m_flag_list(NULL),
+ 			  m_section(NULL)
+-              
++
+ 		{
+ 		}
+ 
+diff --git a/vmime/utility/filteredStream.hpp b/vmime/utility/filteredStream.hpp
+index 00be785..2a55edd 100644
+--- a/vmime/utility/filteredStream.hpp
++++ b/vmime/utility/filteredStream.hpp
+@@ -27,7 +27,8 @@
+ 
+ #include <algorithm>
+ 
+-#include "vmime/utility/stream.hpp"
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/outputStream.hpp"
+ 
+ 
+ namespace vmime {
+diff --git a/vmime/utility/inputStream.hpp b/vmime/utility/inputStream.hpp
+new file mode 100644
+index 0000000..4a76a7d
+--- /dev/null
++++ b/vmime/utility/inputStream.hpp
+@@ -0,0 +1,76 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAM_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAM_HPP_INCLUDED
++
++
++#include "vmime/utility/stream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** Simple input stream.
++  */
++
++class inputStream : public stream
++{
++public:
++
++	/** Test for end of stream (no more data to read).
++	  *
++	  * @return true if we have reached the end of stream, false otherwise
++	  */
++	virtual bool eof() const = 0;
++
++	/** Set the read pointer to the beginning of the stream.
++	  *
++	  * @warning WARNING: this may not work for all stream types.
++	  */
++	virtual void reset() = 0;
++
++	/** Read data from the stream.
++	  *
++	  * @param data will receive the data read
++	  * @param count maximum number of bytes to read
++	  * @return number of bytes read
++	  */
++	virtual size_type read(value_type* const data, const size_type count) = 0;
++
++	/** Skip a number of bytes.
++	  *
++	  * @param count maximum number of bytes to ignore
++	  * @return number of bytes skipped
++	  */
++	virtual size_type skip(const size_type count) = 0;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAM_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamAdapter.hpp b/vmime/utility/inputStreamAdapter.hpp
+new file mode 100644
+index 0000000..278ab52
+--- /dev/null
++++ b/vmime/utility/inputStreamAdapter.hpp
+@@ -0,0 +1,64 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++#include <istream>
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for C++ standard input streams.
++  */
++
++class inputStreamAdapter : public inputStream
++{
++public:
++
++	/** @param is input stream to wrap
++	  */
++	inputStreamAdapter(std::istream& is);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++private:
++
++	std::istream& m_stream;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamByteBufferAdapter.hpp b/vmime/utility/inputStreamByteBufferAdapter.hpp
+new file mode 100644
+index 0000000..0f6a442
+--- /dev/null
++++ b/vmime/utility/inputStreamByteBufferAdapter.hpp
+@@ -0,0 +1,63 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMBYTEBUFFERADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMBYTEBUFFERADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for reading from an array of bytes.
++  */
++
++class inputStreamByteBufferAdapter : public inputStream
++{
++public:
++
++	inputStreamByteBufferAdapter(const byte_t* buffer, size_type length);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++private:
++
++	const byte_t* m_buffer;
++	const size_type m_length;
++
++	size_type m_pos;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMBYTEBUFFERADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamPointerAdapter.hpp b/vmime/utility/inputStreamPointerAdapter.hpp
+new file mode 100644
+index 0000000..44e9bad
+--- /dev/null
++++ b/vmime/utility/inputStreamPointerAdapter.hpp
+@@ -0,0 +1,63 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMPOINTERADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMPOINTERADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStreamAdapter.hpp"
++
++#include <istream>
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for pointer to C++ standard input stream.
++  */
++
++class inputStreamPointerAdapter : public inputStreamAdapter
++{
++public:
++
++	/** @param is input stream to wrap
++	  * @param own if set to 'true', the pointer will be deleted when
++	  * this object is destroyed
++	  */
++	inputStreamPointerAdapter(std::istream* is, const bool own = true);
++	~inputStreamPointerAdapter();
++
++private:
++
++	std::istream* m_stream;
++	const bool m_own;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMPOINTERADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamSocketAdapter.hpp b/vmime/utility/inputStreamSocketAdapter.hpp
+new file mode 100644
+index 0000000..0f99c21
+--- /dev/null
++++ b/vmime/utility/inputStreamSocketAdapter.hpp
+@@ -0,0 +1,77 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++#if VMIME_HAVE_MESSAGING_FEATURES
++
++
++namespace vmime {
++namespace net {
++	class socket;  // forward reference
++} // net
++} // vmime
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An input stream that is connected to a socket.
++  */
++
++class inputStreamSocketAdapter : public inputStream
++{
++public:
++
++	inputStreamSocketAdapter(net::socket& sok);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++	size_type getBlockSize();
++
++private:
++
++	inputStreamSocketAdapter(const inputStreamSocketAdapter&);
++
++	net::socket& m_socket;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_HAVE_MESSAGING_FEATURES
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamStringAdapter.hpp b/vmime/utility/inputStreamStringAdapter.hpp
+new file mode 100644
+index 0000000..a7d986f
+--- /dev/null
++++ b/vmime/utility/inputStreamStringAdapter.hpp
+@@ -0,0 +1,66 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for string input.
++  */
++
++class inputStreamStringAdapter : public inputStream
++{
++public:
++
++	inputStreamStringAdapter(const string& buffer);
++	inputStreamStringAdapter(const string& buffer, const string::size_type begin, const string::size_type end);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++private:
++
++	inputStreamStringAdapter(const inputStreamStringAdapter&);
++
++	const string m_buffer;  // do _NOT_ keep a reference...
++	const string::size_type m_begin;
++	const string::size_type m_end;
++	string::size_type m_pos;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamStringProxyAdapter.hpp b/vmime/utility/inputStreamStringProxyAdapter.hpp
+new file mode 100644
+index 0000000..74b3f60
+--- /dev/null
++++ b/vmime/utility/inputStreamStringProxyAdapter.hpp
+@@ -0,0 +1,68 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMSTRINGPROXYADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMSTRINGPROXYADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++class stringProxy;
++
++
++/** An adapter class for stringProxy input.
++  */
++
++class inputStreamStringProxyAdapter : public inputStream
++{
++public:
++
++	/** @param buffer stringProxy object to wrap
++	  */
++	inputStreamStringProxyAdapter(const stringProxy& buffer);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++private:
++
++	inputStreamStringProxyAdapter(const inputStreamStringProxyAdapter&);
++
++	const stringProxy& m_buffer;
++	string::size_type m_pos;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMSTRINGPROXYADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStream.hpp b/vmime/utility/outputStream.hpp
+new file mode 100644
+index 0000000..7372d20
+--- /dev/null
++++ b/vmime/utility/outputStream.hpp
+@@ -0,0 +1,107 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAM_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAM_HPP_INCLUDED
++
++
++#include "vmime/utility/stream.hpp"
++
++
++#if defined(_MSC_VER) && (_MSC_VER <= 1200)  // VC++6
++#	include <cstring>
++#endif
++
++
++namespace vmime {
++namespace utility {
++
++
++/** Simple output stream.
++  */
++
++class outputStream : public stream
++{
++public:
++
++	/** Write data to the stream.
++	  *
++	  * @param data buffer containing data to write
++	  * @param count number of bytes to write
++	  */
++	virtual void write(const value_type* const data, const size_type count) = 0;
++
++	/** Flush this output stream and forces any buffered output
++	  * bytes to be written out to the stream.
++	  */
++	virtual void flush() = 0;
++};
++
++
++// Helpers functions
++
++outputStream& operator<<(outputStream& os, const string& str);
++outputStream& operator<<(outputStream& os, const stream::value_type c);
++
++
++#if defined(_MSC_VER) && (_MSC_VER <= 1200)  // Internal compiler error with VC++6
++
++inline outputStream& operator<<(outputStream& os, const char* str)
++{
++	os.write(str, ::strlen(str));
++	return (os);
++}
++
++#else
++
++template <int N>
++outputStream& operator<<(outputStream& os, const char (&str)[N])
++{
++	os.write(str, N - 1);
++	return (os);
++}
++
++#endif // defined(_MSC_VER) && (_MSC_VER <= 1200)
++
++
++template <typename T>
++outputStream& operator<<(outputStream& os, const T& t)
++{
++	std::ostringstream oss;
++	oss.imbue(std::locale::classic());  // no formatting
++
++	oss << t;
++
++	os << oss.str();
++
++	return (os);
++}
++
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAM_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStreamAdapter.hpp b/vmime/utility/outputStreamAdapter.hpp
+new file mode 100644
+index 0000000..be55d8d
+--- /dev/null
++++ b/vmime/utility/outputStreamAdapter.hpp
+@@ -0,0 +1,62 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAMADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAMADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/outputStream.hpp"
++
++#include <ostream>
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for C++ standard output streams.
++  */
++
++class outputStreamAdapter : public outputStream
++{
++public:
++
++	/** @param os output stream to wrap
++	  */
++	outputStreamAdapter(std::ostream& os);
++
++	void write(const value_type* const data, const size_type count);
++	void flush();
++
++private:
++
++	std::ostream& m_stream;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAMADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStreamByteArrayAdapter.hpp b/vmime/utility/outputStreamByteArrayAdapter.hpp
+new file mode 100644
+index 0000000..bf7d839
+--- /dev/null
++++ b/vmime/utility/outputStreamByteArrayAdapter.hpp
+@@ -0,0 +1,58 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAMBYTEARRAYADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAMBYTEARRAYADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/outputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for byte array output.
++  */
++
++class outputStreamByteArrayAdapter : public outputStream
++{
++public:
++
++	outputStreamByteArrayAdapter(byteArray& array);
++
++	void write(const value_type* const data, const size_type count);
++	void flush();
++
++private:
++
++	byteArray& m_array;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAMBYTEARRAYADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStreamSocketAdapter.hpp b/vmime/utility/outputStreamSocketAdapter.hpp
+new file mode 100644
+index 0000000..e3d3eb0
+--- /dev/null
++++ b/vmime/utility/outputStreamSocketAdapter.hpp
+@@ -0,0 +1,75 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/outputStream.hpp"
++
++
++#if VMIME_HAVE_MESSAGING_FEATURES
++
++
++namespace vmime {
++namespace net {
++	class socket;  // forward reference
++} // net
++} // vmime
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An output stream that is connected to a socket.
++  */
++
++class outputStreamSocketAdapter : public outputStream
++{
++public:
++
++	outputStreamSocketAdapter(net::socket& sok);
++
++	void write(const value_type* const data, const size_type count);
++	void flush();
++
++	size_type getBlockSize();
++
++private:
++
++	outputStreamSocketAdapter(const outputStreamSocketAdapter&);
++
++	net::socket& m_socket;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_HAVE_MESSAGING_FEATURES
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStreamStringAdapter.hpp b/vmime/utility/outputStreamStringAdapter.hpp
+new file mode 100644
+index 0000000..8c8b304
+--- /dev/null
++++ b/vmime/utility/outputStreamStringAdapter.hpp
+@@ -0,0 +1,59 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/outputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for string output.
++  */
++
++class outputStreamStringAdapter : public outputStream
++{
++public:
++
++	outputStreamStringAdapter(string& buffer);
++
++	void write(const value_type* const data, const size_type count);
++	void flush();
++
++size_type getBlockSize(){return 8192;}
++private:
++
++	string& m_buffer;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/stream.hpp b/vmime/utility/stream.hpp
+index 1faab55..566ab9d 100644
+--- a/vmime/utility/stream.hpp
++++ b/vmime/utility/stream.hpp
+@@ -25,40 +25,22 @@
+ #define VMIME_UTILITY_STREAM_HPP_INCLUDED
+ 
+ 
+-#include <istream>
+-#include <ostream>
+ #include <sstream>
+ 
+ #include "vmime/config.hpp"
+ #include "vmime/types.hpp"
+-
+-#include "vmime/utility/progressListener.hpp"
+-
+-
+-#if VMIME_HAVE_MESSAGING_FEATURES
+-	namespace vmime {
+-	namespace net {
+-		class socket;  // forward reference
+-	} // net
+-	} // vmime
+-#endif
+-
+-#if defined(_MSC_VER) && (_MSC_VER <= 1200)  // VC++6
+-#   include <cstring>
+-#endif
++#include "vmime/base.hpp"
+ 
+ 
+ namespace vmime {
+ namespace utility {
+ 
+ 
+-class stringProxy;
+-
+ 
+ /** Base class for input/output stream.
+   */
+ 
+-class stream : public object
++class stream : public object, private noncopyable
+ {
+ public:
+ 
+@@ -81,365 +63,6 @@ public:
+ };
+ 
+ 
+-
+-/** Simple output stream.
+-  */
+-
+-class outputStream : public stream
+-{
+-public:
+-
+-	/** Write data to the stream.
+-	  *
+-	  * @param data buffer containing data to write
+-	  * @param count number of bytes to write
+-	  */
+-	virtual void write(const value_type* const data, const size_type count) = 0;
+-
+-	/** Flush this output stream and forces any buffered output
+-	  * bytes to be written out to the stream.
+-	  */
+-	virtual void flush() = 0;
+-};
+-
+-
+-
+-/** Simple input stream.
+-  */
+-
+-class inputStream : public stream
+-{
+-public:
+-
+-	/** Test for end of stream (no more data to read).
+-	  *
+-	  * @return true if we have reached the end of stream, false otherwise
+-	  */
+-	virtual bool eof() const = 0;
+-
+-	/** Set the read pointer to the beginning of the stream.
+-	  *
+-	  * @warning WARNING: this may not work for all stream types.
+-	  */
+-	virtual void reset() = 0;
+-
+-	/** Read data from the stream.
+-	  *
+-	  * @param data will receive the data read
+-	  * @param count maximum number of bytes to read
+-	  * @return number of bytes read
+-	  */
+-	virtual size_type read(value_type* const data, const size_type count) = 0;
+-
+-	/** Skip a number of bytes.
+-	  *
+-	  * @param count maximum number of bytes to ignore
+-	  * @return number of bytes skipped
+-	  */
+-	virtual size_type skip(const size_type count) = 0;
+-};
+-
+-
+-
+-// Helpers functions
+-
+-outputStream& operator<<(outputStream& os, const string& str);
+-outputStream& operator<<(outputStream& os, const stream::value_type c);
+-
+-
+-#if defined(_MSC_VER) && (_MSC_VER <= 1200)  // Internal compiler error with VC++6
+-
+-inline outputStream& operator<<(outputStream& os, const char* str)
+-{
+-	os.write(str, ::strlen(str));
+-	return (os);
+-}
+-
+-#else
+-
+-template <int N>
+-outputStream& operator<<(outputStream& os, const char (&str)[N])
+-{
+-	os.write(str, N - 1);
+-	return (os);
+-}
+-
+-#endif // defined(_MSC_VER) && (_MSC_VER <= 1200)
+-
+-
+-template <typename T>
+-outputStream& operator<<(outputStream& os, const T& t)
+-{
+-	std::ostringstream oss;
+-	oss.imbue(std::locale::classic());  // no formatting
+-
+-	oss << t;
+-
+-	os << oss.str();
+-
+-	return (os);
+-}
+-
+-
+-/** Copy data from one stream into another stream using a buffered method.
+-  *
+-  * @param is input stream (source data)
+-  * @param os output stream (destination for data)
+-  * @return number of bytes copied
+-  */
+-
+-stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os);
+-
+-/** Copy data from one stream into another stream using a buffered method
+-  * and notify progress state of the operation.
+-  *
+-  * @param is input stream (source data)
+-  * @param os output stream (destination for data)
+-  * @param length predicted number of bytes to copy
+-  * @param progress listener to notify
+-  * @return number of bytes copied
+-  */
+-
+-stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
+-	const stream::size_type length, progressListener* progress);
+-
+-
+-// Adapters
+-
+-
+-/** An adapter class for C++ standard output streams.
+-  */
+-
+-class outputStreamAdapter : public outputStream
+-{
+-public:
+-
+-	/** @param os output stream to wrap
+-	  */
+-	outputStreamAdapter(std::ostream& os);
+-
+-	void write(const value_type* const data, const size_type count);
+-	void flush();
+-
+-private:
+-
+-	std::ostream& m_stream;
+-};
+-
+-
+-/** An adapter class for string output.
+-  */
+-
+-class outputStreamStringAdapter : public outputStream
+-{
+-public:
+-
+-	outputStreamStringAdapter(string& buffer);
+-
+-	void write(const value_type* const data, const size_type count);
+-	void flush();
+-
+-size_type getBlockSize(){return 8192;}
+-private:
+-
+-	string& m_buffer;
+-};
+-
+-
+-/** An adapter class for byte array output.
+-  */
+-
+-class outputStreamByteArrayAdapter : public outputStream
+-{
+-public:
+-
+-	outputStreamByteArrayAdapter(byteArray& array);
+-
+-	void write(const value_type* const data, const size_type count);
+-	void flush();
+-
+-private:
+-
+-	byteArray& m_array;
+-};
+-
+-
+-/** An adapter class for C++ standard input streams.
+-  */
+-
+-class inputStreamAdapter : public inputStream
+-{
+-public:
+-
+-	/** @param is input stream to wrap
+-	  */
+-	inputStreamAdapter(std::istream& is);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	std::istream& m_stream;
+-};
+-
+-
+-/** An adapter class for string input.
+-  */
+-
+-class inputStreamStringAdapter : public inputStream
+-{
+-public:
+-
+-	inputStreamStringAdapter(const string& buffer);
+-	inputStreamStringAdapter(const string& buffer, const string::size_type begin, const string::size_type end);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	inputStreamStringAdapter(const inputStreamStringAdapter&);
+-
+-	const string m_buffer;  // do _NOT_ keep a reference...
+-	const string::size_type m_begin;
+-	const string::size_type m_end;
+-	string::size_type m_pos;
+-};
+-
+-
+-/** An adapter class for stringProxy input.
+-  */
+-
+-class inputStreamStringProxyAdapter : public inputStream
+-{
+-public:
+-
+-	/** @param buffer stringProxy object to wrap
+-	  */
+-	inputStreamStringProxyAdapter(const stringProxy& buffer);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	inputStreamStringProxyAdapter(const inputStreamStringProxyAdapter&);
+-
+-	const stringProxy& m_buffer;
+-	string::size_type m_pos;
+-};
+-
+-
+-/** An adapter class for pointer to C++ standard input stream.
+-  */
+-
+-class inputStreamPointerAdapter : public inputStream
+-{
+-public:
+-
+-	/** @param is input stream to wrap
+-	  * @param own if set to 'true', the pointer will be deleted when
+-	  * this object is destroyed
+-	  */
+-	inputStreamPointerAdapter(std::istream* is, const bool own = true);
+-	~inputStreamPointerAdapter();
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	inputStreamPointerAdapter(const inputStreamPointerAdapter&);
+-
+-	std::istream* m_stream;
+-	const bool m_own;
+-};
+-
+-
+-/** An adapter class for reading from an array of bytes.
+-  */
+-
+-class inputStreamByteBufferAdapter : public inputStream
+-{
+-public:
+-
+-	inputStreamByteBufferAdapter(const byte_t* buffer, size_type length);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	const byte_t* m_buffer;
+-	const size_type m_length;
+-
+-	size_type m_pos;
+-};
+-
+-
+-#if VMIME_HAVE_MESSAGING_FEATURES
+-
+-
+-/** An output stream that is connected to a socket.
+-  */
+-
+-class outputStreamSocketAdapter : public outputStream
+-{
+-public:
+-
+-	outputStreamSocketAdapter(net::socket& sok);
+-
+-	void write(const value_type* const data, const size_type count);
+-	void flush();
+-
+-	size_type getBlockSize();
+-
+-private:
+-
+-	outputStreamSocketAdapter(const outputStreamSocketAdapter&);
+-
+-	net::socket& m_socket;
+-};
+-
+-
+-/** An input stream that is connected to a socket.
+-  */
+-
+-class inputStreamSocketAdapter : public inputStream
+-{
+-public:
+-
+-	inputStreamSocketAdapter(net::socket& sok);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-	size_type getBlockSize();
+-
+-private:
+-
+-	inputStreamSocketAdapter(const inputStreamSocketAdapter&);
+-
+-	net::socket& m_socket;
+-};
+-
+-
+-#endif // VMIME_HAVE_MESSAGING_FEATURES
+-
+-
+ } // utility
+ } // vmime
+ 
+diff --git a/vmime/utility/streamUtils.hpp b/vmime/utility/streamUtils.hpp
+new file mode 100644
+index 0000000..cdf70aa
+--- /dev/null
++++ b/vmime/utility/streamUtils.hpp
+@@ -0,0 +1,66 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_STREAMUTILS_HPP_INCLUDED
++#define VMIME_UTILITY_STREAMUTILS_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/outputStream.hpp"
++
++#include "vmime/utility/progressListener.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** Copy data from one stream into another stream using a buffered method.
++  *
++  * @param is input stream (source data)
++  * @param os output stream (destination for data)
++  * @return number of bytes copied
++  */
++
++stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os);
++
++/** Copy data from one stream into another stream using a buffered method
++  * and notify progress state of the operation.
++  *
++  * @param is input stream (source data)
++  * @param os output stream (destination for data)
++  * @param length predicted number of bytes to copy
++  * @param progress listener to notify
++  * @return number of bytes copied
++  */
++
++stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
++	const stream::size_type length, progressListener* progress);
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_STREAMUTILS_HPP_INCLUDED
++
+diff --git a/vmime/utility/stringProxy.hpp b/vmime/utility/stringProxy.hpp
+index 21c65ea..66a6dfd 100644
+--- a/vmime/utility/stringProxy.hpp
++++ b/vmime/utility/stringProxy.hpp
+@@ -29,6 +29,7 @@
+ 
+ #include "vmime/types.hpp"
+ #include "vmime/utility/stream.hpp"
++#include "vmime/utility/outputStream.hpp"
+ #include "vmime/utility/progressListener.hpp"
+ 
+ 
+diff --git a/vmime/vmime.hpp b/vmime/vmime.hpp
+index f187b9e..fd04853 100644
+--- a/vmime/vmime.hpp
++++ b/vmime/vmime.hpp
+@@ -68,6 +68,22 @@
+ // Encoders
+ #include "vmime/utility/encoder/encoderFactory.hpp"
+ 
++// Streams
++#include "vmime/utility/filteredStream.hpp"
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/inputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamByteBufferAdapter.hpp"
++#include "vmime/utility/inputStreamPointerAdapter.hpp"
++#include "vmime/utility/inputStreamSocketAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringProxyAdapter.hpp"
++#include "vmime/utility/outputStream.hpp"
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/outputStreamByteArrayAdapter.hpp"
++#include "vmime/utility/outputStreamSocketAdapter.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++#include "vmime/utility/streamUtils.hpp"
++
+ // Message builder/parser
+ #include "vmime/messageBuilder.hpp"
+ #include "vmime/messageParser.hpp"
+-- 
+1.7.10.4
+
+
+From be30b47f09c5358db2ac8e42fa2bb4a14ec24c51 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Mon, 16 Apr 2012 22:32:33 +0200
+Subject: [PATCH 37/42] Added ability to parse directly from an input stream
+ (eg. file). This allows very big messages to be
+ parsed without loading the whole message data into
+ memory.
+
+
+diff --git a/ChangeLog b/ChangeLog
+index 8fdcdb0..1b5b2cf 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -2,6 +2,12 @@
+ VERSION 0.9.2svn
+ ================
+ 
++2012-04-16  Vincent Richard  <vincent@vincent-richard.net>
++
++ * MIME Parser can now operate directly on an input stream (eg. file).
++   This allows very big messages to be parsed without loading the whole
++   message data into memory.
++
+ 2010-11-16  Vincent Richard  <vincent@vincent-richard.net>
+ 
+  * Started version 0.9.2.
+diff --git a/SConstruct b/SConstruct
+index ea5c4eb..2690172 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -153,11 +153,14 @@ libvmime_sources = [
+ 	'utility/inputStreamSocketAdapter.cpp', 'utility/inputStreamSocketAdapter.hpp',
+ 	'utility/inputStreamStringAdapter.cpp', 'utility/inputStreamStringAdapter.hpp',
+ 	'utility/inputStreamStringProxyAdapter.cpp', 'utility/inputStreamStringProxyAdapter.hpp',
++	'utility/seekableInputStream.hpp',
++	'utility/seekableInputStreamRegionAdapter.cpp', 'utility/seekableInputStreamRegionAdapter.hpp',
+ 	'utility/outputStream.cpp', 'utility/outputStream.hpp',
+ 	'utility/outputStreamAdapter.cpp', 'utility/outputStreamAdapter.hpp',
+ 	'utility/outputStreamByteArrayAdapter.cpp', 'utility/outputStreamByteArrayAdapter.hpp',
+ 	'utility/outputStreamSocketAdapter.cpp', 'utility/outputStreamSocketAdapter.hpp',
+ 	'utility/outputStreamStringAdapter.cpp', 'utility/outputStreamStringAdapter.hpp',
++	'utility/parserInputStreamAdapter.cpp', 'utility/parserInputStreamAdapter.hpp',
+ 	'utility/stringProxy.cpp', 'utility/stringProxy.hpp',
+ 	'utility/stringUtils.cpp', 'utility/stringUtils.hpp',
+ 	'utility/url.cpp', 'utility/url.hpp',
+diff --git a/src/addressList.cpp b/src/addressList.cpp
+index 31a2a3d..f06460d 100644
+--- a/src/addressList.cpp
++++ b/src/addressList.cpp
+@@ -50,7 +50,7 @@ addressList::~addressList()
+ }
+ 
+ 
+-void addressList::parse(const string& buffer, const string::size_type position,
++void addressList::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	removeAllAddresses();
+@@ -72,7 +72,7 @@ void addressList::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void addressList::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void addressList::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+@@ -248,9 +248,9 @@ const std::vector <ref <address> > addressList::getAddressList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > addressList::getChildComponents() const
++const std::vector <ref <component> > addressList::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_list, list);
+ 
+diff --git a/src/body.cpp b/src/body.cpp
+index 9d7d57f..732fa8b 100644
+--- a/src/body.cpp
++++ b/src/body.cpp
+@@ -31,10 +31,13 @@
+ 
+ #include "vmime/utility/random.hpp"
+ 
++#include "vmime/utility/seekableInputStreamRegionAdapter.hpp"
++
+ #include "vmime/parserHelpers.hpp"
+ 
+ #include "vmime/emptyContentHandler.hpp"
+ #include "vmime/stringContentHandler.hpp"
++#include "vmime/streamContentHandler.hpp"
+ 
+ 
+ namespace vmime
+@@ -52,11 +55,28 @@ body::~body()
+ }
+ 
+ 
+-void body::parse(const string& buffer, const string::size_type position,
+-	const string::size_type end, string::size_type* newPosition)
++void body::parseImpl
++	(ref <utility::parserInputStreamAdapter> parser,
++	 const utility::stream::size_type position,
++	 const utility::stream::size_type end,
++	 utility::stream::size_type* newPosition)
+ {
+ 	removeAllParts();
+ 
++	m_prologText.clear();
++	m_epilogText.clear();
++
++	if (end == position)
++	{
++
++		setParsedBounds(position, end);
++
++		if (newPosition)
++			*newPosition = end;
++
++		return;
++	}
++
+ 	// Check whether the body is a MIME-multipart
+ 	bool isMultipart = false;
+ 	string boundary;
+@@ -80,37 +100,61 @@ void body::parse(const string& buffer, const string::size_type position,
+ 			{
+ 				// No "boundary" parameter specified: we can try to
+ 				// guess it by scanning the body contents...
+-				string::size_type pos = buffer.find("\n--", position);
++				utility::stream::size_type pos = position;
++
++				parser->seek(pos);
++
++				if (pos + 2 < end && parser->matchBytes("--", 2))
++				{
++					pos += 2;
++				}
++				else
++				{
++					pos = parser->findNext("\n--", position);
+ 
+-				if ((pos != string::npos) && (pos < end))
++					if ((pos != utility::stream::npos) && (pos + 3 < end))
++						pos += 3;  // skip \n--
++				}
++
++				if ((pos != utility::stream::npos) && (pos < end))
+ 				{
+-					pos += 3;
++					parser->seek(pos);
+ 
+-					const string::size_type start = pos;
++					// Read some bytes after boundary separator
++					utility::stream::value_type buffer[256];
++					const utility::stream::size_type bufferLen =
++						parser->read(buffer, std::min(end - pos, sizeof(buffer) / sizeof(buffer[0])));
+ 
+-					char_t c = buffer[pos];
+-					string::size_type length = 0;
++					buffer[sizeof(buffer) / sizeof(buffer[0]) - 1] = '\0';
+ 
++					// Extract boundary from buffer (stop at first CR or LF).
+ 					// We have to stop after a reasonnably long boundary length (100)
+ 					// not to take the whole body contents for a boundary...
+-					while (pos < end && length < 100 && !(c == '\r' || c == '\n'))
++					string::value_type boundaryBytes[100];
++					string::size_type boundaryLen = 0;
++
++					for (string::value_type c = buffer[0] ;
++					     boundaryLen < bufferLen && boundaryLen < 100 && !(c == '\r' || c == '\n') ;
++					     c = buffer[++boundaryLen])
+ 					{
+-						++length;
+-						c = buffer[pos++];
++						boundaryBytes[boundaryLen] = buffer[boundaryLen];
+ 					}
+ 
+-					if (pos < end && length < 100)
++					if (boundaryLen >= 1 && boundaryLen < 100)
+ 					{
+ 						// RFC #1521, Page 31:
+ 						// "...the boundary parameter, which consists of 1 to 70
+ 						//  characters from a set of characters known to be very
+ 						//  robust through email gateways, and NOT ending with
+ 						//  white space..."
+-						while (pos != start && parserHelpers::isSpace(buffer[pos - 1]))
+-							--pos;
+-
+-						boundary = string(buffer.begin() + start,
+-						                  buffer.begin() + pos);
++						while (boundaryLen != 0 &&
++						       parserHelpers::isSpace(boundaryBytes[boundaryLen - 1]))
++						{
++							boundaryLen--;
++						}
++
++						if (boundaryLen >= 1)
++							boundary = string(boundaryBytes, boundaryBytes + boundaryLen);
+ 					}
+ 				}
+ 			}
+@@ -126,51 +170,79 @@ void body::parse(const string& buffer, const string::size_type position,
+ 	{
+ 		const string boundarySep("--" + boundary);
+ 
+-		string::size_type partStart = position;
+-		string::size_type pos = position;
++		utility::stream::size_type partStart = position;
++		utility::stream::size_type pos = position;
+ 
+ 		bool lastPart = false;
+ 
+-		while (pos != string::npos && pos < end)
++		while (pos != utility::stream::npos && pos < end)
+ 		{
+-			pos = buffer.find(boundarySep, pos);
+-
+-			if (pos == string::npos ||
+-			    ((pos == 0 || buffer[pos - 1] == '\n') &&
+-			     (buffer[pos + boundarySep.length()] == '\r' ||
+-			      buffer[pos + boundarySep.length()] == '\n' ||
+-			      buffer[pos + boundarySep.length()] == '-'
+-			     )
+-			    )
+-			   )
++			pos = parser->findNext(boundarySep, pos);
++
++			if (pos == utility::stream::npos)
++				break;  // not found
++
++			if (pos != 0)
+ 			{
+-				break;
++				parser->seek(pos - 1);
++
++				if (parser->peekByte() != '\n')
++				{
++					// Boundary is not at a beginning of a line
++					pos++;
++					continue;
++				}
++
++				parser->skip(1 + boundarySep.length());
++			}
++			else
++			{
++				parser->seek(pos + boundarySep.length());
+ 			}
+ 
+-			// boundary not a beginning of line, or just a prefix of another, continue the search.
++			const utility::stream::value_type next = parser->peekByte();
++
++			if (next == '\r' || next == '\n' || next == '-')
++				break;
++
++			// Boundary is a prefix of another, continue the search
+ 			pos++;
+ 		}
+ 
+-		if (pos != string::npos && pos < end)
++		if (pos != utility::stream::npos && pos < end)
+ 		{
+ 			vmime::text text;
+-			text.parse(buffer, position, pos);
++			text.parse(parser, position, pos);
+ 
+ 			m_prologText = text.getWholeBuffer();
+ 		}
+ 
+-		for (int index = 0 ; !lastPart && (pos != string::npos) && (pos < end) ; ++index)
++		for (int index = 0 ; !lastPart && (pos != utility::stream::npos) && (pos < end) ; ++index)
+ 		{
+-			string::size_type partEnd = pos;
++			utility::stream::size_type partEnd = pos;
+ 
+ 			// Get rid of the [CR]LF just before the boundary string
+-			if (pos >= (position + 1) && buffer[pos - 1] == '\n') --partEnd;
+-			if (pos >= (position + 2) && buffer[pos - 2] == '\r') --partEnd;
++			if (pos >= (position + 1))
++			{
++				parser->seek(pos - 1);
++
++				if (parser->peekByte() == '\n')
++					--partEnd;
++			}
++
++			if (pos >= (position + 2))
++			{
++				parser->seek(pos - 2);
++
++				if (parser->peekByte() == '\r')
++					--partEnd;
++			}
+ 
+ 			// Check whether it is the last part (boundary terminated by "--")
+ 			pos += boundarySep.length();
++			parser->seek(pos);
+ 
+-			if (pos + 1 < end && buffer[pos] == '-' && buffer[pos + 1] == '-')
++			if (pos + 1 < end && parser->matchBytes("--", 2))
+ 			{
+ 				lastPart = true;
+ 				pos += 2;
+@@ -180,15 +252,15 @@ void body::parse(const string& buffer, const string::size_type position,
+ 			// "...(If a boundary appears to end with white space, the
+ 			//  white space must be presumed to have been added by a
+ 			//  gateway, and must be deleted.)..."
+-			while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
+-				++pos;
++			parser->seek(pos);
++			pos += parser->skipIf(parserHelpers::isSpaceOrTab, end);
+ 
+ 			// End of boundary line
+-			if (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] =='\n')
++			if (pos + 1 < end && parser->matchBytes("\r\n", 2))
+ 			{
+ 				pos += 2;
+ 			}
+-			else if (pos < end && buffer[pos] == '\n')
++			else if (pos < end && parser->peekByte() == '\n')
+ 			{
+ 				++pos;
+ 			}
+@@ -202,7 +274,7 @@ void body::parse(const string& buffer, const string::size_type position,
+ 				if (partEnd < partStart)
+ 					std::swap(partStart, partEnd);
+ 
+-				part->parse(buffer, partStart, partEnd, NULL);
++				part->parse(parser, partStart, partEnd, NULL);
+ 				part->m_parent = m_part;
+ 
+ 				m_parts.push_back(part);
+@@ -210,23 +282,37 @@ void body::parse(const string& buffer, const string::size_type position,
+ 
+ 			partStart = pos;
+ 
+-			while (pos != string::npos && pos < end)
++			while (pos != utility::stream::npos && pos < end)
+ 			{
+-				pos = buffer.find(boundarySep, pos);
+-
+-				if (pos == string::npos ||
+-				    ((pos == 0 || buffer[pos - 1] == '\n') &&
+-				     (buffer[pos + boundarySep.length()] == '\r' ||
+-				      buffer[pos + boundarySep.length()] == '\n' ||
+-					buffer[pos + boundarySep.length()] == '-'
+-				     )
+-				    )
+-				   )
++				pos = parser->findNext(boundarySep, pos);
++
++				if (pos == utility::stream::npos)
++					break;  // not found
++
++				if (pos != 0)
+ 				{
+-					break;
++					parser->seek(pos - 1);
++
++					if (parser->peekByte() != '\n')
++					{
++						// Boundary is not at a beginning of a line
++						pos++;
++						continue;
++					}
++
++					parser->skip(1 + boundarySep.length());
++				}
++				else
++				{
++					parser->seek(pos + boundarySep.length());
+ 				}
+ 
+-				// boundary not a beginning of line, or just a prefix of another, continue the search.
++				const utility::stream::value_type next = parser->peekByte();
++
++				if (next == '\r' || next == '\n' || next == '-')
++					break;
++
++				// Boundary is a prefix of another, continue the search
+ 				pos++;
+ 			}
+ 		}
+@@ -234,13 +320,13 @@ void body::parse(const string& buffer, const string::size_type position,
+ 		m_contents = vmime::create <emptyContentHandler>();
+ 
+ 		// Last part was not found: recover from missing boundary
+-		if (!lastPart && pos == string::npos)
++		if (!lastPart && pos == utility::stream::npos)
+ 		{
+ 			ref <bodyPart> part = vmime::create <bodyPart>();
+ 
+ 			try
+ 			{
+-				part->parse(buffer, partStart, end);
++				part->parse(parser, partStart, end);
+ 			}
+ 			catch (std::exception&)
+ 			{
+@@ -255,7 +341,7 @@ void body::parse(const string& buffer, const string::size_type position,
+ 		else if (partStart < end)
+ 		{
+ 			vmime::text text;
+-			text.parse(buffer, partStart, end);
++			text.parse(parser, partStart, end);
+ 
+ 			m_epilogText = text.getWholeBuffer();
+ 		}
+@@ -282,7 +368,13 @@ void body::parse(const string& buffer, const string::size_type position,
+ 		}
+ 
+ 		// Extract the (encoded) contents
+-		m_contents = vmime::create <stringContentHandler>(buffer, position, end, enc);
++		const utility::stream::size_type length = end - position;
++
++		ref <utility::inputStream> contentStream =
++			vmime::create <utility::seekableInputStreamRegionAdapter>
++				(parser->getUnderlyingStream(), position, length);
++
++		m_contents = vmime::create <streamContentHandler>(contentStream, length, enc);
+ 	}
+ 
+ 	setParsedBounds(position, end);
+@@ -292,7 +384,7 @@ void body::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void body::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void body::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type /* curLinePos */, string::size_type* newLinePos) const
+ {
+ 	// MIME-Multipart
+@@ -862,9 +954,9 @@ const std::vector <ref <bodyPart> > body::getPartList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > body::getChildComponents() const
++const std::vector <ref <component> > body::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_parts, list);
+ 
+diff --git a/src/bodyPart.cpp b/src/bodyPart.cpp
+index 7d60461..522cbb2 100644
+--- a/src/bodyPart.cpp
++++ b/src/bodyPart.cpp
+@@ -46,15 +46,18 @@ bodyPart::bodyPart(weak_ref <vmime::bodyPart> parentPart)
+ }
+ 
+ 
+-void bodyPart::parse(const string& buffer, const string::size_type position,
+-	const string::size_type end, string::size_type* newPosition)
++void bodyPart::parseImpl
++	(ref <utility::parserInputStreamAdapter> parser,
++	 const utility::stream::size_type position,
++	 const utility::stream::size_type end,
++	 utility::stream::size_type* newPosition)
+ {
+ 	// Parse the headers
+ 	string::size_type pos = position;
+-	m_header->parse(buffer, pos, end, &pos);
++	m_header->parse(parser, pos, end, &pos);
+ 
+ 	// Parse the body contents
+-	m_body->parse(buffer, pos, end, NULL);
++	m_body->parse(parser, pos, end, NULL);
+ 
+ 	setParsedBounds(position, end);
+ 
+@@ -63,7 +66,7 @@ void bodyPart::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void bodyPart::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void bodyPart::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type /* curLinePos */, string::size_type* newLinePos) const
+ {
+ 	m_header->generate(os, maxLineLength);
+@@ -142,9 +145,9 @@ ref <const bodyPart> bodyPart::getParentPart() const
+ }
+ 
+ 
+-const std::vector <ref <const component> > bodyPart::getChildComponents() const
++const std::vector <ref <component> > bodyPart::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	list.push_back(m_header);
+ 	list.push_back(m_body);
+diff --git a/src/charset.cpp b/src/charset.cpp
+index 0fda450..705664f 100644
+--- a/src/charset.cpp
++++ b/src/charset.cpp
+@@ -57,7 +57,7 @@ charset::charset(const char* name)
+ }
+ 
+ 
+-void charset::parse(const string& buffer, const string::size_type position,
++void charset::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	m_name = utility::stringUtils::trim
+@@ -74,7 +74,7 @@ void charset::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void charset::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
++void charset::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	os << m_name;
+@@ -142,9 +142,9 @@ void charset::copyFrom(const component& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > charset::getChildComponents() const
++const std::vector <ref <component> > charset::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/component.cpp b/src/component.cpp
+index 139cf66..e93aacf 100644
+--- a/src/component.cpp
++++ b/src/component.cpp
+@@ -23,6 +23,9 @@
+ 
+ #include "vmime/component.hpp"
+ #include "vmime/base.hpp"
++
++#include "vmime/utility/streamUtils.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
+ #include "vmime/utility/outputStreamAdapter.hpp"
+ 
+ #include <sstream>
+@@ -43,9 +46,102 @@ component::~component()
+ }
+ 
+ 
++void component::parse
++	(ref <utility::inputStream> inputStream, const utility::stream::size_type length)
++{
++	parse(inputStream, 0, length, NULL);
++}
++
++
++void component::parse
++	(ref <utility::inputStream> inputStream, const utility::stream::size_type position,
++	 const utility::stream::size_type end, utility::stream::size_type* newPosition)
++{
++	m_parsedOffset = m_parsedLength = 0;
++
++	ref <utility::seekableInputStream> seekableStream =
++		inputStream.dynamicCast <utility::seekableInputStream>();
++
++	if (seekableStream == NULL || end == 0)
++	{
++		// Read the whole stream into a buffer
++		std::ostringstream oss;
++		utility::outputStreamAdapter ossAdapter(oss);
++
++		utility::bufferedStreamCopyRange(*inputStream, ossAdapter, position, end - position);
++
++		const string buffer = oss.str();
++		parseImpl(buffer, 0, buffer.length(), NULL);
++	}
++	else
++	{
++		ref <utility::parserInputStreamAdapter> parser =
++			vmime::create <utility::parserInputStreamAdapter>(seekableStream);
++
++		parseImpl(parser, position, end, newPosition);
++	}
++}
++
++
+ void component::parse(const string& buffer)
+ {
+-	parse(buffer, 0, buffer.length(), NULL);
++	m_parsedOffset = m_parsedLength = 0;
++
++	parseImpl(buffer, 0, buffer.length(), NULL);
++}
++
++
++void component::parse
++	(const string& buffer, const string::size_type position,
++	 const string::size_type end, string::size_type* newPosition)
++{
++	m_parsedOffset = m_parsedLength = 0;
++
++	parseImpl(buffer, position, end, newPosition);
++}
++
++
++void component::offsetParsedBounds(const utility::stream::size_type offset)
++{
++	// Offset parsed bounds of this component
++	if (m_parsedLength != 0)
++		m_parsedOffset += offset;
++
++	// Offset parsed bounds of our children
++	std::vector <ref <component> > children = getChildComponents();
++
++	for (unsigned int i = 0, n = children.size() ; i < n ; ++i)
++		children[i]->offsetParsedBounds(offset);
++}
++
++
++void component::parseImpl
++	(ref <utility::parserInputStreamAdapter> parser, const utility::stream::size_type position,
++	 const utility::stream::size_type end, utility::stream::size_type* newPosition)
++{
++	const std::string buffer = parser->extract(position, end);
++	parseImpl(buffer, 0, buffer.length(), newPosition);
++
++	// Recursivey offset parsed bounds on children
++	if (position != 0)
++		offsetParsedBounds(position);
++
++	if (newPosition != NULL)
++		*newPosition += position;
++}
++
++
++void component::parseImpl
++	(const string& buffer, const string::size_type position,
++	 const string::size_type end, string::size_type* newPosition)
++{
++	ref <utility::seekableInputStream> stream =
++		vmime::create <utility::inputStreamStringAdapter>(buffer);
++
++	ref <utility::parserInputStreamAdapter> parser =
++		vmime::create <utility::parserInputStreamAdapter>(stream);
++
++	parseImpl(parser, position, end, newPosition);
+ }
+ 
+ 
+@@ -61,6 +157,26 @@ const string component::generate(const string::size_type maxLineLength,
+ }
+ 
+ 
++void component::generate
++	(utility::outputStream& os,
++	 const string::size_type maxLineLength,
++	 const string::size_type curLinePos,
++	 string::size_type* newLinePos) const
++{
++	generateImpl(os, maxLineLength, curLinePos, newLinePos);
++}
++
++
++void component::generate
++	(ref <utility::outputStream> os,
++	 const string::size_type maxLineLength,
++	 const string::size_type curLinePos,
++	 string::size_type* newLinePos) const
++{
++	generateImpl(*os, maxLineLength, curLinePos, newLinePos);
++}
++
++
+ string::size_type component::getParsedOffset() const
+ {
+ 	return (m_parsedOffset);
+@@ -80,22 +196,5 @@ void component::setParsedBounds(const string::size_type start, const string::siz
+ }
+ 
+ 
+-const std::vector <ref <component> > component::getChildComponents()
+-{
+-	const std::vector <ref <const component> > constList =
+-		const_cast <const component*>(this)->getChildComponents();
+-
+-	std::vector <ref <component> > list;
+-
+-	const std::vector <ref <const component> >::size_type count = constList.size();
++} // vmime
+ 
+-	list.resize(count);
+-
+-	for (std::vector <ref <const component> >::size_type i = 0 ; i < count ; ++i)
+-		list[i] = constList[i].constCast <component>();
+-
+-	return (list);
+-}
+-
+-
+-}
+diff --git a/src/contentDisposition.cpp b/src/contentDisposition.cpp
+index 0ab7c45..253dbba 100644
+--- a/src/contentDisposition.cpp
++++ b/src/contentDisposition.cpp
+@@ -47,7 +47,7 @@ contentDisposition::contentDisposition(const contentDisposition& type)
+ }
+ 
+ 
+-void contentDisposition::parse(const string& buffer, const string::size_type position,
++void contentDisposition::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	m_name = utility::stringUtils::trim(utility::stringUtils::toLower
+@@ -60,7 +60,7 @@ void contentDisposition::parse(const string& buffer, const string::size_type pos
+ }
+ 
+ 
+-void contentDisposition::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
++void contentDisposition::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	os << m_name;
+@@ -122,9 +122,9 @@ void contentDisposition::setName(const string& name)
+ }
+ 
+ 
+-const std::vector <ref <const component> > contentDisposition::getChildComponents() const
++const std::vector <ref <component> > contentDisposition::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/dateTime.cpp b/src/dateTime.cpp
+index 089a900..0d97b2f 100644
+--- a/src/dateTime.cpp
++++ b/src/dateTime.cpp
+@@ -67,7 +67,7 @@ zone = "UT" / "GMT"                               ; Universal Time
+ */
+ 
+ 
+-void datetime::parse(const string& buffer, const string::size_type position,
++void datetime::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -588,7 +588,7 @@ void datetime::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void datetime::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
++void datetime::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	static const string::value_type* dayNames[] =
+@@ -784,9 +784,9 @@ ref <component> datetime::clone() const
+ }
+ 
+ 
+-const std::vector <ref <const component> > datetime::getChildComponents() const
++const std::vector <ref <component> > datetime::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/disposition.cpp b/src/disposition.cpp
+index b8059a7..24a4579 100644
+--- a/src/disposition.cpp
++++ b/src/disposition.cpp
+@@ -79,9 +79,9 @@ disposition& disposition::operator=(const disposition& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > disposition::getChildComponents() const
++const std::vector <ref <component> > disposition::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+@@ -171,7 +171,7 @@ const std::vector <string> disposition::getModifierList() const
+ }
+ 
+ 
+-void disposition::parse(const string& buffer, const string::size_type position,
++void disposition::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	// disposition-mode ";" disposition-type
+@@ -276,7 +276,7 @@ void disposition::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void disposition::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void disposition::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+diff --git a/src/encoding.cpp b/src/encoding.cpp
+index 5d99ab6..343a822 100644
+--- a/src/encoding.cpp
++++ b/src/encoding.cpp
+@@ -61,7 +61,7 @@ encoding::encoding(const encoding& enc)
+ }
+ 
+ 
+-void encoding::parse(const string& buffer, const string::size_type position,
++void encoding::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	m_usage = USAGE_UNKNOWN;
+@@ -80,7 +80,7 @@ void encoding::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void encoding::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
++void encoding::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	os << m_name;
+@@ -268,9 +268,9 @@ void encoding::setUsage(const EncodingUsage usage)
+ }
+ 
+ 
+-const std::vector <ref <const component> > encoding::getChildComponents() const
++const std::vector <ref <component> > encoding::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/header.cpp b/src/header.cpp
+index 443aab8..fcdca2c 100644
+--- a/src/header.cpp
++++ b/src/header.cpp
+@@ -61,7 +61,7 @@ field-body-contents =
+ 		 specials tokens, or else consisting of texts>
+ */
+ 
+-void header::parse(const string& buffer, const string::size_type position,
++void header::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	string::size_type pos = position;
+@@ -83,7 +83,7 @@ void header::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void header::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void header::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type /* curLinePos */, string::size_type* newLinePos) const
+ {
+ 	// Generate the fields
+@@ -337,9 +337,9 @@ const std::vector <ref <headerField> > header::getFieldList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > header::getChildComponents() const
++const std::vector <ref <component> > header::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_fields, list);
+ 
+diff --git a/src/headerField.cpp b/src/headerField.cpp
+index d1d4236..a8460aa 100644
+--- a/src/headerField.cpp
++++ b/src/headerField.cpp
+@@ -262,14 +262,14 @@ ref <headerField> headerField::parseNext(const string& buffer, const string::siz
+ }
+ 
+ 
+-void headerField::parse(const string& buffer, const string::size_type position, const string::size_type end,
++void headerField::parseImpl(const string& buffer, const string::size_type position, const string::size_type end,
+ 	string::size_type* newPosition)
+ {
+ 	m_value->parse(buffer, position, end, newPosition);
+ }
+ 
+ 
+-void headerField::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void headerField::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	os << m_name + ": ";
+@@ -296,9 +296,9 @@ bool headerField::isCustom() const
+ }
+ 
+ 
+-const std::vector <ref <const component> > headerField::getChildComponents() const
++const std::vector <ref <component> > headerField::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	if (m_value)
+ 		list.push_back(m_value);
+diff --git a/src/mailbox.cpp b/src/mailbox.cpp
+index fea7479..dfdccad 100644
+--- a/src/mailbox.cpp
++++ b/src/mailbox.cpp
+@@ -65,7 +65,7 @@ angle-addr      =       [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
+ 
+ */
+ 
+-void mailbox::parse(const string& buffer, const string::size_type position,
++void mailbox::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -343,7 +343,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void mailbox::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void mailbox::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	if (m_name.isEmpty())
+@@ -514,9 +514,9 @@ void mailbox::setEmail(const string& email)
+ }
+ 
+ 
+-const std::vector <ref <const component> > mailbox::getChildComponents() const
++const std::vector <ref <component> > mailbox::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/mailboxGroup.cpp b/src/mailboxGroup.cpp
+index 94f7ba6..c37444a 100644
+--- a/src/mailboxGroup.cpp
++++ b/src/mailboxGroup.cpp
+@@ -54,7 +54,7 @@ mailboxGroup::~mailboxGroup()
+ }
+ 
+ 
+-void mailboxGroup::parse(const string& buffer, const string::size_type position,
++void mailboxGroup::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -111,7 +111,7 @@ void mailboxGroup::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void mailboxGroup::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void mailboxGroup::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	// We have to encode the name:
+@@ -348,9 +348,9 @@ const std::vector <ref <mailbox> > mailboxGroup::getMailboxList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > mailboxGroup::getChildComponents() const
++const std::vector <ref <component> > mailboxGroup::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_list, list);
+ 
+diff --git a/src/mailboxList.cpp b/src/mailboxList.cpp
+index 0023d9d..f87fb48 100644
+--- a/src/mailboxList.cpp
++++ b/src/mailboxList.cpp
+@@ -190,20 +190,20 @@ mailboxList& mailboxList::operator=(const mailboxList& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > mailboxList::getChildComponents() const
++const std::vector <ref <component> > mailboxList::getChildComponents()
+ {
+ 	return (m_list.getChildComponents());
+ }
+ 
+ 
+-void mailboxList::parse(const string& buffer, const string::size_type position,
++void mailboxList::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	m_list.parse(buffer, position, end, newPosition);
+ }
+ 
+ 
+-void mailboxList::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void mailboxList::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	m_list.generate(os, maxLineLength, curLinePos, newLinePos);
+diff --git a/src/mediaType.cpp b/src/mediaType.cpp
+index 725f933..627b276 100644
+--- a/src/mediaType.cpp
++++ b/src/mediaType.cpp
+@@ -48,7 +48,7 @@ mediaType::mediaType(const string& type, const string& subType)
+ }
+ 
+ 
+-void mediaType::parse(const string& buffer, const string::size_type position,
++void mediaType::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -82,7 +82,7 @@ void mediaType::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void mediaType::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void mediaType::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	const string value = m_type + "/" + m_subType;
+@@ -176,9 +176,9 @@ void mediaType::setFromString(const string& type)
+ }
+ 
+ 
+-const std::vector <ref <const component> > mediaType::getChildComponents() const
++const std::vector <ref <component> > mediaType::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/message.cpp b/src/message.cpp
+index 1b4f086..3fa9b6a 100644
+--- a/src/message.cpp
++++ b/src/message.cpp
+@@ -61,9 +61,14 @@ const string message::generate(const string::size_type maxLineLength,
+ }
+ 
+ 
+-void message::parse(const string& buffer)
++
++void message::generate
++	(ref <utility::outputStream> os,
++	 const string::size_type maxLineLength,
++	 const string::size_type curLinePos,
++	 string::size_type* newLinePos) const
+ {
+-	bodyPart::parse(buffer);
++	bodyPart::generate(os, maxLineLength, curLinePos, newLinePos);
+ }
+ 
+ 
+diff --git a/src/messageId.cpp b/src/messageId.cpp
+index 961fb63..1f4b186 100644
+--- a/src/messageId.cpp
++++ b/src/messageId.cpp
+@@ -61,7 +61,7 @@ messageId::messageId(const string& left, const string& right)
+ 	msg-id          =       [CFWS] "<" id-left "@" id-right ">" [CFWS]
+ */
+ 
+-void messageId::parse(const string& buffer, const string::size_type position,
++void messageId::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -185,7 +185,7 @@ const string messageId::getId() const
+ }
+ 
+ 
+-void messageId::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void messageId::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+@@ -288,9 +288,9 @@ void messageId::setRight(const string& right)
+ }
+ 
+ 
+-const std::vector <ref <const component> > messageId::getChildComponents() const
++const std::vector <ref <component> > messageId::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/messageIdSequence.cpp b/src/messageIdSequence.cpp
+index 08103d0..0a5c9a0 100644
+--- a/src/messageIdSequence.cpp
++++ b/src/messageIdSequence.cpp
+@@ -74,9 +74,9 @@ messageIdSequence& messageIdSequence::operator=(const messageIdSequence& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > messageIdSequence::getChildComponents() const
++const std::vector <ref <component> > messageIdSequence::getChildComponents()
+ {
+-	std::vector <ref <const component> > res;
++	std::vector <ref <component> > res;
+ 
+ 	copy_vector(m_list, res);
+ 
+@@ -84,7 +84,7 @@ const std::vector <ref <const component> > messageIdSequence::getChildComponents
+ }
+ 
+ 
+-void messageIdSequence::parse(const string& buffer, const string::size_type position,
++void messageIdSequence::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	removeAllMessageIds();
+@@ -106,7 +106,7 @@ void messageIdSequence::parse(const string& buffer, const string::size_type posi
+ }
+ 
+ 
+-void messageIdSequence::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void messageIdSequence::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+diff --git a/src/parameter.cpp b/src/parameter.cpp
+index ccbe1a5..58d9a3e 100644
+--- a/src/parameter.cpp
++++ b/src/parameter.cpp
+@@ -36,19 +36,19 @@ namespace vmime
+ 
+ 
+ parameter::parameter(const string& name)
+-	: m_name(name)
++	: m_name(name), m_value(vmime::create <word>())
+ {
+ }
+ 
+ 
+ parameter::parameter(const string& name, const word& value)
+-	: m_name(name), m_value(value)
++	: m_name(name), m_value(vmime::create <word>(value))
+ {
+ }
+ 
+ 
+ parameter::parameter(const string& name, const string& value)
+-	: m_name(name), m_value(value)
++	: m_name(name), m_value(vmime::create <word>(value))
+ {
+ }
+ 
+@@ -73,7 +73,7 @@ void parameter::copyFrom(const component& other)
+ 	const parameter& param = dynamic_cast <const parameter&>(other);
+ 
+ 	m_name = param.m_name;
+-	m_value.copyFrom(param.m_value);
++	m_value->copyFrom(*param.m_value);
+ }
+ 
+ 
+@@ -92,7 +92,7 @@ const string& parameter::getName() const
+ 
+ const word& parameter::getValue() const
+ {
+-	return m_value;
++	return *m_value;
+ }
+ 
+ 
+@@ -109,15 +109,15 @@ void parameter::setValue(const component& value)
+ 
+ void parameter::setValue(const word& value)
+ {
+-	m_value = value;
++	*m_value = value;
+ }
+ 
+ 
+-void parameter::parse(const string& buffer, const string::size_type position,
++void parameter::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+-	m_value.setBuffer(string(buffer.begin() + position, buffer.begin() + end));
+-	m_value.setCharset(charset(charsets::US_ASCII));
++	m_value->setBuffer(string(buffer.begin() + position, buffer.begin() + end));
++	m_value->setCharset(charset(charsets::US_ASCII));
+ 
+ 	if (newPosition)
+ 		*newPosition = end;
+@@ -248,16 +248,16 @@ void parameter::parse(const std::vector <valueChunk>& chunks)
+ 		}
+ 	}
+ 
+-	m_value.setBuffer(value.str());
+-	m_value.setCharset(ch);
++	m_value->setBuffer(value.str());
++	m_value->setCharset(ch);
+ }
+ 
+ 
+-void parameter::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void parameter::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	const string& name = m_name;
+-	const string& value = m_value.getBuffer();
++	const string& value = m_value->getBuffer();
+ 
+ 	// For compatibility with implementations that do not understand RFC-2231,
+ 	// also generate a normal "7bit/us-ascii" parameter
+@@ -344,7 +344,7 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ 	// 7-bit (ASCII) bytes in the input will be used to determine if
+ 	// we need to encode the whole buffer.
+ 	encoding recommendedEnc;
+-	const bool alwaysEncode = m_value.getCharset().getRecommendedEncoding(recommendedEnc);
++	const bool alwaysEncode = m_value->getCharset().getRecommendedEncoding(recommendedEnc);
+ 	bool extended = alwaysEncode;
+ 
+ 	if (needQuotedPrintable)
+@@ -352,7 +352,7 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ 		// Send the name in quoted-printable, so outlook express et.al.
+ 		// will understand the real filename
+ 		size_t oldLen = sevenBitBuffer.length();
+-		m_value.generate(sevenBitStream);
++		m_value->generate(sevenBitStream);
+ 		pos += sevenBitBuffer.length() - oldLen;
+ 		extended = true;		// also send with RFC-2231 encoding
+ 	}
+@@ -429,7 +429,7 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ 		// + at least 5 characters for the value
+ 		const string::size_type firstSectionLength =
+ 			  name.length() + 4 /* *0*= */ + 2 /* '' */
+-			+ m_value.getCharset().getName().length();
++			+ m_value->getCharset().getName().length();
+ 
+ 		if (pos + firstSectionLength + 5 >= maxLineLength)
+ 		{
+@@ -539,7 +539,7 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ 
+ 			if (sectionNumber == 0)
+ 			{
+-				os << m_value.getCharset().getName();
++				os << m_value->getCharset().getName();
+ 				os << '\'' << /* No language */ '\'';
+ 			}
+ 
+@@ -570,11 +570,11 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ }
+ 
+ 
+-const std::vector <ref <const component> > parameter::getChildComponents() const
++const std::vector <ref <component> > parameter::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+-	list.push_back(ref <const component>::fromPtr(&m_value));
++	list.push_back(m_value);
+ 
+ 	return list;
+ }
+diff --git a/src/parameterizedHeaderField.cpp b/src/parameterizedHeaderField.cpp
+index 464990e..756d02f 100644
+--- a/src/parameterizedHeaderField.cpp
++++ b/src/parameterizedHeaderField.cpp
+@@ -78,7 +78,7 @@ struct paramInfo
+ #endif // VMIME_BUILDING_DOC
+ 
+ 
+-void parameterizedHeaderField::parse(const string& buffer, const string::size_type position,
++void parameterizedHeaderField::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -328,13 +328,13 @@ void parameterizedHeaderField::parse(const string& buffer, const string::size_ty
+ }
+ 
+ 
+-void parameterizedHeaderField::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void parameterizedHeaderField::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+ 
+ 	// Parent header field
+-	headerField::generate(os, maxLineLength, pos, &pos);
++	headerField::generateImpl(os, maxLineLength, pos, &pos);
+ 
+ 	// Parameters
+ 	for (std::vector <ref <parameter> >::const_iterator
+@@ -552,11 +552,11 @@ const std::vector <ref <parameter> > parameterizedHeaderField::getParameterList(
+ }
+ 
+ 
+-const std::vector <ref <const component> > parameterizedHeaderField::getChildComponents() const
++const std::vector <ref <component> > parameterizedHeaderField::getChildComponents()
+ {
+-	std::vector <ref <const component> > list = headerField::getChildComponents();
++	std::vector <ref <component> > list = headerField::getChildComponents();
+ 
+-	for (std::vector <ref <parameter> >::const_iterator it = m_params.begin() ;
++	for (std::vector <ref <parameter> >::iterator it = m_params.begin() ;
+ 	     it != m_params.end() ; ++it)
+ 	{
+ 		list.push_back(*it);
+diff --git a/src/path.cpp b/src/path.cpp
+index 37a4090..d92bb0a 100644
+--- a/src/path.cpp
++++ b/src/path.cpp
+@@ -106,14 +106,14 @@ path& path::operator=(const path& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > path::getChildComponents() const
++const std::vector <ref <component> > path::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+-void path::parse(const string& buffer, const string::size_type position,
+-                 const string::size_type end, string::size_type* newPosition)
++void path::parseImpl(const string& buffer, const string::size_type position,
++	const string::size_type end, string::size_type* newPosition)
+ {
+ 	string::size_type pos = position;
+ 
+@@ -165,8 +165,8 @@ void path::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void path::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
+-                    const string::size_type curLinePos, string::size_type* newLinePos) const
++void path::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
++	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	if (m_localPart.empty() && m_domain.empty())
+ 	{
+diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp
+index ec529eb..4087a21 100644
+--- a/src/platforms/posix/posixFile.cpp
++++ b/src/platforms/posix/posixFile.cpp
+@@ -224,6 +224,26 @@ vmime::utility::stream::size_type posixFileReaderInputStream::skip(const size_ty
+ }
+ 
+ 
++vmime::utility::stream::size_type posixFileReaderInputStream::getPosition() const
++{
++	const off_t curPos = ::lseek(m_fd, 0, SEEK_CUR);
++
++	if (curPos == off_t(-1))
++		posixFileSystemFactory::reportError(m_path, errno);
++
++	return static_cast <size_type>(curPos);
++}
++
++
++void posixFileReaderInputStream::seek(const size_type pos)
++{
++	const off_t newPos = ::lseek(m_fd, pos, SEEK_SET);
++
++	if (newPos == off_t(-1))
++		posixFileSystemFactory::reportError(m_path, errno);
++}
++
++
+ 
+ //
+ // posixFileWriter
+diff --git a/src/platforms/windows/windowsFile.cpp b/src/platforms/windows/windowsFile.cpp
+index 624612a..5da786e 100644
+--- a/src/platforms/windows/windowsFile.cpp
++++ b/src/platforms/windows/windowsFile.cpp
+@@ -479,6 +479,24 @@ vmime::utility::stream::size_type windowsFileReaderInputStream::skip(const size_
+ 	return (dwNewPos - dwCurPos);
+ }
+ 
++vmime::utility::stream::size_type windowsFileReaderInputStream::getPosition() const
++{
++	DWORD dwCurPos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
++
++	if (dwCurPos == INVALID_SET_FILE_POINTER)
++		windowsFileSystemFactory::reportError(m_path, GetLastError());
++
++	return static_cast <size_type>(dwCurPos);
++}
++
++void windowsFileReaderInputStream::seek(const size_type pos)
++{
++	DWORD dwNewPos = SetFilePointer(m_hFile, (LONG)pos, NULL, FILE_BEGIN);
++
++	if (dwNewPos == INVALID_SET_FILE_POINTER)
++		windowsFileSystemFactory::reportError(m_path, GetLastError());
++}
++
+ windowsFileWriter::windowsFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath)
+ : m_path(path), m_nativePath(nativePath)
+ {
+diff --git a/src/relay.cpp b/src/relay.cpp
+index 5cd454f..97f793d 100644
+--- a/src/relay.cpp
++++ b/src/relay.cpp
+@@ -57,7 +57,7 @@ relay::relay(const relay& r)
+                        ["for"  addr-spec]        ; initial form
+ */
+ 
+-void relay::parse(const string& buffer, const string::size_type position,
++void relay::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -198,7 +198,7 @@ void relay::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void relay::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void relay::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	std::ostringstream oss;
+@@ -338,10 +338,10 @@ std::vector <string>& relay::getWithList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > relay::getChildComponents() const
++const std::vector <ref <component> > relay::getChildComponents()
+ {
+ 	// TODO: should fields inherit from 'component'? (using typeAdapter)
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/streamContentHandler.cpp b/src/streamContentHandler.cpp
+index 89a36b4..14837d2 100644
+--- a/src/streamContentHandler.cpp
++++ b/src/streamContentHandler.cpp
+@@ -25,6 +25,7 @@
+ 
+ #include "vmime/utility/outputStreamAdapter.hpp"
+ #include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ #include "vmime/utility/streamUtils.hpp"
+ 
+ 
+@@ -207,6 +208,9 @@ const vmime::encoding& streamContentHandler::getEncoding() const
+ 
+ bool streamContentHandler::isBuffered() const
+ {
++	if (m_stream.dynamicCast <utility::seekableInputStream>() != NULL)
++		return true;
++
+ 	// FIXME: some streams can be resetted
+ 	return false;
+ }
+diff --git a/src/text.cpp b/src/text.cpp
+index 66c3b35..91b81e1 100644
+--- a/src/text.cpp
++++ b/src/text.cpp
+@@ -67,7 +67,7 @@ text::~text()
+ }
+ 
+ 
+-void text::parse(const string& buffer, const string::size_type position,
++void text::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	removeAllWords();
+@@ -85,7 +85,7 @@ void text::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void text::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void text::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	encodeAndFold(os, maxLineLength, curLinePos, newLinePos, 0);
+@@ -389,9 +389,9 @@ text* text::decodeAndUnfold(const string& in, text* generateInExisting)
+ }
+ 
+ 
+-const std::vector <ref <const component> > text::getChildComponents() const
++const std::vector <ref <component> > text::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_words, list);
+ 
+diff --git a/src/utility/inputStreamAdapter.cpp b/src/utility/inputStreamAdapter.cpp
+index b44b084..441307b 100644
+--- a/src/utility/inputStreamAdapter.cpp
++++ b/src/utility/inputStreamAdapter.cpp
+@@ -65,6 +65,18 @@ stream::size_type inputStreamAdapter::skip(const size_type count)
+ }
+ 
+ 
++stream::size_type inputStreamAdapter::getPosition() const
++{
++	return m_stream.tellg();
++}
++
++
++void inputStreamAdapter::seek(const size_type pos)
++{
++	m_stream.seekg(pos, std::ios_base::beg);
++}
++
++
+ } // utility
+ } // vmime
+ 
+diff --git a/src/utility/inputStreamByteBufferAdapter.cpp b/src/utility/inputStreamByteBufferAdapter.cpp
+index 92e779f..907f1ee 100644
+--- a/src/utility/inputStreamByteBufferAdapter.cpp
++++ b/src/utility/inputStreamByteBufferAdapter.cpp
+@@ -85,6 +85,19 @@ stream::size_type inputStreamByteBufferAdapter::skip(const size_type count)
+ }
+ 
+ 
++stream::size_type inputStreamByteBufferAdapter::getPosition() const
++{
++	return m_pos;
++}
++
++
++void inputStreamByteBufferAdapter::seek(const size_type pos)
++{
++	if (pos <= m_length)
++		m_pos = pos;
++}
++
++
+ } // utility
+ } // vmime
+ 
+diff --git a/src/utility/inputStreamStringAdapter.cpp b/src/utility/inputStreamStringAdapter.cpp
+index 31c9fda..9b8fb0c 100644
+--- a/src/utility/inputStreamStringAdapter.cpp
++++ b/src/utility/inputStreamStringAdapter.cpp
+@@ -89,6 +89,19 @@ stream::size_type inputStreamStringAdapter::skip(const size_type count)
+ }
+ 
+ 
++stream::size_type inputStreamStringAdapter::getPosition() const
++{
++	return m_pos - m_begin;
++}
++
++
++void inputStreamStringAdapter::seek(const size_type pos)
++{
++	if (m_begin + pos <= m_end)
++		m_pos = m_begin + pos;
++}
++
++
+ } // utility
+ } // vmime
+ 
+diff --git a/src/utility/inputStreamStringProxyAdapter.cpp b/src/utility/inputStreamStringProxyAdapter.cpp
+index 5e4b60b..feecddd 100644
+--- a/src/utility/inputStreamStringProxyAdapter.cpp
++++ b/src/utility/inputStreamStringProxyAdapter.cpp
+@@ -84,6 +84,19 @@ stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
+ }
+ 
+ 
++stream::size_type inputStreamStringProxyAdapter::getPosition() const
++{
++	return m_pos;
++}
++
++
++void inputStreamStringProxyAdapter::seek(const size_type pos)
++{
++	if (pos <= m_buffer.length())
++		m_pos = pos;
++}
++
++
+ } // utility
+ } // vmime
+ 
+diff --git a/src/utility/parserInputStreamAdapter.cpp b/src/utility/parserInputStreamAdapter.cpp
+new file mode 100644
+index 0000000..7a38ef1
+--- /dev/null
++++ b/src/utility/parserInputStreamAdapter.cpp
+@@ -0,0 +1,162 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/parserInputStreamAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++parserInputStreamAdapter::parserInputStreamAdapter(ref <seekableInputStream> stream)
++	: m_stream(stream)
++{
++}
++
++
++bool parserInputStreamAdapter::eof() const
++{
++	return m_stream->eof();
++}
++
++
++void parserInputStreamAdapter::reset()
++{
++	m_stream->reset();
++}
++
++
++stream::size_type parserInputStreamAdapter::read
++	(value_type* const data, const size_type count)
++{
++	return m_stream->read(data, count);
++}
++
++
++ref <seekableInputStream> parserInputStreamAdapter::getUnderlyingStream()
++{
++	return m_stream;
++}
++
++
++const string parserInputStreamAdapter::extract(const size_type begin, const size_type end) const
++{
++	const size_type initialPos = m_stream->getPosition();
++
++	try
++	{
++		value_type *buffer = new value_type[end - begin + 1];
++
++		m_stream->seek(begin);
++
++		const size_type readBytes = m_stream->read(buffer, end - begin);
++		buffer[readBytes] = '\0';
++
++		m_stream->seek(initialPos);
++
++		string str(buffer, buffer + readBytes);
++		delete [] buffer;
++
++		return str;
++	}
++	catch (...)
++	{
++		m_stream->seek(initialPos);
++		throw;
++	}
++}
++
++
++stream::size_type parserInputStreamAdapter::findNext
++	(const std::string& token, const size_type startPosition)
++{
++	static const unsigned int BUFFER_SIZE = 4096;
++
++	// Token must not be longer than BUFFER_SIZE/2
++	if (token.empty() || token.length() > BUFFER_SIZE / 2)
++		return npos;
++
++	const size_type initialPos = getPosition();
++
++	seek(startPosition);
++
++	try
++	{
++		value_type findBuffer[BUFFER_SIZE];
++		value_type* findBuffer1 = findBuffer;
++		value_type* findBuffer2 = findBuffer + (BUFFER_SIZE / 2) * sizeof(value_type);
++
++		size_type findBufferLen = 0;
++		size_type findBufferOffset = 0;
++
++		// Fill in initial buffer
++		findBufferLen = read(findBuffer, BUFFER_SIZE * sizeof(value_type));
++
++		for (;;)
++		{
++			// Find token
++			for (value_type *begin = findBuffer, *end = findBuffer + findBufferLen - token.length() ;
++			     begin <= end ; ++begin)
++			{
++				if (begin[0] == token[0] &&
++				    (token.length() == 1 ||
++				     memcmp(static_cast <const void *>(&begin[1]),
++				            static_cast <const void *>(token.data() + 1),
++				            token.length() - 1) == 0))
++				{
++					seek(initialPos);
++					return startPosition + findBufferOffset + (begin - findBuffer);
++				}
++			}
++
++			// Rotate buffer
++			memcpy(findBuffer1, findBuffer2, (BUFFER_SIZE / 2) * sizeof(value_type));
++
++			// Read more bytes
++			if (findBufferLen < BUFFER_SIZE && eof())
++			{
++				break;
++			}
++			else
++			{
++				const size_type bytesRead = read(findBuffer2, (BUFFER_SIZE / 2) * sizeof(value_type));
++				findBufferLen = (BUFFER_SIZE / 2) + bytesRead;
++				findBufferOffset += (BUFFER_SIZE / 2);
++			}
++		}
++
++		seek(initialPos);
++	}
++	catch (...)
++	{
++		seek(initialPos);
++		throw;
++	}
++
++	return npos;
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/seekableInputStreamRegionAdapter.cpp b/src/utility/seekableInputStreamRegionAdapter.cpp
+new file mode 100644
+index 0000000..348618c
+--- /dev/null
++++ b/src/utility/seekableInputStreamRegionAdapter.cpp
+@@ -0,0 +1,95 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/seekableInputStreamRegionAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++seekableInputStreamRegionAdapter::seekableInputStreamRegionAdapter
++	(ref <seekableInputStream> stream, const size_type begin, const size_type length)
++	: m_stream(stream), m_begin(begin), m_length(length)
++{
++}
++
++
++bool seekableInputStreamRegionAdapter::eof() const
++{
++	return getPosition() >= m_length;
++}
++
++
++void seekableInputStreamRegionAdapter::reset()
++{
++	m_stream->seek(m_begin);
++}
++
++
++stream::size_type seekableInputStreamRegionAdapter::read
++	(value_type* const data, const size_type count)
++{
++	if (getPosition() + count >= m_length)
++	{
++		const size_type remaining = m_length - getPosition();
++		return m_stream->read(data, remaining);
++	}
++	else
++	{
++		return m_stream->read(data, count);
++	}
++}
++
++
++stream::size_type seekableInputStreamRegionAdapter::skip(const size_type count)
++{
++	if (getPosition() + count >= m_length)
++	{
++		const size_type remaining = m_length - getPosition();
++		m_stream->skip(remaining);
++		return remaining;
++	}
++	else
++	{
++		m_stream->skip(count);
++		return count;
++	}
++}
++
++
++stream::size_type seekableInputStreamRegionAdapter::getPosition() const
++{
++	return m_stream->getPosition() - m_begin;
++}
++
++
++void seekableInputStreamRegionAdapter::seek(const size_type pos)
++{
++	m_stream->seek(m_begin + pos);
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/stream.cpp b/src/utility/stream.cpp
+index 1c940c2..67c1f33 100644
+--- a/src/utility/stream.cpp
++++ b/src/utility/stream.cpp
+@@ -29,6 +29,9 @@ namespace vmime {
+ namespace utility {
+ 
+ 
++const stream::size_type stream::npos = static_cast <size_type>(vmime::string::npos);
++
++
+ stream::size_type stream::getBlockSize()
+ {
+ 	return 32768;  // 32 KB
+@@ -37,3 +40,4 @@ stream::size_type stream::getBlockSize()
+ 
+ } // utility
+ } // vmime
++
+diff --git a/src/utility/streamUtils.cpp b/src/utility/streamUtils.cpp
+index f1d3b9d..f7ea62f 100644
+--- a/src/utility/streamUtils.cpp
++++ b/src/utility/streamUtils.cpp
+@@ -52,6 +52,35 @@ stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os)
+ }
+ 
+ 
++stream::size_type bufferedStreamCopyRange(inputStream& is, outputStream& os,
++	const stream::size_type start, const stream::size_type length)
++{
++	const stream::size_type blockSize =
++		std::min(is.getBlockSize(), os.getBlockSize());
++
++	is.skip(start);
++
++	std::vector <stream::value_type> vbuffer(blockSize);
++
++	stream::value_type* buffer = &vbuffer.front();
++	stream::size_type total = 0;
++
++	while (!is.eof() && total < length)
++	{
++		const stream::size_type remaining = std::min(length - total, blockSize);
++		const stream::size_type read = is.read(buffer, blockSize);
++
++		if (read != 0)
++		{
++			os.write(buffer, read);
++			total += read;
++		}
++	}
++
++	return total;
++}
++
++
+ stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
+ 	const stream::size_type length, progressListener* progress)
+ {
+diff --git a/src/word.cpp b/src/word.cpp
+index 79060a1..2876ddf 100644
+--- a/src/word.cpp
++++ b/src/word.cpp
+@@ -241,7 +241,7 @@ const std::vector <ref <word> > word::parseMultiple(const string& buffer, const
+ }
+ 
+ 
+-void word::parse(const string& buffer, const string::size_type position,
++void word::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	if (position + 6 < end && // 6 = "=?(.+)?(.*)?="
+@@ -324,7 +324,7 @@ void word::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void word::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void word::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	generate(os, maxLineLength, curLinePos, newLinePos, 0, NULL);
+@@ -743,9 +743,9 @@ void word::setBuffer(const string& buffer)
+ }
+ 
+ 
+-const std::vector <ref <const component> > word::getChildComponents() const
++const std::vector <ref <component> > word::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
+index 9d51262..deb4b9c 100644
+--- a/tests/parser/bodyPartTest.cpp
++++ b/tests/parser/bodyPartTest.cpp
+@@ -33,12 +33,14 @@ VMIME_TEST_SUITE_BEGIN
+ 	VMIME_TEST_LIST_BEGIN
+ 		VMIME_TEST(testParse)
+ 		VMIME_TEST(testGenerate)
++		VMIME_TEST(testParseGuessBoundary)
+ 		VMIME_TEST(testParseMissingLastBoundary)
+ 		VMIME_TEST(testPrologEpilog)
+ 		VMIME_TEST(testPrologEncoding)
+ 		VMIME_TEST(testSuccessiveBoundaries)
+ 		VMIME_TEST(testGenerate7bit)
+ 		VMIME_TEST(testTextUsageForQPEncoding)
++		VMIME_TEST(testParseVeryBigMessage)
+ 	VMIME_TEST_LIST_END
+ 
+ 
+@@ -237,6 +239,93 @@ VMIME_TEST_SUITE_BEGIN
+ 		VASSERT_EQ("2", "Part1-line1\r\nPart1-line2\r\n=89", oss.str());
+ 	}
+ 
++	void testParseGuessBoundary()
++	{
++		// Boundary is not specified in "Content-Type" field
++		// Parser will try to guess it from message contents.
++
++		vmime::string str =
++			"Content-Type: multipart/mixed"
++			"\r\n\r\n"
++			"--UNKNOWN-BOUNDARY\r\nHEADER1\r\n\r\nBODY1\r\n"
++			"--UNKNOWN-BOUNDARY\r\nHEADER2\r\n\r\nBODY2\r\n"
++			"--UNKNOWN-BOUNDARY--";
++
++		vmime::bodyPart p;
++		p.parse(str);
++
++		VASSERT_EQ("count", 2, p.getBody()->getPartCount());
++
++		VASSERT_EQ("part1-body", "BODY1", extractContents(p.getBody()->getPartAt(0)->getBody()->getContents()));
++		VASSERT_EQ("part2-body", "BODY2", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
++	}
++
++	void testParseVeryBigMessage()
++	{
++		// When parsing from a seekable input stream, body contents should not
++		// be kept in memory in a "stringContentHandler" object. Instead, content
++		// should be accessible via a "streamContentHandler" object.
++
++		static const std::string BODY1_BEGIN = "BEGIN1BEGIN1BEGIN1";
++		static const std::string BODY1_LINE = "BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1";
++		static const std::string BODY1_END = "END1END1";
++		static const unsigned int BODY1_REPEAT = 35000;
++		static const unsigned int BODY1_LENGTH =
++			BODY1_BEGIN.length() + BODY1_LINE.length() * BODY1_REPEAT + BODY1_END.length();
++
++		static const std::string BODY2_LINE = "BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2";
++		static const unsigned int BODY2_REPEAT = 20000;
++
++		std::ostringstream oss;
++		oss << "Content-Type: multipart/mixed; boundary=\"MY-BOUNDARY\""
++		    << "\r\n\r\n"
++		    << "--MY-BOUNDARY\r\n"
++		    << "HEADER1\r\n"
++		    << "\r\n";
++
++		oss << BODY1_BEGIN;
++
++		for (unsigned int i = 0 ; i < BODY1_REPEAT ; ++i)
++			oss << BODY1_LINE;
++
++		oss << BODY1_END;
++
++		oss << "\r\n"
++		    << "--MY-BOUNDARY\r\n"
++		    << "HEADER2\r\n"
++		    << "\r\n";
++
++		for (unsigned int i = 0 ; i < BODY2_REPEAT ; ++i)
++			oss << BODY2_LINE;
++
++		oss << "\r\n"
++		    << "--MY-BOUNDARY--\r\n";
++
++		vmime::ref <vmime::utility::inputStreamStringAdapter> is =
++			vmime::create <vmime::utility::inputStreamStringAdapter>(oss.str());
++
++		vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
++		msg->parse(is, oss.str().length());
++
++		vmime::ref <vmime::body> body1 = msg->getBody()->getPartAt(0)->getBody();
++		vmime::ref <const vmime::contentHandler> body1Cts = body1->getContents();
++
++		vmime::ref <vmime::body> body2 = msg->getBody()->getPartAt(1)->getBody();
++		vmime::ref <const vmime::contentHandler> body2Cts = body2->getContents();
++
++		vmime::string body1CtsExtracted;
++		vmime::utility::outputStreamStringAdapter body1CtsExtractStream(body1CtsExtracted);
++		body1Cts->extract(body1CtsExtractStream);
++
++		VASSERT_EQ("1.1", BODY1_LENGTH, body1Cts->getLength());
++		VASSERT("1.2", body1Cts.dynamicCast <const vmime::streamContentHandler>() != NULL);
++		VASSERT_EQ("1.3", BODY1_LENGTH, body1CtsExtracted.length());
++		VASSERT_EQ("1.4", BODY1_BEGIN, body1CtsExtracted.substr(0, BODY1_BEGIN.length()));
++		VASSERT_EQ("1.5", BODY1_END, body1CtsExtracted.substr(BODY1_LENGTH - BODY1_END.length(), BODY1_END.length()));
++
++		VASSERT_EQ("2.1", BODY2_LINE.length() * BODY2_REPEAT, body2Cts->getLength());
++		VASSERT("2.2", body2Cts.dynamicCast <const vmime::streamContentHandler>() != NULL);
++	}
+ 
+ VMIME_TEST_SUITE_END
+ 
+diff --git a/vmime/addressList.hpp b/vmime/addressList.hpp
+index 2e537c0..9dc283c 100644
+--- a/vmime/addressList.hpp
++++ b/vmime/addressList.hpp
+@@ -56,7 +56,7 @@ public:
+ 	addressList& operator=(const addressList& other);
+ 	addressList& operator=(const mailboxList& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	/** Add a address at the end of the list.
+@@ -163,14 +163,20 @@ private:
+ 
+ 	std::vector <ref <address> > m_list;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/body.hpp b/vmime/body.hpp
+index 9e83d6b..bd5bbb9 100644
+--- a/vmime/body.hpp
++++ b/vmime/body.hpp
+@@ -278,7 +278,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	body& operator=(const body& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ private:
+ 
+@@ -299,14 +299,20 @@ private:
+ 
+ 	void initNewPart(ref <bodyPart> part);
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(ref <utility::parserInputStreamAdapter> parser,
++		 const utility::stream::size_type position,
++		 const utility::stream::size_type end,
++		 utility::stream::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/bodyPart.hpp b/vmime/bodyPart.hpp
+index aa0f040..5f36d90 100644
+--- a/vmime/bodyPart.hpp
++++ b/vmime/bodyPart.hpp
+@@ -89,7 +89,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	bodyPart& operator=(const bodyPart& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ private:
+ 
+@@ -98,14 +98,20 @@ private:
+ 
+ 	weak_ref <bodyPart> m_parent;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(ref <utility::parserInputStreamAdapter> parser,
++		 const utility::stream::size_type position,
++		 const utility::stream::size_type end,
++		 utility::stream::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/charset.hpp b/vmime/charset.hpp
+index 5f5e8e5..26abb4f 100644
+--- a/vmime/charset.hpp
++++ b/vmime/charset.hpp
+@@ -62,7 +62,7 @@ public:
+ 	bool operator==(const charset& value) const;
+ 	bool operator!=(const charset& value) const;
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Gets the recommended encoding for this charset.
+ 	  * Note: there may be no recommended encoding.
+@@ -117,14 +117,20 @@ private:
+ 
+ 	string m_name;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/component.hpp b/vmime/component.hpp
+index 12b0406..5e6f393 100644
+--- a/vmime/component.hpp
++++ b/vmime/component.hpp
+@@ -27,6 +27,8 @@
+ 
+ #include "vmime/base.hpp"
+ #include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
++#include "vmime/utility/parserInputStreamAdapter.hpp"
+ #include "vmime/utility/outputStream.hpp"
+ 
+ 
+@@ -51,6 +53,12 @@ public:
+ 	  */
+ 	void parse(const string& buffer);
+ 
++	/** Parse RFC-822/MIME data for this component. If stream is not seekable,
++	  * or if length is not specified, entire contents of the stream will
++	  * be loaded into memory before parsing.
++	  */
++	void parse(ref <utility::inputStream> inputStream, const utility::stream::size_type length);
++
+ 	/** Parse RFC-822/MIME data for this component.
+ 	  *
+ 	  * @param buffer input buffer
+@@ -58,7 +66,26 @@ public:
+ 	  * @param end end position in the input buffer
+ 	  * @param newPosition will receive the new position in the input buffer
+ 	  */
+-	virtual void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL) = 0;
++	void parse
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	/** Parse RFC-822/MIME data for this component. If stream is not seekable,
++	  * or if end position is not specified, entire contents of the stream will
++	  * be loaded into memory before parsing.
++	  *
++	  * @param inputStream stream from which to read data
++	  * @param position current position in the input stream
++	  * @param end end position in the input stream
++	  * @param newPosition will receive the new position in the input stream
++	  */
++	void parse
++		(ref <utility::inputStream> inputStream,
++		 const utility::stream::size_type position,
++		 const utility::stream::size_type end,
++		 utility::stream::size_type* newPosition = NULL);
+ 
+ 	/** Generate RFC-2822/MIME data for this component.
+ 	  *
+@@ -68,16 +95,35 @@ public:
+ 	  * @param curLinePos length of the current line in the output buffer
+ 	  * @return generated data
+ 	  */
+-	const string generate(const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0) const;
++	virtual const string generate
++		(const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0) const;
+ 
+ 	/** Generate RFC-2822/MIME data for this component.
+ 	  *
+-	  * @param os output stream
++	  * @param outputStream output stream
+ 	  * @param maxLineLength maximum line length for output
+ 	  * @param curLinePos length of the current line in the output buffer
+ 	  * @param newLinePos will receive the new line position (length of the last line written)
+ 	  */
+-	virtual void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const = 0;
++	virtual void generate
++		(utility::outputStream& outputStream,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
++
++	/** Generate RFC-2822/MIME data for this component.
++	  *
++	  * @param outputStream output stream
++	  * @param maxLineLength maximum line length for output
++	  * @param curLinePos length of the current line in the output buffer
++	  * @param newLinePos will receive the new line position (length of the last line written)
++	  */
++	virtual void generate
++		(ref <utility::outputStream> outputStream,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+ 	/** Clone this component.
+ 	  *
+@@ -95,41 +141,56 @@ public:
+ 	virtual void copyFrom(const component& other) = 0;
+ 
+ 	/** Return the start position of this component in the
+-	  * parsed message contents.
++	  * parsed message contents. Use for debugging only.
+ 	  *
+ 	  * @return start position in parsed buffer
+ 	  * or 0 if this component has not been parsed
+ 	  */
+-	string::size_type getParsedOffset() const;
++	utility::stream::size_type getParsedOffset() const;
+ 
+ 	/** Return the length of this component in the
+-	  * parsed message contents.
++	  * parsed message contents. Use for debugging only.
+ 	  *
+ 	  * @return length of the component in parsed buffer
+ 	  * or 0 if this component has not been parsed
+ 	  */
+-	string::size_type getParsedLength() const;
++	utility::stream::size_type getParsedLength() const;
+ 
+ 	/** Return the list of children of this component.
+ 	  *
+ 	  * @return list of child components
+ 	  */
+-	const std::vector <ref <component> > getChildComponents();
+-
+-	/** Return the list of children of this component (const version).
+-	  *
+-	  * @return list of child components
+-	  */
+-	virtual const std::vector <ref <const component> > getChildComponents() const = 0;
++	virtual const std::vector <ref <component> > getChildComponents() = 0;
+ 
+ protected:
+ 
+-	void setParsedBounds(const string::size_type start, const string::size_type end);
++	void setParsedBounds(const utility::stream::size_type start, const utility::stream::size_type end);
++
++	// AT LEAST ONE of these parseImpl() functions MUST be implemented in derived class
++	virtual void parseImpl
++		(ref <utility::parserInputStreamAdapter> parser,
++		 const utility::stream::size_type position,
++		 const utility::stream::size_type end,
++		 utility::stream::size_type* newPosition = NULL);
++
++	virtual void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	virtual void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const = 0;
+ 
+ private:
+ 
+-	string::size_type m_parsedOffset;
+-	string::size_type m_parsedLength;
++	void offsetParsedBounds(const utility::stream::size_type offset);
++
++	utility::stream::size_type m_parsedOffset;
++	utility::stream::size_type m_parsedLength;
+ };
+ 
+ 
+diff --git a/vmime/contentDisposition.hpp b/vmime/contentDisposition.hpp
+index 9d1749b..abd2e1a 100644
+--- a/vmime/contentDisposition.hpp
++++ b/vmime/contentDisposition.hpp
+@@ -63,7 +63,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	contentDisposition& operator=(const contentDisposition& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	contentDisposition& operator=(const string& name);
+@@ -75,14 +75,20 @@ private:
+ 
+ 	string m_name;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/dateTime.hpp b/vmime/dateTime.hpp
+index 8e99640..053f4a6 100644
+--- a/vmime/dateTime.hpp
++++ b/vmime/dateTime.hpp
+@@ -237,16 +237,22 @@ public:
+ 	// Current date and time
+ 	static const datetime now();
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/disposition.hpp b/vmime/disposition.hpp
+index 05bfca2..7bdc832 100644
+--- a/vmime/disposition.hpp
++++ b/vmime/disposition.hpp
+@@ -50,7 +50,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	disposition& operator=(const disposition& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	/** Set the disposition action mode.
+@@ -134,14 +134,20 @@ private:
+ 
+ 	std::vector <string> m_modifiers;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp
+index 42f5246..4322b29 100644
+--- a/vmime/encoding.hpp
++++ b/vmime/encoding.hpp
+@@ -93,7 +93,7 @@ public:
+ 	bool operator==(const encoding& value) const;
+ 	bool operator!=(const encoding& value) const;
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Decide which encoding to use based on the specified data.
+ 	  *
+@@ -141,14 +141,20 @@ private:
+ 	  */
+ 	static const encoding decideImpl(const string::const_iterator begin, const string::const_iterator end);
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/header.hpp b/vmime/header.hpp
+index 95a9326..ed555b0 100644
+--- a/vmime/header.hpp
++++ b/vmime/header.hpp
+@@ -220,7 +220,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	header& operator=(const header& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ private:
+ 
+@@ -251,14 +251,20 @@ private:
+ 		string m_name;
+ 	};
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/headerField.hpp b/vmime/headerField.hpp
+index 50494c9..61e01ee 100644
+--- a/vmime/headerField.hpp
++++ b/vmime/headerField.hpp
+@@ -59,7 +59,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	headerField& operator=(const headerField& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Sets the name of this field.
+ 	  *
+@@ -118,15 +118,26 @@ public:
+ 	void setValue(const string& value);
+ 
+ 
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+-protected:
+ 
+-	static ref <headerField> parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
++	static ref <headerField> parseNext
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
+ 
+ 
+ 	string m_name;
+diff --git a/vmime/mailbox.hpp b/vmime/mailbox.hpp
+index 2072be8..2099355 100644
+--- a/vmime/mailbox.hpp
++++ b/vmime/mailbox.hpp
+@@ -85,7 +85,7 @@ public:
+ 
+ 	void clear();
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	bool isGroup() const;
+@@ -101,8 +101,17 @@ public:
+ 	using address::generate;
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/mailboxGroup.hpp b/vmime/mailboxGroup.hpp
+index 0061d5b..1433141 100644
+--- a/vmime/mailboxGroup.hpp
++++ b/vmime/mailboxGroup.hpp
+@@ -52,7 +52,7 @@ public:
+ 	ref <component> clone() const;
+ 	mailboxGroup& operator=(const component& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Return the name of the group.
+ 	  *
+@@ -165,14 +165,20 @@ private:
+ 	text m_name;
+ 	std::vector <ref <mailbox> > m_list;
+ 
+-public:
+-
+-	using address::parse;
+-	using address::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/mailboxList.hpp b/vmime/mailboxList.hpp
+index 11e4e79..1b480c1 100644
+--- a/vmime/mailboxList.hpp
++++ b/vmime/mailboxList.hpp
+@@ -51,7 +51,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	mailboxList& operator=(const mailboxList& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Add a mailbox at the end of the list.
+ 	  *
+@@ -155,14 +155,20 @@ private:
+ 
+ 	addressList m_list;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/mediaType.hpp b/vmime/mediaType.hpp
+index 658b21f..18182f0 100644
+--- a/vmime/mediaType.hpp
++++ b/vmime/mediaType.hpp
+@@ -55,7 +55,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	mediaType& operator=(const mediaType& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Return the media type.
+ 	  * See the constants in vmime::mediaTypes.
+@@ -97,14 +97,18 @@ protected:
+ 	string m_type;
+ 	string m_subType;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
+-
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/message.hpp b/vmime/message.hpp
+index f3be229..9767564 100644
+--- a/vmime/message.hpp
++++ b/vmime/message.hpp
+@@ -43,12 +43,25 @@ public:
+ 	message();
+ 
+ 
+-	// Component parsing & assembling
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(), const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
+-
+-	const string generate(const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(), const string::size_type curLinePos = 0) const;
++public:
+ 
+-	void parse(const string& buffer);
++	// Override default generate() functions so that we can change
++	// the default 'maxLineLength' value
++	void generate
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(),
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
++
++	const string generate
++		(const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(),
++		 const string::size_type curLinePos = 0) const;
++
++	void generate
++		(ref <utility::outputStream> os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/messageId.hpp b/vmime/messageId.hpp
+index 3686b11..ac408e6 100644
+--- a/vmime/messageId.hpp
++++ b/vmime/messageId.hpp
+@@ -97,23 +97,27 @@ public:
+ 	void copyFrom(const component& other);
+ 	messageId& operator=(const messageId& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ private:
+ 
+ 	string m_left;
+ 	string m_right;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
+-
+-protected:
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+ 	/** Parse a message-id from an input buffer.
+ 	  *
+@@ -123,7 +127,11 @@ protected:
+ 	  * @param newPosition will receive the new position in the input buffer
+ 	  * @return a new message-id object, or null if no more message-id can be parsed from the input buffer
+ 	  */
+-	static ref <messageId> parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition);
++	static ref <messageId> parseNext
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition);
+ };
+ 
+ 
+diff --git a/vmime/messageIdSequence.hpp b/vmime/messageIdSequence.hpp
+index 5dfb840..6736d0a 100644
+--- a/vmime/messageIdSequence.hpp
++++ b/vmime/messageIdSequence.hpp
+@@ -49,7 +49,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	messageIdSequence& operator=(const messageIdSequence& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	/** Add a message-id at the end of the list.
+@@ -148,14 +148,20 @@ private:
+ 
+ 	std::vector <ref <messageId> > m_list;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/parameter.hpp b/vmime/parameter.hpp
+index e1b13a1..0773ea6 100644
+--- a/vmime/parameter.hpp
++++ b/vmime/parameter.hpp
+@@ -67,7 +67,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	parameter& operator=(const parameter& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Return the name of this parameter.
+ 	  *
+@@ -104,7 +104,7 @@ public:
+ 	const T getValueAs() const
+ 	{
+ 		T ret;
+-		ret.parse(m_value.getBuffer());
++		ret.parse(m_value->getBuffer());
+ 
+ 		return ret;
+ 	}
+@@ -122,11 +122,19 @@ public:
+ 	void setValue(const word& value);
+ 
+ 
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+ private:
+ 
+@@ -134,7 +142,7 @@ private:
+ 
+ 
+ 	string m_name;
+-	word m_value;
++	ref <word> m_value;
+ };
+ 
+ 
+diff --git a/vmime/parameterizedHeaderField.hpp b/vmime/parameterizedHeaderField.hpp
+index 2940ca3..d2c934f 100644
+--- a/vmime/parameterizedHeaderField.hpp
++++ b/vmime/parameterizedHeaderField.hpp
+@@ -172,19 +172,25 @@ public:
+ 	  */
+ 	const std::vector <ref <parameter> > getParameterList();
+ 
++	const std::vector <ref <component> > getChildComponents();
++
+ private:
+ 
+ 	std::vector <ref <parameter> > m_params;
+ 
+-public:
+-
+-	using headerField::parse;
+-	using headerField::generate;
+-
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++protected:
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/parserHelpers.hpp b/vmime/parserHelpers.hpp
+index 9b075f7..d4f1246 100644
+--- a/vmime/parserHelpers.hpp
++++ b/vmime/parserHelpers.hpp
+@@ -45,6 +45,10 @@ public:
+ 		return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ 	}
+ 
++	static bool isSpaceOrTab(const char_t c)
++	{
++		return (c == ' ' || c == '\t');
++	}
+ 
+ 	static bool isDigit(const char_t c)
+ 	{
+diff --git a/vmime/path.hpp b/vmime/path.hpp
+index beaa72b..eec8dfc 100644
+--- a/vmime/path.hpp
++++ b/vmime/path.hpp
+@@ -76,21 +76,26 @@ public:
+ 	ref <component> clone() const;
+ 	path& operator=(const path& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ protected:
+ 
+ 	string m_localPart;
+ 	string m_domain;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/platforms/posix/posixFile.hpp b/vmime/platforms/posix/posixFile.hpp
+index 70986df..704b7b0 100644
+--- a/vmime/platforms/posix/posixFile.hpp
++++ b/vmime/platforms/posix/posixFile.hpp
+@@ -26,6 +26,7 @@
+ 
+ 
+ #include "vmime/utility/file.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ 
+ #if VMIME_HAVE_FILESYSTEM_FEATURES
+@@ -57,7 +58,7 @@ private:
+ 
+ 
+ 
+-class posixFileReaderInputStream : public vmime::utility::inputStream
++class posixFileReaderInputStream : public vmime::utility::seekableInputStream
+ {
+ public:
+ 
+@@ -72,6 +73,9 @@ public:
+ 
+ 	size_type skip(const size_type count);
+ 
++	size_type getPosition() const;
++	void seek(const size_type pos);
++
+ private:
+ 
+ 	const vmime::utility::file::path m_path;
+diff --git a/vmime/platforms/windows/windowsFile.hpp b/vmime/platforms/windows/windowsFile.hpp
+index 6e1c8fb..f417032 100644
+--- a/vmime/platforms/windows/windowsFile.hpp
++++ b/vmime/platforms/windows/windowsFile.hpp
+@@ -26,6 +26,7 @@
+ 
+ 
+ #include "vmime/utility/file.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ #include <windows.h>
+ 
+@@ -157,6 +158,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/relay.hpp b/vmime/relay.hpp
+index 583ad80..dbaedf2 100644
+--- a/vmime/relay.hpp
++++ b/vmime/relay.hpp
+@@ -51,7 +51,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	relay& operator=(const relay& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	const string& getFrom() const;
+ 	void setFrom(const string& from);
+@@ -85,13 +85,19 @@ private:
+ 
+ 	datetime m_date;
+ 
+-public:
++protected:
+ 
+-	using component::parse;
+-	using component::generate;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
+ 
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/text.hpp b/vmime/text.hpp
+index 15e11ae..778ce86 100644
+--- a/vmime/text.hpp
++++ b/vmime/text.hpp
+@@ -58,7 +58,7 @@ public:
+ 	text& operator=(const component& other);
+ 	text& operator=(const text& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Add a word at the end of the list.
+ 	  *
+@@ -226,13 +226,20 @@ public:
+ 	  */
+ 	static text* decodeAndUnfold(const string& in, text* generateInExisting);
+ 
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+ private:
+ 
+diff --git a/vmime/utility/inputStreamAdapter.hpp b/vmime/utility/inputStreamAdapter.hpp
+index 278ab52..bd4d21e 100644
+--- a/vmime/utility/inputStreamAdapter.hpp
++++ b/vmime/utility/inputStreamAdapter.hpp
+@@ -25,7 +25,7 @@
+ #define VMIME_UTILITY_INPUTSTREAMADAPTER_HPP_INCLUDED
+ 
+ 
+-#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ #include <istream>
+ 
+@@ -37,7 +37,7 @@ namespace utility {
+ /** An adapter class for C++ standard input streams.
+   */
+ 
+-class inputStreamAdapter : public inputStream
++class inputStreamAdapter : public seekableInputStream
+ {
+ public:
+ 
+@@ -49,6 +49,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/utility/inputStreamByteBufferAdapter.hpp b/vmime/utility/inputStreamByteBufferAdapter.hpp
+index 0f6a442..b3dafd9 100644
+--- a/vmime/utility/inputStreamByteBufferAdapter.hpp
++++ b/vmime/utility/inputStreamByteBufferAdapter.hpp
+@@ -25,7 +25,7 @@
+ #define VMIME_UTILITY_INPUTSTREAMBYTEBUFFERADAPTER_HPP_INCLUDED
+ 
+ 
+-#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ 
+ namespace vmime {
+@@ -35,7 +35,7 @@ namespace utility {
+ /** An adapter class for reading from an array of bytes.
+   */
+ 
+-class inputStreamByteBufferAdapter : public inputStream
++class inputStreamByteBufferAdapter : public seekableInputStream
+ {
+ public:
+ 
+@@ -45,6 +45,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/utility/inputStreamStringAdapter.hpp b/vmime/utility/inputStreamStringAdapter.hpp
+index a7d986f..18a9083 100644
+--- a/vmime/utility/inputStreamStringAdapter.hpp
++++ b/vmime/utility/inputStreamStringAdapter.hpp
+@@ -25,7 +25,7 @@
+ #define VMIME_UTILITY_INPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
+ 
+ 
+-#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ 
+ namespace vmime {
+@@ -35,7 +35,7 @@ namespace utility {
+ /** An adapter class for string input.
+   */
+ 
+-class inputStreamStringAdapter : public inputStream
++class inputStreamStringAdapter : public seekableInputStream
+ {
+ public:
+ 
+@@ -46,6 +46,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/utility/inputStreamStringProxyAdapter.hpp b/vmime/utility/inputStreamStringProxyAdapter.hpp
+index 74b3f60..dc52637 100644
+--- a/vmime/utility/inputStreamStringProxyAdapter.hpp
++++ b/vmime/utility/inputStreamStringProxyAdapter.hpp
+@@ -25,7 +25,7 @@
+ #define VMIME_UTILITY_INPUTSTREAMSTRINGPROXYADAPTER_HPP_INCLUDED
+ 
+ 
+-#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ 
+ namespace vmime {
+@@ -38,7 +38,7 @@ class stringProxy;
+ /** An adapter class for stringProxy input.
+   */
+ 
+-class inputStreamStringProxyAdapter : public inputStream
++class inputStreamStringProxyAdapter : public seekableInputStream
+ {
+ public:
+ 
+@@ -50,6 +50,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/utility/parserInputStreamAdapter.hpp b/vmime/utility/parserInputStreamAdapter.hpp
+new file mode 100644
+index 0000000..c24fa44
+--- /dev/null
++++ b/vmime/utility/parserInputStreamAdapter.hpp
+@@ -0,0 +1,173 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_PARSERINPUTSTREAMADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_PARSERINPUTSTREAMADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/seekableInputStream.hpp"
++
++#include <cstring>
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class used for parsing from an input stream.
++  */
++
++class parserInputStreamAdapter : public seekableInputStream
++{
++public:
++
++	/** @param is input stream to wrap
++	  */
++	parserInputStreamAdapter(ref <seekableInputStream> inputStream);
++
++	ref <seekableInputStream> getUnderlyingStream();
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++
++	void seek(const size_type pos)
++	{
++		m_stream->seek(pos);
++	}
++
++	size_type skip(const size_type count)
++	{
++		return m_stream->skip(count);
++	}
++
++	size_type getPosition() const
++	{
++		return m_stream->getPosition();
++	}
++
++	/** Get the byte at the current position without updating the
++	  * current position.
++	  *
++	  * @return byte at the current position
++	  */
++	value_type peekByte() const
++	{
++		const size_type initialPos = m_stream->getPosition();
++
++		try
++		{
++			value_type buffer[1];
++			const size_type readBytes = m_stream->read(buffer, 1);
++
++			m_stream->seek(initialPos);
++
++			return (readBytes == 1 ? buffer[0] : 0);
++		}
++		catch (...)
++		{
++			m_stream->seek(initialPos);
++			throw;
++		}
++	}
++
++	/** Get the byte at the current position and advance current
++	  * position by one byte.
++	  *
++	  * @return byte at the current position
++	  */
++	value_type getByte()
++	{
++		value_type buffer[1];
++		const size_type readBytes = m_stream->read(buffer, 1);
++
++		return (readBytes == 1 ? buffer[0] : 0);
++	}
++
++	/** Check whether the bytes following the current position match
++	  * the specified bytes. Position is not updated.
++	  *
++	  * @param bytes bytes to compare
++	  * @param length number of bytes
++	  * @return true if the next bytes match the pattern, false otherwise
++	  */
++	bool matchBytes(const value_type* bytes, const size_type length) const
++	{
++		const size_type initialPos = m_stream->getPosition();
++
++		try
++		{
++			value_type buffer[32];
++			const size_type readBytes = m_stream->read(buffer, length);
++
++			m_stream->seek(initialPos);
++
++			return readBytes == length &&
++			       ::memcmp(bytes, buffer, length) == 0;
++		}
++		catch (...)
++		{
++			m_stream->seek(initialPos);
++			throw;
++		}
++	}
++
++	const string extract(const size_type begin, const size_type end) const;
++
++	/** Skips bytes matching a predicate from the current position.
++	  * The current position is updated to the next following byte
++	  * which does not match the predicate.
++	  *
++	  * @param pred predicate
++	  * @param endPosition stop at this position (or at end of the stream,
++	  * whichever comes first)
++	  * @return number of bytes skipped
++	  */
++	template <typename PREDICATE>
++	size_type skipIf(PREDICATE pred, const size_type endPosition)
++	{
++		const size_type initialPos = getPosition();
++		size_type pos = initialPos;
++
++		while (!m_stream->eof() && pos < endPosition && pred(getByte()))
++			++pos;
++
++		m_stream->seek(pos);
++
++		return pos - initialPos;
++	}
++
++	size_type findNext(const std::string& token, const size_type startPosition = 0);
++
++private:
++
++	mutable ref <seekableInputStream> m_stream;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_PARSERINPUTSTREAMADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/seekableInputStream.hpp b/vmime/utility/seekableInputStream.hpp
+new file mode 100644
+index 0000000..c2ab1bb
+--- /dev/null
++++ b/vmime/utility/seekableInputStream.hpp
+@@ -0,0 +1,64 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_SEEKABLEINPUTSTREAM_HPP_INCLUDED
++#define VMIME_UTILITY_SEEKABLEINPUTSTREAM_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An input stream that allows seeking within the input.
++  */
++
++class seekableInputStream : public inputStream
++{
++public:
++
++	/** Returns the current position in this stream.
++	  *
++	  * @return the offset from the beginning of the stream, in bytes,
++	  * at which the next read occurs
++	  */
++	virtual size_type getPosition() const = 0;
++
++	/** Sets the position, measured from the beginning of this stream,
++	  * at which the next read occurs.
++	  *
++	  * @param pos the offset position, measured in bytes from the
++	  * beginning of the stream, at which to set the stream pointer.
++	  */
++	virtual void seek(const size_type pos) = 0;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_SEEKABLEINPUTSTREAM_HPP_INCLUDED
++
+diff --git a/vmime/utility/seekableInputStreamRegionAdapter.hpp b/vmime/utility/seekableInputStreamRegionAdapter.hpp
+new file mode 100644
+index 0000000..5ebccc6
+--- /dev/null
++++ b/vmime/utility/seekableInputStreamRegionAdapter.hpp
+@@ -0,0 +1,71 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_SEEKABLEINPUTSTREAMREGIONADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_SEEKABLEINPUTSTREAMREGIONADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/seekableInputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter for reading a limited region of a seekable input stream.
++  */
++
++class seekableInputStreamRegionAdapter : public seekableInputStream
++{
++public:
++
++	/** Creates a new adapter for a seekableInputStream.
++	  *
++	  * @param stream source stream
++	  * @param begin start position in source stream
++	  * @param length region length in source stream
++	  */
++	seekableInputStreamRegionAdapter(ref <seekableInputStream> stream,
++		const size_type begin, const size_type length);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
++
++private:
++
++	ref <seekableInputStream> m_stream;
++	size_type m_begin;
++	size_type m_length;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_SEEKABLEINPUTSTREAMREGIONADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/stream.hpp b/vmime/utility/stream.hpp
+index 566ab9d..78be827 100644
+--- a/vmime/utility/stream.hpp
++++ b/vmime/utility/stream.hpp
+@@ -54,6 +54,10 @@ public:
+ 	  */
+ 	typedef string::size_type size_type;
+ 
++	/** Constant value with the greatest possible value for an element of type size_type.
++	  */
++	static const size_type npos;
++
+ 	/** Return the preferred maximum block size when reading
+ 	  * from or writing to this stream.
+ 	  *
+diff --git a/vmime/utility/streamUtils.hpp b/vmime/utility/streamUtils.hpp
+index cdf70aa..87c8fc5 100644
+--- a/vmime/utility/streamUtils.hpp
++++ b/vmime/utility/streamUtils.hpp
+@@ -45,6 +45,19 @@ namespace utility {
+ stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os);
+ 
+ /** Copy data from one stream into another stream using a buffered method
++  * and copying only a specified range of data.
++  *
++  * @param is input stream (source data)
++  * @param os output stream (destination for data)
++  * @param start number of bytes to ignore before starting copying
++  * @param length maximum number of bytes to copy
++  * @return number of bytes copied
++  */
++
++stream::size_type bufferedStreamCopyRange(inputStream& is, outputStream& os,
++	const stream::size_type start, const stream::size_type length);
++
++/** Copy data from one stream into another stream using a buffered method
+   * and notify progress state of the operation.
+   *
+   * @param is input stream (source data)
+diff --git a/vmime/word.hpp b/vmime/word.hpp
+index ad848ec..492aab5 100644
+--- a/vmime/word.hpp
++++ b/vmime/word.hpp
+@@ -128,21 +128,52 @@ public:
+ #endif
+ 
+ 
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
+ 
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos, const int flags, generatorState* state) const;
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++public:
+ 
+-private:
++	using component::generate;
+ 
+-	static ref <word> parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition, bool prevIsEncoded, bool* isEncoded, bool isFirst);
++#ifndef VMIME_BUILDING_DOC
++	void generate
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength,
++		 const string::size_type curLinePos,
++		 string::size_type* newLinePos,
++		 const int flags,
++		 generatorState* state) const;
++#endif
++
++	const std::vector <ref <component> > getChildComponents();
++
++private:
+ 
+-	static const std::vector <ref <word> > parseMultiple(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition);
++	static ref <word> parseNext
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition,
++		 bool prevIsEncoded,
++		 bool* isEncoded,
++		 bool isFirst);
++
++	static const std::vector <ref <word> > parseMultiple
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition);
+ 
+ 
+ 	// The "m_buffer" of this word holds the data, and this data is encoded
+-- 
+1.7.10.4
+
+
+From 2e05e574fde890c7ec6dd9f3930d06b1b492ea80 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Fri, 27 Apr 2012 08:34:26 +0200
+Subject: [PATCH 38/42] Fixed duplicate file reference (thanks to Enes Albay).
+
+
+diff --git a/SConstruct b/SConstruct
+index 2690172..1f3c7c9 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -137,7 +137,6 @@ libvmime_sources = [
+ 	'utility/childProcess.hpp',
+ 	'utility/file.hpp',
+ 	'utility/datetimeUtils.cpp', 'utility/datetimeUtils.hpp',
+-	'utility/filteredStream.cpp', 'utility/filteredStream.hpp',
+ 	'utility/path.cpp', 'utility/path.hpp',
+ 	'utility/progressListener.cpp', 'utility/progressListener.hpp',
+ 	'utility/random.cpp', 'utility/random.hpp',
+-- 
+1.7.10.4
+
+
+From 799629fd8b21a716f3e3abc6e6a5264555470d85 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Fri, 6 Jul 2012 18:45:02 +0200
+Subject: [PATCH 39/42] Fixed issue #10.
+
+
+diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp
+index 702d5f2..8006920 100644
+--- a/src/net/imap/IMAPMessage.cpp
++++ b/src/net/imap/IMAPMessage.cpp
+@@ -279,8 +279,6 @@ void IMAPMessage::extract(ref <const part> p, utility::outputStream& os,
+ 	{
+ 		if (headerOnly)
+ 			command << "HEADER";
+-		else
+-			command << "TEXT";
+ 	}
+ 	else
+ 	{
+-- 
+1.7.10.4
+
+
+From 72cf7a025f7764998609683904eea1046a766d97 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Sat, 28 Jul 2012 13:01:48 +0200
+Subject: [PATCH 40/42] Added functions to get messages by UID (IMAP only for
+ now).
+
+
+diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
+index 81bf386..3d8c17e 100644
+--- a/src/net/imap/IMAPFolder.cpp
++++ b/src/net/imap/IMAPFolder.cpp
+@@ -208,7 +208,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
+ 					{
+ 					case IMAPParser::resp_text_code::UIDVALIDITY:
+ 
+-						m_uidValidity = code->nz_number()->value();
++						m_uidValidity = static_cast <unsigned int>(code->nz_number()->value());
+ 						break;
+ 
+ 					default:
+@@ -550,6 +550,109 @@ std::vector <ref <message> > IMAPFolder::getMessages(const std::vector <int>& nu
+ }
+ 
+ 
++ref <message> IMAPFolder::getMessageByUID(const message::uid& uid)
++{
++	std::vector <message::uid> uids;
++	uids.push_back(uid);
++
++	std::vector <ref <message> > msgs = getMessagesByUID(uids);
++
++	if (msgs.size() == 0)
++		throw exceptions::message_not_found();
++
++	return msgs[0];
++}
++
++
++std::vector <ref <message> > IMAPFolder::getMessagesByUID(const std::vector <message::uid>& uids)
++{
++	if (!isOpen())
++		throw exceptions::illegal_state("Folder not open");
++
++	if (uids.size() == 0)
++		return std::vector <ref <message> >();
++
++	//     C: . UID FETCH uuuu1,uuuu2,uuuu3 UID
++	//     S: * nnnn1 FETCH (UID uuuu1)
++	//     S: * nnnn2 FETCH (UID uuuu2)
++	//     S: * nnnn3 FETCH (UID uuuu3)
++	//     S: . OK UID FETCH completed
++
++	// Prepare command and arguments
++	std::ostringstream cmd;
++	cmd.imbue(std::locale::classic());
++
++	cmd << "UID FETCH " << IMAPUtils::extractUIDFromGlobalUID(uids[0]);
++
++	for (unsigned int i = 1, n = uids.size() ; i < n ; ++i)
++		cmd << "," << IMAPUtils::extractUIDFromGlobalUID(uids[i]);
++
++	cmd << " UID";
++
++	// Send the request
++	m_connection->send(true, cmd.str(), true);
++
++	// Get the response
++	utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
++
++	if (resp->isBad() || resp->response_done()->response_tagged()->
++			resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
++	{
++		throw exceptions::command_error("UID FETCH ... UID", m_connection->getParser()->lastLine(), "bad response");
++	}
++
++	// Process the response
++	const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
++		resp->continue_req_or_response_data();
++
++	std::vector <ref <message> > messages;
++
++	for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
++	     it = respDataList.begin() ; it != respDataList.end() ; ++it)
++	{
++		if ((*it)->response_data() == NULL)
++		{
++			throw exceptions::command_error("UID FETCH ... UID",
++				m_connection->getParser()->lastLine(), "invalid response");
++		}
++
++		const IMAPParser::message_data* messageData =
++			(*it)->response_data()->message_data();
++
++		// We are only interested in responses of type "FETCH"
++		if (messageData == NULL || messageData->type() != IMAPParser::message_data::FETCH)
++			continue;
++
++		// Get Process fetch response for this message
++		const int msgNum = static_cast <int>(messageData->number());
++		message::uid msgUID, msgFullUID;
++
++		// Find UID in message attributes
++		const std::vector <IMAPParser::msg_att_item*> atts = messageData->msg_att()->items();
++
++		for (std::vector <IMAPParser::msg_att_item*>::const_iterator
++		     it = atts.begin() ; it != atts.end() ; ++it)
++		{
++			if ((*it)->type() == IMAPParser::msg_att_item::UID)
++			{
++				msgFullUID = IMAPUtils::makeGlobalUID(m_uidValidity, (*it)->unique_id()->value());
++				msgUID = (*it)->unique_id()->value();
++
++				break;
++			}
++		}
++
++		if (!msgUID.empty())
++		{
++			ref <IMAPFolder> thisFolder = thisRef().dynamicCast <IMAPFolder>();
++			messages.push_back(vmime::create <IMAPMessage>(thisFolder, msgNum, msgFullUID));
++		}
++	}
++
++	return messages;
++}
++
++
+ int IMAPFolder::getMessageCount()
+ {
+ 	if (!isOpen())
+@@ -730,7 +833,7 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const int opti
+ 
+ 			if (msg != numberToMsg.end())
+ 			{
+-				(*msg).second->processFetchResponse(options, messageData->msg_att());
++				(*msg).second->processFetchResponse(options, messageData);
+ 
+ 				if (progress)
+ 					progress->progress(++current, total);
+@@ -1781,7 +1884,7 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
+ 	std::ostringstream command;
+ 	command.imbue(std::locale::classic());
+ 
+-	command << "SEARCH UID " << uid;
++	command << "SEARCH UID " << uid << ":*";
+ 
+ 	// Send the request
+ 	m_connection->send(true, command.str(), true);
+diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp
+index 8006920..7202a7d 100644
+--- a/src/net/imap/IMAPMessage.cpp
++++ b/src/net/imap/IMAPMessage.cpp
+@@ -98,6 +98,14 @@ IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num)
+ }
+ 
+ 
++IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num, const uid& uniqueId)
++	: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
++	  m_expunged(false), m_uid(uniqueId), m_structure(NULL)
++{
++	folder->registerMessage(this);
++}
++
++
+ IMAPMessage::~IMAPMessage()
+ {
+ 	ref <IMAPFolder> folder = m_folder.acquire();
+@@ -271,7 +279,11 @@ void IMAPMessage::extract(ref <const part> p, utility::outputStream& os,
+ 	std::ostringstream command;
+ 	command.imbue(std::locale::classic());
+ 
+-	command << "FETCH " << m_num << " BODY";
++	if (m_uid.empty())
++		command << "FETCH " << m_num << " BODY";
++	else
++		command << "UID FETCH " << IMAPUtils::extractUIDFromGlobalUID(m_uid) << " BODY";
++
+ 	if (peek) command << ".PEEK";
+ 	command << "[";
+ 
+@@ -361,19 +373,18 @@ void IMAPMessage::fetch(ref <IMAPFolder> msgFolder, const int options)
+ 			continue;
+ 
+ 		// Process fetch response for this message
+-		processFetchResponse(options, messageData->msg_att());
++		processFetchResponse(options, messageData);
+ 	}
+ }
+ 
+ 
+ void IMAPMessage::processFetchResponse
+-	(const int options, const IMAPParser::msg_att* msgAtt)
++	(const int options, const IMAPParser::message_data* msgData)
+ {
+ 	ref <IMAPFolder> folder = m_folder.acquire();
+ 
+ 	// Get message attributes
+-	const std::vector <IMAPParser::msg_att_item*> atts =
+-		msgAtt->items();
++	const std::vector <IMAPParser::msg_att_item*> atts = msgData->msg_att()->items();
+ 
+ 	int flags = 0;
+ 
+@@ -389,12 +400,7 @@ void IMAPMessage::processFetchResponse
+ 		}
+ 		case IMAPParser::msg_att_item::UID:
+ 		{
+-			std::ostringstream oss;
+-			oss.imbue(std::locale::classic());
+-
+-			oss << folder->m_uidValidity << ":" << (*it)->unique_id()->value();
+-
+-			m_uid = oss.str();
++			m_uid = IMAPUtils::makeGlobalUID(folder->m_uidValidity, (*it)->unique_id()->value());
+ 			break;
+ 		}
+ 		case IMAPParser::msg_att_item::ENVELOPE:
+diff --git a/src/net/imap/IMAPUtils.cpp b/src/net/imap/IMAPUtils.cpp
+index 0d6fc47..eceac16 100644
+--- a/src/net/imap/IMAPUtils.cpp
++++ b/src/net/imap/IMAPUtils.cpp
+@@ -540,6 +540,24 @@ const string IMAPUtils::listToSet(const std::vector <int>& list, const int max,
+ 
+ 
+ // static
++const string IMAPUtils::listToSet(const std::vector <message::uid>& list)
++{
++	if (list.size() == 0)
++		return "";
++
++	std::ostringstream res;
++	res.imbue(std::locale::classic());
++
++	res << extractUIDFromGlobalUID(list[0]);
++
++	for (unsigned int i = 1, n = list.size() ; i < n ; ++i)
++		res << "," << extractUIDFromGlobalUID(list[i]);
++
++	return res.str();
++}
++
++
++// static
+ const string IMAPUtils::dateTime(const vmime::datetime& date)
+ {
+ 	std::ostringstream res;
+@@ -609,7 +627,8 @@ const string IMAPUtils::dateTime(const vmime::datetime& date)
+ 
+ 
+ // static
+-const string IMAPUtils::buildFetchRequest(const std::vector <int>& list, const int options)
++const string IMAPUtils::buildFetchRequestImpl
++	(const std::string& mode, const std::string& set, const int options)
+ {
+ 	// Example:
+ 	//   C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)])
+@@ -671,7 +690,10 @@ const string IMAPUtils::buildFetchRequest(const std::vector <int>& list, const i
+ 	std::ostringstream command;
+ 	command.imbue(std::locale::classic());
+ 
+-	command << "FETCH " << listToSet(list, -1, false) << " (";
++	if (mode == "uid")
++		command << "UID FETCH " << set << " (";
++	else
++		command << "FETCH " << set << " (";
+ 
+ 	for (std::vector <string>::const_iterator it = items.begin() ;
+ 	     it != items.end() ; ++it)
+@@ -687,6 +709,20 @@ const string IMAPUtils::buildFetchRequest(const std::vector <int>& list, const i
+ 
+ 
+ // static
++const string IMAPUtils::buildFetchRequest(const std::vector <int>& list, const int options)
++{
++	return buildFetchRequestImpl("number", listToSet(list, -1, false), options);
++}
++
++
++// static
++const string IMAPUtils::buildFetchRequest(const std::vector <message::uid>& list, const int options)
++{
++	return buildFetchRequestImpl("uid", listToSet(list), options);
++}
++
++
++// static
+ void IMAPUtils::convertAddressList
+ 	(const IMAPParser::address_list& src, mailboxList& dest)
+ {
+@@ -706,6 +742,46 @@ void IMAPUtils::convertAddressList
+ }
+ 
+ 
++// static
++unsigned int IMAPUtils::extractUIDFromGlobalUID(const message::uid& uid)
++{
++	message::uid::size_type colonPos = uid.find(':');
++
++	if (colonPos == message::uid::npos)
++	{
++		std::istringstream iss(uid);
++		iss.imbue(std::locale::classic());
++
++		unsigned int n = 0;
++		iss >> n;
++
++		return n;
++	}
++	else
++	{
++		std::istringstream iss(uid.substr(colonPos + 1));
++		iss.imbue(std::locale::classic());
++
++		unsigned int n = 0;
++		iss >> n;
++
++		return n;
++	}
++}
++
++
++// static
++const message::uid IMAPUtils::makeGlobalUID(const unsigned int UIDValidity, const unsigned int messageUID)
++{
++	std::ostringstream oss;
++	oss.imbue(std::locale::classic());
++
++	oss << UIDValidity << ":" << messageUID;
++
++	return message::uid(oss.str());
++}
++
++
+ } // imap
+ } // net
+ } // vmime
+diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
+index 8c4b275..b606cda 100644
+--- a/src/net/maildir/maildirFolder.cpp
++++ b/src/net/maildir/maildirFolder.cpp
+@@ -444,6 +444,18 @@ std::vector <ref <message> > maildirFolder::getMessages(const std::vector <int>&
+ }
+ 
+ 
++ref <message> maildirFolder::getMessageByUID(const message::uid& /* uid */)
++{
++	throw exceptions::operation_not_supported();
++}
++
++
++std::vector <ref <message> > maildirFolder::getMessagesByUID(const std::vector <message::uid>& /* uids */)
++{
++	throw exceptions::operation_not_supported();
++}
++
++
+ int maildirFolder::getMessageCount()
+ {
+ 	return (m_messageCount);
+diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp
+index e085609..21e7a8b 100644
+--- a/src/net/pop3/POP3Folder.cpp
++++ b/src/net/pop3/POP3Folder.cpp
+@@ -249,6 +249,18 @@ std::vector <ref <message> > POP3Folder::getMessages(const int from, const int t
+ }
+ 
+ 
++ref <message> POP3Folder::getMessageByUID(const message::uid& /* uid */)
++{
++	throw exceptions::operation_not_supported();
++}
++
++
++std::vector <ref <message> > POP3Folder::getMessagesByUID(const std::vector <message::uid>& /* uids */)
++{
++	throw exceptions::operation_not_supported();
++}
++
++
+ std::vector <ref <message> > POP3Folder::getMessages(const std::vector <int>& nums)
+ {
+ 	ref <POP3Store> store = m_store.acquire();
+diff --git a/vmime/net/folder.hpp b/vmime/net/folder.hpp
+index df9cbaf..a50ee0e 100644
+--- a/vmime/net/folder.hpp
++++ b/vmime/net/folder.hpp
+@@ -169,7 +169,7 @@ public:
+ 	  */
+ 	virtual bool isOpen() const = 0;
+ 
+-	/** Get a new reference to a message in this folder.
++	/** Get a new reference to a message in this folder, given its number.
+ 	  *
+ 	  * @param num message sequence number
+ 	  * @return a new object referencing the specified message
+@@ -177,7 +177,7 @@ public:
+ 	  */
+ 	virtual ref <message> getMessage(const int num) = 0;
+ 
+-	/** Get new references to messages in this folder.
++	/** Get new references to messages in this folder, given their numbers.
+ 	  *
+ 	  * @param from sequence number of the first message to get
+ 	  * @param to sequence number of the last message to get
+@@ -186,14 +186,30 @@ public:
+ 	  */
+ 	virtual std::vector <ref <message> > getMessages(const int from = 1, const int to = -1) = 0;
+ 
+-	/** Get new references to messages in this folder.
++	/** Get new references to messages in this folder, given their numbers.
+ 	  *
+-	  * @param nums sequence numbers of the messages to delete
++	  * @param nums sequence numbers of the messages to retrieve
+ 	  * @return new objects referencing the specified messages
+ 	  * @throw net_exception if an error occurs
+ 	  */
+ 	virtual std::vector <ref <message> > getMessages(const std::vector <int>& nums) = 0;
+ 
++	/** Get message in this folder, given its UID.
++	  *
++	  * @param uid UID of message to retrieve
++	  * @return a new object referencing the specified message
++	  * @throw net_exception if an error occurs
++	  */
++	virtual ref <message> getMessageByUID(const message::uid& uid) = 0;
++
++	/** Get messages in this folder, given their UIDs.
++	  *
++	  * @param uids UIDs of messages to retrieve
++	  * @return new objects referencing the specified messages
++	  * @throw net_exception if an error occurs
++	  */
++	virtual std::vector <ref <message> > getMessagesByUID(const std::vector <message::uid>& uids) = 0;
++
+ 	/** Return the number of messages in this folder.
+ 	  *
+ 	  * @return number of messages in the folder
+diff --git a/vmime/net/imap/IMAPFolder.hpp b/vmime/net/imap/IMAPFolder.hpp
+index cc52596..3337858 100644
+--- a/vmime/net/imap/IMAPFolder.hpp
++++ b/vmime/net/imap/IMAPFolder.hpp
+@@ -84,6 +84,12 @@ public:
+ 	ref <message> getMessage(const int num);
+ 	std::vector <ref <message> > getMessages(const int from = 1, const int to = -1);
+ 	std::vector <ref <message> > getMessages(const std::vector <int>& nums);
++
++	ref <message> getMessageByUID(const message::uid& uid);
++	std::vector <ref <message> > getMessagesByUID(const std::vector <message::uid>& uids);
++
++	std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
++
+ 	int getMessageCount();
+ 
+ 	ref <folder> getFolder(const folder::path::component& name);
+@@ -120,8 +126,6 @@ public:
+ 
+ 	int getFetchCapabilities() const;
+ 
+-	std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
+-
+ private:
+ 
+ 	void registerMessage(IMAPMessage* msg);
+@@ -152,7 +156,7 @@ private:
+ 
+ 	int m_messageCount;
+ 
+-	int m_uidValidity;
++	unsigned int m_uidValidity;
+ 
+ 	std::vector <IMAPMessage*> m_messages;
+ };
+diff --git a/vmime/net/imap/IMAPMessage.hpp b/vmime/net/imap/IMAPMessage.hpp
+index edbf69f..fbba6e7 100644
+--- a/vmime/net/imap/IMAPMessage.hpp
++++ b/vmime/net/imap/IMAPMessage.hpp
+@@ -50,6 +50,7 @@ private:
+ 	friend class vmime::creator;  // vmime::create <IMAPMessage>
+ 
+ 	IMAPMessage(ref <IMAPFolder> folder, const int num);
++	IMAPMessage(ref <IMAPFolder> folder, const int num, const uid& uniqueId);
+ 	IMAPMessage(const IMAPMessage&) : message() { }
+ 
+ 	~IMAPMessage();
+@@ -83,7 +84,7 @@ private:
+ 
+ 	void fetch(ref <IMAPFolder> folder, const int options);
+ 
+-	void processFetchResponse(const int options, const IMAPParser::msg_att* msgAtt);
++	void processFetchResponse(const int options, const IMAPParser::message_data* msgData);
+ 
+ 	/** Recursively fetch part header for all parts in the structure.
+ 	  *
+diff --git a/vmime/net/imap/IMAPUtils.hpp b/vmime/net/imap/IMAPUtils.hpp
+index d1ed5c8..9c9c420 100644
+--- a/vmime/net/imap/IMAPUtils.hpp
++++ b/vmime/net/imap/IMAPUtils.hpp
+@@ -29,6 +29,7 @@
+ #include "vmime/dateTime.hpp"
+ 
+ #include "vmime/net/folder.hpp"
++#include "vmime/net/message.hpp"
+ #include "vmime/net/imap/IMAPParser.hpp"
+ 
+ #include "vmime/mailboxList.hpp"
+@@ -65,8 +66,8 @@ public:
+ 
+ 	static const string messageFlagList(const int flags);
+ 
+-	/** Build an "IMAP set" given a list. The function tries to group
+-	  * consecutive message numbers to reduce the list.
++	/** Build an "IMAP set" given a list of message numbers. The function tries
++	  * to group consecutive message numbers to reduce the list.
+ 	  *
+ 	  * Example:
+ 	  *    IN  = "1,2,3,4,5,7,8,13,15,16,17"
+@@ -81,6 +82,13 @@ public:
+ 	static const string listToSet(const std::vector <int>& list,
+ 		const int max = -1, const bool alreadySorted = false);
+ 
++	/** Build an "IMAP set" set given a list of message UIDs.
++	  *
++	  * @param list list of message UIDs
++	  * @return a set corresponding to the list
++	  */
++	static const string listToSet(const std::vector <message::uid>& list);
++
+ 	/** Format a date/time to IMAP date/time format.
+ 	  *
+ 	  * @param date date/time to format
+@@ -88,7 +96,7 @@ public:
+ 	  */
+ 	static const string dateTime(const vmime::datetime& date);
+ 
+-	/** Construct a fetch request for the specified messages.
++	/** Construct a fetch request for the specified messages, designated by their sequence numbers.
+ 	  *
+ 	  * @param list list of message numbers
+ 	  * @param options fetch options
+@@ -96,12 +104,40 @@ public:
+ 	  */
+ 	static const string buildFetchRequest(const std::vector <int>& list, const int options);
+ 
++	/** Construct a fetch request for the specified messages, designated by their UIDs.
++	  *
++	  * @param list list of message UIDs
++	  * @param options fetch options
++	  * @return fetch request
++	  */
++	static const string buildFetchRequest(const std::vector <message::uid>& list, const int options);
++
+ 	/** Convert a parser-style address list to a mailbox list.
+ 	  *
+ 	  * @param src input address list
+ 	  * @param dest output mailbox list
+ 	  */
+ 	static void convertAddressList(const IMAPParser::address_list& src, mailboxList& dest);
++
++	/** Extract the message UID from a globally unique UID.
++	  *
++	  * @param uid globally unique UID (as returned by makeGlobalUID(), for example)
++	  * @return message UID
++	  */
++	static unsigned int extractUIDFromGlobalUID(const message::uid& uid);
++
++	/** Construct a globally unique UID from UID Validity and a message UID.
++	  *
++	  * @param UIDValidity UID Validity of the folder
++	  * @param messageUID UID of the message
++	  * @return global UID
++	  */
++	static const message::uid makeGlobalUID(const unsigned int UIDValidity, const unsigned int messageUID);
++
++private:
++
++	static const string buildFetchRequestImpl
++		(const std::string& mode, const std::string& set, const int options);
+ };
+ 
+ 
+diff --git a/vmime/net/maildir/maildirFolder.hpp b/vmime/net/maildir/maildirFolder.hpp
+index 68b5b89..c9ba899 100644
+--- a/vmime/net/maildir/maildirFolder.hpp
++++ b/vmime/net/maildir/maildirFolder.hpp
+@@ -85,6 +85,10 @@ public:
+ 	ref <message> getMessage(const int num);
+ 	std::vector <ref <message> > getMessages(const int from = 1, const int to = -1);
+ 	std::vector <ref <message> > getMessages(const std::vector <int>& nums);
++
++	ref <message> getMessageByUID(const message::uid& uid);
++	std::vector <ref <message> > getMessagesByUID(const std::vector <message::uid>& uids);
++
+ 	int getMessageCount();
+ 
+ 	ref <folder> getFolder(const folder::path::component& name);
+diff --git a/vmime/net/pop3/POP3Folder.hpp b/vmime/net/pop3/POP3Folder.hpp
+index c482908..090f948 100644
+--- a/vmime/net/pop3/POP3Folder.hpp
++++ b/vmime/net/pop3/POP3Folder.hpp
+@@ -83,6 +83,10 @@ public:
+ 	ref <message> getMessage(const int num);
+ 	std::vector <ref <message> > getMessages(const int from = 1, const int to = -1);
+ 	std::vector <ref <message> > getMessages(const std::vector <int>& nums);
++
++	ref <message> getMessageByUID(const message::uid& uid);
++	std::vector <ref <message> > getMessagesByUID(const std::vector <message::uid>& uids);
++
+ 	int getMessageCount();
+ 
+ 	ref <folder> getFolder(const folder::path::component& name);
+-- 
+1.7.10.4
+
+
+From 7501f61214b06a35c8fce7772fd48dded2cad335 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Mon, 30 Jul 2012 11:23:23 +0200
+Subject: [PATCH 41/42] Fixed compilation warning.
+
+
+diff --git a/vmime/utility/parserInputStreamAdapter.hpp b/vmime/utility/parserInputStreamAdapter.hpp
+index c24fa44..861e75b 100644
+--- a/vmime/utility/parserInputStreamAdapter.hpp
++++ b/vmime/utility/parserInputStreamAdapter.hpp
+@@ -82,7 +82,7 @@ public:
+ 
+ 			m_stream->seek(initialPos);
+ 
+-			return (readBytes == 1 ? buffer[0] : 0);
++			return (readBytes == 1 ? buffer[0] : static_cast <value_type>(0));
+ 		}
+ 		catch (...)
+ 		{
+@@ -101,7 +101,7 @@ public:
+ 		value_type buffer[1];
+ 		const size_type readBytes = m_stream->read(buffer, 1);
+ 
+-		return (readBytes == 1 ? buffer[0] : 0);
++		return (readBytes == 1 ? buffer[0] : static_cast <value_type>(0));
+ 	}
+ 
+ 	/** Check whether the bytes following the current position match
+-- 
+1.7.10.4
+
+
+From f9f9b3bf52c76e1803855d1c44147f68ec9f62f2 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Mon, 30 Jul 2012 20:45:17 +0200
+Subject: [PATCH 42/42] Fixed body part extraction (only body should be
+ extracted).
+
+
+diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp
+index 7202a7d..808f7d1 100644
+--- a/src/net/imap/IMAPMessage.cpp
++++ b/src/net/imap/IMAPMessage.cpp
+@@ -192,7 +192,7 @@ void IMAPMessage::extract(utility::outputStream& os, utility::progressListener*
+ 	if (!folder)
+ 		throw exceptions::folder_not_found();
+ 
+-	extract(NULL, os, progress, start, length, false, peek);
++	extractImpl(NULL, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
+ }
+ 
+ 
+@@ -205,7 +205,7 @@ void IMAPMessage::extractPart
+ 	if (!folder)
+ 		throw exceptions::folder_not_found();
+ 
+-	extract(p, os, progress, start, length, false, peek);
++	extractImpl(p, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
+ }
+ 
+ 
+@@ -219,7 +219,7 @@ void IMAPMessage::fetchPartHeader(ref <part> p)
+ 	std::ostringstream oss;
+ 	utility::outputStreamAdapter ossAdapter(oss);
+ 
+-	extract(p, ossAdapter, NULL, 0, -1, true, true);
++	extractImpl(p, ossAdapter, NULL, 0, -1, EXTRACT_HEADER | EXTRACT_PEEK);
+ 
+ 	p.dynamicCast <IMAPPart>()->getOrCreateHeader().parse(oss.str());
+ }
+@@ -240,9 +240,9 @@ void IMAPMessage::fetchPartHeaderForStructure(ref <structure> str)
+ }
+ 
+ 
+-void IMAPMessage::extract(ref <const part> p, utility::outputStream& os,
++void IMAPMessage::extractImpl(ref <const part> p, utility::outputStream& os,
+ 	utility::progressListener* progress, const int start,
+-	const int length, const bool headerOnly, const bool peek) const
++	const int length, const int extractFlags) const
+ {
+ 	ref <const IMAPFolder> folder = m_folder.acquire();
+ 
+@@ -284,18 +284,45 @@ void IMAPMessage::extract(ref <const part> p, utility::outputStream& os,
+ 	else
+ 		command << "UID FETCH " << IMAPUtils::extractUIDFromGlobalUID(m_uid) << " BODY";
+ 
+-	if (peek) command << ".PEEK";
++	/*
++	   BODY[]               header + body
++	   BODY.PEEK[]          header + body (peek)
++	   BODY[HEADER]         header
++	   BODY.PEEK[HEADER]    header (peek)
++	   BODY[TEXT]           body
++	   BODY.PEEK[TEXT]      body (peek)
++	*/
++
++	if (extractFlags & EXTRACT_PEEK)
++		command << ".PEEK";
++
+ 	command << "[";
+ 
+ 	if (section.str().empty())
+ 	{
+-		if (headerOnly)
++		// header + body
++		if ((extractFlags & EXTRACT_HEADER) && (extractFlags & EXTRACT_BODY))
++			command << "";
++		// body only
++		else if (extractFlags & EXTRACT_BODY)
++			command << "TEXT";
++		// header only
++		else if (extractFlags & EXTRACT_HEADER)
+ 			command << "HEADER";
+ 	}
+ 	else
+ 	{
+ 		command << section.str();
+-		if (headerOnly) command << ".MIME";   // "MIME" not "HEADER" for parts
++
++		// header + body
++		if ((extractFlags & EXTRACT_HEADER) && (extractFlags & EXTRACT_BODY))
++			*((int *) 0)=42;//throw exceptions::operation_not_supported();
++		// body only
++		else if (extractFlags & EXTRACT_BODY)
++			command << ".TEXT";
++		// header only
++		else if (extractFlags & EXTRACT_HEADER)
++			command << ".MIME";   // "MIME" not "HEADER" for parts
+ 	}
+ 
+ 	command << "]";
+@@ -318,7 +345,7 @@ void IMAPMessage::extract(ref <const part> p, utility::outputStream& os,
+ 	}
+ 
+ 
+-	if (!headerOnly)
++	if (extractFlags & EXTRACT_BODY)
+ 	{
+ 		// TODO: update the flags (eg. flag "\Seen" may have been set)
+ 	}
+diff --git a/src/net/imap/IMAPMessagePartContentHandler.cpp b/src/net/imap/IMAPMessagePartContentHandler.cpp
+index 85c6ec2..c2cd647 100644
+--- a/src/net/imap/IMAPMessagePartContentHandler.cpp
++++ b/src/net/imap/IMAPMessagePartContentHandler.cpp
+@@ -121,7 +121,7 @@ void IMAPMessagePartContentHandler::extract
+ 	// No decoding to perform
+ 	if (!isEncoded())
+ 	{
+-		msg->extractPart(part, os, progress);
++		msg->extractImpl(part, os, progress, 0, -1, IMAPMessage::EXTRACT_BODY);
+ 	}
+ 	// Need to decode data
+ 	else
+@@ -130,7 +130,7 @@ void IMAPMessagePartContentHandler::extract
+ 		std::ostringstream oss;
+ 		utility::outputStreamAdapter tmp(oss);
+ 
+-		msg->extractPart(part, tmp, NULL);
++		msg->extractImpl(part, tmp, NULL, 0, -1, IMAPMessage::EXTRACT_BODY);
+ 
+ 		// Encode temporary buffer to output stream
+ 		utility::inputStreamStringAdapter is(oss.str());
+diff --git a/vmime/net/imap/IMAPMessage.hpp b/vmime/net/imap/IMAPMessage.hpp
+index fbba6e7..06f8091 100644
+--- a/vmime/net/imap/IMAPMessage.hpp
++++ b/vmime/net/imap/IMAPMessage.hpp
+@@ -47,6 +47,7 @@ class IMAPMessage : public message
+ private:
+ 
+ 	friend class IMAPFolder;
++	friend class IMAPMessagePartContentHandler;
+ 	friend class vmime::creator;  // vmime::create <IMAPMessage>
+ 
+ 	IMAPMessage(ref <IMAPFolder> folder, const int num);
+@@ -101,7 +102,16 @@ private:
+ 	  */
+ 	void constructParsedMessage(ref <bodyPart> parentPart, ref <structure> str, int level = 0);
+ 
+-	void extract(ref <const part> p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool headerOnly, const bool peek) const;
++
++	enum ExtractFlags
++	{
++		EXTRACT_HEADER = 0x1,
++		EXTRACT_BODY = 0x2,
++		EXTRACT_PEEK = 0x10
++	};
++
++	void extractImpl(ref <const part> p, utility::outputStream& os, utility::progressListener* progress,
++		const int start, const int length, const int extractFlags) const;
+ 
+ 
+ 	ref <header> getOrCreateHeader();
+-- 
+1.7.10.4
+
--- a/src/vmime.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/vmime.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,20 +10,16 @@
 $(PKG)_DEPS     := gcc libiconv gnutls libgsasl pthreads zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/vmime/files/vmime/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/vmime/files/vmime/' | \
     $(SED) -n 's,.*libvmime-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
 endef
 
 define $(PKG)_BUILD
+    $(SED) -i 's/pkg-config/$(TARGET)-pkg-config/g;'  '$(1)/SConstruct'
+
     # The configure script will make the real configuration, but
     # we need scons to generate configure.in, Makefile.am etc.
-    # ansi and pedantic are too strict for mingw.
-    # http://sourceforge.net/tracker/index.php?func=detail&aid=2373234&group_id=2435&atid=102435
-    $(SED) -i "s/'-ansi', //;"                        '$(1)/SConstruct'
-    $(SED) -i "s/'-pedantic', //;"                    '$(1)/SConstruct'
-    $(SED) -i 's/pkg-config/$(TARGET)-pkg-config/g;'  '$(1)/SConstruct'
-
     cd '$(1)' && scons autotools \
          prefix='$(PREFIX)/$(TARGET)' \
          target='$(TARGET)' \
@@ -33,6 +29,7 @@
     cd '$(1)' && ./configure \
         --prefix='$(PREFIX)/$(TARGET)' \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --enable-platform-windows \
         --disable-rpath \
--- a/src/vorbis.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/vorbis.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := vorbis
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 4b089ace4c8420c479b2fde9c5b01588cf86c959
+$(PKG)_CHECKSUM := 8dae60349292ed76db0e490dc5ee51088a84518b
 $(PKG)_SUBDIR   := libvorbis-$($(PKG)_VERSION)
 $(PKG)_FILE     := libvorbis-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://downloads.xiph.org/releases/vorbis/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc ogg
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.xiph.org/downloads/' | \
+    $(WGET) -q -O- 'http://www.xiph.org/downloads/' | \
     $(SED) -n 's,.*libvorbis-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -18,6 +18,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         PKG_CONFIG='$(TARGET)-pkg-config'
--- a/src/vtk.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/vtk.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := qt expat freetype jpeg libxml2 libpng tiff zlib libodbc++ postgresql
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://vtk.org/gitweb?p=VTK.git;a=tags' | \
+    $(WGET) -q -O- 'http://vtk.org/gitweb?p=VTK.git;a=tags' | \
     grep 'refs/tags/v[0-9.]*"' | \
     $(SED) 's,.*refs/tags/v\(.*\)".*,\1,g;' | \
     head -1
@@ -21,7 +21,6 @@
     # first we need a native build to create the compile tools
     mkdir '$(1)/native_build'
     cd '$(1)/native_build' && cmake \
-        -DCMAKE_BUILD_TYPE='Release' \
         -DBUILD_TESTING=FALSE \
         -DOPENGL_INCLUDE_DIR='$(1)/Utilities/ParseOGLExt/headers' \
         -DVTK_USE_RENDERING=FALSE \
--- a/src/w32api.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/w32api.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/' | \
     $(SED) -n 's,.*w32api-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/winpcap.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/winpcap.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.winpcap.org/devel.htm' | \
+    $(WGET) -q -O- 'http://www.winpcap.org/devel.htm' | \
     $(SED) -n 's,.*WpcapSrc_\([0-9][^>]*\)\.zip.*,\1,p' | \
     head -1
 endef
--- a/src/wt-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/wt-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,10 +1,17 @@
-# This file is part of MXE.
-# See index.html for further information.
+This file is part of MXE.
+See index.html for further information.
 
-diff -ur a/cmake/WtFindBoost-vintage.txt b/cmake/WtFindBoost-vintage.txt
---- a/cmake/WtFindBoost-vintage.txt	2011-11-15 04:49:29.000000000 -0300
-+++ b/cmake/WtFindBoost-vintage.txt	2012-02-02 19:21:07.108060403 -0300
-@@ -70,6 +70,7 @@
+From 52fc36d3d87c8fc3df1b4bb005ef39bd61db2fef Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Mon, 18 Jun 2012 13:23:21 +0200
+Subject: [PATCH] fixes for mxe
+
+
+diff --git a/cmake/WtFindBoost-vintage.txt b/cmake/WtFindBoost-vintage.txt
+index e48b21e..1198139 100644
+--- a/cmake/WtFindBoost-vintage.txt
++++ b/cmake/WtFindBoost-vintage.txt
+@@ -70,6 +70,7 @@ ELSE(MSVC)
        boost_thread-${BOOST_COMPILER}-mt-${BOOST_FLAGS}-${BOOST_VERSION}
        boost_thread-${BOOST_COMPILER}-mt-${BOOST_VERSION}
        boost_thread-${BOOST_COMPILER}-mt
@@ -12,10 +19,11 @@
        boost_thread-mt-${BOOST_VERSION}
        boost_thread-mt
        boost_thread-${BOOST_COMPILER}-${BOOST_VERSION}
-diff -ur a/cmake/WtFindGm.txt b/cmake/WtFindGm.txt
---- a/cmake/WtFindGm.txt	2011-04-01 07:35:50.000000000 -0300
-+++ b/cmake/WtFindGm.txt	2012-02-02 21:31:04.157439938 -0300
-@@ -59,6 +59,12 @@
+diff --git a/cmake/WtFindGm.txt b/cmake/WtFindGm.txt
+index 76697fc..9bc0fa1 100644
+--- a/cmake/WtFindGm.txt
++++ b/cmake/WtFindGm.txt
+@@ -59,6 +59,12 @@ IF(WIN32)
    ELSE(GM_LIB AND GMPP_LIB AND GM_LIB_DEBUG AND GMPP_LIB_DEBUG AND GM_INCLUDE_DIR)
      SET(GM_FOUND FALSE)
    ENDIF(GM_LIB AND GMPP_LIB AND GM_LIB_DEBUG AND GMPP_LIB_DEBUG AND GM_INCLUDE_DIR)
@@ -28,10 +36,11 @@
  ELSE(WIN32)
    FIND_LIBRARY(GM_LIB
      NAMES
-diff -ur a/cmake/WtFindHaru.txt b/cmake/WtFindHaru.txt
---- a/cmake/WtFindHaru.txt	2011-01-10 05:50:55.000000000 -0300
-+++ b/cmake/WtFindHaru.txt	2012-02-02 21:32:08.165440382 -0300
-@@ -44,6 +44,7 @@
+diff --git a/cmake/WtFindHaru.txt b/cmake/WtFindHaru.txt
+index 4dba35f..642bd58 100644
+--- a/cmake/WtFindHaru.txt
++++ b/cmake/WtFindHaru.txt
+@@ -44,6 +44,7 @@ IF(WIN32)
    FIND_LIBRARY(Z_LIB
      NAMES
        zlib
@@ -39,7 +48,7 @@
      PATHS
        ${HARU_PREFIX}/lib
        ${USERLIB_PREFIX}/lib
-@@ -58,6 +59,17 @@
+@@ -58,6 +59,17 @@ IF(WIN32)
        SET(HARU_SUPPORT_LIBS ${HARU_SUPPORT_LIBS} ${Z_LIB})
      ENDIF(Z_LIB)
    ENDIF(HARU_LIB_RELEASE AND HARU_LIB_DEBUG)
@@ -57,10 +66,11 @@
    SET(HARU_SUPPORT_LIBS_FOUND TRUE)
  ELSE(WIN32)
    FIND_LIBRARY(HARU_LIB
-diff -ur a/cmake/WtFindPangoFt2.txt b/cmake/WtFindPangoFt2.txt
---- a/cmake/WtFindPangoFt2.txt	2011-11-28 06:26:54.000000000 -0300
-+++ b/cmake/WtFindPangoFt2.txt	2012-02-02 21:17:14.341434198 -0300
-@@ -36,11 +36,15 @@
+diff --git a/cmake/WtFindPangoFt2.txt b/cmake/WtFindPangoFt2.txt
+index cd1e640..b1bbe3d 100644
+--- a/cmake/WtFindPangoFt2.txt
++++ b/cmake/WtFindPangoFt2.txt
+@@ -36,11 +36,15 @@ SET(PANGO_FT2_INCLUDE_DIRS
      ${GLIB2_INCLUDE_DIR}
      ${GLIB2_CONFIG_INCLUDE_DIR})
  
@@ -81,10 +91,11 @@
  
  IF (PANGO_INCLUDE_DIR
      AND FT2_INCLUDE_DIR
-diff -ur a/cmake/WtFindSsl.txt b/cmake/WtFindSsl.txt
---- a/cmake/WtFindSsl.txt	2011-09-19 09:34:19.000000000 -0300
-+++ b/cmake/WtFindSsl.txt	2012-02-02 21:17:53.033434468 -0300
-@@ -81,6 +81,11 @@
+diff --git a/cmake/WtFindSsl.txt b/cmake/WtFindSsl.txt
+index fdbcb5f..578baf1 100644
+--- a/cmake/WtFindSsl.txt
++++ b/cmake/WtFindSsl.txt
+@@ -81,6 +81,11 @@ IF(WIN32)
        AND SSL_LIB_DEBUG
        AND SSL_TOO_LIB_RELEASE
        AND SSL_TOO_LIB_DEBUG)
@@ -96,21 +107,10 @@
  ELSE (WIN32)
    FIND_LIBRARY(SSL_LIB
      NAMES
-diff -ur a/src/http/Configuration.C b/src/http/Configuration.C
---- a/src/http/Configuration.C	2011-11-24 13:17:42.000000000 -0300
-+++ b/src/http/Configuration.C	2012-02-02 19:21:07.112060403 -0300
-@@ -18,7 +18,7 @@
- #endif
- #ifdef WIN32
- #include <process.h> // for getpid()
--#include <Winsock2.h> // for gethostname()
-+#include <winsock2.h> // for gethostname()
- #endif
- #include <iostream>
- #include <fstream>
-diff -ur a/src/Wt/WRasterImage.C b/src/Wt/WRasterImage.C
---- a/src/Wt/WRasterImage.C	2011-11-24 13:17:42.000000000 -0300
-+++ b/src/Wt/WRasterImage.C	2012-02-02 19:21:07.112060403 -0300
+diff --git a/src/Wt/WRasterImage.C b/src/Wt/WRasterImage.C
+index 4c52f39..e948691 100644
+--- a/src/Wt/WRasterImage.C
++++ b/src/Wt/WRasterImage.C
 @@ -38,15 +38,6 @@
  #define M_PI 3.14159265358979323846
  #endif
@@ -127,3 +127,6 @@
  namespace {
    static const double EPSILON = 1E-5;
  
+-- 
+1.7.10.4
+
--- a/src/wt.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/wt.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := wt
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 38cf20980f16b0970c42ace45fd62edb28b6358b
+$(PKG)_CHECKSUM := 30f754d631905c4e7ef55ad095b6e480bada642f
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/witty/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/witty/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc boost openssl libharu graphicsmagick pango postgresql sqlite
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/witty/files/witty/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/witty/files/witty/' | \
     $(SED) -n 's,.*wt-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
 endef
@@ -31,8 +31,8 @@
         -DGM_PREFIX='$(PREFIX)/$(TARGET)' \
         -DGM_LIBS="`'$(TARGET)-pkg-config' --libs-only-l GraphicsMagick++`" \
         -DPANGO_FT2_LIBS="`'$(TARGET)-pkg-config' --libs-only-l pangoft2`" \
+        -DWT_CMAKE_FINDER_INSTALL_DIR='/lib/wt' \
         -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
-        -DCMAKE_BUILD_TYPE:STRING="Release" \
         '$(1)'
     $(MAKE) -C '$(1).build' -j '$(JOBS)' install VERBOSE=1
 endef
--- a/src/wxwidgets.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/wxwidgets.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv libpng jpeg tiff sdl zlib expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/wxwindows/files/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/wxwindows/files/' | \
     $(SED) -n 's,.*/\([0-9][^"9]*\)/".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/xapian-core.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,19 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := xapian-core
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 1be1896ab11a3a66c6c0ade962c700d96678116e
+$(PKG)_SUBDIR   := xapian-core-$($(PKG)_VERSION)
+$(PKG)_FILE     := xapian-core-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://oligarchy.co.uk/xapian/$($(PKG)_VERSION)/xapian-core-$($(PKG)_VERSION).tar.gz
+$(PKG)_DEPS     := gcc zlib
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --enable-static
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+endef
--- a/src/xerces.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/xerces.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc libiconv curl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.apache.org/dist/xerces/c/3/sources/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://www.apache.org/dist/xerces/c/3/sources/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="xerces-c-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v rc | \
     head -1
--- a/src/xine-lib-1-fixes.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/xine-lib-1-fixes.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -1,62 +1,19 @@
 This file is part of MXE.
 See index.html for further information.
 
-Contains ad hoc patches for cross building.
-
-From 4968ed3c3300976ce8b24c52c729db6bd264057c Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Sun, 13 Nov 2011 11:48:07 +0100
-Subject: [PATCH 1/4] fix-install-def-file
-
-
-diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am
-index 67ae63f..0f94abf 100644
---- a/src/xine-engine/Makefile.am
-+++ b/src/xine-engine/Makefile.am
-@@ -45,10 +45,10 @@ noinst_HEADERS = bswap.h ffmpeg_bswap.h xine_private.h
- 
- if WIN32
- install-exec-local:
--	cp -p $(DEF_FILE) $(DESTDIR)$(libdir)
-+	-cp -p $(DEF_FILE) $(DESTDIR)$(libdir)
- 
- uninstall-local:
--	rm -f $(DEF_FILE)
-+	-rm -f $(DESTDIR)$(libdir)/$(DEF_FILE)
- endif
- 
- $(XINEUTILS_LIB):
-diff --git a/src/xine-engine/Makefile.in b/src/xine-engine/Makefile.in
-index 167a32b..0664e1f 100644
---- a/src/xine-engine/Makefile.in
-+++ b/src/xine-engine/Makefile.in
-@@ -905,10 +905,10 @@ $(LIBXINEPOSIX):
- 	$(MAKE) -C $(top_builddir)/lib libxineposix.la
- 
- @WIN32_TRUE@install-exec-local:
--@WIN32_TRUE@	cp -p $(DEF_FILE) $(DESTDIR)$(libdir)
-+@WIN32_TRUE@	-cp -p $(DEF_FILE) $(DESTDIR)$(libdir)
- 
- @WIN32_TRUE@uninstall-local:
--@WIN32_TRUE@	rm -f $(DEF_FILE)
-+@WIN32_TRUE@	-rm -f $(DESTDIR)$(libdir)/$(DEF_FILE)
- 
- $(XINEUTILS_LIB):
- 	$(MAKE) -C $(top_builddir)/src/xine-utils libxineutils.la
--- 
-1.7.8.3
-
-
-From 86f2d23f9229e17aa4a54ca982b8f95de5ee4644 Mon Sep 17 00:00:00 2001
-From: MXE
+From 6dc46ed1253c1fce1cfa8d360e352b5bc12d0d3b Mon Sep 17 00:00:00 2001
+From: "mxe@mxe.cc" <mxe@mxe.cc>
 Date: Sun, 13 Nov 2011 12:05:22 +0100
-Subject: [PATCH 2/4] fake missing definitions for WIN32
+Subject: [PATCH 1/4] fake missing definitions for WIN32
 
 Taken from:
 https://bugs.xine-project.org/show_bug.cgi?id=433
+---
+ src/audio_out/audio_file_out.c |   12 ++++++++++++
+ 1 file changed, 12 insertions(+)
 
 diff --git a/src/audio_out/audio_file_out.c b/src/audio_out/audio_file_out.c
-index 802461e..8b9b704 100644
+index bc40d4e..a613a89 100644
 --- a/src/audio_out/audio_file_out.c
 +++ b/src/audio_out/audio_file_out.c
 @@ -53,6 +53,18 @@
@@ -79,17 +36,20 @@
  
  struct wavhdr {
 -- 
-1.7.8.3
+1.7.10.4
 
 
-From 42946ec1f900d22b62cb28996b9f12d11d7be7a8 Mon Sep 17 00:00:00 2001
-From: MXE
+From 4a7cd803cbc3daa3f19fdc6b34fb93e1994bc2f5 Mon Sep 17 00:00:00 2001
+From: "mxe@mxe.cc" <mxe@mxe.cc>
 Date: Sun, 13 Nov 2011 13:45:21 +0100
-Subject: [PATCH 3/4] force graphicsmagick over imagemagick
+Subject: [PATCH 2/4] force graphicsmagick over imagemagick
 
+---
+ configure.ac |    9 ---------
+ 1 file changed, 9 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
-index b175301..d37ba36 100644
+index 9112b58..67f1147 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -1412,14 +1412,6 @@ AC_ARG_WITH([imagemagick],
@@ -116,37 +76,68 @@
        AC_MSG_ERROR([ImageMagick support requested, but neither Wand, MagickWand, nor GraphicsMagick were found])
     elif test "x$have_imagemagick" = "xyes"; then
 -- 
-1.7.8.3
+1.7.10.4
 
 
-From f0fa8b5b9570cdf88788067b1a76669c6863ac9f Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Mon, 30 Jan 2012 09:21:33 +0100
-Subject: [PATCH 4/4] zlib 1.2.6 compatibility
+From 5b362f4aed3a814a351cd259efb62b40761ddb3d Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 27 May 2012 23:28:57 +0200
+Subject: [PATCH 3/4] add missing localtime_r
+
+Previously provided by pthreads-w32-2-8-0-release, which is also
+the source of this version.
+---
+ src/localtime_r.h         |    3 +++
+ src/xine-engine/scratch.c |    1 +
+ 2 files changed, 4 insertions(+)
+ create mode 100644 src/localtime_r.h
+
+diff --git a/src/localtime_r.h b/src/localtime_r.h
+new file mode 100644
+index 0000000..ec778c5
+--- /dev/null
++++ b/src/localtime_r.h
+@@ -0,0 +1,3 @@
++#define localtime_r( _clock, _result ) \
++        ( *(_result) = *localtime( (_clock) ), \
++          (_result) )
+diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c
+index 39bb592..41d561b 100644
+--- a/src/xine-engine/scratch.c
++++ b/src/xine-engine/scratch.c
+@@ -36,6 +36,7 @@
+ 
+ #include "xineutils.h"
+ #include "scratch.h"
++#include "localtime_r.h"
+ 
+ static void XINE_FORMAT_PRINTF(2, 0)
+   scratch_printf (scratch_buffer_t *this, const char *format, va_list argp)
+-- 
+1.7.10.4
 
 
-diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c
-index 1d22ea3..0fbde93 100644
---- a/src/xine-engine/osd.c
-+++ b/src/xine-engine/osd.c
-@@ -650,7 +650,7 @@ static void osd_set_position (osd_object_t *osd, int x, int y) {
-   osd->display_y = y;
+From 0d3546c3c12a8bf311c9751f0d0d2e3a95569657 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 27 May 2012 23:23:19 +0200
+Subject: [PATCH 4/4] ffmpeg 0.11 removed avcodec_init
+
+---
+ src/combined/ffmpeg/ffmpeg_decoder.c |    1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/src/combined/ffmpeg/ffmpeg_decoder.c b/src/combined/ffmpeg/ffmpeg_decoder.c
+index 879df53..84ee1a3 100644
+--- a/src/combined/ffmpeg/ffmpeg_decoder.c
++++ b/src/combined/ffmpeg/ffmpeg_decoder.c
+@@ -312,7 +312,6 @@ void avcodec_register_all(void)
+ 
+ void init_once_routine(void) {
+   pthread_mutex_init(&ffmpeg_lock, NULL);
+-  avcodec_init();
+   avcodec_register_all();
  }
  
--static uint16_t gzread_i16(gzFile *fp) {
-+static uint16_t gzread_i16(gzFile fp) {
-   uint16_t ret;
-   ret = gzgetc(fp);
-   ret |= (gzgetc(fp)<<8);
-@@ -663,7 +663,7 @@ static uint16_t gzread_i16(gzFile *fp) {
- 
- static int osd_renderer_load_font(osd_renderer_t *this, char *filename) {
- 
--  gzFile      *fp;
-+  gzFile      fp;
-   osd_font_t  *font = NULL;
-   int          i, ret = 0;
- 
 -- 
-1.7.8.3
+1.7.10.4
 
--- a/src/xine-lib.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/xine-lib.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := xine-lib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 68e85049723b491ccb22d5123bf8fa780529868a
+$(PKG)_CHECKSUM := 0adf20ef55d24f2a1b4a8974e57ad1be5133b236
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/xine/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc faad2 ffmpeg flac fontconfig freetype graphicsmagick libiconv libmng pthreads sdl speex theora vorbis zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.debian.org/hg/xine-lib/xine-lib/tags' | \
+    $(WGET) -q -O- 'http://hg.debian.org/hg/xine-lib/xine-lib/tags' | \
     $(SED) -n 's,>,\n,gp' | \
     $(SED) -n 's,^\([0-9][^< ]*\)<.*,\1,p' | \
     head -1
--- a/src/xmlwrapp.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/xmlwrapp.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := xmlwrapp
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := b3ef8bff215bbacd988790615b76379672105928
+$(PKG)_CHECKSUM := 7bd66ecc1204b296580a499fd929d77b79e6e85a
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc libxml2 libxslt
+$(PKG)_DEPS     := gcc boost libxml2 libxslt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/xmlwrapp/files/xmlwrapp/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/xmlwrapp/files/xmlwrapp/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/xvidcore.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/xvidcore.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.xvid.org/' | \
+    $(WGET) -q -O- 'http://www.xvid.org/' | \
     $(SED) -n 's,.*Xvid \([0-9][^ ]*\) .*,\1,p' | \
     head -1
 endef
--- a/src/xz.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/xz.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := xz
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 50ce842bea6519537457d9ad90d110a127656786
+$(PKG)_CHECKSUM := 3e976d7715fde43422572c70f927bfdae56a94c3
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://tukaani.org/xz/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://tukaani.org/xz/' | \
+    $(WGET) -q -O- 'http://tukaani.org/xz/' | \
     $(SED) -n 's,.*xz-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -18,9 +18,9 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
-        --disable-dynamic \
         --disable-threads \
         --disable-nls
     $(MAKE) -C '$(1)'/src/liblzma -j '$(JOBS)' install
--- a/src/zlib-1-win32-static.patch	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/zlib-1-win32-static.patch	Mon Oct 08 22:34:44 2012 +0200
@@ -13,7 +13,7 @@
 index ea430bf..f2573e7 100644
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -188,11 +188,11 @@ install-libs: $(LIBS)
+@@ -190,11 +190,11 @@ install-libs: $(LIBS)
  	-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
  	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
  	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
@@ -31,7 +31,7 @@
 index 780317c..6e6a033 100755
 --- a/configure
 +++ b/configure
-@@ -180,10 +180,7 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
+@@ -205,10 +205,7 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
    CYGWIN* | Cygwin* | cygwin* | OS/2*)
          EXE='.exe' ;;
    MINGW* | mingw*)
--- a/src/zlib.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/zlib.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := zlib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3d445731e4bfea1cd00f36567d77d6e5f5a19be9
+$(PKG)_CHECKSUM := 858818fe6d358ec682d54ac5e106a2dd62628e7f
 $(PKG)_SUBDIR   := zlib-$($(PKG)_VERSION)
 $(PKG)_FILE     := zlib-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://zlib.net/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://zlib.net/' | \
+    $(WGET) -q -O- 'http://zlib.net/' | \
     $(SED) -n 's,.*zlib-\([0-9][^>]*\)\.tar.*,\1,ip' | \
     head -1
 endef
--- a/src/zziplib.mk	Mon Oct 08 22:34:18 2012 +0200
+++ b/src/zziplib.mk	Mon Oct 08 22:34:44 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/zziplib/files/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/zziplib/files/' | \
     $(SED) -n 's,.*zziplib-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/s3-fetch-and-sync	Mon Oct 08 22:34:44 2012 +0200
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+#ec2-174-129-78-72.compute-1.amazonaws.com
+#http://s3tools.org/s3cmd
+
+cd ~/mxe && git pull
+cd ~/mxe && make download
+s3cmd sync --acl-public ~/mxe/pkg/* s3://mxe-pkg/