Skip to content

Commit 2a352b6

Browse files
author
Xavier de Gaye
committed
Issue #26851: Set Android compilation and link flags.
1 parent 4fd9cc1 commit 2a352b6

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ Tests
121121
Build
122122
-----
123123

124+
- Issue #26851: Set Android compilation and link flags.
125+
124126
- Issue #28768: Fix implicit declaration of function _setmode. Patch by
125127
Masayuki Yamamoto
126128

configure

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,6 +3247,9 @@ then
32473247
# a lot of different things including 'define_xopen_source'
32483248
# in the case statement below.
32493249
case "$host" in
3250+
*-*-linux-android*)
3251+
ac_sys_system=Linux-android
3252+
;;
32503253
*-*-linux*)
32513254
ac_sys_system=Linux
32523255
;;
@@ -5640,21 +5643,32 @@ $as_echo_n "checking for the Android API level... " >&6; }
56405643
cat >> conftest.c <<EOF
56415644
#ifdef __ANDROID__
56425645
#include <android/api-level.h>
5643-
__ANDROID_API__
5646+
android_api = __ANDROID_API__
5647+
arm_arch = __ARM_ARCH
56445648
#else
56455649
#error not Android
56465650
#endif
56475651
EOF
56485652

56495653
if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
5650-
ANDROID_API_LEVEL=`grep -v '^#' conftest.out | grep -v '^ *$'`
5654+
ANDROID_API_LEVEL=`sed -n -e '/__ANDROID_API__/d' -e 's/^android_api = //p' conftest.out`
5655+
_arm_arch=`sed -n -e '/__ARM_ARCH/d' -e 's/^arm_arch = //p' conftest.out`
56515656
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ANDROID_API_LEVEL" >&5
56525657
$as_echo "$ANDROID_API_LEVEL" >&6; }
56535658

56545659
cat >>confdefs.h <<_ACEOF
56555660
#define ANDROID_API_LEVEL $ANDROID_API_LEVEL
56565661
_ACEOF
56575662

5663+
5664+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the Android arm ABI" >&5
5665+
$as_echo_n "checking for the Android arm ABI... " >&6; }
5666+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_arm_arch" >&5
5667+
$as_echo "$_arm_arch" >&6; }
5668+
if test "$_arm_arch" = 7; then
5669+
BASECFLAGS="${BASECFLAGS} -mfloat-abi=softfp -mfpu=vfpv3-d16"
5670+
LDFLAGS="${LDFLAGS} -march=armv7-a -Wl,--fix-cortex-a8"
5671+
fi
56585672
else
56595673
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not Android" >&5
56605674
$as_echo "not Android" >&6; }
@@ -9281,6 +9295,7 @@ then
92819295
then CCSHARED="-fPIC";
92829296
else CCSHARED="+z";
92839297
fi;;
9298+
Linux-android*) ;;
92849299
Linux*|GNU*) CCSHARED="-fPIC";;
92859300
BSD/OS*/4*) CCSHARED="-fpic";;
92869301
FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
@@ -9314,6 +9329,7 @@ then
93149329
LINKFORSHARED="-Wl,-E -Wl,+s";;
93159330
# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
93169331
BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
9332+
Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";;
93179333
Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
93189334
# -u libsys_s pulls in all symbols in libsys
93199335
Darwin/*)

configure.ac

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ then
379379
# a lot of different things including 'define_xopen_source'
380380
# in the case statement below.
381381
case "$host" in
382+
*-*-linux-android*)
383+
ac_sys_system=Linux-android
384+
;;
382385
*-*-linux*)
383386
ac_sys_system=Linux
384387
;;
@@ -913,16 +916,25 @@ AC_MSG_CHECKING([for the Android API level])
913916
cat >> conftest.c <<EOF
914917
#ifdef __ANDROID__
915918
#include <android/api-level.h>
916-
__ANDROID_API__
919+
android_api = __ANDROID_API__
920+
arm_arch = __ARM_ARCH
917921
#else
918922
#error not Android
919923
#endif
920924
EOF
921925

922926
if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
923-
ANDROID_API_LEVEL=`grep -v '^#' conftest.out | grep -v '^ *$'`
927+
ANDROID_API_LEVEL=`sed -n -e '/__ANDROID_API__/d' -e 's/^android_api = //p' conftest.out`
928+
_arm_arch=`sed -n -e '/__ARM_ARCH/d' -e 's/^arm_arch = //p' conftest.out`
924929
AC_MSG_RESULT([$ANDROID_API_LEVEL])
925930
AC_DEFINE_UNQUOTED(ANDROID_API_LEVEL, $ANDROID_API_LEVEL, [The Android API level.])
931+
932+
AC_MSG_CHECKING([for the Android arm ABI])
933+
AC_MSG_RESULT([$_arm_arch])
934+
if test "$_arm_arch" = 7; then
935+
BASECFLAGS="${BASECFLAGS} -mfloat-abi=softfp -mfpu=vfpv3-d16"
936+
LDFLAGS="${LDFLAGS} -march=armv7-a -Wl,--fix-cortex-a8"
937+
fi
926938
else
927939
AC_MSG_RESULT([not Android])
928940
fi
@@ -2535,6 +2547,7 @@ then
25352547
then CCSHARED="-fPIC";
25362548
else CCSHARED="+z";
25372549
fi;;
2550+
Linux-android*) ;;
25382551
Linux*|GNU*) CCSHARED="-fPIC";;
25392552
BSD/OS*/4*) CCSHARED="-fpic";;
25402553
FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
@@ -2566,6 +2579,7 @@ then
25662579
LINKFORSHARED="-Wl,-E -Wl,+s";;
25672580
# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
25682581
BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
2582+
Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";;
25692583
Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
25702584
# -u libsys_s pulls in all symbols in libsys
25712585
Darwin/*)

0 commit comments

Comments
 (0)