~jkaivo/freeonebook

6c6528e3a508c8ab357b58e9744dd86ebf3e6914 — Jakob Kaivo 3 years ago b512299
automate dependency building
4 files changed, 70 insertions(+), 35 deletions(-)

M .gitignore
M Makefile
M README.md
A deps/Makefile
M .gitignore => .gitignore +6 -0
@@ 1,2 1,8 @@
freeonebook
*.o
*.installed
*.tar.gz

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

M Makefile => Makefile +15 -4
@@ 1,7 1,12 @@
CC=arm-linux-gnueabihf-gcc
CFLAGS=-Wall -Wextra -I. -IImageMagick
LDFLAGS=-lpthread -LImageMagick/MagickCore/.libs
LDLIBS=-lMagickCore-7.Q8 -lm
CROSS=arm-linux-gnueabihf
DEPLIBS=MagickCore libpng16 zlib
PKGCONFIG=PKG_CONFIG_PATH=/usr/$(CROSS)/lib/pkgconfig pkg-config
CC=$(CROSS)-gcc
CFLAGS=-Wall -Wextra -I. $$($(PKGCONFIG) --cflags MagickCore)
LDFLAGS=-lpthread $$($(PKGCONFIG) --libs-only-L $(DEPLIBS))
LDLIBS=$$($(PKGCONFIG) --libs-only-l $(DEPLIBS)) -lm

all: install-deps freeonebook

freeonebook: freeonebook.o gpio.o fb.o convert.o



@@ 15,3 20,9 @@ convert.o: convert.c convert.h

clean:
	rm -f freeonebook *.o

install-deps: deps.installed

deps.installed:
	cd deps; $(MAKE) all
	touch $@

M README.md => README.md +5 -31
@@ 13,38 13,12 @@ with:

Image support is provided by ImageMagick, which in turn depends on libpng,
which in turn depends on zlib. The eOneBook already has dynamic libraries for
zlib and libpng installed, but you still need them installed in your
cross-compilation environment so ImageMagick knows they will be there.
libpng installed, but you still need them installed in your cross-compilation
environment so ImageMagick knows they will be there. A make target is included
to simplify the process of installing them. If one or more is already installed
in your cross-compilation environment, it will be skipped.

#### zlib

    $ wget http://www.zlib.net/zlib-1.2.11.tar.gz
    $ tar xvzf zlib-1.2.11.tar.gz
    $ cd zlib-1.2.11
    $ CHOST=arm-linux-gnueabihf ./configure --prefix=/usr/arm-linux-gnueabihf
    $ make
    $ sudo make install

#### libpng

    $ wget https://download.sourceforge.net/libpng/libpng-1.6.35.tar.gz
    $ tar xvzf libpng-1.6.35.tar.gz
    $ cd libpng-1.6.35
    $ ./configure --prefix=/usr/arm-linux-gnueabihf --host=arm-linux-gnueabihf
    $ make
    $ sudo make install

#### ImageMagick

ImageMagick is not installed on the eOneBook, so we'll configure it to build
as a static library.

    $ wget https://imagemagick.org/download/ImageMagick.tar.gz
    $ tar xvzf ImageMagick.tar.gz
    $ cd ImageMagick-7.0.8-14
    $ PKG_CONFIG_PATH=/usr/arm-linux-gnueabihf/lib/pkgconfig ./configure --host=arm-linux-gnueabihf --without-utilities --disable-openmp --disable-shared --prefix=/usr/arm-linux-gnueabihf
    $ make
    $ sudo make install
    $ make install-deps

### freeonebook


A deps/Makefile => deps/Makefile +44 -0
@@ 0,0 1,44 @@
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)