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