-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAndroid.mk
339 lines (295 loc) · 8.68 KB
/
Android.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#
# Copyright (C) 2014 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
build_host := false
ifeq ($(HOST_OS),linux)
ifeq ($(HOST_ARCH),$(filter $(HOST_ARCH),x86 x86_64))
build_host := true
my_host_arch := $(HOST_ARCH)
endif
endif
# Set to true to enable a debug build of the libraries.
# To control what is logged, set the environment variable UNW_DEBUG_LEVEL=x,
# where x controls the verbosity (from 1 to 20).
debug := false
common_conlyflags := \
-Wno-old-style-declaration \
common_cflags := \
-Wno-unused-parameter \
-Werror \
# gcc 4.8 appears to be overeager declaring that a variable is uninitialized,
# under certain circumstances. Turn off this warning only for target so that
# coverage is still present for the host code. When the entire build system
# is switched to 4.9, then this can be removed.
common_cflags_target := \
-Wno-maybe-uninitialized \
ifeq ($(LOCAL_CLANG),true)
# src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
common_cflags += -Wno-header-guard
endif
ifneq ($(debug),true)
common_cflags += \
-DHAVE_CONFIG_H \
-DNDEBUG \
-D_GNU_SOURCE \
else
common_cflags += \
-DHAVE_CONFIG_H \
-DDEBUG \
-D_GNU_SOURCE \
-U_FORTIFY_SOURCE \
endif
common_c_includes := \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/include \
libunwind_arches := arm arm64 mips x86 x86_64
$(foreach arch,$(libunwind_arches), \
$(eval common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
#-----------------------------------------------------------------------
# libunwind shared library
#-----------------------------------------------------------------------
libunwind_src_files := \
src/mi/init.c \
src/mi/flush_cache.c \
src/mi/mempool.c \
src/mi/strerror.c \
src/mi/backtrace.c \
src/mi/dyn-cancel.c \
src/mi/dyn-info-list.c \
src/mi/dyn-register.c \
src/mi/map.c \
src/mi/Lmap.c \
src/mi/Ldyn-extract.c \
src/mi/Lfind_dynamic_proc_info.c \
src/mi/Lget_proc_info_by_ip.c \
src/mi/Lget_proc_name.c \
src/mi/Lput_dynamic_unwind_info.c \
src/mi/Ldestroy_addr_space.c \
src/mi/Lget_reg.c \
src/mi/Lset_reg.c \
src/mi/Lget_fpreg.c \
src/mi/Lset_fpreg.c \
src/mi/Lset_caching_policy.c \
src/mi/Gdyn-extract.c \
src/mi/Gdyn-remote.c \
src/mi/Gfind_dynamic_proc_info.c \
src/mi/Gget_accessors.c \
src/mi/Gget_proc_info_by_ip.c \
src/mi/Gget_proc_name.c \
src/mi/Gput_dynamic_unwind_info.c \
src/mi/Gdestroy_addr_space.c \
src/mi/Gget_reg.c \
src/mi/Gset_reg.c \
src/mi/Gget_fpreg.c \
src/mi/Gset_fpreg.c \
src/mi/Gset_caching_policy.c \
src/dwarf/Lexpr.c \
src/dwarf/Lfde.c \
src/dwarf/Lparser.c \
src/dwarf/Lpe.c \
src/dwarf/Lstep.c \
src/dwarf/Lfind_proc_info-lsb.c \
src/dwarf/Lfind_unwind_table.c \
src/dwarf/Gexpr.c \
src/dwarf/Gfde.c \
src/dwarf/Gfind_proc_info-lsb.c \
src/dwarf/Gfind_unwind_table.c \
src/dwarf/Gparser.c \
src/dwarf/Gpe.c \
src/dwarf/Gstep.c \
src/dwarf/global.c \
src/os-common.c \
src/os-linux.c \
src/Los-common.c \
# Arch specific source files.
$(foreach arch,$(libunwind_arches), \
$(eval libunwind_src_files_$(arch) += \
src/$(arch)/is_fpreg.c \
src/$(arch)/regname.c \
src/$(arch)/Gcreate_addr_space.c \
src/$(arch)/Gget_proc_info.c \
src/$(arch)/Gget_save_loc.c \
src/$(arch)/Gglobal.c \
src/$(arch)/Ginit.c \
src/$(arch)/Ginit_local.c \
src/$(arch)/Ginit_remote.c \
src/$(arch)/Gregs.c \
src/$(arch)/Gresume.c \
src/$(arch)/Gstep.c \
src/$(arch)/Lcreate_addr_space.c \
src/$(arch)/Lget_proc_info.c \
src/$(arch)/Lget_save_loc.c \
src/$(arch)/Lglobal.c \
src/$(arch)/Linit.c \
src/$(arch)/Linit_local.c \
src/$(arch)/Linit_remote.c \
src/$(arch)/Lregs.c \
src/$(arch)/Lresume.c \
src/$(arch)/Lstep.c \
))
# 64-bit architectures
libunwind_src_files_arm64 += src/elf64.c
libunwind_src_files_x86_64 += src/elf64.c
# 32-bit architectures
libunwind_src_files_arm += src/elf32.c
libunwind_src_files_mips += src/elf32.c
libunwind_src_files_x86 += src/elf32.c
libunwind_src_files_arm += \
src/arm/getcontext.S \
src/arm/Gis_signal_frame.c \
src/arm/Gex_tables.c \
src/arm/Lis_signal_frame.c \
src/arm/Lex_tables.c \
libunwind_src_files_arm64 += \
src/aarch64/Gis_signal_frame.c \
src/aarch64/Lis_signal_frame.c \
libunwind_src_files_mips += \
src/mips/getcontext-android.S \
src/mips/Gis_signal_frame.c \
src/mips/Lis_signal_frame.c \
libunwind_src_files_x86 += \
src/x86/getcontext-linux.S \
src/x86/Gos-linux.c \
src/x86/Los-linux.c \
libunwind_src_files_x86_64 += \
src/x86_64/getcontext.S \
src/x86_64/Gstash_frame.c \
src/x86_64/Gtrace.c \
src/x86_64/Gos-linux.c \
src/x86_64/Lstash_frame.c \
src/x86_64/Ltrace.c \
src/x86_64/Los-linux.c \
src/x86_64/setcontext.S \
libunwind_src_files += \
src/unwind/Backtrace.c \
src/unwind/DeleteException.c \
src/unwind/FindEnclosingFunction.c \
src/unwind/ForcedUnwind.c \
src/unwind/GetBSP.c \
src/unwind/GetCFA.c \
src/unwind/GetDataRelBase.c \
src/unwind/GetGR.c \
src/unwind/GetIP.c \
src/unwind/GetIPInfo.c \
src/unwind/GetLanguageSpecificData.c \
src/unwind/GetRegionStart.c \
src/unwind/GetTextRelBase.c \
src/unwind/RaiseException.c \
src/unwind/Resume.c \
src/unwind/Resume_or_Rethrow.c \
src/unwind/SetGR.c \
src/unwind/SetIP.c \
libunwind_shared_libraries_target := \
libdl \
libunwind_ldflags_host := \
-nostdlib
libunwind_ldlibs_host := \
-lc \
-lpthread \
ifeq ($(debug),true)
libunwind_shared_libraries += \
liblog \
endif
module := libunwind
module_tag := optional
build_type := target
build_target := SHARED_LIBRARY
include $(LOCAL_PATH)/Android.build.mk
build_type := host
include $(LOCAL_PATH)/Android.build.mk
build_type := target
build_target := STATIC_LIBRARY
include $(LOCAL_PATH)/Android.build.mk
build_type := host
include $(LOCAL_PATH)/Android.build.mk
#-----------------------------------------------------------------------
# libunwind-ptrace shared library
#-----------------------------------------------------------------------
libunwind-ptrace_src_files := \
src/ptrace/_UPT_elf.c \
src/ptrace/_UPT_accessors.c \
src/ptrace/_UPT_access_fpreg.c \
src/ptrace/_UPT_access_mem.c \
src/ptrace/_UPT_access_reg.c \
src/ptrace/_UPT_create.c \
src/ptrace/_UPT_destroy.c \
src/ptrace/_UPT_find_proc_info.c \
src/ptrace/_UPT_get_dyn_info_list_addr.c \
src/ptrace/_UPT_put_unwind_info.c \
src/ptrace/_UPT_get_proc_name.c \
src/ptrace/_UPT_reg_offset.c \
src/ptrace/_UPT_resume.c \
libunwind-ptrace_shared_libraries := \
libunwind \
libunwind-ptrace_ldflags_host := \
-nostdlib
libunwind-ptrace_ldlibs_host := \
-lc \
-lpthread \
ifeq ($(debug),true)
libunwind-ptrace_shared_libraries += \
liblog \
endif
module := libunwind-ptrace
module_tag := optional
build_type := target
build_target := SHARED_LIBRARY
include $(LOCAL_PATH)/Android.build.mk
build_type := host
include $(LOCAL_PATH)/Android.build.mk
#-----------------------------------------------------------------------
# libunwind testing
#-----------------------------------------------------------------------
libunwind-unit-tests_cflags := \
-fno-builtin \
-O0 \
-g \
libunwind-unit-tests_c_includes := \
$(LOCAL_PATH)/include \
libunwind-unit-tests_src_files := \
android/tests/local_test.cpp \
libunwind-unit-tests_shared_libraries := \
libunwind \
libunwind-unit-tests_multilib := both
module := libunwind-unit-tests
module_tag := optional
build_type := target
build_target := NATIVE_TEST
include $(LOCAL_PATH)/Android.build.mk
build_type := host
include $(LOCAL_PATH)/Android.build.mk
# Run the unit tests built for x86 or x86_64.
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
LINKER = linker64
TEST_SUFFIX = 64
else
LINKER = linker
TEST_SUFFIX = 32
endif
libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
if [ ! -d /system -o ! -d /system/bin ]; then \
echo "Attempting to create /system/bin"; \
sudo mkdir -p -m 0777 /system/bin; \
fi
mkdir -p $(TARGET_OUT_DATA)/local/tmp
cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
ANDROID_DATA=$(TARGET_OUT_DATA) \
ANDROID_ROOT=$(TARGET_OUT) \
LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
$(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
endif