blob: 67b01a7f65ab49605a99cbc0ab6a2c617e072c8c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Performance analysis tools for Linux"
2DESCRIPTION = "Performance counters for Linux are a new kernel-based \
3subsystem that provide a framework for all things \
4performance analysis. It covers hardware level \
5(CPU/PMU, Performance Monitoring Unit) features \
6and software features (software counters, tracepoints) \
7as well."
Joel Stanleye252c312017-12-14 15:11:12 +10308HOMEPAGE = "https://perf.wiki.kernel.org/index.php/Main_Page"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000010LICENSE = "GPL-2.0-only"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011
12PR = "r9"
13
Patrick Williamse760df82023-05-26 11:10:49 -050014PACKAGECONFIG ??= "scripting tui libunwind libtraceevent"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080015PACKAGECONFIG[dwarf] = ",NO_DWARF=1"
Patrick Williams2390b1b2022-11-03 13:47:49 -050016PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python3 python3-setuptools-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017# gui support was added with kernel 3.6.35
18# since 3.10 libnewt was replaced by slang
19# to cover a wide range of kernel we add both dependencies
Joel Stanleye252c312017-12-14 15:11:12 +103020PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang"
21PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind"
22PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1"
Patrick Williams92b42cb2022-09-03 06:53:57 -050023PACKAGECONFIG[bfd] = ",NO_LIBBFD=1"
Joel Stanleye252c312017-12-14 15:11:12 +103024PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap"
25PACKAGECONFIG[jvmti] = ",NO_JVMTI=1"
Brad Bishop316dfdd2018-06-25 12:45:53 -040026# libaudit support would need scripting to be enabled
27PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028PACKAGECONFIG[manpages] = ",,xmlto-native asciidoc-native"
Brad Bishop64c979e2019-11-04 13:55:29 -050029PACKAGECONFIG[cap] = ",,libcap"
Patrick Williamse760df82023-05-26 11:10:49 -050030PACKAGECONFIG[libtraceevent] = ",NO_LIBTRACEEVENT=1,libtraceevent"
Andrew Geisslerb7d28612020-07-24 16:15:54 -050031# Arm CoreSight
32PACKAGECONFIG[coresight] = "CORESIGHT=1,,opencsd"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080033
34# libunwind is not yet ported for some architectures
Patrick Williams213cb262021-08-07 19:21:33 -050035PACKAGECONFIG:remove:arc = "libunwind"
Patrick Williams213cb262021-08-07 19:21:33 -050036PACKAGECONFIG:remove:riscv32 = "libunwind"
Brad Bishop316dfdd2018-06-25 12:45:53 -040037
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038DEPENDS = " \
39 virtual/${MLPREFIX}libc \
40 ${MLPREFIX}elfutils \
41 ${MLPREFIX}binutils \
Brad Bishop316dfdd2018-06-25 12:45:53 -040042 bison-native flex-native xz \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043"
44
45do_configure[depends] += "virtual/kernel:do_shared_workdir"
46
47PROVIDES = "virtual/perf"
48
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080049inherit linux-kernel-base kernel-arch manpages
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050
51# needed for building the tools/perf Python bindings
Patrick Williams325e4992023-05-04 11:08:58 -050052inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'python3targetconfig', '', d)}
Brad Bishop79641f22019-09-10 07:20:22 -040053inherit python3-dir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054export PYTHON_SITEPACKAGES_DIR
55
56#kernel 3.1+ supports WERROR to disable warnings as errors
57export WERROR = "0"
58
Andrew Geissler82c905d2020-04-13 13:39:40 -050059do_populate_lic[depends] += "virtual/kernel:do_shared_workdir"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060
61# needed for building the tools/perf Perl binding
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080062include ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'perf-perl.inc', '', d)}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063
64inherit kernelsrc
65
Brad Bishop316dfdd2018-06-25 12:45:53 -040066S = "${WORKDIR}/${BP}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067SPDX_S = "${S}/tools/perf"
68
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069# The LDFLAGS is required or some old kernels fails due missing
70# symbols and this is preferred than requiring patches to every old
71# supported kernel.
72LDFLAGS="-ldl -lutil"
73
74EXTRA_OEMAKE = '\
Andrew Geissler635e0e42020-08-21 15:58:33 -050075 V=1 \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050076 -C ${S}/tools/perf \
77 O=${B} \
78 CROSS_COMPILE=${TARGET_PREFIX} \
79 ARCH=${ARCH} \
80 CC="${CC}" \
Andrew Geissler82c905d2020-04-13 13:39:40 -050081 CCLD="${CC}" \
82 LDSHARED="${CC} -shared" \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083 AR="${AR}" \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060084 LD="${LD}" \
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050085 EXTRA_CFLAGS="-ldw -I${S}" \
Andrew Geissler95ac1b82021-03-31 14:34:31 -050086 YFLAGS='-y --file-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}' \
Joel Stanleye252c312017-12-14 15:11:12 +103087 EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 perfexecdir=${libexecdir} \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080089 NO_GTK2=1 \
Joel Stanleye252c312017-12-14 15:11:12 +103090 ${PACKAGECONFIG_CONFARGS} \
Patrick Williamse760df82023-05-26 11:10:49 -050091 PKG_CONFIG=pkg-config \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080092 TMPDIR="${B}" \
Brad Bishop19323692019-04-05 15:28:33 -040093 LIBUNWIND_DIR=${STAGING_EXECPREFIXDIR} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094'
95
96EXTRA_OEMAKE += "\
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050097 'DESTDIR=${D}' \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098 'prefix=${prefix}' \
99 'bindir=${bindir}' \
100 'sharedir=${datadir}' \
101 'sysconfdir=${sysconfdir}' \
102 'perfexecdir=${libexecdir}/perf-core' \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103 'ETC_PERFCONFIG=${@os.path.relpath(sysconfdir, prefix)}' \
104 'sharedir=${@os.path.relpath(datadir, prefix)}' \
105 'mandir=${@os.path.relpath(mandir, prefix)}' \
106 'infodir=${@os.path.relpath(infodir, prefix)}' \
Brad Bishop79641f22019-09-10 07:20:22 -0400107 ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108"
109
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700110# During do_configure, we might run a 'make clean'. That often breaks
111# when done in parallel, so disable parallelism for do_configure. Note
112# that it has to be done this way rather than by passing -j1, since
113# perf's build system by default ignores any -j argument, but does
114# honour a JOBS variable.
Patrick Williams213cb262021-08-07 19:21:33 -0500115EXTRA_OEMAKE:append:task-configure = " JOBS=1"
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700116
Brad Bishop316dfdd2018-06-25 12:45:53 -0400117PERF_SRC ?= "Makefile \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400118 tools/arch \
119 tools/build \
120 tools/include \
121 tools/lib \
122 tools/Makefile \
123 tools/perf \
124 tools/scripts \
Brad Bishop64c979e2019-11-04 13:55:29 -0500125 scripts/ \
126 arch/${ARCH}/Makefile \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400127"
128
Joel Stanleye252c312017-12-14 15:11:12 +1030129PERF_EXTRA_LDFLAGS = ""
130
Andrew Geissler595f6302022-01-24 19:11:47 +0000131# MIPS N32/N64
Patrick Williams213cb262021-08-07 19:21:33 -0500132PERF_EXTRA_LDFLAGS:mipsarchn32eb = "-m elf32btsmipn32"
133PERF_EXTRA_LDFLAGS:mipsarchn32el = "-m elf32ltsmipn32"
Andrew Geissler595f6302022-01-24 19:11:47 +0000134PERF_EXTRA_LDFLAGS:mipsarchn64eb = "-m elf64btsmip"
135PERF_EXTRA_LDFLAGS:mipsarchn64el = "-m elf64ltsmip"
Joel Stanleye252c312017-12-14 15:11:12 +1030136
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500137do_compile() {
138 # Linux kernel build system is expected to do the right thing
139 unset CFLAGS
140 oe_runmake all
141}
142
143do_install() {
144 # Linux kernel build system is expected to do the right thing
145 unset CFLAGS
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500146 oe_runmake install
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147 # we are checking for this make target to be compatible with older perf versions
Joel Stanleye252c312017-12-14 15:11:12 +1030148 if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
Brad Bishop79641f22019-09-10 07:20:22 -0400149 oe_runmake DESTDIR=${D} install-python_ext
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500150 if [ -e ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt ]; then
151 sed -i -e 's#${WORKDIR}##g' ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt
152 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153 fi
154}
155
Brad Bishop316dfdd2018-06-25 12:45:53 -0400156do_configure[prefuncs] += "copy_perf_source_from_kernel"
157python copy_perf_source_from_kernel() {
158 sources = (d.getVar("PERF_SRC") or "").split()
159 src_dir = d.getVar("STAGING_KERNEL_DIR")
160 dest_dir = d.getVar("S")
161 bb.utils.mkdirhier(dest_dir)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500162 bb.utils.prunedir(dest_dir)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400163 for s in sources:
164 src = oe.path.join(src_dir, s)
165 dest = oe.path.join(dest_dir, s)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800166 if not os.path.exists(src):
167 bb.fatal("Path does not exist: %s. Maybe PERF_SRC does not match the kernel version." % src)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400168 if os.path.isdir(src):
169 oe.path.copyhardlinktree(src, dest)
170 else:
Brad Bishop64c979e2019-11-04 13:55:29 -0500171 src_path = os.path.dirname(s)
172 os.makedirs(os.path.join(dest_dir,src_path),exist_ok=True)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400173 bb.utils.copyfile(src, dest)
174}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500175
Patrick Williams213cb262021-08-07 19:21:33 -0500176do_configure:prepend () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177 # If building a multlib based perf, the incorrect library path will be
178 # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700179 # build, with a 64 bit multilib, the arch won't match and the detection of a
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180 # 64 bit build (and library) are not exected. To ensure that libraries are
181 # installed to the correct location, we can use the weak assignment in the
182 # config/Makefile.
183 #
184 # Also need to relocate .config-detected to $(OUTPUT)/config-detected
185 # for kernel sources that do not already do this
186 # as two builds (e.g. perf and lib32-perf from mutlilib can conflict
187 # with each other if its in the shared source directory
188 #
189 if [ -e "${S}/tools/perf/config/Makefile" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600190 perfconfig="${S}/tools/perf/config/Makefile"
191 fi
192 if [ -e "${S}/tools/perf/Makefile.config" ]; then
193 perfconfig="${S}/tools/perf/Makefile.config"
194 fi
195 if [ -n "${perfconfig}" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500196 # Match $(prefix)/$(lib) and $(prefix)/lib
197 sed -i -e 's,^libdir = \($(prefix)/.*lib\),libdir ?= \1,' \
198 -e 's,^perfexecdir = \(.*\),perfexecdir ?= \1,' \
199 -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600200 ${perfconfig}
201 fi
202 # The man pages installation is "$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)"
203 # in ${S}/tools/perf/Documentation/Makefile, if the mandir set to '?=', it
204 # will use the relative path 'share/man', in the way it will resulting in
205 # incorrect installation for man pages.
206 if [ -e "${S}/tools/perf/Documentation/Makefile" ]; then
207 sed -i 's,^mandir?=,mandir:=,' ${S}/tools/perf/Documentation/Makefile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500208 fi
209 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
210 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
211 ${S}/tools/perf/Makefile.perf
Patrick Williams92b42cb2022-09-03 06:53:57 -0500212 sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(PYTHON_SITEPACKAGES_DIR)' --root='\$(DESTDIR)',g" \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500213 ${S}/tools/perf/Makefile.perf
Andrew Geissler635e0e42020-08-21 15:58:33 -0500214 # backport https://github.com/torvalds/linux/commit/e4ffd066ff440a57097e9140fa9e16ceef905de8
215 sed -i -e 's,\($(Q)$(SHELL) .$(arch_errno_tbl).\) $(CC) $(arch_errno_hdr_dir),\1 $(firstword $(CC)) $(arch_errno_hdr_dir),g' \
216 ${S}/tools/perf/Makefile.perf
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500217 fi
218 sed -i -e "s,--root='/\$(DESTDIR_SQ)',--prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \
Patrick Williamsd7e96312015-09-22 08:09:05 -0500219 ${S}/tools/perf/Makefile*
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500220
221 if [ -e "${S}/tools/build/Makefile.build" ]; then
222 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
223 ${S}/tools/build/Makefile.build
224 fi
225
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500226 # start reproducibility substitutions
227 if [ -e "${S}/tools/perf/Makefile.config" ]; then
228 # The following line in the Makefle:
229 # override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON_AUTO))
230 # "PYTHON" / "PYTHON_AUTO" have the full path as part of the variable. We've
231 # ensure that the environment is setup and we do not need the full path to be
232 # captured, since the symbol gets built into the executable, making it not
233 # reproducible.
234 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO))),g' \
235 ${S}/tools/perf/Makefile.config
Patrick Williamsdb4c27e2022-08-05 08:10:29 -0500236 # The same line is in older releases, but looking explicitly for Python 2
237 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON2)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON2))),g' \
238 ${S}/tools/perf/Makefile.config
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500239
Andrew Geissler615f2f12022-07-15 14:00:58 -0500240 # likewise with this substitution. Kernels with commit 18f2967418d031a39
241 # [perf tools: Use Python devtools for version autodetection rather than runtime]
242 # need this substitution for reproducibility.
243 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(subst -config\,\,$(PYTHON_AUTO))),$(notdir $(call get-executable-or-default\,PYTHON\,$(subst -config\,\,$(PYTHON_AUTO)))),g' \
244 ${S}/tools/perf/Makefile.config
245
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500246 # The following line:
247 # srcdir_SQ = $(patsubst %tools/perf,tools/perf,$(subst ','\'',$(srcdir))),
248 # Captures the full src path of perf, which of course makes it not
249 # reproducible. We really only need the relative location 'tools/perf', so we
250 # change the Makefile line to remove everything before 'tools/perf'
251 sed -i -e "s%srcdir_SQ = \$(subst ','\\\'',\$(srcdir))%srcdir_SQ = \$(patsubst \%tools/perf,tools/perf,\$(subst ','\\\'',\$(srcdir)))%g" \
252 ${S}/tools/perf/Makefile.config
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500253 # Avoid hardcoded path to python-native
254 sed -i -e 's#\(PYTHON_WORD := \)$(call shell-wordify,$(PYTHON))#\1 python3#g' \
255 ${S}/tools/perf/Makefile.config
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500256 fi
257 if [ -e "${S}/tools/perf/tests/Build" ]; then
258 # OUTPUT is the full path, we have python on the path so we remove it from the
259 # definition. This is captured in the perf binary, so breaks reproducibility
260 sed -i -e 's,PYTHONPATH="BUILD_STR($(OUTPUT)python)",PYTHONPATH="BUILD_STR(python)",g' \
261 ${S}/tools/perf/tests/Build
262 fi
263 if [ -e "${S}/tools/perf/util/Build" ]; then
264 # To avoid bison generating #ifdefs that have captured paths, we make sure
265 # all the calls have YFLAGS, which contains prefix mapping information.
266 sed -i -e 's,$(BISON),$(BISON) $(YFLAGS),g' ${S}/tools/perf/util/Build
267 fi
268 if [ -e "${S}/scripts/Makefile.host" ]; then
269 # To avoid yacc (bison) generating #ifdefs that have captured paths, we make sure
270 # all the calls have YFLAGS, which contains prefix mapping information.
271 sed -i -e 's,$(YACC),$(YACC) $(YFLAGS),g' ${S}/scripts/Makefile.host
272 fi
273 if [ -e "${S}/tools/perf/pmu-events/Build" ]; then
274 target='$(OUTPUT)pmu-events/pmu-events.c $(V)'
275 replacement1='$(OUTPUT)pmu-events/pmu-events.c $(V)\n'
276 replacement2='\t$(srctree)/sort-pmuevents.py $(OUTPUT)pmu-events/pmu-events.c $(OUTPUT)pmu-events/pmu-events.c.new\n'
277 replacement3='\tcp $(OUTPUT)pmu-events/pmu-events.c.new $(OUTPUT)pmu-events/pmu-events.c'
278 sed -i -e "s,$target,$replacement1$replacement2$replacement3,g" \
279 "${S}/tools/perf/pmu-events/Build"
280 fi
Patrick Williams864cc432023-02-09 14:54:44 -0600281 if [ -e "${S}/tools/perf/pmu-events/jevents.py" ]; then
282 sed -i -e "s#os.scandir(path)#sorted(os.scandir(path), key=lambda e: e.name)#g" \
283 "${S}/tools/perf/pmu-events/jevents.py"
284 fi
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500285 if [ -e "${S}/tools/perf/arch/arm64/Makefile" ]; then
286 sed -i 's,sysdef := $(srctree)/,sysdef := ,' ${S}/tools/perf/arch/arm64/Makefile
287 sed -i 's,$(incpath) $(sysdef),$(incpath) $(srctree)/$(sysdef) $(sysdef),' ${S}/tools/perf/arch/arm64/Makefile
288 fi
289 if [ -e "${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl" ]; then
290 if ! grep -q input_rel ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl; then
291 sed -i 's,input=$4,input=$4\ninput_rel=$5,' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
292 fi
293 sed -i 's,#include \\"\$input\\",#include \\"\$input_rel\\",' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
294 fi
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500295 # end reproducibility substitutions
296
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500297 # We need to ensure the --sysroot option in CC is preserved
298 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
299 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf
300 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600301 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf
Patrick Williamse760df82023-05-26 11:10:49 -0500302 sed -i 's,PKG_CONFIG = $(CROSS_COMPILE)pkg-config,#PKG_CONFIG,' ${S}/tools/perf/Makefile.perf
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500303 fi
304 if [ -e "${S}/tools/lib/api/Makefile" ]; then
305 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile
306 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/api/Makefile
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600307 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/lib/api/Makefile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500308 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500309 if [ -e "${S}/tools/lib/subcmd/Makefile" ]; then
310 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/subcmd/Makefile
311 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/subcmd/Makefile
312 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500313 if [ -e "${S}/tools/perf/config/feature-checks/Makefile" ]; then
314 sed -i 's,CC := $(CROSS_COMPILE)gcc -MD,CC += -MD,' ${S}/tools/perf/config/feature-checks/Makefile
315 fi
316 if [ -e "${S}/tools/build/Makefile.feature" ]; then
317 sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature
318 fi
319
320 # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include
321 if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then
322 sed -i 's,#include "util/callchain.h",#include "util/callchain.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c
323 fi
324 if [ -e "${S}/tools/perf/arch/arm/util/unwind-libunwind.c" ] && [ -e "${S}/tools/perf/arch/arm/tests/dwarf-unwind.c" ]; then
325 sed -i 's,#include "tests/tests.h",#include "tests/tests.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/arm/tests/dwarf-unwind.c
326 sed -i 's,#include "perf_regs.h",#include "perf_regs.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/arm/util/unwind-libunwind.c
327 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500328
329 # use /usr/bin/env instead of version specific python
Andrew Geissler82c905d2020-04-13 13:39:40 -0500330 for s in `find ${S}/tools/perf/ -name '*.py'` `find ${S}/scripts/ -name 'bpf_helpers_doc.py'`; do
331 sed -i -e "s,#!.*python.*,#!${USRBINPATH}/env python3," ${s}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500332 done
Brad Bishop19323692019-04-05 15:28:33 -0400333
334 # unistd.h can be out of sync between libc-headers and the captured version in the perf source
335 # so we copy it from the sysroot unistd.h to the perf unistd.h
Brad Bishopc342db32019-05-15 21:57:59 -0400336 install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/tools/include/uapi/asm-generic/unistd.h
Brad Bishop79641f22019-09-10 07:20:22 -0400337 install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/include/uapi/asm-generic/unistd.h
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500338
339 # the fetcher is inhibited by the 'inherit kernelsrc', so we do a quick check and
340 # copy for a helper script we need
341 for p in $(echo ${FILESPATH} | tr ':' '\n'); do
342 if [ -e $p/sort-pmuevents.py ]; then
343 cp $p/sort-pmuevents.py ${S}
344 fi
345 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500346}
347
Patrick Williams213cb262021-08-07 19:21:33 -0500348python do_package:prepend() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500349 d.setVar('PKGV', d.getVar("KERNEL_VERSION").split("-")[0])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500350}
351
352PACKAGE_ARCH = "${MACHINE_ARCH}"
353
354
355PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
356
Patrick Williams213cb262021-08-07 19:21:33 -0500357RDEPENDS:${PN} += "elfutils bash"
358RDEPENDS:${PN}-archive =+ "bash"
359RDEPENDS:${PN}-python =+ "bash python3 python3-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}"
360RDEPENDS:${PN}-perl =+ "bash perl perl-modules"
361RDEPENDS:${PN}-tests =+ "python3 bash"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500362
Joel Stanleye252c312017-12-14 15:11:12 +1030363RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}"
Patrick Williams213cb262021-08-07 19:21:33 -0500364RSUGGESTS:${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500365
Brad Bishop19323692019-04-05 15:28:33 -0400366FILES_SOLIBSDEV = ""
Patrick Williams213cb262021-08-07 19:21:33 -0500367FILES:${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent ${libdir}/libperf-jvmti.so"
368FILES:${PN}-archive = "${libdir}/perf/perf-core/perf-archive"
369FILES:${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests"
370FILES:${PN}-python = " \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400371 ${PYTHON_SITEPACKAGES_DIR} \
372 ${libexecdir}/perf-core/scripts/python \
373 "
Patrick Williams213cb262021-08-07 19:21:33 -0500374FILES:${PN}-perl = "${libexecdir}/perf-core/scripts/perl"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500375
Patrick Williams213cb262021-08-07 19:21:33 -0500376DEBUG_OPTIMIZATION:append = " -Wno-error=maybe-uninitialized"
Patrick Williams864cc432023-02-09 14:54:44 -0600377
378PACKAGESPLITFUNCS =+ "perf_fix_sources"
379
380perf_fix_sources () {
381 for f in util/parse-events-flex.h util/parse-events-flex.c util/pmu-flex.c \
382 util/expr-flex.h util/expr-flex.c; do
383 f=${PKGD}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/$f
384 if [ -e $f ]; then
385 sed -i -e 's#${S}/##g' $f
386 fi
387 done
388}