Skip to content

Commit

Permalink
Switch to the Linaro compiler toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Jul 15, 2019
1 parent 9b93428 commit 666bd27
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
/src/wrapper/*.so
/src/wrapper/*.dylib
/dist
/plato-*.zip
/thirdparty/*/*
!/thirdparty/*/*kobo*
11 changes: 2 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ set -e

method=${*:-"fast"}

[ -d libs ] && method=skip
[ -e libs/libz.so ] && method=skip

case "$method" in
fast)
version=$(cargo pkgid | cut -d '#' -f 2)
archive="plato-${version}.zip"
info_url="https://github.com/baskerville/plato/releases/tag/${version}"
echo "Downloading ${archive}."
release_url=$(wget -q -O - "$info_url" | grep -Eo "https[^\"]+files[^\"]+${archive}")
wget -q "$release_url"
unzip "$archive" 'libs/*' 'bin/*' 'hyphenation-patterns/*'
rm "$archive"
./download.sh 'libs/*'
cd libs

ln -s libz.so.1 libz.so
Expand Down
9 changes: 3 additions & 6 deletions dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

[ -d dist ] && rm -Rf dist

if ! [ -x thirdparty/chrpath/chrpath ] ; then
cd thirdparty/chrpath
./configure && make
cd ../..
fi
[ -d bin ] || ./download.sh 'bin/*'
[ -d hyphenation-patterns ] || ./download.sh 'hyphenation-patterns/*'

mkdir -p dist/libs

Expand All @@ -33,6 +30,6 @@ cp -R fonts dist
cp -R css dist
cp target/arm-unknown-linux-gnueabihf/release/plato dist/

./thirdparty/chrpath/chrpath -d dist/libs/*
patchelf --remove-rpath dist/libs/*

arm-linux-gnueabihf-strip dist/plato dist/libs/*
10 changes: 2 additions & 8 deletions doc/BUILD.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
## Preliminary

Install [Ubuntu 14.04.5](http:https://releases.ubuntu.com/14.04.5/).
Install the appropriate [compiler toolchain](https:https://github.com/kobolabs/Kobo-Reader/tree/master/toolchain) (the binaries of the `bin` directory need to be in your path).

Install the required packages:
```sh
sudo apt-get upgrade
sudo apt-get install curl git libtool {auto,c}make ragel
sudo apt-get install {zlib1g,libjpeg8,libjbig2dec0}-dev
sudo apt-get install g{cc,++}-arm-linux-gnueabihf
```
Install the required dependencies: `curl`, `git` `libtool` `automake`, `pkg-config`, `cmake` `ragel`, `jq`, `patchelf`.

Install *rustup*:
```sh
Expand Down
11 changes: 11 additions & 0 deletions download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/sh

version=$(cargo pkgid | cut -d '#' -f 2)
archive="plato-${version}.zip"
if ! [ -e "$archive" ] ; then
info_url="https://api.github.com/repos/baskerville/plato/releases/tags/${version}"
echo "Downloading ${archive}."
release_url=$(wget -q -O - "$info_url" | jq -r ".assets[] | select(.name == \"$archive\").browser_download_url")
wget -q "$release_url"
fi
unzip "$archive" "$@"
2 changes: 1 addition & 1 deletion src/wrapper/build-kobo.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#! /bin/sh

CFLAGS="-I../../thirdparty/mupdf/include" CC=arm-linux-gnueabihf-gcc AR=arm-linux-gnueabihf-ar ./build.sh
TARGET_OS=Kobo CFLAGS="-I../../thirdparty/mupdf/include" CC=arm-linux-gnueabihf-gcc AR=arm-linux-gnueabihf-ar ./build.sh
2 changes: 1 addition & 1 deletion src/wrapper/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
CC=${CC:-gcc}
LD=${LD:-ld}

TARGET_OS=$(uname -s)
TARGET_OS=${TARGET_OS:-$(uname -s)}
if [ "$TARGET_OS" = "Darwin" ] ; then
LIB_EXT=dylib
else
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/djvulibre/build-kobo.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /bin/sh

TRIPLE=arm-linux-gnueabihf
JPEG_DIR=$(readlink -f ../libjpeg)
JPEG_DIR=$(realpath ../libjpeg)
export CFLAGS="-O2 -mcpu=cortex-a9 -mfpu=neon"
export CXXFLAGS="$CFLAGS"
export CXX=${TRIPLE}-g++
Expand Down
14 changes: 6 additions & 8 deletions thirdparty/download.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#! /bin/bash
#! /usr/bin/env bash

declare -A urls=(
# Compression
["zlib"]="https://zlib.net/zlib-1.2.11.tar.gz"
["bzip2"]="https://ftp.osuosl.org/pub/clfs/conglomeration/bzip2/bzip2-1.0.6.tar.gz"
# Images
["libpng"]="https://download.sourceforge.net/libpng/libpng-1.6.36.tar.gz"
["libpng"]="https://download.sourceforge.net/libpng/libpng-1.6.37.tar.gz"
["libjpeg"]="http:https://www.ijg.org/files/jpegsrc.v9c.tar.gz"
["openjpeg"]="https://github.com/uclouvain/openjpeg/archive/v2.3.0.tar.gz"
["jbig2dec"]="https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs924/jbig2dec-0.15.tar.gz"
["openjpeg"]="https://github.com/uclouvain/openjpeg/archive/v2.3.1.tar.gz"
["jbig2dec"]="https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs927/jbig2dec-0.16.tar.gz"
# Fonts
["freetype2"]="https://download.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz"
["harfbuzz"]="https://github.com/harfbuzz/harfbuzz/archive/2.1.0.tar.gz"
["freetype2"]="https://download.savannah.gnu.org/releases/freetype/freetype-2.10.1.tar.gz"
["harfbuzz"]="https://github.com/harfbuzz/harfbuzz/archive/2.5.3.tar.gz"
# Documents
["djvulibre"]="http:https://downloads.sourceforge.net/djvu/djvulibre-3.5.27.tar.gz"
["mupdf"]="https://mupdf.com/downloads/archive/mupdf-1.15.0-source.tar.gz"
# Helper
["chrpath"]="http:https://archive.ubuntu.com/ubuntu/pool/main/c/chrpath/chrpath_0.14.orig.tar.gz"
)

for name in "${@:-${!urls[@]}}" ; do
Expand Down
10 changes: 5 additions & 5 deletions thirdparty/harfbuzz/build-kobo.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#! /bin/sh

FREETYPE_DIR=$(readlink -f ../freetype2)
BZIP2_DIR=$(readlink -f ../bzip2)
LIBPNG_DIR=$(readlink -f ../libpng)
ZLIB_DIR=$(readlink -f ../zlib)
FREETYPE_DIR=$(realpath ../freetype2)
BZIP2_DIR=$(realpath ../bzip2)
LIBPNG_DIR=$(realpath ../libpng)
ZLIB_DIR=$(realpath ../zlib)
export TRIPLE=arm-linux-gnueabihf
export CFLAGS="-O2 -mcpu=cortex-a9 -mfpu=neon"
export CXXFLAGS="$CFLAGS"
export FREETYPE_CFLAGS="-I${FREETYPE_DIR}/include"
export FREETYPE_LIBS="-L${FREETYPE_DIR}/objs/.libs -L${LIBPNG_DIR}/.libs -L${BZIP2_DIR} -L${ZLIB_DIR} -lfreetype -lpng16 -lbz2 -lz"

./autogen.sh --host=${TRIPLE} --disable-static --with-freetype=yes --with-icu=no --with-fontconfig=no && make
./autogen.sh --host=${TRIPLE} --disable-static --with-freetype=yes --with-glib=no --with-icu=no --with-fontconfig=no && make
13 changes: 0 additions & 13 deletions thirdparty/harfbuzz/kobo.patch

This file was deleted.

2 changes: 1 addition & 1 deletion thirdparty/openjpeg/build-kobo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TRIPLE=arm-linux-gnueabihf
export CFLAGS="-O2 -mcpu=cortex-a9 -mfpu=neon"
export CXXFLAGS="$CFLAGS"

cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC_LIBS=off -DCMAKE_C_COMPILER=${TRIPLE}-gcc -DCMAKE_CXX_COMPILER=${TRIPLE}-g++ -DCMAKE_AR=${TRIPLE}-ar .. && make
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_CODEC=off -DBUILD_STATIC_LIBS=off -DCMAKE_C_COMPILER=${TRIPLE}-gcc -DCMAKE_CXX_COMPILER=${TRIPLE}-g++ -DCMAKE_AR=${TRIPLE}-ar .. && make

cd .. || exit 1
cp build/src/lib/openjp2/opj_config.h src/lib/openjp2

0 comments on commit 666bd27

Please sign in to comment.