blob: 321d99b71ab2d9cd70b96c505ac90790db9a54ab [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 +020040# src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
Chih-Hung Hsiehf760bf52014-10-03 09:33:43 -070041# src/x86_64/Gstash_frame.c has unnecessary calls to labs.
42common_clang_cflags += \
43 -Wno-header-guard \
44 -Wno-absolute-value \
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020045
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070046ifneq ($(debug),true)
47common_cflags += \
Christopher Ferris1c82a522013-10-01 12:38:42 -070048 -DHAVE_CONFIG_H \
49 -DNDEBUG \
50 -D_GNU_SOURCE \
Christopher Ferris9fc75e82014-01-26 21:39:06 -080051
Christopher Ferris76dbee52014-02-12 21:12:09 -080052else
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070053common_cflags += \
Christopher Ferris76dbee52014-02-12 21:12:09 -080054 -DHAVE_CONFIG_H \
55 -DDEBUG \
56 -D_GNU_SOURCE \
57 -U_FORTIFY_SOURCE \
58
59endif
Pavel Chupinf1f90e72013-12-04 13:29:29 +040060
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080061common_c_includes := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070062 $(LOCAL_PATH)/src \
63 $(LOCAL_PATH)/include \
Colin Cross26183d22014-01-24 15:59:56 -080064
Duane Sand5cd02e12014-06-05 23:38:56 -070065# Since mips and mips64 use the same source, only generate includes/srcs
66# for the below set of arches.
67generate_arches := arm arm64 mips x86 x86_64
68# The complete list of arches used by Android.build.mk to set arch
69# variables.
70libunwind_arches := $(generate_arches) mips64
Christopher Ferris1c82a522013-10-01 12:38:42 -070071
Duane Sand5cd02e12014-06-05 23:38:56 -070072$(foreach arch,$(generate_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 \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700117 src/dwarf/Lstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700118 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 \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700126 src/dwarf/Gstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700127 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.
Duane Sand5cd02e12014-06-05 23:38:56 -0700133$(foreach arch,$(generate_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 -0800159libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700160 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700161 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700162 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700163 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700164 src/arm/Lex_tables.c \
165
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800166libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800167 src/aarch64/Gis_signal_frame.c \
168 src/aarch64/Lis_signal_frame.c \
169
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800170libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700171 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700172 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700173 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700174
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800175libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700176 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700177 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700178 src/x86/Los-linux.c \
179
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800180libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400181 src/x86_64/getcontext.S \
182 src/x86_64/Gstash_frame.c \
183 src/x86_64/Gtrace.c \
184 src/x86_64/Gos-linux.c \
185 src/x86_64/Lstash_frame.c \
186 src/x86_64/Ltrace.c \
187 src/x86_64/Los-linux.c \
188 src/x86_64/setcontext.S \
189
Duane Sand5cd02e12014-06-05 23:38:56 -0700190# mips and mips64 use the same sources but define _MIP_SIM differently
191# to change the behavior.
192# mips uses o32 abi (_MIPS_SIM == _ABIO32).
193# mips64 uses n64 abi (_MIPS_SIM == _ABI64).
194common_c_includes_mips64 := $(LOCAL_PATH)/include/tdep-mips
195libunwind_src_files_mips64 := $(libunwind_src_files_mips)
196
197# 64-bit architectures
198libunwind_src_files_arm64 += src/elf64.c
199libunwind_src_files_mips64 += src/elf64.c
200libunwind_src_files_x86_64 += src/elf64.c
201
202# 32-bit architectures
203libunwind_src_files_arm += src/elf32.c
204libunwind_src_files_mips += src/elf32.c
205libunwind_src_files_x86 += src/elf32.c
206
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800207libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700208 libdl \
209
Dan Albert162c8cb2014-05-09 10:19:20 -0700210libunwind_ldflags_host := \
211 -nostdlib
212
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800213libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700214 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800215 -lpthread \
216
Christopher Ferris76dbee52014-02-12 21:12:09 -0800217ifeq ($(debug),true)
218libunwind_shared_libraries += \
219 liblog \
220
221endif
222
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800223module := libunwind
224module_tag := optional
225build_type := target
226build_target := SHARED_LIBRARY
227include $(LOCAL_PATH)/Android.build.mk
228build_type := host
229include $(LOCAL_PATH)/Android.build.mk
Dan Albert76728fb2014-05-09 13:51:35 -0700230build_type := target
231build_target := STATIC_LIBRARY
232include $(LOCAL_PATH)/Android.build.mk
233build_type := host
234include $(LOCAL_PATH)/Android.build.mk
235
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800236#-----------------------------------------------------------------------
237# libunwind-ptrace shared library
238#-----------------------------------------------------------------------
239libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700240 src/ptrace/_UPT_elf.c \
241 src/ptrace/_UPT_accessors.c \
242 src/ptrace/_UPT_access_fpreg.c \
243 src/ptrace/_UPT_access_mem.c \
244 src/ptrace/_UPT_access_reg.c \
245 src/ptrace/_UPT_create.c \
246 src/ptrace/_UPT_destroy.c \
247 src/ptrace/_UPT_find_proc_info.c \
248 src/ptrace/_UPT_get_dyn_info_list_addr.c \
249 src/ptrace/_UPT_put_unwind_info.c \
250 src/ptrace/_UPT_get_proc_name.c \
251 src/ptrace/_UPT_reg_offset.c \
252 src/ptrace/_UPT_resume.c \
253
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800254libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700255 libunwind \
256
Dan Albert162c8cb2014-05-09 10:19:20 -0700257libunwind-ptrace_ldflags_host := \
258 -nostdlib
259
260libunwind-ptrace_ldlibs_host := \
261 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800262 -lpthread \
263
Christopher Ferris76dbee52014-02-12 21:12:09 -0800264ifeq ($(debug),true)
265libunwind-ptrace_shared_libraries += \
266 liblog \
267
268endif
269
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800270module := libunwind-ptrace
271module_tag := optional
272build_type := target
273build_target := SHARED_LIBRARY
274include $(LOCAL_PATH)/Android.build.mk
275build_type := host
276include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700277
278#-----------------------------------------------------------------------
Christopher Ferrisaa946482014-06-19 11:04:34 -0700279# libunwindbacktrace static library
280#-----------------------------------------------------------------------
281libunwindbacktrace_src_files += \
282 src/unwind/BacktraceWrapper.c \
283 src/unwind/DeleteException.c \
284 src/unwind/FindEnclosingFunction.c \
285 src/unwind/ForcedUnwind.c \
286 src/unwind/GetBSP.c \
287 src/unwind/GetCFA.c \
288 src/unwind/GetDataRelBase.c \
289 src/unwind/GetGR.c \
290 src/unwind/GetIP.c \
291 src/unwind/GetIPInfo.c \
292 src/unwind/GetLanguageSpecificData.c \
293 src/unwind/GetRegionStart.c \
294 src/unwind/GetTextRelBase.c \
295 src/unwind/RaiseException.c \
296 src/unwind/Resume.c \
297 src/unwind/Resume_or_Rethrow.c \
298 src/unwind/SetGR.c \
299 src/unwind/SetIP.c \
300
301libunwindbacktrace_cflags += \
302 -Wno-old-style-declaration \
303 -fvisibility=hidden \
304
305module := libunwindbacktrace
306module_tag := optional
307build_type := target
308build_target := STATIC_LIBRARY
309libunwindbacktrace_whole_static_libraries := libunwind
310include $(LOCAL_PATH)/Android.build.mk
311build_type := host
312include $(LOCAL_PATH)/Android.build.mk
313
314#-----------------------------------------------------------------------
Christopher Ferris7c042422014-04-25 13:21:40 -0700315# libunwind testing
316#-----------------------------------------------------------------------
317libunwind-unit-tests_cflags := \
318 -fno-builtin \
319 -O0 \
320 -g \
321
322libunwind-unit-tests_c_includes := \
323 $(LOCAL_PATH)/include \
324
325libunwind-unit-tests_src_files := \
326 android/tests/local_test.cpp \
327
328libunwind-unit-tests_shared_libraries := \
329 libunwind \
330
331libunwind-unit-tests_multilib := both
332module := libunwind-unit-tests
333module_tag := optional
334build_type := target
335build_target := NATIVE_TEST
336include $(LOCAL_PATH)/Android.build.mk
337build_type := host
338include $(LOCAL_PATH)/Android.build.mk
339
340# Run the unit tests built for x86 or x86_64.
341ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
342ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
343LINKER = linker64
344TEST_SUFFIX = 64
345else
346LINKER = linker
347TEST_SUFFIX = 32
348endif
349
350libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
351 if [ ! -d /system -o ! -d /system/bin ]; then \
352 echo "Attempting to create /system/bin"; \
353 sudo mkdir -p -m 0777 /system/bin; \
354 fi
355 mkdir -p $(TARGET_OUT_DATA)/local/tmp
356 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
357 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
358 ANDROID_DATA=$(TARGET_OUT_DATA) \
359 ANDROID_ROOT=$(TARGET_OUT) \
360 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
361 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
362endif