1#
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#
16
17LOCAL_PATH:= $(call my-dir)
18
19libbacktrace_common_cflags := \
20	-Wall \
21	-Werror \
22
23libbacktrace_common_conlyflags := \
24	-std=gnu99 \
25
26libbacktrace_common_cppflags := \
27	-std=gnu++11 \
28	-I external/libunwind/include/tdep \
29
30# 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
34build_host := false
35ifeq ($(HOST_OS),linux)
36ifeq ($(HOST_ARCH),$(filter $(HOST_ARCH),x86 x86_64))
37build_host := true
38endif
39endif
40
41LLVM_ROOT_PATH := external/llvm
42include $(LLVM_ROOT_PATH)/llvm.mk
43
44#-------------------------------------------------------------------------
45# The libbacktrace library.
46#-------------------------------------------------------------------------
47libbacktrace_src_files := \
48	Backtrace.cpp \
49	BacktraceCurrent.cpp \
50	BacktraceMap.cpp \
51	BacktracePtrace.cpp \
52	thread_utils.c \
53	ThreadEntry.cpp \
54	UnwindCurrent.cpp \
55	UnwindMap.cpp \
56	UnwindPtrace.cpp \
57
58libbacktrace_shared_libraries := \
59	libbase \
60	liblog \
61	libunwind \
62
63libbacktrace_static_libraries := \
64	libcutils
65
66module := libbacktrace
67module_tag := optional
68build_type := target
69build_target := SHARED_LIBRARY
70include $(LOCAL_PATH)/Android.build.mk
71build_type := host
72libbacktrace_multilib := both
73include $(LOCAL_PATH)/Android.build.mk
74libbacktrace_static_libraries := \
75	libbase \
76	liblog \
77	libunwind \
78
79build_target := STATIC_LIBRARY
80include $(LOCAL_PATH)/Android.build.mk
81libbacktrace_static_libraries :=
82
83#-------------------------------------------------------------------------
84# The libbacktrace_offline shared library.
85#-------------------------------------------------------------------------
86libbacktrace_offline_src_files := \
87	BacktraceOffline.cpp \
88
89# Use shared llvm library on device to save space.
90libbacktrace_offline_shared_libraries_target := \
91	libbacktrace \
92	libbase \
93	liblog \
94	libunwind \
95	libutils \
96	libLLVM \
97
98libbacktrace_offline_static_libraries_target := \
99	libziparchive \
100	libz \
101
102# Use static llvm libraries on host to remove dependency on 32-bit llvm shared library
103# which is not included in the prebuilt.
104libbacktrace_offline_static_libraries_host := \
105	libbacktrace \
106	libunwind \
107	libziparchive-host \
108	libz \
109	libbase \
110	liblog \
111	libutils \
112	libLLVMObject \
113	libLLVMBitReader \
114	libLLVMMC \
115	libLLVMMCParser \
116	libLLVMCore \
117	libLLVMSupport \
118
119module := libbacktrace_offline
120build_type := target
121build_target := STATIC_LIBRARY
122libbacktrace_offline_multilib := both
123include $(LOCAL_PATH)/Android.build.mk
124build_type := host
125include $(LOCAL_PATH)/Android.build.mk
126
127#-------------------------------------------------------------------------
128# The libbacktrace_test library needed by backtrace_test.
129#-------------------------------------------------------------------------
130libbacktrace_test_cflags := \
131	-O0 \
132
133libbacktrace_test_src_files := \
134	backtrace_testlib.c \
135
136libbacktrace_test_strip_module := false
137
138module := libbacktrace_test
139module_tag := debug
140build_type := target
141build_target := SHARED_LIBRARY
142libbacktrace_test_multilib := both
143include $(LOCAL_PATH)/Android.build.mk
144build_type := host
145include $(LOCAL_PATH)/Android.build.mk
146
147#-------------------------------------------------------------------------
148# The backtrace_test executable.
149#-------------------------------------------------------------------------
150backtrace_test_cflags := \
151	-fno-builtin \
152	-O0 \
153	-g \
154
155backtrace_test_cflags_target := \
156	-DENABLE_PSS_TESTS \
157
158backtrace_test_src_files := \
159	backtrace_offline_test.cpp \
160	backtrace_test.cpp \
161	GetPss.cpp \
162	thread_utils.c \
163
164backtrace_test_ldlibs_host := \
165	-lpthread \
166	-lrt \
167
168backtrace_test_shared_libraries := \
169	libbacktrace_test \
170	libbacktrace \
171	libbase \
172	libcutils \
173	liblog \
174	libunwind \
175
176backtrace_test_shared_libraries_target += \
177	libdl \
178	libutils \
179	libLLVM \
180
181backtrace_test_static_libraries := \
182	libbacktrace_offline \
183
184backtrace_test_static_libraries_target := \
185	libziparchive \
186	libz \
187
188backtrace_test_static_libraries_host := \
189	libziparchive-host \
190	libz \
191	libutils \
192	libLLVMObject \
193	libLLVMBitReader \
194	libLLVMMC \
195	libLLVMMCParser \
196	libLLVMCore \
197	libLLVMSupport \
198
199backtrace_test_ldlibs_host += \
200	-ldl \
201
202backtrace_test_strip_module := false
203
204module := backtrace_test
205module_tag := debug
206build_type := target
207build_target := NATIVE_TEST
208backtrace_test_multilib := both
209include $(LOCAL_PATH)/Android.build.mk
210build_type := host
211include $(LOCAL_PATH)/Android.build.mk
212
213#----------------------------------------------------------------------------
214# Special truncated libbacktrace library for mac.
215#----------------------------------------------------------------------------
216ifeq ($(HOST_OS),darwin)
217
218include $(CLEAR_VARS)
219
220LOCAL_MODULE := libbacktrace
221LOCAL_MODULE_TAGS := optional
222
223LOCAL_SRC_FILES := \
224	BacktraceMap.cpp \
225
226LOCAL_MULTILIB := both
227
228include $(BUILD_HOST_SHARED_LIBRARY)
229
230endif # HOST_OS-darwin
231