I’m working on an Android.mk file in which, for a single module, one of the files needs different CPPFLAGS; namely, it needs -frtti enabled, while others need the Android default of -fno-rtti.
The obvious solution was target-specific variables, but oddly they do not seem to affect compilation, even with some fiddling to ensure the values should be fixed at the right time.
Here’s an extract from my Android.mk (names changed to protect me):
LOCAL_MODULE := foo_bar
LOCAL_SRC_FILES := \
foo_bar.cpp \
foo_baz.cpp
my_intermediates:= $(local-intermediates-dir)/foo_baz.o
$(my_intermediates): LOCAL_CPPFLAGS := -frtti
I have tried simply doing foo_baz.o: in lieu of $(my_intermediates), and have tried substituting += for := to no change.
So, is there an Android-specific way to override CPPFLAGS (or CFLAGS) for a specific source file?
(In this case I’m using the Eclair Android sources, though it may apply to the NDK; see my answer, below.)
As is usual, having asked the question after spending a lot of time on it, I have found the answer in short order. I need to use
PRIVATE_CPPFLAGSinstead ofLOCAL_CPPFLAGS.However, this only appears to be the case for the Android source distribution (at least Eclair) and NDK r6b. If I was using NDK r6, this probably would have worked as it stands.