Android.mk -- using wildcards in LOCAL_SRC_FILES

2,848 views
Skip to first unread message

phil

unread,
Aug 17, 2009, 12:14:35 AM8/17/09
to android-ndk
I want to include a bunch of source files in my Android.mk file, but I
don't want to have list them all individually, is there a way to do
this with a wildcard?

I tried:

LOCAL_SRC_FILES := *.c
LOCAL_SRC_FILES += $(addprefix path/to/subdir/, $(C_SOURCES))
LOCAL_SRC_FILES += path/to/subdir/*.c

None of which worked.

Any ideas?

-phil

Rohit Grover

unread,
Aug 17, 2009, 12:20:28 AM8/17/09
to andro...@googlegroups.com
Refer to the documentation for GNU Make. There are may built-in functions for transforming text, including ones for filename manipulation. Perhaps you want to use the 'wildcard' function:

     LOCAL_SRC_FILES += $(wildcard *.c)

David Turner

unread,
Aug 17, 2009, 1:49:53 AM8/17/09
to andro...@googlegroups.com
the wildcard rule should work, but keep in mind two things:

- first, the build scripts are all run from the top-level NDK directory
- the content of LOCAL_SRC_FILES on the other hand must be relative to LOCAL_PATH

so you will end up with something like this:

MY_PREFIX := $(LOCAL_PATH)/subdir/
MY_SOURCES := $(wildcard $(MY_PREFIX)/*.c)
LOCAL_SRC_FILES += $(MY_SOURCES:$(MY_PREFIX)%=%)
Reply all
Reply to author
Forward
0 new messages