aboutsummaryrefslogtreecommitdiff
path: root/src/tools/perf/Android.mk
blob: 332ade2be952fd4e39df72b3bed791df196901b8 (plain)
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
# Copyright (C) 2013 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)

ifeq ($(TARGET_PRODUCT),sdk)
supported_platforms := none
else
supported_platforms := linux
endif

cur_platform := $(filter $(HOST_OS),$(supported_platforms))

ifdef cur_platform

perf_arch := $(TARGET_ARCH)
ifeq ($(TARGET_ARCH), x86_64)
perf_arch := x86
endif

ifeq ($(TARGET_ARCH), mips64)
perf_arch := mips
endif

#
# target libperf
#
libperf_src_files := \
    arch/common.c \
    arch/$(perf_arch)/util/dwarf-regs.c \
    ui/helpline.c \
    ui/hist.c \
    ui/progress.c \
    ui/setup.c \
    ui/stdio/hist.c \
    ui/util.c \
    util/abspath.c \
    util/alias.c \
    util/annotate.c \
    util/bitmap.c \
    util/build-id.c \
    util/callchain.c \
    util/cgroup.c \
    util/color.c \
    util/config.c \
    util/cpumap.c \
    util/ctype.c \
    util/debug.c \
    util/dso.c \
    util/dwarf-aux.c \
    util/environment.c \
    util/event.c \
    util/evlist.c \
    util/evsel.c \
    util/exec_cmd.c \
    util/header.c \
    util/help.c \
    util/hist.c \
    util/hweight.c \
    util/intlist.c \
    util/levenshtein.c \
    util/machine.c \
    util/map.c \
    util/pager.c \
    util/parse-events.c \
    util/parse-events-bison.c \
    util/parse-events-flex.c \
    util/parse-options.c \
    util/path.c \
    util/pmu.c \
    util/pmu-bison.c \
    util/pmu-flex.c \
    util/probe-event.c \
    util/probe-finder.c \
    util/quote.c \
    util/rblist.c \
    util/record.c \
    util/run-command.c \
    util/sigchain.c \
    util/session.c \
    util/sort.c \
    util/stat.c \
    util/strbuf.c \
    util/string.c \
    util/strfilter.c \
    util/strlist.c \
    util/svghelper.c \
    util/symbol.c \
    util/symbol-elf.c \
    util/sysfs.c \
    util/target.c \
    util/thread.c \
    util/thread_map.c \
    util/top.c \
    util/trace-event-info.c \
    util/trace-event-parse.c \
    util/trace-event-read.c \
    util/trace-event-scripting.c \
    util/usage.c \
    util/util.c \
    util/values.c \
    util/vdso.c \
    util/wrapper.c \
    util/xyarray.c \
    ../lib/lk/debugfs.c \
    ../lib/traceevent/event-parse.c \
    ../lib/traceevent/parse-utils.c \
    ../lib/traceevent/trace-seq.c \
    ../../lib/rbtree.c

common_perf_headers := \
    $(LOCAL_PATH)/../lib \
    $(LOCAL_PATH)/util/include \
    $(LOCAL_PATH)/util \
    bionic/libc/kernel/uapi \

common_elfutil_headers := \
    external/elfutils/include/ \

common_clang_compiler_flags := \
    -Wno-int-conversion \
    -Wno-tautological-pointer-compare \
    -Wno-tautological-constant-out-of-range-compare \
    -Wno-pointer-bool-conversion \

common_compiler_flags := \
    -include external/linux-tools-perf/android-fixes.h \
    -Wno-error \
    -std=gnu99 \
    -Wno-attributes \
    -Wno-implicit-function-declaration \
    -Wno-int-to-pointer-cast \
    -Wno-maybe-uninitialized \
    -Wno-missing-field-initializers \
    -Wno-pointer-arith \
    -Wno-pointer-sign \
    -Wno-return-type \
    -Wno-sign-compare \
    -Wno-unused-parameter \

common_predefined_macros := \
    -D_GNU_SOURCE \
    -DDWARF_SUPPORT \
    -DPYTHON='""' \
    -DPYTHONPATH='""' \
    -DBINDIR='""' \
    -DETC_PERFCONFIG='""' \
    -DPREFIX='""' \
    -DPERF_EXEC_PATH='""' \
    -DPERF_HTML_PATH='""' \
    -DPERF_MAN_PATH='""' \
    -DPERF_INFO_PATH='""' \
    -DPERF_VERSION='"perf.3.12_android"' \
    -DHAVE_ELF_GETPHDRNUM \
    -DHAVE_CPLUS_DEMANGLE \
    -DLIBELF_SUPPORT \
    -DLIBELF_MMAP \
    -DNO_NEWT_SUPPORT \
    -DNO_LIBPERL \
    -DNO_LIBPYTHON \
    -DNO_GTK2 \
    -DNO_LIBNUMA \
    -DNO_LIBAUDIT \

