# Build C source files into .o
#
-# XXX: TODO: support LOCAL_ARM_MODE
+ifeq ($(LOCAL_ARM_MODE),arm)
+ arm_sources := $(LOCAL_SRC_FILES)
+else
+ arm_sources := $(filter %.arm,$(LOCAL_SRC_FILES))
+ thumb_sources := $(filter-out %.arm,$(LOCAL_SRC_FILES))
+endif
-arm_sources := $(LOCAL_SRC_FILES:%.arm)
+# First, build the 'thumb' sources
+#
+LOCAL_ARM_MODE := thumb
-c_sources := $(filter %.c, \
- $(LOCAL_SRC_FILES) \
- $(arm_sources:%.arm=%))
+$(foreach src,$(filter %.c,$(thumb_sources)), $(call compile-c-source,$(src)))
+$(foreach src,$(filter %.S,$(thumb_sources)), $(call compile-s-source,$(src)))
-s_sources := $(filter %.S, \
- $(LOCAL_SRC_FILES) \
- $(arm_sources:%.arm=%))
+$(foreach src,$(filter %$(LOCAL_CPP_EXTENSION),$(thumb_sources)),\
+ $(call compile-cpp-source,$(src)))
-cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION), \
- $(LOCAL_SRC_FILES) \
- $(arm_sources:%.arm=%))
+# Then, the 'ARM' ones
+#
+LOCAL_ARM_MODE := arm
+arm_sources := $(arm_sources:%.arm=%)
+
+$(foreach src,$(filter %.c,$(arm_sources)), $(call compile-c-source,$(src)))
+$(foreach src,$(filter %.S,$(arm_sources)), $(call compile-s-source,$(src)))
+
+$(foreach src,$(filter %$(LOCAL_CPP_EXTENSION),$(arm_sources)),\
+ $(call compile-cpp-source,$(src)))
#
-# The following will update LOCAL_OBJECTS and LOCAL_DEPENDENCY_DIRS
+# The compile-xxx-source calls updated LOCAL_OBJECTS and LOCAL_DEPENDENCY_DIRS
#
-$(foreach src,$(c_sources), $(call compile-c-source,$(src)))
-$(foreach src,$(s_sources), $(call compile-s-source,$(src)))
-$(foreach src,$(cpp_sources), $(call compile-cpp-source,$(src)))
-
ALL_DEPENDENCY_DIRS += $(sort $(LOCAL_DEPENDENCY_DIRS))
CLEAN_OBJS_DIRS += $(LOCAL_OBJS_DIR)
However, if for some reason you need to disable this check, set this
variable to 'true'. Note that the corresponding shared library may fail
to load at runtime.
+
+LOCAL_ARM_MODE
+ By default, ARM target binaries will be generated in 'thumb' mode, where
+ each instruction are 16-bit wide. You can define this variable to 'arm'
+ if you want to force the generation of the module's object files in
+ 'arm' (32-bit instructions) mode. E.g.:
+
+ LOCAL_ARM_MODE := arm
+
+ Note that you can also instruct the build system to only build specific
+ sources in arm mode by appending an '.arm' suffix to its source file
+ name. For example, with:
+
+ LOCAL_SRC_FILES := foo.c bar.c.arm
+
+ Tells the build system to always compile 'bar.c' in arm mode, and to
+ build foo.c according to the value of LOCAL_ARM_MODE.
+
+ NOTE: Setting APP_OPTIM to 'debug' in your Application.mk will also force
+ the generation of ARM binaries as well. This is due to bugs in the
+ toolchain debugger that don't deal too well with thumb code.
The Android NDK currently requires a Linux, OS X or Windows host operating system.
Windows users will need to install Cygwin (http://www.cygwin.com) to use it. Note
-that running the NDK under MSys has not been tested.
+that running the NDK under MSys is not supported.
You will need to have the Android SDK and its dependencies installed. The NDK
cannot generate final application packages (.apk files), only the shared library
II. Preparing your installation prebuilt cross-toolchain binaries:
------------------------------------------------
+------------------------------------------------------------------
After installing and unarchiving the NDK, you will need to run the following
command from the root folder: