以递归方式编译目录下的所有cpp文件

时间:2012-08-14 20:44:08

标签: android makefile

我正在编写一个make文件,用于在Android中编译jni代码。 我希望能够递归地编译位于特定文件夹下的所有cpp文件。

我该怎么做? 我尝试使用wildcard命令,但没有得到我需要的结果。

1 个答案:

答案 0 :(得分:0)

Android make系统有一个用于处理此问题的gmake宏。请参阅NDK中的文档doc\ANDROID-MK.html。这是一个摘录:

all-subdir-makefiles
  Returns a list of Android.mk located in all sub-directories of
  the current 'my-dir' path. For example, consider the following
  hierarchy:

    sources/foo/Android.mk
    sources/foo/lib1/Android.mk
    sources/foo/lib2/Android.mk

  If sources/foo/Android.mk contains the single line:

    include $(call all-subdir-makefiles)

  Then it will include automatically sources/foo/lib1/Android.mk and
  sources/foo/lib2/Android.mk

  This function can be used to provide deep-nested source directory
  hierarchies to the build system. Note that by default, the NDK
  will only look for files in sources/*/Android.mk
相关问题