blob: 22bd3c820055d2c23b600464f77140d0279a6b53 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "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 = " \
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
35do_configure[depends] += "virtual/kernel:do_shared_workdir"
36
37PROVIDES = "virtual/perf"
38
39inherit linux-kernel-base kernel-arch pythonnative
40
41# needed for building the tools/perf Python bindings
42inherit python-dir
43export STAGING_INCDIR
44export STAGING_LIBDIR
45export BUILD_SYS
46export HOST_SYS
47export PYTHON_SITEPACKAGES_DIR
48
49#kernel 3.1+ supports WERROR to disable warnings as errors
50export WERROR = "0"
51
52do_populate_lic[depends] += "virtual/kernel:do_patch"
53
54# needed for building the tools/perf Perl binding
55inherit perlnative cpan-base
56# Env var which tells perl if it should use host (no) or target (yes) settings
57export PERLCONFIGTARGET = "${@is_target(d)}"
58export PERL_INC = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}/CORE"
59export PERL_LIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}"
60export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}"
61
62inherit kernelsrc
63
64B = "${WORKDIR}/${BPN}-${PV}"
65SPDX_S = "${S}/tools/perf"
66
67SCRIPTING_DEFINES = "${@perf_feature_enabled('perf-scripting', '', 'NO_LIBPERL=1 NO_LIBPYTHON=1',d)}"
68TUI_DEFINES = "${@perf_feature_enabled('perf-tui', '', 'NO_NEWT=1',d)}"
69LIBUNWIND_DEFINES = "${@perf_feature_enabled('perf-libunwind', '', 'NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1',d)}"
70LIBNUMA_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.
75LDFLAGS="-ldl -lutil"
76
77EXTRA_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
90EXTRA_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
104do_compile() {
105 # Linux kernel build system is expected to do the right thing
106 unset CFLAGS
107 oe_runmake all
108}
109
110do_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
120do_configure_prepend () {
121 # Fix for rebuilding
122 rm -rf ${B}/
Patrick Williamsd7e96312015-09-22 08:09:05 -0500123 mkdir -p ${B}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124
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 Williamsd7e96312015-09-22 08:09:05 -0500151 ${S}/tools/perf/Makefile*
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500152
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
184python do_package_prepend() {
185 d.setVar('PKGV', d.getVar("KERNEL_VERSION", True).split("-")[0])
186}
187
188PACKAGE_ARCH = "${MACHINE_ARCH}"
189
190
191PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
192
193RDEPENDS_${PN} += "elfutils bash"
194RDEPENDS_${PN}-archive =+ "bash"
195RDEPENDS_${PN}-python =+ "bash python"
196RDEPENDS_${PN}-perl =+ "bash perl perl-modules"
197RDEPENDS_${PN}-tests =+ "python"
198
199RSUGGESTS_SCRIPTING = "${@perf_feature_enabled('perf-scripting', '${PN}-perl ${PN}-python', '',d)}"
200RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
201
202FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent"
203FILES_${PN}-dbg += "${libdir}/python*/site-packages/.debug"
204FILES_${PN}-archive = "${libdir}/perf/perf-core/perf-archive"
205FILES_${PN}-tests = "${libdir}/perf/perf-core/tests"
206FILES_${PN}-python = "${libdir}/python*/site-packages ${libdir}/perf/perf-core/scripts/python"
207FILES_${PN}-perl = "${libdir}/perf/perf-core/scripts/perl"
208
209
210INHIBIT_PACKAGE_DEBUG_SPLIT="1"