2 # This file helps integrate apitrace into FirefoxOS - when apitrace
3 # sources are put in B2GROOT/external/apitrace (including this Android.mk
4 # file), then the B2G build system will pick apitrace automatically and
5 # compile and install it into the system images seamlessly.
7 # This may work in other than FirefoxOS environments, but has not been tested.
10 NDK := prebuilt/ndk/android-ndk-r7
12 ifeq ($(shell which cmake),)
13 $(shell echo "CMake not found, will not compile apitrace" >&2)
15 ifeq ($(wildcard $(NDK)),)
16 $(shell echo "CMake present but NDK not found at $(abspath $(NDK)), will not compile apitrace" >&2)
18 $(shell echo "CMake and NDK ($(abspath $(NDK))) found, will compile apitrace" >&2)
20 LOCAL_PATH := $(call my-dir)
24 LOCAL_MODULE := egltrace
25 LOCAL_MODULE_TAGS := debug eng
27 include $(BUILD_SHARED_LIBRARY)
29 # Below we hook the process of configuring and compiling apitrace,
30 # described in INSTALL.markdown (but we use the FirefoxOS's NDK). We override
31 # the $(linked_module): targed, which is already defined by
32 # $(BUILD_SHARED_LIBRARY) - by default it would want to compile the
33 # library out of some source files.
34 # We also override the target $(LOCAL_INSTALLED_MODULE): which installs
35 # the shared library because we want it installed in
36 # /lib/apitrace/wrappers/egltrace.so instead of /lib/egltrace.so because
37 # /bin/apitrace searches for the library in that directory.
38 # The rules will end up with /lib/apitrace/wrappers/egltrace.so and
39 # /bin/apitrace inside system.img.
40 MY_APITRACE_ROOT := $(TOPDIR)external/apitrace
41 MY_APITRACE_BUILD_ROOT_HOST := out/host/apitrace
42 MY_APITRACE_BUILD_ROOT_TARGET := out/target/apitrace
44 apitrace_private_target:
45 $(hide) # apitrace: run cmake for the host if it has not been run
46 $(hide) if [ ! -e $(MY_APITRACE_BUILD_ROOT_HOST)/Makefile ] ; then \
47 cd $(MY_APITRACE_ROOT) && \
48 cmake -H. -B../../$(MY_APITRACE_BUILD_ROOT_HOST) ; \
50 $(hide) # apitrace: compile for the host
51 $(hide) make -C $(MY_APITRACE_BUILD_ROOT_HOST)
52 $(hide) # apitrace: run cmake for android if it has not been run
53 $(hide) if [ ! -e $(MY_APITRACE_BUILD_ROOT_TARGET)/Makefile ] ; then \
54 cd $(MY_APITRACE_ROOT) && \
56 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/android.toolchain.cmake \
57 -DANDROID_NDK=../../$(NDK) \
58 -DANDROID_NDK_LAYOUT=LINARO \
59 -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.4.x \
60 -DANDROID_API_LEVEL=9 \
61 -DANDROID_NO_UNDEFINED=OFF \
62 -DLIBRARY_OUTPUT_PATH_ROOT=../../$(MY_APITRACE_BUILD_ROOT_TARGET) \
63 -H. -B../../$(MY_APITRACE_BUILD_ROOT_TARGET) ; \
65 $(hide) # apitrace: compile for android
66 $(hide) make -C $(MY_APITRACE_BUILD_ROOT_TARGET)
68 $(linked_module): apitrace_private_target
69 $(hide) # apitrace: copy egltrace lib to where the build system expects it
70 $(hide) mkdir -p $(dir $@)
71 $(hide) cp $(MY_APITRACE_BUILD_ROOT_TARGET)/libs/*/egltrace$(TARGET_SHLIB_SUFFIX) $@
73 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
74 @echo "Install (overridden): $@"
75 @mkdir -p $(dir $@)/apitrace/wrappers
76 $(hide) $(ACP) -fp $< $(dir $@)/apitrace/wrappers/egltrace$(TARGET_SHLIB_SUFFIX)
82 LOCAL_MODULE := apitrace
83 LOCAL_MODULE_TAGS := debug eng
85 include $(BUILD_EXECUTABLE)
87 $(linked_module): apitrace_private_target
88 $(hide) # apitrace: copy apitrace executable to where the build system expects it
89 $(hide) mkdir -p $(dir $@)
90 $(hide) cp $(MY_APITRACE_BUILD_ROOT_TARGET)/apitrace$(TARGET_EXECUTABLE_SUFFIX) $@