blob: 155a9f1d8d3f643b5f4e639e0943ef6dc110fd67 [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)
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080021build_host := true
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080022endif
23
Christopher Ferris76dbee52014-02-12 21:12:09 -080024# Set to true to enable a debug build of the libraries.
25# To control what is logged, set the environment variable UNW_DEBUG_LEVEL=x,
26# where x controls the verbosity (from 1 to 20).
27debug := false
28
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080029common_cflags := \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070030 -Wno-unused-parameter \
31 -Werror \
32
33# gcc 4.8 appears to be overeager declaring that a variable is uninitialized,
34# under certain circumstances. Turn off this warning only for target so that
35# coverage is still present for the host code. When the entire build system
36# is switched to 4.9, then this can be removed.
37common_cflags_target := \
38 -Wno-maybe-uninitialized \
39
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020040ifeq ($(LOCAL_CLANG),true)
41# src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
42common_cflags += -Wno-header-guard
43endif
44
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070045ifneq ($(debug),true)
46common_cflags += \
Christopher Ferris1c82a522013-10-01 12:38:42 -070047 -DHAVE_CONFIG_H \
48 -DNDEBUG \
49 -D_GNU_SOURCE \
Christopher Ferris9fc75e82014-01-26 21:39:06 -080050
Christopher Ferris76dbee52014-02-12 21:12:09 -080051else
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070052common_cflags += \
Christopher Ferris76dbee52014-02-12 21:12:09 -080053 -DHAVE_CONFIG_H \
54 -DDEBUG \
55 -D_GNU_SOURCE \
56 -U_FORTIFY_SOURCE \
57
58endif
Pavel Chupinf1f90e72013-12-04 13:29:29 +040059
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080060common_c_includes := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070061 $(LOCAL_PATH)/src \
62 $(LOCAL_PATH)/include \
Colin Cross26183d22014-01-24 15:59:56 -080063
Duane Sand5cd02e12014-06-05 23:38:56 -070064# Since mips and mips64 use the same source, only generate includes/srcs
65# for the below set of arches.
66generate_arches := arm arm64 mips x86 x86_64
67# The complete list of arches used by Android.build.mk to set arch
68# variables.
69libunwind_arches := $(generate_arches) mips64
Christopher Ferris1c82a522013-10-01 12:38:42 -070070
Duane Sand5cd02e12014-06-05 23:38:56 -070071$(foreach arch,$(generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080072 $(eval common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
Christopher Ferris1c82a522013-10-01 12:38:42 -070073
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080074#-----------------------------------------------------------------------
75# libunwind shared library
76#-----------------------------------------------------------------------
77libunwind_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070078 src/mi/init.c \
79 src/mi/flush_cache.c \
80 src/mi/mempool.c \
81 src/mi/strerror.c \
82 src/mi/backtrace.c \
83 src/mi/dyn-cancel.c \
84 src/mi/dyn-info-list.c \
85 src/mi/dyn-register.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -080086 src/mi/map.c \
87 src/mi/Lmap.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -070088 src/mi/Ldyn-extract.c \
89 src/mi/Lfind_dynamic_proc_info.c \
90 src/mi/Lget_proc_info_by_ip.c \
91 src/mi/Lget_proc_name.c \
92 src/mi/Lput_dynamic_unwind_info.c \
93 src/mi/Ldestroy_addr_space.c \
94 src/mi/Lget_reg.c \
95 src/mi/Lset_reg.c \
96 src/mi/Lget_fpreg.c \
97 src/mi/Lset_fpreg.c \
98 src/mi/Lset_caching_policy.c \
99 src/mi/Gdyn-extract.c \
100 src/mi/Gdyn-remote.c \
101 src/mi/Gfind_dynamic_proc_info.c \
102 src/mi/Gget_accessors.c \
103 src/mi/Gget_proc_info_by_ip.c \
104 src/mi/Gget_proc_name.c \
105 src/mi/Gput_dynamic_unwind_info.c \
106 src/mi/Gdestroy_addr_space.c \
107 src/mi/Gget_reg.c \
108 src/mi/Gset_reg.c \
109 src/mi/Gget_fpreg.c \
110 src/mi/Gset_fpreg.c \
111 src/mi/Gset_caching_policy.c \
112 src/dwarf/Lexpr.c \
113 src/dwarf/Lfde.c \
114 src/dwarf/Lparser.c \
115 src/dwarf/Lpe.c \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700116 src/dwarf/Lstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700117 src/dwarf/Lfind_proc_info-lsb.c \
118 src/dwarf/Lfind_unwind_table.c \
119 src/dwarf/Gexpr.c \
120 src/dwarf/Gfde.c \
121 src/dwarf/Gfind_proc_info-lsb.c \
122 src/dwarf/Gfind_unwind_table.c \
123 src/dwarf/Gparser.c \
124 src/dwarf/Gpe.c \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700125 src/dwarf/Gstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700126 src/dwarf/global.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800127 src/os-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700128 src/os-linux.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800129 src/Los-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700130
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800131# Arch specific source files.
Duane Sand5cd02e12014-06-05 23:38:56 -0700132$(foreach arch,$(generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800133 $(eval libunwind_src_files_$(arch) += \
134 src/$(arch)/is_fpreg.c \
135 src/$(arch)/regname.c \
136 src/$(arch)/Gcreate_addr_space.c \
137 src/$(arch)/Gget_proc_info.c \
138 src/$(arch)/Gget_save_loc.c \
139 src/$(arch)/Gglobal.c \
140 src/$(arch)/Ginit.c \
141 src/$(arch)/Ginit_local.c \
142 src/$(arch)/Ginit_remote.c \
143 src/$(arch)/Gregs.c \
144 src/$(arch)/Gresume.c \
145 src/$(arch)/Gstep.c \
146 src/$(arch)/Lcreate_addr_space.c \
147 src/$(arch)/Lget_proc_info.c \
148 src/$(arch)/Lget_save_loc.c \
149 src/$(arch)/Lglobal.c \
150 src/$(arch)/Linit.c \
151 src/$(arch)/Linit_local.c \
152 src/$(arch)/Linit_remote.c \
153 src/$(arch)/Lregs.c \
154 src/$(arch)/Lresume.c \
155 src/$(arch)/Lstep.c \
Colin Cross26183d22014-01-24 15:59:56 -0800156 ))
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800157
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800158libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700159 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700160 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700161 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700162 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700163 src/arm/Lex_tables.c \
164
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800165libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800166 src/aarch64/Gis_signal_frame.c \
167 src/aarch64/Lis_signal_frame.c \
168
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800169libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700170 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700171 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700172 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700173
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800174libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700175 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700176 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700177 src/x86/Los-linux.c \
178
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800179libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400180 src/x86_64/getcontext.S \
181 src/x86_64/Gstash_frame.c \
182 src/x86_64/Gtrace.c \
183 src/x86_64/Gos-linux.c \
184 src/x86_64/Lstash_frame.c \
185 src/x86_64/Ltrace.c \
186 src/x86_64/Los-linux.c \
187 src/x86_64/setcontext.S \
188
Duane Sand5cd02e12014-06-05 23:38:56 -0700189# mips and mips64 use the same sources but define _MIP_SIM differently
190# to change the behavior.
191# mips uses o32 abi (_MIPS_SIM == _ABIO32).
192# mips64 uses n64 abi (_MIPS_SIM == _ABI64).
193common_c_includes_mips64 := $(LOCAL_PATH)/include/tdep-mips
194libunwind_src_files_mips64 := $(libunwind_src_files_mips)
195
196# 64-bit architectures
197libunwind_src_files_arm64 += src/elf64.c
198libunwind_src_files_mips64 += src/elf64.c
199libunwind_src_files_x86_64 += src/elf64.c
200
201# 32-bit architectures
202libunwind_src_files_arm += src/elf32.c
203libunwind_src_files_mips += src/elf32.c
204libunwind_src_files_x86 += src/elf32.c
205
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800206libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700207 libdl \
208
Dan Albert162c8cb2014-05-09 10:19:20 -0700209libunwind_ldflags_host := \
210 -nostdlib
211
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800212libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700213 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800214 -lpthread \
215
Christopher Ferris76dbee52014-02-12 21:12:09 -0800216ifeq ($(debug),true)
217libunwind_shared_libraries += \
218 liblog \
219
220endif
221
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800222module := libunwind
223module_tag := optional
224build_type := target
225build_target := SHARED_LIBRARY
226include $(LOCAL_PATH)/Android.build.mk
227build_type := host
228include $(LOCAL_PATH)/Android.build.mk
Dan Albert76728fb2014-05-09 13:51:35 -0700229build_type := target
230build_target := STATIC_LIBRARY
231include $(LOCAL_PATH)/Android.build.mk
232build_type := host
233include $(LOCAL_PATH)/Android.build.mk
234
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800235#-----------------------------------------------------------------------
236# libunwind-ptrace shared library
237#-----------------------------------------------------------------------
238libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700239 src/ptrace/_UPT_elf.c \
240 src/ptrace/_UPT_accessors.c \
241 src/ptrace/_UPT_access_fpreg.c \
242 src/ptrace/_UPT_access_mem.c \
243 src/ptrace/_UPT_access_reg.c \
244 src/ptrace/_UPT_create.c \
245 src/ptrace/_UPT_destroy.c \
246 src/ptrace/_UPT_find_proc_info.c \
247 src/ptrace/_UPT_get_dyn_info_list_addr.c \
248 src/ptrace/_UPT_put_unwind_info.c \
249 src/ptrace/_UPT_get_proc_name.c \
250 src/ptrace/_UPT_reg_offset.c \
251 src/ptrace/_UPT_resume.c \
252
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800253libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700254 libunwind \
255
Dan Albert162c8cb2014-05-09 10:19:20 -0700256libunwind-ptrace_ldflags_host := \
257 -nostdlib
258
259libunwind-ptrace_ldlibs_host := \
260 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800261 -lpthread \
262
Christopher Ferris76dbee52014-02-12 21:12:09 -0800263ifeq ($(debug),true)
264libunwind-ptrace_shared_libraries += \
265 liblog \
266
267endif
268
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800269module := libunwind-ptrace
270module_tag := optional
271build_type := target
272build_target := SHARED_LIBRARY
273include $(LOCAL_PATH)/Android.build.mk
274build_type := host
275include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700276
277#-----------------------------------------------------------------------
Christopher Ferrisaa946482014-06-19 11:04:34 -0700278# libunwindbacktrace static library
279#-----------------------------------------------------------------------
280libunwindbacktrace_src_files += \
281 src/unwind/BacktraceWrapper.c \
282 src/unwind/DeleteException.c \
283 src/unwind/FindEnclosingFunction.c \
284 src/unwind/ForcedUnwind.c \
285 src/unwind/GetBSP.c \
286 src/unwind/GetCFA.c \
287 src/unwind/GetDataRelBase.c \
288 src/unwind/GetGR.c \
289 src/unwind/GetIP.c \
290 src/unwind/GetIPInfo.c \
291 src/unwind/GetLanguageSpecificData.c \
292 src/unwind/GetRegionStart.c \
293 src/unwind/GetTextRelBase.c \
294 src/unwind/RaiseException.c \
295 src/unwind/Resume.c \
296 src/unwind/Resume_or_Rethrow.c \
297 src/unwind/SetGR.c \
298 src/unwind/SetIP.c \
299
300libunwindbacktrace_cflags += \
301 -Wno-old-style-declaration \
302 -fvisibility=hidden \
303
304module := libunwindbacktrace
305module_tag := optional
306build_type := target
307build_target := STATIC_LIBRARY
308libunwindbacktrace_whole_static_libraries := libunwind
309include $(LOCAL_PATH)/Android.build.mk
310build_type := host
311include $(LOCAL_PATH)/Android.build.mk
312
313#-----------------------------------------------------------------------
Christopher Ferris7c042422014-04-25 13:21:40 -0700314# libunwind testing
315#-----------------------------------------------------------------------
316libunwind-unit-tests_cflags := \
317 -fno-builtin \
318 -O0 \
319 -g \
320
321libunwind-unit-tests_c_includes := \
322 $(LOCAL_PATH)/include \
323
324libunwind-unit-tests_src_files := \
325 android/tests/local_test.cpp \
326
327libunwind-unit-tests_shared_libraries := \
328 libunwind \
329
330libunwind-unit-tests_multilib := both
331module := libunwind-unit-tests
332module_tag := optional
333build_type := target
334build_target := NATIVE_TEST
335include $(LOCAL_PATH)/Android.build.mk
336build_type := host
337include $(LOCAL_PATH)/Android.build.mk
338
339# Run the unit tests built for x86 or x86_64.
340ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
341ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
342LINKER = linker64
343TEST_SUFFIX = 64
344else
345LINKER = linker
346TEST_SUFFIX = 32
347endif
348
349libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
350 if [ ! -d /system -o ! -d /system/bin ]; then \
351 echo "Attempting to create /system/bin"; \
352 sudo mkdir -p -m 0777 /system/bin; \
353 fi
354 mkdir -p $(TARGET_OUT_DATA)/local/tmp
355 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
356 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
357 ANDROID_DATA=$(TARGET_OUT_DATA) \
358 ANDROID_ROOT=$(TARGET_OUT) \
359 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
360 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
361endif