Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Make's 'wildcard' function in Android.mk

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?

like image 291
Steve Avatar asked Dec 02 '11 02:12

Steve


People also ask

How do you use a wildcard in makefile?

If you want to do wildcard expansion in such places, you need to use the wildcard function, like this: $(wildcard pattern …) This string, used anywhere in a makefile, is replaced by a space-separated list of names of existing files that match one of the given file name patterns.

What is LOCAL_ cflags?

LOCAL_CFLAGS is applied to the current module, and is undefined after an include $(CLEAR_VARS) . APP_CFLAGS is applied to all modules.

How to find Android mk?

The Android.mk file resides in a subdirectory of your project's jni/ directory, and describes your sources and shared libraries to the build system. It is really a tiny GNU makefile fragment that the build system parses once or more.


1 Answers

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.

like image 192
richq Avatar answered Sep 24 '22 04:09

richq