Issue
In most Android.mk files I find a line that runs something like this:
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
I understand that this line takes the expression on the right of :=
and assigns it to the symbol LOCAL_SRC_FILES
. I understand that $(LOCAL_PATH)
takes the value of the LOCAL_PATH
symbol. But I'm left with two questions:
- What is the
%=%
part all about? - What's the significance of nesting the symbol
$(LOCAL_PATH)
within the broader$(FILE_LIST:...)
expression?
Is this an ordinary makefile syntax (I'm not all that familiar with makefiles) or something else? Where would I find a guide to this syntax? (Don't tell me the Android.mk guide: it doesn't deal with the % symbol.)
Example values might help us talks about this. Let's say that $(LOCAL_PATH)
is /Users/Jeff/dev/
. Let's say that $(FILE_LIST)
without further complication is /Users/Jeff/dev/aaa.c /Users/Jeff/dev/bbb.c /Users/Jeff/dev/ccc.c
. How does the above assignment lead to a useful value for LOCAL_SRC_FILES
?
Solution
Android makefiles are intended to be run using GNU make. The documentation is available online and also should come with your distribution.
The syntax you're asking about are substitution references; basically, the %
is a wildcard that matches zero or more characters, and matches on the left are replaced with the right side.
So $(FILE_LIST:$(LOCAL_PATH)/%=%)
removes the string $(LOCAL_PATH)/
from the start of the FILE_LIST
variable value (if it's there; if not no change is made).
Answered By - MadScientist
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.