blob: 6f94bb1f9dc924a47b467bfac306c4f9ae5c0d3e [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 Ferrisfe6ff002014-01-30 01:04:29 -080024endif
25endif
26
Christopher Ferris76dbee52014-02-12 21:12:09 -080027# Set to true to enable a debug build of the libraries.
28# To control what is logged, set the environment variable UNW_DEBUG_LEVEL=x,
29# where x controls the verbosity (from 1 to 20).
30debug := false
31
Christopher Ferris2319e0f2014-04-29 10:23:55 -070032common_conlyflags := \
33 -Wno-old-style-declaration \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070034
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080035common_cflags := \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070036 -Wno-unused-parameter \
37 -Werror \
38
39# gcc 4.8 appears to be overeager declaring that a variable is uninitialized,
40# under certain circumstances. Turn off this warning only for target so that
41# coverage is still present for the host code. When the entire build system
42# is switched to 4.9, then this can be removed.
43common_cflags_target := \
44 -Wno-maybe-uninitialized \
45
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020046ifeq ($(LOCAL_CLANG),true)
47# src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
48common_cflags += -Wno-header-guard
49endif
50
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070051ifneq ($(debug),true)
52common_cflags += \
Christopher Ferris1c82a522013-10-01 12:38:42 -070053 -DHAVE_CONFIG_H \
54 -DNDEBUG \
55 -D_GNU_SOURCE \
Christopher Ferris9fc75e82014-01-26 21:39:06 -080056
Christopher Ferris76dbee52014-02-12 21:12:09 -080057else
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070058common_cflags += \
Christopher Ferris76dbee52014-02-12 21:12:09 -080059 -DHAVE_CONFIG_H \
60 -DDEBUG \
61 -D_GNU_SOURCE \
62 -U_FORTIFY_SOURCE \
63
64endif
Pavel Chupinf1f90e72013-12-04 13:29:29 +040065
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080066common_c_includes := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070067 $(LOCAL_PATH)/src \
68 $(LOCAL_PATH)/include \
Colin Cross26183d22014-01-24 15:59:56 -080069
Pavel Chupinf1f90e72013-12-04 13:29:29 +040070libunwind_arches := arm arm64 mips x86 x86_64
Christopher Ferris1c82a522013-10-01 12:38:42 -070071
Colin Cross26183d22014-01-24 15:59:56 -080072$(foreach arch,$(libunwind_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080073 $(eval common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
Christopher Ferris1c82a522013-10-01 12:38:42 -070074
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080075#-----------------------------------------------------------------------
76# libunwind shared library
77#-----------------------------------------------------------------------
78libunwind_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070079 src/mi/init.c \
80 src/mi/flush_cache.c \
81 src/mi/mempool.c \
82 src/mi/strerror.c \
83 src/mi/backtrace.c \
84 src/mi/dyn-cancel.c \
85 src/mi/dyn-info-list.c \
86 src/mi/dyn-register.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -080087 src/mi/map.c \
88 src/mi/Lmap.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -070089 src/mi/Ldyn-extract.c \
90 src/mi/Lfind_dynamic_proc_info.c \
91 src/mi/Lget_proc_info_by_ip.c \
92 src/mi/Lget_proc_name.c \
93 src/mi/Lput_dynamic_unwind_info.c \
94 src/mi/Ldestroy_addr_space.c \
95 src/mi/Lget_reg.c \
96 src/mi/Lset_reg.c \
97 src/mi/Lget_fpreg.c \
98 src/mi/Lset_fpreg.c \
99 src/mi/Lset_caching_policy.c \
100 src/mi/Gdyn-extract.c \
101 src/mi/Gdyn-remote.c \
102 src/mi/Gfind_dynamic_proc_info.c \
103 src/mi/Gget_accessors.c \
104 src/mi/Gget_proc_info_by_ip.c \
105 src/mi/Gget_proc_name.c \
106 src/mi/Gput_dynamic_unwind_info.c \
107 src/mi/Gdestroy_addr_space.c \
108 src/mi/Gget_reg.c \
109 src/mi/Gset_reg.c \
110 src/mi/Gget_fpreg.c \
111 src/mi/Gset_fpreg.c \
112 src/mi/Gset_caching_policy.c \
113 src/dwarf/Lexpr.c \
114 src/dwarf/Lfde.c \
115 src/dwarf/Lparser.c \
116 src/dwarf/Lpe.c \
117 src/dwarf/Lstep.c \
118 src/dwarf/Lfind_proc_info-lsb.c \
119 src/dwarf/Lfind_unwind_table.c \
120 src/dwarf/Gexpr.c \
121 src/dwarf/Gfde.c \
122 src/dwarf/Gfind_proc_info-lsb.c \
123 src/dwarf/Gfind_unwind_table.c \
124 src/dwarf/Gparser.c \
125 src/dwarf/Gpe.c \
126 src/dwarf/Gstep.c \
127 src/dwarf/global.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800128 src/os-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700129 src/os-linux.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800130 src/Los-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700131
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800132# Arch specific source files.
Colin Cross26183d22014-01-24 15:59:56 -0800133$(foreach arch,$(libunwind_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800134 $(eval libunwind_src_files_$(arch) += \
135 src/$(arch)/is_fpreg.c \
136 src/$(arch)/regname.c \
137 src/$(arch)/Gcreate_addr_space.c \
138 src/$(arch)/Gget_proc_info.c \
139 src/$(arch)/Gget_save_loc.c \
140 src/$(arch)/Gglobal.c \
141 src/$(arch)/Ginit.c \
142 src/$(arch)/Ginit_local.c \
143 src/$(arch)/Ginit_remote.c \
144 src/$(arch)/Gregs.c \
145 src/$(arch)/Gresume.c \
146 src/$(arch)/Gstep.c \
147 src/$(arch)/Lcreate_addr_space.c \
148 src/$(arch)/Lget_proc_info.c \
149 src/$(arch)/Lget_save_loc.c \
150 src/$(arch)/Lglobal.c \
151 src/$(arch)/Linit.c \
152 src/$(arch)/Linit_local.c \
153 src/$(arch)/Linit_remote.c \
154 src/$(arch)/Lregs.c \
155 src/$(arch)/Lresume.c \
156 src/$(arch)/Lstep.c \
Colin Cross26183d22014-01-24 15:59:56 -0800157 ))
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800158
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800159# 64-bit architectures
160libunwind_src_files_arm64 += src/elf64.c
161libunwind_src_files_x86_64 += src/elf64.c
162
163# 32-bit architectures
164libunwind_src_files_arm += src/elf32.c
165libunwind_src_files_mips += src/elf32.c
166libunwind_src_files_x86 += src/elf32.c
167
168libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700169 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700170 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700171 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700172 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700173 src/arm/Lex_tables.c \
174
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800175libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800176 src/aarch64/Gis_signal_frame.c \
177 src/aarch64/Lis_signal_frame.c \
178
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800179libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700180 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700181 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700182 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700183
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800184libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700185 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700186 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700187 src/x86/Los-linux.c \
188
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800189libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400190 src/x86_64/getcontext.S \
191 src/x86_64/Gstash_frame.c \
192 src/x86_64/Gtrace.c \
193 src/x86_64/Gos-linux.c \
194 src/x86_64/Lstash_frame.c \
195 src/x86_64/Ltrace.c \
196 src/x86_64/Los-linux.c \
197 src/x86_64/setcontext.S \
198
Christopher Ferris2319e0f2014-04-29 10:23:55 -0700199libunwind_src_files += \
200 src/unwind/Backtrace.c \
201 src/unwind/DeleteException.c \
202 src/unwind/FindEnclosingFunction.c \
203 src/unwind/ForcedUnwind.c \
204 src/unwind/GetBSP.c \
205 src/unwind/GetCFA.c \
206 src/unwind/GetDataRelBase.c \
207 src/unwind/GetGR.c \
208 src/unwind/GetIP.c \
209 src/unwind/GetIPInfo.c \
210 src/unwind/GetLanguageSpecificData.c \
211 src/unwind/GetRegionStart.c \
212 src/unwind/GetTextRelBase.c \
213 src/unwind/RaiseException.c \
214 src/unwind/Resume.c \
215 src/unwind/Resume_or_Rethrow.c \
216 src/unwind/SetGR.c \
217 src/unwind/SetIP.c \
218
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800219libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700220 libdl \
221
Dan Albert162c8cb2014-05-09 10:19:20 -0700222libunwind_ldflags_host := \
223 -nostdlib
224
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800225libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700226 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800227 -lpthread \
228
Christopher Ferris76dbee52014-02-12 21:12:09 -0800229ifeq ($(debug),true)
230libunwind_shared_libraries += \
231 liblog \
232
233endif
234
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800235module := libunwind
236module_tag := optional
237build_type := target
238build_target := SHARED_LIBRARY
239include $(LOCAL_PATH)/Android.build.mk
240build_type := host
241include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris836d9152013-12-02 12:27:30 -0800242
Dan Albert76728fb2014-05-09 13:51:35 -0700243build_type := target
244build_target := STATIC_LIBRARY
245include $(LOCAL_PATH)/Android.build.mk
246build_type := host
247include $(LOCAL_PATH)/Android.build.mk
248
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800249#-----------------------------------------------------------------------
250# libunwind-ptrace shared library
251#-----------------------------------------------------------------------
252libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700253 src/ptrace/_UPT_elf.c \
254 src/ptrace/_UPT_accessors.c \
255 src/ptrace/_UPT_access_fpreg.c \
256 src/ptrace/_UPT_access_mem.c \
257 src/ptrace/_UPT_access_reg.c \
258 src/ptrace/_UPT_create.c \
259 src/ptrace/_UPT_destroy.c \
260 src/ptrace/_UPT_find_proc_info.c \
261 src/ptrace/_UPT_get_dyn_info_list_addr.c \
262 src/ptrace/_UPT_put_unwind_info.c \
263 src/ptrace/_UPT_get_proc_name.c \
264 src/ptrace/_UPT_reg_offset.c \
265 src/ptrace/_UPT_resume.c \
266
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800267libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700268 libunwind \
269
Dan Albert162c8cb2014-05-09 10:19:20 -0700270libunwind-ptrace_ldflags_host := \
271 -nostdlib
272
273libunwind-ptrace_ldlibs_host := \
274 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800275 -lpthread \
276
Christopher Ferris76dbee52014-02-12 21:12:09 -0800277ifeq ($(debug),true)
278libunwind-ptrace_shared_libraries += \
279 liblog \
280
281endif
282
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800283module := libunwind-ptrace
284module_tag := optional
285build_type := target
286build_target := SHARED_LIBRARY
287include $(LOCAL_PATH)/Android.build.mk
288build_type := host
289include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700290
291#-----------------------------------------------------------------------
292# libunwind testing
293#-----------------------------------------------------------------------
294libunwind-unit-tests_cflags := \
295 -fno-builtin \
296 -O0 \
297 -g \
298
299libunwind-unit-tests_c_includes := \
300 $(LOCAL_PATH)/include \
301
302libunwind-unit-tests_src_files := \
303 android/tests/local_test.cpp \
304
305libunwind-unit-tests_shared_libraries := \
306 libunwind \
307
308libunwind-unit-tests_multilib := both
309module := libunwind-unit-tests
310module_tag := optional
311build_type := target
312build_target := NATIVE_TEST
313include $(LOCAL_PATH)/Android.build.mk
314build_type := host
315include $(LOCAL_PATH)/Android.build.mk
316
317# Run the unit tests built for x86 or x86_64.
318ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
319ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
320LINKER = linker64
321TEST_SUFFIX = 64
322else
323LINKER = linker
324TEST_SUFFIX = 32
325endif
326
327libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
328 if [ ! -d /system -o ! -d /system/bin ]; then \
329 echo "Attempting to create /system/bin"; \
330 sudo mkdir -p -m 0777 /system/bin; \
331 fi
332 mkdir -p $(TARGET_OUT_DATA)/local/tmp
333 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
334 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
335 ANDROID_DATA=$(TARGET_OUT_DATA) \
336 ANDROID_ROOT=$(TARGET_OUT) \
337 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
338 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
339endif