I am currently trying to build a native module using Android's NDK. My project consists of several source files (e.g.: FILENAME.c) and for each of them I need to declare a define in their CFLAGS (-DOPERATION_FILENAME).
In order to do that I need to dynamically fetch the name of the current target file of the Android NDK's cross-compiler and use it to for the define value.
I could not find any information about how to do this and the Makefile way (CFLAGS += -DOPERATION_echo $* | sed 's/_$$//'
) does not apply/work here.
My current Android.mk looks like this:
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := libmpn
LOCAL_SRC_FILES := \
<cut>
LOCAL_CFLAGS := \
-std=gnu99 \
-DHAVE_CONFIG_H \
-D__GMP_WITHIN_GMP \
-O2 \
-pedantic \
-fomit-frame-pointer \
-mfloat-abi=softfp \
-DOPERATION_`echo $* | sed 's/_$$//'`
include $(BUILD_SHARED_LIBRARY)
Does anyone know of a working way to get the file name of the current cross-compiler target in Android.mk? Thanks!
My other option is to execute in the LOCAL_CFLAGS field some sort of script that prints the current target of the compiler (e.g.: build a list of source files and consume the first line at every iteration) but I would gladly avoid doing that as it does not seem the proper solution here.
get-src-file-target-cflags = $(LOCAL_SRC_FILES_TARGET_CFLAGS.$1) -DOPERATION_$(basename $1)
Enjoy,
Alex