+# Get the Android NDK and SDK, install required packages and toolchains.
+if [ "x$1" = "xprepare" ]; then
+ mkdir -p $ANDROID_PATH
+ cd $ANDROID_PATH
+
+ # NDK
+ $WGET http://dl.google.com/android/ndk/android-ndk-r$VER_NDK-linux-x86.bin
+ chmod 700 android-ndk-r$VER_NDK-linux-x86.bin
+ ./android-ndk-r$VER_NDK-linux-x86.bin -y
+ cd android-ndk-r$VER_NDK
+ ./build/tools/make-standalone-toolchain.sh --platform=android-$VER_AND_API \
+ --toolchain=arm-linux-androideabi-4.9 \
+ --install-dir=$ANDROID_PATH/android-arm-toolchain
+ ./build/tools/make-standalone-toolchain.sh --platform=android-$VER_AND_API \
+ --toolchain=x86-4.9 \
+ --install-dir=$ANDROID_PATH/android-i686-toolchain
+ cd ..
+
+ # SDK
+ $WGET http://dl.google.com/android/android-sdk_r$VER_SDK-linux.tgz
+ tar xfz android-sdk_r$VER_SDK-linux.tgz
+ cd android-sdk-linux
+ echo y | ./tools/android update sdk --no-ui --all --filter platform-tools,build-tools-$VER_AND_BT,android-$VER_AND_API
+ cd ..
+
+ exit
+fi
+
+# -----------------------------------------------------------------------------
+