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 += "\ |
| 91 | 'prefix=${prefix}' \ |
| 92 | 'bindir=${bindir}' \ |
| 93 | 'sharedir=${datadir}' \ |
| 94 | 'sysconfdir=${sysconfdir}' \ |
| 95 | 'perfexecdir=${libexecdir}/perf-core' \ |
| 96 | \ |
| 97 | 'ETC_PERFCONFIG=${@os.path.relpath(sysconfdir, prefix)}' \ |
| 98 | 'sharedir=${@os.path.relpath(datadir, prefix)}' \ |
| 99 | 'mandir=${@os.path.relpath(mandir, prefix)}' \ |
| 100 | 'infodir=${@os.path.relpath(infodir, prefix)}' \ |
| 101 | " |
| 102 | |
| 103 | |
| 104 | do_compile() { |
| 105 | # Linux kernel build system is expected to do the right thing |
| 106 | unset CFLAGS |
| 107 | oe_runmake all |
| 108 | } |
| 109 | |
| 110 | do_install() { |
| 111 | # Linux kernel build system is expected to do the right thing |
| 112 | unset CFLAGS |
| 113 | oe_runmake DESTDIR=${D} install |
| 114 | # we are checking for this make target to be compatible with older perf versions |
| 115 | if [ "${@perf_feature_enabled('perf-scripting', 1, 0, d)}" = "1" ] && grep -q install-python_ext ${S}/tools/perf/Makefile*; then |
| 116 | oe_runmake DESTDIR=${D} install-python_ext |
| 117 | fi |
| 118 | } |
| 119 | |
| 120 | do_configure_prepend () { |
| 121 | # Fix for rebuilding |
| 122 | rm -rf ${B}/ |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame^] | 123 | mkdir -p ${B}/ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 124 | |
| 125 | # If building a multlib based perf, the incorrect library path will be |
| 126 | # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit |
| 127 | # build, with a 64 bit multilib, the arch won't match and the detection of a |
| 128 | # 64 bit build (and library) are not exected. To ensure that libraries are |
| 129 | # installed to the correct location, we can use the weak assignment in the |
| 130 | # config/Makefile. |
| 131 | # |
| 132 | # Also need to relocate .config-detected to $(OUTPUT)/config-detected |
| 133 | # for kernel sources that do not already do this |
| 134 | # as two builds (e.g. perf and lib32-perf from mutlilib can conflict |
| 135 | # with each other if its in the shared source directory |
| 136 | # |
| 137 | if [ -e "${S}/tools/perf/config/Makefile" ]; then |
| 138 | # Match $(prefix)/$(lib) and $(prefix)/lib |
| 139 | sed -i -e 's,^libdir = \($(prefix)/.*lib\),libdir ?= \1,' \ |
| 140 | -e 's,^perfexecdir = \(.*\),perfexecdir ?= \1,' \ |
| 141 | -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
| 142 | ${S}/tools/perf/config/Makefile |
| 143 | fi |
| 144 | if [ -e "${S}/tools/perf/Makefile.perf" ]; then |
| 145 | sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
| 146 | ${S}/tools/perf/Makefile.perf |
| 147 | sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ |
| 148 | ${S}/tools/perf/Makefile.perf |
| 149 | fi |
| 150 | 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^] | 151 | ${S}/tools/perf/Makefile* |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 152 | |
| 153 | if [ -e "${S}/tools/build/Makefile.build" ]; then |
| 154 | sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
| 155 | ${S}/tools/build/Makefile.build |
| 156 | fi |
| 157 | |
| 158 | # We need to ensure the --sysroot option in CC is preserved |
| 159 | if [ -e "${S}/tools/perf/Makefile.perf" ]; then |
| 160 | sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf |
| 161 | sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf |
| 162 | fi |
| 163 | if [ -e "${S}/tools/lib/api/Makefile" ]; then |
| 164 | sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile |
| 165 | sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/api/Makefile |
| 166 | fi |
| 167 | if [ -e "${S}/tools/perf/config/feature-checks/Makefile" ]; then |
| 168 | sed -i 's,CC := $(CROSS_COMPILE)gcc -MD,CC += -MD,' ${S}/tools/perf/config/feature-checks/Makefile |
| 169 | fi |
| 170 | if [ -e "${S}/tools/build/Makefile.feature" ]; then |
| 171 | sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature |
| 172 | fi |
| 173 | |
| 174 | # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include |
| 175 | if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then |
| 176 | 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 |
| 177 | fi |
| 178 | if [ -e "${S}/tools/perf/arch/arm/util/unwind-libunwind.c" ] && [ -e "${S}/tools/perf/arch/arm/tests/dwarf-unwind.c" ]; then |
| 179 | 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 |
| 180 | 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 |
| 181 | fi |
| 182 | } |
| 183 | |
| 184 | python do_package_prepend() { |
| 185 | d.setVar('PKGV', d.getVar("KERNEL_VERSION", True).split("-")[0]) |
| 186 | } |
| 187 | |
| 188 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 189 | |
| 190 | |
| 191 | PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python" |
| 192 | |
| 193 | RDEPENDS_${PN} += "elfutils bash" |
| 194 | RDEPENDS_${PN}-archive =+ "bash" |
| 195 | RDEPENDS_${PN}-python =+ "bash python" |
| 196 | RDEPENDS_${PN}-perl =+ "bash perl perl-modules" |
| 197 | RDEPENDS_${PN}-tests =+ "python" |
| 198 | |
| 199 | RSUGGESTS_SCRIPTING = "${@perf_feature_enabled('perf-scripting', '${PN}-perl ${PN}-python', '',d)}" |
| 200 | RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}" |
| 201 | |
| 202 | FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent" |
| 203 | FILES_${PN}-dbg += "${libdir}/python*/site-packages/.debug" |
| 204 | FILES_${PN}-archive = "${libdir}/perf/perf-core/perf-archive" |
| 205 | FILES_${PN}-tests = "${libdir}/perf/perf-core/tests" |
| 206 | FILES_${PN}-python = "${libdir}/python*/site-packages ${libdir}/perf/perf-core/scripts/python" |
| 207 | FILES_${PN}-perl = "${libdir}/perf/perf-core/scripts/perl" |
| 208 | |
| 209 | |
| 210 | INHIBIT_PACKAGE_DEBUG_SPLIT="1" |