blob: 33af0a302c4ec395d6d1a80e4dd92be070ff25dd [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
19common_cflags := \
20 -Wall \
Christopher Ferris17e91d42013-10-21 13:30:52 -070021 -Werror \
22
23common_conlyflags := \
24 -std=gnu99 \
25
26common_cppflags := \
27 -std=gnu++11 \
28
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080029build_host := false
30ifeq ($(HOST_OS),linux)
31ifeq ($(HOST_ARCH),$(filter $(HOST_ARCH),x86 x86_64))
32build_host := true
33endif
34endif
35
36#-------------------------------------------------------------------------
37# The libbacktrace library.
38#-------------------------------------------------------------------------
39libbacktrace_src_files := \
40 BacktraceImpl.cpp \
41 BacktraceMap.cpp \
42 BacktraceThread.cpp \
43 thread_utils.c \
44
45libbacktrace_shared_libraries_target := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070046 libcutils \
47 libgccdemangle \
Christopher Ferris17e91d42013-10-21 13:30:52 -070048
Elliott Hughes3c67fe92014-01-02 15:13:38 -080049# To enable using libunwind on each arch, add it to this list.
Pavel Chupinc6c194c2013-11-21 23:17:20 +040050libunwind_architectures := arm arm64 x86 x86_64
Elliott Hughes3c67fe92014-01-02 15:13:38 -080051
52ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),$(libunwind_architectures)))
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080053libbacktrace_src_files += \
Christopher Ferris17e91d42013-10-21 13:30:52 -070054 UnwindCurrent.cpp \
Christopher Ferrisdf290612014-01-22 19:21:07 -080055 UnwindMap.cpp \
Christopher Ferris17e91d42013-10-21 13:30:52 -070056 UnwindPtrace.cpp \
Christopher Ferris7fb22872013-09-27 12:43:15 -070057
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080058libbacktrace_c_includes := \
Christopher Ferris7fb22872013-09-27 12:43:15 -070059 external/libunwind/include \
60
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080061libbacktrace_shared_libraries := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070062 libunwind \
63 libunwind-ptrace \
64
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080065libbacktrace_shared_libraries_host := \
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -070066 liblog \
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -070067
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080068libbacktrace_static_libraries_host := \
69 libcutils \
Christopher Ferrisf67c6412014-01-10 00:43:54 -080070
71else
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080072libbacktrace_src_files += \
73 Corkscrew.cpp \
74
75libbacktrace_c_includes := \
76 system/core/libcorkscrew \
77
78libbacktrace_shared_libraries := \
79 libcorkscrew \
80
81libbacktrace_shared_libraries_target += \
82 libdl \
83
84libbacktrace_ldlibs_host := \
85 -ldl \
Christopher Ferrisf67c6412014-01-10 00:43:54 -080086
87endif
88
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080089module := libbacktrace
90module_tag := optional
91build_type := target
92build_target := SHARED_LIBRARY
93include $(LOCAL_PATH)/Android.build.mk
94build_type := host
95include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -070096
Christopher Ferris04b1e8c2014-01-30 01:13:33 -080097#-------------------------------------------------------------------------
98# The libbacktrace_test library needed by backtrace_test.
99#-------------------------------------------------------------------------
100libbacktrace_test_cflags := \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700101 -O0 \
102
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800103libbacktrace_test_src_files := \
104 backtrace_testlib.c \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700105
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800106module := libbacktrace_test
107module_tag := debug
108build_type := target
109build_target := SHARED_LIBRARY
110include $(LOCAL_PATH)/Android.build.mk
111build_type := host
112include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7fb22872013-09-27 12:43:15 -0700113
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800114#-------------------------------------------------------------------------
115# The backtrace_test executable.
116#-------------------------------------------------------------------------
117backtrace_test_cflags := \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700118 -fno-builtin \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700119 -O0 \
120 -g \
121 -DGTEST_HAS_STD_STRING \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700122
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800123ifneq ($(TARGET_ARCH),arm64)
124backtrace_test_cflags += -fstack-protector-all
125else
126 $(info TODO: $(LOCAL_PATH)/Android.mk -fstack-protector not yet available for the AArch64 toolchain)
127 common_cflags += -fno-stack-protector
128endif # arm64
129
130backtrace_test_cflags_target := \
131 -DGTEST_OS_LINUX_ANDROID \
132
133backtrace_test_src_files := \
134 backtrace_test.cpp \
135 thread_utils.c \
136
137backtrace_test_ldlibs := \
138 -lpthread \
139
140backtrace_test_ldlibs_host := \
141 -lrt \
142
143backtrace_test_shared_libraries := \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700144 libbacktrace_test \
145 libbacktrace \
146
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800147backtrace_test_shared_libraries_target := \
148 libcutils \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700149
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800150module := backtrace_test
151module_tag := debug
152build_type := target
153build_target := NATIVE_TEST
154include $(LOCAL_PATH)/Android.build.mk
155build_type := host
156include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris17e91d42013-10-21 13:30:52 -0700157
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800158#----------------------------------------------------------------------------
159# Special truncated libbacktrace library for mac.
160#----------------------------------------------------------------------------
161ifeq ($(HOST_OS),darwin)
Christopher Ferris7fb22872013-09-27 12:43:15 -0700162
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800163include $(CLEAR_VARS)
Christopher Ferrisf67c6412014-01-10 00:43:54 -0800164
Christopher Ferris04b1e8c2014-01-30 01:13:33 -0800165LOCAL_MODULE := libbacktrace
166LOCAL_MODULE_TAGS := optional
167
168LOCAL_SRC_FILES := \
169 BacktraceMap.cpp \
170
171include $(BUILD_HOST_SHARED_LIBRARY)
172
173endif # HOST_OS-darwin