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