RazZziel

buildAndroidMysql.sh

May 13th, 2014
510
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #http://qt-project.org/wiki/Build_Qt5_mysql_plugin_for_Android
  4.  
  5. here="$(realpath -e "$(dirname "$0")")"
  6.  
  7. export ANDROID_NDK_ROOT="$HOME/Applications/android-ndk-r9/"
  8. SR="$ANDROID_NDK_ROOT/platforms/android-9/arch-arm"
  9. BR="$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-"
  10.  
  11. find "$SR" > "$here/rootfs_files_before.txt" || exit 1
  12. checkChanges() {
  13.        find "$SR" > "$here/rootfs_files_after.txt" || exit 1
  14.        echo "Changes:"
  15.        diff -u "$here/rootfs_files_before.txt" "$here/rootfs_files_after.txt"
  16. }
  17. trap checkChanges EXIT
  18.  
  19. # OpenSSL
  20. #pkg=openssl-1.0.1f.tar.gz
  21. pkg=openssl-1.0.1e.tar.gz
  22. dir=$(basename $pkg .tar.gz)
  23.  
  24. if [ ! -d $dir ]; then
  25.        [ -f $pkg ] || wget http://www.openssl.org/source/$pkg
  26.        tar -xf $pkg || exit 1
  27. fi
  28.  
  29. pushd $dir
  30.        RANLIB="$BR"ranlib CC="$BR"gcc ./Configure android-armv7 --prefix=$SR/usr
  31.        ANDROID_DEV=$SR/usr make #|| exit 1
  32.        ANDROID_DEV=$SR/usr make || exit 1
  33.        make install_sw || exit 1
  34. popd
  35.  
  36.  
  37. # libiconv
  38. pkg=libiconv-1.14.tar.gz
  39. dir=$(basename $pkg .tar.gz)
  40.  
  41. if [ ! -d $dir ]; then
  42.        [ -f $pkg ] || wget http://ftp.gnu.org/pub/gnu/libiconv/$pkg
  43.        tar -xf $pkg || exit 1
  44. fi
  45.  
  46. pushd $dir
  47.        STRIP="$BR"strip RANLIB="$BR"ranlib OBJDUMP="$BR"objdump AR="$BR"ar CC="$BR"gcc CFLAGS=--sysroot=$SR CPP="$BR"cpp CPPFLAGS=$CFLAGS ./configure --build=x86_64 --host=arm --prefix=$SR/usr --with-sysroot=$SR
  48.        make || exit 1
  49.        make install || exit 1
  50. popd
  51.  
  52.  
  53. # mariadbclient
  54.  
  55. if [ ! -d mariadb-native-client ]; then
  56.        bzr branch lp:mariadb-native-client || exit 1
  57. fi
  58.  
  59. pushd mariadb-native-client
  60.        sed -i -e "s|ADD_SUBDIRECTORY(unittest/libmariadb)|#ADD_SUBDIRECTORY(unittest/libmariadb)|" CMakeLists.txt
  61.         sed -i -e "N; s|typedef unsigned short ushort;\n#endif|#endif\ntypedef unsigned short ushort;|" include/my_global.h
  62.         sed -i -e "N; s|SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION.*||" libmariadb/CMakeLists.txt
  63.         sed -i -e "N; s|SOVERSION \${CPACK_PACKAGE_VERSION_MAJOR})||" libmariadb/CMakeLists.txt # Pig disgusting: the previous multiline thingie should've done it
  64.         sed -i -e "N; s|\${CPACK_PACKAGE_VERSION_MAJOR}||" libmariadb/CMakeLists.txt # Pig disgusting: what the fuck
  65.         mkdir build
  66.         pushd build
  67.         PKG_CONFIG_PATH=$SR/usr/lib/pkgconfig cmake -DCMAKE_AR="$BR"ar -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$BR"gcc -DCMAKE_C_FLAGS=--sysroot=$SR -DCMAKE_INSTALL_PREFIX=$SR/usr -DCMAKE_LINKER="$BR"ld -DCMAKE_NM="$BR"nm -DCMAKE_OBJCOPY="$BR"objcopy -DCMAKE_OBJDUMP="$BR"objdump -DCMAKE_RANLIB="$BR"ranlib -DCMAKE_STRIP="$BR"strip -DWITH_EXTERNAL_ZLIB=ON -DICONV_INCLUDE_DIR=$SR/usr/include -DICONV_LIBRARIES=$SR/usr/lib/libiconv.a -DZLIB_INCLUDE_DIR=$SR/usr/include -DZLIB_LIBRARY=$SR/usr/lib/libz.so ../ || exit 1
  68.         make install || exit 1
  69.         popd
  70.  
  71.         # ???
  72.         pwd
  73.         cp build/libmariadb/*.{a,so} "$SR/usr/lib/mariadb/" || exit 1
  74. popd
  75.  
  76. # qt
  77. #pkg=qt-everywhere-opensource-src-5.2.1.tar.gz
  78. pkg=qtbase-opensource-src-5.2.1.tar.gz
  79. dir=$(basename $pkg .tar.gz)
  80.  
  81. if [ ! -d $dir ]; then
  82.         #[ -f $pkg ] || wget http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/$pkg
  83.         [ -f $pkg ] || wget http://download.qt-project.org/official_releases/qt/5.2/5.2.1/submodules/$pkg
  84.         tar -xf $pkg || exit 1
  85. fi
  86.  
  87. pushd $dir/src/plugins/sqldrivers/mysql/
  88.         #qmake=~/"Applications/Qt/5.2.1/gcc/bin/qmake"
  89.         qmake=~/"Applications/Qt/5.2.1/android_armv7/bin/qmake"
  90.  
  91.         $qmake "INCLUDEPATH+=$SR/usr/include/mariadb" "LIBS+=$SR/usr/lib/mariadb/libmariadbclient.a $SR/usr/lib/libssl.a $SR/usr/lib/libcrypto.a $SR/usr/lib/libiconv.a" "LIBPATH+=$SR/usr/lib/mariadb" -o Makefile mysql.pro
  92.         make || exit 1
  93.         make install || exit 1
  94. popd
  95.  
  96.  
  97. echo
  98. echo "BOOYAH!!!"
  99. echo
RAW Paste Data