Android.mk PREBUILT_SHARED_LIBRARY how to generate LOCAL_SRC_FILES file from script?
<p>I have an NDK project where I build the shared libraries using the cross-compiler and standard gnu make utils.  That is done with a separate script.  But for the purpose of using the libraries in my project, I would like my <code>Android.mk</code> process to call my script to generate the shared library if it hasn't already been built, and then have <code>Android.mk</code> wrap it using the <code>PREBUILT_SHARED_LIBRARY</code> process.</p>

<p>Currently, if I run my script offline to generate <code>libmy_so.so</code>, then the following makefile will work.  However, if I don't run the script explicitly first, I get the following error:</p>

<p><code>Android NDK: ERROR:/path_to_project/Android.mk:my_module: LOCAL_SRC_FILES points to a missing file</code></p>

<p>and my script is never called, so the make process is failing before even trying to resolve the dependency.</p>

<pre><code>include $(CLEAR_VARS)

LOCAL_MODULE        := my_module
LOCAL_SRC_FILES     := libmy_so.so
LOCAL_EXPORT_CFLAGS := # some stuff
LOCAL_EXPORT_LDLIBS := # some stuff
$(LOCAL_PATH)/libmy_so.so:
    echo "generate file"
    $(shell run_script_that_creates_libmy_so.so)

include $(PREBUILT_SHARED_LIBRARY)
</code></pre>

<p>Is there a clean solution to this?  I am even ok with running the script automatically as a preprocessing step (I can always have my script quietly exit if the file exists already), but I have not found an incantation that allows the <code>LOCAL_SRC_FILES</code> variable to point to a non-existent file.  I have considered placing a dummy <code>libmy_so.so</code> to start, but that is an ugly hack.</p>