pokey909
pokey909

Reputation: 1837

post-build step: Copy lib and headers to specific location

I'm trying to find information on how to do add a post-build target for my static library that copies the library and its associated header files to a specific directory.

I read about LOCAL_EXPORT_C_INCLUDES but I'm still unsure what exactly it does, since it doesnt seem to copy headers for me.

Generally I want to copy the lib to $(LOCAL_PATH)/../lib and the headers $(LOCAL_PATH)/../include.

Upvotes: 2

Views: 3414

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57163

Add the following to the end of your Android.mk, after include $(BUILD_SHARED_LIBRARY):

all: $(LOCAL_PATH)/../lib/$(notdir $(LOCAL_BUILT_MODULE))

$(LOCAL_PATH)/../lib/$(notdir $(LOCAL_BUILT_MODULE)): $(LOCAL_BUILT_MODULE)
    cp $< $@
    cp $(wildcard $(LOCAL_PATH)/*.h $(LOCAL_PATH)/../include

Note that make requires leading tab, not spaces before cp.

The last line could be defined differently to copy all include files available to the compiler:

    cp $(wildcard $(LOCAL_C_INCLUDES)/*.h $(LOCAL_PATH)/../include

But there is no way to automatically choose which .h files should be copied, and which should be left alone.

Upvotes: 4

Related Questions