blob: 03ae4464ecd3e994f0484de84dffda84e66df9c6 [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 \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 xmlto-native \
34 asciidoc-native \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050035"
36
37do_configure[depends] += "virtual/kernel:do_shared_workdir"
38
39PROVIDES = "virtual/perf"
40
41inherit linux-kernel-base kernel-arch pythonnative
42
43# needed for building the tools/perf Python bindings
44inherit python-dir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045export PYTHON_SITEPACKAGES_DIR
46
47#kernel 3.1+ supports WERROR to disable warnings as errors
48export WERROR = "0"
49
50do_populate_lic[depends] += "virtual/kernel:do_patch"
51
52# needed for building the tools/perf Perl binding
53inherit perlnative cpan-base
54# Env var which tells perl if it should use host (no) or target (yes) settings
55export PERLCONFIGTARGET = "${@is_target(d)}"
56export PERL_INC = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}/CORE"
57export PERL_LIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}"
58export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}"
59
60inherit kernelsrc
61
62B = "${WORKDIR}/${BPN}-${PV}"
63SPDX_S = "${S}/tools/perf"
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)}"
68LIBNUMA_DEFINES = "${@perf_feature_enabled('perf-libnuma', '', 'NO_LIBNUMA=1',d)}"
Brad Bishop37a0e4d2017-12-04 01:01:44 -050069SYSTEMTAP_DEFINES = "${@perf_feature_enabled('perf-systemtap', '', 'NO_SDT=1', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070
71# The LDFLAGS is required or some old kernels fails due missing
72# symbols and this is preferred than requiring patches to every old
73# supported kernel.
74LDFLAGS="-ldl -lutil"
75
76EXTRA_OEMAKE = '\
77 -C ${S}/tools/perf \
78 O=${B} \
79 CROSS_COMPILE=${TARGET_PREFIX} \
80 ARCH=${ARCH} \
81 CC="${CC}" \
82 AR="${AR}" \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060083 LD="${LD}" \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 EXTRA_CFLAGS="-ldw" \
85 perfexecdir=${libexecdir} \
86 NO_GTK2=1 ${TUI_DEFINES} NO_DWARF=1 ${LIBUNWIND_DEFINES} \
Brad Bishop37a0e4d2017-12-04 01:01:44 -050087 ${SCRIPTING_DEFINES} ${LIBNUMA_DEFINES} ${SYSTEMTAP_DEFINES} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088'
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' \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097 '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
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103do_compile() {
104 # Linux kernel build system is expected to do the right thing
105 unset CFLAGS
106 oe_runmake all
107}
108
109do_install() {
110 # Linux kernel build system is expected to do the right thing
111 unset CFLAGS
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500112 oe_runmake install
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113 # we are checking for this make target to be compatible with older perf versions
114 if [ "${@perf_feature_enabled('perf-scripting', 1, 0, d)}" = "1" ] && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
115 oe_runmake DESTDIR=${D} install-python_ext
116 fi
117}
118
119do_configure_prepend () {
120 # Fix for rebuilding
121 rm -rf ${B}/
Patrick Williamsd7e96312015-09-22 08:09:05 -0500122 mkdir -p ${B}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123
124 # If building a multlib based perf, the incorrect library path will be
125 # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit
126 # build, with a 64 bit multilib, the arch won't match and the detection of a
127 # 64 bit build (and library) are not exected. To ensure that libraries are
128 # installed to the correct location, we can use the weak assignment in the
129 # config/Makefile.
130 #
131 # Also need to relocate .config-detected to $(OUTPUT)/config-detected
132 # for kernel sources that do not already do this
133 # as two builds (e.g. perf and lib32-perf from mutlilib can conflict
134 # with each other if its in the shared source directory
135 #
136 if [ -e "${S}/tools/perf/config/Makefile" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600137 perfconfig="${S}/tools/perf/config/Makefile"
138 fi
139 if [ -e "${S}/tools/perf/Makefile.config" ]; then
140 perfconfig="${S}/tools/perf/Makefile.config"
141 fi
142 if [ -n "${perfconfig}" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500143 # Match $(prefix)/$(lib) and $(prefix)/lib
144 sed -i -e 's,^libdir = \($(prefix)/.*lib\),libdir ?= \1,' \
145 -e 's,^perfexecdir = \(.*\),perfexecdir ?= \1,' \
146 -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600147 ${perfconfig}
148 fi
149 # The man pages installation is "$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)"
150 # in ${S}/tools/perf/Documentation/Makefile, if the mandir set to '?=', it
151 # will use the relative path 'share/man', in the way it will resulting in
152 # incorrect installation for man pages.
153 if [ -e "${S}/tools/perf/Documentation/Makefile" ]; then
154 sed -i 's,^mandir?=,mandir:=,' ${S}/tools/perf/Documentation/Makefile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500155 fi
156 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
157 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
158 ${S}/tools/perf/Makefile.perf
159 sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \
160 ${S}/tools/perf/Makefile.perf
161 fi
162 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 -0500163 ${S}/tools/perf/Makefile*
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164
165 if [ -e "${S}/tools/build/Makefile.build" ]; then
166 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
167 ${S}/tools/build/Makefile.build
168 fi
169
170 # We need to ensure the --sysroot option in CC is preserved
171 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
172 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf
173 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600174 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500175 fi
176 if [ -e "${S}/tools/lib/api/Makefile" ]; then
177 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile
178 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/api/Makefile
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600179 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/lib/api/Makefile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500181 if [ -e "${S}/tools/lib/subcmd/Makefile" ]; then
182 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/subcmd/Makefile
183 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/subcmd/Makefile
184 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500185 if [ -e "${S}/tools/perf/config/feature-checks/Makefile" ]; then
186 sed -i 's,CC := $(CROSS_COMPILE)gcc -MD,CC += -MD,' ${S}/tools/perf/config/feature-checks/Makefile
187 fi
188 if [ -e "${S}/tools/build/Makefile.feature" ]; then
189 sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature
190 fi
191
192 # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include
193 if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then
194 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
195 fi
196 if [ -e "${S}/tools/perf/arch/arm/util/unwind-libunwind.c" ] && [ -e "${S}/tools/perf/arch/arm/tests/dwarf-unwind.c" ]; then
197 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
198 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
199 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500200
201 # use /usr/bin/env instead of version specific python
202 for s in `find ${S}/tools/perf/scripts/python/ -name '*.py'`; do
203 sed -i 's,/usr/bin/python2,/usr/bin/env python,' "${s}"
204 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500205}
206
207python do_package_prepend() {
208 d.setVar('PKGV', d.getVar("KERNEL_VERSION", True).split("-")[0])
209}
210
211PACKAGE_ARCH = "${MACHINE_ARCH}"
212
213
214PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
215
216RDEPENDS_${PN} += "elfutils bash"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600217RDEPENDS_${PN}-doc += "man"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500218RDEPENDS_${PN}-archive =+ "bash"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500219RDEPENDS_${PN}-python =+ "bash python python-modules"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500220RDEPENDS_${PN}-perl =+ "bash perl perl-modules"
221RDEPENDS_${PN}-tests =+ "python"
222
223RSUGGESTS_SCRIPTING = "${@perf_feature_enabled('perf-scripting', '${PN}-perl ${PN}-python', '',d)}"
224RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
225
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600226#FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core /usr/lib64/traceevent ${libdir}/traceevent"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500227FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500228FILES_${PN}-archive = "${libdir}/perf/perf-core/perf-archive"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500229FILES_${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600230FILES_${PN}-python = "${libdir}/perf/perf-core/scripts/python ${PYTHON_SITEPACKAGES_DIR}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500231FILES_${PN}-python += "${libexecdir}/perf-core/scripts/python/*"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500232FILES_${PN}-perl = "${libdir}/perf/perf-core/scripts/perl"
233
234
235INHIBIT_PACKAGE_DEBUG_SPLIT="1"