summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/perf/perf.bb
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/perf/perf.bb')
-rw-r--r--meta/recipes-kernel/perf/perf.bb189
1 files changed, 189 insertions, 0 deletions
diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
new file mode 100644
index 0000000000..19772d87c9
--- /dev/null
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -0,0 +1,189 @@
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."
8
9LICENSE = "GPLv2"
10LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"
11
12PR = "r9"
13
14require perf-features.inc
15
16BUILDPERF_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
21TUI_DEPENDS = "${@perf_feature_enabled('perf-tui', 'libnewt slang', '',d)}"
22SCRIPTING_DEPENDS = "${@perf_feature_enabled('perf-scripting', 'perl python', '',d)}"
23LIBUNWIND_DEPENDS = "${@perf_feature_enabled('perf-libunwind', 'libunwind', '',d)}"
24
25DEPENDS = "virtual/kernel \
26 virtual/${MLPREFIX}libc \
27 ${MLPREFIX}elfutils \
28 ${MLPREFIX}binutils \
29 ${TUI_DEPENDS} \
30 ${SCRIPTING_DEPENDS} \
31 ${LIBUNWIND_DEPENDS} \
32 bison flex \
33"
34
35PROVIDES = "virtual/perf"
36
37inherit linux-kernel-base kernel-arch pythonnative
38
39# needed for building the tools/perf Python bindings
40inherit python-dir
41export STAGING_INCDIR
42export STAGING_LIBDIR
43export BUILD_SYS
44export HOST_SYS
45
46#kernel 3.1+ supports WERROR to disable warnings as errors
47export WERROR = "0"
48
49do_populate_lic[depends] += "virtual/kernel:do_populate_sysroot"
50
51# needed for building the tools/perf Perl binding
52inherit perlnative cpan-base
53# Env var which tells perl if it should use host (no) or target (yes) settings
54export PERLCONFIGTARGET = "${@is_target(d)}"
55export PERL_INC = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}/CORE"
56export PERL_LIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}"
57export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}"
58
59S = "${STAGING_KERNEL_DIR}"
60# The source should be ready after the do_unpack
61do_unpack[depends] += "virtual/kernel:do_populate_sysroot"
62
63B = "${WORKDIR}/${BPN}-${PV}"
64
65SCRIPTING_DEFINES = "${@perf_feature_enabled('perf-scripting', '', 'NO_LIBPERL=1 NO_LIBPYTHON=1',d)}"
66TUI_DEFINES = "${@perf_feature_enabled('perf-tui', '', 'NO_NEWT=1',d)}"
67LIBUNWIND_DEFINES = "${@perf_feature_enabled('perf-libunwind', '', 'NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1',d)}"
68
69# The LDFLAGS is required or some old kernels fails due missing
70# symbols and this is preferred than requiring patches to every old
71# supported kernel.
72LDFLAGS="-ldl -lutil"
73
74EXTRA_OEMAKE = '\
75 -C ${S}/tools/perf \
76 O=${B} \
77 CROSS_COMPILE=${TARGET_PREFIX} \
78 ARCH=${ARCH} \
79 CC="${CC}" \
80 AR="${AR}" \
81 EXTRA_CFLAGS="-ldw" \
82 perfexecdir=${libexecdir} \
83 NO_GTK2=1 ${TUI_DEFINES} NO_DWARF=1 ${LIBUNWIND_DEFINES} ${SCRIPTING_DEFINES} \
84'
85
86EXTRA_OEMAKE += "\
87 'prefix=${prefix}' \
88 'bindir=${bindir}' \
89 'sharedir=${datadir}' \
90 'sysconfdir=${sysconfdir}' \
91 'perfexecdir=${libexecdir}/perf-core' \
92 \
93 'ETC_PERFCONFIG=${@os.path.relpath(sysconfdir, prefix)}' \
94 'sharedir=${@os.path.relpath(datadir, prefix)}' \
95 'mandir=${@os.path.relpath(mandir, prefix)}' \
96 'infodir=${@os.path.relpath(infodir, prefix)}' \
97"
98
99PARALLEL_MAKE = ""
100
101do_compile() {
102 # Linux kernel build system is expected to do the right thing
103 unset CFLAGS
104 oe_runmake all
105}
106
107do_install() {
108 # Linux kernel build system is expected to do the right thing
109 unset CFLAGS
110 oe_runmake DESTDIR=${D} install
111 # we are checking for this make target to be compatible with older perf versions
112 if [ "${@perf_feature_enabled('perf-scripting', 1, 0, d)}" = "1" -a $(grep install-python_ext ${S}/tools/perf/Makefile) = "0" ]; then
113 oe_runmake DESTDIR=${D} install-python_ext
114 fi
115}
116
117do_configure_prepend () {
118 # Fix for rebuilding
119 rm -rf ${B}/
120 mkdir ${B}/
121
122 #kernels before 3.1 do not support WERROR env variable
123 sed -i 's,-Werror ,,' ${S}/tools/perf/Makefile
124 if [ -e "${S}/tools/perf/config/Makefile" ]; then
125 sed -i 's,-Werror ,,' ${S}/tools/perf/config/Makefile
126 fi
127
128 # If building a multlib based perf, the incorrect library path will be
129 # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit
130 # build, with a 64 bit multilib, the arch won't match and the detection of a
131 # 64 bit build (and library) are not exected. To ensure that libraries are
132 # installed to the correct location, we can use the weak assignment in the
133 # config/Makefile.
134 if [ -e "${S}/tools/perf/config/Makefile" ]; then
135 # Match $(prefix)/$(lib) and $(prefix)/lib
136 sed -i -e 's,^libdir = \($(prefix)/.*lib\),libdir ?= \1,' \
137 -e 's,^perfexecdir = \(.*\),perfexecdir ?= \1,' \
138 ${S}/tools/perf/config/Makefile
139 fi
140 # We need to ensure the --sysroot option in CC is preserved
141 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
142 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf
143 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf
144 fi
145 if [ -e "${S}/tools/lib/api/Makefile" ]; then
146 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile
147 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/api/Makefile
148 fi
149 if [ -e "${S}/tools/perf/config/feature-checks/Makefile" ]; then
150 sed -i 's,CC := $(CROSS_COMPILE)gcc -MD,CC += -MD,' ${S}/tools/perf/config/feature-checks/Makefile
151 fi
152
153 # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include
154 if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then
155 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
156 fi
157 if [ -e "${S}/tools/perf/arch/arm/util/unwind-libunwind.c" ] && [ -e "${S}/tools/perf/arch/arm/tests/dwarf-unwind.c" ]; then
158 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
159 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
160 fi
161}
162
163python do_package_prepend() {
164 bb.data.setVar('PKGV', get_kernelversion('${S}').split("-")[0], d)
165}
166
167PACKAGE_ARCH = "${MACHINE_ARCH}"
168
169
170PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
171
172RDEPENDS_${PN} += "elfutils"
173RDEPENDS_${PN}-archive =+ "bash"
174RDEPENDS_${PN}-python =+ "bash python"
175RDEPENDS_${PN}-perl =+ "bash perl perl-modules"
176RDEPENDS_${PN}-tests =+ "python"
177
178RSUGGESTS_SCRIPTING = "${@perf_feature_enabled('perf-scripting', '${PN}-perl ${PN}-python', '',d)}"
179RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
180
181FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent"
182FILES_${PN}-dbg += "${libdir}/python*/site-packages/.debug"
183FILES_${PN}-archive = "${libdir}/perf/perf-core/perf-archive"
184FILES_${PN}-tests = "${libdir}/perf/perf-core/tests"
185FILES_${PN}-python = "${libdir}/python*/site-packages ${libdir}/perf/perf-core/scripts/python"
186FILES_${PN}-perl = "${libdir}/perf/perf-core/scripts/perl"
187
188
189INHIBIT_PACKAGE_DEBUG_SPLIT="1"