[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: my busybox +android bionic + ndk tips, etc
From:       Hin-Tak Leung <htl10 () users ! sourceforge ! net>
Date:       2011-08-29 23:19:45
Message-ID: 1314659985.21557.YahooMailClassic () web29515 ! mail ! ird ! yahoo ! com
[Download RAW message or body]

--- On Mon, 29/8/11, Dan Fandrich <dan@coneharvesters.com> wrote:
<snipped>
> These are already worked around in platform.h, and I see
> why they're not
> working for you:
> 
> > 5. The android ndk compiler preprocessor defines 
> > #define __ANDROID__ 1
> > this is probably useful to distinguish it from other
> ARM-targeted cross-gcc's.
> 
> Android builds themselves use #define ANDROID 1 instead,
> and that's what the
> android_defconfig defines to enable an Android build
> configuration. If the 
> NDK standalone toolchain enables __ANDROID__ instead, then
> Busybox should
> probably switch to that instead.
> 
> > I hope this info is useful to somebody... and hope
> that busybox can be built cleanly with the android ndk
> soon... :-).
> 
> Can you try setting -DANDROID in your .config file and see
> if that makes it
> work for you?

Yeah - thanks for the tips about platform.h and -DANDROID . Here is a little patch to \
make it build on my machine. It is so much cleaner now just with a few warnings about \
implicit declaration and format mis-match, go to completion generating a 694370 bytes \
for busybox_unstripped and 535548 bytes for busybox (stripped).

Some explanation of the patch:
1. ndk does not have a libcrypt, and libcrypt does not seem to be needed either! I \
don't have a better way to test for this other than using the ndk compiler prefix \
(probably should test for "i686-android-linux-", also - ndk ships two compilers, the \
other for x86-based android).

2. I thought of replacing ANDROID with __ANDROID__, but then there are probably other \
arm-targeted gcc's, which might want to define ANDROID manually, same with commenting \
out the old CFLAGS vs removing it.

Please feel free to improve the patch before committing.


["0001-Building-with-Android-NDK-against-android-8.patch" (text/x-patch)]

From 7f9fe203ffd8e9d66f6b2846978f88c1fb188e7d Mon Sep 17 00:00:00 2001
From: Hin-Tak Leung <htl10@users.sourceforge.net>
Date: Mon, 29 Aug 2011 23:57:40 +0100
Subject: [PATCH] Building with Android NDK against android-8

Tested with the standalone toolchain from ndk r6:
android-ndk-r6/build/tools/make-standalone-toolchain.sh \
--platform=android-8

Signed-off-by: Hin-Tak Leung <htl10@users.sourceforge.net>
---
 Makefile.flags            |    5 ++++-
 configs/android_defconfig |    6 ++++--
 include/platform.h        |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Makefile.flags b/Makefile.flags
index b3e1371..b6385d7 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -97,7 +97,10 @@ CFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_CFLAGS)))
 #"))
 endif
 
-LDLIBS += m crypt
+LDLIBS += m
+ifneq ($(CONFIG_CROSS_COMPILER_PREFIX),"arm-linux-androideabi-")
+LDLIBS += crypt
+endif
 
 ifeq ($(CONFIG_PAM),y)
 LDLIBS += pam pam_misc
diff --git a/configs/android_defconfig b/configs/android_defconfig
index 7e5232a..ee71c1a 100644
--- a/configs/android_defconfig
+++ b/configs/android_defconfig
@@ -61,7 +61,8 @@ CONFIG_FEATURE_SYSLOG=y
 # CONFIG_FEATURE_INDIVIDUAL is not set
 # CONFIG_FEATURE_SHARED_BUSYBOX is not set
 # CONFIG_LFS is not set
-CONFIG_CROSS_COMPILER_PREFIX="arm-eabi-"
+#CONFIG_CROSS_COMPILER_PREFIX="arm-eabi-"
+CONFIG_CROSS_COMPILER_PREFIX="arm-linux-androideabi-"
 #
 # Removed:
 # warning flags:
@@ -79,7 +80,8 @@ CONFIG_CROSS_COMPILER_PREFIX="arm-eabi-"
 # -fgcse-after-reload
 # -frerun-cse-after-loop
 # -frename-registers
-CONFIG_EXTRA_CFLAGS="-I$A/system/core/include -I$A/bionic/libc/arch-arm/include \
-I$A/bionic/libc/include -I$A/bionic/libc/kernel/common \
-I$A/bionic/libc/kernel/arch-arm -I$A/bionic/libm/include \
-I$A/bionic/libm/include/arch/arm -include \
$A/system/core/include/arch/linux-arm/AndroidConfig.h \
-I$A/system/core/include/arch/linux-arm/ -DANDROID -DSK_RELEASE -nostdlib \
-march=armv7-a -msoft-float -mfloat-abi=softfp -mfpu=neon -mthumb -mthumb-interwork \
-fpic -fno-short-enums -fgcse-after-reload -frerun-cse-after-loop -frename-registers" \
+#CONFIG_EXTRA_CFLAGS="-I$A/system/core/include -I$A/bionic/libc/arch-arm/include \
-I$A/bionic/libc/include -I$A/bionic/libc/kernel/common \
-I$A/bionic/libc/kernel/arch-arm -I$A/bionic/libm/include \
-I$A/bionic/libm/include/arch/arm -include \
$A/system/core/include/arch/linux-arm/AndroidConfig.h \
-I$A/system/core/include/arch/linux-arm/ -DANDROID -DSK_RELEASE -nostdlib \
-march=armv7-a -msoft-float -mfloat-abi=softfp -mfpu=neon -mthumb -mthumb-interwork \
-fpic -fno-short-enums -fgcse-after-reload -frerun-cse-after-loop -frename-registers" \
+CONFIG_EXTRA_CFLAGS=""  
 #
 # Debugging Options
diff --git a/include/platform.h b/include/platform.h
index 826a4c4..aa1bc33 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -433,7 +433,7 @@ typedef unsigned smalluint;
 # undef HAVE_STPCPY
 #endif
 
-#if defined(ANDROID)
+#if defined(ANDROID) || defined(__ANDROID__)
 # undef HAVE_DPRINTF
 # undef HAVE_GETLINE
 # undef HAVE_STPCPY
-- 
1.7.6



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic