Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # this script creates a build environment for
- # QT5-based applications for the Raspberry Pi
- #
- # the script is tested on Ubuntu 14 32 Bit
- # first we need to set the LANG to a default value
- export LANG=C
- # we need some commands
- testCommands()
- {
- sudo apt-get install build-essential
- echo "checking needed programs";
- [ -x /usr/bin/wget ] || exit 1;
- [ -x /usr/bin/git ] || exit 2;
- [ -x /usr/bin/unzip ] || exit 3;
- [ -x /sbin/fdisk ] || exit 4;
- [ -x /bin/grep ] || exit 5;
- [ -x /usr/bin/awk ] || exit 6;
- echo "done";
- }
- # here we fetch the current raspbian image and mount them
- getRootFs()
- {
- echo "getting Raspberry Pi image";
- mkdir rootfs;
- wget http://downloads.raspberrypi.org/raspbian/images/raspbian-2015-02-17/2015-02-16-raspbian-wheezy.zip;
- unzip 2015-02-16-raspbian-wheezy.zip;
- # UNITS and START are needed to calculate the offset for the mount command
- UNITS=$(/sbin/fdisk -l 2015-02-16-raspbian-wheezy.img|grep Units|awk '{print $9}');
- START=$(/sbin/fdisk -l 2015-02-16-raspbian-wheezy.img|grep img2|awk '{print $2}');
- OFFSET=$(($UNITS * $START))
- sudo mount -t ext4 -o offset=$OFFSET $PWD/2015-02-16-raspbian-wheezy.img $PWD/rootfs
- }
- # we need a cross-compiler and a couple of variables to use them
- getCompiler()
- {
- git clone https://github.com/raspberrypi/tools.git
- cat > variables.sh <<EOF
- PWD=$(pwd)
- export TOOLCHAIN=$PWD/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian
- export PATH=$PWD/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH
- export ROOTFS=$PWD/rootfs
- export CC='arm-linux-gnueabihf-gcc -march=armv4t -mtune=arm920t'
- export CXX='arm-linux-gnueabihf-g++ -march=armv4t -mtune=arm920t'
- export CROSS_COMPILE=arm-linux-gnueabihf-
- export LDFLAGS="-L$PWD/rootfs/usr/lib -L$PWD/rootfs/usr/local/qt5pi/lib"
- export CFLAGS="-I$PWD/rootfs/usr/include -I$PWD/rootfs/usr/local/qt5pi/include"
- export CXXFLAGS="-I$PWD/rootfs/usr/include -I$PWD/rootfs/usr/local/qt5pi/include"
- export QTDIR=/usr/local/qt5pi
- EOF
- PWD=$(pwd)
- # fix the library paths in the raspberry image
- git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git
- sudo cross-compile-tools/fixQualifiedLibraryPaths $PWD/rootfs/ $PWD/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
- }
- # here we cross-compile QT 5.4.0. we start with qtbase. after that
- # we compile the additional modules
- getQt5()
- {
- wget http://download.qt-project.org/official_releases/qt/5.4/5.4.0/single/qt-everywhere-opensource-src-5.4.0.tar.gz
- tar xvfz qt-everywhere-opensource-src-5.4.0.tar.gz
- pushd qt-everywhere-opensource-src-5.4.0
- pushd qtbase
- ./configure -prefix /usr/local/qt5pi -release \
- -opensource -confirm-license -device linux-rasp-pi-g++ \
- -make libs -optimized-qmake -device-option \
- CROSS_COMPILE=$ROOT/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- \
- -nomake tests -nomake examples -reduce-exports \
- -sysroot $ROOT/rootfs -opengl es2
- make && sudo make install
- popd
- for i in qtactiveqt qtandroidextras qtbase qtconnectivity \
- qtdeclarative qtdoc qtenginio qtgraphicaleffects \
- qtimageformats qtlocation qtmultimedia qtquick1 \
- qtquickcontrols qtscript qtsensors qtserialport \
- qtsvg qttools qttranslations qtwebchannel \
- qtwebengine qtwebkit qtwebsockets qtxmlpatterns
- do
- pushd $i
- /usr/local/qt5pi/bin/qmake && make && sudo make install
- popd
- done
- popd
- }
- testCommands;
- mkdir Raspberry
- pushd Raspberry
- ROOT=$(pwd)
- getRootFs
- getCompiler
- getQt5
- echo "QT5 built"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement