blob: 05525ae5c4fae244554a65897c83281c5eaa37fa [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
Pavel Chupinf1f90e72013-12-04 13:29:29 +040067libunwind_arches := arm arm64 mips x86 x86_64
Christopher Ferris1c82a522013-10-01 12:38:42 -070068
Colin Cross26183d22014-01-24 15:59:56 -080069$(foreach arch,$(libunwind_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.
Colin Cross26183d22014-01-24 15:59:56 -0800130$(foreach arch,$(libunwind_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 -0800156# 64-bit architectures
157libunwind_src_files_arm64 += src/elf64.c
158libunwind_src_files_x86_64 += src/elf64.c
159
160# 32-bit architectures
161libunwind_src_files_arm += src/elf32.c
162libunwind_src_files_mips += src/elf32.c
163libunwind_src_files_x86 += src/elf32.c
164
165libunwind_src_files_arm += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700166 src/arm/getcontext.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700167 src/arm/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700168 src/arm/Gex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700169 src/arm/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700170 src/arm/Lex_tables.c \
171
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800172libunwind_src_files_arm64 += \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800173 src/aarch64/Gis_signal_frame.c \
174 src/aarch64/Lis_signal_frame.c \
175
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800176libunwind_src_files_mips += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700177 src/mips/getcontext-android.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700178 src/mips/Gis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700179 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700180
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800181libunwind_src_files_x86 += \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700182 src/x86/getcontext-linux.S \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700183 src/x86/Gos-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700184 src/x86/Los-linux.c \
185
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800186libunwind_src_files_x86_64 += \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400187 src/x86_64/getcontext.S \
188 src/x86_64/Gstash_frame.c \
189 src/x86_64/Gtrace.c \
190 src/x86_64/Gos-linux.c \
191 src/x86_64/Lstash_frame.c \
192 src/x86_64/Ltrace.c \
193 src/x86_64/Los-linux.c \
194 src/x86_64/setcontext.S \
195
Christopher Ferris2319e0f2014-04-29 10:23:55 -0700196libunwind_src_files += \
Ian Rogers97cfce22014-05-27 11:40:00 -0700197 src/unwind/BacktraceWrapper.c \
Christopher Ferris2319e0f2014-04-29 10:23:55 -0700198 src/unwind/DeleteException.c \
199 src/unwind/FindEnclosingFunction.c \
200 src/unwind/ForcedUnwind.c \
201 src/unwind/GetBSP.c \
202 src/unwind/GetCFA.c \
203 src/unwind/GetDataRelBase.c \
204 src/unwind/GetGR.c \
205 src/unwind/GetIP.c \
206 src/unwind/GetIPInfo.c \
207 src/unwind/GetLanguageSpecificData.c \
208 src/unwind/GetRegionStart.c \
209 src/unwind/GetTextRelBase.c \
210 src/unwind/RaiseException.c \
211 src/unwind/Resume.c \
212 src/unwind/Resume_or_Rethrow.c \
213 src/unwind/SetGR.c \
214 src/unwind/SetIP.c \
215
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800216libunwind_shared_libraries_target := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700217 libdl \
218
Dan Albert162c8cb2014-05-09 10:19:20 -0700219libunwind_ldflags_host := \
220 -nostdlib
221
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800222libunwind_ldlibs_host := \
Dan Albert162c8cb2014-05-09 10:19:20 -0700223 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800224 -lpthread \
225
Christopher Ferris76dbee52014-02-12 21:12:09 -0800226ifeq ($(debug),true)
227libunwind_shared_libraries += \
228 liblog \
229
230endif
231
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800232module := libunwind
233module_tag := optional
234build_type := target
235build_target := SHARED_LIBRARY
236include $(LOCAL_PATH)/Android.build.mk
237build_type := host
Ian Rogersaf7a2972014-06-05 10:35:29 -0700238libunwind_multilib := both
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800239include $(LOCAL_PATH)/Android.build.mk
Ian Rogersaf7a2972014-06-05 10:35:29 -0700240libunwind_multilib :=
Christopher Ferris836d9152013-12-02 12:27:30 -0800241
Dan Albert76728fb2014-05-09 13:51:35 -0700242build_type := target
243build_target := STATIC_LIBRARY
244include $(LOCAL_PATH)/Android.build.mk
245build_type := host
Ian Rogersaf7a2972014-06-05 10:35:29 -0700246libunwind_multilib := both
Dan Albert76728fb2014-05-09 13:51:35 -0700247include $(LOCAL_PATH)/Android.build.mk
Ian Rogersaf7a2972014-06-05 10:35:29 -0700248libunwind_multilib :=
Dan Albert76728fb2014-05-09 13:51:35 -0700249
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800250#-----------------------------------------------------------------------
251# libunwind-ptrace shared library
252#-----------------------------------------------------------------------
253libunwind-ptrace_src_files := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700254 src/ptrace/_UPT_elf.c \
255 src/ptrace/_UPT_accessors.c \
256 src/ptrace/_UPT_access_fpreg.c \
257 src/ptrace/_UPT_access_mem.c \
258 src/ptrace/_UPT_access_reg.c \
259 src/ptrace/_UPT_create.c \
260 src/ptrace/_UPT_destroy.c \
261 src/ptrace/_UPT_find_proc_info.c \
262 src/ptrace/_UPT_get_dyn_info_list_addr.c \
263 src/ptrace/_UPT_put_unwind_info.c \
264 src/ptrace/_UPT_get_proc_name.c \
265 src/ptrace/_UPT_reg_offset.c \
266 src/ptrace/_UPT_resume.c \
267
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800268libunwind-ptrace_shared_libraries := \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700269 libunwind \
270
Dan Albert162c8cb2014-05-09 10:19:20 -0700271libunwind-ptrace_ldflags_host := \
272 -nostdlib
273
274libunwind-ptrace_ldlibs_host := \
275 -lc \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800276 -lpthread \
277
Christopher Ferris76dbee52014-02-12 21:12:09 -0800278ifeq ($(debug),true)
279libunwind-ptrace_shared_libraries += \
280 liblog \
281
282endif
283
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800284module := libunwind-ptrace
285module_tag := optional
286build_type := target
287build_target := SHARED_LIBRARY
288include $(LOCAL_PATH)/Android.build.mk
289build_type := host
290include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris7c042422014-04-25 13:21:40 -0700291
292#-----------------------------------------------------------------------
293# libunwind testing
294#-----------------------------------------------------------------------
295libunwind-unit-tests_cflags := \
296 -fno-builtin \
297 -O0 \
298 -g \
299
300libunwind-unit-tests_c_includes := \
301 $(LOCAL_PATH)/include \
302
303libunwind-unit-tests_src_files := \
304 android/tests/local_test.cpp \
305
306libunwind-unit-tests_shared_libraries := \
307 libunwind \
308
309libunwind-unit-tests_multilib := both
310module := libunwind-unit-tests
311module_tag := optional
312build_type := target
313build_target := NATIVE_TEST
314include $(LOCAL_PATH)/Android.build.mk
315build_type := host
Ying Wangeb25b732014-05-20 15:51:06 -0700316libunwind-unit-tests_multilib :=
Christopher Ferris7c042422014-04-25 13:21:40 -0700317include $(LOCAL_PATH)/Android.build.mk
318
319# Run the unit tests built for x86 or x86_64.
320ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
321ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
322LINKER = linker64
323TEST_SUFFIX = 64
324else
325LINKER = linker
326TEST_SUFFIX = 32
327endif
328
329libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
330 if [ ! -d /system -o ! -d /system/bin ]; then \
331 echo "Attempting to create /system/bin"; \
332 sudo mkdir -p -m 0777 /system/bin; \
333 fi
334 mkdir -p $(TARGET_OUT_DATA)/local/tmp
335 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
336 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
337 ANDROID_DATA=$(TARGET_OUT_DATA) \
338 ANDROID_ROOT=$(TARGET_OUT) \
339 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
340 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
341endif