Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 1 | # 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 | |
| 15 | LOCAL_PATH := $(call my-dir) |
| 16 | |
| 17 | ifeq ($(TARGET_PRODUCT),sdk) |
| 18 | supported_platforms := none |
| 19 | else |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 20 | supported_platforms := linux |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 21 | endif |
| 22 | |
Ying Wang | d87efbc | 2014-06-18 16:03:12 -0700 | [diff] [blame] | 23 | cur_platform := $(filter $(HOST_OS),$(supported_platforms)) |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 24 | |
| 25 | ifdef cur_platform |
| 26 | |
Fengwei Yin | 5f45339 | 2014-03-13 22:39:41 +0800 | [diff] [blame] | 27 | perf_arch := $(TARGET_ARCH) |
| 28 | ifeq ($(TARGET_ARCH), x86_64) |
| 29 | perf_arch := x86 |
| 30 | endif |
| 31 | |
Raghu Gandham | 37c9bb9 | 2014-04-14 18:24:00 -0700 | [diff] [blame] | 32 | ifeq ($(TARGET_ARCH), mips64) |
| 33 | perf_arch := mips |
| 34 | endif |
| 35 | |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 36 | # |
| 37 | # target libperf |
| 38 | # |
| 39 | libperf_src_files := \ |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 40 | 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 Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 122 | |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 123 | common_perf_headers := \ |
| 124 | $(LOCAL_PATH)/../lib \ |
| 125 | $(LOCAL_PATH)/util/include \ |
| 126 | $(LOCAL_PATH)/util \ |
| 127 | bionic/libc/kernel/uapi \ |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 128 | |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 129 | common_elfutil_headers := \ |
| 130 | external/elfutils \ |
| 131 | external/elfutils/0.153/libelf \ |
| 132 | external/elfutils/0.153/libdw \ |
| 133 | external/elfutils/0.153/libdwfl \ |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 134 | |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 135 | common_compiler_flags := \ |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 136 | -include external/linux-tools-perf/android-fixes.h \ |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 137 | -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 Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 151 | common_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 Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 174 | |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 175 | # glibc has the obsolete on_exit, which collides with perf's redefinition. |
| 176 | host_predefined_macros := \ |
| 177 | -DHAVE_ON_EXIT \ |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 178 | |
| 179 | include $(CLEAR_VARS) |
| 180 | |
| 181 | LOCAL_SRC_FILES := $(libperf_src_files) |
| 182 | |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 183 | LOCAL_CFLAGS += $(common_predefined_macros) |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 184 | LOCAL_CFLAGS += $(common_compiler_flags) |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 185 | LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers) |
| 186 | |
| 187 | LOCAL_MODULE := libperf |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 188 | LOCAL_MODULE_TAGS := eng |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 189 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 190 | |
| 191 | include $(BUILD_STATIC_LIBRARY) |
| 192 | |
| 193 | # |
| 194 | # host libperf |
| 195 | # |
| 196 | include $(CLEAR_VARS) |
| 197 | |
| 198 | LOCAL_SRC_FILES := $(libperf_src_files) |
| 199 | |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 200 | LOCAL_CFLAGS += $(common_predefined_macros) $(host_predefined_macros) |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 201 | LOCAL_CFLAGS += $(common_compiler_flags) |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 202 | LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers) |
Ben Cheng | 0da4803 | 2013-11-26 15:56:54 -0800 | [diff] [blame] | 203 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup |
| 204 | |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 205 | LOCAL_MODULE := libperf |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 206 | LOCAL_MODULE_TAGS := eng |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 207 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 208 | |
| 209 | include $(BUILD_HOST_STATIC_LIBRARY) |
| 210 | |
| 211 | # |
| 212 | # target perf |
| 213 | # |
| 214 | perf_src_files := \ |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 215 | perf.c \ |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 216 | bench/mem-memcpy.c \ |
| 217 | bench/mem-memset.c \ |
| 218 | bench/sched-messaging.c \ |
| 219 | bench/sched-pipe.c \ |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 220 | builtin-annotate.c \ |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 221 | builtin-bench.c \ |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 222 | 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 Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 229 | builtin-kvm.c \ |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 230 | 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 Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 241 | 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 | |
| 266 | perf_src_files_x86 = \ |
| 267 | arch/x86/util/tsc.c \ |
| 268 | tests/perf-time-to-tsc.c \ |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 269 | |
| 270 | include $(CLEAR_VARS) |
| 271 | |
| 272 | LOCAL_SRC_FILES := $(perf_src_files) |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 273 | LOCAL_SRC_FILES_x86 := $(perf_src_files_x86) |
| 274 | LOCAL_SRC_FILES_x86_64 := $(perf_src_files_x86) |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 275 | |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 276 | # TODO: this is only needed because of libebl below, which seems like a mistake on the target. |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 277 | LOCAL_SHARED_LIBRARIES := libdl |
| 278 | |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 279 | # TODO: there's probably more stuff here than is strictly necessary on the target. |
| 280 | LOCAL_STATIC_LIBRARIES := \ |
| 281 | libperf \ |
| 282 | libdwfl \ |
| 283 | libdw \ |
| 284 | libebl \ |
| 285 | libelf \ |
| 286 | libgccdemangle \ |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 287 | |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 288 | LOCAL_CFLAGS += $(common_predefined_macros) |
| 289 | LOCAL_CFLAGS += $(common_compiler_flags) |
| 290 | LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers) |
| 291 | |
| 292 | LOCAL_MODULE := perf |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 293 | LOCAL_MODULE_TAGS := eng |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 294 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 295 | |
| 296 | include $(BUILD_EXECUTABLE) |
| 297 | |
| 298 | # |
| 299 | # host perf |
| 300 | # |
| 301 | include $(CLEAR_VARS) |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 302 | |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 303 | LOCAL_SRC_FILES := $(perf_src_files) |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 304 | LOCAL_SRC_FILES_x86 := $(perf_src_files_x86) |
| 305 | LOCAL_SRC_FILES_x86_64 := $(perf_src_files_x86) |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 306 | |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 307 | # 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. |
| 310 | LOCAL_STATIC_LIBRARIES := \ |
| 311 | libperf \ |
| 312 | libdwfl \ |
| 313 | libdw \ |
| 314 | libebl \ |
| 315 | libelf \ |
| 316 | libgccdemangle \ |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 317 | |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 318 | LOCAL_CFLAGS += $(common_predefined_macros) $(host_predefined_macros) |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 319 | LOCAL_CFLAGS += $(common_compiler_flags) |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 320 | |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 321 | LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers) |
Ben Cheng | 0da4803 | 2013-11-26 15:56:54 -0800 | [diff] [blame] | 322 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup |
| 323 | |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 324 | LOCAL_C_INCLUDES += bionic/libc/kernel/uapi/asm-x86 # The kvm stuff needs <asm/svm.h>. |
Ben Cheng | 0da4803 | 2013-11-26 15:56:54 -0800 | [diff] [blame] | 325 | |
Elliott Hughes | f0ccdc5 | 2014-08-15 15:59:20 -0700 | [diff] [blame] | 326 | LOCAL_LDLIBS := -ldl -lpthread -lrt |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 327 | |
| 328 | LOCAL_MODULE := perfhost |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 329 | LOCAL_MODULE_TAGS := eng |
Elliott Hughes | efa9f00 | 2014-08-13 13:13:02 -0700 | [diff] [blame] | 330 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
Ben Cheng | f305579 | 2013-11-19 15:38:08 -0800 | [diff] [blame] | 331 | |
| 332 | include $(BUILD_HOST_EXECUTABLE) |
| 333 | |
| 334 | endif #cur_platform |