I have an Android.mk file that has a number of files for which LOCAL_CFLAGS get applied to them. I would like to apply a different flag to only one of the files out of the many. How can this be accomplished?
I searched the internet from the Android perspective, but didn't find a whole lot. Considering the following example I would like to apply flag TEST3
to file test3.c
only. I looked at Per-file CPPFLAGS in Android.mk, but I couldn't find anything as far as how to use PRIVATE_CPPFLAGS
to one file. Any ideas?
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := test1.c test2.c test3.c
LOCAL_CFLAGS := -DTEST1_2_AND_3
include $(BUILD_SHARED_LIBRARY)
The supported way to achieve your goal is to use a separate static library for C/CPP files that need different parameters. In this particular case, the fix would be as easy as
There is another approach, similar to one I forged a while ago
If
-Dtest3
would do, you can use another hack:See more in How to dynamically get the current compiler target file name in Android.mk's LOCAL_CFLAGS?.