blob: c3b63a4628e1479bb6d778b251a6f9ad52906e1b [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
Bernhard Rosenkraenzer999f9632014-09-18 19:04:26 +020041common_clang_cflags += -Wno-header-guard
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020042
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070043ifneq ($(debug),true)
44common_cflags += \
Christopher Ferris1c82a522013-10-01 12:38:42 -070045 -DHAVE_CONFIG_H \
46 -DNDEBUG \
47 -D_GNU_SOURCE \
Christopher Ferris9fc75e82014-01-26 21:39:06 -080048
Christopher Ferris76dbee52014-02-12 21:12:09 -080049else
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070050common_cflags += \
Christopher Ferris76dbee52014-02-12 21:12:09 -080051 -DHAVE_CONFIG_H \
52 -DDEBUG \
53 -D_GNU_SOURCE \
54 -U_FORTIFY_SOURCE \
55
56endif
Pavel Chupinf1f90e72013-12-04 13:29:29 +040057
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080058common_c_includes := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070059 $(LOCAL_PATH)/src \
60 $(LOCAL_PATH)/include \
Colin Cross26183d22014-01-24 15:59:56 -080061
Duane Sand5cd02e12014-06-05 23:38:56 -070062# Since mips and mips64 use the same source, only generate includes/srcs
63# for the below set of arches.
64generate_arches := arm arm64 mips x86 x86_64
65# The complete list of arches used by Android.build.mk to set arch
66# variables.
67libunwind_arches := $(generate_arches) mips64
Christopher Ferris1c82a522013-10-01 12:38:42 -070068
Duane Sand5cd02e12014-06-05 23:38:56 -070069$(foreach arch,$(generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080070 $(eval common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
Christopher Ferris1c82a522013-10-01 12:38:42 -070071
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080072#-----------------------------------------------------------------------
73# libunwind shared library
74#-----------------------------------------------------------------------
75libunwind_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070076 src/mi/init.c \
77 src/mi/flush_cache.c \
78 src/mi/mempool.c \
79 src/mi/strerror.c \
80 src/mi/backtrace.c \
81 src/mi/dyn-cancel.c \
82 src/mi/dyn-info-list.c \
83 src/mi/dyn-register.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -080084 src/mi/map.c \
85 src/mi/Lmap.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -070086 src/mi/Ldyn-extract.c \
87 src/mi/Lfind_dynamic_proc_info.c \
88 src/mi/Lget_proc_info_by_ip.c \
89 src/mi/Lget_proc_name.c \
90 src/mi/Lput_dynamic_unwind_info.c \
91 src/mi/Ldestroy_addr_space.c \
92 src/mi/Lget_reg.c \
93 src/mi/Lset_reg.c \
94 src/mi/Lget_fpreg.c \
95 src/mi/Lset_fpreg.c \
96 src/mi/Lset_caching_policy.c \
97 src/mi/Gdyn-extract.c \
98 src/mi/Gdyn-remote.c \
99 src/mi/Gfind_dynamic_proc_info.c \
100 src/mi/Gget_accessors.c \
101 src/mi/Gget_proc_info_by_ip.c \
102 src/mi/Gget_proc_name.c \
103 src/mi/Gput_dynamic_unwind_info.c \
104 src/mi/Gdestroy_addr_space.c \
105 src/mi/Gget_reg.c \
106 src/mi/Gset_reg.c \
107 src/mi/Gget_fpreg.c \
108 src/mi/Gset_fpreg.c \
109 src/mi/Gset_caching_policy.c \
110 src/dwarf/Lexpr.c \
111 src/dwarf/Lfde.c \
112 src/dwarf/Lparser.c \
113 src/dwarf/Lpe.c \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700114 src/dwarf/Lstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700115 src/dwarf/Lfind_proc_info-lsb.c \
116 src/dwarf/Lfind_unwind_table.c \
117 src/dwarf/Gexpr.c \
118 src/dwarf/Gfde.c \
119 src/dwarf/Gfind_proc_info-lsb.c \
120 src/dwarf/Gfind_unwind_table.c \
121 src/dwarf/Gparser.c \
122 src/dwarf/Gpe.c \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700123 src/dwarf/Gstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700124 src/dwarf/global.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800125 src/os-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700126 src/os-linux.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800127 src/Los-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700128
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800129# Arch specific source files.
Duane Sand5cd02e12014-06-05 23:38:56 -0700130$(foreach arch,$(generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800131 $(eval libunwind_src_files_$(arch) += \
132 src/$(arch)/is_fpreg.c \
133 src/$(arch)/regname.c \
134 src/$(arch)/Gcreate_addr_space.c \
135 src/$(arch)/Gget_proc_info.c \
136 src/$(arch)/Gget_save_loc.c \
137 src/$(arch)/Gglobal.c \
138 src/$(arch)/Ginit.c \
139 src/$(arch)/Ginit_local.c \
140 src/$(arch)/Ginit_remote.c \
141 src/$(arch)/Gregs.c \
142 src/$(arch)/Gresume.c \
143 src/$(arch)/Gstep.c \
144 src/$(arch)/Lcreate_addr_space.c \
145 src/$(arch)/Lget_proc_info.c \
146 src/$(arch)/Lget_save_loc.c \
147 src/$(arch)/Lglobal.c \
148 src/$(arch)/Linit.c \
149 src/$(arch)/Linit_local.c \
150 src/$(arch)/Linit_remote.c \
151 src/$(arch)/Lregs.c \
152 src/$(arch)/Lresume.c \
153 src/$(arch)/Lstep.c \
Colin Cross26183d22014-01-24 15:59:56 -0800154 ))
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800155
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800156libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700157 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700158 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700159 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700160 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700161 src/arm/Lex_tables.c \
162
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800163libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800164 src/aarch64/Gis_signal_frame.c \
165 src/aarch64/Lis_signal_frame.c \
166
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800167libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700168 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700169 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700170 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700171
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800172libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700173 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700174 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700175 src/x86/Los-linux.c \
176
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800177libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400178 src/x86_64/getcontext.S \
179 src/x86_64/Gstash_frame.c \
180 src/x86_64/Gtrace.c \
181 src/x86_64/Gos-linux.c \
182 src/x86_64/Lstash_frame.c \
183 src/x86_64/Ltrace.c \
184 src/x86_64/Los-linux.c \
185 src/x86_64/setcontext.S \
186
Duane Sand5cd02e12014-06-05 23:38:56 -0700187# mips and mips64 use the same sources but define _MIP_SIM differently
188# to change the behavior.
189# mips uses o32 abi (_MIPS_SIM == _ABIO32).
190# mips64 uses n64 abi (_MIPS_SIM == _ABI64).
191common_c_includes_mips64 := $(LOCAL_PATH)/include/tdep-mips
192libunwind_src_files_mips64 := $(libunwind_src_files_mips)
193
194# 64-bit architectures
195libunwind_src_files_arm64 += src/elf64.c
196libunwind_src_files_mips64 += src/elf64.c
197libunwind_src_files_x86_64 += src/elf64.c
198
199# 32-bit architectures
200libunwind_src_files_arm += src/elf32.c
201libunwind_src_files_mips += src/elf32.c
202libunwind_src_files_x86 += src/elf32.c
203
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800204libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700205 libdl \
206
Dan Albert162c8cb2014-05-09 10:19:20 -0700207libunwind_ldflags_host := \
208 -nostdlib
209
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800210libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700211 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800212 -lpthread \
213
Christopher Ferris76dbee52014-02-12 21:12:09 -0800214ifeq ($(debug),true)
215libunwind_shared_libraries += \
216 liblog \
217
218endif
219
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800220module := libunwind
221module_tag := optional
222build_type := target
223build_target := SHARED_LIBRARY
224include $(LOCAL_PATH)/Android.build.mk
225build_type := host
226include $(LOCAL_PATH)/Android.build.mk
Dan Albert76728fb2014-05-09 13:51:35 -0700227build_type := target
228build_target := STATIC_LIBRARY
229include $(LOCAL_PATH)/Android.build.mk
230build_type := host
231include $(LOCAL_PATH)/Android.build.mk
232
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800233#-----------------------------------------------------------------------
234# libunwind-ptrace shared library
235#-----------------------------------------------------------------------
236libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700237 src/ptrace/_UPT_elf.c \
238 src/ptrace/_UPT_accessors.c \
239 src/ptrace/_UPT_access_fpreg.c \
240 src/ptrace/_UPT_access_mem.c \
241 src/ptrace/_UPT_access_reg.c \
242 src/ptrace/_UPT_create.c \
243 src/ptrace/_UPT_destroy.c \
244 src/ptrace/_UPT_find_proc_info.c \
245 src/ptrace/_UPT_get_dyn_info_list_addr.c \
246 src/ptrace/_UPT_put_unwind_info.c \
247 src/ptrace/_UPT_get_proc_name.c \
248 src/ptrace/_UPT_reg_offset.c \
249 src/ptrace/_UPT_resume.c \
250
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800251libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700252 libunwind \
253
Dan Albert162c8cb2014-05-09 10:19:20 -0700254libunwind-ptrace_ldflags_host := \
255 -nostdlib
256
257libunwind-ptrace_ldlibs_host := \
258 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800259 -lpthread \
260
Christopher Ferris76dbee52014-02-12 21:12:09 -0800261ifeq ($(debug),true)
262libunwind-ptrace_shared_libraries += \
263 liblog \
264
265endif
266
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800267module := libunwind-ptrace
268module_tag := optional
269build_type := target
270build_target := SHARED_LIBRARY
271include $(LOCAL_PATH)/Android.build.mk
272build_type := host
273include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700274
275#-----------------------------------------------------------------------
Christopher Ferrisaa946482014-06-19 11:04:34 -0700276# libunwindbacktrace static library
277#-----------------------------------------------------------------------
278libunwindbacktrace_src_files += \
279 src/unwind/BacktraceWrapper.c \
280 src/unwind/DeleteException.c \
281 src/unwind/FindEnclosingFunction.c \
282 src/unwind/ForcedUnwind.c \
283 src/unwind/GetBSP.c \
284 src/unwind/GetCFA.c \
285 src/unwind/GetDataRelBase.c \
286 src/unwind/GetGR.c \
287 src/unwind/GetIP.c \
288 src/unwind/GetIPInfo.c \
289 src/unwind/GetLanguageSpecificData.c \
290 src/unwind/GetRegionStart.c \
291 src/unwind/GetTextRelBase.c \
292 src/unwind/RaiseException.c \
293 src/unwind/Resume.c \
294 src/unwind/Resume_or_Rethrow.c \
295 src/unwind/SetGR.c \
296 src/unwind/SetIP.c \
297
298libunwindbacktrace_cflags += \
299 -Wno-old-style-declaration \
300 -fvisibility=hidden \
301
302module := libunwindbacktrace
303module_tag := optional
304build_type := target
305build_target := STATIC_LIBRARY
306libunwindbacktrace_whole_static_libraries := libunwind
307include $(LOCAL_PATH)/Android.build.mk
308build_type := host
309include $(LOCAL_PATH)/Android.build.mk
310
311#-----------------------------------------------------------------------
Christopher Ferris7c042422014-04-25 13:21:40 -0700312# libunwind testing
313#-----------------------------------------------------------------------
314libunwind-unit-tests_cflags := \
315 -fno-builtin \
316 -O0 \
317 -g \
318
319libunwind-unit-tests_c_includes := \
320 $(LOCAL_PATH)/include \
321
322libunwind-unit-tests_src_files := \
323 android/tests/local_test.cpp \
324
325libunwind-unit-tests_shared_libraries := \
326 libunwind \
327
328libunwind-unit-tests_multilib := both
329module := libunwind-unit-tests
330module_tag := optional
331build_type := target
332build_target := NATIVE_TEST
333include $(LOCAL_PATH)/Android.build.mk
334build_type := host
335include $(LOCAL_PATH)/Android.build.mk
336
337# Run the unit tests built for x86 or x86_64.
338ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
339ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
340LINKER = linker64
341TEST_SUFFIX = 64
342else
343LINKER = linker
344TEST_SUFFIX = 32
345endif
346
347libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
348 if [ ! -d /system -o ! -d /system/bin ]; then \
349 echo "Attempting to create /system/bin"; \
350 sudo mkdir -p -m 0777 /system/bin; \
351 fi
352 mkdir -p $(TARGET_OUT_DATA)/local/tmp
353 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
354 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
355 ANDROID_DATA=$(TARGET_OUT_DATA) \
356 ANDROID_ROOT=$(TARGET_OUT) \
357 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
358 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
359endif