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