~jkaivo/freeonebook

43d7600d4415b3d4895628231576a3ae9f24e7c9 — Jakob Kaivo 3 years ago 6c6528e
redo dependency build as a straight-up shell script
3 files changed, 75 insertions(+), 50 deletions(-)

M .gitignore
A build-deps.sh
D deps/Makefile
M .gitignore => .gitignore +1 -6
@@ 1,8 1,3 @@
freeonebook
*.o
*.installed
*.tar.gz

deps/ImageMagick*
deps/zlib*
deps/libpng*
deps

A build-deps.sh => build-deps.sh +74 -0
@@ 0,0 1,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

D deps/Makefile => deps/Makefile +0 -44
@@ 1,44 0,0 @@
HOST=arm-linux-gnueabihf
PREFIX=/usr/$(HOST)

PKGCONFIG_PATH=/usr/$(HOST)/lib/pkgconfig

ZLIB_VERSION=1.2.11
LIBPNG16_VERSION=1.6.35
IMAGEMAGICK_VERSION=7.0.8-14

all: imagemagick.installed

zlib.installed:
	pkg-config --modversion zlib > $@ || $(MAKE) install-zlib

install-zlib:
	wget http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
	tar xvzf zlib-$(ZLIB_VERSION).tar.gz
	cd zlib-$(ZLIB_VERSION); CHOST=$(HOST) ./configure --static --prefix=$(PREFIX)
	cd zlib-$(ZLIB_VERSION); $(MAKE) && sudo $(MAKE) install
	pkg-config --modversion zlib > zlib.installed

libpng16.installed:
	pkg-config --modversion libpng16 > $@ || $(MAKE) install-libpng16

install-libpng16: zlib.installed
	wget https://download.sourceforge.net/libpng/libpng-$(LIBPNG16_VERSION).tar.gz
	tar xvzf libpng-$(LIBPNG16_VERSION).tar.gz
	cd libpng-$(LIBPNG16_VERSION); ./configure --prefix=$(PREFIX) --host=$(HOST)
	cd libpng-$(LIBPNG16_VERSION); $(MAKE) && sudo $(MAKE) install
	pkg-config --modversion libpng16 > libpng16.installed

imagemagick.installed:
	pkg-config --modversion MagickCore > $@ || $(MAKE) install-imagemagick

install-imagemagick: libpng16.installed
	wget https://imagemagick.org/download/ImageMagick.tar.gz
	tar xvzf ImageMagick.tar.gz
	cd ImageMagick-$(IMAGEMAGICK_VERSION); ./configure --host=$(HOST) --without-utilities --disable-shared --prefix=$(PREFIX) --disable-openmp --disable-docs
	cd ImageMagick-$(IMAGEMAGICK_VERSION); $(MAKE) && sudo $(MAKE) install
	

clean:
	rm -f *.installed
	rm -rf zlib-$(ZLIB_VERSION) libpng-$(LIBPNG16_VERSION) ImageMagic-$(IMAGEMAGICK_VERSION)