blob: 092f38051fa593ea986a4319374cee4a6b6c263c [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
Ying Wangd87efbc2014-06-18 16:03:12 -070020supported_platforms := linux darwin
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 -080036libperf_src_files := \
Elliott Hughes708e65a2014-08-13 13:13:02 -070037 arch/common.c \
38 arch/$(perf_arch)/util/dwarf-regs.c \
39 tests/attr.c \
40 ui/helpline.c \
41 ui/hist.c \
42 ui/progress.c \
43 ui/setup.c \
44 ui/stdio/hist.c \
45 ui/util.c \
46 util/abspath.c \
47 util/alias.c \
48 util/annotate.c \
49 util/bitmap.c \
50 util/build-id.c \
51 util/callchain.c \
52 util/cgroup.c \
53 util/color.c \
54 util/config.c \
55 util/cpumap.c \
56 util/ctype.c \
57 util/debug.c \
58 util/dso.c \
59 util/dwarf-aux.c \
60 util/environment.c \
61 util/event.c \
62 util/evlist.c \
63 util/evsel.c \
64 util/exec_cmd.c \
65 util/header.c \
66 util/help.c \
67 util/hist.c \
68 util/hweight.c \
69 util/intlist.c \
70 util/levenshtein.c \
71 util/machine.c \
72 util/map.c \
73 util/pager.c \
74 util/parse-events.c \
75 util/parse-events-bison.c \
76 util/parse-events-flex.c \
77 util/parse-options.c \
78 util/path.c \
79 util/pmu.c \
80 util/pmu-bison.c \
81 util/pmu-flex.c \
82 util/probe-event.c \
83 util/probe-finder.c \
84 util/quote.c \
85 util/rblist.c \
86 util/record.c \
87 util/run-command.c \
88 util/sigchain.c \
89 util/session.c \
90 util/sort.c \
91 util/stat.c \
92 util/strbuf.c \
93 util/string.c \
94 util/strfilter.c \
95 util/strlist.c \
96 util/svghelper.c \
97 util/symbol.c \
98 util/symbol-elf.c \
99 util/sysfs.c \
100 util/target.c \
101 util/thread.c \
102 util/thread_map.c \
103 util/top.c \
104 util/trace-event-info.c \
105 util/trace-event-parse.c \
106 util/trace-event-read.c \
107 util/trace-event-scripting.c \
108 util/usage.c \
109 util/util.c \
110 util/values.c \
111 util/vdso.c \
112 util/wrapper.c \
113 util/xyarray.c \
114 ../lib/lk/debugfs.c \
115 ../lib/traceevent/event-parse.c \
116 ../lib/traceevent/parse-utils.c \
117 ../lib/traceevent/trace-seq.c \
118 ../../lib/rbtree.c
Ben Chengf3055792013-11-19 15:38:08 -0800119
120common_perf_headers := $(LOCAL_PATH)/../lib $(LOCAL_PATH)/util/include \
Elliott Hughes708e65a2014-08-13 13:13:02 -0700121 $(LOCAL_PATH)/util $(LOCAL_PATH)/../../include/uapi
Ben Chengf3055792013-11-19 15:38:08 -0800122
Ben Cheng61f91732013-11-21 15:54:02 -0800123common_elfutil_headers := external/elfutils external/elfutils/0.153/libelf \
Elliott Hughes708e65a2014-08-13 13:13:02 -0700124 external/elfutils/0.153/libdw external/elfutils/0.153/libdwfl
Ben Chengf3055792013-11-19 15:38:08 -0800125
Elliott Hughes708e65a2014-08-13 13:13:02 -0700126common_compiler_flags := \
Elliott Hughesd8fa3692014-08-14 14:06:28 -0700127 -DANDROID_PATCHES \
Elliott Hughes708e65a2014-08-13 13:13:02 -0700128 -Wno-error \
129 -std=gnu99 \
Elliott Hughes41c166c2014-08-13 19:28:12 -0700130 -Wno-return-type \
131
Elliott Hughes35868b62014-08-14 11:32:34 -0700132ifeq ($(strip $(HOST_OS)),linux)
Elliott Hughes41c166c2014-08-13 19:28:12 -0700133common_compiler_flags += \
Elliott Hughes708e65a2014-08-13 13:13:02 -0700134 -Wno-attributes \
135 -Wno-implicit-function-declaration \
136 -Wno-int-to-pointer-cast \
137 -Wno-maybe-uninitialized \
138 -Wno-missing-field-initializers \
139 -Wno-pointer-arith \
140 -Wno-pointer-sign \
Elliott Hughes708e65a2014-08-13 13:13:02 -0700141 -Wno-sign-compare \
142 -Wno-unused-parameter \
143
Elliott Hughes708e65a2014-08-13 13:13:02 -0700144endif
Ben Chengf3055792013-11-19 15:38:08 -0800145
Elliott Hughes35868b62014-08-14 11:32:34 -0700146ifeq ($(strip $(HOST_OS)),darwin)
147host_compiler_flags := -include $(LOCAL_PATH)/host-darwin-fixup/AndroidFixup.h
148endif
149
Ben Chengf3055792013-11-19 15:38:08 -0800150common_disabled_macros := -DNO_NEWT_SUPPORT -DNO_LIBPERL -DNO_LIBPYTHON \
Elliott Hughes708e65a2014-08-13 13:13:02 -0700151 -DNO_GTK2 -DNO_LIBNUMA -DNO_LIBAUDIT
Ben Chengf3055792013-11-19 15:38:08 -0800152
153common_predefined_macros := -DDWARF_SUPPORT -DPYTHON='""' -DBINDIR='""' \
Elliott Hughes708e65a2014-08-13 13:13:02 -0700154 -DETC_PERFCONFIG='""' -DPREFIX='""' -DPERF_EXEC_PATH='""' \
155 -DPERF_HTML_PATH='""' -DPERF_MAN_PATH='""' -DPERF_INFO_PATH='""' \
156 -DPERF_VERSION='"perf.3.12_android"' -DHAVE_ELF_GETPHDRNUM \
157 -DLIBELF_SUPPORT -DLIBELF_MMAP
Ben Chengf3055792013-11-19 15:38:08 -0800158
Elliott Hughes35868b62014-08-14 11:32:34 -0700159perf_src_files := \
160 perf.c \
161 builtin-annotate.c \
162 builtin-buildid-cache.c \
163 builtin-buildid-list.c \
164 builtin-diff.c \
165 builtin-evlist.c \
166 builtin-help.c \
167 builtin-inject.c \
168 builtin-kmem.c \
169 builtin-list.c \
170 builtin-lock.c \
171 builtin-mem.c \
172 builtin-probe.c \
173 builtin-record.c \
174 builtin-report.c \
175 builtin-sched.c \
176 builtin-script.c \
177 builtin-stat.c \
178 builtin-timechart.c \
179 builtin-top.c \
180
181
182#
183# target libperf
184#
Ben Chengf3055792013-11-19 15:38:08 -0800185include $(CLEAR_VARS)
186
187LOCAL_SRC_FILES := $(libperf_src_files)
188
Ben Chengf3055792013-11-19 15:38:08 -0800189LOCAL_CFLAGS := $(common_disabled_macros)
Ben Chengf3055792013-11-19 15:38:08 -0800190LOCAL_CFLAGS += $(common_predefined_macros)
Ben Chengf3055792013-11-19 15:38:08 -0800191LOCAL_CFLAGS += $(common_compiler_flags)
Ben Chengf3055792013-11-19 15:38:08 -0800192LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)
193
194LOCAL_MODULE := libperf
Ben Chengf3055792013-11-19 15:38:08 -0800195LOCAL_MODULE_TAGS := eng
Elliott Hughes708e65a2014-08-13 13:13:02 -0700196LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ben Chengf3055792013-11-19 15:38:08 -0800197
198include $(BUILD_STATIC_LIBRARY)
199
200#
201# host libperf
202#
203include $(CLEAR_VARS)
204
205LOCAL_SRC_FILES := $(libperf_src_files)
206
Ben Chengf3055792013-11-19 15:38:08 -0800207LOCAL_CFLAGS := $(common_disabled_macros)
Ben Chengf3055792013-11-19 15:38:08 -0800208LOCAL_CFLAGS += $(common_predefined_macros)
Elliott Hughes35868b62014-08-14 11:32:34 -0700209LOCAL_CFLAGS += $(common_compiler_flags) $(host_compiler_flags)
Ben Chengf3055792013-11-19 15:38:08 -0800210LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)
Ben Cheng0da48032013-11-26 15:56:54 -0800211LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup
212
Ben Chengf3055792013-11-19 15:38:08 -0800213LOCAL_MODULE := libperf
Ben Chengf3055792013-11-19 15:38:08 -0800214LOCAL_MODULE_TAGS := eng
Elliott Hughes708e65a2014-08-13 13:13:02 -0700215LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ben Chengf3055792013-11-19 15:38:08 -0800216
Tim Murray20f6b4b2014-08-18 13:48:58 -0700217LOCAL_CLANG := false
218
Ben Chengf3055792013-11-19 15:38:08 -0800219include $(BUILD_HOST_STATIC_LIBRARY)
220
221#
222# target perf
223#
Ben Chengf3055792013-11-19 15:38:08 -0800224include $(CLEAR_VARS)
225
226LOCAL_SRC_FILES := $(perf_src_files)
227
Elliott Hughes708e65a2014-08-13 13:13:02 -0700228# TODO: this is only needed because of libebl below, which seems like a mistake on the target.
Ben Chengf3055792013-11-19 15:38:08 -0800229LOCAL_SHARED_LIBRARIES := libdl
230
Elliott Hughes708e65a2014-08-13 13:13:02 -0700231# TODO: there's probably more stuff here than is strictly necessary on the target.
232LOCAL_STATIC_LIBRARIES := \
233 libperf \
234 libdwfl \
235 libdw \
236 libebl \
237 libelf \
238 libgccdemangle \
Ben Chengf3055792013-11-19 15:38:08 -0800239
Elliott Hughes708e65a2014-08-13 13:13:02 -0700240LOCAL_CFLAGS := $(common_disabled_macros)
241LOCAL_CFLAGS += $(common_predefined_macros)
242LOCAL_CFLAGS += $(common_compiler_flags)
243LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)
244
245LOCAL_MODULE := perf
Ben Chengf3055792013-11-19 15:38:08 -0800246LOCAL_MODULE_TAGS := eng
Elliott Hughes708e65a2014-08-13 13:13:02 -0700247LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ben Chengf3055792013-11-19 15:38:08 -0800248
249include $(BUILD_EXECUTABLE)
250
251#
252# host perf
253#
254include $(CLEAR_VARS)
255
256LOCAL_SRC_FILES := $(perf_src_files)
257
Elliott Hughes708e65a2014-08-13 13:13:02 -0700258# TODO: libebl tries to dlopen libebl_$arch.so, which we don't actually build.
259# At the moment it's probably pulling in the ones from the host OS' perf, at
260# least on Linux. On the Mac it's probably just completely broken.
261LOCAL_STATIC_LIBRARIES := \
262 libperf \
263 libdwfl \
264 libdw \
265 libebl \
266 libelf \
267 libgccdemangle \
Ben Chengf3055792013-11-19 15:38:08 -0800268
Ben Chengf3055792013-11-19 15:38:08 -0800269LOCAL_CFLAGS := $(common_disabled_macros)
Ben Chengf3055792013-11-19 15:38:08 -0800270LOCAL_CFLAGS += $(common_predefined_macros)
Elliott Hughes35868b62014-08-14 11:32:34 -0700271LOCAL_CFLAGS += $(common_compiler_flags) $(host_compiler_flags)
Ben Chengf3055792013-11-19 15:38:08 -0800272
Ben Cheng0da48032013-11-26 15:56:54 -0800273# available on linux-x86 but not darwin-x86
274ifeq ($(strip $(HOST_OS)),linux)
Ben Chengf3055792013-11-19 15:38:08 -0800275LOCAL_CFLAGS += -DHAVE_ON_EXIT
Ben Cheng0da48032013-11-26 15:56:54 -0800276endif
Ben Chengf3055792013-11-19 15:38:08 -0800277
Ben Chengf3055792013-11-19 15:38:08 -0800278LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers)
Ben Cheng0da48032013-11-26 15:56:54 -0800279LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup
280
Ben Chengf3055792013-11-19 15:38:08 -0800281# for pthread_* and clock_gettime
Ben Cheng0da48032013-11-26 15:56:54 -0800282LOCAL_LDLIBS := -lpthread -ldl
283
284ifeq ($(strip $(HOST_OS)),linux)
285LOCAL_LDLIBS += -lrt
286endif
Ben Chengf3055792013-11-19 15:38:08 -0800287
288LOCAL_MODULE := perfhost
Ben Chengf3055792013-11-19 15:38:08 -0800289LOCAL_MODULE_TAGS := eng
Elliott Hughes708e65a2014-08-13 13:13:02 -0700290LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ben Chengf3055792013-11-19 15:38:08 -0800291
Tim Murray20f6b4b2014-08-18 13:48:58 -0700292LOCAL_CLANG := false
293
Ben Chengf3055792013-11-19 15:38:08 -0800294include $(BUILD_HOST_EXECUTABLE)
295
296endif #cur_platform