2 # Copyright (C) 2015 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 LOCAL_PATH := $(call my-dir)
19 simpleperf_common_cppflags := -std=c++11 -Wall -Wextra -Werror -Wunused \
21 simpleperf_cppflags_target := $(simpleperf_common_cppflags) \
23 simpleperf_cppflags_host := $(simpleperf_common_cppflags) \
24 -DUSE_BIONIC_UAPI_HEADERS -I bionic/libc/kernel \
26 simpleperf_cppflags_host_linux := $(simpleperf_cppflags_host) \
28 simpleperf_cppflags_host_darwin := $(simpleperf_cppflags_host) \
29 -I $(LOCAL_PATH)/darwin_support/include \
31 LLVM_ROOT_PATH := external/llvm
32 include $(LLVM_ROOT_PATH)/llvm.mk
34 simpleperf_shared_libraries_target := \
39 simpleperf_shared_libraries_host_linux := \
43 simpleperf_shared_libraries_host_darwin := \
47 simpleperf_ldlibs_host_linux := -lrt \
51 # =========================================================
52 libsimpleperf_src_files := \
64 record_file_reader.cpp \
69 libsimpleperf_src_files_linux := \
76 event_selection_set.cpp \
77 record_file_writer.cpp \
80 libsimpleperf_src_files_darwin := \
81 darwin_support/darwin_support.cpp \
83 # libsimpleperf target
86 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
88 $(libsimpleperf_src_files) \
89 $(libsimpleperf_src_files_linux) \
91 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
92 LOCAL_MULTILIB := first
93 LOCAL_MODULE := libsimpleperf
94 LOCAL_MODULE_TAGS := debug
95 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
96 include $(LLVM_DEVICE_BUILD_MK)
97 include $(BUILD_STATIC_LIBRARY)
99 # libsimpleperf linux host
100 ifeq ($(HOST_OS),linux)
101 include $(CLEAR_VARS)
103 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_linux)
105 $(libsimpleperf_src_files) \
106 $(libsimpleperf_src_files_linux) \
108 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host_linux)
109 LOCAL_LDLIBS := $(simpleperf_ldlibs_host_linux)
110 LOCAL_MULTILIB := first
111 LOCAL_MODULE := libsimpleperf
112 LOCAL_MODULE_TAGS := optional
113 include $(LLVM_HOST_BUILD_MK)
114 include $(BUILD_HOST_STATIC_LIBRARY)
117 # libsimpleperf darwin host
118 ifeq ($(HOST_OS),darwin)
119 include $(CLEAR_VARS)
121 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_darwin)
123 $(libsimpleperf_src_files) \
124 $(libsimpleperf_src_files_darwin) \
126 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host_darwin)
127 LOCAL_MULTILIB := first
128 LOCAL_MODULE := libsimpleperf
129 LOCAL_MODULE_TAGS := optional
130 include $(LLVM_HOST_BUILD_MK)
131 include $(BUILD_HOST_SHARED_LIBRARY)
136 # =========================================================
139 include $(CLEAR_VARS)
141 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
142 LOCAL_SRC_FILES := main.cpp
143 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
144 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
145 LOCAL_MULTILIB := first
146 LOCAL_MODULE := simpleperf
147 LOCAL_MODULE_TAGS := debug
148 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
149 include $(BUILD_EXECUTABLE)
151 # simpleperf linux host
152 ifeq ($(HOST_OS),linux)
153 include $(CLEAR_VARS)
155 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_linux)
156 LOCAL_SRC_FILES := main.cpp
157 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
158 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host_linux)
159 LOCAL_MULTILIB := first
160 LOCAL_LDLIBS := $(simpleperf_ldlibs_host_linux)
161 LOCAL_MODULE := simpleperf
162 LOCAL_MODULE_TAGS := optional
163 include $(BUILD_HOST_EXECUTABLE)
166 # simpleperf darwin host
167 ifeq ($(HOST_OS),darwin)
168 include $(CLEAR_VARS)
170 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_darwin)
171 LOCAL_SRC_FILES := main.cpp
172 LOCAL_SHARED_LIBRARIES := \
174 $(simpleperf_shared_libraries_host_darwin) \
176 LOCAL_MULTILIB := first
177 LOCAL_MODULE := simpleperf
178 LOCAL_MODULE_TAGS := optional
179 include $(BUILD_HOST_EXECUTABLE)
183 # simpleperf_unit_test
184 # =========================================================
185 simpleperf_unit_test_src_files := \
189 sample_tree_test.cpp \
191 simpleperf_unit_test_src_files_linux := \
192 cmd_dumprecord_test.cpp \
194 cmd_record_test.cpp \
195 cmd_report_test.cpp \
197 cpu_offline_test.cpp \
198 environment_test.cpp \
200 record_file_test.cpp \
203 # simpleperf_unit_test target
204 include $(CLEAR_VARS)
206 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
208 $(simpleperf_unit_test_src_files) \
209 $(simpleperf_unit_test_src_files_linux) \
211 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
212 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
213 LOCAL_MULTILIB := first
214 LOCAL_MODULE := simpleperf_unit_test
215 LOCAL_MODULE_TAGS := optional
216 include $(BUILD_NATIVE_TEST)
218 # simpleperf_unit_test linux host
219 ifeq ($(HOST_OS),linux)
220 include $(CLEAR_VARS)
222 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_linux)
224 $(simpleperf_unit_test_src_files) \
225 $(simpleperf_unit_test_src_files_linux) \
227 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
228 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host_linux)
229 LOCAL_MULTILIB := first
230 LOCAL_MODULE := simpleperf_unit_test
231 LOCAL_MODULE_TAGS := optional
232 include $(BUILD_HOST_NATIVE_TEST)
235 # simpleperf_unit_test darwin host
236 ifeq ($(HOST_OS),darwin)
237 include $(CLEAR_VARS)
239 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_darwin)
240 LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files)
241 LOCAL_SHARED_LIBRARIES := \
243 $(simpleperf_shared_libraries_host_darwin) \
245 LOCAL_MULTILIB := first
246 LOCAL_MODULE := simpleperf_unit_test
247 LOCAL_MODULE_TAGS := optional
248 include $(BUILD_HOST_NATIVE_TEST)