# glibc has the obsolete on_exit, which collides with perf's redefinition.
host_predefined_macros := \
    -DHAVE_ON_EXIT \

#
# target perf
#
perf_src_files := \
    perf.c \
    bench/mem-memcpy.c \
    bench/mem-memset.c \
    bench/sched-messaging.c \
    bench/sched-pipe.c \
    builtin-annotate.c \
    builtin-bench.c \
    builtin-buildid-cache.c \
    builtin-buildid-list.c \
    builtin-diff.c \
    builtin-evlist.c \
    builtin-help.c \
    builtin-inject.c \
    builtin-kmem.c \
    builtin-kvm.c \
    builtin-list.c \
    builtin-lock.c \
    builtin-mem.c \
    builtin-probe.c \
    builtin-record.c \
    builtin-report.c \
    builtin-sched.c \
    builtin-script.c \
    builtin-stat.c \
    builtin-timechart.c \
    builtin-top.c \
    tests/attr.c \
    tests/bp_signal.c \
    tests/bp_signal_overflow.c \
    tests/builtin-test.c \
    tests/code-reading.c \
    tests/dso-data.c \
    tests/evsel-roundtrip-name.c \
    tests/evsel-tp-sched.c \
    tests/hists_link.c \
    tests/keep-tracking.c \
    tests/mmap-basic.c \
    tests/open-syscall-all-cpus.c \
    tests/open-syscall.c \
    tests/open-syscall-tp-fields.c \
    tests/parse-events.c \
    tests/parse-no-sample-id-all.c \
    tests/perf-record.c \
    tests/pmu.c \
    tests/python-use.c \
    tests/rdpmc.c \
    tests/sample-parsing.c \
    tests/sw-clock.c \
    tests/task-exit.c \
    tests/vmlinux-kallsyms.c \

perf_src_files_x86 = \
    arch/x86/util/tsc.c \
    tests/perf-time-to-tsc.c \

include $(CLEAR_VARS)
ifeq ($(TARGET_ARCH),arm)
# b/17167262, builtin-report.c and builtin-top.c have undefined __aeabi_read_tp
# when compiled with clang -fpie.
LOCAL_CLANG := false
endif

LOCAL_SRC_FILES := $(libperf_src_files) $(perf_src_files)
LOCAL_SRC_FILES_x86 := $(perf_src_files_x86)
LOCAL_SRC_FILES_x86_64 := $(perf_src_files_x86)

# TODO: this is only needed because of libebl below, which seems like a mistake on the target.
LOCAL_SHARED_LIBRARIES := libdl

# TODO: there's probably more stuff here than is strictly necessary on the target.
LOCAL_STATIC_LIBRARIES := \
    libdwfl \
    libdw \
    libebl \
    libelf \

LOCAL_CFLAGS += $(common_predefined_macros)
LOCAL_CFLAGS += $(common_compiler_flags)
LOCAL_CLANG_CFLAGS += $(common_clang_compiler_flags)
LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)

LOCAL_MODULE := perf
LOCAL_MODULE_TAGS := eng
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk

include $(BUILD_EXECUTABLE)

#
# host perf
#
include $(CLEAR_VARS)

LOCAL_SRC_FILES := $(perf_src_files) $(libperf_src_files)
LOCAL_SRC_FILES_x86 := $(perf_src_files_x86)
LOCAL_SRC_FILES_x86_64 := $(perf_src_files_x86)

# TODO: libebl tries to dlopen libebl_$arch.so, which we don't actually build.
# At the moment it's probably pulling in the ones from the host OS' perf, at
# least on Linux. On the Mac it's probably just completely broken.
LOCAL_STATIC_LIBRARIES := \
    libdwfl \
    libdw \
    libebl \
    libelf \

LOCAL_CFLAGS += $(common_predefined_macros) $(host_predefined_macros)
LOCAL_CFLAGS += $(common_compiler_flags)
LOCAL_CLANG_CFLAGS += $(common_clang_compiler_flags)

LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)

LOCAL_C_INCLUDES += bionic/libc/kernel/uapi/asm-x86 # The kvm stuff needs <asm/svm.h>.

LOCAL_LDLIBS := -ldl -lpthread -lrt

LOCAL_MODULE := perfhost
LOCAL_MODULE_TAGS := eng
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk

include $(BUILD_HOST_EXECUTABLE)

endif #cur_platform