~jkaivo/freeonebook

freeonebook/build-deps.sh -rwxr-xr-x 1.4 KiB
f1795ce9 — Jakob Kaivo remove debug output 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

ZLIB_VERSION=1.2.8
LIBPNG_VERSION=1.6.21
IMAGEMAGICK_VERSION=7.0.8-14

export CHOST=arm-linux-gnueabihf
export PREFIX=${PWD}/deps
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
export CPPFLAGS=-I${PREFIX}/include
export LDFLAGS=-L${PREFIX}/lib
export PNG_COPTS="-I${PREFIX}/include -L${PREFIX}/lib"

set -ex

download() {
	cd ${PREFIX}/src
	if ! [ -f $(basename $1) ]; then
		wget $1
	fi
}

version_check() {
	if [ $(pkg-config --modversion "$1") = "$2" ]; then
		return 0
	fi
	return 1
}

build() {
	cd ${PREFIX}/src
	tar xvzf ${1}*.tar.gz
	cd ${1}-*
	shift
	./configure --prefix=${PREFIX} ${1+$@}
	make
	make install
}

build_imagemagick() {
	download https://imagemagick.org/download/ImageMagick.tar.gz
	if ! version_check MagickCore ${1}; then
		build ImageMagick \
			--host=${CHOST} \
			--without-utilities \
			--disable-shared \
			--disable-openmp \
			--disable-docs \
			--with-pkgconfigdir=${PKG_CONFIG_PATH}

	fi
}

build_libpng() {
	download https://downloads.sourceforge.net/project/libpng/libpng16/older-releases/${1}/libpng-${1}.tar.gz
	if ! version_check libpng ${1}; then
		build libpng \
			--host=${CHOST} \
			--with-pkgconfigdir=${PKG_CONFIG_PATH}
	fi
}

build_zlib() {
	download http://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz
	if ! version_check zlib ${1}; then
		build zlib
		rm ${PREFIX}/lib/libz.so
	fi
}

mkdir -p ${PREFIX}/src
build_zlib $ZLIB_VERSION
build_libpng $LIBPNG_VERSION
build_imagemagick $IMAGEMAGICK_VERSION