1SUMMARY = "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." 8HOMEPAGE = "https://perf.wiki.kernel.org/index.php/Main_Page" 9 10LICENSE = "GPLv2" 11 12PR = "r9" 13 14PACKAGECONFIG ??= "scripting tui libunwind" 15PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python" 16# gui support was added with kernel 3.6.35 17# since 3.10 libnewt was replaced by slang 18# to cover a wide range of kernel we add both dependencies 19PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang" 20PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind" 21PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1" 22PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap" 23PACKAGECONFIG[jvmti] = ",NO_JVMTI=1" 24 25# libaudit support would need scripting to be enabled 26PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit" 27 28DEPENDS = " \ 29 virtual/${MLPREFIX}libc \ 30 ${MLPREFIX}elfutils \ 31 ${MLPREFIX}binutils \ 32 bison-native flex-native xz \ 33 xmlto-native \ 34 asciidoc-native \ 35" 36 37do_configure[depends] += "virtual/kernel:do_shared_workdir" 38 39PROVIDES = "virtual/perf" 40 41inherit linux-kernel-base kernel-arch 42 43# needed for building the tools/perf Python bindings 44inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'pythonnative', '', d)} 45inherit python-dir 46export PYTHON_SITEPACKAGES_DIR 47 48#kernel 3.1+ supports WERROR to disable warnings as errors 49export WERROR = "0" 50 51do_populate_lic[depends] += "virtual/kernel:do_patch" 52 53# needed for building the tools/perf Perl binding 54inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'perlnative', '', d)} 55inherit cpan-base 56# Env var which tells perl if it should use host (no) or target (yes) settings 57export PERLCONFIGTARGET = "${@is_target(d)}" 58export PERL_INC = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}/CORE" 59export PERL_LIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" 60export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" 61 62inherit kernelsrc 63 64S = "${WORKDIR}/${BP}" 65SPDX_S = "${S}/tools/perf" 66 67# The LDFLAGS is required or some old kernels fails due missing 68# symbols and this is preferred than requiring patches to every old 69# supported kernel. 70LDFLAGS="-ldl -lutil" 71 72EXTRA_OEMAKE = '\ 73 -C ${S}/tools/perf \ 74 O=${B} \ 75 CROSS_COMPILE=${TARGET_PREFIX} \ 76 ARCH=${ARCH} \ 77 CC="${CC}" \ 78 AR="${AR}" \ 79 LD="${LD}" \ 80 EXTRA_CFLAGS="-ldw" \ 81 EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \ 82 perfexecdir=${libexecdir} \ 83 NO_GTK2=1 NO_DWARF=1 \ 84 ${PACKAGECONFIG_CONFARGS} \ 85' 86 87EXTRA_OEMAKE += "\ 88 'DESTDIR=${D}' \ 89 'prefix=${prefix}' \ 90 'bindir=${bindir}' \ 91 'sharedir=${datadir}' \ 92 'sysconfdir=${sysconfdir}' \ 93 'perfexecdir=${libexecdir}/perf-core' \ 94 'ETC_PERFCONFIG=${@os.path.relpath(sysconfdir, prefix)}' \ 95 'sharedir=${@os.path.relpath(datadir, prefix)}' \ 96 'mandir=${@os.path.relpath(mandir, prefix)}' \ 97 'infodir=${@os.path.relpath(infodir, prefix)}' \ 98" 99 100PERF_SRC ?= "Makefile \ 101 include \ 102 tools/arch \ 103 tools/build \ 104 tools/include \ 105 tools/lib \ 106 tools/Makefile \ 107 tools/perf \ 108 tools/scripts \ 109" 110 111PERF_EXTRA_LDFLAGS = "" 112 113# MIPS N32 114PERF_EXTRA_LDFLAGS_mipsarchn32eb = "-m elf32btsmipn32" 115PERF_EXTRA_LDFLAGS_mipsarchn32el = "-m elf32ltsmipn32" 116 117do_compile() { 118 # Linux kernel build system is expected to do the right thing 119 unset CFLAGS 120 oe_runmake all 121} 122 123do_install() { 124 # Linux kernel build system is expected to do the right thing 125 unset CFLAGS 126 oe_runmake install 127 # we are checking for this make target to be compatible with older perf versions 128 if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then 129 oe_runmake DESTDIR=${D} install-python_ext 130 fi 131} 132 133do_configure[prefuncs] += "copy_perf_source_from_kernel" 134python copy_perf_source_from_kernel() { 135 sources = (d.getVar("PERF_SRC") or "").split() 136 src_dir = d.getVar("STAGING_KERNEL_DIR") 137 dest_dir = d.getVar("S") 138 bb.utils.mkdirhier(dest_dir) 139 for s in sources: 140 src = oe.path.join(src_dir, s) 141 dest = oe.path.join(dest_dir, s) 142 if os.path.isdir(src): 143 oe.path.copyhardlinktree(src, dest) 144 else: 145 bb.utils.copyfile(src, dest) 146} 147 148do_configure_prepend () { 149 # If building a multlib based perf, the incorrect library path will be 150 # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit 151 # build, with a 64 bit multilib, the arch won't match and the detection of a 152 # 64 bit build (and library) are not exected. To ensure that libraries are 153 # installed to the correct location, we can use the weak assignment in the 154 # config/Makefile. 155 # 156 # Also need to relocate .config-detected to $(OUTPUT)/config-detected 157 # for kernel sources that do not already do this 158 # as two builds (e.g. perf and lib32-perf from mutlilib can conflict 159 # with each other if its in the shared source directory 160 # 161 if [ -e "${S}/tools/perf/config/Makefile" ]; then 162 perfconfig="${S}/tools/perf/config/Makefile" 163 fi 164 if [ -e "${S}/tools/perf/Makefile.config" ]; then 165 perfconfig="${S}/tools/perf/Makefile.config" 166 fi 167 if [ -n "${perfconfig}" ]; then 168 # Match $(prefix)/$(lib) and $(prefix)/lib 169 sed -i -e 's,^libdir = \($(prefix)/.*lib\),libdir ?= \1,' \ 170 -e 's,^perfexecdir = \(.*\),perfexecdir ?= \1,' \ 171 -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ 172 ${perfconfig} 173 fi 174 # The man pages installation is "$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)" 175 # in ${S}/tools/perf/Documentation/Makefile, if the mandir set to '?=', it 176 # will use the relative path 'share/man', in the way it will resulting in 177 # incorrect installation for man pages. 178 if [ -e "${S}/tools/perf/Documentation/Makefile" ]; then 179 sed -i 's,^mandir?=,mandir:=,' ${S}/tools/perf/Documentation/Makefile 180 fi 181 if [ -e "${S}/tools/perf/Makefile.perf" ]; then 182 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ 183 ${S}/tools/perf/Makefile.perf 184 sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ 185 ${S}/tools/perf/Makefile.perf 186 fi 187 sed -i -e "s,--root='/\$(DESTDIR_SQ)',--prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ 188 ${S}/tools/perf/Makefile* 189 190 if [ -e "${S}/tools/build/Makefile.build" ]; then 191 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ 192 ${S}/tools/build/Makefile.build 193 fi 194 195 # We need to ensure the --sysroot option in CC is preserved 196 if [ -e "${S}/tools/perf/Makefile.perf" ]; then 197 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf 198 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf 199 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf 200 fi 201 if [ -e "${S}/tools/lib/api/Makefile" ]; then 202 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile 203 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/api/Makefile 204 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/lib/api/Makefile 205 fi 206 if [ -e "${S}/tools/lib/subcmd/Makefile" ]; then 207 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/subcmd/Makefile 208 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/subcmd/Makefile 209 fi 210 if [ -e "${S}/tools/perf/config/feature-checks/Makefile" ]; then 211 sed -i 's,CC := $(CROSS_COMPILE)gcc -MD,CC += -MD,' ${S}/tools/perf/config/feature-checks/Makefile 212 fi 213 if [ -e "${S}/tools/build/Makefile.feature" ]; then 214 sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature 215 fi 216 217 # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include 218 if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then 219 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 220 fi 221 if [ -e "${S}/tools/perf/arch/arm/util/unwind-libunwind.c" ] && [ -e "${S}/tools/perf/arch/arm/tests/dwarf-unwind.c" ]; then 222 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 223 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 224 fi 225 226 # use /usr/bin/env instead of version specific python 227 for s in `find ${S}/tools/perf/scripts/python/ -name '*.py'`; do 228 sed -i 's,/usr/bin/python2,/usr/bin/env python,' "${s}" 229 done 230} 231 232python do_package_prepend() { 233 d.setVar('PKGV', d.getVar("KERNEL_VERSION").split("-")[0]) 234} 235 236PACKAGE_ARCH = "${MACHINE_ARCH}" 237 238 239PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python" 240 241RDEPENDS_${PN} += "elfutils bash" 242RDEPENDS_${PN}-doc += "man" 243RDEPENDS_${PN}-archive =+ "bash" 244RDEPENDS_${PN}-python =+ "bash python python-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}" 245RDEPENDS_${PN}-perl =+ "bash perl perl-modules" 246RDEPENDS_${PN}-tests =+ "python" 247 248RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}" 249RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}" 250 251FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent" 252FILES_${PN}-archive = "${libdir}/perf/perf-core/perf-archive" 253FILES_${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests" 254FILES_${PN}-python = " \ 255 ${PYTHON_SITEPACKAGES_DIR} \ 256 ${libexecdir}/perf-core/scripts/python \ 257 " 258FILES_${PN}-perl = "${libexecdir}/perf-core/scripts/perl" 259 260 261INHIBIT_PACKAGE_DEBUG_SPLIT="1" 262