提交 6b4f9892 编写于 作者: R Richard Levitte

Android build: use ANDROID_NDK_HOME rather than ANDROID_NDK

It apepars that ANDROID_NDK_HOME is the recommended standard
environment variable for the NDK.

We retain ANDROID_NDK as a fallback.

Fixes #8101
Reviewed-by: NMatt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8103)

(cherry picked from commit 6e826c471b7f0431391a4e9f9484f6ea2833774a)
上级 2d190d64
...@@ -22,13 +22,18 @@ ...@@ -22,13 +22,18 @@
return $android_ndk = { bn_ops => "BN_AUTO" }; return $android_ndk = { bn_ops => "BN_AUTO" };
} }
my $ndk = $ENV{ANDROID_NDK}; my $ndk_var;
die "\$ANDROID_NDK is not defined" if (!$ndk); my $ndk;
foreach $ndk_var (qw(ANDROID_NDK_HOME ANDROID_NDK)) {
$ndk = $ENV{$ndk_var};
last if defined $ndk;
}
die "\$ANDROID_NDK_HOME is not defined" if (!$ndk);
if (!-d "$ndk/platforms" && !-f "$ndk/AndroidVersion.txt") { if (!-d "$ndk/platforms" && !-f "$ndk/AndroidVersion.txt") {
# $ndk/platforms is traditional "all-inclusive" NDK, while # $ndk/platforms is traditional "all-inclusive" NDK, while
# $ndk/AndroidVersion.txt is so-called standalone toolchain # $ndk/AndroidVersion.txt is so-called standalone toolchain
# tailored for specific target down to API level. # tailored for specific target down to API level.
die "\$ANDROID_NDK=$ndk is invalid"; die "\$ANDROID_NDK_HOME=$ndk is invalid";
} }
$ndk = canonpath($ndk); $ndk = canonpath($ndk);
...@@ -90,7 +95,7 @@ ...@@ -90,7 +95,7 @@
(my $tridefault = $triarch) =~ s/^arm-/$arm-/; (my $tridefault = $triarch) =~ s/^arm-/$arm-/;
(my $tritools = $triarch) =~ s/(?:x|i6)86(_64)?-.*/x86$1/; (my $tritools = $triarch) =~ s/(?:x|i6)86(_64)?-.*/x86$1/;
$cflags .= " -target $tridefault " $cflags .= " -target $tridefault "
. "-gcc-toolchain \$(ANDROID_NDK)/toolchains" . "-gcc-toolchain \$($ndk_var)/toolchains"
. "/$tritools-4.9/prebuilt/$host"; . "/$tritools-4.9/prebuilt/$host";
$user{CC} = "clang" if ($user{CC} !~ m|clang|); $user{CC} = "clang" if ($user{CC} !~ m|clang|);
$user{CROSS_COMPILE} = undef; $user{CROSS_COMPILE} = undef;
...@@ -127,13 +132,13 @@ ...@@ -127,13 +132,13 @@
die "no $incroot/$triarch" if (!-d "$incroot/$triarch"); die "no $incroot/$triarch" if (!-d "$incroot/$triarch");
$incroot =~ s|^$ndk/||; $incroot =~ s|^$ndk/||;
$cppflags = "-D__ANDROID_API__=$api"; $cppflags = "-D__ANDROID_API__=$api";
$cppflags .= " -isystem \$(ANDROID_NDK)/$incroot/$triarch"; $cppflags .= " -isystem \$($ndk_var)/$incroot/$triarch";
$cppflags .= " -isystem \$(ANDROID_NDK)/$incroot"; $cppflags .= " -isystem \$($ndk_var)/$incroot";
} }
$sysroot =~ s|^$ndk/||; $sysroot =~ s|^$ndk/||;
$android_ndk = { $android_ndk = {
cflags => "$cflags --sysroot=\$(ANDROID_NDK)/$sysroot", cflags => "$cflags --sysroot=\$($ndk_var)/$sysroot",
cppflags => $cppflags, cppflags => $cppflags,
bn_ops => $arch =~ m/64$/ ? "SIXTY_FOUR_BIT_LONG" bn_ops => $arch =~ m/64$/ ? "SIXTY_FOUR_BIT_LONG"
: "BN_LLONG", : "BN_LLONG",
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
platform. Though you still need to know the prefix to extend your PATH, platform. Though you still need to know the prefix to extend your PATH,
in order to invoke $(CROSS_COMPILE)gcc and company. (Configure will fail in order to invoke $(CROSS_COMPILE)gcc and company. (Configure will fail
and give you a hint if you get it wrong.) Apart from PATH adjustment and give you a hint if you get it wrong.) Apart from PATH adjustment
you need to set ANDROID_NDK environment to point at NDK directory you need to set ANDROID_NDK_HOME environment to point at NDK directory
as /some/where/android-ndk-<ver>. Both variables are significant at both as /some/where/android-ndk-<ver>. Both variables are significant at both
configuration and compilation times. NDK customarily supports multiple configuration and compilation times. NDK customarily supports multiple
Android API levels, e.g. android-14, android-21, etc. By default latest Android API levels, e.g. android-14, android-21, etc. By default latest
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
target platform version. For example, to compile for ICS on ARM with target platform version. For example, to compile for ICS on ARM with
NDK 10d: NDK 10d:
export ANDROID_NDK=/some/where/android-ndk-10d export ANDROID_NDK_HOME=/some/where/android-ndk-10d
PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH PATH=$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH
./Configure android-arm -D__ANDROID_API__=14 ./Configure android-arm -D__ANDROID_API__=14
make make
Caveat lector! Earlier OpenSSL versions relied on additional CROSS_SYSROOT Caveat lector! Earlier OpenSSL versions relied on additional CROSS_SYSROOT
variable set to $ANDROID_NDK/platforms/android-<api>/arch-<arch> to variable set to $ANDROID_NDK_HOME/platforms/android-<api>/arch-<arch> to
appoint headers-n-libraries' location. It's still recognized in order appoint headers-n-libraries' location. It's still recognized in order
to facilitate migration from older projects. However, since API level to facilitate migration from older projects. However, since API level
appears in CROSS_SYSROOT value, passing -D__ANDROID_API__=N can be in appears in CROSS_SYSROOT value, passing -D__ANDROID_API__=N can be in
...@@ -53,9 +53,9 @@ ...@@ -53,9 +53,9 @@
Another option is to create so called "standalone toolchain" tailored Another option is to create so called "standalone toolchain" tailored
for single specific platform including Android API level, and assign its for single specific platform including Android API level, and assign its
location to ANDROID_NDK. In such case you have to pass matching target location to ANDROID_NDK_HOME. In such case you have to pass matching
name to Configure and shouldn't use -D__ANDROID_API__=N. PATH adjustment target name to Configure and shouldn't use -D__ANDROID_API__=N. PATH
becomes simpler, $ANDROID_NDK/bin:$PATH suffices. adjustment becomes simpler, $ANDROID_NDK_HOME/bin:$PATH suffices.
Running tests (on Linux) Running tests (on Linux)
------------------------ ------------------------
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册