install-deps-linux.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. # Change directory to the location of this script
  3. echo "This Shell Script will install dependencies for cocos2d-x"
  4. echo "if you execute this shell more than once it will get errors when building libGLFW.so"
  5. echo -n "Are you continue? (y/n) "
  6. read answer
  7. if echo "$answer" | grep -iq "^y" ;then
  8. echo "It will take few minutes"
  9. else
  10. exit
  11. fi
  12. cd $(dirname ${BASH_SOURCE[0]})
  13. if [ ! $(command -v apt-get) ]; then
  14. echo "Not a .deb package system. Please install dependencies manually"
  15. exit 0
  16. fi
  17. #install g++-4.9
  18. sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y > /dev/null
  19. sudo apt-get update
  20. DEPENDS='libx11-dev'
  21. DEPENDS+=' libxmu-dev'
  22. DEPENDS+=' libglu1-mesa-dev'
  23. DEPENDS+=' libgl2ps-dev'
  24. DEPENDS+=' libxi-dev'
  25. DEPENDS+=' gcc-4.9'
  26. DEPENDS+=' g++-4.9'
  27. DEPENDS+=' libzip-dev'
  28. DEPENDS+=' libpng12-dev'
  29. DEPENDS+=' libcurl4-gnutls-dev'
  30. DEPENDS+=' libfontconfig1-dev'
  31. DEPENDS+=' libsqlite3-dev'
  32. DEPENDS+=' libglew-dev'
  33. DEPENDS+=' libssl-dev'
  34. DEPENDS+=' libgtk-3-dev'
  35. DEPENDS+=' binutils'
  36. MISSING=
  37. echo "Checking for missing packages ..."
  38. for i in $DEPENDS; do
  39. if ! dpkg-query -W --showformat='${Status}\n' $i | grep "install ok installed" > /dev/null; then
  40. MISSING+="$i "
  41. fi
  42. done
  43. if [ -n "$MISSING" ]; then
  44. TXTCOLOR_DEFAULT="\033[0;m"
  45. TXTCOLOR_GREEN="\033[0;32m"
  46. echo -e $TXTCOLOR_GREEN"Missing packages: $MISSING.\nYou may be asked for your password for package installation."$TXTCOLOR_DEFAULT
  47. CUR_APT_VERSION="$(apt --version | grep -o '[0-9].[0-9]')"
  48. REQ_APT_VERSION="1.1"
  49. if [ 1 -ge "$(echo "${CUR_APT_VERSION} >= ${REQ_APT_VERSION}" | bc)" ]
  50. then
  51. sudo apt-get install --allow-change-held-packages $MISSING -y > /dev/null
  52. else
  53. sudo apt-get install --force-yes --yes $MISSING > /dev/null
  54. fi
  55. fi
  56. sudo update-alternatives --remove-all gcc
  57. sudo update-alternatives --remove-all g++
  58. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60
  59. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 60
  60. echo "Cocos uses GCC Version: `gcc --version`"
  61. echo "Cocos uses G++ Version: `g++ --version`"
  62. echo "Cocos uses ld Version: `ld --version`"
  63. echo "Cocos uses /usr/bin/ld Version: `/usr/bin/ld --version`"