android.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. export NDK=/home/android-ndk-r10e
  3. export PREFIX_BASE=$(pwd)/android
  4. export HOST=arm-linux-androideabi
  5. export CPU=ARM
  6. if [ w$1 = "wx64" ]
  7. then
  8. echo "************************"
  9. echo " X64 "
  10. echo "************************"
  11. export HOST=x86_64-linux-android
  12. export CPU=x86_64
  13. export SYSROOT=$NDK/platforms/android-21/arch-x86_64
  14. export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86_64
  15. $NDK/build/tools/make-standalone-toolchain.sh --arch=x86_64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
  16. export CFLAGS='-fPIC' # For FFmpeg: '-fno-PIC'
  17. export LDFLAGS=''
  18. export OS=android64
  19. elif [ w$1 = "wx86" ]
  20. then
  21. echo "************************"
  22. echo " X86 "
  23. echo "************************"
  24. export HOST=i686-linux-android
  25. export CPU=x86
  26. export SYSROOT=$NDK/platforms/android-9/arch-x86
  27. export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86
  28. $NDK/build/tools/make-standalone-toolchain.sh --arch=x86 --platform=android-9 --install-dir=$ANDROID_TOOLCHAIN
  29. export CFLAGS='-fPIC' # For FFmpeg: '-fno-PIC'
  30. export LDFLAGS=''
  31. export OS=android-x86
  32. elif [ w$1 = "warm64" ]
  33. then
  34. echo "************************"
  35. echo " ARM64 "
  36. echo "************************"
  37. export HOST=aarch64-linux-android
  38. export CPU=arm64
  39. export SYSROOT=$NDK/platforms/android-21/arch-arm64
  40. export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-arm64
  41. $NDK/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
  42. export CFLAGS='-fPIC -D__ARMEL__ -DWEBRTC_DETECT_ARM_NEON -DWEBRTC_ARCH_ARM_NEON' # For FFmpeg: '-fno-PIC'
  43. export LDFLAGS=''
  44. export OS=android64-aarch64
  45. elif [ w$1 = "warmv7a" ]
  46. then
  47. echo "************************"
  48. echo " ARMv7-a "
  49. echo "************************"
  50. export HOST=arm-linux-androideabi
  51. export CPU=armv7-a
  52. export SYSROOT=$NDK/platforms/android-3/arch-arm
  53. export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a
  54. $NDK/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-3 --install-dir=$ANDROID_TOOLCHAIN
  55. export CFLAGS='-march=armv7-a -mfloat-abi=softfp -fPIC'
  56. export LDFLAGS='-Wl,--fix-cortex-a8'
  57. export OS=android-armv7
  58. elif [ w$1 = "wneon" ]
  59. then
  60. echo "************************"
  61. echo " NEON "
  62. echo "************************"
  63. export HOST=arm-linux-androideabi
  64. export CPU=armv7-a-neon
  65. export SYSROOT=$NDK/platforms/android-3/arch-arm
  66. export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a-neon
  67. $NDK/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-3 --install-dir=$ANDROID_TOOLCHAIN
  68. export CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon -fPIC'
  69. export LDFLAGS='-Wl,--fix-cortex-a8'
  70. export OS=android-armv7
  71. else
  72. echo "************************"
  73. echo " ARMv5TE "
  74. echo "************************"
  75. export HOST=arm-linux-androideabi
  76. export CPU=armv5te
  77. export SYSROOT=$NDK/platforms/android-3/arch-arm
  78. export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-armv5te
  79. $NDK/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-3 --install-dir=$ANDROID_TOOLCHAIN
  80. export CFLAGS='-fPIC'
  81. export LDFLAGS=''
  82. export OS=android
  83. fi
  84. ### COMMON ###
  85. export PATH=$ANDROID_TOOLCHAIN/bin:$PATH
  86. export CC=$ANDROID_TOOLCHAIN/bin/$HOST-gcc
  87. export AR=$ANDROID_TOOLCHAIN/bin/$HOST-ar
  88. export CXX=$ANDROID_TOOLCHAIN/bin/$HOST-g++
  89. #export AS=$ANDROID_TOOLCHAIN/bin/$HOST-as
  90. export AS=$ANDROID_TOOLCHAIN/bin/$HOST-gcc
  91. export RANLIB=$ANDROID_TOOLCHAIN/bin/$HOST-ranlib
  92. export CFLAGS="${CFLAGS} -DANDROID=1 -fPIC"
  93. export CPPFLAGS=$CFLAGS
  94. ./Configure -no-shared --prefix=$PREFIX_BASE/$CPU --openssldir=$PREFIX_BASE/$CPU/openssl $OS -I$ANDROID_TOOLCHAIN/sysroot/ -I$ANDROID_TOOLCHAIN/sysroot/usr/include
  95. make clean
  96. make