blob: 9c6742ecfba9ba222e8a48b4d38ae0c136c34ef4 [file] [log] [blame]
Christopher Ferris04b1e8c2014-01-30 01:13:33 -08001#
2# Copyright (C) 2014 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
Christopher Ferris7fb22872013-09-27 12:43:15 -070016
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080017LOCAL_PATH:= $(call my-dir)
Christopher Ferris17e91d42013-10-21 13:30:52 -070018
Christopher Ferris2c43cff2015-03-26 19:18:36 -070019libbacktrace_common_cflags := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070020 -Wall \
Christopher Ferris17e91d42013-10-21 13:30:52 -070021 -Werror \
22
Christopher Ferris2c43cff2015-03-26 19:18:36 -070023libbacktrace_common_conlyflags := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070024 -std=gnu99 \
25
Christopher Ferris2c43cff2015-03-26 19:18:36 -070026libbacktrace_common_cppflags := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070027 -std=gnu++11 \
Yabin Cui9e402bb2015-09-22 04:46:57 +000028 -I external/libunwind/include/tdep \
Christopher Ferris17e91d42013-10-21 13:30:52 -070029
Stephen Hines035e9ba2015-03-31 09:39:20 -070030# The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists.
31libbacktrace_common_clang_cflags += \
32 -Wno-inline-asm
33
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080034build_host := false
35ifeq ($(HOST_OS),linux)
36ifeq ($(HOST_ARCH),$(filter $(HOST_ARCH),x86 x86_64))
37build_host := true
38endif
39endif
40
Yabin Cui9e402bb2015-09-22 04:46:57 +000041LLVM_ROOT_PATH := external/llvm
42include $(LLVM_ROOT_PATH)/llvm.mk
43
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080044#-------------------------------------------------------------------------
45# The libbacktrace library.
46#-------------------------------------------------------------------------
47libbacktrace_src_files := \
Christopher Ferris2c43cff2015-03-26 19:18:36 -070048 Backtrace.cpp \
49 BacktraceCurrent.cpp \
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080050 BacktraceMap.cpp \
Yabin Cui9e402bb2015-09-22 04:46:57 +000051 BacktraceOffline.cpp \
Christopher Ferris2c43cff2015-03-26 19:18:36 -070052 BacktracePtrace.cpp \
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080053 thread_utils.c \
Christopher Ferris2c43cff2015-03-26 19:18:36 -070054 ThreadEntry.cpp \
Christopher Ferris17e91d42013-10-21 13:30:52 -070055 UnwindCurrent.cpp \
Christopher Ferrisdf290612014-01-22 19:21:07 -080056 UnwindMap.cpp \
Christopher Ferris17e91d42013-10-21 13:30:52 -070057 UnwindPtrace.cpp \
Christopher Ferris7fb22872013-09-27 12:43:15 -070058
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080059libbacktrace_shared_libraries := \
Christopher Ferris2c43cff2015-03-26 19:18:36 -070060 libbase \
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -070061 liblog \
Colin Crossdb134ca2015-04-28 17:49:42 -070062 libunwind \
Christopher Ferrisf67c6412014-01-10 00:43:54 -080063
Yabin Cui9e402bb2015-09-22 04:46:57 +000064# Use shared llvm library on device to save space.
65libbacktrace_shared_libraries_target := \
66 libLLVM \
67
68# Use static llvm libraries on host to remove dependency on 32-bit llvm shared library
69# which is not included in the prebuilt.
70libbacktrace_static_libraries_host := \
71 libLLVMObject \
72 libLLVMBitReader \
73 libLLVMMC \
74 libLLVMMCParser \
75 libLLVMCore \
76 libLLVMSupport \
77
Christopher Ferris3cdbfdc2014-11-08 15:57:11 -080078libbacktrace_ldlibs_host := \
79 -lpthread \
80 -lrt \
81
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080082module := libbacktrace
83module_tag := optional
84build_type := target
85build_target := SHARED_LIBRARY
86include $(LOCAL_PATH)/Android.build.mk
87build_type := host
Dan Albert0d7164d2014-11-11 15:15:21 -080088libbacktrace_multilib := both
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080089include $(LOCAL_PATH)/Android.build.mk
Calin Juravle28042b52015-06-08 14:30:52 +010090libbacktrace_static_libraries := \
91 libbase \
92 liblog \
93 libunwind \
94
95build_target := STATIC_LIBRARY
96include $(LOCAL_PATH)/Android.build.mk
97libbacktrace_static_libraries :=
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -070098
Dan Albert40a46dd2014-05-19 10:10:37 -070099#-------------------------------------------------------------------------
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800100# The libbacktrace_test library needed by backtrace_test.
101#-------------------------------------------------------------------------
102libbacktrace_test_cflags := \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700103 -O0 \
104
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800105libbacktrace_test_src_files := \
106 backtrace_testlib.c \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700107
Yabin Cui9e402bb2015-09-22 04:46:57 +0000108libbacktrace_test_strip_module := false
109
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800110module := libbacktrace_test
111module_tag := debug
112build_type := target
113build_target := SHARED_LIBRARY
Christopher Ferris2c43cff2015-03-26 19:18:36 -0700114libbacktrace_test_multilib := both
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800115include $(LOCAL_PATH)/Android.build.mk
116build_type := host
117include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7fb22872013-09-27 12:43:15 -0700118
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800119#-------------------------------------------------------------------------
120# The backtrace_test executable.
121#-------------------------------------------------------------------------
122backtrace_test_cflags := \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700123 -fno-builtin \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700124 -O0 \
125 -g \
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800126
127backtrace_test_cflags_target := \
Christopher Ferrise2960912014-03-07 19:42:19 -0800128 -DENABLE_PSS_TESTS \
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800129
130backtrace_test_src_files := \
Yabin Cui9e402bb2015-09-22 04:46:57 +0000131 backtrace_offline_test.cpp \
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800132 backtrace_test.cpp \
Christopher Ferrise2960912014-03-07 19:42:19 -0800133 GetPss.cpp \
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800134 thread_utils.c \
135
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800136backtrace_test_ldlibs_host := \
Ying Wang9f437d72014-05-07 15:36:05 -0700137 -lpthread \
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800138 -lrt \
139
140backtrace_test_shared_libraries := \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700141 libbacktrace_test \
142 libbacktrace \
Christopher Ferris67aba682015-05-08 15:44:46 -0700143 libbase \
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800144 libcutils \
Yabin Cui9e402bb2015-09-22 04:46:57 +0000145 libunwind \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700146
Christopher Ferris67aba682015-05-08 15:44:46 -0700147backtrace_test_shared_libraries_target += \
148 libdl \
149
150backtrace_test_ldlibs_host += \
151 -ldl \
Christopher Ferrisa2efd3a2014-05-06 15:23:59 -0700152
Yabin Cui9e402bb2015-09-22 04:46:57 +0000153backtrace_test_strip_module := false
154
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800155module := backtrace_test
156module_tag := debug
157build_type := target
158build_target := NATIVE_TEST
Christopher Ferris2c43cff2015-03-26 19:18:36 -0700159backtrace_test_multilib := both
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800160include $(LOCAL_PATH)/Android.build.mk
161build_type := host
162include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris17e91d42013-10-21 13:30:52 -0700163
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800164#----------------------------------------------------------------------------
165# Special truncated libbacktrace library for mac.
166#----------------------------------------------------------------------------
167ifeq ($(HOST_OS),darwin)
Christopher Ferris7fb22872013-09-27 12:43:15 -0700168
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800169include $(CLEAR_VARS)
Christopher Ferrisf67c6412014-01-10 00:43:54 -0800170
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800171LOCAL_MODULE := libbacktrace
172LOCAL_MODULE_TAGS := optional
173
174LOCAL_SRC_FILES := \
175 BacktraceMap.cpp \
176
Dan Albert5570c9b2014-11-13 14:54:10 -0800177LOCAL_MULTILIB := both
178
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800179include $(BUILD_HOST_SHARED_LIBRARY)
180
181endif # HOST_OS-darwin