前文提到了qtopia 2.2.0源代码编译移植的一些问题和注意事项,为了提高编译效率和可重复性,我编写了两个Shell脚本来实现自动修复源码错误和代码编译安装。
#! /bin/bash # modify qtopia source files to fix some compile errors. QT_ROOT_DIR=$PWD/qtopia-free-2.2.0 pushd $QT_ROOT_DIR # 1: pthread_yield --> sched_yield pushd qtopia/src/3rdparty/plugins/codecs/libffmpeg sed -i 's/pthread_yield/sched_yield/g' mediapacketbuffer.h popd # 2: fix ptrdiff_t is not a name type error pushd dqt/src/tools/ sed -i '52i\ #include <cstddef>\n #include "stddef.h" ' qvaluelist.h popd # 3:append ,remove function add object pushd qt2/src/tools sed -i '52c\ void push( const T& d ) { this->append(d);}' qvaluestack.h sed -i '57c\ this->remove( this->fromLast() );' qvaluestack.h popd # 4:about <asm/page.h> header file use pushd qt2/src/kernel sed -i '/<asm\/page.h>/c\ #define PAGE_SHIFT 12 \ #define PAGE_SIZE (1UL << PAGE_SHIFT) \ #define PAGE_MASK (~(PAGE_SIZE-1)) ' qpixmapcache.cpp popd pushd qt2/tools/qvfb sed -i '/<asm\/page.h>/c\ #define PAGE_SHIFT 12 \ #define PAGE_SIZE (1UL << PAGE_SHIFT) \ #define PAGE_MASK (~(PAGE_SIZE-1)) ' qvfbview.cpp popd # 5:remove class qualifier before destructor function pushd qtopia/src/libraries/qtopia sed -i '/\~QDawgPrivate/c\ ~QDawgPrivate()' qdawg.cpp popd # 6: undef macro HAVE_PROGRAM_INVOCATION_NAME pushd qtopia/src/3rdparty/libraries/rsync sed -i '/HAVE_PROGRAM_INVOCATION_NAME/c\#undef HAVE_PROGRAM_INVOCATION_NAME' config_linux.h popd # 7: open function lack the mode parameter pushd qt2/src/tools sed -i '143c\ f = ::open(tmpFile.latin1(), O_CREAT | O_WRONLY,0666);' qmemoryfile_unix.cpp popd pushd qtopia/src/libraries/qtopia sed -i '141c\ f = ::open(tmpFile.latin1(), O_CREAT | O_WRONLY, 0666);' qmemoryfile_unix.cpp popd # 8: fix error: cannot find zlib.h header file sed -i '/"zlib.h"/c\ #include "../zlib/zlib.h" ' qt2/src/3rdparty/libpng/png.h popd exit 0
#! /bin/bash #==================================================================== # the script builds qtopia-2.2.0 embedded environment. #==================================================================== # includes qtopia-2.2.0 and png,zlib,jpeg,uuid 3rdparties. # the content of the tar is listed below: # # Qt-2.2.0/Qtools/ # Qt-2.2.0/Qtools/libpng-1.2.14.tar.gz # Qt-2.2.0/Qtools/zlib-1.2.3.tar.gz # Qt-2.2.0/Qtools/qtopia-free-src-2.2.0.tar.gz # Qt-2.2.0/Qtools/jpegsrc.v6b.tar.gz # Qt-2.2.0/Qtools/e2fsprogs-1.39.tar.gz # #==================================================================== # common variables,includes cross-toolchains,prefix-dir etc. QTOOLS_DIR=$PWD CROSS=/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/usr/bin PLATFORM=arm-hismall-linux CC=$CROSS/$PLATFORM-gcc LD=$CROSS/$PLATFORM-ld AR=$CROSS/$PLATFORM-ar CPP=$CROSS/$PLATFORM-g++ RANLIB=$CROSS/$PLATFORM-ranlib # create build directory for 3rd liraries and headers PREFIX=$PWD/build PREFIX_LIB=$PREFIX/lib PREFIX_INC=$PREFIX/include mkdir -p $PREFIX_LIB $PREFIX_INC # create install directory for qtopia installation INSTALL=$PWD/install mkdir -p $INSTALL BUILD_LOG=$PWD/3rd_build.log echo "=======Begin to build 3rd libraries...=======" echo "*********start to build e2fsprogs(uuid)*********" echo "*********start to build e2fsprogs(uuid)*********" > $BUILD_LOG tar -zxf Qtools/e2fsprogs-1.39.tar.gz pushd e2fsprogs-1.39 ./configure --host=$PLATFORM --enable-elf-shlibs --with-cc=$CC --with-linker=$LD --prefix=$PREFIX make 2>>$BUILD_LOG cp -fv lib/libuuid.so* $PREFIX_LIB cp -rfv lib/uuid $PREFIX_INC popd echo "*********e2fsprogs build successfull*********" echo "*********start to build jpegsrc.v6b**********" echo "*********start to build jpegsrc.v6b**********" >> $BUILD_LOG tar -zxf Qtools/jpegsrc.v6b.tar.gz pushd jpeg-6b mkdir -pv install/bin install/include install/lib install/man/man1 ./configure --enable-shared --prefix=$PWD/install echo y | cp jconfig.doc jconfig.h # extract JPEG library version for libtool utility JPEG_LIB_VER=`sed -n '/#define JPEG_LIB_VERSION/s/[[:space:]][[:space:]]*/ /gp' jpeglib.h |cut -d " " -f 3` make CC=$CC AR="$AR rc" AR2=$RANLIB JPEG_LIB_VERSION=$JPEG_LIB_VER 2>>$BUILD_LOG make install cp -fv install/lib/libjpeg.* $PREFIX_LIB cp -fv j*.h $PREFIX_INC cp -fv install/man $PREFIX/ popd echo "*********jpeg build successful*********" echo "*********start to build zlib***********" echo "*********start to build zlib***********" >> $BUILD_LOG tar -zxf Qtools/zlib-1.2.3.tar.gz pushd zlib-1.2.3 ./configure -shared make CC=$CC LDSHARED="$CC -shared -Wl,-soname,libz.so.1" CPP="$CC -E" AR="$AR rc" RANLIB=$RANLIB prefix=$PREFIX 2>>$BUILD_LOG cp -fv libz.so* $PREFIX_LIB cp -fv *.h $PREFIX_INC popd echo "*********zlib build successful*********" echo "*********start to build libpng*********" echo "*********start to build libpng*********" >> $BUILD_LOG tar -zxf Qtools/libpng-1.2.14.tar.gz mv -fv zlib-1.2.3 zlib pushd libpng-1.2.14 cp scripts/makefile.linux ./Makefile make CC=$CC AR_RC="$AR rc" RANLIB=$RANLIB prefix=$PREFIX 2>>$BUILD_LOG cp -fv libpng12.so* $PREFIX_LIB # remove the libpng version number to let ld find it #ln -s $PREFIX_LIB/libpng12.so.0 $PREFIX_LIB/libpng.so.0 cp -fv $PREFIX_LIB/libpng12.so.0 $PREFIX_LIB/libpng.so cp -fv *.h $PREFIX_INC popd mv -fv zlib zlib-1.2.3 echo "*********libpng build successful*********" echo "=======End to build 3rd libraries.=======" echo "=======Begin to build qtopia-2.2.0=======" echo "-------step1:create platform tmake.conf and qmake.conf-------" tar -zxf Qtools/qtopia-free-src-2.2.0.tar.gz pushd qtopia-free-2.2.0 QT_ROOT_DIR=$PWD QT_BUILD_LOG=$QT_ROOT_DIR/build.log # create platform tmake qws config file cp -frv tmake/lib/qws/linux-arm-g++ tmake/lib/qws/arm-hismall-linux-g++ pushd tmake/lib/qws/arm-hismall-linux-g++ # modify tmake.conf file sed -i 's/arm-linux/arm-hismall-linux/g' tmake.conf popd # create platform qtopia mkspecs qws files cp -frv qtopia/mkspecs/qws/linux-arm-g++/ qtopia/mkspecs/qws/arm-hismall-linux-g++ pushd qtopia/mkspecs/qws/arm-hismall-linux-g++ # modify qmake.conf file sed -i 's/arm-linux/arm-hismall-linux/g' qmake.conf sed -i '61c\QMAKE_LIBS_QT = -lqte -lpng -lz -luuid -ljpeg' qmake.conf popd echo "-------step 2: create qconfig-qpe.h file for our project-------" # modify qconfig-xxx.h pushd qtopia/src/qt #if let qtopia support mouse #/* #ifndef QT_NO_QWS_CURSOR #define QT_NO_QWS_MOUSE_PC #endif #*/ sed -i '47a\/* ' qconfig-qpe.h sed -i '60i\*/ ' qconfig-qpe.h # used for qte build cp qconfig-qpe.h $QT_ROOT_DIR/qt2/src/tools popd # about touch panels feature pushd qtopia/src/libraries/qtopia # iPAQ Touch Panel #cp custom-linux-ipaq-g++.cpp custom-linux-arm-g++.cpp #cp custom-linux-ipaq-g++.h custom-linux-arm-g++.h # Don't use Touch Panel cp custom-linux-x86-g++.cpp custom-$PLATFORM-g++.cpp cp custom-linux-x86-g++.h custom-$PLATFORM-g++.h popd echo "-------step 3:fix source files compile errors-------" pushd $QTOOLS_DIR ./fix-src-errors.sh popd echo "-------step 4:configure,make and install qtopia-------" QTE_CFG="'-embedded -no-xft -xplatform $PLATFORM-g++ -qconfig qpe -depths 16,32 -no-qvfb -system-jpeg -gif -system-libpng -I$PREFIX_INC -lpng -lz -ljpeg -L$PREFIX_LIB'" QPE_CFG="'-xplatform $PLATFORM-g++ -edition pda -displaysize 240x320'" QT2_CFG= DQT_CFG= # configure echo "yes" |./configure -qte "$QTE_CFG" -qpe "$QPE_CFG" -libpath $PREFIX_LIB -prefix $INSTALL > $QT_BUILD_LOG # set environment variables if [ -f setQpeEnv ] then . ./setQpeEnv export PATH=$TMAKEDIR/bin:$PATH fi # make make 2>>$QT_BUILD_LOG # install make install popd