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 := -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 environment_test.cpp \
199 record_file_test.cpp \
202 # simpleperf_unit_test target
203 include $(CLEAR_VARS)
205 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
207 $(simpleperf_unit_test_src_files) \
208 $(simpleperf_unit_test_src_files_linux) \
210 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
211 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
212 LOCAL_MULTILIB := first
213 LOCAL_MODULE := simpleperf_unit_test
214 LOCAL_MODULE_TAGS := optional
215 include $(BUILD_NATIVE_TEST)
217 # simpleperf_unit_test linux host
218 ifeq ($(HOST_OS),linux)
219 include $(CLEAR_VARS)
221 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_linux)
223 $(simpleperf_unit_test_src_files) \
224 $(simpleperf_unit_test_src_files_linux) \
226 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
227 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host_linux)
228 LOCAL_MULTILIB := first
229 LOCAL_MODULE := simpleperf_unit_test
230 LOCAL_MODULE_TAGS := optional
231 include $(BUILD_HOST_NATIVE_TEST)
234 # simpleperf_unit_test darwin host
235 ifeq ($(HOST_OS),darwin)
236 include $(CLEAR_VARS)
238 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_darwin)
239 LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files)
240 LOCAL_SHARED_LIBRARIES := \
242 $(simpleperf_shared_libraries_host_darwin) \
244 LOCAL_MULTILIB := first
245 LOCAL_MODULE := simpleperf_unit_test
246 LOCAL_MODULE_TAGS := optional
247 include $(BUILD_HOST_NATIVE_TEST)
251 # simpleperf_cpu_hotplug_test
252 # =========================================================
253 simpleperf_cpu_hotplug_test_src_files := \
255 cpu_hotplug_test.cpp \
257 # simpleperf_cpu_hotplug_test target
258 include $(CLEAR_VARS)
260 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
261 LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
262 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
263 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
264 LOCAL_MULTILIB := first
265 LOCAL_MODULE := simpleperf_cpu_hotplug_test
266 LOCAL_MODULE_TAGS := optional
267 include $(BUILD_NATIVE_TEST)
269 # simpleperf_cpu_hotplug_test linux host
270 ifeq ($(HOST_OS),linux)
271 include $(CLEAR_VARS)
273 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host_linux)
274 LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
275 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
276 LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host_linux)
277 LOCAL_MULTILIB := first
278 LOCAL_MODULE := simpleperf_cpu_hotplug_test
279 LOCAL_MODULE_TAGS := optional
280 include $(BUILD_HOST_NATIVE_TEST)
283 include $(call first-makefiles-under,$(LOCAL_PATH))