blob: 624b7ef85bc1422af3ecea0d033edf2d09eb2812 [file] [log] [blame]
Ben Chengf3055792013-11-19 15:38:08 -08001# Copyright (C) 2013 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15LOCAL_PATH := $(call my-dir)
16
17ifeq ($(TARGET_PRODUCT),sdk)
18supported_platforms := none
19else
Elliott Hughesf0ccdc52014-08-15 15:59:20 -070020supported_platforms := linux
Ben Chengf3055792013-11-19 15:38:08 -080021endif
22
Ying Wangd87efbc2014-06-18 16:03:12 -070023cur_platform := $(filter $(HOST_OS),$(supported_platforms))
Ben Chengf3055792013-11-19 15:38:08 -080024
25ifdef cur_platform
26
Fengwei Yin5f453392014-03-13 22:39:41 +080027perf_arch := $(TARGET_ARCH)
28ifeq ($(TARGET_ARCH), x86_64)
29perf_arch := x86
30endif
31
Raghu Gandham37c9bb92014-04-14 18:24:00 -070032ifeq ($(TARGET_ARCH), mips64)
33perf_arch := mips
34endif
35
Ben Chengf3055792013-11-19 15:38:08 -080036#
37# target libperf
38#
39libperf_src_files := \
Elliott Hughesefa9f002014-08-13 13:13:02 -070040 arch/common.c \
41 arch/$(perf_arch)/util/dwarf-regs.c \
42 tests/attr.c \
43 ui/helpline.c \
44 ui/hist.c \
45 ui/progress.c \
46 ui/setup.c \
47 ui/stdio/hist.c \
48 ui/util.c \
49 util/abspath.c \
50 util/alias.c \
51 util/annotate.c \
52 util/bitmap.c \
53 util/build-id.c \
54 util/callchain.c \
55 util/cgroup.c \
56 util/color.c \
57 util/config.c \
58 util/cpumap.c \
59 util/ctype.c \
60 util/debug.c \
61 util/dso.c \
62 util/dwarf-aux.c \
63 util/environment.c \
64 util/event.c \
65 util/evlist.c \
66 util/evsel.c \
67 util/exec_cmd.c \
68 util/header.c \
69 util/help.c \
70 util/hist.c \
71 util/hweight.c \
72 util/intlist.c \
73 util/levenshtein.c \
74 util/machine.c \
75 util/map.c \
76 util/pager.c \
77 util/parse-events.c \
78 util/parse-events-bison.c \
79 util/parse-events-flex.c \
80 util/parse-options.c \
81 util/path.c \
82 util/pmu.c \
83 util/pmu-bison.c \
84 util/pmu-flex.c \
85 util/probe-event.c \
86 util/probe-finder.c \
87 util/quote.c \
88 util/rblist.c \
89 util/record.c \
90 util/run-command.c \
91 util/sigchain.c \
92 util/session.c \
93 util/sort.c \
94 util/stat.c \
95 util/strbuf.c \
96 util/string.c \
97 util/strfilter.c \
98 util/strlist.c \
99 util/svghelper.c \
100 util/symbol.c \
101 util/symbol-elf.c \
102 util/sysfs.c \
103 util/target.c \
104 util/thread.c \
105 util/thread_map.c \
106 util/top.c \
107 util/trace-event-info.c \
108 util/trace-event-parse.c \
109 util/trace-event-read.c \
110 util/trace-event-scripting.c \
111 util/usage.c \
112 util/util.c \
113 util/values.c \
114 util/vdso.c \
115 util/wrapper.c \
116 util/xyarray.c \
117 ../lib/lk/debugfs.c \
118 ../lib/traceevent/event-parse.c \
119 ../lib/traceevent/parse-utils.c \
120 ../lib/traceevent/trace-seq.c \
121 ../../lib/rbtree.c
Ben Chengf3055792013-11-19 15:38:08 -0800122
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700123common_perf_headers := \
124 $(LOCAL_PATH)/../lib \
125 $(LOCAL_PATH)/util/include \
126 $(LOCAL_PATH)/util \
127 bionic/libc/kernel/uapi \
Ben Chengf3055792013-11-19 15:38:08 -0800128
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700129common_elfutil_headers := \
130 external/elfutils \
131 external/elfutils/0.153/libelf \
132 external/elfutils/0.153/libdw \
133 external/elfutils/0.153/libdwfl \
Ben Chengf3055792013-11-19 15:38:08 -0800134
Elliott Hughesefa9f002014-08-13 13:13:02 -0700135common_compiler_flags := \
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700136 -include external/linux-tools-perf/android-fixes.h \
Elliott Hughesefa9f002014-08-13 13:13:02 -0700137 -Wno-error \
138 -std=gnu99 \
139 -Wno-attributes \
140 -Wno-implicit-function-declaration \
141 -Wno-int-conversion \
142 -Wno-int-to-pointer-cast \
143 -Wno-maybe-uninitialized \
144 -Wno-missing-field-initializers \
145 -Wno-pointer-arith \
146 -Wno-pointer-sign \
147 -Wno-return-type \
148 -Wno-sign-compare \
149 -Wno-unused-parameter \
150
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700151common_predefined_macros := \
152 -D_GNU_SOURCE \
153 -DDWARF_SUPPORT \
154 -DPYTHON='""' \
155 -DPYTHONPATH='""' \
156 -DBINDIR='""' \
157 -DETC_PERFCONFIG='""' \
158 -DPREFIX='""' \
159 -DPERF_EXEC_PATH='""' \
160 -DPERF_HTML_PATH='""' \
161 -DPERF_MAN_PATH='""' \
162 -DPERF_INFO_PATH='""' \
163 -DPERF_VERSION='"perf.3.12_android"' \
164 -DHAVE_ELF_GETPHDRNUM \
165 -DHAVE_CPLUS_DEMANGLE \
166 -DLIBELF_SUPPORT \
167 -DLIBELF_MMAP \
168 -DNO_NEWT_SUPPORT \
169 -DNO_LIBPERL \
170 -DNO_LIBPYTHON \
171 -DNO_GTK2 \
172 -DNO_LIBNUMA \
173 -DNO_LIBAUDIT \
Ben Chengf3055792013-11-19 15:38:08 -0800174
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700175# glibc has the obsolete on_exit, which collides with perf's redefinition.
176host_predefined_macros := \
177 -DHAVE_ON_EXIT \
Ben Chengf3055792013-11-19 15:38:08 -0800178
179include $(CLEAR_VARS)
180
181LOCAL_SRC_FILES := $(libperf_src_files)
182
Ben Chengf3055792013-11-19 15:38:08 -0800183LOCAL_CFLAGS += $(common_predefined_macros)
Ben Chengf3055792013-11-19 15:38:08 -0800184LOCAL_CFLAGS += $(common_compiler_flags)
Ben Chengf3055792013-11-19 15:38:08 -0800185LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)
186
187LOCAL_MODULE := libperf
Ben Chengf3055792013-11-19 15:38:08 -0800188LOCAL_MODULE_TAGS := eng
Elliott Hughesefa9f002014-08-13 13:13:02 -0700189LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ben Chengf3055792013-11-19 15:38:08 -0800190
191include $(BUILD_STATIC_LIBRARY)
192
193#
194# host libperf
195#
196include $(CLEAR_VARS)
197
198LOCAL_SRC_FILES := $(libperf_src_files)
199
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700200LOCAL_CFLAGS += $(common_predefined_macros) $(host_predefined_macros)
Ben Chengf3055792013-11-19 15:38:08 -0800201LOCAL_CFLAGS += $(common_compiler_flags)
Ben Chengf3055792013-11-19 15:38:08 -0800202LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)
Ben Cheng0da48032013-11-26 15:56:54 -0800203LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup
204
Ben Chengf3055792013-11-19 15:38:08 -0800205LOCAL_MODULE := libperf
Ben Chengf3055792013-11-19 15:38:08 -0800206LOCAL_MODULE_TAGS := eng
Elliott Hughesefa9f002014-08-13 13:13:02 -0700207LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ben Chengf3055792013-11-19 15:38:08 -0800208
209include $(BUILD_HOST_STATIC_LIBRARY)
210
211#
212# target perf
213#
214perf_src_files := \
Elliott Hughesefa9f002014-08-13 13:13:02 -0700215 perf.c \
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700216 bench/mem-memcpy.c \
217 bench/mem-memset.c \
218 bench/sched-messaging.c \
219 bench/sched-pipe.c \
Elliott Hughesefa9f002014-08-13 13:13:02 -0700220 builtin-annotate.c \
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700221 builtin-bench.c \
Elliott Hughesefa9f002014-08-13 13:13:02 -0700222 builtin-buildid-cache.c \
223 builtin-buildid-list.c \
224 builtin-diff.c \
225 builtin-evlist.c \
226 builtin-help.c \
227 builtin-inject.c \
228 builtin-kmem.c \
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700229 builtin-kvm.c \
Elliott Hughesefa9f002014-08-13 13:13:02 -0700230 builtin-list.c \
231 builtin-lock.c \
232 builtin-mem.c \
233 builtin-probe.c \
234 builtin-record.c \
235 builtin-report.c \
236 builtin-sched.c \
237 builtin-script.c \
238 builtin-stat.c \
239 builtin-timechart.c \
240 builtin-top.c \
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700241 tests/attr.c \
242 tests/bp_signal.c \
243 tests/bp_signal_overflow.c \
244 tests/builtin-test.c \
245 tests/code-reading.c \
246 tests/dso-data.c \
247 tests/evsel-roundtrip-name.c \
248 tests/evsel-tp-sched.c \
249 tests/hists_link.c \
250 tests/keep-tracking.c \
251 tests/mmap-basic.c \
252 tests/open-syscall-all-cpus.c \
253 tests/open-syscall.c \
254 tests/open-syscall-tp-fields.c \
255 tests/parse-events.c \
256 tests/parse-no-sample-id-all.c \
257 tests/perf-record.c \
258 tests/pmu.c \
259 tests/python-use.c \
260 tests/rdpmc.c \
261 tests/sample-parsing.c \
262 tests/sw-clock.c \
263 tests/task-exit.c \
264 tests/vmlinux-kallsyms.c \
265
266perf_src_files_x86 = \
267 arch/x86/util/tsc.c \
268 tests/perf-time-to-tsc.c \
Ben Chengf3055792013-11-19 15:38:08 -0800269
270include $(CLEAR_VARS)
271
272LOCAL_SRC_FILES := $(perf_src_files)
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700273LOCAL_SRC_FILES_x86 := $(perf_src_files_x86)
274LOCAL_SRC_FILES_x86_64 := $(perf_src_files_x86)
Ben Chengf3055792013-11-19 15:38:08 -0800275
Elliott Hughesefa9f002014-08-13 13:13:02 -0700276# TODO: this is only needed because of libebl below, which seems like a mistake on the target.
Ben Chengf3055792013-11-19 15:38:08 -0800277LOCAL_SHARED_LIBRARIES := libdl
278
Elliott Hughesefa9f002014-08-13 13:13:02 -0700279# TODO: there's probably more stuff here than is strictly necessary on the target.
280LOCAL_STATIC_LIBRARIES := \
281 libperf \
282 libdwfl \
283 libdw \
284 libebl \
285 libelf \
286 libgccdemangle \
Ben Chengf3055792013-11-19 15:38:08 -0800287
Elliott Hughesefa9f002014-08-13 13:13:02 -0700288LOCAL_CFLAGS += $(common_predefined_macros)
289LOCAL_CFLAGS += $(common_compiler_flags)
290LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)
291
292LOCAL_MODULE := perf
Ben Chengf3055792013-11-19 15:38:08 -0800293LOCAL_MODULE_TAGS := eng
Elliott Hughesefa9f002014-08-13 13:13:02 -0700294LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ben Chengf3055792013-11-19 15:38:08 -0800295
296include $(BUILD_EXECUTABLE)
297
298#
299# host perf
300#
301include $(CLEAR_VARS)
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700302
Ben Chengf3055792013-11-19 15:38:08 -0800303LOCAL_SRC_FILES := $(perf_src_files)
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700304LOCAL_SRC_FILES_x86 := $(perf_src_files_x86)
305LOCAL_SRC_FILES_x86_64 := $(perf_src_files_x86)
Ben Chengf3055792013-11-19 15:38:08 -0800306
Elliott Hughesefa9f002014-08-13 13:13:02 -0700307# TODO: libebl tries to dlopen libebl_$arch.so, which we don't actually build.
308# At the moment it's probably pulling in the ones from the host OS' perf, at
309# least on Linux. On the Mac it's probably just completely broken.
310LOCAL_STATIC_LIBRARIES := \
311 libperf \
312 libdwfl \
313 libdw \
314 libebl \
315 libelf \
316 libgccdemangle \
Ben Chengf3055792013-11-19 15:38:08 -0800317
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700318LOCAL_CFLAGS += $(common_predefined_macros) $(host_predefined_macros)
Elliott Hughesefa9f002014-08-13 13:13:02 -0700319LOCAL_CFLAGS += $(common_compiler_flags)
Ben Chengf3055792013-11-19 15:38:08 -0800320
Ben Chengf3055792013-11-19 15:38:08 -0800321LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)
Ben Cheng0da48032013-11-26 15:56:54 -0800322LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup
323
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700324LOCAL_C_INCLUDES += bionic/libc/kernel/uapi/asm-x86 # The kvm stuff needs <asm/svm.h>.
Ben Cheng0da48032013-11-26 15:56:54 -0800325
Elliott Hughesf0ccdc52014-08-15 15:59:20 -0700326LOCAL_LDLIBS := -ldl -lpthread -lrt
Ben Chengf3055792013-11-19 15:38:08 -0800327
328LOCAL_MODULE := perfhost
Ben Chengf3055792013-11-19 15:38:08 -0800329LOCAL_MODULE_TAGS := eng
Elliott Hughesefa9f002014-08-13 13:13:02 -0700330LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ben Chengf3055792013-11-19 15:38:08 -0800331
332include $(BUILD_HOST_EXECUTABLE)
333
334endif #cur_platform