Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
322 lines (274 sloc) 11.3 KB
#
# Written 2011 by Xiangfu Liu <xiangfu@sharism.cc>
# this file try to manager build flickernoise toolchain
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# before compile flickernoise. you need the lm32-rtems toolchain and rtems
# For Mac OS X use curl.
WGET=wget -c -O
# WGET=curl -o
# export PATH=/opt/rtems-4.11/bin:$PATH
# export RTEMS_MAKEFILE_PATH=/opt/rtems-4.11/lm32-rtems4.11/milkymist
RTEMS_VERSION=4.11
RTEMS_MAKEFILE_PATH ?= \
/opt/rtems-$(RTEMS_VERSION)/lm32-rtems$(RTEMS_VERSION)/milkymist
LIBPNG_VERSION = 1.5.6
FREETYPE2_VERSION = 2.4.4
MUPDF_VERSION = 0.8
CURL_VERSION = 7.22.0
EXPAT_VERSION = 2.0.1
JANSSON_VERSION = 2.3
LIBPNG = libpng-$(LIBPNG_VERSION).tar.gz
LIBJPEG = jpegsrc.v8c.tar.gz
OPENJPEG = openjpeg_v1_2.tar.gz
FREETYPE2 = freetype-$(FREETYPE2_VERSION).tar.gz
MUPDF = mupdf-$(MUPDF_VERSION)-source.tar.gz
CURL = curl-$(CURL_VERSION).tar.bz2
EXPAT = expat-$(EXPAT_VERSION).tar.gz
JANSSON = jansson-$(JANSSON_VERSION).tar.gz
DL = $(if $(wildcard ../dl/.),../dl,dl)
BUILD_DIR = ./build_dir
MILKYMIST_GIT_URL = git://github.com/milkymist
MILKYMIST_GIT_DIR ?= /opt/milkymist
CONFIGURE_VARS = CC=lm32-rtems4.11-gcc AR=lm32-rtems4.11-ar \
LD=lm32-rtems4.11-ld RANLIB=lm32-rtems4.11-ranlib \
CFLAGS="-O9 -Wall -mbarrel-shift-enabled -mmultiply-enabled \
-mdivide-enabled -msign-extend-enabled \
-I $(RTEMS_MAKEFILE_PATH)/lib/include -B $(RTEMS_MAKEFILE_PATH)/lib \
-specs bsp_specs -qrtems"
RTEMS_CONFIGURE_FLAGS = --target=lm32-rtems4.11 --enable-rtemsbsp=milkymist \
--enable-testsuites=samples --enable-posix --disable-itron \
--enable-networking --disable-multiprocessing
HOST_CC = gcc
all: flickernoise.fbi flickernoise-pdf.fbiz
.PHONY: clean clean-rtems boot.crc.bin
build_dir/.prepare:
mkdir -p build_dir
touch $@
$(BUILD_DIR)/libpng: $(DL)/$(LIBPNG).ok build_dir/.prepare
tar xf $(DL)/$(LIBPNG) -C $(BUILD_DIR)
cd $(BUILD_DIR)/libpng-$(LIBPNG_VERSION) && $(CONFIGURE_VARS) \
CPPFLAGS="-DPNG_NO_FLOATING_ARITHMETIC -DPNG_NO_FLOATING_POINT" \
./configure --disable-shared --prefix=$(RTEMS_MAKEFILE_PATH) \
--host=lm32-rtems4.11 && \
make all install
cp -rf $(RTEMS_MAKEFILE_PATH)/include/* \
$(RTEMS_MAKEFILE_PATH)/lib/include
rm -rf $(RTEMS_MAKEFILE_PATH)/include/*
touch $@
$(BUILD_DIR)/libjpeg: $(DL)/$(LIBJPEG).ok build_dir/.prepare
tar xf $(DL)/$(LIBJPEG) -C $(BUILD_DIR)
cd $(BUILD_DIR)/jpeg-8c && $(CONFIGURE_VARS) ./configure \
--host=lm32-rtems4.11 --disable-shared \
--prefix=$(RTEMS_MAKEFILE_PATH) && \
make all install
mv $(RTEMS_MAKEFILE_PATH)/include/* $(RTEMS_MAKEFILE_PATH)/lib/include
touch $@
$(BUILD_DIR)/openjpeg: $(DL)/$(OPENJPEG).ok build_dir/.prepare
tar xf $(DL)/$(OPENJPEG) -C $(BUILD_DIR)
mv $(BUILD_DIR)/trunk $(BUILD_DIR)/openjpeg-trunk
cd $(BUILD_DIR)/openjpeg-trunk && \
patch -Np1 < ../../patches/openjpeg-0001-for-milkymist-one.patch
cd $(BUILD_DIR)/openjpeg-trunk && $(CONFIGURE_VARS) make && \
lm32-rtems4.11-ranlib libopenjpeg.a && \
cp libopenjpeg.a $(RTEMS_MAKEFILE_PATH)/lib && \
cp libopenjpeg/openjpeg.h $(RTEMS_MAKEFILE_PATH)/lib/include
touch $@
$(BUILD_DIR)/jbig2dec: build_dir/.prepare
if [ ! -d $(DL)/jbig2dec ] ; \
then \
git clone git://git.ghostscript.com/jbig2dec.git $(BUILD_DIR)/jbig2dec && \
cd $(BUILD_DIR)/jbig2dec && git checkout 0.11 ; \
fi
cd $(BUILD_DIR)/jbig2dec && \
./autogen.sh && \
$(CONFIGURE_VARS) \
./configure --host=lm32-rtems4.11 --disable-shared \
--prefix=$(RTEMS_MAKEFILE_PATH) && \
make all install
mv $(RTEMS_MAKEFILE_PATH)/include/* $(RTEMS_MAKEFILE_PATH)/lib/include
touch $@
$(BUILD_DIR)/freetype2: $(DL)/$(FREETYPE2).ok build_dir/.prepare
tar xf $(DL)/$(FREETYPE2) -C $(BUILD_DIR)
cd $(BUILD_DIR)/freetype-$(FREETYPE2_VERSION) && \
$(CONFIGURE_VARS) ./configure --host=lm32-rtems4.11 \
--disable-shared --prefix=$(RTEMS_MAKEFILE_PATH) && \
make all install
cp -rf $(RTEMS_MAKEFILE_PATH)/include/* \
$(RTEMS_MAKEFILE_PATH)/lib/include
rm -rf $(RTEMS_MAKEFILE_PATH)/include/*
touch $@
$(BUILD_DIR)/mupdf: $(DL)/$(MUPDF).ok build_dir/.prepare \
$(BUILD_DIR)/libpng $(BUILD_DIR)/libjpeg \
$(BUILD_DIR)/openjpeg $(BUILD_DIR)/jbig2dec \
$(BUILD_DIR)/freetype2
tar xf $(DL)/$(MUPDF) -C $(BUILD_DIR)
#First, compile the code generation tools natively:
cd $(BUILD_DIR)/mupdf-$(MUPDF_VERSION) && \
patch -Np1 < ../../patches/mupdf-0001-for-milkymist-one.patch
cd $(BUILD_DIR)/mupdf-$(MUPDF_VERSION) && \
mkdir -p build/release && \
$(HOST_CC) -o build/release/cmapdump ./mupdf/cmapdump.c \
-lfreetype -ljpeg -lz -lm -Ifitz && \
$(HOST_CC) -o build/release/fontdump ./mupdf/fontdump.c \
-lfreetype -ljpeg -lz -lm -Ifitz && \
mkdir -p build/generated
cd $(BUILD_DIR)/mupdf-$(MUPDF_VERSION) && \
OS=Rtems CC=lm32-rtems4.11-gcc \
CFLAGS="-O9 -mbarrel-shift-enabled -mmultiply-enabled \
-mdivide-enabled -msign-extend-enabled \
-I $(RTEMS_MAKEFILE_PATH)/lib/include -I \
$(RTEMS_MAKEFILE_PATH)/lib/include/freetype2 \
-B $(RTEMS_MAKEFILE_PATH)/lib -specs bsp_specs -qrtems" \
LDFLAGS="-L $(RTEMS_MAKEFILE_PATH)/lib" \
make build=release build/release/libmupdf.a
cd $(BUILD_DIR)/mupdf-$(MUPDF_VERSION) && \
cp fitz/fitz.h $(RTEMS_MAKEFILE_PATH)/lib/include && \
cp mupdf/mupdf.h $(RTEMS_MAKEFILE_PATH)/lib/include && \
cp build/release/libmupdf.a $(RTEMS_MAKEFILE_PATH)/lib
touch $@
$(BUILD_DIR)/curl: $(DL)/$(CURL).ok
tar xf $(DL)/$(CURL) -C $(BUILD_DIR)
cd $(BUILD_DIR)/curl-$(CURL_VERSION) && \
$(CONFIGURE_VARS) ./configure --host=lm32-rtems4.11 \
--disable-shared --prefix=$(RTEMS_MAKEFILE_PATH) \
--without-librtmp --disable-ftp --disable-ldap --disable-ldaps \
--disable-rtsp --disable-dict --disable-telnet --disable-tftp \
--disable-pop3 --disable-imap --disable-smtp --disable-gopher \
--disable-manual && \
echo "#define HAVE_SOCKET 1" >> lib/setup.h && \
make all install
cp -rf $(RTEMS_MAKEFILE_PATH)/include/* \
$(RTEMS_MAKEFILE_PATH)/lib/include
rm -rf $(RTEMS_MAKEFILE_PATH)/include/*
touch $@
$(BUILD_DIR)/expat: $(DL)/$(EXPAT).ok
tar xf $(DL)/$(EXPAT) -C $(BUILD_DIR)
cd $(BUILD_DIR)/expat-$(EXPAT_VERSION) && \
sed -i 's/ppc)/lm32)/' conftools/config.sub && \
$(CONFIGURE_VARS) ./configure --host=lm32-rtems4.11 \
--disable-shared --prefix=$(RTEMS_MAKEFILE_PATH) && \
make all install
cp -rf $(RTEMS_MAKEFILE_PATH)/include/* \
$(RTEMS_MAKEFILE_PATH)/lib/include
rm -rf $(RTEMS_MAKEFILE_PATH)/include/*
touch $@
$(BUILD_DIR)/jansson: $(DL)/$(JANSSON).ok
tar xf $(DL)/$(JANSSON) -C $(BUILD_DIR)
cd $(BUILD_DIR)/jansson-$(JANSSON_VERSION) && \
patch -Np1 < ../../patches/jansson-0001-for-milkymist-one.patch.patch
cd $(BUILD_DIR)/jansson-$(JANSSON_VERSION) && \
$(CONFIGURE_VARS) ./configure --host=lm32-rtems4.11 \
--disable-shared --prefix=$(RTEMS_MAKEFILE_PATH) && \
make all install
cp -rf $(RTEMS_MAKEFILE_PATH)/include/* \
$(RTEMS_MAKEFILE_PATH)/lib/include
rm -rf $(RTEMS_MAKEFILE_PATH)/include/*
touch $@
REPO_DIRS=milkymist flickernoise rtems-yaffs2 liboscparse mtk autotest-m1
milkymist-git-clone:
mkdir -p $(MILKYMIST_GIT_DIR)
if [ ! -d "$(MILKYMIST_GIT_DIR)/rtems" ] ; then git clone git://git.rtems.org/rtems.git $(MILKYMIST_GIT_DIR)/rtems ; fi
for d in $(REPO_DIRS); \
do if [ ! -d "$(MILKYMIST_GIT_DIR)/$$d" ] ; then (git clone $(MILKYMIST_GIT_URL)/$$d.git \
$(MILKYMIST_GIT_DIR)/$$d) || exit 1; fi \
done
milkymist-git-update:
for d in $(REPO_DIRS) rtems; \
do (cd $(MILKYMIST_GIT_DIR)/$$d && git fetch -a && \
git checkout -f master && \
git reset --hard origin/master) || exit 1; \
done
#You will need Lemon and RE2C to compile libFPVM.
sdk-install:
make -C $(MILKYMIST_GIT_DIR)/milkymist sdk-install
mtk:
make -C $(MILKYMIST_GIT_DIR)/$@ milkymist install-milkymist
liboscparse:
make -C $(MILKYMIST_GIT_DIR)/$@ all install
rtems-yaffs2:
make -C $(MILKYMIST_GIT_DIR)/$@ -f Makefile.rtems all install
rtems: $(BUILD_DIR)/bsp-milkymist/Makefile
make -C $(BUILD_DIR)/bsp-milkymist all install
touch $@
$(BUILD_DIR)/bsp-milkymist/Makefile:
mkdir -p $(BUILD_DIR)/bsp-milkymist
[ -e ${MILKYMIST_GIT_DIR}/wernermisc ] || \
git clone git://projects.qi-hardware.com/wernermisc.git ${MILKYMIST_GIT_DIR}/wernermisc
cd ${MILKYMIST_GIT_DIR}/wernermisc && git fetch -a && git reset --hard origin/master
cd ${MILKYMIST_GIT_DIR}/rtems && rm -f patches && ln -s ${MILKYMIST_GIT_DIR}/wernermisc/m1/patches/rtems patches
-cd ${MILKYMIST_GIT_DIR}/rtems && quilt pop -a -f
cd ${MILKYMIST_GIT_DIR}/rtems && quilt push -a
cd $(MILKYMIST_GIT_DIR)/rtems && \
./bootstrap -c && ./bootstrap -p && ./bootstrap
cd $(BUILD_DIR)/bsp-milkymist && \
$(MILKYMIST_GIT_DIR)/rtems/configure $(RTEMS_CONFIGURE_FLAGS)
#you will need clang for compile milkymist tools
flickernoise.fbi: rtems sdk-install mtk liboscparse rtems-yaffs2 \
$(BUILD_DIR)/mupdf $(BUILD_DIR)/curl $(BUILD_DIR)/expat \
$(BUILD_DIR)/jansson
make -C $(MILKYMIST_GIT_DIR)/flickernoise/src \
clean bin/flickernoise.fbi
cp $(MILKYMIST_GIT_DIR)/flickernoise/src/bin/$@ .
flickernoise-pdf.fbiz: flickernoise.fbi
WITH_PDF=1 make -C $(MILKYMIST_GIT_DIR)/flickernoise/src \
clean bin/flickernoise.fbiz
cp $(MILKYMIST_GIT_DIR)/flickernoise/src/bin/flickernoise.fbiz ./$@
boot.bin:
MMDIR=$(MILKYMIST_GIT_DIR)/milkymist \
make -C $(MILKYMIST_GIT_DIR)/autotest-m1/src clean boot.bin
cp $(MILKYMIST_GIT_DIR)/autotest-m1/src/boot.bin ./$@
boot.crc.bin:
MMDIR=$(MILKYMIST_GIT_DIR)/milkymist IMAGES_DIR=$(IMAGES_DIR) \
make -C $(MILKYMIST_GIT_DIR)/autotest-m1/src clean boot.crc.bin
cp $(MILKYMIST_GIT_DIR)/autotest-m1/src/boot.crc.*.bin ./
####
$(DL)/$(LIBPNG).ok:
mkdir -p dl
$(WGET) $(DL)/$(LIBPNG) "http://download.sourceforge.net/\
project/libpng/libpng15/older-releases/$(LIBPNG_VERSION)/$(LIBPNG)"
touch $@
$(DL)/$(LIBJPEG).ok:
mkdir -p dl
$(WGET) $(DL)/$(LIBJPEG) "http://www.ijg.org/files/$(LIBJPEG)"
touch $@
$(DL)/$(OPENJPEG).ok:
mkdir -p dl
$(WGET) $(DL)/$(OPENJPEG) "http://www.openjpeg.org/$(OPENJPEG)"
touch $@
$(DL)/$(FREETYPE2).ok:
mkdir -p dl
$(WGET) $(DL)/$(FREETYPE2) "http://download.sourceforge.net/\
project/freetype/freetype2/$(FREETYPE2_VERSION)/$(FREETYPE2)"
touch $@
$(DL)/$(MUPDF).ok:
mkdir -p dl
$(WGET) $(DL)/$(MUPDF) "http://mupdf.com/download/archive/$(MUPDF)"
touch $@
$(DL)/$(CURL).ok:
mkdir -p dl
$(WGET) $(DL)/$(CURL) "http://curl.haxx.se/download/$(CURL)"
touch $@
$(DL)/$(EXPAT).ok:
mkdir -p dl
$(WGET) $(DL)/$(EXPAT) "http://download.sourceforge.net/\
project/expat/expat/$(EXPAT_VERSION)/expat-$(EXPAT_VERSION).tar.gz"
touch $@
$(DL)/$(JANSSON).ok:
mkdir -p dl
$(WGET) $(DL)/$(JANSSON) "http://www.digip.org/jansson/releases/$(JANSSON)"
touch $@
clean:
rm -rf build_dir/*
clean-rtems:
rm -rf build_dir/bsp-milkymist/