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
29# The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists.
30libbacktrace_common_clang_cflags += \
31    -Wno-inline-asm
32
33build_host := false
34ifeq ($(HOST_OS),linux)
35ifeq ($(HOST_ARCH),$(filter $(HOST_ARCH),x86 x86_64))
36build_host := true
37endif
38endif
39
40#-------------------------------------------------------------------------
41# The libbacktrace library.
42#-------------------------------------------------------------------------
43libbacktrace_src_files := \
44	Backtrace.cpp \
45	BacktraceCurrent.cpp \
46	BacktraceMap.cpp \
47	BacktracePtrace.cpp \
48	thread_utils.c \
49	ThreadEntry.cpp \
50	UnwindCurrent.cpp \
51	UnwindMap.cpp \
52	UnwindPtrace.cpp \
53
54libbacktrace_shared_libraries_target := \
55	libcutils \
56
57libbacktrace_shared_libraries := \
58	libbase \
59	libunwind \
60
61libbacktrace_shared_libraries_host := \
62	liblog \
63
64libbacktrace_static_libraries_host := \
65	libcutils \
66
67libbacktrace_ldlibs_host := \
68	-lpthread \
69	-lrt \
70
71module := libbacktrace
72module_tag := optional
73build_type := target
74build_target := SHARED_LIBRARY
75include $(LOCAL_PATH)/Android.build.mk
76build_type := host
77libbacktrace_multilib := both
78include $(LOCAL_PATH)/Android.build.mk
79
80#-------------------------------------------------------------------------
81# The libbacktrace_test library needed by backtrace_test.
82#-------------------------------------------------------------------------
83libbacktrace_test_cflags := \
84	-O0 \
85
86libbacktrace_test_src_files := \
87	backtrace_testlib.c \
88
89module := libbacktrace_test
90module_tag := debug
91build_type := target
92build_target := SHARED_LIBRARY
93libbacktrace_test_multilib := both
94include $(LOCAL_PATH)/Android.build.mk
95build_type := host
96include $(LOCAL_PATH)/Android.build.mk
97
98#-------------------------------------------------------------------------
99# The backtrace_test executable.
100#-------------------------------------------------------------------------
101backtrace_test_cflags := \
102	-fno-builtin \
103	-O0 \
104	-g \
105
106backtrace_test_cflags_target := \
107	-DENABLE_PSS_TESTS \
108
109backtrace_test_src_files := \
110	backtrace_test.cpp \
111	GetPss.cpp \
112	thread_utils.c \
113
114backtrace_test_ldlibs_host := \
115	-lpthread \
116	-lrt \
117
118backtrace_test_shared_libraries := \
119	libbacktrace_test \
120	libbacktrace \
121	libbase \
122	libcutils \
123
124backtrace_test_shared_libraries_target += \
125	libdl \
126
127backtrace_test_ldlibs_host += \
128	-ldl \
129
130module := backtrace_test
131module_tag := debug
132build_type := target
133build_target := NATIVE_TEST
134backtrace_test_multilib := both
135include $(LOCAL_PATH)/Android.build.mk
136build_type := host
137include $(LOCAL_PATH)/Android.build.mk
138
139#----------------------------------------------------------------------------
140# Special truncated libbacktrace library for mac.
141#----------------------------------------------------------------------------
142ifeq ($(HOST_OS),darwin)
143
144include $(CLEAR_VARS)
145
146LOCAL_MODULE := libbacktrace
147LOCAL_MODULE_TAGS := optional
148
149LOCAL_SRC_FILES := \
150	BacktraceMap.cpp \
151
152LOCAL_MULTILIB := both
153
154include $(BUILD_HOST_SHARED_LIBRARY)
155
156endif # HOST_OS-darwin
157