Using Make's 'wildcard' function in Android.mk
Solution 1
Here's what I've used in the past for doing this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mylibrary
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.c)
include $(BUILD_STATIC_LIBRARY)
'my-dir' is a macro provided by the build system and returns the path of the directory containing the Android.mk file.
Solution 2
If your definition of "this directory" is "the directory containing this makefile", then
$(wildcard $(dir $(lastword $(MAKEFILE_LIST)))*.c)
ought to work.
(caveat: I don't know from Android)
Related videos on Youtube
Steve
Opinions are my own and do not represent the views of my employer or anyone else.
Updated on June 04, 2022Comments
-
Steve almost 2 years
I'm having a problem using Make's
wildcard
function in my Android.mk build file.My other makefiles use a line like this one to specify "All .c files in this folder":
CFILES := $(wildcard *.c)
In my Android.mk file I tried this:
LOCAL_SRC_FILES := $(wildcard *.c)
However, this has the same affect as not including any files at all.
If I include the files manually the build works as I'd expect.
I'm wondering if maybe the current working directory isn't my project path at the time this statement is evaluated? If so, can I use a combination of
$(call my-dir)
and the wildcard function to get the list I want? -
Steve over 12 yearsWow... thank you. That's exactly what I needed. I had written a shell script to generate the .mk dynamically because I was tired of mucking around with it. But this is just what I needed. Cheers.