提交 df3a1551 编写于 作者: A Andy Polyakov

Configurations/15-android.conf: detect clang by PATH, not by CC.

Since they intend to omit gcc, it's more appropriate to simply detect
if there is NDK's clang on PATH, as opposite to requiring to specify it
with CC=clang (and looking for it on PATH).

Also detect NDK version and default to armv7-a for NDK>16.

Address failure to recognize -D__ADNDROID_API__=N in CPPFLAGS.
Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5613)
上级 f39276fd
#### Android... #### Android...
# #
# See NOTES.ANDROID for details. But don't miss platform-specific # See NOTES.ANDROID for details, and don't miss platform-specific
# comments below... # comments below...
{ {
...@@ -20,13 +20,26 @@ ...@@ -20,13 +20,26 @@
die "\$ANDROID_NDK is not defined" if (!$ndk); die "\$ANDROID_NDK is not defined" if (!$ndk);
die "\$ANDROID_NDK=$ndk is invalid" if (!-d "$ndk/platforms"); die "\$ANDROID_NDK=$ndk is invalid" if (!-d "$ndk/platforms");
my $ndkver = undef;
if (open my $fh, "<$ndk/source.properties") {
local $_;
while(<$fh>) {
if (m|Pkg\.Revision\s*=\s*([0-9]+)|) {
$ndkver = $1;
last;
}
}
close $fh;
}
my $sysroot; my $sysroot;
if (!($sysroot = $ENV{CROSS_SYSROOT})) { if (!($sysroot = $ENV{CROSS_SYSROOT})) {
my $api = "*"; my $api = "*";
# see if user passed -D__ANDROID_API__=N # see if user passed -D__ANDROID_API__=N
foreach (@{$useradd{CPPDEFINES}}) { foreach (@{$useradd{CPPDEFINES}}, @{$user{CPPFLAGS}}) {
if (m|__ANDROID_API__=([0-9]+)|) { if (m|__ANDROID_API__=([0-9]+)|) {
$api = $1; $api = $1;
last; last;
...@@ -51,20 +64,24 @@ ...@@ -51,20 +64,24 @@
my $cflags = "-Wa,--noexecstack"; my $cflags = "-Wa,--noexecstack";
my $cppflags; my $cppflags;
# see if user passed CC=clang # see if there is NDK clang on $PATH
if ($user{CC} eq "clang") { if (which("clang") =~ m|^$ndk/.*/prebuilt/([^/]+)/|) {
if (which("clang") !~ m|^$ndk/.*/prebuilt/([^/]+)/|) {
die "no NDK clang on \$PATH";
}
my $host=$1; my $host=$1;
# harmonize with gcc default # harmonize with gcc default
(my $tridefault = $triarch) =~ s/^arm-/armv5te-/; my $arm = $ndkver > 16 ? "armv7a" : "armv5te";
(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 \$(ANDROID_NDK)/toolchains"
. "/$tritools-4.9/prebuilt/$host"; . "/$tritools-4.9/prebuilt/$host";
$user{CC} = "clang" if ($user{CC} !~ m|clang|);
$user{CROSS_COMPILE} = undef; $user{CROSS_COMPILE} = undef;
} elsif ($user{CC} eq "clang") {
die "no NDK clang on \$PATH";
} else { } else {
if (which("$triarch-gcc") !~ m|^$ndk/.*/prebuilt/([^/]+)/|) {
die "no NDK $triarch-gcc on \$PATH";
}
$cflags .= " -mandroid"; $cflags .= " -mandroid";
$user{CROSS_COMPILE} = "$triarch-"; $user{CROSS_COMPILE} = "$triarch-";
} }
...@@ -138,7 +155,7 @@ my %targets = ( ...@@ -138,7 +155,7 @@ my %targets = (
# compiler defaults, which is not necessarily what you had # compiler defaults, which is not necessarily what you had
# in mind, in which case you would have to pass additional # in mind, in which case you would have to pass additional
# -march and/or -mfloat-abi flags. NDK defaults to armv5te. # -march and/or -mfloat-abi flags. NDK defaults to armv5te.
# Some NDK versions reportedly require additional -latomic. # Newer NDK versions reportedly require additional -latomic.
# #
inherit_from => [ "android", asm("armv4_asm") ], inherit_from => [ "android", asm("armv4_asm") ],
bn_ops => add("RC4_CHAR"), bn_ops => add("RC4_CHAR"),
......
...@@ -43,10 +43,11 @@ ...@@ -43,10 +43,11 @@
conflict, and mixing the two is therefore not supported. Migration to conflict, and mixing the two is therefore not supported. Migration to
CROSS_SYSROOT-less setup is recommended. CROSS_SYSROOT-less setup is recommended.
One can engage clang by passing CC=clang to Configure. In such case One can engage clang by adjusting PATH to cover NDK's clang. Just keep
PATH needs even more adjustments to cover NDK's clang itself, as well in mind that if you miss it, Configure will try to use gcc... Also,
as unprefixed, yet target-specific, ar and ranlib (or not, if you use PATH would need even further adjustment to cover unprefixed, yet
binutils-multiarch on your Linux). target-specific, ar and ranlib (or not, if you use binutils-multiarch
on your Linux).
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.
先完成此消息的编辑!
想要评论请 注册