blob: 5b3c64ca68f7a297479123baf4cb12ed6ab2b896 [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
49ifneq ($(debug),true)
50common_cflags += \
Christopher Ferris1c82a522013-10-01 12:38:42 -070051 -DHAVE_CONFIG_H \
52 -DNDEBUG \
53 -D_GNU_SOURCE \
Christopher Ferris9fc75e82014-01-26 21:39:06 -080054
Christopher Ferris76dbee52014-02-12 21:12:09 -080055else
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070056common_cflags += \
Christopher Ferris76dbee52014-02-12 21:12:09 -080057 -DHAVE_CONFIG_H \
58 -DDEBUG \
59 -D_GNU_SOURCE \
60 -U_FORTIFY_SOURCE \
61
62endif
Pavel Chupinf1f90e72013-12-04 13:29:29 +040063
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080064common_c_includes := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070065 $(LOCAL_PATH)/src \
66 $(LOCAL_PATH)/include \
Colin Cross26183d22014-01-24 15:59:56 -080067
Pavel Chupinf1f90e72013-12-04 13:29:29 +040068libunwind_arches := arm arm64 mips x86 x86_64
Christopher Ferris1c82a522013-10-01 12:38:42 -070069
Colin Cross26183d22014-01-24 15:59:56 -080070$(foreach arch,$(libunwind_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080071 $(eval common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
Christopher Ferris1c82a522013-10-01 12:38:42 -070072
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080073#-----------------------------------------------------------------------
74# libunwind shared library
75#-----------------------------------------------------------------------
76libunwind_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070077 src/mi/init.c \
78 src/mi/flush_cache.c \
79 src/mi/mempool.c \
80 src/mi/strerror.c \
81 src/mi/backtrace.c \
82 src/mi/dyn-cancel.c \
83 src/mi/dyn-info-list.c \
84 src/mi/dyn-register.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -080085 src/mi/map.c \
86 src/mi/Lmap.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -070087 src/mi/Ldyn-extract.c \
88 src/mi/Lfind_dynamic_proc_info.c \
89 src/mi/Lget_proc_info_by_ip.c \
90 src/mi/Lget_proc_name.c \
91 src/mi/Lput_dynamic_unwind_info.c \
92 src/mi/Ldestroy_addr_space.c \
93 src/mi/Lget_reg.c \
94 src/mi/Lset_reg.c \
95 src/mi/Lget_fpreg.c \
96 src/mi/Lset_fpreg.c \
97 src/mi/Lset_caching_policy.c \
98 src/mi/Gdyn-extract.c \
99 src/mi/Gdyn-remote.c \
100 src/mi/Gfind_dynamic_proc_info.c \
101 src/mi/Gget_accessors.c \
102 src/mi/Gget_proc_info_by_ip.c \
103 src/mi/Gget_proc_name.c \
104 src/mi/Gput_dynamic_unwind_info.c \
105 src/mi/Gdestroy_addr_space.c \
106 src/mi/Gget_reg.c \
107 src/mi/Gset_reg.c \
108 src/mi/Gget_fpreg.c \
109 src/mi/Gset_fpreg.c \
110 src/mi/Gset_caching_policy.c \
111 src/dwarf/Lexpr.c \
112 src/dwarf/Lfde.c \
113 src/dwarf/Lparser.c \
114 src/dwarf/Lpe.c \
115 src/dwarf/Lstep.c \
116 src/dwarf/Lfind_proc_info-lsb.c \
117 src/dwarf/Lfind_unwind_table.c \
118 src/dwarf/Gexpr.c \
119 src/dwarf/Gfde.c \
120 src/dwarf/Gfind_proc_info-lsb.c \
121 src/dwarf/Gfind_unwind_table.c \
122 src/dwarf/Gparser.c \
123 src/dwarf/Gpe.c \
124 src/dwarf/Gstep.c \
125 src/dwarf/global.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800126 src/os-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700127 src/os-linux.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800128 src/Los-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700129
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800130# Arch specific source files.
Colin Cross26183d22014-01-24 15:59:56 -0800131$(foreach arch,$(libunwind_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800132 $(eval libunwind_src_files_$(arch) += \
133 src/$(arch)/is_fpreg.c \
134 src/$(arch)/regname.c \
135 src/$(arch)/Gcreate_addr_space.c \
136 src/$(arch)/Gget_proc_info.c \
137 src/$(arch)/Gget_save_loc.c \
138 src/$(arch)/Gglobal.c \
139 src/$(arch)/Ginit.c \
140 src/$(arch)/Ginit_local.c \
141 src/$(arch)/Ginit_remote.c \
142 src/$(arch)/Gregs.c \
143 src/$(arch)/Gresume.c \
144 src/$(arch)/Gstep.c \
145 src/$(arch)/Lcreate_addr_space.c \
146 src/$(arch)/Lget_proc_info.c \
147 src/$(arch)/Lget_save_loc.c \
148 src/$(arch)/Lglobal.c \
149 src/$(arch)/Linit.c \
150 src/$(arch)/Linit_local.c \
151 src/$(arch)/Linit_remote.c \
152 src/$(arch)/Lregs.c \
153 src/$(arch)/Lresume.c \
154 src/$(arch)/Lstep.c \
Colin Cross26183d22014-01-24 15:59:56 -0800155 ))
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800156
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800157# 64-bit architectures
158libunwind_src_files_arm64 += src/elf64.c
159libunwind_src_files_x86_64 += src/elf64.c
160
161# 32-bit architectures
162libunwind_src_files_arm += src/elf32.c
163libunwind_src_files_mips += src/elf32.c
164libunwind_src_files_x86 += src/elf32.c
165
166libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700167 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700168 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700169 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700170 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700171 src/arm/Lex_tables.c \
172
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800173libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800174 src/aarch64/Gis_signal_frame.c \
175 src/aarch64/Lis_signal_frame.c \
176
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800177libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700178 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700179 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700180 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700181
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800182libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700183 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700184 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700185 src/x86/Los-linux.c \
186
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800187libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400188 src/x86_64/getcontext.S \
189 src/x86_64/Gstash_frame.c \
190 src/x86_64/Gtrace.c \
191 src/x86_64/Gos-linux.c \
192 src/x86_64/Lstash_frame.c \
193 src/x86_64/Ltrace.c \
194 src/x86_64/Los-linux.c \
195 src/x86_64/setcontext.S \
196
Christopher Ferris2319e0f2014-04-29 10:23:55 -0700197libunwind_src_files += \
198 src/unwind/Backtrace.c \
199 src/unwind/DeleteException.c \
200 src/unwind/FindEnclosingFunction.c \
201 src/unwind/ForcedUnwind.c \
202 src/unwind/GetBSP.c \
203 src/unwind/GetCFA.c \
204 src/unwind/GetDataRelBase.c \
205 src/unwind/GetGR.c \
206 src/unwind/GetIP.c \
207 src/unwind/GetIPInfo.c \
208 src/unwind/GetLanguageSpecificData.c \
209 src/unwind/GetRegionStart.c \
210 src/unwind/GetTextRelBase.c \
211 src/unwind/RaiseException.c \
212 src/unwind/Resume.c \
213 src/unwind/Resume_or_Rethrow.c \
214 src/unwind/SetGR.c \
215 src/unwind/SetIP.c \
216
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800217libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700218 libdl \
219
Dan Albert162c8cb2014-05-09 10:19:20 -0700220libunwind_ldflags_host := \
221 -nostdlib
222
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800223libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700224 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800225 -lpthread \
226
Christopher Ferris76dbee52014-02-12 21:12:09 -0800227ifeq ($(debug),true)
228libunwind_shared_libraries += \
229 liblog \
230
231endif
232
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800233module := libunwind
234module_tag := optional
235build_type := target
236build_target := SHARED_LIBRARY
237include $(LOCAL_PATH)/Android.build.mk
238build_type := host
239include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris836d9152013-12-02 12:27:30 -0800240
Dan Albert76728fb2014-05-09 13:51:35 -0700241build_type := target
242build_target := STATIC_LIBRARY
243include $(LOCAL_PATH)/Android.build.mk
244build_type := host
245include $(LOCAL_PATH)/Android.build.mk
246
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800247#-----------------------------------------------------------------------
248# libunwind-ptrace shared library
249#-----------------------------------------------------------------------
250libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700251 src/ptrace/_UPT_elf.c \
252 src/ptrace/_UPT_accessors.c \
253 src/ptrace/_UPT_access_fpreg.c \
254 src/ptrace/_UPT_access_mem.c \
255 src/ptrace/_UPT_access_reg.c \
256 src/ptrace/_UPT_create.c \
257 src/ptrace/_UPT_destroy.c \
258 src/ptrace/_UPT_find_proc_info.c \
259 src/ptrace/_UPT_get_dyn_info_list_addr.c \
260 src/ptrace/_UPT_put_unwind_info.c \
261 src/ptrace/_UPT_get_proc_name.c \
262 src/ptrace/_UPT_reg_offset.c \
263 src/ptrace/_UPT_resume.c \
264
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800265libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700266 libunwind \
267
Dan Albert162c8cb2014-05-09 10:19:20 -0700268libunwind-ptrace_ldflags_host := \
269 -nostdlib
270
271libunwind-ptrace_ldlibs_host := \
272 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800273 -lpthread \
274
Christopher Ferris76dbee52014-02-12 21:12:09 -0800275ifeq ($(debug),true)
276libunwind-ptrace_shared_libraries += \
277 liblog \
278
279endif
280
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800281module := libunwind-ptrace
282module_tag := optional
283build_type := target
284build_target := SHARED_LIBRARY
285include $(LOCAL_PATH)/Android.build.mk
286build_type := host
287include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700288
289#-----------------------------------------------------------------------
290# libunwind testing
291#-----------------------------------------------------------------------
292libunwind-unit-tests_cflags := \
293 -fno-builtin \
294 -O0 \
295 -g \
296
297libunwind-unit-tests_c_includes := \
298 $(LOCAL_PATH)/include \
299
300libunwind-unit-tests_src_files := \
301 android/tests/local_test.cpp \
302
303libunwind-unit-tests_shared_libraries := \
304 libunwind \
305
306libunwind-unit-tests_multilib := both
307module := libunwind-unit-tests
308module_tag := optional
309build_type := target
310build_target := NATIVE_TEST
311include $(LOCAL_PATH)/Android.build.mk
312build_type := host
313include $(LOCAL_PATH)/Android.build.mk
314
315# Run the unit tests built for x86 or x86_64.
316ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
317ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
318LINKER = linker64
319TEST_SUFFIX = 64
320else
321LINKER = linker
322TEST_SUFFIX = 32
323endif
324
325libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
326 if [ ! -d /system -o ! -d /system/bin ]; then \
327 echo "Attempting to create /system/bin"; \
328 sudo mkdir -p -m 0777 /system/bin; \
329 fi
330 mkdir -p $(TARGET_OUT_DATA)/local/tmp
331 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
332 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
333 ANDROID_DATA=$(TARGET_OUT_DATA) \
334 ANDROID_ROOT=$(TARGET_OUT) \
335 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
336 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
337endif