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 20 supported_platforms := linux darwin 21 endif 22 23 cur_platform := $(filter $(HOST_OS),$(supported_platforms)) 24 25 ifdef cur_platform 26 27 perf_arch := $(TARGET_ARCH) 28 ifeq ($(TARGET_ARCH), x86_64) 29 perf_arch := x86 30 endif 31 32 ifeq ($(TARGET_ARCH), mips64) 33 perf_arch := mips 34 endif 35 36 libperf_src_files := \ 37 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 119 120 common_perf_headers := $(LOCAL_PATH)/../lib $(LOCAL_PATH)/util/include \ 121 $(LOCAL_PATH)/util $(LOCAL_PATH)/../../include/uapi 122 123 common_elfutil_headers := external/elfutils external/elfutils/0.153/libelf \ 124 external/elfutils/0.153/libdw external/elfutils/0.153/libdwfl 125 126 common_compiler_flags := \ 127 -DANDROID_PATCHES \ 128 -Wno-error \ 129 -std=gnu99 \ 130 -Wno-return-type \ 131 132 ifeq ($(strip $(HOST_OS)),linux) 133 common_compiler_flags += \ 134 -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 \ 141 -Wno-sign-compare \ 142 -Wno-unused-parameter \ 143 144 endif 145 146 ifeq ($(strip $(HOST_OS)),darwin) 147 host_compiler_flags := -include $(LOCAL_PATH)/host-darwin-fixup/AndroidFixup.h 148 endif 149 150 common_disabled_macros := -DNO_NEWT_SUPPORT -DNO_LIBPERL -DNO_LIBPYTHON \ 151 -DNO_GTK2 -DNO_LIBNUMA -DNO_LIBAUDIT 152 153 common_predefined_macros := -DDWARF_SUPPORT -DPYTHON='""' -DBINDIR='""' \ 154 -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 158 159 perf_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 # 185 include $(CLEAR_VARS) 186 187 LOCAL_SRC_FILES := $(libperf_src_files) 188 189 LOCAL_CFLAGS := $(common_disabled_macros) 190 LOCAL_CFLAGS += $(common_predefined_macros) 191 LOCAL_CFLAGS += $(common_compiler_flags) 192 LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers) 193 194 LOCAL_MODULE := libperf 195 LOCAL_MODULE_TAGS := eng 196 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 197 198 include $(BUILD_STATIC_LIBRARY) 199 200 # 201 # host libperf 202 # 203 include $(CLEAR_VARS) 204 205 LOCAL_SRC_FILES := $(libperf_src_files) 206 207 LOCAL_CFLAGS := $(common_disabled_macros) 208 LOCAL_CFLAGS += $(common_predefined_macros) 209 LOCAL_CFLAGS += $(common_compiler_flags) $(host_compiler_flags) 210 LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers) 211 LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup 212 213 LOCAL_MODULE := libperf 214 LOCAL_MODULE_TAGS := eng 215 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 216 217 LOCAL_CLANG := false 218 219 include $(BUILD_HOST_STATIC_LIBRARY) 220 221 # 222 # target perf 223 # 224 include $(CLEAR_VARS) 225 226 LOCAL_SRC_FILES := $(perf_src_files) 227 228 # TODO: this is only needed because of libebl below, which seems like a mistake on the target. 229 LOCAL_SHARED_LIBRARIES := libdl 230 231 # TODO: there's probably more stuff here than is strictly necessary on the target. 232 LOCAL_STATIC_LIBRARIES := \ 233 libperf \ 234 libdwfl \ 235 libdw \ 236 libebl \ 237 libelf \ 238 libgccdemangle \ 239 240 LOCAL_CFLAGS := $(common_disabled_macros) 241 LOCAL_CFLAGS += $(common_predefined_macros) 242 LOCAL_CFLAGS += $(common_compiler_flags) 243 LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers) 244 245 LOCAL_MODULE := perf 246 LOCAL_MODULE_TAGS := eng 247 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 248 249 include $(BUILD_EXECUTABLE) 250 251 # 252 # host perf 253 # 254 include $(CLEAR_VARS) 255 256 LOCAL_SRC_FILES := $(perf_src_files) 257 258 # 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. 261 LOCAL_STATIC_LIBRARIES := \ 262 libperf \ 263 libdwfl \ 264 libdw \ 265 libebl \ 266 libelf \ 267 libgccdemangle \ 268 269 LOCAL_CFLAGS := $(common_disabled_macros) 270 LOCAL_CFLAGS += $(common_predefined_macros) 271 LOCAL_CFLAGS += $(common_compiler_flags) $(host_compiler_flags) 272 273 # available on linux-x86 but not darwin-x86 274 ifeq ($(strip $(HOST_OS)),linux) 275 LOCAL_CFLAGS += -DHAVE_ON_EXIT 276 endif 277 278 LOCAL_C_INCLUDES := $(common_perf_headers) $(common_elfutil_headers) 279 LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup 280 281 # for pthread_* and clock_gettime 282 LOCAL_LDLIBS := -lpthread -ldl 283 284 ifeq ($(strip $(HOST_OS)),linux) 285 LOCAL_LDLIBS += -lrt 286 endif 287 288 LOCAL_MODULE := perfhost 289 LOCAL_MODULE_TAGS := eng 290 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 291 292 LOCAL_CLANG := false 293 294 include $(BUILD_HOST_EXECUTABLE) 295 296 endif #cur_platform 297