summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--Makefile19
-rw-r--r--README.md36
-rw-r--r--deps/Makefile44
4 files changed, 70 insertions, 35 deletions
diff --git a/.gitignore b/.gitignore
index 35d3c37..6941b9c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,8 @@
freeonebook
*.o
+*.installed
+*.tar.gz
+
+deps/ImageMagick*
+deps/zlib*
+deps/libpng*
diff --git a/Makefile b/Makefile
index dfe7230..9633fad 100644
--- a/Makefile
+++ b/Makefile
@@ -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 $@
diff --git a/README.md b/README.md
index 253bd2d..4bf30b5 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/deps/Makefile b/deps/Makefile
new file mode 100644
index 0000000..0089102
--- /dev/null
+++ b/deps/Makefile
@@ -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)