Coola
Coola

Reputation: 499

How to write Android.mk file with source files in sub directories?

I have a structure like this:

folder1

      |--subfolder1

          |--.cpp files .h files

      |--other .cpp files

folder1 contains cpp files and 1 subfolder which also contains cpp files and head files

How will I write my Android.mk file so that all the source files, including those inside subfolder1 will be included during compilation?

i tried

LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/\*/\*.*) $(wildcard *.*) 

but it does not work, it didnt include the source files which are inside the subdirectories

Upvotes: 5

Views: 4723

Answers (2)

Bill Hoo
Bill Hoo

Reputation: 647

this may help. quote:

If you want to define Android.mk files in sub-directories, you should include them explicitly in your top-level Android.mk. There is even a helper function to do that, i.e. use:

include $(call all-subdir-makefiles)

This will include all Android.mk files in sub-directories of the current build file's path.

copied from android-ndk-r8d doc.

that means you should write a Android.mk file to describe your .cpp in each of your subdir, and write a top-level Android.mk to include them by "include $(call all-subdir-makefiles)"

now it may like this:

|-jni

|----Android.mk (top level one)

|--------subfolder1

|------------Android.mk (to describe your a.cpp)

|------------a.cpp/a.h

|----other .cpp/.h files

Upvotes: 4

medazzo
medazzo

Reputation: 99

try :

LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*/*.cpp)

Upvotes: 4

Related Questions