blob: a42dde9e3b27d65ee46d7b9d0496e00e9b86243e [file] [log] [blame]
Christopher Ferrisfe6ff002014-01-30 01:04:29 -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#
16
Christopher Ferris1c82a522013-10-01 12:38:42 -070017LOCAL_PATH := $(call my-dir)
18
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080019build_host := false
20ifeq ($(HOST_OS),linux)
21ifeq ($(HOST_ARCH),$(filter $(HOST_ARCH),x86 x86_64))
22build_host := true
Ying Wang57c68a32014-02-21 15:53:33 -080023my_host_arch := $(HOST_ARCH)
Christopher Ferris3fa49972014-01-31 15:07:26 -080024ifneq ($(strip $(BUILD_HOST_64bit)),)
Ying Wang57c68a32014-02-21 15:53:33 -080025my_host_arch := x86_64
Christopher Ferris3fa49972014-01-31 15:07:26 -080026endif
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080027endif
28endif
29
Christopher Ferris76dbee52014-02-12 21:12:09 -080030# Set to true to enable a debug build of the libraries.
31# To control what is logged, set the environment variable UNW_DEBUG_LEVEL=x,
32# where x controls the verbosity (from 1 to 20).
33debug := false
34
Christopher Ferris2319e0f2014-04-29 10:23:55 -070035common_conlyflags := \
36 -Wno-old-style-declaration \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070037
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080038common_cflags := \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070039 -Wno-unused-parameter \
40 -Werror \
41
42# gcc 4.8 appears to be overeager declaring that a variable is uninitialized,
43# under certain circumstances. Turn off this warning only for target so that
44# coverage is still present for the host code. When the entire build system
45# is switched to 4.9, then this can be removed.
46common_cflags_target := \
47 -Wno-maybe-uninitialized \
48
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020049ifeq ($(LOCAL_CLANG),true)
50# src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
51common_cflags += -Wno-header-guard
52endif
53
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070054ifneq ($(debug),true)
55common_cflags += \
Christopher Ferris1c82a522013-10-01 12:38:42 -070056 -DHAVE_CONFIG_H \
57 -DNDEBUG \
58 -D_GNU_SOURCE \
Christopher Ferris9fc75e82014-01-26 21:39:06 -080059
Christopher Ferris76dbee52014-02-12 21:12:09 -080060else
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070061common_cflags += \
Christopher Ferris76dbee52014-02-12 21:12:09 -080062 -DHAVE_CONFIG_H \
63 -DDEBUG \
64 -D_GNU_SOURCE \
65 -U_FORTIFY_SOURCE \
66
67endif
Pavel Chupinf1f90e72013-12-04 13:29:29 +040068
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080069common_c_includes := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070070 $(LOCAL_PATH)/src \
71 $(LOCAL_PATH)/include \
Colin Cross26183d22014-01-24 15:59:56 -080072
Pavel Chupinf1f90e72013-12-04 13:29:29 +040073libunwind_arches := arm arm64 mips x86 x86_64
Christopher Ferris1c82a522013-10-01 12:38:42 -070074
Colin Cross26183d22014-01-24 15:59:56 -080075$(foreach arch,$(libunwind_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080076 $(eval common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
Christopher Ferris1c82a522013-10-01 12:38:42 -070077
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080078#-----------------------------------------------------------------------
79# libunwind shared library
80#-----------------------------------------------------------------------
81libunwind_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070082 src/mi/init.c \
83 src/mi/flush_cache.c \
84 src/mi/mempool.c \
85 src/mi/strerror.c \
86 src/mi/backtrace.c \
87 src/mi/dyn-cancel.c \
88 src/mi/dyn-info-list.c \
89 src/mi/dyn-register.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -080090 src/mi/map.c \
91 src/mi/Lmap.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -070092 src/mi/Ldyn-extract.c \
93 src/mi/Lfind_dynamic_proc_info.c \
94 src/mi/Lget_proc_info_by_ip.c \
95 src/mi/Lget_proc_name.c \
96 src/mi/Lput_dynamic_unwind_info.c \
97 src/mi/Ldestroy_addr_space.c \
98 src/mi/Lget_reg.c \
99 src/mi/Lset_reg.c \
100 src/mi/Lget_fpreg.c \
101 src/mi/Lset_fpreg.c \
102 src/mi/Lset_caching_policy.c \
103 src/mi/Gdyn-extract.c \
104 src/mi/Gdyn-remote.c \
105 src/mi/Gfind_dynamic_proc_info.c \
106 src/mi/Gget_accessors.c \
107 src/mi/Gget_proc_info_by_ip.c \
108 src/mi/Gget_proc_name.c \
109 src/mi/Gput_dynamic_unwind_info.c \
110 src/mi/Gdestroy_addr_space.c \
111 src/mi/Gget_reg.c \
112 src/mi/Gset_reg.c \
113 src/mi/Gget_fpreg.c \
114 src/mi/Gset_fpreg.c \
115 src/mi/Gset_caching_policy.c \
116 src/dwarf/Lexpr.c \
117 src/dwarf/Lfde.c \
118 src/dwarf/Lparser.c \
119 src/dwarf/Lpe.c \
120 src/dwarf/Lstep.c \
121 src/dwarf/Lfind_proc_info-lsb.c \
122 src/dwarf/Lfind_unwind_table.c \
123 src/dwarf/Gexpr.c \
124 src/dwarf/Gfde.c \
125 src/dwarf/Gfind_proc_info-lsb.c \
126 src/dwarf/Gfind_unwind_table.c \
127 src/dwarf/Gparser.c \
128 src/dwarf/Gpe.c \
129 src/dwarf/Gstep.c \
130 src/dwarf/global.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800131 src/os-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700132 src/os-linux.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800133 src/Los-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700134
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800135# Arch specific source files.
Colin Cross26183d22014-01-24 15:59:56 -0800136$(foreach arch,$(libunwind_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800137 $(eval libunwind_src_files_$(arch) += \
138 src/$(arch)/is_fpreg.c \
139 src/$(arch)/regname.c \
140 src/$(arch)/Gcreate_addr_space.c \
141 src/$(arch)/Gget_proc_info.c \
142 src/$(arch)/Gget_save_loc.c \
143 src/$(arch)/Gglobal.c \
144 src/$(arch)/Ginit.c \
145 src/$(arch)/Ginit_local.c \
146 src/$(arch)/Ginit_remote.c \
147 src/$(arch)/Gregs.c \
148 src/$(arch)/Gresume.c \
149 src/$(arch)/Gstep.c \
150 src/$(arch)/Lcreate_addr_space.c \
151 src/$(arch)/Lget_proc_info.c \
152 src/$(arch)/Lget_save_loc.c \
153 src/$(arch)/Lglobal.c \
154 src/$(arch)/Linit.c \
155 src/$(arch)/Linit_local.c \
156 src/$(arch)/Linit_remote.c \
157 src/$(arch)/Lregs.c \
158 src/$(arch)/Lresume.c \
159 src/$(arch)/Lstep.c \
Colin Cross26183d22014-01-24 15:59:56 -0800160 ))
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800161
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800162# 64-bit architectures
163libunwind_src_files_arm64 += src/elf64.c
164libunwind_src_files_x86_64 += src/elf64.c
165
166# 32-bit architectures
167libunwind_src_files_arm += src/elf32.c
168libunwind_src_files_mips += src/elf32.c
169libunwind_src_files_x86 += src/elf32.c
170
171libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700172 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700173 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700174 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700175 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700176 src/arm/Lex_tables.c \
177
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800178libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800179 src/aarch64/Gis_signal_frame.c \
180 src/aarch64/Lis_signal_frame.c \
181
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800182libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700183 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700184 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700185 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700186
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800187libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700188 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700189 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700190 src/x86/Los-linux.c \
191
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800192libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400193 src/x86_64/getcontext.S \
194 src/x86_64/Gstash_frame.c \
195 src/x86_64/Gtrace.c \
196 src/x86_64/Gos-linux.c \
197 src/x86_64/Lstash_frame.c \
198 src/x86_64/Ltrace.c \
199 src/x86_64/Los-linux.c \
200 src/x86_64/setcontext.S \
201
Christopher Ferris2319e0f2014-04-29 10:23:55 -0700202libunwind_src_files += \
203 src/unwind/Backtrace.c \
204 src/unwind/DeleteException.c \
205 src/unwind/FindEnclosingFunction.c \
206 src/unwind/ForcedUnwind.c \
207 src/unwind/GetBSP.c \
208 src/unwind/GetCFA.c \
209 src/unwind/GetDataRelBase.c \
210 src/unwind/GetGR.c \
211 src/unwind/GetIP.c \
212 src/unwind/GetIPInfo.c \
213 src/unwind/GetLanguageSpecificData.c \
214 src/unwind/GetRegionStart.c \
215 src/unwind/GetTextRelBase.c \
216 src/unwind/RaiseException.c \
217 src/unwind/Resume.c \
218 src/unwind/Resume_or_Rethrow.c \
219 src/unwind/SetGR.c \
220 src/unwind/SetIP.c \
221
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800222libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700223 libdl \
224
Dan Albert162c8cb2014-05-09 10:19:20 -0700225libunwind_ldflags_host := \
226 -nostdlib
227
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800228libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700229 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800230 -lpthread \
231
Christopher Ferris76dbee52014-02-12 21:12:09 -0800232ifeq ($(debug),true)
233libunwind_shared_libraries += \
234 liblog \
235
236endif
237
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800238module := libunwind
239module_tag := optional
240build_type := target
241build_target := SHARED_LIBRARY
242include $(LOCAL_PATH)/Android.build.mk
243build_type := host
244include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris836d9152013-12-02 12:27:30 -0800245
Dan Albert76728fb2014-05-09 13:51:35 -0700246build_type := target
247build_target := STATIC_LIBRARY
248include $(LOCAL_PATH)/Android.build.mk
249build_type := host
250include $(LOCAL_PATH)/Android.build.mk
251
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800252#-----------------------------------------------------------------------
253# libunwind-ptrace shared library
254#-----------------------------------------------------------------------
255libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700256 src/ptrace/_UPT_elf.c \
257 src/ptrace/_UPT_accessors.c \
258 src/ptrace/_UPT_access_fpreg.c \
259 src/ptrace/_UPT_access_mem.c \
260 src/ptrace/_UPT_access_reg.c \
261 src/ptrace/_UPT_create.c \
262 src/ptrace/_UPT_destroy.c \
263 src/ptrace/_UPT_find_proc_info.c \
264 src/ptrace/_UPT_get_dyn_info_list_addr.c \
265 src/ptrace/_UPT_put_unwind_info.c \
266 src/ptrace/_UPT_get_proc_name.c \
267 src/ptrace/_UPT_reg_offset.c \
268 src/ptrace/_UPT_resume.c \
269
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800270libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700271 libunwind \
272
Dan Albert162c8cb2014-05-09 10:19:20 -0700273libunwind-ptrace_ldflags_host := \
274 -nostdlib
275
276libunwind-ptrace_ldlibs_host := \
277 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800278 -lpthread \
279
Christopher Ferris76dbee52014-02-12 21:12:09 -0800280ifeq ($(debug),true)
281libunwind-ptrace_shared_libraries += \
282 liblog \
283
284endif
285
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800286module := libunwind-ptrace
287module_tag := optional
288build_type := target
289build_target := SHARED_LIBRARY
290include $(LOCAL_PATH)/Android.build.mk
291build_type := host
292include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700293
294#-----------------------------------------------------------------------
295# libunwind testing
296#-----------------------------------------------------------------------
297libunwind-unit-tests_cflags := \
298 -fno-builtin \
299 -O0 \
300 -g \
301
302libunwind-unit-tests_c_includes := \
303 $(LOCAL_PATH)/include \
304
305libunwind-unit-tests_src_files := \
306 android/tests/local_test.cpp \
307
308libunwind-unit-tests_shared_libraries := \
309 libunwind \
310
311libunwind-unit-tests_multilib := both
312module := libunwind-unit-tests
313module_tag := optional
314build_type := target
315build_target := NATIVE_TEST
316include $(LOCAL_PATH)/Android.build.mk
317build_type := host
318include $(LOCAL_PATH)/Android.build.mk
319
320# Run the unit tests built for x86 or x86_64.
321ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
322ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
323LINKER = linker64
324TEST_SUFFIX = 64
325else
326LINKER = linker
327TEST_SUFFIX = 32
328endif
329
330libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
331 if [ ! -d /system -o ! -d /system/bin ]; then \
332 echo "Attempting to create /system/bin"; \
333 sudo mkdir -p -m 0777 /system/bin; \
334 fi
335 mkdir -p $(TARGET_OUT_DATA)/local/tmp
336 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
337 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
338 ANDROID_DATA=$(TARGET_OUT_DATA) \
339 ANDROID_ROOT=$(TARGET_OUT) \
340 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
341 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
342endif