From 8caab6db57875782d1f7398d5a6b7b1dbbf1665a Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 6 Mar 2017 10:54:00 +0100 Subject: [PATCH] Simplify the python2 detection code --- dist-build/android-build.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dist-build/android-build.sh b/dist-build/android-build.sh index 6fe9fcf3..f24f84de 100755 --- a/dist-build/android-build.sh +++ b/dist-build/android-build.sh @@ -16,16 +16,29 @@ if [ -z "$ANDROID_NDK_HOME" ]; then fi if [ ! -f ./configure ]; then - echo "Can't find ./configure. Wrong directory or haven't run autogen.sh?" + echo "Can't find ./configure. Wrong directory or haven't run autogen.sh?" >&2 exit 1 fi if [ "x$TARGET_ARCH" = 'x' ] || [ "x$ARCH" = 'x' ] || [ "x$HOST_COMPILER" = 'x' ]; then - echo "You shouldn't use android-build.sh directly, use android-[arch].sh instead" + echo "You shouldn't use android-build.sh directly, use android-[arch].sh instead" >&2 exit 1 fi -export PYTHON2=$(python2 --version > /dev/null 2>&1 && echo python2 || echo python) +if [ "x$PYTHON2" = 'x' ]; then + for c in python2 python; do + if "$c" --version 2> /dev/null; then + PYTHON2="$c" + break + fi + done +fi +if [ "x$PYTHON2" = 'x' ]; then + echo "Python 2.x is required by the Android compilation toolchain" >&2 + exit 1 +fi + +export PYTHON2 export MAKE_TOOLCHAIN="${ANDROID_NDK_HOME}/build/tools/make_standalone_toolchain.py" export PREFIX="$(pwd)/libsodium-android-${TARGET_ARCH}"