diff --git a/ndk/build/core/clear-vars.mk b/ndk/build/core/clear-vars.mk index 05566a6aa..435247465 100644 --- a/ndk/build/core/clear-vars.mk +++ b/ndk/build/core/clear-vars.mk @@ -19,6 +19,7 @@ NDK_LOCAL_VARS := \ LOCAL_MODULE \ LOCAL_SRC_FILES \ + LOCAL_C_INCLUDES \ LOCAL_CFLAGS \ LOCAL_CXXFLAGS \ LOCAL_CPPFLAGS \ diff --git a/ndk/build/core/definitions.mk b/ndk/build/core/definitions.mk index 6b660a58f..56e50e509 100644 --- a/ndk/build/core/definitions.mk +++ b/ndk/build/core/definitions.mk @@ -369,6 +369,7 @@ $$(_OBJ): PRIVATE_ARM_TEXT := $$(LOCAL_ARM_TEXT) $$(_OBJ): PRIVATE_CC := $$($$(my)CC) $$(_OBJ): PRIVATE_CFLAGS := $$($$(my)CFLAGS) \ $$($$(my)$(LOCAL_ARM_MODE)_$(LOCAL_BUILD_MODE)_CFLAGS) \ + $$(LOCAL_C_INCLUDES:%=-I%) \ -I$$(LOCAL_PATH) \ $$(LOCAL_CFLAGS) \ $$(NDK_APP_CPPFLAGS) \ @@ -427,6 +428,7 @@ $$(_OBJ): PRIVATE_ARM_TEXT := $$(LOCAL_ARM_TEXT) $$(_OBJ): PRIVATE_CXX := $$($$(my)CXX) $$(_OBJ): PRIVATE_CXXFLAGS := $$($$(my)CXXFLAGS) \ $$($$(my)$(LOCAL_ARM_MODE)_$(LOCAL_BUILD_MODE)_CFLAGS) \ + $$(LOCAL_C_INCLUDES:%=-I%) \ -I$$(LOCAL_PATH) \ $$(LOCAL_CFLAGS) \ $$(NDK_APP_CPPFLAGS) \ diff --git a/ndk/docs/ANDROID-MK.TXT b/ndk/docs/ANDROID-MK.TXT index ccdf96e4e..235b4b2d9 100644 --- a/ndk/docs/ANDROID-MK.TXT +++ b/ndk/docs/ANDROID-MK.TXT @@ -319,6 +319,21 @@ LOCAL_CPP_EXTENSION LOCAL_CPP_EXTENSION := .cxx +LOCAL_C_INCLUDES + An optional list of paths, relative to the NDK *root* directory, + which will be appended to the include search path when compiling + all sources (C, C++ and Assembly). For example: + + LOCAL_C_INCLUDES := sources/foo + + Or even: + + LOCAL_C_INCLUDES := $(LOCAL_PATH)/../foo + + These are placed before any corresponding inclusion flag in + LOCAL_CFLAGS / LOCAL_CXXFLAGS / LOCAL_CPPFLAGS + + LOCAL_CFLAGS An optional set of compiler flags that will be passed when building C source files (*not* C++ sources). diff --git a/ndk/docs/CHANGES.TXT b/ndk/docs/CHANGES.TXT index 510a16761..2509fe9b6 100644 --- a/ndk/docs/CHANGES.TXT +++ b/ndk/docs/CHANGES.TXT @@ -28,6 +28,7 @@ current version - Generate proper unoptimized versions of binaries when APP_OPTIM := debug +- Add support for LOCAL_C_INCLUDES in Android.mk ------------------------------------------------------------------------------- android-1.5_r1 released. diff --git a/ndk/docs/HOWTO.TXT b/ndk/docs/HOWTO.TXT index d2fa95ffb..f7a00c3ca 100644 --- a/ndk/docs/HOWTO.TXT +++ b/ndk/docs/HOWTO.TXT @@ -73,22 +73,22 @@ path to the 'foo' module in bar/Android.mk to build it properly. One is tempted to use the following: - LOCAL_CPPFLAGS := -I../foo + LOCAL_C_INCLUDES := ../foo However this will not work because all compilation happens from the root NDK directory (i.e. $NDK_ROOT), and include files must be relative to it. The above line really translates to: - LOCAL_CPPFLAGS := -I$(NDK_ROOT)/../foo + LOCAL_C_INCLUDES := $(NDK_ROOT)/../foo Which adds a non-existing directory to the C include path. The correct line is instead: - LOCAL_CPPFLAGS := -Isources/foo + LOCAL_C_INCLUDES := sources/foo Or even better: - LOCAL_CPPFLAGS := $(LOCAL_PATH)/../foo + LOCAL_C_INCLUDES := $(LOCAL_PATH)/../foo Which uses a path relative to $(LOCAL_PATH), in the case where you would need to move 'foo' and 'bar' to a deeper level in the 'sources' hierarchy.