blob: 3d6ffb30fb083e9c325419b2853b90626a504edb [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 += "\
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050091 'DESTDIR=${D}' \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092 '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
105do_compile() {
106 # Linux kernel build system is expected to do the right thing
107 unset CFLAGS
108 oe_runmake all
109}
110
111do_install() {
112 # Linux kernel build system is expected to do the right thing
113 unset CFLAGS
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500114 oe_runmake install
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115 # 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
121do_configure_prepend () {
122 # Fix for rebuilding
123 rm -rf ${B}/
Patrick Williamsd7e96312015-09-22 08:09:05 -0500124 mkdir -p ${B}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125
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 Williamsd7e96312015-09-22 08:09:05 -0500152 ${S}/tools/perf/Makefile*
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153
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 Williamsd8c66bc2016-06-20 12:57:21 -0500168 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 Williamsc124f4f2015-09-15 14:41:29 -0500172 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 Williamsd8c66bc2016-06-20 12:57:21 -0500187
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 Williamsc124f4f2015-09-15 14:41:29 -0500192}
193
194python do_package_prepend() {
195 d.setVar('PKGV', d.getVar("KERNEL_VERSION", True).split("-")[0])
196}
197
198PACKAGE_ARCH = "${MACHINE_ARCH}"
199
200
201PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
202
203RDEPENDS_${PN} += "elfutils bash"
204RDEPENDS_${PN}-archive =+ "bash"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500205RDEPENDS_${PN}-python =+ "bash python python-modules"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500206RDEPENDS_${PN}-perl =+ "bash perl perl-modules"
207RDEPENDS_${PN}-tests =+ "python"
208
209RSUGGESTS_SCRIPTING = "${@perf_feature_enabled('perf-scripting', '${PN}-perl ${PN}-python', '',d)}"
210RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
211
212FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500213FILES_${PN}-archive = "${libdir}/perf/perf-core/perf-archive"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500214FILES_${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500215FILES_${PN}-python = "${libdir}/python*/site-packages ${libdir}/perf/perf-core/scripts/python"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500216FILES_${PN}-python += "${libexecdir}/perf-core/scripts/python/*"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500217FILES_${PN}-perl = "${libdir}/perf/perf-core/scripts/perl"
218
219
220INHIBIT_PACKAGE_DEBUG_SPLIT="1"