The ndk-build
tool is a thin wrapper script that calls GNU Make with some command line arguments. You can add any build rules to your Android.mk file that you like written in make, including generating source files.
If you have the generated file name in the LOCAL_SRC_FILES
variable together with the rule to generate this file, make will figure it out. This is a minimal example Android.mk that copies "generated.in" to "generated.c" and then compiles it:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ndkexample
LOCAL_SRC_FILES := generated.c
$(LOCAL_PATH)/generated.c : $(LOCAL_PATH)/generated.in
echo "Generate file"
cp $< $@