blob: f23eefdd75337d28d082909a77f88577c491e7e5 [file] [log] [blame]
Christopher Ferris7fb22872013-09-27 12:43:15 -07001LOCAL_PATH:= $(call my-dir)
2
Christopher Ferris17e91d42013-10-21 13:30:52 -07003common_src := \
4 Backtrace.cpp \
Christopher Ferris46756822014-01-14 20:16:30 -08005 BacktraceMap.cpp \
Christopher Ferris17e91d42013-10-21 13:30:52 -07006 BacktraceThread.cpp \
Christopher Ferris17e91d42013-10-21 13:30:52 -07007 thread_utils.c \
8
9common_cflags := \
10 -Wall \
11 -Wno-unused-parameter \
12 -Werror \
13
14common_conlyflags := \
15 -std=gnu99 \
16
17common_cppflags := \
18 -std=gnu++11 \
19
20common_shared_libs := \
21 libcutils \
22 libgccdemangle \
23 liblog \
24
Elliott Hughes3c67fe92014-01-02 15:13:38 -080025# To enable using libunwind on each arch, add it to this list.
Christopher Ferrisedbe3b42014-01-27 10:50:58 -080026libunwind_architectures := arm64
Elliott Hughes3c67fe92014-01-02 15:13:38 -080027
28ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),$(libunwind_architectures)))
Christopher Ferris17e91d42013-10-21 13:30:52 -070029
Christopher Ferris7fb22872013-09-27 12:43:15 -070030#----------------------------------------------------------------------------
Christopher Ferris17e91d42013-10-21 13:30:52 -070031# The native libbacktrace library with libunwind.
Christopher Ferris7fb22872013-09-27 12:43:15 -070032#----------------------------------------------------------------------------
33include $(CLEAR_VARS)
34
35LOCAL_SRC_FILES:= \
Christopher Ferris17e91d42013-10-21 13:30:52 -070036 $(common_src) \
37 UnwindCurrent.cpp \
38 UnwindPtrace.cpp \
Christopher Ferris7fb22872013-09-27 12:43:15 -070039
40LOCAL_CFLAGS := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070041 $(common_cflags) \
42
43LOCAL_CONLYFLAGS += \
44 $(common_conlyflags) \
45
46LOCAL_CPPFLAGS += \
47 $(common_cppflags) \
Christopher Ferris7fb22872013-09-27 12:43:15 -070048
49LOCAL_MODULE := libbacktrace
50LOCAL_MODULE_TAGS := optional
51
Christopher Ferris7fb22872013-09-27 12:43:15 -070052LOCAL_C_INCLUDES := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070053 $(common_c_includes) \
Christopher Ferris7fb22872013-09-27 12:43:15 -070054 external/libunwind/include \
55
Christopher Ferris17e91d42013-10-21 13:30:52 -070056LOCAL_SHARED_LIBRARIES := \
57 $(common_shared_libs) \
58 libunwind \
59 libunwind-ptrace \
60
61LOCAL_ADDITIONAL_DEPENDENCIES := \
62 $(LOCAL_PATH)/Android.mk
63
64include external/stlport/libstlport.mk
65
66include $(BUILD_SHARED_LIBRARY)
67
68else
Christopher Ferris7fb22872013-09-27 12:43:15 -070069
70#----------------------------------------------------------------------------
Christopher Ferris17e91d42013-10-21 13:30:52 -070071# The native libbacktrace library with libcorkscrew.
Christopher Ferris7fb22872013-09-27 12:43:15 -070072#----------------------------------------------------------------------------
73include $(CLEAR_VARS)
74
75LOCAL_SRC_FILES:= \
Christopher Ferris17e91d42013-10-21 13:30:52 -070076 $(common_src) \
77 Corkscrew.cpp \
Christopher Ferris7fb22872013-09-27 12:43:15 -070078
79LOCAL_CFLAGS := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070080 $(common_cflags) \
81
82LOCAL_CONLYFLAGS += \
83 $(common_conlyflags) \
84
85LOCAL_CPPFLAGS += \
86 $(common_cppflags) \
Christopher Ferris7fb22872013-09-27 12:43:15 -070087
88LOCAL_MODULE := libbacktrace
89LOCAL_MODULE_TAGS := optional
90
Christopher Ferris17e91d42013-10-21 13:30:52 -070091LOCAL_C_INCLUDES := \
92 $(common_c_includes) \
93 system/core/libcorkscrew \
94
Christopher Ferris7fb22872013-09-27 12:43:15 -070095LOCAL_SHARED_LIBRARIES := \
Christopher Ferris17e91d42013-10-21 13:30:52 -070096 $(common_shared_libs) \
Christopher Ferris7fb22872013-09-27 12:43:15 -070097 libcorkscrew \
98 libdl \
Christopher Ferris17e91d42013-10-21 13:30:52 -070099
100LOCAL_ADDITIONAL_DEPENDENCIES := \
101 $(LOCAL_PATH)/Android.mk
102
103include external/stlport/libstlport.mk
Christopher Ferris7fb22872013-09-27 12:43:15 -0700104
105include $(BUILD_SHARED_LIBRARY)
106
Christopher Ferris17e91d42013-10-21 13:30:52 -0700107endif
108
Christopher Ferris7fb22872013-09-27 12:43:15 -0700109#----------------------------------------------------------------------------
Christopher Ferris7fb22872013-09-27 12:43:15 -0700110# libbacktrace test library, all optimizations turned off
111#----------------------------------------------------------------------------
112include $(CLEAR_VARS)
113
114LOCAL_MODULE := libbacktrace_test
115LOCAL_MODULE_FLAGS := debug
116
117LOCAL_SRC_FILES := \
118 backtrace_testlib.c
119
120LOCAL_CFLAGS += \
121 -std=gnu99 \
122 -O0 \
123
Christopher Ferris17e91d42013-10-21 13:30:52 -0700124LOCAL_ADDITIONAL_DEPENDENCIES := \
125 $(LOCAL_PATH)/Android.mk
126
Christopher Ferris7fb22872013-09-27 12:43:15 -0700127include $(BUILD_SHARED_LIBRARY)
128
129#----------------------------------------------------------------------------
130# libbacktrace test executable
131#----------------------------------------------------------------------------
132include $(CLEAR_VARS)
133
134LOCAL_MODULE := backtrace_test
135LOCAL_MODULE_FLAGS := debug
136
137LOCAL_SRC_FILES := \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700138 backtrace_test.cpp \
139 thread_utils.c \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700140
141LOCAL_CFLAGS += \
Christopher Ferris7f081ec2013-11-05 11:38:05 -0800142 $(common_cflags) \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700143 -fno-builtin \
144 -fstack-protector-all \
145 -O0 \
146 -g \
147 -DGTEST_OS_LINUX_ANDROID \
148 -DGTEST_HAS_STD_STRING \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700149
Colin Crossd4146e62014-01-21 20:12:28 -0800150ifeq ($(TARGET_ARCH),arm64)
Elliott Hughes1380ddc2014-01-14 16:44:31 -0800151 $(info TODO: $(LOCAL_PATH)/Android.mk -fstack-protector not yet available for the AArch64 toolchain)
152 LOCAL_CFLAGS += -fno-stack-protector
Colin Crossd4146e62014-01-21 20:12:28 -0800153endif # arm64
Elliott Hughes1380ddc2014-01-14 16:44:31 -0800154
Christopher Ferris17e91d42013-10-21 13:30:52 -0700155LOCAL_CONLYFLAGS += \
156 $(common_conlyflags) \
157
158LOCAL_CPPFLAGS += \
159 $(common_cppflags) \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700160
161LOCAL_SHARED_LIBRARIES += \
162 libcutils \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700163 libbacktrace_test \
164 libbacktrace \
165
Christopher Ferris17e91d42013-10-21 13:30:52 -0700166LOCAL_LDLIBS := \
167 -lpthread \
168
169LOCAL_ADDITIONAL_DEPENDENCIES := \
170 $(LOCAL_PATH)/Android.mk
171
172include $(BUILD_NATIVE_TEST)
Christopher Ferris7fb22872013-09-27 12:43:15 -0700173
174#----------------------------------------------------------------------------
Christopher Ferrisf67c6412014-01-10 00:43:54 -0800175# Only x86 host versions of libbacktrace supported.
Christopher Ferris7fb22872013-09-27 12:43:15 -0700176#----------------------------------------------------------------------------
Christopher Ferrisf67c6412014-01-10 00:43:54 -0800177ifeq ($(HOST_ARCH),x86)
Christopher Ferris7fb22872013-09-27 12:43:15 -0700178
179#----------------------------------------------------------------------------
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -0700180# The host libbacktrace library using libcorkscrew
181#----------------------------------------------------------------------------
182include $(CLEAR_VARS)
183
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -0700184
185LOCAL_CFLAGS += \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700186 $(common_cflags) \
187
188LOCAL_CONLYFLAGS += \
189 $(common_conlyflags) \
190
Christopher Ferris17e91d42013-10-21 13:30:52 -0700191LOCAL_C_INCLUDES := \
192 $(common_c_includes) \
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -0700193
194LOCAL_SHARED_LIBRARIES := \
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -0700195 libgccdemangle \
196 liblog \
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -0700197
198LOCAL_MODULE := libbacktrace
199LOCAL_MODULE_TAGS := optional
200
Christopher Ferris17e91d42013-10-21 13:30:52 -0700201LOCAL_ADDITIONAL_DEPENDENCIES := \
202 $(LOCAL_PATH)/Android.mk
203
Christopher Ferrisf67c6412014-01-10 00:43:54 -0800204ifeq ($(HOST_OS),linux)
205LOCAL_SRC_FILES += \
206 $(common_src) \
207 Corkscrew.cpp \
208
209LOCAL_C_INCLUDES += \
210 system/core/libcorkscrew \
211
212LOCAL_SHARED_LIBRARIES := \
213 libcorkscrew \
214
215LOCAL_CPPFLAGS += \
216 $(common_cppflags) \
217
218LOCAL_LDLIBS += \
219 -ldl \
220 -lrt \
221
222else
223LOCAL_SRC_FILES += \
Christopher Ferris46756822014-01-14 20:16:30 -0800224 BacktraceMap.cpp \
Christopher Ferrisf67c6412014-01-10 00:43:54 -0800225
226endif
227
Christopher Ferris9e1ee2b2013-10-02 14:19:19 -0700228include $(BUILD_HOST_SHARED_LIBRARY)
229
230#----------------------------------------------------------------------------
Christopher Ferrisf67c6412014-01-10 00:43:54 -0800231# The host test is only supported on linux.
232#----------------------------------------------------------------------------
233ifeq ($(HOST_OS),linux)
234
235#----------------------------------------------------------------------------
Christopher Ferris7fb22872013-09-27 12:43:15 -0700236# libbacktrace host test library, all optimizations turned off
237#----------------------------------------------------------------------------
238include $(CLEAR_VARS)
239
240LOCAL_MODULE := libbacktrace_test
241LOCAL_MODULE_FLAGS := debug
242
243LOCAL_SRC_FILES := \
244 backtrace_testlib.c
245
246LOCAL_CFLAGS += \
247 -std=gnu99 \
248 -O0 \
249
Christopher Ferris17e91d42013-10-21 13:30:52 -0700250LOCAL_ADDITIONAL_DEPENDENCIES := \
251 $(LOCAL_PATH)/Android.mk
252
Christopher Ferris7fb22872013-09-27 12:43:15 -0700253include $(BUILD_HOST_SHARED_LIBRARY)
254
255#----------------------------------------------------------------------------
256# libbacktrace host test executable
257#----------------------------------------------------------------------------
258include $(CLEAR_VARS)
259
260LOCAL_MODULE := backtrace_test
261LOCAL_MODULE_FLAGS := debug
262
263LOCAL_SRC_FILES := \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700264 backtrace_test.cpp \
265 thread_utils.c \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700266
267LOCAL_CFLAGS += \
Christopher Ferris7f081ec2013-11-05 11:38:05 -0800268 $(common_cflags) \
Christopher Ferris17e91d42013-10-21 13:30:52 -0700269 -fno-builtin \
270 -fstack-protector-all \
271 -O0 \
272 -g \
273 -DGTEST_HAS_STD_STRING \
Christopher Ferris7fb22872013-09-27 12:43:15 -0700274
275LOCAL_SHARED_LIBRARIES := \
276 libbacktrace_test \
277 libbacktrace \
278
Christopher Ferris17e91d42013-10-21 13:30:52 -0700279LOCAL_LDLIBS := \
280 -lpthread \
281
282LOCAL_ADDITIONAL_DEPENDENCIES := \
283 $(LOCAL_PATH)/Android.mk
284
285include $(BUILD_HOST_NATIVE_TEST)
Christopher Ferris7fb22872013-09-27 12:43:15 -0700286
Christopher Ferrisf67c6412014-01-10 00:43:54 -0800287endif # HOST_OS == linux
288
289endif # HOST_ARCH == x86