You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

  1. #!/bin/sh
  2. if [ -z "$ANDROID_NDK_HOME" ]; then
  3. echo "You should probably set ANDROID_NDK_HOME to the directory containing"
  4. echo "the Android NDK"
  5. exit
  6. fi
  7. if [ ! -f ./configure ]; then
  8. echo "Can't find ./configure. Wrong directory or haven't run autogen.sh?"
  9. exit 1
  10. fi
  11. if [ "x$TARGET_ARCH" = 'x' ] || [ "x$HOST_COMPILER" = 'x' ]; then
  12. echo "You shouldn't use android-build.sh directly, use android-[arch].sh instead"
  13. exit 1
  14. fi
  15. export MAKE_TOOLCHAIN="${ANDROID_NDK_HOME}/build/tools/make-standalone-toolchain.sh"
  16. export PREFIX="$(pwd)/libsodium-android-${TARGET_ARCH}"
  17. export TOOLCHAIN_DIR="$(pwd)/android-toolchain-${TARGET_ARCH}"
  18. export PATH="${PATH}:${TOOLCHAIN_DIR}/bin"
  19. # Clean up before build
  20. rm -rf "${TOOLCHAIN_DIR}" "${PREFIX}"
  21. $MAKE_TOOLCHAIN --platform="${NDK_PLATFORM:-android-14}" \
  22. --arch="$TARGET_ARCH" \
  23. --install-dir="$TOOLCHAIN_DIR" && \
  24. ./configure --host="${HOST_COMPILER}" \
  25. --with-sysroot="${TOOLCHAIN_DIR}/sysroot" \
  26. --prefix="${PREFIX}" \
  27. --enable-minimal \
  28. --disable-soname-versions && \
  29. make clean && \
  30. make -j3 install && \
  31. echo "libsodium has been installed into $PREFIX"