11#! /bin/bash
2+
3+ set -e
4+
25# Cross-compile environment for Android on ARMv7 and x86
36#
47# Contents licensed under the terms of the OpenSSL license
912
1013# ####################################################################
1114
15+ echo ===========setenv-android starts=============
16+
1217# Set ANDROID_NDK_ROOT to you NDK location. For example,
1318# /opt/android-ndk-r8e or /opt/android-ndk-r9. This can be done in a
1419# login script. If ANDROID_NDK_ROOT is not specified, the script will
2227# list in $ANDROID_NDK_ROOT/toolchains. This value is always used.
2328# _ANDROID_EABI="x86-4.6"
2429# _ANDROID_EABI="arm-linux-androideabi-4.6"
25- _ANDROID_EABI=" arm-linux-androideabi-4.8"
26- # _ANDROID_EABI="arm-linux-androideabi-4.9"
30+ # _ANDROID_EABI="arm-linux-androideabi-4.8"
31+ _ANDROID_EABI=" arm-linux-androideabi-4.9"
2732
2833# Set _ANDROID_ARCH to the architecture you are building for.
2934# This value is always used.
103108# doing things according to the NDK documentation for Ice Cream Sandwich.
104109# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
105110
106- ANDROID_TOOLCHAIN=" "
107- for host in " linux-x86_64" " linux-x86" " darwin-x86_64" " darwin-x86"
108- do
109- if [ -d " $ANDROID_NDK_ROOT /toolchains/$_ANDROID_EABI /prebuilt/$host /bin" ]; then
110- ANDROID_TOOLCHAIN=" $ANDROID_NDK_ROOT /toolchains/$_ANDROID_EABI /prebuilt/$host /bin"
111- break
112- fi
113- done
111+ if [ -z " $ANDROID_TOOLCHAIN " ]; then
112+
113+ ANDROID_TOOLCHAIN=" "
114+ for host in " linux-x86_64" " linux-x86" " darwin-x86_64" " darwin-x86"
115+ do
116+ if [ -d " $ANDROID_NDK_ROOT /toolchains/$_ANDROID_EABI /prebuilt/$host /bin" ]; then
117+ export ANDROID_TOOLCHAIN=" $ANDROID_NDK_ROOT /toolchains/$_ANDROID_EABI /prebuilt/$host /bin"
118+ break
119+ fi
120+ done
121+ fi
122+
114123
115124# Error checking
116125if [ -z " $ANDROID_TOOLCHAIN " ] || [ ! -d " $ANDROID_TOOLCHAIN " ]; then
@@ -120,12 +129,12 @@ if [ -z "$ANDROID_TOOLCHAIN" ] || [ ! -d "$ANDROID_TOOLCHAIN" ]; then
120129fi
121130
122131case $_ANDROID_ARCH in
123- arch-arm)
132+ arch-arm)
124133 ANDROID_TOOLS=" arm-linux-androideabi-gcc arm-linux-androideabi-ranlib arm-linux-androideabi-ld"
125134 ;;
126- arch-x86)
135+ arch-x86)
127136 ANDROID_TOOLS=" i686-linux-android-gcc i686-linux-android-ranlib i686-linux-android-ld"
128- ;;
137+ ;;
129138 * )
130139 echo " ERROR ERROR ERROR"
131140 ;;
151160
152161# For the Android SYSROOT. Can be used on the command line with --sysroot
153162# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
154- export ANDROID_SYSROOT=" $ANDROID_NDK_ROOT /platforms/$_ANDROID_API /$_ANDROID_ARCH "
163+ # export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
164+ export ANDROID_SYSROOT=" $ANDROID_TOOLCHAIN /../sysroot"
165+ export NDK_SYSROOT=" $ANDROID_NDK_ROOT /sysroot"
155166export CROSS_SYSROOT=" $ANDROID_SYSROOT "
156- export NDK_SYSROOT=" $ANDROID_SYSROOT "
157167
158168# Error checking
159169if [ -z " $ANDROID_SYSROOT " ] || [ ! -d " $ANDROID_SYSROOT " ]; then
210220
211221# For the Android toolchain
212222# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
213- export ANDROID_SYSROOT=" $ANDROID_NDK_ROOT /platforms/$_ANDROID_API /$_ANDROID_ARCH "
214223export SYSROOT=" $ANDROID_SYSROOT "
215- export NDK_SYSROOT=" $ANDROID_SYSROOT "
224+ export NDK_SYSROOT=" $ANDROID_NDK_ROOT /sysroot "
216225export ANDROID_NDK_SYSROOT=" $ANDROID_SYSROOT "
217226export ANDROID_API=" $_ANDROID_API "
218227
@@ -221,15 +230,20 @@ export ANDROID_API="$_ANDROID_API"
221230export ANDROID_DEV=" $ANDROID_NDK_ROOT /platforms/$_ANDROID_API /$_ANDROID_ARCH /usr"
222231export HOSTCC=gcc
223232
224- VERBOSE=1
225- if [ ! -z " $VERBOSE " ] && [ " $VERBOSE " != " 0" ]; then
226- echo " ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT "
227- echo " ANDROID_ARCH: $_ANDROID_ARCH "
228- echo " ANDROID_EABI: $_ANDROID_EABI "
229- echo " ANDROID_API: $ANDROID_API "
230- echo " ANDROID_SYSROOT: $ANDROID_SYSROOT "
231- echo " ANDROID_TOOLCHAIN: $ANDROID_TOOLCHAIN "
232- echo " FIPS_SIG: $FIPS_SIG "
233- echo " CROSS_COMPILE: $CROSS_COMPILE "
234- echo " ANDROID_DEV: $ANDROID_DEV "
235- fi
233+ echo " ANDROID_TOOLS: $ANDROID_TOOLS "
234+ echo " ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT "
235+ echo " ANDROID_ARCH: $_ANDROID_ARCH "
236+ echo " ANDROID_EABI: $_ANDROID_EABI "
237+ echo " ANDROID_API: $ANDROID_API "
238+ echo " ANDROID_SYSROOT: $ANDROID_SYSROOT "
239+ echo " ANDROID_TOOLCHAIN: $ANDROID_TOOLCHAIN "
240+ echo " FIPS_SIG: $FIPS_SIG "
241+ echo " CROSS_SYS_ROOT: $CROSS_SYSROOT "
242+ echo " NDK_SYSROOT: $NDK_SYSROOT "
243+ echo " MACHINE: $MACHINE "
244+ echo " SYSTEM: $SYSTEM "
245+ echo " ARCH: $ARCH "
246+ echo " CROSS_COMPILE: $CROSS_COMPILE "
247+ echo " ANDROID_DEV: $ANDROID_DEV "
248+
249+ echo ===========setenv-android completed=============
0 commit comments