1# 2# Copyright (C) 2015 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17LOCAL_PATH := $(call my-dir) 18 19simpleperf_common_cppflags := -Wextra -Wunused -Wno-unknown-pragmas 20 21simpleperf_cppflags_target := $(simpleperf_common_cppflags) 22 23simpleperf_cppflags_host := $(simpleperf_common_cppflags) \ 24 -DUSE_BIONIC_UAPI_HEADERS -I bionic/libc/kernel \ 25 26simpleperf_cppflags_host_darwin := -I $(LOCAL_PATH)/nonlinux_support/include 27simpleperf_cppflags_host_windows := -I $(LOCAL_PATH)/nonlinux_support/include 28 29 30LLVM_ROOT_PATH := external/llvm 31include $(LLVM_ROOT_PATH)/llvm.mk 32 33simpleperf_shared_libraries_target := \ 34 libbacktrace \ 35 libunwind \ 36 libbase \ 37 liblog \ 38 libutils \ 39 libLLVM \ 40 41simpleperf_static_libraries_target := \ 42 libbacktrace_offline \ 43 liblzma \ 44 libziparchive \ 45 libz \ 46 47simpleperf_static_libraries_host := \ 48 libziparchive-host \ 49 libbase \ 50 liblog \ 51 libz \ 52 libutils \ 53 libLLVMObject \ 54 libLLVMBitReader \ 55 libLLVMMC \ 56 libLLVMMCParser \ 57 libLLVMCore \ 58 libLLVMSupport \ 59 60simpleperf_static_libraries_host_linux := \ 61 libbacktrace_offline \ 62 libbacktrace \ 63 libunwind \ 64 libcutils \ 65 liblzma \ 66 67simpleperf_ldlibs_host_linux := -lrt 68 69# libsimpleperf 70# ========================================================= 71libsimpleperf_src_files := \ 72 callchain.cpp \ 73 cmd_dumprecord.cpp \ 74 cmd_help.cpp \ 75 cmd_report.cpp \ 76 command.cpp \ 77 dso.cpp \ 78 event_attr.cpp \ 79 event_type.cpp \ 80 perf_regs.cpp \ 81 read_apk.cpp \ 82 read_elf.cpp \ 83 record.cpp \ 84 record_file_reader.cpp \ 85 sample_tree.cpp \ 86 thread_tree.cpp \ 87 utils.cpp \ 88 89libsimpleperf_src_files_linux := \ 90 cmd_list.cpp \ 91 cmd_record.cpp \ 92 cmd_stat.cpp \ 93 dwarf_unwind.cpp \ 94 environment.cpp \ 95 event_fd.cpp \ 96 event_selection_set.cpp \ 97 record_file_writer.cpp \ 98 workload.cpp \ 99 100libsimpleperf_src_files_darwin := \ 101 nonlinux_support/nonlinux_support.cpp \ 102 103libsimpleperf_src_files_windows := \ 104 nonlinux_support/nonlinux_support.cpp \ 105 106# libsimpleperf target 107include $(CLEAR_VARS) 108LOCAL_CLANG := true 109LOCAL_MODULE := libsimpleperf 110LOCAL_MODULE_TAGS := debug 111LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 112LOCAL_CPPFLAGS := $(simpleperf_cppflags_target) 113LOCAL_SRC_FILES := \ 114 $(libsimpleperf_src_files) \ 115 $(libsimpleperf_src_files_linux) \ 116 117LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target) 118LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target) 119LOCAL_MULTILIB := first 120include $(LLVM_DEVICE_BUILD_MK) 121include $(BUILD_STATIC_LIBRARY) 122 123# libsimpleperf host 124include $(CLEAR_VARS) 125#LOCAL_CLANG := true # Comment it to build on windows. 126LOCAL_MODULE := libsimpleperf 127LOCAL_MODULE_HOST_OS := darwin linux windows 128LOCAL_CPPFLAGS := $(simpleperf_cppflags_host) 129LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin) 130LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux) 131LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows) 132LOCAL_SRC_FILES := $(libsimpleperf_src_files) 133LOCAL_SRC_FILES_darwin := $(libsimpleperf_src_files_darwin) 134LOCAL_SRC_FILES_linux := $(libsimpleperf_src_files_linux) 135LOCAL_SRC_FILES_windows := $(libsimpleperf_src_files_windows) 136LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host) 137LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) 138LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) 139LOCAL_MULTILIB := first 140include $(LLVM_HOST_BUILD_MK) 141include $(BUILD_HOST_STATIC_LIBRARY) 142 143 144# simpleperf 145# ========================================================= 146 147# simpleperf target 148include $(CLEAR_VARS) 149LOCAL_CLANG := true 150LOCAL_MODULE := simpleperf 151LOCAL_MODULE_TAGS := debug 152LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 153LOCAL_CPPFLAGS := $(simpleperf_cppflags_target) 154LOCAL_SRC_FILES := main.cpp 155LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_target) 156LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target) 157LOCAL_MULTILIB := first 158include $(BUILD_EXECUTABLE) 159 160# simpleperf host 161include $(CLEAR_VARS) 162LOCAL_MODULE := simpleperf 163LOCAL_MODULE_HOST_OS := darwin linux windows 164LOCAL_CPPFLAGS := $(simpleperf_cppflags_host) 165LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin) 166LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux) 167LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows) 168LOCAL_SRC_FILES := main.cpp 169LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host) 170LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) 171LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) 172LOCAL_MULTILIB := first 173include $(LLVM_HOST_BUILD_MK) 174include $(BUILD_HOST_EXECUTABLE) 175 176 177# simpleperf_unit_test 178# ========================================================= 179simpleperf_unit_test_src_files := \ 180 cmd_report_test.cpp \ 181 command_test.cpp \ 182 gtest_main.cpp \ 183 read_apk_test.cpp \ 184 read_elf_test.cpp \ 185 record_test.cpp \ 186 sample_tree_test.cpp \ 187 188simpleperf_unit_test_src_files_linux := \ 189 cmd_dumprecord_test.cpp \ 190 cmd_list_test.cpp \ 191 cmd_record_test.cpp \ 192 cmd_stat_test.cpp \ 193 environment_test.cpp \ 194 record_file_test.cpp \ 195 workload_test.cpp \ 196 197# simpleperf_unit_test target 198include $(CLEAR_VARS) 199LOCAL_CLANG := true 200LOCAL_MODULE := simpleperf_unit_test 201LOCAL_CPPFLAGS := $(simpleperf_cppflags_target) 202LOCAL_SRC_FILES := \ 203 $(simpleperf_unit_test_src_files) \ 204 $(simpleperf_unit_test_src_files_linux) \ 205 206LOCAL_STATIC_LIBRARIES += libsimpleperf $(simpleperf_static_libraries_target) 207LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target) 208LOCAL_MULTILIB := first 209include $(BUILD_NATIVE_TEST) 210 211# simpleperf_unit_test host 212include $(CLEAR_VARS) 213LOCAL_MODULE := simpleperf_unit_test 214LOCAL_MODULE_HOST_OS := darwin linux windows 215LOCAL_CPPFLAGS := $(simpleperf_cppflags_host) 216LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin) 217LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux) 218LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows) 219LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files) 220LOCAL_SRC_FILES_linux := $(simpleperf_unit_test_src_files_linux) 221LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host) 222LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) 223LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) 224LOCAL_MULTILIB := first 225include $(LLVM_HOST_BUILD_MK) 226include $(BUILD_HOST_NATIVE_TEST) 227 228 229# simpleperf_cpu_hotplug_test 230# ========================================================= 231simpleperf_cpu_hotplug_test_src_files := \ 232 cpu_hotplug_test.cpp \ 233 234# simpleperf_cpu_hotplug_test target 235include $(CLEAR_VARS) 236LOCAL_CLANG := true 237LOCAL_MODULE := simpleperf_cpu_hotplug_test 238LOCAL_CPPFLAGS := $(simpleperf_cppflags_target) 239LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files) 240LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_target) 241LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target) 242LOCAL_MULTILIB := first 243include $(BUILD_NATIVE_TEST) 244 245# simpleperf_cpu_hotplug_test linux host 246include $(CLEAR_VARS) 247LOCAL_CLANG := true 248LOCAL_MODULE := simpleperf_cpu_hotplug_test 249LOCAL_MODULE_HOST_OS := linux 250LOCAL_CPPFLAGS := $(simpleperf_cppflags_host) 251LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux) 252LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files) 253LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host) 254LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) 255LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) 256LOCAL_MULTILIB := first 257include $(LLVM_HOST_BUILD_MK) 258include $(BUILD_HOST_NATIVE_TEST) 259 260 261# libsimpleperf_cts_test 262# ========================================================= 263libsimpleperf_cts_test_src_files := \ 264 $(libsimpleperf_src_files) \ 265 $(libsimpleperf_src_files_linux) \ 266 $(simpleperf_unit_test_src_files) \ 267 $(simpleperf_unit_test_src_files_linux) \ 268 269# libsimpleperf_cts_test target 270include $(CLEAR_VARS) 271LOCAL_CLANG := true 272LOCAL_MODULE := libsimpleperf_cts_test 273LOCAL_CPPFLAGS := $(simpleperf_cppflags_target) -DIN_CTS_TEST 274LOCAL_SRC_FILES := $(libsimpleperf_cts_test_src_files) 275LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target) 276LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target) 277LOCAL_MULTILIB := both 278include $(LLVM_DEVICE_BUILD_MK) 279include $(BUILD_STATIC_TEST_LIBRARY) 280 281# libsimpleperf_cts_test linux host 282include $(CLEAR_VARS) 283LOCAL_CLANG := true 284LOCAL_MODULE := libsimpleperf_cts_test 285LOCAL_MODULE_HOST_OS := linux 286LOCAL_CPPFLAGS := $(simpleperf_cppflags_host) -DIN_CTS_TEST 287LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux) 288LOCAL_SRC_FILES := $(libsimpleperf_cts_test_src_files) 289LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host) 290LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) 291LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) 292LOCAL_MULTILIB := both 293include $(LLVM_HOST_BUILD_MK) 294include $(BUILD_HOST_STATIC_TEST_LIBRARY) 295 296include $(call first-makefiles-under,$(LOCAL_PATH)) 297