blob: e6d12610d1ec86184edccb6145955e3c191cfe31 [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 Ferris2319e0f2014-04-29 10:23:55 -070029common_conlyflags := \
30 -Wno-old-style-declaration \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070031
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080032common_cflags := \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070033 -Wno-unused-parameter \
34 -Werror \
35
36# gcc 4.8 appears to be overeager declaring that a variable is uninitialized,
37# under certain circumstances. Turn off this warning only for target so that
38# coverage is still present for the host code. When the entire build system
39# is switched to 4.9, then this can be removed.
40common_cflags_target := \
41 -Wno-maybe-uninitialized \
42
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020043ifeq ($(LOCAL_CLANG),true)
44# src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
45common_cflags += -Wno-header-guard
46endif
47
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070048ifneq ($(debug),true)
49common_cflags += \
Christopher Ferris1c82a522013-10-01 12:38:42 -070050 -DHAVE_CONFIG_H \
51 -DNDEBUG \
52 -D_GNU_SOURCE \
Christopher Ferris9fc75e82014-01-26 21:39:06 -080053
Christopher Ferris76dbee52014-02-12 21:12:09 -080054else
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070055common_cflags += \
Christopher Ferris76dbee52014-02-12 21:12:09 -080056 -DHAVE_CONFIG_H \
57 -DDEBUG \
58 -D_GNU_SOURCE \
59 -U_FORTIFY_SOURCE \
60
61endif
Pavel Chupinf1f90e72013-12-04 13:29:29 +040062
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080063common_c_includes := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070064 $(LOCAL_PATH)/src \
65 $(LOCAL_PATH)/include \
Colin Cross26183d22014-01-24 15:59:56 -080066
Duane Sand5cd02e12014-06-05 23:38:56 -070067# Since mips and mips64 use the same source, only generate includes/srcs
68# for the below set of arches.
69generate_arches := arm arm64 mips x86 x86_64
70# The complete list of arches used by Android.build.mk to set arch
71# variables.
72libunwind_arches := $(generate_arches) mips64
Christopher Ferris1c82a522013-10-01 12:38:42 -070073
Duane Sand5cd02e12014-06-05 23:38:56 -070074$(foreach arch,$(generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080075 $(eval common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
Christopher Ferris1c82a522013-10-01 12:38:42 -070076
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080077#-----------------------------------------------------------------------
78# libunwind shared library
79#-----------------------------------------------------------------------
80libunwind_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070081 src/mi/init.c \
82 src/mi/flush_cache.c \
83 src/mi/mempool.c \
84 src/mi/strerror.c \
85 src/mi/backtrace.c \
86 src/mi/dyn-cancel.c \
87 src/mi/dyn-info-list.c \
88 src/mi/dyn-register.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -080089 src/mi/map.c \
90 src/mi/Lmap.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -070091 src/mi/Ldyn-extract.c \
92 src/mi/Lfind_dynamic_proc_info.c \
93 src/mi/Lget_proc_info_by_ip.c \
94 src/mi/Lget_proc_name.c \
95 src/mi/Lput_dynamic_unwind_info.c \
96 src/mi/Ldestroy_addr_space.c \
97 src/mi/Lget_reg.c \
98 src/mi/Lset_reg.c \
99 src/mi/Lget_fpreg.c \
100 src/mi/Lset_fpreg.c \
101 src/mi/Lset_caching_policy.c \
102 src/mi/Gdyn-extract.c \
103 src/mi/Gdyn-remote.c \
104 src/mi/Gfind_dynamic_proc_info.c \
105 src/mi/Gget_accessors.c \
106 src/mi/Gget_proc_info_by_ip.c \
107 src/mi/Gget_proc_name.c \
108 src/mi/Gput_dynamic_unwind_info.c \
109 src/mi/Gdestroy_addr_space.c \
110 src/mi/Gget_reg.c \
111 src/mi/Gset_reg.c \
112 src/mi/Gget_fpreg.c \
113 src/mi/Gset_fpreg.c \
114 src/mi/Gset_caching_policy.c \
115 src/dwarf/Lexpr.c \
116 src/dwarf/Lfde.c \
117 src/dwarf/Lparser.c \
118 src/dwarf/Lpe.c \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700119 src/dwarf/Lstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700120 src/dwarf/Lfind_proc_info-lsb.c \
121 src/dwarf/Lfind_unwind_table.c \
122 src/dwarf/Gexpr.c \
123 src/dwarf/Gfde.c \
124 src/dwarf/Gfind_proc_info-lsb.c \
125 src/dwarf/Gfind_unwind_table.c \
126 src/dwarf/Gparser.c \
127 src/dwarf/Gpe.c \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700128 src/dwarf/Gstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700129 src/dwarf/global.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800130 src/os-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700131 src/os-linux.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800132 src/Los-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700133
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800134# Arch specific source files.
Duane Sand5cd02e12014-06-05 23:38:56 -0700135$(foreach arch,$(generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800136 $(eval libunwind_src_files_$(arch) += \
137 src/$(arch)/is_fpreg.c \
138 src/$(arch)/regname.c \
139 src/$(arch)/Gcreate_addr_space.c \
140 src/$(arch)/Gget_proc_info.c \
141 src/$(arch)/Gget_save_loc.c \
142 src/$(arch)/Gglobal.c \
143 src/$(arch)/Ginit.c \
144 src/$(arch)/Ginit_local.c \
145 src/$(arch)/Ginit_remote.c \
146 src/$(arch)/Gregs.c \
147 src/$(arch)/Gresume.c \
148 src/$(arch)/Gstep.c \
149 src/$(arch)/Lcreate_addr_space.c \
150 src/$(arch)/Lget_proc_info.c \
151 src/$(arch)/Lget_save_loc.c \
152 src/$(arch)/Lglobal.c \
153 src/$(arch)/Linit.c \
154 src/$(arch)/Linit_local.c \
155 src/$(arch)/Linit_remote.c \
156 src/$(arch)/Lregs.c \
157 src/$(arch)/Lresume.c \
158 src/$(arch)/Lstep.c \
Colin Cross26183d22014-01-24 15:59:56 -0800159 ))
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800160
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800161libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700162 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700163 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700164 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700165 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700166 src/arm/Lex_tables.c \
167
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800168libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800169 src/aarch64/Gis_signal_frame.c \
170 src/aarch64/Lis_signal_frame.c \
171
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800172libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700173 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700174 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700175 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700176
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800177libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700178 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700179 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700180 src/x86/Los-linux.c \
181
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800182libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400183 src/x86_64/getcontext.S \
184 src/x86_64/Gstash_frame.c \
185 src/x86_64/Gtrace.c \
186 src/x86_64/Gos-linux.c \
187 src/x86_64/Lstash_frame.c \
188 src/x86_64/Ltrace.c \
189 src/x86_64/Los-linux.c \
190 src/x86_64/setcontext.S \
191
Christopher Ferris2319e0f2014-04-29 10:23:55 -0700192libunwind_src_files += \
Ian Rogers97cfce22014-05-27 11:40:00 -0700193 src/unwind/BacktraceWrapper.c \
Christopher Ferris2319e0f2014-04-29 10:23:55 -0700194 src/unwind/DeleteException.c \
195 src/unwind/FindEnclosingFunction.c \
196 src/unwind/ForcedUnwind.c \
197 src/unwind/GetBSP.c \
198 src/unwind/GetCFA.c \
199 src/unwind/GetDataRelBase.c \
200 src/unwind/GetGR.c \
201 src/unwind/GetIP.c \
202 src/unwind/GetIPInfo.c \
203 src/unwind/GetLanguageSpecificData.c \
204 src/unwind/GetRegionStart.c \
205 src/unwind/GetTextRelBase.c \
206 src/unwind/RaiseException.c \
207 src/unwind/Resume.c \
208 src/unwind/Resume_or_Rethrow.c \
209 src/unwind/SetGR.c \
210 src/unwind/SetIP.c \
211
Duane Sand5cd02e12014-06-05 23:38:56 -0700212# mips and mips64 use the same sources but define _MIP_SIM differently
213# to change the behavior.
214# mips uses o32 abi (_MIPS_SIM == _ABIO32).
215# mips64 uses n64 abi (_MIPS_SIM == _ABI64).
216common_c_includes_mips64 := $(LOCAL_PATH)/include/tdep-mips
217libunwind_src_files_mips64 := $(libunwind_src_files_mips)
218
219# 64-bit architectures
220libunwind_src_files_arm64 += src/elf64.c
221libunwind_src_files_mips64 += src/elf64.c
222libunwind_src_files_x86_64 += src/elf64.c
223
224# 32-bit architectures
225libunwind_src_files_arm += src/elf32.c
226libunwind_src_files_mips += src/elf32.c
227libunwind_src_files_x86 += src/elf32.c
228
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800229libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700230 libdl \
231
Dan Albert162c8cb2014-05-09 10:19:20 -0700232libunwind_ldflags_host := \
233 -nostdlib
234
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800235libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700236 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800237 -lpthread \
238
Christopher Ferris76dbee52014-02-12 21:12:09 -0800239ifeq ($(debug),true)
240libunwind_shared_libraries += \
241 liblog \
242
243endif
244
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800245module := libunwind
246module_tag := optional
247build_type := target
248build_target := SHARED_LIBRARY
249include $(LOCAL_PATH)/Android.build.mk
250build_type := host
Ian Rogersaf7a2972014-06-05 10:35:29 -0700251libunwind_multilib := both
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800252include $(LOCAL_PATH)/Android.build.mk
Ian Rogersaf7a2972014-06-05 10:35:29 -0700253libunwind_multilib :=
Christopher Ferris836d9152013-12-02 12:27:30 -0800254
Dan Albert76728fb2014-05-09 13:51:35 -0700255build_type := target
256build_target := STATIC_LIBRARY
257include $(LOCAL_PATH)/Android.build.mk
258build_type := host
Ian Rogersaf7a2972014-06-05 10:35:29 -0700259libunwind_multilib := both
Dan Albert76728fb2014-05-09 13:51:35 -0700260include $(LOCAL_PATH)/Android.build.mk
Ian Rogersaf7a2972014-06-05 10:35:29 -0700261libunwind_multilib :=
Dan Albert76728fb2014-05-09 13:51:35 -0700262
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800263#-----------------------------------------------------------------------
264# libunwind-ptrace shared library
265#-----------------------------------------------------------------------
266libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700267 src/ptrace/_UPT_elf.c \
268 src/ptrace/_UPT_accessors.c \
269 src/ptrace/_UPT_access_fpreg.c \
270 src/ptrace/_UPT_access_mem.c \
271 src/ptrace/_UPT_access_reg.c \
272 src/ptrace/_UPT_create.c \
273 src/ptrace/_UPT_destroy.c \
274 src/ptrace/_UPT_find_proc_info.c \
275 src/ptrace/_UPT_get_dyn_info_list_addr.c \
276 src/ptrace/_UPT_put_unwind_info.c \
277 src/ptrace/_UPT_get_proc_name.c \
278 src/ptrace/_UPT_reg_offset.c \
279 src/ptrace/_UPT_resume.c \
280
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800281libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700282 libunwind \
283
Dan Albert162c8cb2014-05-09 10:19:20 -0700284libunwind-ptrace_ldflags_host := \
285 -nostdlib
286
287libunwind-ptrace_ldlibs_host := \
288 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800289 -lpthread \
290
Christopher Ferris76dbee52014-02-12 21:12:09 -0800291ifeq ($(debug),true)
292libunwind-ptrace_shared_libraries += \
293 liblog \
294
295endif
296
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800297module := libunwind-ptrace
298module_tag := optional
299build_type := target
300build_target := SHARED_LIBRARY
301include $(LOCAL_PATH)/Android.build.mk
302build_type := host
303include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700304
305#-----------------------------------------------------------------------
306# libunwind testing
307#-----------------------------------------------------------------------
308libunwind-unit-tests_cflags := \
309 -fno-builtin \
310 -O0 \
311 -g \
312
313libunwind-unit-tests_c_includes := \
314 $(LOCAL_PATH)/include \
315
316libunwind-unit-tests_src_files := \
317 android/tests/local_test.cpp \
318
319libunwind-unit-tests_shared_libraries := \
320 libunwind \
321
322libunwind-unit-tests_multilib := both
323module := libunwind-unit-tests
324module_tag := optional
325build_type := target
326build_target := NATIVE_TEST
327include $(LOCAL_PATH)/Android.build.mk
328build_type := host
Ying Wangeb25b732014-05-20 15:51:06 -0700329libunwind-unit-tests_multilib :=
Christopher Ferris7c042422014-04-25 13:21:40 -0700330include $(LOCAL_PATH)/Android.build.mk
331
332# Run the unit tests built for x86 or x86_64.
333ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
334ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
335LINKER = linker64
336TEST_SUFFIX = 64
337else
338LINKER = linker
339TEST_SUFFIX = 32
340endif
341
342libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
343 if [ ! -d /system -o ! -d /system/bin ]; then \
344 echo "Attempting to create /system/bin"; \
345 sudo mkdir -p -m 0777 /system/bin; \
346 fi
347 mkdir -p $(TARGET_OUT_DATA)/local/tmp
348 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
349 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
350 ANDROID_DATA=$(TARGET_OUT_DATA) \
351 ANDROID_ROOT=$(TARGET_OUT) \
352 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
353 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
354endif