1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 )
7 inherit bash-completion-r1 estack eutils toolchain-funcs python-single-r1 linux-info
10 MY_PV="${MY_PV/-pre/-git}"
12 DESCRIPTION="Userland tools for Linux Performance Counters"
13 HOMEPAGE="https://perf.wiki.kernel.org/"
16 if [[ ${PV} == *_rc* ]] ; then
17 LINUX_VER=$(ver_cut 1-2).$(($(ver_cut 3)-1))
18 PATCH_VERSION=$(ver_cut 1-3)
19 LINUX_PATCH=patch-${PV//_/-}.xz
20 SRC_URI="mirror://kernel/linux/kernel/v${LINUX_V}/testing/${LINUX_PATCH}
21 mirror://kernel/linux/kernel/v${LINUX_V}/testing/v${PATCH_VERSION}/${LINUX_PATCH}"
22 elif [[ ${PV} == *.*.* ]] ; then
23 # stable-release series
24 LINUX_VER=$(ver_cut 1-2)
25 LINUX_PATCH=patch-${PV}.xz
26 SRC_URI="mirror://kernel/linux/kernel/v${LINUX_V}/${LINUX_PATCH}"
32 LINUX_SOURCES="linux-${LINUX_VER}.tar.xz"
33 SRC_URI+=" mirror://kernel/linux/kernel/v${LINUX_V}/${LINUX_SOURCES}"
37 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~mips ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux"
38 IUSE="audit clang crypt debug +demangle +doc gtk java lzma numa perl python slang systemtap unwind zlib"
40 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
42 RDEPEND="audit? ( sys-process/audit )
43 crypt? ( dev-libs/openssl:0= )
48 demangle? ( sys-libs/binutils-libs:= )
49 gtk? ( x11-libs/gtk+:2 )
50 java? ( virtual/jre:* )
51 lzma? ( app-arch/xz-utils )
52 numa? ( sys-process/numactl )
53 perl? ( dev-lang/perl )
54 python? ( ${PYTHON_DEPS} )
55 slang? ( sys-libs/slang )
56 systemtap? ( dev-util/systemtap )
57 unwind? ( sys-libs/libunwind )
58 zlib? ( sys-libs/zlib )
61 >=sys-kernel/linux-headers-4.19
62 ${LINUX_PATCH+dev-util/patchutils}
73 S_K="${WORKDIR}/linux-${LINUX_VER}"
76 CONFIG_CHECK="~PERF_EVENTS ~KALLSYMS"
80 use python && python-single-r1_pkg_setup
85 tools/arch tools/build tools/include tools/lib tools/perf tools/scripts
86 include lib "arch/*/lib"
89 # We expect the tar implementation to support the -j option (both
90 # GNU tar and libarchive's tar support that).
91 echo ">>> Unpacking ${LINUX_SOURCES} (${paths[*]}) to ${PWD}"
92 tar --wildcards -xpf "${DISTDIR}"/${LINUX_SOURCES} \
93 "${paths[@]/#/linux-${LINUX_VER}/}" || die
95 if [[ -n ${LINUX_PATCH} ]] ; then
96 eshopts_push -o noglob
97 ebegin "Filtering partial source patch"
98 filterdiff -p1 ${paths[@]/#/-i } -z "${DISTDIR}"/${LINUX_PATCH} \
100 eend $? || die "filterdiff failed"
106 [[ ${a} == ${LINUX_SOURCES} ]] && continue
107 [[ ${a} == ${LINUX_PATCH} ]] && continue
114 if [[ -n ${LINUX_PATCH} ]] ; then
116 eapply "${WORKDIR}"/${P}.patch
119 # Drop some upstream too-developer-oriented flags and fix the
120 # Makefile in general
122 -e "s:\$(sysconfdir_SQ)/bash_completion.d:$(get_bashcompdir):" \
123 "${S}"/Makefile.perf || die
124 # A few places still use -Werror w/out $(WERROR) protection.
125 sed -i -e 's:-Werror::' \
126 "${S}"/Makefile.perf "${S_K}"/tools/lib/bpf/Makefile || die
128 # Avoid the call to make kernelversion
129 echo "#define PERF_VERSION \"${MY_PV}\"" > PERF-VERSION-FILE
131 # The code likes to compile local assembly files which lack ELF markings.
132 find -name '*.S' -exec sed -i '$a.section .note.GNU-stack,"",%progbits' {} +
135 puse() { usex $1 "" no; }
137 # The arch parsing is a bit funky. The perf tools package is integrated
138 # into the kernel, so it wants an ARCH that looks like the kernel arch,
139 # but it also wants to know about the split value -- i386/x86_64 vs just
140 # x86. We can get that by telling the func to use an older linux version.
141 # It's kind of a hack, but not that bad ...
143 # LIBDIR sets a search path of perf-gtk.so. Bug 515954
145 local arch=$(tc-arch-kernel)
147 use java && java_dir="/etc/java-config-2/current-system-vm"
148 # FIXME: NO_CORESIGHT
149 # FIXME: NO_LIBBABELTRACE
151 CC="$(tc-getCC)" CXX="$(tc-getCXX)" AR="$(tc-getAR)" LD="$(tc-getLD)" \
152 prefix="${EPREFIX}/usr" bindir_relative="bin" \
153 EXTRA_CFLAGS="${CFLAGS}" \
156 LIBCLANGLLVM=$(usex clang 1 "") \
160 NO_DEMANGLE=$(puse demangle) \
161 NO_GTK2=$(puse gtk) \
162 NO_JVMTI=$(puse java) \
163 NO_LIBAUDIT=$(puse audit) \
167 NO_LIBCRYPTO=$(puse crypt) \
168 NO_LIBDW_DWARF_UNWIND="" \
170 NO_LIBNUMA=$(puse numa) \
171 NO_LIBPERL=$(puse perl) \
172 NO_LIBPYTHON=$(puse python) \
173 NO_LIBUNWIND=$(puse unwind) \
174 NO_SDT=$(puse systemtap) \
175 NO_SLANG=$(puse slang) \
176 NO_LZMA=$(puse lzma) \
179 LIBDIR="/usr/libexec/perf-core" \
184 # test-clang.bin not build with g++
186 pushd "${S_K}/tools/build/feature/" || die
187 make V=1 CXX=${CHOST}-clang++ test-clang.bin || die
190 perf_make -f Makefile.perf
191 use doc && perf_make -C Documentation
199 perf_make -f Makefile.perf install DESTDIR="${D}"
201 rm -rv "${D}"/usr/share/doc/perf-tip || die
204 mv "${D}"/usr/$(get_libdir)/libperf-gtk.so \
205 "${D}"/usr/libexec/perf-core || die
210 dodoc *txt Documentation/*.txt
212 HTML_DOCS="Documentation/*.html" einstalldocs
213 doman Documentation/*.1
219 elog "Without the doc USE flag you won't get any documentation nor man pages."
220 elog "And without man pages, you won't get any --help output for perf and its"