blob: 18415a8dc2cbeac54e9161b0dee7ec0e99a803e9 [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 Ferris4a590092015-03-07 11:32:24 -080029common_cppflags := \
30 -Wno-old-style-cast \
31
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 +020043# src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
Chih-Hung Hsiehf760bf52014-10-03 09:33:43 -070044# src/x86_64/Gstash_frame.c has unnecessary calls to labs.
45common_clang_cflags += \
46 -Wno-header-guard \
47 -Wno-absolute-value \
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020048
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070049ifneq ($(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
Duane Sand5cd02e12014-06-05 23:38:56 -070068# Since mips and mips64 use the same source, only generate includes/srcs
69# for the below set of arches.
70generate_arches := arm arm64 mips x86 x86_64
71# The complete list of arches used by Android.build.mk to set arch
72# variables.
73libunwind_arches := $(generate_arches) mips64
Christopher Ferris1c82a522013-10-01 12:38:42 -070074
Duane Sand5cd02e12014-06-05 23:38:56 -070075$(foreach arch,$(generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080076 $(eval common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
Christopher Ferris1c82a522013-10-01 12:38:42 -070077
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080078#-----------------------------------------------------------------------
79# libunwind shared library
80#-----------------------------------------------------------------------
81libunwind_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -070082 src/mi/init.c \
83 src/mi/flush_cache.c \
84 src/mi/mempool.c \
85 src/mi/strerror.c \
86 src/mi/backtrace.c \
87 src/mi/dyn-cancel.c \
88 src/mi/dyn-info-list.c \
89 src/mi/dyn-register.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -080090 src/mi/map.c \
91 src/mi/Lmap.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -070092 src/mi/Ldyn-extract.c \
93 src/mi/Lfind_dynamic_proc_info.c \
94 src/mi/Lget_proc_info_by_ip.c \
95 src/mi/Lget_proc_name.c \
96 src/mi/Lput_dynamic_unwind_info.c \
97 src/mi/Ldestroy_addr_space.c \
98 src/mi/Lget_reg.c \
99 src/mi/Lset_reg.c \
100 src/mi/Lget_fpreg.c \
101 src/mi/Lset_fpreg.c \
102 src/mi/Lset_caching_policy.c \
103 src/mi/Gdyn-extract.c \
104 src/mi/Gdyn-remote.c \
105 src/mi/Gfind_dynamic_proc_info.c \
106 src/mi/Gget_accessors.c \
107 src/mi/Gget_proc_info_by_ip.c \
108 src/mi/Gget_proc_name.c \
109 src/mi/Gput_dynamic_unwind_info.c \
110 src/mi/Gdestroy_addr_space.c \
111 src/mi/Gget_reg.c \
112 src/mi/Gset_reg.c \
113 src/mi/Gget_fpreg.c \
114 src/mi/Gset_fpreg.c \
115 src/mi/Gset_caching_policy.c \
116 src/dwarf/Lexpr.c \
117 src/dwarf/Lfde.c \
118 src/dwarf/Lparser.c \
119 src/dwarf/Lpe.c \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700120 src/dwarf/Lstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700121 src/dwarf/Lfind_proc_info-lsb.c \
122 src/dwarf/Lfind_unwind_table.c \
123 src/dwarf/Gexpr.c \
124 src/dwarf/Gfde.c \
125 src/dwarf/Gfind_proc_info-lsb.c \
126 src/dwarf/Gfind_unwind_table.c \
127 src/dwarf/Gparser.c \
128 src/dwarf/Gpe.c \
Dan Albert7cb7cbc2014-05-22 17:53:39 -0700129 src/dwarf/Gstep_dwarf.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700130 src/dwarf/global.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800131 src/os-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700132 src/os-linux.c \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800133 src/Los-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700134
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800135# Arch specific source files.
Duane Sand5cd02e12014-06-05 23:38:56 -0700136$(foreach arch,$(generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800137 $(eval libunwind_src_files_$(arch) += \
138 src/$(arch)/is_fpreg.c \
139 src/$(arch)/regname.c \
140 src/$(arch)/Gcreate_addr_space.c \
141 src/$(arch)/Gget_proc_info.c \
142 src/$(arch)/Gget_save_loc.c \
143 src/$(arch)/Gglobal.c \
144 src/$(arch)/Ginit.c \
145 src/$(arch)/Ginit_local.c \
146 src/$(arch)/Ginit_remote.c \
147 src/$(arch)/Gregs.c \
148 src/$(arch)/Gresume.c \
149 src/$(arch)/Gstep.c \
150 src/$(arch)/Lcreate_addr_space.c \
151 src/$(arch)/Lget_proc_info.c \
152 src/$(arch)/Lget_save_loc.c \
153 src/$(arch)/Lglobal.c \
154 src/$(arch)/Linit.c \
155 src/$(arch)/Linit_local.c \
156 src/$(arch)/Linit_remote.c \
157 src/$(arch)/Lregs.c \
158 src/$(arch)/Lresume.c \
159 src/$(arch)/Lstep.c \
Colin Cross26183d22014-01-24 15:59:56 -0800160 ))
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800161
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800162libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700163 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700164 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700165 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700166 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700167 src/arm/Lex_tables.c \
168
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800169libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800170 src/aarch64/Gis_signal_frame.c \
171 src/aarch64/Lis_signal_frame.c \
172
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800173libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700174 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700175 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700176 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700177
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800178libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700179 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700180 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700181 src/x86/Los-linux.c \
182
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800183libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400184 src/x86_64/getcontext.S \
185 src/x86_64/Gstash_frame.c \
186 src/x86_64/Gtrace.c \
187 src/x86_64/Gos-linux.c \
188 src/x86_64/Lstash_frame.c \
189 src/x86_64/Ltrace.c \
190 src/x86_64/Los-linux.c \
191 src/x86_64/setcontext.S \
192
Duane Sand5cd02e12014-06-05 23:38:56 -0700193# mips and mips64 use the same sources but define _MIP_SIM differently
194# to change the behavior.
195# mips uses o32 abi (_MIPS_SIM == _ABIO32).
196# mips64 uses n64 abi (_MIPS_SIM == _ABI64).
197common_c_includes_mips64 := $(LOCAL_PATH)/include/tdep-mips
198libunwind_src_files_mips64 := $(libunwind_src_files_mips)
199
200# 64-bit architectures
201libunwind_src_files_arm64 += src/elf64.c
202libunwind_src_files_mips64 += src/elf64.c
203libunwind_src_files_x86_64 += src/elf64.c
204
205# 32-bit architectures
206libunwind_src_files_arm += src/elf32.c
207libunwind_src_files_mips += src/elf32.c
208libunwind_src_files_x86 += src/elf32.c
209
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800210libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700211 libdl \
212
Dan Albert162c8cb2014-05-09 10:19:20 -0700213libunwind_ldflags_host := \
214 -nostdlib
215
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800216libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700217 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800218 -lpthread \
219
Trevor Drake9fcad642014-12-07 12:35:09 +0000220libunwind_export_c_include_dirs := \
221 $(LOCAL_PATH)/include
222
Christopher Ferris76dbee52014-02-12 21:12:09 -0800223ifeq ($(debug),true)
224libunwind_shared_libraries += \
225 liblog \
226
227endif
228
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800229module := libunwind
230module_tag := optional
231build_type := target
232build_target := SHARED_LIBRARY
233include $(LOCAL_PATH)/Android.build.mk
234build_type := host
235include $(LOCAL_PATH)/Android.build.mk
Dan Albert76728fb2014-05-09 13:51:35 -0700236build_type := target
237build_target := STATIC_LIBRARY
238include $(LOCAL_PATH)/Android.build.mk
239build_type := host
240include $(LOCAL_PATH)/Android.build.mk
241
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800242#-----------------------------------------------------------------------
243# libunwind-ptrace shared library
244#-----------------------------------------------------------------------
245libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700246 src/ptrace/_UPT_elf.c \
247 src/ptrace/_UPT_accessors.c \
248 src/ptrace/_UPT_access_fpreg.c \
249 src/ptrace/_UPT_access_mem.c \
250 src/ptrace/_UPT_access_reg.c \
251 src/ptrace/_UPT_create.c \
252 src/ptrace/_UPT_destroy.c \
253 src/ptrace/_UPT_find_proc_info.c \
254 src/ptrace/_UPT_get_dyn_info_list_addr.c \
255 src/ptrace/_UPT_put_unwind_info.c \
256 src/ptrace/_UPT_get_proc_name.c \
257 src/ptrace/_UPT_reg_offset.c \
258 src/ptrace/_UPT_resume.c \
259
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800260libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700261 libunwind \
262
Dan Albert162c8cb2014-05-09 10:19:20 -0700263libunwind-ptrace_ldflags_host := \
264 -nostdlib
265
266libunwind-ptrace_ldlibs_host := \
267 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800268 -lpthread \
269
Trevor Drake9fcad642014-12-07 12:35:09 +0000270libunwind-ptrace_export_c_include_dirs := \
271 $(LOCAL_PATH)/include
272
Christopher Ferris76dbee52014-02-12 21:12:09 -0800273ifeq ($(debug),true)
274libunwind-ptrace_shared_libraries += \
275 liblog \
276
277endif
278
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800279module := libunwind-ptrace
280module_tag := optional
281build_type := target
282build_target := SHARED_LIBRARY
283include $(LOCAL_PATH)/Android.build.mk
284build_type := host
285include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700286
287#-----------------------------------------------------------------------
Christopher Ferrisaa946482014-06-19 11:04:34 -0700288# libunwindbacktrace static library
289#-----------------------------------------------------------------------
290libunwindbacktrace_src_files += \
291 src/unwind/BacktraceWrapper.c \
292 src/unwind/DeleteException.c \
293 src/unwind/FindEnclosingFunction.c \
294 src/unwind/ForcedUnwind.c \
295 src/unwind/GetBSP.c \
296 src/unwind/GetCFA.c \
297 src/unwind/GetDataRelBase.c \
298 src/unwind/GetGR.c \
299 src/unwind/GetIP.c \
300 src/unwind/GetIPInfo.c \
301 src/unwind/GetLanguageSpecificData.c \
302 src/unwind/GetRegionStart.c \
303 src/unwind/GetTextRelBase.c \
304 src/unwind/RaiseException.c \
305 src/unwind/Resume.c \
306 src/unwind/Resume_or_Rethrow.c \
307 src/unwind/SetGR.c \
308 src/unwind/SetIP.c \
309
310libunwindbacktrace_cflags += \
311 -Wno-old-style-declaration \
312 -fvisibility=hidden \
313
314module := libunwindbacktrace
315module_tag := optional
316build_type := target
317build_target := STATIC_LIBRARY
318libunwindbacktrace_whole_static_libraries := libunwind
319include $(LOCAL_PATH)/Android.build.mk
320build_type := host
321include $(LOCAL_PATH)/Android.build.mk
322
323#-----------------------------------------------------------------------
Christopher Ferris7c042422014-04-25 13:21:40 -0700324# libunwind testing
325#-----------------------------------------------------------------------
326libunwind-unit-tests_cflags := \
327 -fno-builtin \
328 -O0 \
329 -g \
330
331libunwind-unit-tests_c_includes := \
332 $(LOCAL_PATH)/include \
333
334libunwind-unit-tests_src_files := \
335 android/tests/local_test.cpp \
336
337libunwind-unit-tests_shared_libraries := \
338 libunwind \
339
340libunwind-unit-tests_multilib := both
341module := libunwind-unit-tests
342module_tag := optional
343build_type := target
344build_target := NATIVE_TEST
345include $(LOCAL_PATH)/Android.build.mk
346build_type := host
347include $(LOCAL_PATH)/Android.build.mk
348
349# Run the unit tests built for x86 or x86_64.
350ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
351ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
352LINKER = linker64
353TEST_SUFFIX = 64
354else
355LINKER = linker
356TEST_SUFFIX = 32
357endif
358
359libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
360 if [ ! -d /system -o ! -d /system/bin ]; then \
361 echo "Attempting to create /system/bin"; \
362 sudo mkdir -p -m 0777 /system/bin; \
363 fi
364 mkdir -p $(TARGET_OUT_DATA)/local/tmp
365 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
366 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
367 ANDROID_DATA=$(TARGET_OUT_DATA) \
368 ANDROID_ROOT=$(TARGET_OUT) \
369 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
370 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
371endif