Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 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 | # |
Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 16 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 17 | LOCAL_PATH:= $(call my-dir) |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 18 | |
| 19 | common_cflags := \ |
| 20 | -Wall \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 21 | -Werror \ |
| 22 | |
| 23 | common_conlyflags := \ |
| 24 | -std=gnu99 \ |
| 25 | |
| 26 | common_cppflags := \ |
| 27 | -std=gnu++11 \ |
| 28 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 29 | build_host := false |
| 30 | ifeq ($(HOST_OS),linux) |
| 31 | ifeq ($(HOST_ARCH),$(filter $(HOST_ARCH),x86 x86_64)) |
| 32 | build_host := true |
| 33 | endif |
| 34 | endif |
| 35 | |
| 36 | #------------------------------------------------------------------------- |
| 37 | # The libbacktrace library. |
| 38 | #------------------------------------------------------------------------- |
| 39 | libbacktrace_src_files := \ |
| 40 | BacktraceImpl.cpp \ |
| 41 | BacktraceMap.cpp \ |
| 42 | BacktraceThread.cpp \ |
| 43 | thread_utils.c \ |
| 44 | |
| 45 | libbacktrace_shared_libraries_target := \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 46 | libcutils \ |
| 47 | libgccdemangle \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 48 | |
Elliott Hughes | 3c67fe9 | 2014-01-02 15:13:38 -0800 | [diff] [blame] | 49 | # To enable using libunwind on each arch, add it to this list. |
Christopher Ferris | c29a134 | 2014-02-26 13:41:32 -0800 | [diff] [blame] | 50 | libunwind_architectures := arm arm64 mips x86 x86_64 |
Elliott Hughes | 3c67fe9 | 2014-01-02 15:13:38 -0800 | [diff] [blame] | 51 | |
| 52 | ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),$(libunwind_architectures))) |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 53 | libbacktrace_src_files += \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 54 | UnwindCurrent.cpp \ |
Christopher Ferris | df29061 | 2014-01-22 19:21:07 -0800 | [diff] [blame] | 55 | UnwindMap.cpp \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 56 | UnwindPtrace.cpp \ |
Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 57 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 58 | libbacktrace_c_includes := \ |
Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 59 | external/libunwind/include \ |
| 60 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 61 | libbacktrace_shared_libraries := \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 62 | libunwind \ |
| 63 | libunwind-ptrace \ |
| 64 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 65 | libbacktrace_shared_libraries_host := \ |
Christopher Ferris | 9e1ee2b | 2013-10-02 14:19:19 -0700 | [diff] [blame] | 66 | liblog \ |
Christopher Ferris | 9e1ee2b | 2013-10-02 14:19:19 -0700 | [diff] [blame] | 67 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 68 | libbacktrace_static_libraries_host := \ |
| 69 | libcutils \ |
Christopher Ferris | f67c641 | 2014-01-10 00:43:54 -0800 | [diff] [blame] | 70 | |
| 71 | else |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 72 | libbacktrace_src_files += \ |
| 73 | Corkscrew.cpp \ |
| 74 | |
| 75 | libbacktrace_c_includes := \ |
| 76 | system/core/libcorkscrew \ |
| 77 | |
| 78 | libbacktrace_shared_libraries := \ |
| 79 | libcorkscrew \ |
| 80 | |
| 81 | libbacktrace_shared_libraries_target += \ |
| 82 | libdl \ |
| 83 | |
| 84 | libbacktrace_ldlibs_host := \ |
| 85 | -ldl \ |
Christopher Ferris | f67c641 | 2014-01-10 00:43:54 -0800 | [diff] [blame] | 86 | |
| 87 | endif |
| 88 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 89 | module := libbacktrace |
| 90 | module_tag := optional |
| 91 | build_type := target |
| 92 | build_target := SHARED_LIBRARY |
| 93 | include $(LOCAL_PATH)/Android.build.mk |
| 94 | build_type := host |
| 95 | include $(LOCAL_PATH)/Android.build.mk |
Christopher Ferris | 9e1ee2b | 2013-10-02 14:19:19 -0700 | [diff] [blame] | 96 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 97 | #------------------------------------------------------------------------- |
| 98 | # The libbacktrace_test library needed by backtrace_test. |
| 99 | #------------------------------------------------------------------------- |
| 100 | libbacktrace_test_cflags := \ |
Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 101 | -O0 \ |
| 102 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 103 | libbacktrace_test_src_files := \ |
| 104 | backtrace_testlib.c \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 105 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 106 | module := libbacktrace_test |
| 107 | module_tag := debug |
| 108 | build_type := target |
| 109 | build_target := SHARED_LIBRARY |
| 110 | include $(LOCAL_PATH)/Android.build.mk |
| 111 | build_type := host |
| 112 | include $(LOCAL_PATH)/Android.build.mk |
Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 113 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 114 | #------------------------------------------------------------------------- |
| 115 | # The backtrace_test executable. |
| 116 | #------------------------------------------------------------------------- |
| 117 | backtrace_test_cflags := \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 118 | -fno-builtin \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 119 | -O0 \ |
| 120 | -g \ |
| 121 | -DGTEST_HAS_STD_STRING \ |
Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 122 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 123 | ifneq ($(TARGET_ARCH),arm64) |
| 124 | backtrace_test_cflags += -fstack-protector-all |
| 125 | else |
| 126 | $(info TODO: $(LOCAL_PATH)/Android.mk -fstack-protector not yet available for the AArch64 toolchain) |
| 127 | common_cflags += -fno-stack-protector |
| 128 | endif # arm64 |
| 129 | |
| 130 | backtrace_test_cflags_target := \ |
| 131 | -DGTEST_OS_LINUX_ANDROID \ |
| 132 | |
| 133 | backtrace_test_src_files := \ |
| 134 | backtrace_test.cpp \ |
| 135 | thread_utils.c \ |
| 136 | |
| 137 | backtrace_test_ldlibs := \ |
| 138 | -lpthread \ |
| 139 | |
| 140 | backtrace_test_ldlibs_host := \ |
| 141 | -lrt \ |
| 142 | |
| 143 | backtrace_test_shared_libraries := \ |
Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 144 | libbacktrace_test \ |
| 145 | libbacktrace \ |
| 146 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 147 | backtrace_test_shared_libraries_target := \ |
| 148 | libcutils \ |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 149 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 150 | module := backtrace_test |
| 151 | module_tag := debug |
| 152 | build_type := target |
| 153 | build_target := NATIVE_TEST |
| 154 | include $(LOCAL_PATH)/Android.build.mk |
| 155 | build_type := host |
| 156 | include $(LOCAL_PATH)/Android.build.mk |
Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 157 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 158 | #---------------------------------------------------------------------------- |
| 159 | # Special truncated libbacktrace library for mac. |
| 160 | #---------------------------------------------------------------------------- |
| 161 | ifeq ($(HOST_OS),darwin) |
Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 162 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 163 | include $(CLEAR_VARS) |
Christopher Ferris | f67c641 | 2014-01-10 00:43:54 -0800 | [diff] [blame] | 164 | |
Christopher Ferris | 04b1e8c | 2014-01-30 01:13:33 -0800 | [diff] [blame] | 165 | LOCAL_MODULE := libbacktrace |
| 166 | LOCAL_MODULE_TAGS := optional |
| 167 | |
| 168 | LOCAL_SRC_FILES := \ |
| 169 | BacktraceMap.cpp \ |
| 170 | |
| 171 | include $(BUILD_HOST_SHARED_LIBRARY) |
| 172 | |
| 173 | endif # HOST_OS-darwin |