From 575fed1dd076396f2dc8ad6402cd5000077952fa Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sun, 10 May 2020 16:54:14 +0000 Subject: [PATCH] BUILDBOT: Add toolchain for OpenPandora --- master/platforms.py | 19 + toolchains/openpandora/Dockerfile.m4 | 116 + toolchains/openpandora/functions-platform.sh | 3 + .../openpandora/packages/alsa-lib/build.sh | 26 + toolchains/openpandora/packages/curl/build.sh | 23 + .../openpandora/packages/faad2/build.sh | 24 + toolchains/openpandora/packages/flac/build.sh | 23 + .../packages/flac/patches/remove-xmms.patch | 16 + .../openpandora/packages/freetype/build.sh | 31 + .../openpandora/packages/gnutls/build.sh | 78 + .../packages/gnutls/gnutls-openssl.patch | 149 ++ .../openpandora/packages/libjpeg/build.sh | 24 + .../packages/libjpeg/patches/debian.patch | 1874 +++++++++++++++++ .../openpandora/packages/libogg/build.sh | 24 + .../openpandora/packages/libpng/build.sh | 28 + .../openpandora/packages/libsdl/build.sh | 35 + .../openpandora/packages/libvorbis/build.sh | 24 + .../openpandora/packages/sdl-net1.2/build.sh | 21 + .../openpandora/packages/toolchain/build.sh | 36 + .../openpandora/packages/toolchain/config | 179 ++ .../patches/add-openpandora-support.patch | 579 +++++ .../toolchain/patches/allow-root-build.patch | 18 + .../patches/allow-static-libstdc++.patch | 31 + .../toolchain/patches/switch-back-eabi4.patch | 60 + .../openpandora/packages/tslib/build.sh | 25 + .../packages/tslib/patches/fix-malloc.patch | 12 + .../packages/tslib/patches/fix-version.patch | 32 + toolchains/openpandora/packages/x11/build.sh | 208 ++ toolchains/openpandora/packages/zlib/build.sh | 21 + .../packages/zlib/patches/visibility.patch | 955 +++++++++ workers/openpandora/Dockerfile.m4 | 32 + 31 files changed, 4726 insertions(+) create mode 100644 toolchains/openpandora/Dockerfile.m4 create mode 100644 toolchains/openpandora/functions-platform.sh create mode 100755 toolchains/openpandora/packages/alsa-lib/build.sh create mode 100755 toolchains/openpandora/packages/curl/build.sh create mode 100755 toolchains/openpandora/packages/faad2/build.sh create mode 100755 toolchains/openpandora/packages/flac/build.sh create mode 100644 toolchains/openpandora/packages/flac/patches/remove-xmms.patch create mode 100755 toolchains/openpandora/packages/freetype/build.sh create mode 100755 toolchains/openpandora/packages/gnutls/build.sh create mode 100644 toolchains/openpandora/packages/gnutls/gnutls-openssl.patch create mode 100755 toolchains/openpandora/packages/libjpeg/build.sh create mode 100644 toolchains/openpandora/packages/libjpeg/patches/debian.patch create mode 100755 toolchains/openpandora/packages/libogg/build.sh create mode 100755 toolchains/openpandora/packages/libpng/build.sh create mode 100755 toolchains/openpandora/packages/libsdl/build.sh create mode 100755 toolchains/openpandora/packages/libvorbis/build.sh create mode 100755 toolchains/openpandora/packages/sdl-net1.2/build.sh create mode 100755 toolchains/openpandora/packages/toolchain/build.sh create mode 100644 toolchains/openpandora/packages/toolchain/config create mode 100644 toolchains/openpandora/packages/toolchain/patches/add-openpandora-support.patch create mode 100644 toolchains/openpandora/packages/toolchain/patches/allow-root-build.patch create mode 100644 toolchains/openpandora/packages/toolchain/patches/allow-static-libstdc++.patch create mode 100644 toolchains/openpandora/packages/toolchain/patches/switch-back-eabi4.patch create mode 100755 toolchains/openpandora/packages/tslib/build.sh create mode 100644 toolchains/openpandora/packages/tslib/patches/fix-malloc.patch create mode 100644 toolchains/openpandora/packages/tslib/patches/fix-version.patch create mode 100755 toolchains/openpandora/packages/x11/build.sh create mode 100755 toolchains/openpandora/packages/zlib/build.sh create mode 100644 toolchains/openpandora/packages/zlib/patches/visibility.patch create mode 100644 workers/openpandora/Dockerfile.m4 diff --git a/master/platforms.py b/master/platforms.py index b89c816..2e32e5e 100644 --- a/master/platforms.py +++ b/master/platforms.py @@ -314,6 +314,25 @@ def nds(): register_platform(platform) nds() +def openpandora(): + platform = Platform("openpandora") + platform.workerimage = "openpandora" + platform.compatibleBuilds = (builds.ScummVMBuild, ) + platform.env["CXX"] = "ccache /opt/openpandora/bin/arm-angstrom-linux-gnueabi-c++" + platform.configureargs.append("--host=openpandora") + platform.buildconfigureargs = { + builds.ScummVMBuild: [ "--enable-plugins", "--default-dynamic", "--enable-vkeybd" ], + } + platform.packaging_cmd = "op-pnd" + platform.built_files = { + builds.ScummVMBuild: [ "release/scummvm-op-pnd.tar.bz2" ], + } + platform.archiveext = "tar.bz2" + platform.testable = False + platform.run_tests = False + register_platform(platform) +openpandora() + def ps3(): platform = Platform("ps3") platform.compatibleBuilds = (builds.ScummVMBuild, ) diff --git a/toolchains/openpandora/Dockerfile.m4 b/toolchains/openpandora/Dockerfile.m4 new file mode 100644 index 0000000..c510aa7 --- /dev/null +++ b/toolchains/openpandora/Dockerfile.m4 @@ -0,0 +1,116 @@ +FROM toolchains/common AS helpers + +m4_include(`paths.m4')m4_dnl + +m4_include(`packages.m4')m4_dnl + +FROM debian:stable-slim +USER root + +WORKDIR /usr/src + +# Copy and execute each step separately to avoid invalidating cache +COPY --from=helpers /lib-helpers/prepare.sh lib-helpers/ +RUN lib-helpers/prepare.sh + +COPY --from=helpers /lib-helpers/functions.sh lib-helpers/ +COPY functions-platform.sh lib-helpers/ + +# Create fake links because those got deleted when installing gawk +# Using docker in an unprivileged container prevents deleting files across layers +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + bison \ + flex \ + gawk \ + g++ \ + help2man \ + libncurses-dev \ + libtool-bin \ + texinfo && \ + ln -s /nonexistent /etc/alternatives/awk.1.gz && \ + ln -s /nonexistent /etc/alternatives/nawk.1.gz && \ + rm -rf /var/lib/apt/lists/* + +ENV TOOLCHAIN=/opt/openpandora HOST=arm-angstrom-linux-gnueabi + +local_package(toolchain) + +ENV PREFIX=${TOOLCHAIN}/${HOST}/sysroot/usr + +ENV \ + def_binaries(`${TOOLCHAIN}/bin/${HOST}-', `ar, as, c++filt, ld, nm, objcopy, objdump, ranlib, readelf, strings, strip') \ + def_binaries(`${TOOLCHAIN}/bin/${HOST}-', `gcc, cpp, c++') \ + CC=${TOOLCHAIN}/bin/$HOST-gcc \ + def_aclocal(`${PREFIX}') \ + def_pkg_config(`${PREFIX}') \ + PATH=$PATH:${PREFIX}/bin + +# Use same version as official toolchain +local_package(zlib) + +# Use same version as official toolchain +local_package(libpng) + +# Use same version as official toolchain +local_package(libjpeg) + +# Use same version as official toolchain +local_package(faad2) + +# libmad hasn't seen any activity since a really long time and still has the same ABI +helpers_package(libmad, --enable-shared) + +# Use same version as official toolchain +local_package(libogg) + +# libtheora hasn't seen any activity since a really long time and still has the same version +helpers_package(libtheora, --enable-shared) + +# Use same version as official toolchain +local_package(libvorbis) + +# Use same version as official toolchain +local_package(flac) + +# No mpeg2dec in the original toolchain build ours statically +helpers_package(mpeg2dec) + +# No a52dec in the original toolchain build ours statically +helpers_package(a52dec) + +# Use same version as official toolchain +local_package(freetype) + +# No fribidi in the original toolchain build ours statically +helpers_package(fribidi) + +# We try to have the same SDL_config.h by installing same dependencies + +# Use same version as official toolchain +# Dependency of SDL +local_package(tslib) + +# Use same version as official toolchain +# Dependency of SDL +local_package(x11) + +# libGL could be needed but it seems toolchain got it built but not installed, so don't know... + +# Use same version as official toolchain +# Dependency of SDL +local_package(alsa-lib) + +# Use same version as official toolchain +local_package(libsdl) + +# Use same version as official toolchain +local_package(sdl-net1.2) + +# Use same version as official toolchain +local_package(gnutls) + +# Use same version as official toolchain +local_package(curl) + +# fluidsynth-lite is unlikely to be fast enough. diff --git a/toolchains/openpandora/functions-platform.sh b/toolchains/openpandora/functions-platform.sh new file mode 100644 index 0000000..8ff44b2 --- /dev/null +++ b/toolchains/openpandora/functions-platform.sh @@ -0,0 +1,3 @@ +do_configure_shared () { + ./configure --prefix=$PREFIX --host=$HOST --enable-shared --disable-static "$@" +} diff --git a/toolchains/openpandora/packages/alsa-lib/build.sh b/toolchains/openpandora/packages/alsa-lib/build.sh new file mode 100755 index 0000000..77671fa --- /dev/null +++ b/toolchains/openpandora/packages/alsa-lib/build.sh @@ -0,0 +1,26 @@ +#! /bin/sh + +# OpenPandora firmware uses alsa-lib 1.0.20 stick with it +ALSA_LIB_VERSION=1.0.20 +ALSA_LIB_SHA256=15f8d0eef1da10c62136107e7b585bc8beb9c9e9b7ad177654097f8c15e57a63 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch alsa-lib "http://www.alsa-project.org/files/pub/lib/alsa-lib-${ALSA_LIB_VERSION}.tar.bz2" \ + 'tar xjf' "sha256:${ALSA_LIB_SHA256}" + +# Enable shared objects to make binary lighter +do_configure_shared --disable-python + +# Only build src and include +do_make -C src +do_make -C include + +do_make -C src install-exec +do_make -C include install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/curl/build.sh b/toolchains/openpandora/packages/curl/build.sh new file mode 100755 index 0000000..f24abb1 --- /dev/null +++ b/toolchains/openpandora/packages/curl/build.sh @@ -0,0 +1,23 @@ +#! /bin/sh + +# OpenPandora firmware uses curl 7.20.0 stick with it +CURL_VERSION=7.20.0 +CURL_SHA256=eb516915da615d8f6b2b855004d5d4b19c468f080e3736d7a73c5599b9acab11 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch curl "http://curl.haxx.se/download/curl-${CURL_VERSION}.tar.bz2" \ + 'tar xjf' "sha256:${CURL_SHA256}" + +do_configure_shared --with-gnutls="$PREFIX" +do_make -C lib +do_make -C lib install +# No need to build includes +do_make -C include install +do_make install-pkgconfigDATA install-binSCRIPTS + +do_clean_bdir diff --git a/toolchains/openpandora/packages/faad2/build.sh b/toolchains/openpandora/packages/faad2/build.sh new file mode 100755 index 0000000..81bf675 --- /dev/null +++ b/toolchains/openpandora/packages/faad2/build.sh @@ -0,0 +1,24 @@ +#! /bin/sh + +# OpenPandora firmware uses faad2 2.7 stick with it +FAAD2_VERSION=2.7 +FAAD2_SHA256=14561b5d6bc457e825bfd3921ae50a6648f377a9396eaf16d4b057b39a3f63b5 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch faad2 "http://download.sourceforge.net/project/faac/faad2-src/faad2-${FAAD2_VERSION}/faad2-${FAAD2_VERSION}.tar.bz2" \ + 'tar xjf' "sha256:${FAAD2_SHA256}" + +# Avoid compiling and installing libfaad2_drm +sed -ie 's/^\(lib_LTLIBRARIES.*\) libfaad_drm.la/\1/' libfaad/Makefile.am + +autoreconf -fi +do_configure_shared +do_make -C libfaad +do_make -C libfaad install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/flac/build.sh b/toolchains/openpandora/packages/flac/build.sh new file mode 100755 index 0000000..d8357c3 --- /dev/null +++ b/toolchains/openpandora/packages/flac/build.sh @@ -0,0 +1,23 @@ +#! /bin/sh + +# OpenPandora firmware uses FLAC 1.2.1 stick with it +FLAC_VERSION=1.2.1 +FLAC_SHA256=9635a44bceb478bbf2ee8a785cf6986fba525afb5fad1fd4bba73cf71f2d3edf + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch flac "http://downloads.xiph.org/releases/flac/flac-${FLAC_VERSION}.tar.gz" \ + 'tar xzf' "sha256:${FLAC_SHA256}" + +autoreconf -fi +do_configure_shared --disable-doxygen-docs --disable-xmms-plugin --disable-cpplibs --enable-ogg "$@" +do_make -C src/libFLAC +do_make -C src/libFLAC install +# No need to build includes +do_make -C include install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/flac/patches/remove-xmms.patch b/toolchains/openpandora/packages/flac/patches/remove-xmms.patch new file mode 100644 index 0000000..e0fde54 --- /dev/null +++ b/toolchains/openpandora/packages/flac/patches/remove-xmms.patch @@ -0,0 +1,16 @@ +Index: flac-1.2.1/configure.in +=================================================================== +--- flac-1.2.1.orig/configure.in ++++ flac-1.2.1/configure.in +@@ -226,9 +226,9 @@ AC_HELP_STRING([--disable-xmms-plugin], + *) AC_MSG_ERROR(bad value ${enableval} for --enable-xmms-plugin) ;; + esac],[enable_xmms_plugin=true]) + if test "x$enable_xmms_plugin" != xfalse ; then +- AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - XMMS support will not be built])) ++ AC_MSG_ERROR(No XMMS support) + fi +-AM_CONDITIONAL(FLaC__HAS_XMMS, test -n "$XMMS_INPUT_PLUGIN_DIR") ++AM_CONDITIONAL(FLaC__HAS_XMMS, false) + + dnl build FLAC++ or not + AC_ARG_ENABLE([cpplibs], diff --git a/toolchains/openpandora/packages/freetype/build.sh b/toolchains/openpandora/packages/freetype/build.sh new file mode 100755 index 0000000..85e2f7b --- /dev/null +++ b/toolchains/openpandora/packages/freetype/build.sh @@ -0,0 +1,31 @@ +#! /bin/sh + +# OpenPandora firmware uses freetype 2.3.9 stick with it +FREETYPE_VERSION=2.3.9 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +# GPG key of Werner Lemberg +gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 0xC1A60EACE707FDA5 +do_http_fetch freetype "http://download.savannah.gnu.org/releases/freetype/freetype-old/freetype-${FREETYPE_VERSION}.tar.bz2" \ + 'tar xjf' "gpgurl:http://download.savannah.gnu.org/releases/freetype/freetype-old/freetype-${FREETYPE_VERSION}.tar.bz2.sig" +rm -Rf $HOME/.gnupg + +# As in original toolchain, create a UNIX specific configure script and don't use zlib +# Script is not executable, call shell +# mmap test fails because we are cross-compiling but toolchain has it so force enable +/bin/sh ./autogen.sh + +# We must export because sh keeps local to functions the variables assignments put in front of them +export ac_cv_func_mmap_fixed_mapped=yes +do_configure_shared --without-zlib +unset ac_cv_func_mmap_fixed_mapped + +do_make +do_make install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/gnutls/build.sh b/toolchains/openpandora/packages/gnutls/build.sh new file mode 100755 index 0000000..2b639d4 --- /dev/null +++ b/toolchains/openpandora/packages/gnutls/build.sh @@ -0,0 +1,78 @@ +#! /bin/sh + +# OpenPandora firmware uses : +# - libgpg-error 1.4 +# - libgcrypt 1.4.1 +# - GnuTLS 2.8.5 +# stick with them + +LIBGPG_ERROR_VERSION=1.4 +LIBGPG_ERROR_SHA256=5f71a3f7da2d0b5ea241186848e33e36714952d40d75d98278c4f184b79915f4 + +LIBGCRYPT_VERSION=1.4.1 +LIBGCRYPT_SHA256=fe3b32bdf0c92d6b3bb7b3e4b3c19a6a899a9deb65f1b36f0a5882d308c91fa3 + +GNUTLS_VERSION=2.8.5 +GNUTLS_SHA256=9249c29df71551e302e0186f4e1876dd6cc4c6cf2974b432c22525dde815cae8 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch libgpg-error "http://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-${LIBGPG_ERROR_VERSION}.tar.bz2" \ + 'tar xjf' "sha256:${LIBGPG_ERROR_SHA256}" + +# Fix GCC preprocessor without a patch to avoid hacks +sed -ie 's/_\$@ | grep GPG_ERR_ |/-P \0/' src/Makefile.in + +# Enable shared objects to make binary lighter +do_configure_shared +do_make + +do_make -C src install-libLTLIBRARIES \ + install-binSCRIPTS \ + install-includeHEADERS \ + install-m4dataDATA + +cd .. + +do_http_fetch libgcrypt "http://gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-${LIBGCRYPT_VERSION}.tar.bz2" \ + 'tar xjf' "sha256:${LIBGCRYPT_SHA256}" + +# Fix inline with recent GCCs without a patch to avoid hacks (5abc06114e91beca0177331e1c79815f5fb6d7be) +sed -ie 's/^\(#define G10_MPI_INLINE_DECL.*\) __inline__/\1 inline __attribute__ ((__gnu_inline__))/' mpi/mpi-inline.h + +# Disable tests, they don't even build... +sed -ie 's/^\(SUBDIRS.*\) doc tests/\1/' Makefile.in + +# Enable shared objects to make binary lighter +do_configure_shared --without-pth --disable-asm +do_make + +do_make -C src install-libLTLIBRARIES \ + install-binSCRIPTS \ + install-includeHEADERS \ + install-m4dataDATA + +cd .. + +do_http_fetch gnutls "http://ftp.gnu.org/gnu/gnutls/gnutls-${GNUTLS_VERSION}.tar.bz2" \ + 'tar xjf' "sha256:${GNUTLS_SHA256}" + +patch -t -p1 < $PACKAGE_DIR/gnutls-openssl.patch + +# Disable programs, doc and tests they don't even build... +sed -ie 's/^\(SUBDIRS.*\) src doc tests/\1/' Makefile.in + +# Disable po +sed -ie 's/^\(SUBDIRS.*\) po/\1/' lib/Makefile.in + +# Enable shared objects to make binary lighter +do_configure_shared --with-included-opencdk --with-included-libtasn1 +do_make + +do_make install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/gnutls/gnutls-openssl.patch b/toolchains/openpandora/packages/gnutls/gnutls-openssl.patch new file mode 100644 index 0000000..596bd01 --- /dev/null +++ b/toolchains/openpandora/packages/gnutls/gnutls-openssl.patch @@ -0,0 +1,149 @@ +--- + libextra/gnutls_openssl.c | 58 +++++++++++++++++++++++++++++++++++++ + libextra/includes/gnutls/openssl.h | 5 +++ + 2 files changed, 63 insertions(+) + +--- gnutls-2.8.5.orig/libextra/gnutls_openssl.c ++++ gnutls-2.8.5/libextra/gnutls_openssl.c +@@ -256,16 +256,21 @@ SSL_new (SSL_CTX * ctx) + ssl->options = ctx->options; + + ssl->rfd = (gnutls_transport_ptr_t) - 1; + ssl->wfd = (gnutls_transport_ptr_t) - 1; + ++ ssl->ssl_peek_buffer = NULL; ++ ssl->ssl_peek_buffer_size = ssl->ssl_peek_avail = 0; ++ + return ssl; + } + + void + SSL_free (SSL * ssl) + { ++ if (ssl->ssl_peek_buffer) ++ free(ssl->ssl_peek_buffer); + gnutls_certificate_free_credentials (ssl->gnutls_cred); + gnutls_deinit (ssl->gnutls_state); + free (ssl); + } + +@@ -285,10 +290,11 @@ SSL_get_error (SSL * ssl, int ret) + + int + SSL_set_fd (SSL * ssl, int fd) + { + gnutls_transport_set_ptr (ssl->gnutls_state, GNUTLS_INT_TO_POINTER (fd)); ++ ssl->rfd = ssl->wfd = fd; + return 1; + } + + int + SSL_set_rfd (SSL * ssl, int fd) +@@ -310,10 +316,21 @@ SSL_set_wfd (SSL * ssl, int fd) + gnutls_transport_set_ptr2 (ssl->gnutls_state, ssl->rfd, ssl->wfd); + + return 1; + } + ++int SSL_get_rfd(SSL *ssl) ++{ ++ return ssl->rfd; ++} ++ ++int SSL_get_wfd(SSL *ssl) ++{ ++ return ssl->wfd; ++} ++ ++ + void + SSL_set_bio (SSL * ssl, BIO * rbio, BIO * wbio) + { + gnutls_transport_set_ptr2 (ssl->gnutls_state, rbio->fd, wbio->fd); + /* free(BIO); ? */ +@@ -325,10 +342,12 @@ SSL_set_connect_state (SSL * ssl) + } + + int + SSL_pending (SSL * ssl) + { ++ if (ssl->ssl_peek_avail) ++ return ssl->ssl_peek_avail; + return gnutls_record_check_pending (ssl->gnutls_state); + } + + void + SSL_set_verify (SSL * ssl, int verify_mode, +@@ -480,15 +499,54 @@ SSL_shutdown (SSL * ssl) + + /* FIXME */ + return 1; + } + ++int SSL_peek(SSL *ssl, void *buf, int len) ++{ ++ if (len > ssl->ssl_peek_buffer_size) { ++ ssl->ssl_peek_buffer = realloc (ssl->ssl_peek_buffer, len); ++ ssl->ssl_peek_buffer_size = len; ++ } ++ ++ if (ssl->ssl_peek_avail == 0) { ++ ++ int ret; ++ ++ ret = gnutls_record_recv(ssl->gnutls_state, ssl->ssl_peek_buffer, len); ++ ssl->last_error = ret; ++ ++ if (ret > 0) ++ ssl->ssl_peek_avail += ret; ++ } ++ ++ if (len > ssl->ssl_peek_avail) ++ len = ssl->ssl_peek_avail; ++ ++ memcpy (buf, ssl->ssl_peek_buffer, len); ++ ++ return len; ++} ++ + int + SSL_read (SSL * ssl, void *buf, int len) + { + int ret; + ++ if (ssl->ssl_peek_avail) { ++ int n = (ssl->ssl_peek_avail > len) ? len : ssl->ssl_peek_avail; ++ ++ memcpy (buf, ssl->ssl_peek_buffer, n); ++ ++ if (ssl->ssl_peek_avail > n) ++ memmove (ssl->ssl_peek_buffer, ssl->ssl_peek_buffer + n, ssl->ssl_peek_avail - n); ++ ++ ssl->ssl_peek_avail -= n; ++ ++ return n; ++ } ++ + ret = gnutls_record_recv (ssl->gnutls_state, buf, len); + ssl->last_error = ret; + + if (ret < 0) + { +--- gnutls-2.8.5.orig/libextra/includes/gnutls/openssl.h ++++ gnutls-2.8.5/libextra/includes/gnutls/openssl.h +@@ -162,10 +162,15 @@ extern "C" + int (*verify_callback) (int, X509_STORE_CTX *); + int verify_mode; + + gnutls_transport_ptr_t rfd; + gnutls_transport_ptr_t wfd; ++ ++ char *ssl_peek_buffer; ++ size_t ssl_peek_buffer_size; ++ size_t ssl_peek_avail; ++ + }; + + #define rbio gnutls_state + + typedef struct { diff --git a/toolchains/openpandora/packages/libjpeg/build.sh b/toolchains/openpandora/packages/libjpeg/build.sh new file mode 100755 index 0000000..650e1bb --- /dev/null +++ b/toolchains/openpandora/packages/libjpeg/build.sh @@ -0,0 +1,24 @@ +#! /bin/sh + +# OpenPandora firmware uses jpeg 6b stick with it +JPEG_VERSION=6b +JPEG_SHA256=75c3ec241e9996504fe02a9ed4d12f16b74ade713972f3db9e65ce95cd27e35d + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch jpeg "http://www.ijg.org/files/jpegsrc.v${JPEG_VERSION}.tar.gz" 'tar xzf' "sha256:${JPEG_SHA256}" + +# Replace outdated config.* manually as there is no autogen.sh nor autoconf script +cp /usr/share/misc/config.guess /usr/share/misc/config.sub . + +do_configure_shared +do_make + +# Don't install binaries and doc +do_make install-lib + +do_clean_bdir diff --git a/toolchains/openpandora/packages/libjpeg/patches/debian.patch b/toolchains/openpandora/packages/libjpeg/patches/debian.patch new file mode 100644 index 0000000..a169ad1 --- /dev/null +++ b/toolchains/openpandora/packages/libjpeg/patches/debian.patch @@ -0,0 +1,1874 @@ +--- jpeg-6b/jpegtran.1~libjpeg6bb-5 ++++ jpeg-6b/jpegtran.1 +@@ -131,6 +131,24 @@ + .B \-rot 180 -trim + trims both edges. + .PP ++We also offer a lossless-crop option, which discards data outside a given ++image region but losslessly preserves what is inside. Like the rotate and ++flip transforms, lossless crop is restricted by the JPEG format: the upper ++left corner of the selected region must fall on an iMCU boundary. If this ++does not hold for the given crop parameters, we silently move the upper left ++corner up and/or left to make it so, simultaneously increasing the region ++dimensions to keep the lower right crop corner unchanged. (Thus, the ++output image covers at least the requested region, but may cover more.) ++ ++Note: lossless-crop is an enhancement from http://sylvana.net/jpegcrop/ ++that may not be available on non-Debian systems. ++ ++The image can be losslessly cropped by giving the switch: ++.TP ++.B \-crop WxH+X+Y ++Crop to a rectangular subarea of width W, height H starting at point X,Y. ++.PP ++.PP + Another not-strictly-lossless transformation switch is: + .TP + .B \-grayscale +--- jpeg-6b/configure~libjpeg6bb-5 ++++ jpeg-6b/configure +@@ -52,7 +52,7 @@ + includedir='${prefix}/include' + oldincludedir='/usr/include' + infodir='${prefix}/info' +-mandir='${prefix}/man' ++mandir='${prefix}/share/man' + + # Initialize some other variables. + subdirs= +--- jpeg-6b/makefile.cfg~libjpeg6bb-5 ++++ jpeg-6b/makefile.cfg +@@ -17,7 +17,7 @@ + binprefix = + manprefix = + manext = 1 +-mandir = $(prefix)/man/man$(manext) ++mandir = $(prefix)/share/man/man$(manext) + + # The name of your C compiler: + CC= @CC@ +@@ -210,6 +210,11 @@ + $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h + $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h + $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h ++#:mjpegtools require this file to build and header say: ++# * These declarations are considered internal to the JPEG library; most ++# * applications using the library shouldn't need to include this file. ++# So it is not forbidden to use it, therefore it must be installed. ++ $(INSTALL_DATA) $(srcdir)/jpegint.h $(includedir)/jpegint.h + + clean: + $(RM) *.o *.lo libjpeg.a libjpeg.la +--- jpeg-6b/jpegtran.c~libjpeg6bb-5 ++++ jpeg-6b/jpegtran.c +@@ -1,7 +1,7 @@ + /* + * jpegtran.c + * +- * Copyright (C) 1995-1997, Thomas G. Lane. ++ * Copyright (C) 1995-2001, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * +@@ -64,6 +64,7 @@ + #endif + #if TRANSFORMS_SUPPORTED + fprintf(stderr, "Switches for modifying the image:\n"); ++ fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n"); + fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); + fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); + fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); +@@ -134,6 +135,7 @@ + transformoption.transform = JXFORM_NONE; + transformoption.trim = FALSE; + transformoption.force_grayscale = FALSE; ++ transformoption.crop = FALSE; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ +@@ -160,7 +162,7 @@ + exit(EXIT_FAILURE); + #endif + +- } else if (keymatch(arg, "copy", 1)) { ++ } else if (keymatch(arg, "copy", 2)) { + /* Select which extra markers to copy. */ + if (++argn >= argc) /* advance to next argument */ + usage(); +@@ -173,6 +175,20 @@ + } else + usage(); + ++ } else if (keymatch(arg, "crop", 2)) { ++ /* Perform lossless cropping. */ ++#if TRANSFORMS_SUPPORTED ++ if (++argn >= argc) /* advance to next argument */ ++ usage(); ++ if (! jtransform_parse_crop_spec(&transformoption, argv[argn])) { ++ fprintf(stderr, "%s: bogus -crop argument '%s'\n", ++ progname, argv[argn]); ++ exit(EXIT_FAILURE); ++ } ++#else ++ select_transform(JXFORM_NONE); /* force an error */ ++#endif ++ + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ +@@ -342,8 +358,10 @@ + jvirt_barray_ptr * src_coef_arrays; + jvirt_barray_ptr * dst_coef_arrays; + int file_index; +- FILE * input_file; +- FILE * output_file; ++ /* We assume all-in-memory processing and can therefore use only a ++ * single file pointer for sequential input and output operation. ++ */ ++ FILE * fp; + + /* On Mac, fetch a command line. */ + #ifdef USE_CCOMMAND +@@ -406,24 +424,13 @@ + + /* Open the input file. */ + if (file_index < argc) { +- if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { ++ if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ +- input_file = read_stdin(); +- } +- +- /* Open the output file. */ +- if (outfilename != NULL) { +- if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { +- fprintf(stderr, "%s: can't open %s\n", progname, outfilename); +- exit(EXIT_FAILURE); +- } +- } else { +- /* default output file is stdout */ +- output_file = write_stdout(); ++ fp = read_stdin(); + } + + #ifdef PROGRESS_REPORT +@@ -431,7 +438,7 @@ + #endif + + /* Specify data source for decompression */ +- jpeg_stdio_src(&srcinfo, input_file); ++ jpeg_stdio_src(&srcinfo, fp); + + /* Enable saving of extra markers that we want to copy */ + jcopy_markers_setup(&srcinfo, copyoption); +@@ -463,11 +470,32 @@ + dst_coef_arrays = src_coef_arrays; + #endif + ++ /* Close input file, if we opened it. ++ * Note: we assume that jpeg_read_coefficients consumed all input ++ * until JPEG_REACHED_EOI, and that jpeg_finish_decompress will ++ * only consume more while (! cinfo->inputctl->eoi_reached). ++ * We cannot call jpeg_finish_decompress here since we still need the ++ * virtual arrays allocated from the source object for processing. ++ */ ++ if (fp != stdin) ++ fclose(fp); ++ ++ /* Open the output file. */ ++ if (outfilename != NULL) { ++ if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) { ++ fprintf(stderr, "%s: can't open %s\n", progname, outfilename); ++ exit(EXIT_FAILURE); ++ } ++ } else { ++ /* default output file is stdout */ ++ fp = write_stdout(); ++ } ++ + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); + + /* Specify data destination for compression */ +- jpeg_stdio_dest(&dstinfo, output_file); ++ jpeg_stdio_dest(&dstinfo, fp); + + /* Start compressor (note no image data is actually written here) */ + jpeg_write_coefficients(&dstinfo, dst_coef_arrays); +@@ -488,11 +516,9 @@ + (void) jpeg_finish_decompress(&srcinfo); + jpeg_destroy_decompress(&srcinfo); + +- /* Close files, if we opened them */ +- if (input_file != stdin) +- fclose(input_file); +- if (output_file != stdout) +- fclose(output_file); ++ /* Close output file, if we opened it */ ++ if (fp != stdout) ++ fclose(fp); + + #ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &dstinfo); +--- jpeg-6b/rdjpgcom.c~libjpeg6bb-5 ++++ jpeg-6b/rdjpgcom.c +@@ -14,6 +14,7 @@ + #define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ + #include "jinclude.h" /* get auto-config symbols, */ + ++#include /*ballombe@debian.org: use locale for isprint*/ + #include /* to declare isupper(), tolower() */ + #ifdef USE_SETMODE + #include /* to declare setmode()'s parameter macros */ +@@ -223,7 +224,10 @@ + unsigned int length; + int ch; + int lastch = 0; +- ++/* ballombe@debian.org Thu, 15 Nov 2001 20:04:47 +0100*/ ++/* Set locale properly for isprint*/ ++ setlocale(LC_CTYPE,""); ++ + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ +@@ -254,6 +258,8 @@ + length--; + } + printf("\n"); ++/*ballombe@debian.org: revert to C locale*/ ++ setlocale(LC_CTYPE,"C"); + } + + +--- jpeg-6b/transupp.c~libjpeg6bb-5 ++++ jpeg-6b/transupp.c +@@ -1,7 +1,7 @@ + /* + * transupp.c + * +- * Copyright (C) 1997, Thomas G. Lane. ++ * Copyright (C) 1997-2001, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * +@@ -20,6 +20,7 @@ + #include "jinclude.h" + #include "jpeglib.h" + #include "transupp.h" /* My own external interface */ ++#include /* to declare isdigit() */ + + + #if TRANSFORMS_SUPPORTED +@@ -28,7 +29,8 @@ + * Lossless image transformation routines. These routines work on DCT + * coefficient arrays and thus do not require any lossy decompression + * or recompression of the image. +- * Thanks to Guido Vollbeding for the initial design and code of this feature. ++ * Thanks to Guido Vollbeding for the initial design and code of this feature, ++ * and to Ben Jackson for introducing the cropping feature. + * + * Horizontal flipping is done in-place, using a single top-to-bottom + * pass through the virtual source array. It will thus be much the +@@ -42,6 +44,13 @@ + * arrays for most of the transforms. That could result in much thrashing + * if the image is larger than main memory. + * ++ * If cropping or trimming is involved, the destination arrays may be smaller ++ * than the source arrays. Note it is not possible to do horizontal flip ++ * in-place when a nonzero Y crop offset is specified, since we'd have to move ++ * data from one block row to another but the virtual array manager doesn't ++ * guarantee we can touch more than one row at a time. So in that case, ++ * we have to use a separate destination array. ++ * + * Some notes about the operating environment of the individual transform + * routines: + * 1. Both the source and destination virtual arrays are allocated from the +@@ -54,20 +63,65 @@ + * and we may as well take that as the effective iMCU size. + * 4. When "trim" is in effect, the destination's dimensions will be the + * trimmed values but the source's will be untrimmed. +- * 5. All the routines assume that the source and destination buffers are ++ * 5. When "crop" is in effect, the destination's dimensions will be the ++ * cropped values but the source's will be uncropped. Each transform ++ * routine is responsible for picking up source data starting at the ++ * correct X and Y offset for the crop region. (The X and Y offsets ++ * passed to the transform routines are measured in iMCU blocks of the ++ * destination.) ++ * 6. All the routines assume that the source and destination buffers are + * padded out to a full iMCU boundary. This is true, although for the + * source buffer it is an undocumented property of jdcoefct.c. +- * Notes 2,3,4 boil down to this: generally we should use the destination's +- * dimensions and ignore the source's. + */ + + + LOCAL(void) +-do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, +- jvirt_barray_ptr *src_coef_arrays) +-/* Horizontal flip; done in-place, so no separate dest array is required */ ++do_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, ++ jvirt_barray_ptr *src_coef_arrays, ++ jvirt_barray_ptr *dst_coef_arrays) ++/* Crop. This is only used when no rotate/flip is requested with the crop. */ + { +- JDIMENSION MCU_cols, comp_width, blk_x, blk_y; ++ JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks; ++ int ci, offset_y; ++ JBLOCKARRAY src_buffer, dst_buffer; ++ jpeg_component_info *compptr; ++ ++ /* We simply have to copy the right amount of data (the destination's ++ * image size) starting at the given X and Y offsets in the source. ++ */ ++ for (ci = 0; ci < dstinfo->num_components; ci++) { ++ compptr = dstinfo->comp_info + ci; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; ++ y_crop_blocks = y_crop_offset * compptr->v_samp_factor; ++ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; ++ dst_blk_y += compptr->v_samp_factor) { ++ dst_buffer = (*srcinfo->mem->access_virt_barray) ++ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, ++ (JDIMENSION) compptr->v_samp_factor, TRUE); ++ src_buffer = (*srcinfo->mem->access_virt_barray) ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ dst_blk_y + y_crop_blocks, ++ (JDIMENSION) compptr->v_samp_factor, FALSE); ++ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { ++ jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, ++ dst_buffer[offset_y], ++ compptr->width_in_blocks); ++ } ++ } ++ } ++} ++ ++ ++LOCAL(void) ++do_flip_h_no_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, ++ jvirt_barray_ptr *src_coef_arrays) ++/* Horizontal flip; done in-place, so no separate dest array is required. ++ * NB: this only works when y_crop_offset is zero. ++ */ ++{ ++ JDIMENSION MCU_cols, comp_width, blk_x, blk_y, x_crop_blocks; + int ci, k, offset_y; + JBLOCKARRAY buffer; + JCOEFPTR ptr1, ptr2; +@@ -79,17 +133,19 @@ + * mirroring by changing the signs of odd-numbered columns. + * Partial iMCUs at the right edge are left untouched. + */ +- MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); ++ MCU_cols = srcinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + for (blk_y = 0; blk_y < compptr->height_in_blocks; + blk_y += compptr->v_samp_factor) { + buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { ++ /* Do the mirroring */ + for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { + ptr1 = buffer[offset_y][blk_x]; + ptr2 = buffer[offset_y][comp_width - blk_x - 1]; +@@ -105,6 +161,79 @@ + *ptr2++ = -temp1; + } + } ++ if (x_crop_blocks > 0) { ++ /* Now left-justify the portion of the data to be kept. ++ * We can't use a single jcopy_block_row() call because that routine ++ * depends on memcpy(), whose behavior is unspecified for overlapping ++ * source and destination areas. Sigh. ++ */ ++ for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) { ++ jcopy_block_row(buffer[offset_y] + blk_x + x_crop_blocks, ++ buffer[offset_y] + blk_x, ++ (JDIMENSION) 1); ++ } ++ } ++ } ++ } ++ } ++} ++ ++ ++LOCAL(void) ++do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, ++ jvirt_barray_ptr *src_coef_arrays, ++ jvirt_barray_ptr *dst_coef_arrays) ++/* Horizontal flip in general cropping case */ ++{ ++ JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; ++ JDIMENSION x_crop_blocks, y_crop_blocks; ++ int ci, k, offset_y; ++ JBLOCKARRAY src_buffer, dst_buffer; ++ JBLOCKROW src_row_ptr, dst_row_ptr; ++ JCOEFPTR src_ptr, dst_ptr; ++ jpeg_component_info *compptr; ++ ++ /* Here we must output into a separate array because we can't touch ++ * different rows of a single virtual array simultaneously. Otherwise, ++ * this is essentially the same as the routine above. ++ */ ++ MCU_cols = srcinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); ++ ++ for (ci = 0; ci < dstinfo->num_components; ci++) { ++ compptr = dstinfo->comp_info + ci; ++ comp_width = MCU_cols * compptr->h_samp_factor; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; ++ y_crop_blocks = y_crop_offset * compptr->v_samp_factor; ++ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; ++ dst_blk_y += compptr->v_samp_factor) { ++ dst_buffer = (*srcinfo->mem->access_virt_barray) ++ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, ++ (JDIMENSION) compptr->v_samp_factor, TRUE); ++ src_buffer = (*srcinfo->mem->access_virt_barray) ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ dst_blk_y + y_crop_blocks, ++ (JDIMENSION) compptr->v_samp_factor, FALSE); ++ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { ++ dst_row_ptr = dst_buffer[offset_y]; ++ src_row_ptr = src_buffer[offset_y]; ++ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { ++ if (x_crop_blocks + dst_blk_x < comp_width) { ++ /* Do the mirrorable blocks */ ++ dst_ptr = dst_row_ptr[dst_blk_x]; ++ src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; ++ /* this unrolled loop doesn't need to know which row it's on... */ ++ for (k = 0; k < DCTSIZE2; k += 2) { ++ *dst_ptr++ = *src_ptr++; /* copy even column */ ++ *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ ++ } ++ } else { ++ /* Copy last partial block(s) verbatim */ ++ jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, ++ dst_row_ptr + dst_blk_x, ++ (JDIMENSION) 1); ++ } ++ } + } + } + } +@@ -113,11 +242,13 @@ + + LOCAL(void) + do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) + /* Vertical flip */ + { + JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; ++ JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; +@@ -131,33 +262,38 @@ + * of odd-numbered rows. + * Partial iMCUs at the bottom edge are copied verbatim. + */ +- MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); ++ MCU_rows = srcinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_height = MCU_rows * compptr->v_samp_factor; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; ++ y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); +- if (dst_blk_y < comp_height) { ++ if (y_crop_blocks + dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], +- comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, ++ comp_height - y_crop_blocks - dst_blk_y - ++ (JDIMENSION) compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + /* Bottom-edge blocks will be copied verbatim. */ + src_buffer = (*srcinfo->mem->access_virt_barray) +- ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { +- if (dst_blk_y < comp_height) { ++ if (y_crop_blocks + dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ + dst_row_ptr = dst_buffer[offset_y]; + src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; ++ src_row_ptr += x_crop_blocks; + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; +@@ -173,7 +309,8 @@ + } + } else { + /* Just copy row verbatim. */ +- jcopy_block_row(src_buffer[offset_y], dst_buffer[offset_y], ++ jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, ++ dst_buffer[offset_y], + compptr->width_in_blocks); + } + } +@@ -184,11 +321,12 @@ + + LOCAL(void) + do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) + /* Transpose source into destination */ + { +- JDIMENSION dst_blk_x, dst_blk_y; ++ JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; +@@ -201,6 +339,8 @@ + */ + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; ++ y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) +@@ -210,11 +350,12 @@ + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + src_buffer = (*srcinfo->mem->access_virt_barray) +- ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ dst_blk_x + x_crop_blocks, + (JDIMENSION) compptr->h_samp_factor, FALSE); + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { +- src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; ++ src_ptr = src_buffer[offset_x][dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -228,6 +369,7 @@ + + LOCAL(void) + do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) + /* 90 degree rotation is equivalent to +@@ -237,6 +379,7 @@ + */ + { + JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; ++ JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; +@@ -246,11 +389,13 @@ + * at the (output) right edge properly. They just get transposed and + * not mirrored. + */ +- MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); ++ MCU_cols = srcinfo->image_height / (dstinfo->max_h_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; ++ y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) +@@ -259,15 +404,26 @@ + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { +- src_buffer = (*srcinfo->mem->access_virt_barray) +- ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, +- (JDIMENSION) compptr->h_samp_factor, FALSE); ++ if (x_crop_blocks + dst_blk_x < comp_width) { ++ /* Block is within the mirrorable area. */ ++ src_buffer = (*srcinfo->mem->access_virt_barray) ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ comp_width - x_crop_blocks - dst_blk_x - ++ (JDIMENSION) compptr->h_samp_factor, ++ (JDIMENSION) compptr->h_samp_factor, FALSE); ++ } else { ++ /* Edge blocks are transposed but not mirrored. */ ++ src_buffer = (*srcinfo->mem->access_virt_barray) ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ dst_blk_x + x_crop_blocks, ++ (JDIMENSION) compptr->h_samp_factor, FALSE); ++ } + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { +- src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; +- if (dst_blk_x < comp_width) { ++ dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; ++ if (x_crop_blocks + dst_blk_x < comp_width) { + /* Block is within the mirrorable area. */ +- dst_ptr = dst_buffer[offset_y] +- [comp_width - dst_blk_x - offset_x - 1]; ++ src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] ++ [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -277,7 +433,8 @@ + } + } else { + /* Edge blocks are transposed but not mirrored. */ +- dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; ++ src_ptr = src_buffer[offset_x] ++ [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -292,6 +449,7 @@ + + LOCAL(void) + do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) + /* 270 degree rotation is equivalent to +@@ -301,6 +459,7 @@ + */ + { + JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; ++ JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; +@@ -310,11 +469,13 @@ + * at the (output) bottom edge properly. They just get transposed and + * not mirrored. + */ +- MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); ++ MCU_rows = srcinfo->image_width / (dstinfo->max_v_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_height = MCU_rows * compptr->v_samp_factor; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; ++ y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) +@@ -324,14 +485,15 @@ + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + src_buffer = (*srcinfo->mem->access_virt_barray) +- ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ dst_blk_x + x_crop_blocks, + (JDIMENSION) compptr->h_samp_factor, FALSE); + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; +- if (dst_blk_y < comp_height) { ++ if (y_crop_blocks + dst_blk_y < comp_height) { + /* Block is within the mirrorable area. */ + src_ptr = src_buffer[offset_x] +- [comp_height - dst_blk_y - offset_y - 1]; ++ [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -341,7 +503,8 @@ + } + } else { + /* Edge blocks are transposed but not mirrored. */ +- src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; ++ src_ptr = src_buffer[offset_x] ++ [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -356,6 +519,7 @@ + + LOCAL(void) + do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) + /* 180 degree rotation is equivalent to +@@ -365,89 +529,93 @@ + */ + { + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; ++ JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + +- MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); +- MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); ++ MCU_cols = srcinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); ++ MCU_rows = srcinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; ++ y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); +- if (dst_blk_y < comp_height) { ++ if (y_crop_blocks + dst_blk_y < comp_height) { + /* Row is within the vertically mirrorable area. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], +- comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, ++ comp_height - y_crop_blocks - dst_blk_y - ++ (JDIMENSION) compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + /* Bottom-edge rows are only mirrored horizontally. */ + src_buffer = (*srcinfo->mem->access_virt_barray) +- ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { +- if (dst_blk_y < comp_height) { ++ dst_row_ptr = dst_buffer[offset_y]; ++ if (y_crop_blocks + dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ +- dst_row_ptr = dst_buffer[offset_y]; + src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; +- /* Process the blocks that can be mirrored both ways. */ +- for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { ++ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; +- src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; +- for (i = 0; i < DCTSIZE; i += 2) { +- /* For even row, negate every odd column. */ +- for (j = 0; j < DCTSIZE; j += 2) { +- *dst_ptr++ = *src_ptr++; +- *dst_ptr++ = - *src_ptr++; ++ if (x_crop_blocks + dst_blk_x < comp_width) { ++ /* Process the blocks that can be mirrored both ways. */ ++ src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; ++ for (i = 0; i < DCTSIZE; i += 2) { ++ /* For even row, negate every odd column. */ ++ for (j = 0; j < DCTSIZE; j += 2) { ++ *dst_ptr++ = *src_ptr++; ++ *dst_ptr++ = - *src_ptr++; ++ } ++ /* For odd row, negate every even column. */ ++ for (j = 0; j < DCTSIZE; j += 2) { ++ *dst_ptr++ = - *src_ptr++; ++ *dst_ptr++ = *src_ptr++; ++ } + } +- /* For odd row, negate every even column. */ +- for (j = 0; j < DCTSIZE; j += 2) { +- *dst_ptr++ = - *src_ptr++; +- *dst_ptr++ = *src_ptr++; ++ } else { ++ /* Any remaining right-edge blocks are only mirrored vertically. */ ++ src_ptr = src_row_ptr[x_crop_blocks + dst_blk_x]; ++ for (i = 0; i < DCTSIZE; i += 2) { ++ for (j = 0; j < DCTSIZE; j++) ++ *dst_ptr++ = *src_ptr++; ++ for (j = 0; j < DCTSIZE; j++) ++ *dst_ptr++ = - *src_ptr++; + } + } + } +- /* Any remaining right-edge blocks are only mirrored vertically. */ +- for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { +- dst_ptr = dst_row_ptr[dst_blk_x]; +- src_ptr = src_row_ptr[dst_blk_x]; +- for (i = 0; i < DCTSIZE; i += 2) { +- for (j = 0; j < DCTSIZE; j++) +- *dst_ptr++ = *src_ptr++; +- for (j = 0; j < DCTSIZE; j++) +- *dst_ptr++ = - *src_ptr++; +- } +- } + } else { + /* Remaining rows are just mirrored horizontally. */ +- dst_row_ptr = dst_buffer[offset_y]; + src_row_ptr = src_buffer[offset_y]; +- /* Process the blocks that can be mirrored. */ +- for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { +- dst_ptr = dst_row_ptr[dst_blk_x]; +- src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; +- for (i = 0; i < DCTSIZE2; i += 2) { +- *dst_ptr++ = *src_ptr++; +- *dst_ptr++ = - *src_ptr++; ++ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { ++ if (x_crop_blocks + dst_blk_x < comp_width) { ++ /* Process the blocks that can be mirrored. */ ++ dst_ptr = dst_row_ptr[dst_blk_x]; ++ src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; ++ for (i = 0; i < DCTSIZE2; i += 2) { ++ *dst_ptr++ = *src_ptr++; ++ *dst_ptr++ = - *src_ptr++; ++ } ++ } else { ++ /* Any remaining right-edge blocks are only copied. */ ++ jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, ++ dst_row_ptr + dst_blk_x, ++ (JDIMENSION) 1); + } + } +- /* Any remaining right-edge blocks are only copied. */ +- for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { +- dst_ptr = dst_row_ptr[dst_blk_x]; +- src_ptr = src_row_ptr[dst_blk_x]; +- for (i = 0; i < DCTSIZE2; i++) +- *dst_ptr++ = *src_ptr++; +- } + } + } + } +@@ -457,6 +625,7 @@ + + LOCAL(void) + do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, ++ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) + /* Transverse transpose is equivalent to +@@ -470,18 +639,21 @@ + */ + { + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; ++ JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + +- MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); +- MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); ++ MCU_cols = srcinfo->image_height / (dstinfo->max_h_samp_factor * DCTSIZE); ++ MCU_rows = srcinfo->image_width / (dstinfo->max_v_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; ++ x_crop_blocks = x_crop_offset * compptr->h_samp_factor; ++ y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) +@@ -490,17 +662,26 @@ + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { +- src_buffer = (*srcinfo->mem->access_virt_barray) +- ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, +- (JDIMENSION) compptr->h_samp_factor, FALSE); ++ if (x_crop_blocks + dst_blk_x < comp_width) { ++ /* Block is within the mirrorable area. */ ++ src_buffer = (*srcinfo->mem->access_virt_barray) ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ comp_width - x_crop_blocks - dst_blk_x - ++ (JDIMENSION) compptr->h_samp_factor, ++ (JDIMENSION) compptr->h_samp_factor, FALSE); ++ } else { ++ src_buffer = (*srcinfo->mem->access_virt_barray) ++ ((j_common_ptr) srcinfo, src_coef_arrays[ci], ++ dst_blk_x + x_crop_blocks, ++ (JDIMENSION) compptr->h_samp_factor, FALSE); ++ } + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { +- if (dst_blk_y < comp_height) { +- src_ptr = src_buffer[offset_x] +- [comp_height - dst_blk_y - offset_y - 1]; +- if (dst_blk_x < comp_width) { ++ dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; ++ if (y_crop_blocks + dst_blk_y < comp_height) { ++ if (x_crop_blocks + dst_blk_x < comp_width) { + /* Block is within the mirrorable area. */ +- dst_ptr = dst_buffer[offset_y] +- [comp_width - dst_blk_x - offset_x - 1]; ++ src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] ++ [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -516,7 +697,8 @@ + } + } else { + /* Right-edge blocks are mirrored in y only */ +- dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; ++ src_ptr = src_buffer[offset_x] ++ [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -526,11 +708,10 @@ + } + } + } else { +- src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; +- if (dst_blk_x < comp_width) { ++ if (x_crop_blocks + dst_blk_x < comp_width) { + /* Bottom-edge blocks are mirrored in x only */ +- dst_ptr = dst_buffer[offset_y] +- [comp_width - dst_blk_x - offset_x - 1]; ++ src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] ++ [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -540,7 +721,8 @@ + } + } else { + /* At lower right corner, just transpose, no mirroring */ +- dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; ++ src_ptr = src_buffer[offset_x] ++ [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; +@@ -554,8 +736,116 @@ + } + + ++/* Parse an unsigned integer: subroutine for jtransform_parse_crop_spec. ++ * Returns TRUE if valid integer found, FALSE if not. ++ * *strptr is advanced over the digit string, and *result is set to its value. ++ */ ++ ++LOCAL(boolean) ++jt_read_integer (const char ** strptr, JDIMENSION * result) ++{ ++ const char * ptr = *strptr; ++ JDIMENSION val = 0; ++ ++ for (; isdigit(*ptr); ptr++) { ++ val = val * 10 + (JDIMENSION) (*ptr - '0'); ++ } ++ *result = val; ++ if (ptr == *strptr) ++ return FALSE; /* oops, no digits */ ++ *strptr = ptr; ++ return TRUE; ++} ++ ++ ++/* Parse a crop specification (written in X11 geometry style). ++ * The routine returns TRUE if the spec string is valid, FALSE if not. ++ * ++ * The crop spec string should have the format ++ * x{+-}{+-} ++ * where width, height, xoffset, and yoffset are unsigned integers. ++ * Each of the elements can be omitted to indicate a default value. ++ * (A weakness of this style is that it is not possible to omit xoffset ++ * while specifying yoffset, since they look alike.) ++ * ++ * This code is loosely based on XParseGeometry from the X11 distribution. ++ */ ++ ++GLOBAL(boolean) ++jtransform_parse_crop_spec (jpeg_transform_info *info, const char *spec) ++{ ++ info->crop = FALSE; ++ info->crop_width_set = JCROP_UNSET; ++ info->crop_height_set = JCROP_UNSET; ++ info->crop_xoffset_set = JCROP_UNSET; ++ info->crop_yoffset_set = JCROP_UNSET; ++ ++ if (isdigit(*spec)) { ++ /* fetch width */ ++ if (! jt_read_integer(&spec, &info->crop_width)) ++ return FALSE; ++ info->crop_width_set = JCROP_POS; ++ } ++ if (*spec == 'x' || *spec == 'X') { ++ /* fetch height */ ++ spec++; ++ if (! jt_read_integer(&spec, &info->crop_height)) ++ return FALSE; ++ info->crop_height_set = JCROP_POS; ++ } ++ if (*spec == '+' || *spec == '-') { ++ /* fetch xoffset */ ++ info->crop_xoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS; ++ spec++; ++ if (! jt_read_integer(&spec, &info->crop_xoffset)) ++ return FALSE; ++ } ++ if (*spec == '+' || *spec == '-') { ++ /* fetch yoffset */ ++ info->crop_yoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS; ++ spec++; ++ if (! jt_read_integer(&spec, &info->crop_yoffset)) ++ return FALSE; ++ } ++ /* We had better have gotten to the end of the string. */ ++ if (*spec != '\0') ++ return FALSE; ++ info->crop = TRUE; ++ return TRUE; ++} ++ ++ ++/* Trim off any partial iMCUs on the indicated destination edge */ ++ ++LOCAL(void) ++trim_right_edge (jpeg_transform_info *info, JDIMENSION full_width) ++{ ++ JDIMENSION MCU_cols; ++ ++ MCU_cols = info->output_width / (info->max_h_samp_factor * DCTSIZE); ++ if (MCU_cols > 0 && info->x_crop_offset + MCU_cols == ++ full_width / (info->max_h_samp_factor * DCTSIZE)) ++ info->output_width = MCU_cols * (info->max_h_samp_factor * DCTSIZE); ++} ++ ++LOCAL(void) ++trim_bottom_edge (jpeg_transform_info *info, JDIMENSION full_height) ++{ ++ JDIMENSION MCU_rows; ++ ++ MCU_rows = info->output_height / (info->max_v_samp_factor * DCTSIZE); ++ if (MCU_rows > 0 && info->y_crop_offset + MCU_rows == ++ full_height / (info->max_v_samp_factor * DCTSIZE)) ++ info->output_height = MCU_rows * (info->max_v_samp_factor * DCTSIZE); ++} ++ ++ + /* Request any required workspace. + * ++ * This routine figures out the size that the output image will be ++ * (which implies that all the transform parameters must be set before ++ * it is called). ++ * + * We allocate the workspace virtual arrays from the source decompression + * object, so that all the arrays (both the original data and the workspace) + * will be taken into account while making memory management decisions. +@@ -569,9 +859,13 @@ + jpeg_transform_info *info) + { + jvirt_barray_ptr *coef_arrays = NULL; ++ boolean need_workspace, transpose_it; + jpeg_component_info *compptr; +- int ci; ++ JDIMENSION xoffset, yoffset, width_in_iMCUs, height_in_iMCUs; ++ JDIMENSION width_in_blocks, height_in_blocks; ++ int ci, h_samp_factor, v_samp_factor; + ++ /* Determine number of components in output image */ + if (info->force_grayscale && + srcinfo->jpeg_color_space == JCS_YCbCr && + srcinfo->num_components == 3) { +@@ -581,55 +875,181 @@ + /* Process all the components */ + info->num_components = srcinfo->num_components; + } ++ /* If there is only one output component, force the iMCU size to be 1; ++ * else use the source iMCU size. (This allows us to do the right thing ++ * when reducing color to grayscale, and also provides a handy way of ++ * cleaning up "funny" grayscale images whose sampling factors are not 1x1.) ++ */ ++ ++ switch (info->transform) { ++ case JXFORM_TRANSPOSE: ++ case JXFORM_TRANSVERSE: ++ case JXFORM_ROT_90: ++ case JXFORM_ROT_270: ++ info->output_width = srcinfo->image_height; ++ info->output_height = srcinfo->image_width; ++ if (info->num_components == 1) { ++ info->max_h_samp_factor = 1; ++ info->max_v_samp_factor = 1; ++ } else { ++ info->max_h_samp_factor = srcinfo->max_v_samp_factor; ++ info->max_v_samp_factor = srcinfo->max_h_samp_factor; ++ } ++ break; ++ default: ++ info->output_width = srcinfo->image_width; ++ info->output_height = srcinfo->image_height; ++ if (info->num_components == 1) { ++ info->max_h_samp_factor = 1; ++ info->max_v_samp_factor = 1; ++ } else { ++ info->max_h_samp_factor = srcinfo->max_h_samp_factor; ++ info->max_v_samp_factor = srcinfo->max_v_samp_factor; ++ } ++ break; ++ } ++ ++ /* If cropping has been requested, compute the crop area's position and ++ * dimensions, ensuring that its upper left corner falls at an iMCU boundary. ++ */ ++ if (info->crop) { ++ /* Insert default values for unset crop parameters */ ++ if (info->crop_xoffset_set == JCROP_UNSET) ++ info->crop_xoffset = 0; /* default to +0 */ ++ if (info->crop_yoffset_set == JCROP_UNSET) ++ info->crop_yoffset = 0; /* default to +0 */ ++ if (info->crop_xoffset >= info->output_width || ++ info->crop_yoffset >= info->output_height) ++ ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); ++ if (info->crop_width_set == JCROP_UNSET) ++ info->crop_width = info->output_width - info->crop_xoffset; ++ if (info->crop_height_set == JCROP_UNSET) ++ info->crop_height = info->output_height - info->crop_yoffset; ++ /* Ensure parameters are valid */ ++ if (info->crop_width <= 0 || info->crop_width > info->output_width || ++ info->crop_height <= 0 || info->crop_height > info->output_height || ++ info->crop_xoffset > info->output_width - info->crop_width || ++ info->crop_yoffset > info->output_height - info->crop_height) ++ ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); ++ /* Convert negative crop offsets into regular offsets */ ++ if (info->crop_xoffset_set == JCROP_NEG) ++ xoffset = info->output_width - info->crop_width - info->crop_xoffset; ++ else ++ xoffset = info->crop_xoffset; ++ if (info->crop_yoffset_set == JCROP_NEG) ++ yoffset = info->output_height - info->crop_height - info->crop_yoffset; ++ else ++ yoffset = info->crop_yoffset; ++ /* Now adjust so that upper left corner falls at an iMCU boundary */ ++ info->output_width = ++ info->crop_width + (xoffset % (info->max_h_samp_factor * DCTSIZE)); ++ info->output_height = ++ info->crop_height + (yoffset % (info->max_v_samp_factor * DCTSIZE)); ++ /* Save x/y offsets measured in iMCUs */ ++ info->x_crop_offset = xoffset / (info->max_h_samp_factor * DCTSIZE); ++ info->y_crop_offset = yoffset / (info->max_v_samp_factor * DCTSIZE); ++ } else { ++ info->x_crop_offset = 0; ++ info->y_crop_offset = 0; ++ } + ++ /* Figure out whether we need workspace arrays, ++ * and if so whether they are transposed relative to the source. ++ */ ++ need_workspace = FALSE; ++ transpose_it = FALSE; + switch (info->transform) { + case JXFORM_NONE: ++ if (info->x_crop_offset != 0 || info->y_crop_offset != 0) ++ need_workspace = TRUE; ++ /* No workspace needed if neither cropping nor transforming */ ++ break; + case JXFORM_FLIP_H: +- /* Don't need a workspace array */ ++ if (info->trim) ++ trim_right_edge(info, srcinfo->image_width); ++ if (info->y_crop_offset != 0) ++ need_workspace = TRUE; ++ /* do_flip_h_no_crop doesn't need a workspace array */ + break; + case JXFORM_FLIP_V: +- case JXFORM_ROT_180: +- /* Need workspace arrays having same dimensions as source image. +- * Note that we allocate arrays padded out to the next iMCU boundary, +- * so that transform routines need not worry about missing edge blocks. +- */ +- coef_arrays = (jvirt_barray_ptr *) +- (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, +- SIZEOF(jvirt_barray_ptr) * info->num_components); +- for (ci = 0; ci < info->num_components; ci++) { +- compptr = srcinfo->comp_info + ci; +- coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) +- ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, +- (JDIMENSION) jround_up((long) compptr->width_in_blocks, +- (long) compptr->h_samp_factor), +- (JDIMENSION) jround_up((long) compptr->height_in_blocks, +- (long) compptr->v_samp_factor), +- (JDIMENSION) compptr->v_samp_factor); +- } ++ if (info->trim) ++ trim_bottom_edge(info, srcinfo->image_height); ++ /* Need workspace arrays having same dimensions as source image. */ ++ need_workspace = TRUE; + break; + case JXFORM_TRANSPOSE: ++ /* transpose does NOT have to trim anything */ ++ /* Need workspace arrays having transposed dimensions. */ ++ need_workspace = TRUE; ++ transpose_it = TRUE; ++ break; + case JXFORM_TRANSVERSE: ++ if (info->trim) { ++ trim_right_edge(info, srcinfo->image_height); ++ trim_bottom_edge(info, srcinfo->image_width); ++ } ++ /* Need workspace arrays having transposed dimensions. */ ++ need_workspace = TRUE; ++ transpose_it = TRUE; ++ break; + case JXFORM_ROT_90: ++ if (info->trim) ++ trim_right_edge(info, srcinfo->image_height); ++ /* Need workspace arrays having transposed dimensions. */ ++ need_workspace = TRUE; ++ transpose_it = TRUE; ++ break; ++ case JXFORM_ROT_180: ++ if (info->trim) { ++ trim_right_edge(info, srcinfo->image_width); ++ trim_bottom_edge(info, srcinfo->image_height); ++ } ++ /* Need workspace arrays having same dimensions as source image. */ ++ need_workspace = TRUE; ++ break; + case JXFORM_ROT_270: +- /* Need workspace arrays having transposed dimensions. +- * Note that we allocate arrays padded out to the next iMCU boundary, +- * so that transform routines need not worry about missing edge blocks. +- */ ++ if (info->trim) ++ trim_bottom_edge(info, srcinfo->image_width); ++ /* Need workspace arrays having transposed dimensions. */ ++ need_workspace = TRUE; ++ transpose_it = TRUE; ++ break; ++ } ++ ++ /* Allocate workspace if needed. ++ * Note that we allocate arrays padded out to the next iMCU boundary, ++ * so that transform routines need not worry about missing edge blocks. ++ */ ++ if (need_workspace) { + coef_arrays = (jvirt_barray_ptr *) + (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, +- SIZEOF(jvirt_barray_ptr) * info->num_components); ++ SIZEOF(jvirt_barray_ptr) * info->num_components); ++ width_in_iMCUs = (JDIMENSION) ++ jdiv_round_up((long) info->output_width, ++ (long) (info->max_h_samp_factor * DCTSIZE)); ++ height_in_iMCUs = (JDIMENSION) ++ jdiv_round_up((long) info->output_height, ++ (long) (info->max_v_samp_factor * DCTSIZE)); + for (ci = 0; ci < info->num_components; ci++) { + compptr = srcinfo->comp_info + ci; ++ if (info->num_components == 1) { ++ /* we're going to force samp factors to 1x1 in this case */ ++ h_samp_factor = v_samp_factor = 1; ++ } else if (transpose_it) { ++ h_samp_factor = compptr->v_samp_factor; ++ v_samp_factor = compptr->h_samp_factor; ++ } else { ++ h_samp_factor = compptr->h_samp_factor; ++ v_samp_factor = compptr->v_samp_factor; ++ } ++ width_in_blocks = width_in_iMCUs * h_samp_factor; ++ height_in_blocks = height_in_iMCUs * v_samp_factor; + coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) + ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, +- (JDIMENSION) jround_up((long) compptr->height_in_blocks, +- (long) compptr->v_samp_factor), +- (JDIMENSION) jround_up((long) compptr->width_in_blocks, +- (long) compptr->h_samp_factor), +- (JDIMENSION) compptr->h_samp_factor); ++ width_in_blocks, height_in_blocks, (JDIMENSION) v_samp_factor); + } +- break; + } ++ + info->workspace_coef_arrays = coef_arrays; + } + +@@ -642,14 +1062,8 @@ + int tblno, i, j, ci, itemp; + jpeg_component_info *compptr; + JQUANT_TBL *qtblptr; +- JDIMENSION dtemp; + UINT16 qtemp; + +- /* Transpose basic image dimensions */ +- dtemp = dstinfo->image_width; +- dstinfo->image_width = dstinfo->image_height; +- dstinfo->image_height = dtemp; +- + /* Transpose sampling factors */ + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; +@@ -674,46 +1088,159 @@ + } + + +-/* Trim off any partial iMCUs on the indicated destination edge */ ++/* Adjust Exif image parameters. ++ * ++ * We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible. ++ */ + + LOCAL(void) +-trim_right_edge (j_compress_ptr dstinfo) ++adjust_exif_parameters (JOCTET FAR * data, unsigned int length, ++ JDIMENSION new_width, JDIMENSION new_height) + { +- int ci, max_h_samp_factor; +- JDIMENSION MCU_cols; ++ boolean is_motorola; /* Flag for byte order */ ++ unsigned int number_of_tags, tagnum; ++ unsigned int firstoffset, offset; ++ JDIMENSION new_value; + +- /* We have to compute max_h_samp_factor ourselves, +- * because it hasn't been set yet in the destination +- * (and we don't want to use the source's value). +- */ +- max_h_samp_factor = 1; +- for (ci = 0; ci < dstinfo->num_components; ci++) { +- int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor; +- max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor); ++ if (length < 12) return; /* Length of an IFD entry */ ++ ++ /* Discover byte order */ ++ if (GETJOCTET(data[0]) == 0x49 && GETJOCTET(data[1]) == 0x49) ++ is_motorola = FALSE; ++ else if (GETJOCTET(data[0]) == 0x4D && GETJOCTET(data[1]) == 0x4D) ++ is_motorola = TRUE; ++ else ++ return; ++ ++ /* Check Tag Mark */ ++ if (is_motorola) { ++ if (GETJOCTET(data[2]) != 0) return; ++ if (GETJOCTET(data[3]) != 0x2A) return; ++ } else { ++ if (GETJOCTET(data[3]) != 0) return; ++ if (GETJOCTET(data[2]) != 0x2A) return; + } +- MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE); +- if (MCU_cols > 0) /* can't trim to 0 pixels */ +- dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE); +-} + +-LOCAL(void) +-trim_bottom_edge (j_compress_ptr dstinfo) +-{ +- int ci, max_v_samp_factor; +- JDIMENSION MCU_rows; ++ /* Get first IFD offset (offset to IFD0) */ ++ if (is_motorola) { ++ if (GETJOCTET(data[4]) != 0) return; ++ if (GETJOCTET(data[5]) != 0) return; ++ firstoffset = GETJOCTET(data[6]); ++ firstoffset <<= 8; ++ firstoffset += GETJOCTET(data[7]); ++ } else { ++ if (GETJOCTET(data[7]) != 0) return; ++ if (GETJOCTET(data[6]) != 0) return; ++ firstoffset = GETJOCTET(data[5]); ++ firstoffset <<= 8; ++ firstoffset += GETJOCTET(data[4]); ++ } ++ if (firstoffset > length - 2) return; /* check end of data segment */ + +- /* We have to compute max_v_samp_factor ourselves, +- * because it hasn't been set yet in the destination +- * (and we don't want to use the source's value). +- */ +- max_v_samp_factor = 1; +- for (ci = 0; ci < dstinfo->num_components; ci++) { +- int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor; +- max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor); ++ /* Get the number of directory entries contained in this IFD */ ++ if (is_motorola) { ++ number_of_tags = GETJOCTET(data[firstoffset]); ++ number_of_tags <<= 8; ++ number_of_tags += GETJOCTET(data[firstoffset+1]); ++ } else { ++ number_of_tags = GETJOCTET(data[firstoffset+1]); ++ number_of_tags <<= 8; ++ number_of_tags += GETJOCTET(data[firstoffset]); + } +- MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE); +- if (MCU_rows > 0) /* can't trim to 0 pixels */ +- dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE); ++ if (number_of_tags == 0) return; ++ firstoffset += 2; ++ ++ /* Search for ExifSubIFD offset Tag in IFD0 */ ++ for (;;) { ++ if (firstoffset > length - 12) return; /* check end of data segment */ ++ /* Get Tag number */ ++ if (is_motorola) { ++ tagnum = GETJOCTET(data[firstoffset]); ++ tagnum <<= 8; ++ tagnum += GETJOCTET(data[firstoffset+1]); ++ } else { ++ tagnum = GETJOCTET(data[firstoffset+1]); ++ tagnum <<= 8; ++ tagnum += GETJOCTET(data[firstoffset]); ++ } ++ if (tagnum == 0x8769) break; /* found ExifSubIFD offset Tag */ ++ if (--number_of_tags == 0) return; ++ firstoffset += 12; ++ } ++ ++ /* Get the ExifSubIFD offset */ ++ if (is_motorola) { ++ if (GETJOCTET(data[firstoffset+8]) != 0) return; ++ if (GETJOCTET(data[firstoffset+9]) != 0) return; ++ offset = GETJOCTET(data[firstoffset+10]); ++ offset <<= 8; ++ offset += GETJOCTET(data[firstoffset+11]); ++ } else { ++ if (GETJOCTET(data[firstoffset+11]) != 0) return; ++ if (GETJOCTET(data[firstoffset+10]) != 0) return; ++ offset = GETJOCTET(data[firstoffset+9]); ++ offset <<= 8; ++ offset += GETJOCTET(data[firstoffset+8]); ++ } ++ if (offset > length - 2) return; /* check end of data segment */ ++ ++ /* Get the number of directory entries contained in this SubIFD */ ++ if (is_motorola) { ++ number_of_tags = GETJOCTET(data[offset]); ++ number_of_tags <<= 8; ++ number_of_tags += GETJOCTET(data[offset+1]); ++ } else { ++ number_of_tags = GETJOCTET(data[offset+1]); ++ number_of_tags <<= 8; ++ number_of_tags += GETJOCTET(data[offset]); ++ } ++ if (number_of_tags < 2) return; ++ offset += 2; ++ ++ /* Search for ExifImageWidth and ExifImageHeight Tags in this SubIFD */ ++ do { ++ if (offset > length - 12) return; /* check end of data segment */ ++ /* Get Tag number */ ++ if (is_motorola) { ++ tagnum = GETJOCTET(data[offset]); ++ tagnum <<= 8; ++ tagnum += GETJOCTET(data[offset+1]); ++ } else { ++ tagnum = GETJOCTET(data[offset+1]); ++ tagnum <<= 8; ++ tagnum += GETJOCTET(data[offset]); ++ } ++ if (tagnum == 0xA002 || tagnum == 0xA003) { ++ if (tagnum == 0xA002) ++ new_value = new_width; /* ExifImageWidth Tag */ ++ else ++ new_value = new_height; /* ExifImageHeight Tag */ ++ if (is_motorola) { ++ data[offset+2] = 0; /* Format = unsigned long (4 octets) */ ++ data[offset+3] = 4; ++ data[offset+4] = 0; /* Number Of Components = 1 */ ++ data[offset+5] = 0; ++ data[offset+6] = 0; ++ data[offset+7] = 1; ++ data[offset+8] = 0; ++ data[offset+9] = 0; ++ data[offset+10] = (JOCTET)((new_value >> 8) & 0xFF); ++ data[offset+11] = (JOCTET)(new_value & 0xFF); ++ } else { ++ data[offset+2] = 4; /* Format = unsigned long (4 octets) */ ++ data[offset+3] = 0; ++ data[offset+4] = 1; /* Number Of Components = 1 */ ++ data[offset+5] = 0; ++ data[offset+6] = 0; ++ data[offset+7] = 0; ++ data[offset+8] = (JOCTET)(new_value & 0xFF); ++ data[offset+9] = (JOCTET)((new_value >> 8) & 0xFF); ++ data[offset+10] = 0; ++ data[offset+11] = 0; ++ } ++ } ++ offset += 12; ++ } while (--number_of_tags); + } + + +@@ -736,18 +1263,22 @@ + { + /* If force-to-grayscale is requested, adjust destination parameters */ + if (info->force_grayscale) { +- /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed +- * properly. Among other things, the target h_samp_factor & v_samp_factor +- * will get set to 1, which typically won't match the source. +- * In fact we do this even if the source is already grayscale; that +- * provides an easy way of coercing a grayscale JPEG with funny sampling +- * factors to the customary 1,1. (Some decoders fail on other factors.) ++ /* First, ensure we have YCbCr or grayscale data, and that the source's ++ * Y channel is full resolution. (No reasonable person would make Y ++ * be less than full resolution, so actually coping with that case ++ * isn't worth extra code space. But we check it to avoid crashing.) + */ +- if ((dstinfo->jpeg_color_space == JCS_YCbCr && +- dstinfo->num_components == 3) || +- (dstinfo->jpeg_color_space == JCS_GRAYSCALE && +- dstinfo->num_components == 1)) { +- /* We have to preserve the source's quantization table number. */ ++ if (((dstinfo->jpeg_color_space == JCS_YCbCr && ++ dstinfo->num_components == 3) || ++ (dstinfo->jpeg_color_space == JCS_GRAYSCALE && ++ dstinfo->num_components == 1)) && ++ srcinfo->comp_info[0].h_samp_factor == srcinfo->max_h_samp_factor && ++ srcinfo->comp_info[0].v_samp_factor == srcinfo->max_v_samp_factor) { ++ /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed ++ * properly. Among other things, it sets the target h_samp_factor & ++ * v_samp_factor to 1, which typically won't match the source. ++ * We have to preserve the source's quantization table number, however. ++ */ + int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; + jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); + dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; +@@ -755,50 +1286,52 @@ + /* Sorry, can't do it */ + ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); + } ++ } else if (info->num_components == 1) { ++ /* For a single-component source, we force the destination sampling factors ++ * to 1x1, with or without force_grayscale. This is useful because some ++ * decoders choke on grayscale images with other sampling factors. ++ */ ++ dstinfo->comp_info[0].h_samp_factor = 1; ++ dstinfo->comp_info[0].v_samp_factor = 1; + } + +- /* Correct the destination's image dimensions etc if necessary */ ++ /* Correct the destination's image dimensions as necessary ++ * for crop and rotate/flip operations. ++ */ ++ dstinfo->image_width = info->output_width; ++ dstinfo->image_height = info->output_height; ++ ++ /* Transpose destination image parameters */ + switch (info->transform) { +- case JXFORM_NONE: +- /* Nothing to do */ +- break; +- case JXFORM_FLIP_H: +- if (info->trim) +- trim_right_edge(dstinfo); +- break; +- case JXFORM_FLIP_V: +- if (info->trim) +- trim_bottom_edge(dstinfo); +- break; + case JXFORM_TRANSPOSE: +- transpose_critical_parameters(dstinfo); +- /* transpose does NOT have to trim anything */ +- break; + case JXFORM_TRANSVERSE: +- transpose_critical_parameters(dstinfo); +- if (info->trim) { +- trim_right_edge(dstinfo); +- trim_bottom_edge(dstinfo); +- } +- break; + case JXFORM_ROT_90: +- transpose_critical_parameters(dstinfo); +- if (info->trim) +- trim_right_edge(dstinfo); +- break; +- case JXFORM_ROT_180: +- if (info->trim) { +- trim_right_edge(dstinfo); +- trim_bottom_edge(dstinfo); +- } +- break; + case JXFORM_ROT_270: + transpose_critical_parameters(dstinfo); +- if (info->trim) +- trim_bottom_edge(dstinfo); + break; + } + ++ /* Adjust Exif properties */ ++ if (srcinfo->marker_list != NULL && ++ srcinfo->marker_list->marker == JPEG_APP0+1 && ++ srcinfo->marker_list->data_length >= 6 && ++ GETJOCTET(srcinfo->marker_list->data[0]) == 0x45 && ++ GETJOCTET(srcinfo->marker_list->data[1]) == 0x78 && ++ GETJOCTET(srcinfo->marker_list->data[2]) == 0x69 && ++ GETJOCTET(srcinfo->marker_list->data[3]) == 0x66 && ++ GETJOCTET(srcinfo->marker_list->data[4]) == 0 && ++ GETJOCTET(srcinfo->marker_list->data[5]) == 0) { ++ /* Suppress output of JFIF marker */ ++ dstinfo->write_JFIF_header = FALSE; ++ /* Adjust Exif image parameters */ ++ if (dstinfo->image_width != srcinfo->image_width || ++ dstinfo->image_height != srcinfo->image_height) ++ /* Align data segment to start of TIFF structure for parsing */ ++ adjust_exif_parameters(srcinfo->marker_list->data + 6, ++ srcinfo->marker_list->data_length - 6, ++ dstinfo->image_width, dstinfo->image_height); ++ } ++ + /* Return the appropriate output data set */ + if (info->workspace_coef_arrays != NULL) + return info->workspace_coef_arrays; +@@ -816,36 +1349,53 @@ + */ + + GLOBAL(void) +-jtransform_execute_transformation (j_decompress_ptr srcinfo, +- j_compress_ptr dstinfo, +- jvirt_barray_ptr *src_coef_arrays, +- jpeg_transform_info *info) ++jtransform_execute_transform (j_decompress_ptr srcinfo, ++ j_compress_ptr dstinfo, ++ jvirt_barray_ptr *src_coef_arrays, ++ jpeg_transform_info *info) + { + jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; + ++ /* Note: conditions tested here should match those in switch statement ++ * in jtransform_request_workspace() ++ */ + switch (info->transform) { + case JXFORM_NONE: ++ if (info->x_crop_offset != 0 || info->y_crop_offset != 0) ++ do_crop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, ++ src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_FLIP_H: +- do_flip_h(srcinfo, dstinfo, src_coef_arrays); ++ if (info->y_crop_offset != 0) ++ do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, ++ src_coef_arrays, dst_coef_arrays); ++ else ++ do_flip_h_no_crop(srcinfo, dstinfo, info->x_crop_offset, ++ src_coef_arrays); + break; + case JXFORM_FLIP_V: +- do_flip_v(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); ++ do_flip_v(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, ++ src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_TRANSPOSE: +- do_transpose(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); ++ do_transpose(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, ++ src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_TRANSVERSE: +- do_transverse(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); ++ do_transverse(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, ++ src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_90: +- do_rot_90(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); ++ do_rot_90(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, ++ src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_180: +- do_rot_180(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); ++ do_rot_180(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, ++ src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_270: +- do_rot_270(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); ++ do_rot_270(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, ++ src_coef_arrays, dst_coef_arrays); + break; + } + } +--- jpeg-6b/jerror.h~libjpeg6bb-5 ++++ jpeg-6b/jerror.h +@@ -45,6 +45,7 @@ + JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") + JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") + JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") ++JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request") + JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") + JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") + JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") +--- jpeg-6b/transupp.h~libjpeg6bb-5 ++++ jpeg-6b/transupp.h +@@ -1,7 +1,7 @@ + /* + * transupp.h + * +- * Copyright (C) 1997, Thomas G. Lane. ++ * Copyright (C) 1997-2001, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * +@@ -22,32 +22,6 @@ + #define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ + #endif + +-/* Short forms of external names for systems with brain-damaged linkers. */ +- +-#ifdef NEED_SHORT_EXTERNAL_NAMES +-#define jtransform_request_workspace jTrRequest +-#define jtransform_adjust_parameters jTrAdjust +-#define jtransform_execute_transformation jTrExec +-#define jcopy_markers_setup jCMrkSetup +-#define jcopy_markers_execute jCMrkExec +-#endif /* NEED_SHORT_EXTERNAL_NAMES */ +- +- +-/* +- * Codes for supported types of image transformations. +- */ +- +-typedef enum { +- JXFORM_NONE, /* no transformation */ +- JXFORM_FLIP_H, /* horizontal flip */ +- JXFORM_FLIP_V, /* vertical flip */ +- JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ +- JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ +- JXFORM_ROT_90, /* 90-degree clockwise rotation */ +- JXFORM_ROT_180, /* 180-degree rotation */ +- JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ +-} JXFORM_CODE; +- + /* + * Although rotating and flipping data expressed as DCT coefficients is not + * hard, there is an asymmetry in the JPEG format specification for images +@@ -75,6 +49,19 @@ + * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim + * followed by -rot 180 -trim trims both edges.) + * ++ * We also offer a lossless-crop option, which discards data outside a given ++ * image region but losslessly preserves what is inside. Like the rotate and ++ * flip transforms, lossless crop is restricted by the JPEG format: the upper ++ * left corner of the selected region must fall on an iMCU boundary. If this ++ * does not hold for the given crop parameters, we silently move the upper left ++ * corner up and/or left to make it so, simultaneously increasing the region ++ * dimensions to keep the lower right crop corner unchanged. (Thus, the ++ * output image covers at least the requested region, but may cover more.) ++ * ++ * If both crop and a rotate/flip transform are requested, the crop is applied ++ * last --- that is, the crop region is specified in terms of the destination ++ * image. ++ * + * We also offer a "force to grayscale" option, which simply discards the + * chrominance channels of a YCbCr image. This is lossless in the sense that + * the luminance channel is preserved exactly. It's not the same kind of +@@ -83,20 +70,87 @@ + * be aware of the option to know how many components to work on. + */ + ++ ++/* Short forms of external names for systems with brain-damaged linkers. */ ++ ++#ifdef NEED_SHORT_EXTERNAL_NAMES ++#define jtransform_parse_crop_spec jTrParCrop ++#define jtransform_request_workspace jTrRequest ++#define jtransform_adjust_parameters jTrAdjust ++#define jtransform_execute_transform jTrExec ++#define jcopy_markers_setup jCMrkSetup ++#define jcopy_markers_execute jCMrkExec ++#endif /* NEED_SHORT_EXTERNAL_NAMES */ ++ ++ ++/* ++ * Codes for supported types of image transformations. ++ */ ++ ++typedef enum { ++ JXFORM_NONE, /* no transformation */ ++ JXFORM_FLIP_H, /* horizontal flip */ ++ JXFORM_FLIP_V, /* vertical flip */ ++ JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ ++ JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ ++ JXFORM_ROT_90, /* 90-degree clockwise rotation */ ++ JXFORM_ROT_180, /* 180-degree rotation */ ++ JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ ++} JXFORM_CODE; ++ ++/* ++ * Codes for crop parameters, which can individually be unspecified, ++ * positive, or negative. (Negative width or height makes no sense, though.) ++ */ ++ ++typedef enum { ++ JCROP_UNSET, ++ JCROP_POS, ++ JCROP_NEG ++} JCROP_CODE; ++ ++/* ++ * Transform parameters struct. ++ * NB: application must not change any elements of this struct after ++ * calling jtransform_request_workspace. ++ */ ++ + typedef struct { + /* Options: set by caller */ + JXFORM_CODE transform; /* image transform operator */ + boolean trim; /* if TRUE, trim partial MCUs as needed */ + boolean force_grayscale; /* if TRUE, convert color image to grayscale */ ++ boolean crop; /* if TRUE, crop source image */ ++ ++ /* Crop parameters: application need not set these unless crop is TRUE. ++ * These can be filled in by jtransform_parse_crop_spec(). ++ */ ++ JDIMENSION crop_width; /* Width of selected region */ ++ JCROP_CODE crop_width_set; ++ JDIMENSION crop_height; /* Height of selected region */ ++ JCROP_CODE crop_height_set; ++ JDIMENSION crop_xoffset; /* X offset of selected region */ ++ JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */ ++ JDIMENSION crop_yoffset; /* Y offset of selected region */ ++ JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */ + + /* Internal workspace: caller should not touch these */ + int num_components; /* # of components in workspace */ + jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ ++ JDIMENSION output_width; /* cropped destination dimensions */ ++ JDIMENSION output_height; ++ JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */ ++ JDIMENSION y_crop_offset; ++ int max_h_samp_factor; /* destination iMCU size */ ++ int max_v_samp_factor; + } jpeg_transform_info; + + + #if TRANSFORMS_SUPPORTED + ++/* Parse a crop specification (written in X11 geometry style) */ ++EXTERN(boolean) jtransform_parse_crop_spec ++ JPP((jpeg_transform_info *info, const char *spec)); + /* Request any required workspace */ + EXTERN(void) jtransform_request_workspace + JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); +@@ -106,11 +160,18 @@ + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info)); + /* Execute the actual transformation, if any */ +-EXTERN(void) jtransform_execute_transformation ++EXTERN(void) jtransform_execute_transform + JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info)); + ++/* jtransform_execute_transform used to be called ++ * jtransform_execute_transformation, but some compilers complain about ++ * routine names that long. This macro is here to avoid breaking any ++ * old source code that uses the original name... ++ */ ++#define jtransform_execute_transformation jtransform_execute_transform ++ + #endif /* TRANSFORMS_SUPPORTED */ + + + diff --git a/toolchains/openpandora/packages/libogg/build.sh b/toolchains/openpandora/packages/libogg/build.sh new file mode 100755 index 0000000..934fa59 --- /dev/null +++ b/toolchains/openpandora/packages/libogg/build.sh @@ -0,0 +1,24 @@ +#! /bin/sh + +# OpenPandora firmware uses libogg 1.1.4 (ABI 0.6.0) stick with it +LIBOGG_VERSION=1.1.4 +LIBOGG_SHA256=9354c183fd88417c2860778b60b7896c9487d8f6e58b9fec3fdbf971142ce103 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch libogg "http://downloads.xiph.org/releases/ogg/libogg-${LIBOGG_VERSION}.tar.gz" \ + 'tar xzf' "sha256:${LIBOGG_SHA256}" + +# Avoid compiling and installing doc +sed -ie 's/^\(SUBDIRS.*\) doc/\1/' Makefile.am +autoreconf -fi + +do_configure_shared +do_make +do_make install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/libpng/build.sh b/toolchains/openpandora/packages/libpng/build.sh new file mode 100755 index 0000000..48dd988 --- /dev/null +++ b/toolchains/openpandora/packages/libpng/build.sh @@ -0,0 +1,28 @@ +#! /bin/sh + +# OpenPandora firmware uses libpng 1.2.42 stick with it +LIBPNG_VERSION=1.2.42 +LIBPNG_SHA256=a044c4632a236bbf99527da81977577929a173c1f7f68a70a81ea2ea7cffa6a7 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch libpng "http://download.sourceforge.net/project/libpng/libpng12/older-releases/${LIBPNG_VERSION}/libpng-${LIBPNG_VERSION}.tar.bz2" \ + 'tar xjf' "sha256:${LIBPNG_SHA256}" + +# Enable shared objects to make binary lighter +do_configure_shared +do_make + +# Don't install man pages and binaries +do_make install-libLTLIBRARIES \ + install-binSCRIPTS \ + install-exec-hook \ + install-pkgconfigDATA \ + install-pkgincludeHEADERS \ + install-data-hook + +do_clean_bdir diff --git a/toolchains/openpandora/packages/libsdl/build.sh b/toolchains/openpandora/packages/libsdl/build.sh new file mode 100755 index 0000000..abf6e6d --- /dev/null +++ b/toolchains/openpandora/packages/libsdl/build.sh @@ -0,0 +1,35 @@ +#! /bin/sh + +# OpenPandora firmware uses libSDL 1.2.14 stick with it +SDL_VERSION=1.2.14 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +# GPG key of Sam Lantinga +gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 0xA7763BE6 +do_http_fetch SDL "https://www.libsdl.org/release/SDL-${SDL_VERSION}.tar.gz" 'tar xzf' \ + "gpgurl:http://www.libsdl.org/release/SDL-${SDL_VERSION}.tar.gz.sig" +rm -Rf $HOME/.gnupg + +./autogen.sh + +do_configure_shared \ + --disable-static \ + --disable-diskaudio \ + --disable-video-dummy \ + --disable-video-dga \ + --enable-input-tslib \ + --enable-video-x11 \ + --enable-video-fbcon \ + --enable-video-opengl + +do_make + +# No man pages +do_make install-bin install-hdrs install-lib install-data + +do_clean_bdir diff --git a/toolchains/openpandora/packages/libvorbis/build.sh b/toolchains/openpandora/packages/libvorbis/build.sh new file mode 100755 index 0000000..9e6343f --- /dev/null +++ b/toolchains/openpandora/packages/libvorbis/build.sh @@ -0,0 +1,24 @@ +#! /bin/sh + +# OpenPandora firmware uses libvorbis 1.2.3 stick with it +LIBVORBIS_VERSION=1.2.3 +LIBVORBIS_SHA256=c679d1e5e45a3ec8aceb5e71de8e3712630b7a6dec6952886c17435a65955947 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch libvorbis "http://downloads.xiph.org/releases/vorbis/libvorbis-${LIBVORBIS_VERSION}.tar.gz" \ + 'tar xzf' "sha256:${LIBVORBIS_SHA256}" + +# Avoid compiling and installing useless stuff +sed -ie 's/^\(SUBDIRS.*\) examples test doc/\1/' Makefile.am + +autoreconf -fi -I m4 +do_configure_shared +do_make +do_make install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/sdl-net1.2/build.sh b/toolchains/openpandora/packages/sdl-net1.2/build.sh new file mode 100755 index 0000000..a5d321d --- /dev/null +++ b/toolchains/openpandora/packages/sdl-net1.2/build.sh @@ -0,0 +1,21 @@ +#! /bin/sh + +# OpenPandora firmware uses SDL-net 1.2.7 stick with it +SDL_NET_VERSION=1.2.7 +SDL_NET_SHA256=2ce7c84e62ff8117b9f205758bcce68ea603e08bc9d6936ded343735b8b77c53 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch SDL_net "https://www.libsdl.org/projects/SDL_net/release/SDL_net-${SDL_NET_VERSION}.tar.gz" 'tar xzf' \ + "sha256:${SDL_NET_SHA256}" + +do_configure_shared --with-sdl-prefix=$PREFIX + +do_make +do_make install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/toolchain/build.sh b/toolchains/openpandora/packages/toolchain/build.sh new file mode 100755 index 0000000..20def9a --- /dev/null +++ b/toolchains/openpandora/packages/toolchain/build.sh @@ -0,0 +1,36 @@ +#! /bin/sh + +CT_NG_VERSION=1.24.0 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +# GPG keys of Bryan Hundven and Alexey Neyman +gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 0x35B871D1 0x11D618A4 +do_http_fetch crosstool-ng "http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-${CT_NG_VERSION}.tar.bz2" 'tar xjf' \ + "gpgurl:http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-${CT_NG_VERSION}.tar.bz2.sig" +rm -Rf $HOME/.gnupg + +# Update everything as we just patched Crosstool +./bootstrap + +# Don't use do_configure as it's a pure host job +./configure --enable-local +make + +# Create tarballs directory +mkdir -p ./.tarballs + +# Update configuration +cp ${PACKAGE_DIR}/config .config +./ct-ng olddefconfig + +./ct-ng build CT_PREFIX=${TOOLCHAIN} + +do_clean_bdir +# Cleanup stuff left by crosstool-ng +rm -f $HOME/.wget-hsts +rm -f /tmp/cc* diff --git a/toolchains/openpandora/packages/toolchain/config b/toolchains/openpandora/packages/toolchain/config new file mode 100644 index 0000000..2c523ae --- /dev/null +++ b/toolchains/openpandora/packages/toolchain/config @@ -0,0 +1,179 @@ +# crosstool-NG Configuration +# +CT_CONFIG_VERSION="3" + +# +# Paths and misc options +# + +# +# crosstool-NG behavior +# + +# +# Paths +# +# Define all paths +# +CT_LOCAL_TARBALLS_DIR="${CT_TOP_DIR}/.tarballs" +CT_WORK_DIR="${CT_TOP_DIR}/.build" +CT_BUILD_TOP_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/.build}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}" +CT_PREFIX_DIR="${CT_PREFIX:-${CT_TOP_DIR}/toolchain}" +# Don't put toolchain R/O as we need to install libraries in it +# CT_PREFIX_DIR_RO is not set + +# +# Target options +# +# That's an ARM +CT_ARCH_ARM=y +# OpenPandora has TI OMAP3 which is Cortex-A8 +CT_ARCH_TUNE="cortex-a8" + +# +# Options for arm +# +# No thumb and EABI +CT_ARCH_ARM_MODE_ARM=y +CT_ARCH_ARM_EABI=y + +# +# Generic target options +# +# Little endian +CT_ARCH_LE=y + +# +# Target optimisations +# +# Use same flags as the official firmware +CT_ARCH_ARCH="armv7-a" +CT_ARCH_FPU="neon" +# No hardfloat on the target +CT_ARCH_FLOAT_SW=y + +# +# Toolchain options +# + +# +# General toolchain options +# + +# +# Tuple completion and aliasing +# +# Use same vendor as the official toolchain +CT_TARGET_VENDOR="angstrom" + +# +# Toolchain type +# +CT_CROSS=y + +# +# Build system +# + +# +# Misc options +# + +# +# Operating System +# +CT_KERNEL_LINUX=y + +# +# Options for linux +# +# Use 2.6.24 kernel like the one running on the target +CT_LINUX_SRC_RELEASE=y +CT_LINUX_V_2_6=y +CT_LINUX_VERSION="2.6.31" + +# +# Common kernel options +# + +# +# Binary utilities +# + +# +# Options for binutils +# + +# +# GNU binutils +# + +# +# C-library +# +CT_LIBC_GLIBC=y + +# +# Options for glibc +# +# Use same GLIBC as the target to avoid static linking of it +CT_GLIBC_USE_GNU=y +CT_GLIBC_SRC_RELEASE=y +CT_GLIBC_V_2_9=y +# As in official firmware, target a 2.6.16 kernel +CT_GLIBC_KERNEL_VERSION_CHOSEN=y +CT_GLIBC_MIN_KERNEL_VERSION="2.6.16" + +# +# Common C library options +# +# Use native threads +CT_THREADS_NATIVE=y + +# +# C compiler +# +CT_CC_GCC=y + +# +# Options for gcc +# +# Don't build shared libgcc_s and libstdc++ as we are way more recent than the target compiler +CT_CC_GCC_EXTRA_CONFIG_ARRAY="--disable-shared" + +# +# Optimisation features +# +# Make the toolchain lighter +# CT_CC_GCC_USE_GRAPHITE is not set +# CT_CC_GCC_USE_LTO is not set + +# +# Settings for libraries running on target +# + +# +# Misc. obscure options. +# + +# +# Additional supported languages: +# +# Support C++ +CT_CC_LANG_CXX=y + +# +# Debug facilities +# + +# +# Companion libraries +# + +# +# Companion tools +# + +# +# Test suite +# diff --git a/toolchains/openpandora/packages/toolchain/patches/add-openpandora-support.patch b/toolchains/openpandora/packages/toolchain/patches/add-openpandora-support.patch new file mode 100644 index 0000000..b94e858 --- /dev/null +++ b/toolchains/openpandora/packages/toolchain/patches/add-openpandora-support.patch @@ -0,0 +1,579 @@ +diff --git a/config/libc/glibc.in b/config/libc/glibc.in +index 4138707f..ca54d9d2 100644 +--- a/config/libc/glibc.in ++++ b/config/libc/glibc.in +@@ -5,7 +5,7 @@ + ## select LIBC_SUPPORT_THREADS_NATIVE + ## select CC_CORE_PASSES_NEEDED + # TBD: select GETTEXT for build only, not for host +-## select GETTEXT_NEEDED ++## select GETTEXT_NEEDED if !GLIBC_V_2_9 + ## select BINUTILS_FORCE_LD_BFD_DEFAULT + + ## help The de-facto standard for Linux distributions. +diff --git a/packages/glibc-ports/2.9/0000-Fix-ARM-build-with-GCC-trunk.patch b/packages/glibc-ports/2.9/0000-Fix-ARM-build-with-GCC-trunk.patch +new file mode 100644 +index 00000000..a8eff6a0 +--- /dev/null ++++ b/packages/glibc-ports/2.9/0000-Fix-ARM-build-with-GCC-trunk.patch +@@ -0,0 +1,56 @@ ++Index: glibc-ports-2.9/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c ++=================================================================== ++--- glibc-ports-2.9.orig/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c +++++ glibc-ports-2.9/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c ++@@ -22,7 +22,8 @@ ++ #include ++ #include ++ ++-static void (*libgcc_s_resume) (struct _Unwind_Exception *exc); +++static void (*libgcc_s_resume) (struct _Unwind_Exception *exc) +++ __attribute_used__; ++ static _Unwind_Reason_Code (*libgcc_s_personality) ++ (_Unwind_State, struct _Unwind_Exception *, struct _Unwind_Context *); ++ static _Unwind_Reason_Code (*libgcc_s_forcedunwind) ++Index: glibc-ports-2.9/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c ++=================================================================== ++--- glibc-ports-2.9.orig/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c +++++ glibc-ports-2.9/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c ++@@ -21,7 +21,8 @@ ++ #include ++ #include ++ ++-static void (*libgcc_s_resume) (struct _Unwind_Exception *exc); +++static void (*libgcc_s_resume) (struct _Unwind_Exception *exc) +++ __attribute_used__; ++ static _Unwind_Reason_Code (*libgcc_s_personality) ++ (_Unwind_State, struct _Unwind_Exception *, struct _Unwind_Context *); ++ ++Index: glibc-ports-2.9/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c ++=================================================================== ++--- glibc-ports-2.9.orig/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c +++++ glibc-ports-2.9/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c ++@@ -22,7 +22,8 @@ ++ #include ++ #include ++ ++-static void (*libgcc_s_resume) (struct _Unwind_Exception *exc); +++static void (*libgcc_s_resume) (struct _Unwind_Exception *exc) +++ __attribute_used__; ++ static _Unwind_Reason_Code (*libgcc_s_personality) ++ (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *, ++ struct _Unwind_Context *); ++Index: glibc-ports-2.9/sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c ++=================================================================== ++--- glibc-ports-2.9.orig/sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c +++++ glibc-ports-2.9/sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c ++@@ -21,7 +21,8 @@ ++ #include ++ #include ++ ++-static void (*libgcc_s_resume) (struct _Unwind_Exception *exc); +++static void (*libgcc_s_resume) (struct _Unwind_Exception *exc) +++ __attribute_used__; ++ static _Unwind_Reason_Code (*libgcc_s_personality) ++ (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *, ++ struct _Unwind_Context *); +diff --git a/packages/glibc-ports/2.9/0100-arm-lowlevellock-include-tls.patch b/packages/glibc-ports/2.9/0100-arm-lowlevellock-include-tls.patch +new file mode 100644 +index 00000000..2f8e6756 +--- /dev/null ++++ b/packages/glibc-ports/2.9/0100-arm-lowlevellock-include-tls.patch +@@ -0,0 +1,12 @@ ++Index: sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h ++=================================================================== ++--- a/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h 2009-06-19 20:54:35.446686910 +0400 +++++ b/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h 2009-06-19 20:54:43.774683370 +0400 ++@@ -25,6 +25,7 @@ ++ #include ++ #include ++ #include +++#include ++ ++ #define FUTEX_WAIT 0 ++ #define FUTEX_WAKE 1 +diff --git a/packages/glibc-ports/2.9/chksum b/packages/glibc-ports/2.9/chksum +new file mode 100644 +index 00000000..08afc976 +--- /dev/null ++++ b/packages/glibc-ports/2.9/chksum +@@ -0,0 +1,8 @@ ++md5 glibc-ports-2.9.tar.bz2 7d5d86031cb15403e4d246658209ee81 ++sha1 glibc-ports-2.9.tar.bz2 599f44dd21c653a115ebf9dbb73eeff9d89b4f86 ++sha256 glibc-ports-2.9.tar.bz2 824c97b83f1ec2894ee0e824db6d542c40b978d2f6c4364c7411777e44b15a64 ++sha512 glibc-ports-2.9.tar.bz2 bdaad157dffb3e029a62d3c34e21042aa45b10bc728e9373774000c3bae4281f92b98a806320de9b18899e9f213a7f2730c45ddd571336ed576612a260aad9c1 ++md5 glibc-ports-2.9.tar.gz 1d136173241ce2b0554ffe302e909cc5 ++sha1 glibc-ports-2.9.tar.gz d5e2f500c60296c25159017f045c062b6e79b32b ++sha256 glibc-ports-2.9.tar.gz ce23634accd7df13a97827ddb7e9e668b95e72e7a0936db68e728467f8583c44 ++sha512 glibc-ports-2.9.tar.gz ec412fe98768d9c04bfda4f453f2af4da34823e3041e6eaea439887f0fd408e8f5c13672c5c60a910cfa9802a299b880fa879345b516d1d4f237d94e524e7668 +diff --git a/packages/glibc-ports/2.9/version.desc b/packages/glibc-ports/2.9/version.desc +new file mode 100644 +index 00000000..d44e333b +--- /dev/null ++++ b/packages/glibc-ports/2.9/version.desc +@@ -0,0 +1 @@ ++archive_formats='.tar.bz2 .tar.gz' +diff --git a/packages/glibc/2.9/0000-fix-configure-versions.patch b/packages/glibc/2.9/0000-fix-configure-versions.patch +new file mode 100644 +index 00000000..018dfbbe +--- /dev/null ++++ b/packages/glibc/2.9/0000-fix-configure-versions.patch +@@ -0,0 +1,105 @@ ++Index: glibc-2.9/configure ++=================================================================== ++--- glibc-2.9.orig/configure +++++ glibc-2.9/configure ++@@ -4531,7 +4531,7 @@ echo $ECHO_N "checking version of $AS... ++ ac_prog_version=`$AS --version 2>&1 | sed -n 's/^.*GNU assembler.* \([0-9]*\.[0-9.]*\).*$/\1/p'` ++ case $ac_prog_version in ++ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; ++- 2.1[3-9]*) +++ 2.1[0-9][0-9]*|2.1[3-9]*|2.[2-9]*|[3-9].*|[1-9][0-9]*) ++ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; ++ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; ++ ++@@ -4594,7 +4594,7 @@ echo $ECHO_N "checking version of $LD... ++ ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` ++ case $ac_prog_version in ++ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; ++- 2.1[3-9]*) +++ 2.1[0-9][0-9]*|2.1[3-9]*|2.[2-9]*|[3-9].*|[1-9][0-9]*) ++ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; ++ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; ++ ++@@ -4712,7 +4712,7 @@ echo $ECHO_N "checking version of $CC... ++ ac_prog_version=`$CC -v 2>&1 | sed -n 's/^.*version \([egcygnustpi-]*[0-9.]*\).*$/\1/p'` ++ case $ac_prog_version in ++ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; ++- 3.4* | 4.[0-9]* ) +++ 3.4* | [4-9].[0-9]* | [0-9][0-9].[0-9]* ) ++ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; ++ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; ++ ++@@ -4775,7 +4775,7 @@ echo $ECHO_N "checking version of $MAKE. ++ ac_prog_version=`$MAKE --version 2>&1 | sed -n 's/^.*GNU Make[^0-9]*\([0-9][0-9.]*\).*$/\1/p'` ++ case $ac_prog_version in ++ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; ++- 3.79* | 3.[89]*) +++ 3.79* | 3.[89]* | [4-9].* | [1-9][0-9]*) ++ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; ++ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; ++ ++@@ -4902,7 +4902,7 @@ echo $ECHO_N "checking version of $MAKEI ++ ac_prog_version=`$MAKEINFO --version 2>&1 | sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'` ++ case $ac_prog_version in ++ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; ++- 4.*) +++ [4-9].*) ++ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; ++ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; ++ ++@@ -4962,7 +4962,7 @@ else ++ # Found it, now check the version. ++ { echo "$as_me:$LINENO: checking version of $SED" >&5 ++ echo $ECHO_N "checking version of $SED... $ECHO_C" >&6; } ++- ac_prog_version=`$SED --version 2>&1 | sed -n 's/^.*GNU sed version \([0-9]*\.[0-9.]*\).*$/\1/p'` +++ ac_prog_version=`$SED --version 2>&1 | sed -n 's/^.*GNU sed[^0-9]* \([0-9]*\.[0-9.]*\).*$/\1/p'` ++ case $ac_prog_version in ++ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; ++ 3.0[2-9]*|3.[1-9]*|[4-9]*) ++Index: glibc-2.7/configure.in ++=================================================================== ++--- glibc-2.7.orig/configure.in +++++ glibc-2.7/configure.in ++@@ -844,10 +844,12 @@ AC_SUBST(MIG)dnl Needed by sysdeps/mach/ ++ # Accept binutils 2.13 or newer. ++ AC_CHECK_PROG_VER(AS, $AS, --version, ++ [GNU assembler.* \([0-9]*\.[0-9.]*\)], ++- [2.1[3-9]*], AS=: critic_missing="$critic_missing as") +++ [2.1[0-9][0-9]*|2.1[3-9]*|2.[2-9]*|[3-9].*|[1-9][0-9]*], +++ AS=: critic_missing="$critic_missing as") ++ AC_CHECK_PROG_VER(LD, $LD, --version, ++ [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)], ++- [2.1[3-9]*], LD=: critic_missing="$critic_missing ld") +++ [2.1[0-9][0-9]*|2.1[3-9]*|2.[2-9]*|[3-9].*|[1-9][0-9]*], +++ LD=: critic_missing="$critic_missing ld") ++ ++ # We need the physical current working directory. We cannot use the ++ # "pwd -P" shell builtin since that's not portable. Instead we try to ++@@ -862,11 +864,12 @@ fi ++ # These programs are version sensitive. ++ AC_CHECK_TOOL_PREFIX ++ AC_CHECK_PROG_VER(CC, ${ac_tool_prefix}gcc ${ac_tool_prefix}cc, -v, ++- [version \([egcygnustpi-]*[0-9.]*\)], [3.4* | 4.[0-9]* ], +++ [version \([egcygnustpi-]*[0-9.]*\)], +++ [3.4* | [4-9].[0-9]* | [0-9][0-9].[0-9]*], ++ critic_missing="$critic_missing gcc") ++ AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version, ++ [GNU Make[^0-9]*\([0-9][0-9.]*\)], ++- [3.79* | 3.[89]*], critic_missing="$critic_missing make") +++ 3.79* | 3.[89]* | [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make") ++ ++ AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version, ++ [GNU gettext.* \([0-9]*\.[0-9.]*\)], ++@@ -874,10 +877,10 @@ AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsg ++ MSGFMT=: aux_missing="$aux_missing msgfmt") ++ AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version, ++ [GNU texinfo.* \([0-9][0-9.]*\)], ++- [4.*], +++ [[4-9].*], ++ MAKEINFO=: aux_missing="$aux_missing makeinfo") ++ AC_CHECK_PROG_VER(SED, sed, --version, ++- [GNU sed version \([0-9]*\.[0-9.]*\)], +++ [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)], ++ [3.0[2-9]*|3.[1-9]*|[4-9]*], ++ SED=: aux_missing="$aux_missing sed") ++ +diff --git a/packages/glibc/2.9/0001-fix-recent-make.patch b/packages/glibc/2.9/0001-fix-recent-make.patch +new file mode 100644 +index 00000000..d59ec36b +--- /dev/null ++++ b/packages/glibc/2.9/0001-fix-recent-make.patch +@@ -0,0 +1,17 @@ ++Index: glibc-2.9/manual/Makefile ++=================================================================== ++--- glibc-2.9.orig/manual/Makefile +++++ glibc-2.9/manual/Makefile ++@@ -232,7 +232,11 @@ ifdef objpfx ++ .PHONY: stubs ++ stubs: $(objpfx)stubs ++ endif ++-$(objpfx)stubs ../po/manual.pot $(objpfx)stamp%: +++$(objpfx)stubs ../po/manual.pot: +++ $(make-target-directory) +++ touch $@ +++ +++$(objpfx)stamp%: ++ $(make-target-directory) ++ touch $@ ++ +diff --git a/packages/glibc/2.9/0100-nscd-init.patch b/packages/glibc/2.9/0100-nscd-init.patch +new file mode 100644 +index 00000000..b5b0dbb5 +--- /dev/null ++++ b/packages/glibc/2.9/0100-nscd-init.patch +@@ -0,0 +1,39 @@ ++--- a/nscd/nscd.init +++++ b/nscd/nscd.init ++@@ -48,9 +48,8 @@ ++ ++ start () { ++ [ -d /var/run/nscd ] || mkdir /var/run/nscd ++- [ -d /var/db/nscd ] || mkdir /var/db/nscd ++ echo -n $"Starting $prog: " ++- daemon /usr/sbin/nscd +++ /usr/sbin/nscd ++ RETVAL=$? ++ echo ++ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd ++@@ -67,12 +66,10 @@ ++ # a non-privileged user ++ rm -f /var/run/nscd/nscd.pid ++ rm -f /var/run/nscd/socket ++- success $"$prog shutdown" ++- else ++- failure $"$prog shutdown" ++ fi ++- echo ++- return $RETVAL +++ echo "Done." +++ # If nscd did not run, return 0 according to LSB. +++ return 0 ++ } ++ ++ restart() { ++@@ -104,7 +101,8 @@ ++ ;; ++ force-reload | reload) ++ echo -n $"Reloading $prog: " ++- killproc /usr/sbin/nscd -HUP +++ # Use killall, initscripts-1.0-r115 don't support -HUP yet. +++ killall -HUP /usr/sbin/nscd ++ RETVAL=$? ++ echo ++ ;; +diff --git a/packages/glibc/2.9/0110-fhs-linux-paths.patch b/packages/glibc/2.9/0110-fhs-linux-paths.patch +new file mode 100644 +index 00000000..1f32f6d7 +--- /dev/null ++++ b/packages/glibc/2.9/0110-fhs-linux-paths.patch +@@ -0,0 +1,11 @@ ++--- glibc-2.1.1/sysdeps/unix/sysv/linux/paths.h~ Thu May 27 13:16:33 1999 +++++ glibc-2.1.1/sysdeps/unix/sysv/linux/paths.h Thu May 27 13:17:55 1999 ++@@ -71,7 +71,7 @@ ++ /* Provide trailing slash, since mostly used for building pathnames. */ ++ #define _PATH_DEV "/dev/" ++ #define _PATH_TMP "/tmp/" ++-#define _PATH_VARDB "/var/db/" +++#define _PATH_VARDB "/var/lib/misc/" ++ #define _PATH_VARRUN "/var/run/" ++ #define _PATH_VARTMP "/var/tmp/" ++ +diff --git a/packages/glibc/2.9/0120-march-i686.patch b/packages/glibc/2.9/0120-march-i686.patch +new file mode 100644 +index 00000000..a9bfd73c +--- /dev/null ++++ b/packages/glibc/2.9/0120-march-i686.patch +@@ -0,0 +1,38 @@ ++2007-02-15 Khem Raj ++ ++ * sysdeps/unix/sysv/linux/i386/sysdep.h: Re-define __i686. ++ * nptl/sysdeps/pthread/pt-initfini.c: Ditto. ++ ++ ++ ++Index: sysdeps/unix/sysv/linux/i386/sysdep.h ++=================================================================== ++--- a/sysdeps/unix/sysv/linux/i386/sysdep.h (revision 1469) +++++ b/sysdeps/unix/sysv/linux/i386/sysdep.h (working copy) ++@@ -29,6 +29,10 @@ ++ #include ++ #include ++ +++#if defined __i686 && defined __ASSEMBLER__ +++#undef __i686 +++#define __i686 __i686 +++#endif ++ ++ /* For Linux we can use the system call table in the header file ++ /usr/include/asm/unistd.h ++Index: nptl/sysdeps/pthread/pt-initfini.c ++=================================================================== ++--- a/nptl/sysdeps/pthread/pt-initfini.c (revision 1469) +++++ b/nptl/sysdeps/pthread/pt-initfini.c (working copy) ++@@ -45,6 +45,11 @@ ++ /* Embed an #include to pull in the alignment and .end directives. */ ++ asm ("\n#include \"defs.h\""); ++ +++asm ("\n#if defined __i686 && defined __ASSEMBLER__"); +++asm ("\n#undef __i686"); +++asm ("\n#define __i686 __i686"); +++asm ("\n#endif"); +++ ++ /* The initial common code ends here. */ ++ asm ("\n/*@HEADER_ENDS*/"); ++ +diff --git a/packages/glibc/2.9/0130-tls_i486.patch b/packages/glibc/2.9/0130-tls_i486.patch +new file mode 100644 +index 00000000..69a1fdf9 +--- /dev/null ++++ b/packages/glibc/2.9/0130-tls_i486.patch +@@ -0,0 +1,14 @@ ++Index: glibc-2.9/sysdeps/i386/dl-tlsdesc.S ++=================================================================== ++--- glibc-2.9.orig/sysdeps/i386/dl-tlsdesc.S 2009-07-07 23:21:11.647664128 +0200 +++++ glibc-2.9/sysdeps/i386/dl-tlsdesc.S 2009-07-07 23:21:32.802555992 +0200 ++@@ -128,8 +128,7 @@ ++ .Lslow: ++ cfi_adjust_cfa_offset (28) ++ movl %ebx, 16(%esp) ++- call __i686.get_pc_thunk.bx ++- addl $_GLOBAL_OFFSET_TABLE_, %ebx +++ LOAD_PIC_REG (bx) ++ call ___tls_get_addr@PLT ++ movl 16(%esp), %ebx ++ jmp .Lret +diff --git a/packages/glibc/2.9/0200-glibc-2.9-use-_begin.patch b/packages/glibc/2.9/0200-glibc-2.9-use-_begin.patch +new file mode 100644 +index 00000000..8d36a052 +--- /dev/null ++++ b/packages/glibc/2.9/0200-glibc-2.9-use-_begin.patch +@@ -0,0 +1,28 @@ ++From 7c8a67320e26b8c11108bf0a3410d3aef9cf3486 Mon Sep 17 00:00:00 2001 ++From: Ulrich Drepper ++Date: Sat, 31 Jan 2009 00:21:15 +0000 ++Subject: [PATCH] * elf/Makefile (ld.so): Adjust the sed script to insert _begin in to newer linker scripts. ++--- ++diff --git a/elf/Makefile b/elf/Makefile ++index 8079fe9..e44ff1d 100644 ++--- a/elf/Makefile +++++ b/elf/Makefile ++@@ -1,4 +1,4 @@ ++-# Copyright (C) 1995-2007, 2008 Free Software Foundation, Inc. +++# Copyright (C) 1995-2007, 2008, 2009 Free Software Foundation, Inc. ++ # This file is part of the GNU C Library. ++ ++ # The GNU C Library is free software; you can redistribute it and/or ++@@ -304,7 +304,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map) ++ $(LDFLAGS-rtld) -Wl,-z,defs -Wl,--verbose 2>&1 | \ ++ LC_ALL=C \ ++ sed -e '/^=========/,/^=========/!d;/^=========/d' \ ++- -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \ +++ -e 's/\. = .* + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \ ++ > $@.lds ++ $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \ ++ $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \ ++-- ++1.6.3.2 ++ ++ +diff --git a/packages/glibc/2.9/0300-malloc-memusage.c-update_data-Fix-handling-of-wrappi.patch b/packages/glibc/2.9/0300-malloc-memusage.c-update_data-Fix-handling-of-wrappi.patch +new file mode 100644 +index 00000000..9a43212f +--- /dev/null ++++ b/packages/glibc/2.9/0300-malloc-memusage.c-update_data-Fix-handling-of-wrappi.patch +@@ -0,0 +1,46 @@ ++From c3ab42a82de7506c17749e78a171ce07ced95dd5 Mon Sep 17 00:00:00 2001 ++From: Ulrich Drepper ++Date: Fri, 6 Feb 2009 18:24:23 +0000 ++Subject: [PATCH 1/3] * malloc/memusage.c (update_data): Fix handling of wrapping back ++ ++ to the beginning of the buffer. ++--- ++ malloc/memusage.c | 8 +++++--- ++ 1 files changed, 5 insertions(+), 3 deletions(-) ++ ++diff --git a/malloc/memusage.c b/malloc/memusage.c ++index d11e9e6..6c67a8c 100644 ++--- a/malloc/memusage.c +++++ b/malloc/memusage.c ++@@ -1,5 +1,5 @@ ++ /* Profile heap and stack memory usage of running program. ++- Copyright (C) 1998-2002, 2004, 2005, 2006 Free Software Foundation, Inc. +++ Copyright (C) 1998-2002, 2004-2006, 2009 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ Contributed by Ulrich Drepper , 1998. ++ ++@@ -18,6 +18,7 @@ ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ +++#include ++ #include ++ #include ++ #include ++@@ -168,10 +169,11 @@ update_data (struct header *result, size_t len, size_t old_len) ++ this fails because of another thread increasing the ++ counter it does not matter since that thread will take ++ care of the correction. */ ++- unsigned int reset = idx - 2 * buffer_size; ++- catomic_compare_and_exchange_val_acq (&buffer_size, reset, idx); +++ uatomic32_t reset = idx % (2 * buffer_size); +++ catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx); ++ idx = reset; ++ } +++ assert (idx < 2 * DEFAULT_BUFFER_SIZE); ++ ++ buffer[idx].heap = current_heap; ++ buffer[idx].stack = current_stack; ++-- ++1.6.3.3 ++ +diff --git a/packages/glibc/2.9/0310-malloc-memusage.c-DEFAULT_BUFFER_SIZE-Change-to-3276.patch b/packages/glibc/2.9/0310-malloc-memusage.c-DEFAULT_BUFFER_SIZE-Change-to-3276.patch +new file mode 100644 +index 00000000..770de9ee +--- /dev/null ++++ b/packages/glibc/2.9/0310-malloc-memusage.c-DEFAULT_BUFFER_SIZE-Change-to-3276.patch +@@ -0,0 +1,26 @@ ++From e2e390fad8271da33a51075cc2bf27c9fe78861b Mon Sep 17 00:00:00 2001 ++From: Ulrich Drepper ++Date: Fri, 6 Feb 2009 18:27:08 +0000 ++Subject: [PATCH 2/3] * malloc/memusage.c (DEFAULT_BUFFER_SIZE): Change to 32768. ++ ++ (update_data): Fix handling of wrapping back ++--- ++ malloc/memusage.c | 2 +- ++ 1 files changed, 1 insertions(+), 1 deletions(-) ++ ++diff --git a/malloc/memusage.c b/malloc/memusage.c ++index 6c67a8c..fcd58dc 100644 ++--- a/malloc/memusage.c +++++ b/malloc/memusage.c ++@@ -93,7 +93,7 @@ static __thread uintptr_t start_sp; ++ #define peak_stack peak_use[1] ++ #define peak_total peak_use[2] ++ ++-#define DEFAULT_BUFFER_SIZE 1024 +++#define DEFAULT_BUFFER_SIZE 32768 ++ static size_t buffer_size; ++ ++ static int fd = -1; ++-- ++1.6.3.3 ++ +diff --git a/packages/glibc/2.9/0320-Fix-wrap-around-in-memusage.patch b/packages/glibc/2.9/0320-Fix-wrap-around-in-memusage.patch +new file mode 100644 +index 00000000..e07c9d92 +--- /dev/null ++++ b/packages/glibc/2.9/0320-Fix-wrap-around-in-memusage.patch +@@ -0,0 +1,37 @@ ++From 22bc5239e1c7d97b0642af6c135af994586f8e82 Mon Sep 17 00:00:00 2001 ++From: Andreas Schwab ++Date: Thu, 29 Oct 2009 11:25:20 -0700 ++Subject: [PATCH 3/3] Fix wrap-around in memusage. ++ ++--- ++ malloc/memusage.c | 9 +++++---- ++ 1 files changed, 5 insertions(+), 4 deletions(-) ++ ++diff --git a/malloc/memusage.c b/malloc/memusage.c ++index fcd58dc..382261c 100644 ++--- a/malloc/memusage.c +++++ b/malloc/memusage.c ++@@ -163,15 +163,16 @@ update_data (struct header *result, size_t len, size_t old_len) ++ if (fd != -1) ++ { ++ uatomic32_t idx = catomic_exchange_and_add (&buffer_cnt, 1); ++- if (idx >= 2 * buffer_size) +++ if (idx + 1 >= 2 * buffer_size) ++ { ++ /* We try to reset the counter to the correct range. If ++ this fails because of another thread increasing the ++ counter it does not matter since that thread will take ++ care of the correction. */ ++- uatomic32_t reset = idx % (2 * buffer_size); ++- catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx); ++- idx = reset; +++ uatomic32_t reset = (idx + 1) % (2 * buffer_size); +++ catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx + 1); +++ if (idx >= 2 * buffer_size) +++ idx = reset - 1; ++ } ++ assert (idx < 2 * DEFAULT_BUFFER_SIZE); ++ ++-- ++1.6.3.3 ++ +diff --git a/packages/glibc/2.9/chksum b/packages/glibc/2.9/chksum +new file mode 100644 +index 00000000..b620c50d +--- /dev/null ++++ b/packages/glibc/2.9/chksum +@@ -0,0 +1,8 @@ ++md5 glibc-2.9.tar.bz2 fc62e989cf31d015f31628609fc3757a ++sha1 glibc-2.9.tar.bz2 13de149245b84af770eddafe842acb208929352b ++sha256 glibc-2.9.tar.bz2 098baa84c74af5b21d27ec6e8ba6f1a393de88327cefbcd9e90c9b4edda9a36c ++sha512 glibc-2.9.tar.bz2 53af0d0c888d8beb0fa2729f32b605f2bd546bafe03de80805f25e7bc69189f7183d78f8e6465f553be4fc9846a500aaaafec24325e7cb88892fc918b886a6bb ++md5 glibc-2.9.tar.gz 21e4c70a6819c821b2a219e26fb414fb ++sha1 glibc-2.9.tar.gz 3f0f2b42dfba01649d524adea7761c0974566048 ++sha256 glibc-2.9.tar.gz e0210dec2a4ca0a03d8ee26e2a4ebccc915d99f4cdb1489ff0f9f4ce7bda3e30 ++sha512 glibc-2.9.tar.gz ff9888bc73479af52efb7d9da17e2a6f073e8105eabae406fe4d78bceaed3d6e00c11a18abbae8cc72465878fb7ed281803b56c61777bbd4df0337cfa8f671f4 +diff --git a/packages/glibc/2.9/version.desc b/packages/glibc/2.9/version.desc +new file mode 100644 +index 00000000..d2fdc339 +--- /dev/null ++++ b/packages/glibc/2.9/version.desc +@@ -0,0 +1,2 @@ ++# OpenPandora specific ++archive_formats='.tar.bz2 .tar.gz' +diff --git a/packages/linux/2.6.31/chksum b/packages/linux/2.6.31/chksum +new file mode 100644 +index 00000000..a200e054 +--- /dev/null ++++ b/packages/linux/2.6.31/chksum +@@ -0,0 +1,8 @@ ++md5 linux-2.6.31.tar.xz c6a901042a2dc9552bc6f475887a5ef3 ++sha1 linux-2.6.31.tar.xz df3dc6292aee9c993186adc14412fdd3b895944f ++sha256 linux-2.6.31.tar.xz 4ad0df33ca20f170fa0a05ad2bcf8fb18bf457aba7f909434ed13461c59be80a ++sha512 linux-2.6.31.tar.xz 0b9543896568af46bc62d6bdbc13104b449b52267c568fba016588f9da413f4e066cccbdbc92d8ffed2d2f6e5aa1ad29f07c67f1c6cea3b8905a1af52a2384d2 ++md5 linux-2.6.31.tar.gz 16c0355d3612806ef87addf7c9f8c9f9 ++sha1 linux-2.6.31.tar.gz 6b19c2987b0e2d74dcdca2aadebd5081bc143b72 ++sha256 linux-2.6.31.tar.gz 304eab47177ecd6964b587df1682c31d21e4c4bc2e6ebfa14218c85a76659bc7 ++sha512 linux-2.6.31.tar.gz 6152f4cacd68c7f8fedcd8fa89cb013135b9e368821a8d0fbd0bf13067bd89a51d37686414a5f8d4e46eb500dafc6f57ecdf6f3434c0f81838ecaac57fa654b2 +diff --git a/packages/linux/2.6.31/version.desc b/packages/linux/2.6.31/version.desc +new file mode 100644 +index 00000000..554d220c +--- /dev/null ++++ b/packages/linux/2.6.31/version.desc +@@ -0,0 +1,2 @@ ++# OpenPandora specific ++archive_formats='.tar.xz .tar.gz' diff --git a/toolchains/openpandora/packages/toolchain/patches/allow-root-build.patch b/toolchains/openpandora/packages/toolchain/patches/allow-root-build.patch new file mode 100644 index 0000000..c7bdb93 --- /dev/null +++ b/toolchains/openpandora/packages/toolchain/patches/allow-root-build.patch @@ -0,0 +1,18 @@ +diff --git a/config/global/ct-behave.in b/config/global/ct-behave.in +index 42171e4d..244a2d60 100644 +--- a/config/global/ct-behave.in ++++ b/config/global/ct-behave.in +@@ -32,5 +32,4 @@ config EXPERIMENTAL + config ALLOW_BUILD_AS_ROOT +- bool ++ def_bool y + prompt "Allow building as root user (READ HELP!)" +- depends on EXPERIMENTAL + help +@@ -57,6 +56,6 @@ config ALLOW_BUILD_AS_ROOT + + config ALLOW_BUILD_AS_ROOT_SURE +- bool ++ def_bool y + prompt "Are you sure?" + depends on ALLOW_BUILD_AS_ROOT diff --git a/toolchains/openpandora/packages/toolchain/patches/allow-static-libstdc++.patch b/toolchains/openpandora/packages/toolchain/patches/allow-static-libstdc++.patch new file mode 100644 index 0000000..ac7dea7 --- /dev/null +++ b/toolchains/openpandora/packages/toolchain/patches/allow-static-libstdc++.patch @@ -0,0 +1,31 @@ +Index: crosstool-ng/packages/gcc/8.3.0/9999-allow-static-libstdc++.patch +=================================================================== +--- /dev/null ++++ crosstool-ng/packages/gcc/8.3.0/9999-allow-static-libstdc++.patch +@@ -0,0 +1,26 @@ ++--- a/libstdc++-v3/configure.ac +++++ b/libstdc++-v3/configure.ac ++@@ -121,8 +121,8 @@ if test "$enable_shared" = yes; then ++ glibcxx_compiler_shared_flag="-D_GLIBCXX_SHARED" ++ ++ else ++- glibcxx_lt_pic_flag= ++- glibcxx_compiler_pic_flag= +++ glibcxx_lt_pic_flag="-prefer-pic" +++ glibcxx_compiler_pic_flag="$lt_prog_compiler_pic_CXX" ++ glibcxx_compiler_shared_flag= ++ fi ++ AC_SUBST(glibcxx_lt_pic_flag) ++--- a/libstdc++-v3/configure +++++ b/libstdc++-v3/configure ++@@ -15025,8 +15025,8 @@ if test "$enable_shared" = yes; then ++ glibcxx_compiler_shared_flag="-D_GLIBCXX_SHARED" ++ ++ else ++- glibcxx_lt_pic_flag= ++- glibcxx_compiler_pic_flag= +++ glibcxx_lt_pic_flag="-prefer-pic" +++ glibcxx_compiler_pic_flag="$lt_prog_compiler_pic_CXX" ++ glibcxx_compiler_shared_flag= ++ fi ++ diff --git a/toolchains/openpandora/packages/toolchain/patches/switch-back-eabi4.patch b/toolchains/openpandora/packages/toolchain/patches/switch-back-eabi4.patch new file mode 100644 index 0000000..d91dbb3 --- /dev/null +++ b/toolchains/openpandora/packages/toolchain/patches/switch-back-eabi4.patch @@ -0,0 +1,60 @@ +diff --git a/packages/binutils/2.32/9999-use-eabi4.patch b/packages/binutils/2.32/9999-use-eabi4.patch +new file mode 100644 +index 00000000..77bc0535 +--- /dev/null ++++ b/packages/binutils/2.32/9999-use-eabi4.patch +@@ -0,0 +1,35 @@ ++Index: binutils-2.32/gas/config/te-armeabi.h ++=================================================================== ++--- binutils-2.32.orig/gas/config/te-armeabi.h +++++ binutils-2.32/gas/config/te-armeabi.h ++@@ -19,7 +19,7 @@ ++ ++ /* The EABI requires the use of VFP. */ ++ #define FPU_DEFAULT FPU_ARCH_VFP ++-#define EABI_DEFAULT EF_ARM_EABI_VER5 +++#define EABI_DEFAULT EF_ARM_EABI_VER4 ++ ++ #define LOCAL_LABELS_DOLLAR 1 ++ #define LOCAL_LABELS_FB 1 ++Index: binutils-2.32/gas/config/te-armlinuxeabi.h ++=================================================================== ++--- binutils-2.32.orig/gas/config/te-armlinuxeabi.h +++++ binutils-2.32/gas/config/te-armlinuxeabi.h ++@@ -21,4 +21,4 @@ ++ ++ /* The EABI requires the use of VFP. */ ++ #define FPU_DEFAULT FPU_ARCH_VFP ++-#define EABI_DEFAULT EF_ARM_EABI_VER5 +++#define EABI_DEFAULT EF_ARM_EABI_VER4 ++Index: binutils-2.32/gas/config/te-nacl.h ++=================================================================== ++--- binutils-2.32.orig/gas/config/te-nacl.h +++++ binutils-2.32/gas/config/te-nacl.h ++@@ -25,6 +25,6 @@ ++ /* These are for ARM but don't hurt other CPU targets. ++ They match the settings from te-armeabi.h; NaCl/ARM is based on EABI. */ ++ #define FPU_DEFAULT FPU_ARCH_VFP ++-#define EABI_DEFAULT EF_ARM_EABI_VER5 +++#define EABI_DEFAULT EF_ARM_EABI_VER4 ++ ++ #include "obj-format.h" +diff --git a/packages/gcc/8.3.0/9998-use-eabi4.patch b/packages/gcc/8.3.0/9998-use-eabi4.patch +new file mode 100644 +index 00000000..0e311146 +--- /dev/null ++++ b/packages/gcc/8.3.0/9998-use-eabi4.patch +@@ -0,0 +1,13 @@ ++Index: gcc-8.3.0/gcc/config/arm/bpabi.h ++=================================================================== ++--- gcc-8.3.0.orig/gcc/config/arm/bpabi.h +++++ gcc-8.3.0/gcc/config/arm/bpabi.h ++@@ -64,7 +64,7 @@ ++ /* Tell the assembler to build BPABI binaries. */ ++ #undef SUBTARGET_EXTRA_ASM_SPEC ++ #define SUBTARGET_EXTRA_ASM_SPEC \ ++- "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=5}" TARGET_FIX_V4BX_SPEC +++ "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=4}" TARGET_FIX_V4BX_SPEC ++ ++ #ifndef SUBTARGET_EXTRA_LINK_SPEC ++ #define SUBTARGET_EXTRA_LINK_SPEC "" diff --git a/toolchains/openpandora/packages/tslib/build.sh b/toolchains/openpandora/packages/tslib/build.sh new file mode 100755 index 0000000..6145aa8 --- /dev/null +++ b/toolchains/openpandora/packages/tslib/build.sh @@ -0,0 +1,25 @@ +#! /bin/sh + +# Use the same version as the official toolchain +TSLIB_VERSION=1.0 + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch tslib "https://github.com/libts/tslib/archive/${TSLIB_VERSION}.tar.gz" 'tar xzf' + +# Remove configuration file and tests +sed -ie 's/^\(SUBDIRS.*\) etc\(.*\) tests/\1\2/' Makefile.am + +./autogen.sh + +do_configure_shared +do_make + +do_make install + +do_clean_bdir + diff --git a/toolchains/openpandora/packages/tslib/patches/fix-malloc.patch b/toolchains/openpandora/packages/tslib/patches/fix-malloc.patch new file mode 100644 index 0000000..291c800 --- /dev/null +++ b/toolchains/openpandora/packages/tslib/patches/fix-malloc.patch @@ -0,0 +1,12 @@ +diff --git a/configure.ac b/configure.ac +--- a/configure.ac ++++ b/configure.ac +@@ -43,7 +43,6 @@ AC_FUNC_SELECT_ARGTYPES + + # Checks for library functions. + AC_PROG_GCC_TRADITIONAL +-AC_FUNC_MALLOC + AC_FUNC_MMAP + AC_FUNC_SELECT_ARGTYPES + AC_TYPE_SIGNAL + diff --git a/toolchains/openpandora/packages/tslib/patches/fix-version.patch b/toolchains/openpandora/packages/tslib/patches/fix-version.patch new file mode 100644 index 0000000..d6a0ebd --- /dev/null +++ b/toolchains/openpandora/packages/tslib/patches/fix-version.patch @@ -0,0 +1,32 @@ +--- + configure.ac | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +Index: tslib-1.0/configure.ac +=================================================================== +--- tslib-1.0.orig/configure.ac 2006-08-24 22:02:55.000000000 +0100 ++++ tslib-1.0/configure.ac 2007-07-09 21:04:38.000000000 +0100 +@@ -2,7 +2,7 @@ + # Process this file with autoconf to produce a configure script. + + AC_PREREQ(2.57) +-AC_INIT(tslib, 0.0.2, kergoth@handhelds.org) ++AC_INIT(tslib, 1.0.0, kergoth@handhelds.org) + # AC_CONFIG_AUX_DIR(config) + AM_INIT_AUTOMAKE(dist-bzip2) + AC_CONFIG_SRCDIR([src/ts_close.c]) +@@ -193,10 +193,10 @@ TS_CONF='${sysconfdir}/ts.conf' + AC_SUBST(TS_CONF) + + # Library versioning +-LT_RELEASE=0.0 +-LT_CURRENT=1 +-LT_REVISION=1 +-LT_AGE=1 ++LT_RELEASE=1.0 ++LT_CURRENT=0 ++LT_REVISION=0 ++LT_AGE=0 + AC_SUBST(LT_RELEASE) + AC_SUBST(LT_CURRENT) + AC_SUBST(LT_REVISION) diff --git a/toolchains/openpandora/packages/x11/build.sh b/toolchains/openpandora/packages/x11/build.sh new file mode 100755 index 0000000..8adf446 --- /dev/null +++ b/toolchains/openpandora/packages/x11/build.sh @@ -0,0 +1,208 @@ +#! /bin/sh + +# Use same versions as OpenPandora toolchain +UTIL_MACROS_VERSION=1.7.0 +UTIL_MACROS_SHA256=7a5519ca22cd6bc4664be7b52cc58d5594e9f18c282ee0f6f7c59c1dffabdd13 + +BIGREQSPROTO_VERSION=1.1.0 +BIGREQSPROTO_SHA256=000703ba64664bd9018af88192062e7df8da30ed1939b4e7cbfd68baaa966390 + +KBPROTO_VERSION=1.0.4 +KBPROTO_SHA256=d7fcd4fa4332109b05f0d5e238e4aa0ef2ca1a51b45ab9fcf8affd7ee021cfe7 + +INPUTPROTO_VERSION=2.0 +INPUTPROTO_SHA256=cd89a1e95745875e66947ba28587c720c91aec63836ac6548ca12fd525c0a2ee + +RANDRPROTO_VERSION=1.3.1 +RANDRPROTO_SHA256=cdabd4d78b58ce4fd173793edc53d64e568f54da479e9b93e7c68185555af86f + +RENDERPROTO_VERSION=0.11 +RENDERPROTO_SHA256=256e4af1d3b4007872a276ed9e5c2522f80f5fe69b97268542917635b4dbf758 + +XCMISCPROTO_VERSION=1.2.0 +XCMISCPROTO_SHA256=3e7ebffc1cdf93b371aa0db90775a630f66c3a77815059992c7b2789f119273e + +XEXTPROTO_VERSION=7.1.1 +XEXTPROTO_SHA256=5ade284271eed437b05829be336b2b0ddaabad48335be220c0d9d5101fd8baec + +XF86BIGFONTPROTO_VERSION=1.2.0 +XF86BIGFONTPROTO_SHA256=d190e6462b2bbbac6ee9a007fb8eccb9ad9f5f70544154f388266f031d4bbb23 + +XPROTO_VERSION=7.0.16 +XPROTO_SHA256=996eb41d9ec3ddcea503f12230ea5fbb8ca36a9fa9facb241dacf063468d9972 + +XTRANS_VERSION=1.2.5 +XTRANS_SHA256=97d76ab76c755fabf2ef1896aaa76c0e38fc58d92799f9b2dd885a535cdd1e2b + +LIBXAU_VERSION=1.0.5 +LIBXAU_SHA256=2ad4324cf204331d6773bba441baed58e46168e7913de2079f10b272eae5c4db + +LIBXDMCP_VERSION=1.0.3 +LIBXDMCP_SHA256=ac6fb3182d50c5e2b1723a09eb77593602a7e64d7d501ea90a79edc26acb87b2 + +LIBX11_VERSION=1.3.3 +LIBX11_SHA256=91274846aebcc9b1867d051c87833ef8f1a1ebe372b675373dd2a744360a8734 + +LIBXEXT_VERSION=1.1.1 +LIBXEXT_SHA256=e3149cffe6f26ec1fe5022bc582e8621cc26d718b6d712c79b4619af39812db9 + +LIBXRENDER_VERSION=0.9.5 +LIBXRENDER_SHA256=1f8b12a94ede6d5c9c7f34a137da9f88504ae16b69f76d03e429e2920c840a20 + +LIBXRANDR_VERSION=1.3.0 +LIBXRANDR_SHA256=c2a7cfeb8506734bca4c23321c1ba5d9e6f9b1bd2f2434033a6bd9eea6814b7a + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +BDIR=$(pwd) + +do_xorg_fetch () { + cd "$BDIR" + + varname=$(echo $2 | tr a-z- A-Z_) + eval "local pkg_VERSION=\$${varname}_VERSION" + eval "local pkg_SHA256=\$${varname}_SHA256" + + do_http_fetch $2 "https://www.x.org/releases/individual/$1/$2-$pkg_VERSION.tar.gz" \ + 'tar xzf' "sha256:$pkg_SHA256" +} + +# util-macros +do_xorg_fetch util util-macros + +# Patch pkg-config directory +sed -ie 's/^\(pkgconfigdir .*\)\$(datadir)/\1$(libdir)/' Makefile.in + +do_configure_shared +do_make +do_make install + +# bigreqsproto +do_xorg_fetch proto bigreqsproto +do_configure_shared +do_make +do_make install + +# kbproto +do_xorg_fetch proto kbproto +do_configure_shared +do_make +do_make install + +# inputproto +do_xorg_fetch proto inputproto +do_configure_shared +do_make +do_make install + +# randrproto +do_xorg_fetch proto randrproto +do_configure_shared +do_make +# No doc +do_make install-pkgconfigDATA \ + install-randrHEADERS + +# renderproto +do_xorg_fetch proto renderproto +do_configure_shared +do_make +do_make install-pkgconfigDATA \ + install-renderHEADERS + +# xcmiscproto +do_xorg_fetch proto xcmiscproto +do_configure_shared +do_make +do_make install + +# xextproto +do_xorg_fetch proto xextproto +do_configure_shared +do_make +do_make install + +# xf86bigfontproto +do_xorg_fetch proto xf86bigfontproto +do_configure_shared +do_make +do_make install + +# xproto +do_xorg_fetch proto xproto +do_configure_shared +do_make +do_make install + +# xtrans +do_xorg_fetch lib xtrans + +# Patch pkg-config directory +sed -ie 's/^\(pkgconfigdir .*\)\$(datadir)/\1$(libdir)/' Makefile.in + +do_configure_shared --disable-docs +do_make +# No docs +do_make install-XtransincludeHEADERS \ + install-aclocalDATA \ + install-pkgconfigDATA + +# libXau +do_xorg_fetch lib libXau +do_configure_shared +do_make +do_make install-libLTLIBRARIES \ + install-pkgconfigDATA \ + install-xauincludeHEADERS + +# libXdmcp +do_xorg_fetch lib libXdmcp +do_configure_shared +do_make +do_make install-libLTLIBRARIES \ + install-pkgconfigDATA \ + install-xdmcpincludeHEADERS + +# libX11 +do_xorg_fetch lib libX11 +do_configure_shared --without-xcb +do_make + +# Just install the bare minimum +do_make install-pkgconfigDATA +do_make -C src install +do_make -C include install + +# libXext +do_xorg_fetch lib libXext +do_configure_shared --disable-malloc0returnsnull +do_make + +# No man pages +do_make install-pkgconfigDATA +do_make -C src install-libLTLIBRARIES \ + install-libXextincludeHEADERS + +# libXrender +do_xorg_fetch lib libXrender +do_configure_shared --disable-malloc0returnsnull +do_make + +# No man pages +do_make -C src install +do_make install-pkgconfigDATA + +# libXrandr +do_xorg_fetch lib libXrandr +do_configure_shared --disable-malloc0returnsnull +do_make + +# No man pages +do_make -C src install +do_make install-pkgconfigDATA + +do_clean_bdir diff --git a/toolchains/openpandora/packages/zlib/build.sh b/toolchains/openpandora/packages/zlib/build.sh new file mode 100755 index 0000000..ca594c4 --- /dev/null +++ b/toolchains/openpandora/packages/zlib/build.sh @@ -0,0 +1,21 @@ +#! /bin/sh + +# OpenPandora firmware uses zlib 1.2.3 stick with it +ZLIB_VERSION=1.2.3 +ZLIB_SHA256=1795c7d067a43174113fdf03447532f373e1c6c57c08d61d9e4e9be5e244b05e + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_http_fetch zlib "http://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" 'tar xzf' "sha256:${ZLIB_SHA256}" + +# Enable shared objects +# There is a bug in configure script when AR is specified, it eats the rc argument +AR="$AR rc" ./configure --prefix=$PREFIX --shared +do_make +do_make install + +do_clean_bdir diff --git a/toolchains/openpandora/packages/zlib/patches/visibility.patch b/toolchains/openpandora/packages/zlib/patches/visibility.patch new file mode 100644 index 0000000..797274d --- /dev/null +++ b/toolchains/openpandora/packages/zlib/patches/visibility.patch @@ -0,0 +1,955 @@ + +# +# Patch managed by http://www.holgerschurig.de/patcher.html +# + +--- zlib-1.2.3-orig/adler32.c~visibility ++++ zlib-1.2.3-orig/adler32.c +@@ -54,7 +54,7 @@ + #endif + + /* ========================================================================= */ +-uLong ZEXPORT adler32(adler, buf, len) ++ZEXPORT uLong adler32(adler, buf, len) + uLong adler; + const Bytef *buf; + uInt len; +--- zlib-1.2.3-orig/compress.c~visibility ++++ zlib-1.2.3-orig/compress.c +@@ -19,7 +19,7 @@ + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. + */ +-int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) ++ZEXPORT int compress2 (dest, destLen, source, sourceLen, level) + Bytef *dest; + uLongf *destLen; + const Bytef *source; +@@ -59,7 +59,7 @@ + + /* =========================================================================== + */ +-int ZEXPORT compress (dest, destLen, source, sourceLen) ++ZEXPORT int compress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; +@@ -72,7 +72,7 @@ + If the default memLevel or windowBits for deflateInit() is changed, then + this function needs to be updated. + */ +-uLong ZEXPORT compressBound (sourceLen) ++ZEXPORT uLong compressBound (sourceLen) + uLong sourceLen; + { + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; +--- zlib-1.2.3-orig/crc32.c~visibility ++++ zlib-1.2.3-orig/crc32.c +@@ -202,7 +202,7 @@ + /* ========================================================================= + * This function can be used by asm versions of crc32() + */ +-const unsigned long FAR * ZEXPORT get_crc_table() ++ZEXPORT const unsigned long FAR * get_crc_table() + { + #ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) +@@ -216,7 +216,7 @@ + #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 + + /* ========================================================================= */ +-unsigned long ZEXPORT crc32(crc, buf, len) ++ZEXPORT unsigned long crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +--- zlib-1.2.3-orig/deflate.c~visibility ++++ zlib-1.2.3-orig/deflate.c +@@ -201,7 +201,7 @@ + zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + + /* ========================================================================= */ +-int ZEXPORT deflateInit_(strm, level, version, stream_size) ++ZEXPORT int deflateInit_(strm, level, version, stream_size) + z_streamp strm; + int level; + const char *version; +@@ -213,7 +213,7 @@ + } + + /* ========================================================================= */ +-int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, ++ZEXPORT int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + version, stream_size) + z_streamp strm; + int level; +@@ -312,7 +312,7 @@ + } + + /* ========================================================================= */ +-int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) ++ZEXPORT int deflateSetDictionary (strm, dictionary, dictLength) + z_streamp strm; + const Bytef *dictionary; + uInt dictLength; +@@ -354,7 +354,7 @@ + } + + /* ========================================================================= */ +-int ZEXPORT deflateReset (strm) ++ZEXPORT int deflateReset (strm) + z_streamp strm; + { + deflate_state *s; +@@ -401,7 +401,7 @@ + } + + /* ========================================================================= */ +-int ZEXPORT deflatePrime (strm, bits, value) ++ZEXPORT int deflatePrime (strm, bits, value) + z_streamp strm; + int bits; + int value; +@@ -413,7 +413,7 @@ + } + + /* ========================================================================= */ +-int ZEXPORT deflateParams(strm, level, strategy) ++ZEXPORT int deflateParams(strm, level, strategy) + z_streamp strm; + int level; + int strategy; +@@ -486,7 +486,7 @@ + * But even the conservative upper bound of about 14% expansion does not + * seem onerous for output buffer allocation. + */ +-uLong ZEXPORT deflateBound(strm, sourceLen) ++ZEXPORT uLong deflateBound(strm, sourceLen) + z_streamp strm; + uLong sourceLen; + { +@@ -549,7 +549,7 @@ + } + + /* ========================================================================= */ +-int ZEXPORT deflate (strm, flush) ++ZEXPORT int deflate (strm, flush) + z_streamp strm; + int flush; + { +@@ -856,7 +856,7 @@ + } + + /* ========================================================================= */ +-int ZEXPORT deflateEnd (strm) ++ZEXPORT int deflateEnd (strm) + z_streamp strm; + { + int status; +@@ -891,7 +891,7 @@ + * To simplify the source, this is not supported for 16-bit MSDOS (which + * doesn't have enough memory anyway to duplicate compression states). + */ +-int ZEXPORT deflateCopy (dest, source) ++ZEXPORT int deflateCopy (dest, source) + z_streamp dest; + z_streamp source; + { +--- zlib-1.2.3-orig/gzio.c~visibility ++++ zlib-1.2.3-orig/gzio.c +@@ -205,7 +205,7 @@ + /* =========================================================================== + Opens a gzip (.gz) file for reading or writing. + */ +-gzFile ZEXPORT gzopen (path, mode) ++ZEXPORT gzFile gzopen (path, mode) + const char *path; + const char *mode; + { +@@ -216,7 +216,7 @@ + Associate a gzFile with the file descriptor fd. fd is not dup'ed here + to mimic the behavio(u)r of fdopen. + */ +-gzFile ZEXPORT gzdopen (fd, mode) ++ZEXPORT gzFile gzdopen (fd, mode) + int fd; + const char *mode; + { +@@ -231,7 +231,7 @@ + /* =========================================================================== + * Update the compression level and strategy + */ +-int ZEXPORT gzsetparams (file, level, strategy) ++ZEXPORT int gzsetparams (file, level, strategy) + gzFile file; + int level; + int strategy; +@@ -391,7 +391,7 @@ + Reads the given number of uncompressed bytes from the compressed file. + gzread returns the number of bytes actually read (0 for end of file). + */ +-int ZEXPORT gzread (file, buf, len) ++ZEXPORT int gzread (file, buf, len) + gzFile file; + voidp buf; + unsigned len; +@@ -500,7 +500,7 @@ + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. + */ +-int ZEXPORT gzgetc(file) ++ZEXPORT int gzgetc(file) + gzFile file; + { + unsigned char c; +@@ -512,7 +512,7 @@ + /* =========================================================================== + Push one byte back onto the stream. + */ +-int ZEXPORT gzungetc(c, file) ++ZEXPORT int gzungetc(c, file) + int c; + gzFile file; + { +@@ -537,7 +537,7 @@ + + The current implementation is not optimized at all. + */ +-char * ZEXPORT gzgets(file, buf, len) ++ZEXPORT char * gzgets(file, buf, len) + gzFile file; + char *buf; + int len; +@@ -556,7 +556,7 @@ + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of bytes actually written (0 in case of error). + */ +-int ZEXPORT gzwrite (file, buf, len) ++ZEXPORT int gzwrite (file, buf, len) + gzFile file; + voidpc buf; + unsigned len; +@@ -600,7 +600,7 @@ + #ifdef STDC + #include + +-int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) ++ZEXPORTVA int gzprintf (gzFile file, const char *format, /* args */ ...) + { + char buf[Z_PRINTF_BUFSIZE]; + va_list va; +@@ -634,7 +634,7 @@ + } + #else /* not ANSI C */ + +-int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ++ZEXPORT intVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) + gzFile file; + const char *format; +@@ -675,7 +675,7 @@ + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. + */ +-int ZEXPORT gzputc(file, c) ++ZEXPORT int gzputc(file, c) + gzFile file; + int c; + { +@@ -690,7 +690,7 @@ + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. + */ +-int ZEXPORT gzputs(file, s) ++ZEXPORT int gzputs(file, s) + gzFile file; + const char *s; + { +@@ -743,7 +743,7 @@ + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; + } + +-int ZEXPORT gzflush (file, flush) ++ZEXPORT int gzflush (file, flush) + gzFile file; + int flush; + { +@@ -764,7 +764,7 @@ + SEEK_END is not implemented, returns error. + In this version of the library, gzseek can be extremely slow. + */ +-z_off_t ZEXPORT gzseek (file, offset, whence) ++ZEXPORT z_off_t gzseek (file, offset, whence) + gzFile file; + z_off_t offset; + int whence; +@@ -854,7 +854,7 @@ + /* =========================================================================== + Rewinds input file. + */ +-int ZEXPORT gzrewind (file) ++ZEXPORT int gzrewind (file) + gzFile file; + { + gz_stream *s = (gz_stream*)file; +@@ -878,7 +878,7 @@ + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + */ +-z_off_t ZEXPORT gztell (file) ++ZEXPORT z_off_t gztell (file) + gzFile file; + { + return gzseek(file, 0L, SEEK_CUR); +@@ -888,7 +888,7 @@ + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. + */ +-int ZEXPORT gzeof (file) ++ZEXPORT int gzeof (file) + gzFile file; + { + gz_stream *s = (gz_stream*)file; +@@ -950,7 +950,7 @@ + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. + */ +-int ZEXPORT gzclose (file) ++ZEXPORT int gzclose (file) + gzFile file; + { + gz_stream *s = (gz_stream*)file; +@@ -984,7 +984,7 @@ + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. + */ +-const char * ZEXPORT gzerror (file, errnum) ++ZEXPORT const char * gzerror (file, errnum) + gzFile file; + int *errnum; + { +@@ -1014,7 +1014,7 @@ + /* =========================================================================== + Clear the error and end-of-file flags, and do the same for the real file. + */ +-void ZEXPORT gzclearerr (file) ++ZEXPORT void gzclearerr (file) + gzFile file; + { + gz_stream *s = (gz_stream*)file; +--- zlib-1.2.3-orig/infback.c~visibility ++++ zlib-1.2.3-orig/infback.c +@@ -25,7 +25,7 @@ + windowBits is in the range 8..15, and window is a user-supplied + window and output buffer that is 2**windowBits bytes. + */ +-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) ++ZEXPORT int inflateBackInit_(strm, windowBits, window, version, stream_size) + z_streamp strm; + int windowBits; + unsigned char FAR *window; +@@ -238,7 +238,7 @@ + inflateBack() can also return Z_STREAM_ERROR if the input parameters + are not correct, i.e. strm is Z_NULL or the state was not initialized. + */ +-int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) ++ZEXPORT int inflateBack(strm, in, in_desc, out, out_desc) + z_streamp strm; + in_func in; + void FAR *in_desc; +@@ -611,7 +611,7 @@ + return ret; + } + +-int ZEXPORT inflateBackEnd(strm) ++ZEXPORT int inflateBackEnd(strm) + z_streamp strm; + { + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) +--- zlib-1.2.3-orig/inflate.c~visibility ++++ zlib-1.2.3-orig/inflate.c +@@ -100,7 +100,7 @@ + local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, + unsigned len)); + +-int ZEXPORT inflateReset(strm) ++ZEXPORT int inflateReset(strm) + z_streamp strm; + { + struct inflate_state FAR *state; +@@ -141,7 +141,7 @@ + return Z_OK; + } + +-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) ++ZEXPORT int inflateInit2_(strm, windowBits, version, stream_size) + z_streamp strm; + int windowBits; + const char *version; +@@ -184,7 +184,7 @@ + return inflateReset(strm); + } + +-int ZEXPORT inflateInit_(strm, version, stream_size) ++ZEXPORT int inflateInit_(strm, version, stream_size) + z_streamp strm; + const char *version; + int stream_size; +@@ -551,7 +551,7 @@ + will return Z_BUF_ERROR if it has not reached the end of the stream. + */ + +-int ZEXPORT inflate(strm, flush) ++ZEXPORT int inflate(strm, flush) + z_streamp strm; + int flush; + { +@@ -1152,7 +1152,7 @@ + return ret; + } + +-int ZEXPORT inflateEnd(strm) ++ZEXPORT int inflateEnd(strm) + z_streamp strm; + { + struct inflate_state FAR *state; +@@ -1166,7 +1166,7 @@ + return Z_OK; + } + +-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) ++ZEXPORT int inflateSetDictionary(strm, dictionary, dictLength) + z_streamp strm; + const Bytef *dictionary; + uInt dictLength; +@@ -1259,7 +1259,7 @@ + return next; + } + +-int ZEXPORT inflateSync(strm) ++ZEXPORT int inflateSync(strm) + z_streamp strm; + { + unsigned len; /* number of bytes to look at or looked at */ +@@ -1310,7 +1310,7 @@ + block. When decompressing, PPP checks that at the end of input packet, + inflate is waiting for these length bytes. + */ +-int ZEXPORT inflateSyncPoint(strm) ++ZEXPORT int inflateSyncPoint(strm) + z_streamp strm; + { + struct inflate_state FAR *state; +@@ -1320,7 +1320,7 @@ + return state->mode == STORED && state->bits == 0; + } + +-int ZEXPORT inflateCopy(dest, source) ++ZEXPORT int inflateCopy(dest, source) + z_streamp dest; + z_streamp source; + { +--- zlib-1.2.3-orig/uncompr.c~visibility ++++ zlib-1.2.3-orig/uncompr.c +@@ -23,7 +23,7 @@ + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. + */ +-int ZEXPORT uncompress (dest, destLen, source, sourceLen) ++ZEXPORT int uncompress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; +--- zlib-1.2.3-orig/zlib.h~visibility ++++ zlib-1.2.3-orig/zlib.h +@@ -209,7 +209,7 @@ + + /* basic functions */ + +-ZEXTERN const char * ZEXPORT zlibVersion OF((void)); ++ZEXTERN ZEXPORT const char * zlibVersion OF((void)); + /* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. +@@ -217,7 +217,7 @@ + */ + + /* +-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); ++ZEXTERN ZEXPORT int deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. +@@ -239,7 +239,7 @@ + */ + + +-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); ++ZEXTERN ZEXPORT int deflate OF((z_streamp strm, int flush)); + /* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some +@@ -325,7 +325,7 @@ + */ + + +-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); ++ZEXTERN ZEXPORT int deflateEnd OF((z_streamp strm)); + /* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any +@@ -340,7 +340,7 @@ + + + /* +-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); ++ZEXTERN ZEXPORT int inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by +@@ -360,7 +360,7 @@ + */ + + +-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); ++ZEXTERN ZEXPORT int inflate OF((z_streamp strm, int flush)); + /* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce +@@ -459,7 +459,7 @@ + */ + + +-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); ++ZEXTERN ZEXPORT int inflateEnd OF((z_streamp strm)); + /* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any +@@ -477,7 +477,7 @@ + */ + + /* +-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, ++ZEXTERN ZEXPORT int deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, +@@ -535,7 +535,7 @@ + not perform any compression: this will be done by deflate(). + */ + +-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, ++ZEXTERN ZEXPORT int deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); + /* +@@ -574,7 +574,7 @@ + perform any compression: this will be done by deflate(). + */ + +-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, ++ZEXTERN ZEXPORT int deflateCopy OF((z_streamp dest, + z_streamp source)); + /* + Sets the destination stream as a complete copy of the source stream. +@@ -592,7 +592,7 @@ + destination. + */ + +-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); ++ZEXTERN ZEXPORT int deflateReset OF((z_streamp strm)); + /* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. +@@ -603,7 +603,7 @@ + stream state was inconsistent (such as zalloc or state being NULL). + */ + +-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, ++ZEXTERN ZEXPORT int deflateParams OF((z_streamp strm, + int level, + int strategy)); + /* +@@ -641,7 +641,7 @@ + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, ++ZEXTERN ZEXPORT uLong deflateBound OF((z_streamp strm, + uLong sourceLen)); + /* + deflateBound() returns an upper bound on the compressed size after +@@ -650,7 +650,7 @@ + for deflation in a single pass, and so would be called before deflate(). + */ + +-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, ++ZEXTERN ZEXPORT int deflatePrime OF((z_streamp strm, + int bits, + int value)); + /* +@@ -691,7 +691,7 @@ + */ + + /* +-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, ++ZEXTERN ZEXPORT int inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The +@@ -733,7 +733,7 @@ + and avail_out are unchanged.) + */ + +-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, ++ZEXTERN ZEXPORT int inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); + /* +@@ -755,7 +755,7 @@ + inflate(). + */ + +-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); ++ZEXTERN ZEXPORT int inflateSync OF((z_streamp strm)); + /* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all +@@ -770,7 +770,7 @@ + until success or end of the input data. + */ + +-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, ++ZEXTERN ZEXPORT int inflateCopy OF((z_streamp dest, + z_streamp source)); + /* + Sets the destination stream as a complete copy of the source stream. +@@ -786,7 +786,7 @@ + destination. + */ + +-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); ++ZEXTERN ZEXPORT int inflateReset OF((z_streamp strm)); + /* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. +@@ -853,7 +853,7 @@ + */ + + /* +-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, ++ZEXTERN ZEXPORT int inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() +@@ -877,7 +877,7 @@ + typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); + typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, ++ZEXTERN ZEXPORT int inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); + /* +@@ -946,7 +946,7 @@ + that inflateBack() cannot return Z_OK. + */ + +-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); ++ZEXTERN ZEXPORT int inflateBackEnd OF((z_streamp strm)); + /* + All memory allocated by inflateBackInit() is freed. + +@@ -954,7 +954,7 @@ + state was inconsistent. + */ + +-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); ++ZEXTERN ZEXPORT uLong zlibCompileFlags OF((void)); + /* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: +@@ -1006,7 +1006,7 @@ + utility functions can easily be modified if you need special options. + */ + +-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, ++ZEXTERN ZEXPORT int compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); + /* + Compresses the source buffer into the destination buffer. sourceLen is +@@ -1021,7 +1021,7 @@ + buffer. + */ + +-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, ++ZEXTERN ZEXPORT int compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); + /* +@@ -1037,14 +1037,14 @@ + Z_STREAM_ERROR if the level parameter is invalid. + */ + +-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); ++ZEXTERN ZEXPORT uLong compressBound OF((uLong sourceLen)); + /* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. + */ + +-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, ++ZEXTERN ZEXPORT int uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); + /* + Decompresses the source buffer into the destination buffer. sourceLen is +@@ -1065,7 +1065,7 @@ + + typedef voidp gzFile; + +-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); ++ZEXTERN ZEXPORT gzFile gzopen OF((const char *path, const char *mode)); + /* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level +@@ -1082,7 +1082,7 @@ + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); ++ZEXTERN ZEXPORT gzFile gzdopen OF((int fd, const char *mode)); + /* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or +@@ -1095,7 +1095,7 @@ + the (de)compression state. + */ + +-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); ++ZEXTERN ZEXPORT int gzsetparams OF((gzFile file, int level, int strategy)); + /* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. +@@ -1103,7 +1103,7 @@ + opened for writing. + */ + +-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); ++ZEXTERN ZEXPORT int gzread OF((gzFile file, voidp buf, unsigned len)); + /* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number +@@ -1111,7 +1111,7 @@ + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +-ZEXTERN int ZEXPORT gzwrite OF((gzFile file, ++ZEXTERN ZEXPORT int gzwrite OF((gzFile file, + voidpc buf, unsigned len)); + /* + Writes the given number of uncompressed bytes into the compressed file. +@@ -1119,7 +1119,7 @@ + (0 in case of error). + */ + +-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); ++ZEXTERN ZEXPORTVA int gzprintf OF((gzFile file, const char *format, ...)); + /* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of +@@ -1132,14 +1132,14 @@ + because the secure snprintf() or vsnprintf() functions were not available. + */ + +-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); ++ZEXTERN ZEXPORT int gzputs OF((gzFile file, const char *s)); + /* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. + */ + +-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); ++ZEXTERN ZEXPORT char * gzgets OF((gzFile file, char *buf, int len)); + /* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file +@@ -1148,19 +1148,19 @@ + gzgets returns buf, or Z_NULL in case of error. + */ + +-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); ++ZEXTERN ZEXPORT int gzputc OF((gzFile file, int c)); + /* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. + */ + +-ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); ++ZEXTERN ZEXPORT int gzgetc OF((gzFile file)); + /* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. + */ + +-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); ++ZEXTERN ZEXPORT int gzungetc OF((int c, gzFile file)); + /* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the +@@ -1170,7 +1170,7 @@ + or gzrewind(). + */ + +-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); ++ZEXTERN ZEXPORT int gzflush OF((gzFile file, int flush)); + /* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib +@@ -1180,7 +1180,7 @@ + degrade compression. + */ + +-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, ++ZEXTERN ZEXPORT z_off_t gzseek OF((gzFile file, + z_off_t offset, int whence)); + /* + Sets the starting position for the next gzread or gzwrite on the +@@ -1198,14 +1198,14 @@ + would be before the current position. + */ + +-ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); ++ZEXTERN ZEXPORT int gzrewind OF((gzFile file)); + /* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) + */ + +-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); ++ZEXTERN ZEXPORT z_off_t gztell OF((gzFile file)); + /* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the +@@ -1214,26 +1214,26 @@ + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) + */ + +-ZEXTERN int ZEXPORT gzeof OF((gzFile file)); ++ZEXTERN ZEXPORT int gzeof OF((gzFile file)); + /* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. + */ + +-ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); ++ZEXTERN ZEXPORT int gzdirect OF((gzFile file)); + /* + Returns 1 if file is being read directly without decompression, otherwise + zero. + */ + +-ZEXTERN int ZEXPORT gzclose OF((gzFile file)); ++ZEXTERN ZEXPORT int gzclose OF((gzFile file)); + /* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). + */ + +-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); ++ZEXTERN ZEXPORT const char * gzerror OF((gzFile file, int *errnum)); + /* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an +@@ -1242,7 +1242,7 @@ + to get the exact error code. + */ + +-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); ++ZEXTERN ZEXPORT void gzclearerr OF((gzFile file)); + /* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip +@@ -1257,7 +1257,7 @@ + compression library. + */ + +-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); ++ZEXTERN ZEXPORT uLong adler32 OF((uLong adler, const Bytef *buf, uInt len)); + /* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns +@@ -1282,7 +1282,7 @@ + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. + */ + +-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); ++ZEXTERN ZEXPORT uLong crc32 OF((uLong crc, const Bytef *buf, uInt len)); + /* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial +@@ -1314,17 +1314,17 @@ + /* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, ++ZEXTERN ZEXPORT int deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, ++ZEXTERN ZEXPORT int inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, ++ZEXTERN ZEXPORT int deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, ++ZEXTERN ZEXPORT int inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, ++ZEXTERN ZEXPORT int inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +@@ -1346,9 +1346,9 @@ + struct internal_state {int dummy;}; /* hack for buggy compilers */ + #endif + +-ZEXTERN const char * ZEXPORT zError OF((int)); +-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +-ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); ++ZEXTERN ZEXPORT const char * zError OF((int)); ++ZEXTERN ZEXPORT int inflateSyncPoint OF((z_streamp z)); ++ZEXTERN ZEXPORT const uLongf * get_crc_table OF((void)); + + #ifdef __cplusplus + } +--- zlib-1.2.3-orig/zutil.c~visibility ++++ zlib-1.2.3-orig/zutil.c +@@ -24,12 +24,12 @@ + ""}; + + +-const char * ZEXPORT zlibVersion() ++ZEXPORT const char * zlibVersion() + { + return ZLIB_VERSION; + } + +-uLong ZEXPORT zlibCompileFlags() ++ZEXPORT uLong zlibCompileFlags() + { + uLong flags; + +@@ -130,7 +130,7 @@ + /* exported to allow conversion of error code to string for compress() and + * uncompress() + */ +-const char * ZEXPORT zError(err) ++ZEXPORT const char * zError(err) + int err; + { + return ERR_MSG(err); diff --git a/workers/openpandora/Dockerfile.m4 b/workers/openpandora/Dockerfile.m4 new file mode 100644 index 0000000..0644de3 --- /dev/null +++ b/workers/openpandora/Dockerfile.m4 @@ -0,0 +1,32 @@ +FROM toolchains/openpandora AS toolchain + +m4_include(`paths.m4')m4_dnl + +m4_include(`debian-builder-base.m4')m4_dnl + +ENV TOOLCHAIN=/opt/openpandora HOST=arm-angstrom-linux-gnueabi + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + bzip2 \ + libxml2-utils \ + squashfs-tools && \ + rm -rf /var/lib/apt/lists/* + +COPY --from=toolchain $TOOLCHAIN $TOOLCHAIN/ + +ENV PREFIX=${TOOLCHAIN}/${HOST}/sysroot/usr + +# We add PATH here for *-config and platform specific binaries +ENV \ + def_binaries(`${TOOLCHAIN}/bin/${HOST}-', `ar, as, c++filt, ld, nm, objcopy, objdump, ranlib, readelf, strings, strip') \ + def_binaries(`${TOOLCHAIN}/bin/${HOST}-', `gcc, cpp, c++') \ + CC=${TOOLCHAIN}/bin/$HOST-gcc \ + def_aclocal(`${PREFIX}') \ + def_pkg_config(`${PREFIX}') \ + PATH=$PATH:${PREFIX}/bin + +# To please OpenPandora port makefile +RUN mkdir -p ${TOOLCHAIN}/${HOST}/usr/lib && ln -s ${PREFIX}/lib/libFLAC.so.8.2.0 ${TOOLCHAIN}/${HOST}/usr/lib + +m4_include(`run-buildbot.m4')m4_dnl