]> git.cworth.org Git - apitrace/blob - Android.mk
In Android.mk: skip if cmake is not present
[apitrace] / Android.mk
1 #
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.
6 #
7 # This may work in other than FirefoxOS environments, but has not been tested.
8 #
9
10 ifeq ($(shell which cmake),)
11 $(shell echo "CMake not found, will not compile apitrace" >&2)
12 else # cmake
13 $(shell echo "CMake found, will compile apitrace" >&2)
14
15 LOCAL_PATH := $(call my-dir)
16
17 include $(CLEAR_VARS)
18
19 LOCAL_MODULE := egltrace
20 LOCAL_MODULE_TAGS := debug eng
21
22 include $(BUILD_SHARED_LIBRARY)
23
24 # Below we hook the process of configuring and compiling apitrace,
25 # described in INSTALL.markdown (but we use the FirefoxOS's NDK). We override
26 # the $(linked_module): targed, which is already defined by
27 # $(BUILD_SHARED_LIBRARY) - by default it would want to compile the
28 # library out of some source files.
29 # We also override the target $(LOCAL_INSTALLED_MODULE): which installs
30 # the shared library because we want it installed in
31 # /lib/apitrace/wrappers/egltrace.so instead of /lib/egltrace.so because
32 # /bin/apitrace searches for the library in that directory.
33 # The rules will end up with /lib/apitrace/wrappers/egltrace.so and
34 # /bin/apitrace inside system.img.
35 MY_APITRACE_ROOT := $(TOPDIR)external/apitrace
36 MY_APITRACE_BUILD_ROOT_HOST := out/host/apitrace
37 MY_APITRACE_BUILD_ROOT_TARGET := out/target/apitrace
38
39 apitrace_private_target:
40         $(hide) # apitrace: run cmake for the host if it has not been run
41         $(hide) if [ ! -e $(MY_APITRACE_BUILD_ROOT_HOST)/Makefile ] ; then \
42                 cd $(MY_APITRACE_ROOT) && \
43                 cmake -H. -B../../$(MY_APITRACE_BUILD_ROOT_HOST) ; \
44         fi
45         $(hide) # apitrace: compile for the host
46         $(hide) make -C $(MY_APITRACE_BUILD_ROOT_HOST)
47         $(hide) # apitrace: run cmake for android if it has not been run
48         $(hide) if [ ! -e $(MY_APITRACE_BUILD_ROOT_TARGET)/Makefile ] ; then \
49                 cd $(MY_APITRACE_ROOT) && \
50                 cmake \
51                 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/android.toolchain.cmake \
52                 -DANDROID_NDK=../../prebuilt/ndk/android-ndk-r7 \
53                 -DANDROID_NDK_LAYOUT=LINARO \
54                 -DANDROID_API_LEVEL=9 \
55                 -DANDROID_NO_UNDEFINED=OFF \
56                 -DLIBRARY_OUTPUT_PATH_ROOT=../../$(MY_APITRACE_BUILD_ROOT_TARGET) \
57                 -H. -B../../$(MY_APITRACE_BUILD_ROOT_TARGET) ; \
58         fi
59         $(hide) # apitrace: compile for android
60         $(hide) make -C $(MY_APITRACE_BUILD_ROOT_TARGET)
61
62 $(linked_module): apitrace_private_target
63         $(hide) # apitrace: copy egltrace lib to where the build system expects it
64         $(hide) mkdir -p $(dir $@)
65         $(hide) cp $(MY_APITRACE_BUILD_ROOT_TARGET)/libs/*/egltrace$(TARGET_SHLIB_SUFFIX) $@
66
67 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
68         @echo "Install (overridden): $@"
69         @mkdir -p $(dir $@)/apitrace/wrappers
70         $(hide) $(ACP) -fp $< $(dir $@)/apitrace/wrappers/egltrace$(TARGET_SHLIB_SUFFIX)
71
72 #
73
74 include $(CLEAR_VARS)
75
76 LOCAL_MODULE := apitrace
77 LOCAL_MODULE_TAGS := debug eng
78
79 include $(BUILD_EXECUTABLE)
80
81 $(linked_module): apitrace_private_target
82         $(hide) # apitrace: copy apitrace executable to where the build system expects it
83         $(hide) mkdir -p $(dir $@)
84         $(hide) cp $(MY_APITRACE_BUILD_ROOT_TARGET)/apitrace$(TARGET_EXECUTABLE_SUFFIX) $@
85
86 endif # cmake