at release-16.03-start 53 lines 1.8 kB view raw
1{ lib, stdenv, kernel, elfutils, python, perl, newt, slang, asciidoc, xmlto 2, docbook_xsl, docbook_xml_dtd_45, libxslt, flex, bison, pkgconfig, libunwind, binutils 3, zlib, withGtk ? false, gtk ? null }: 4 5with lib; 6 7assert withGtk -> gtk != null; 8assert versionAtLeast kernel.version "3.12"; 9 10stdenv.mkDerivation { 11 name = "perf-linux-${kernel.version}"; 12 13 inherit (kernel) src patches; 14 15 preConfigure = '' 16 cd tools/perf 17 sed -i s,/usr/include/elfutils,$elfutils/include/elfutils, Makefile 18 ${optionalString (versionOlder kernel.version "3.13") "patch -p1 < ${./perf.diff}"} 19 [ -f bash_completion ] && sed -i 's,^have perf,_have perf,' bash_completion 20 export makeFlags="DESTDIR=$out $makeFlags" 21 ''; 22 23 # perf refers both to newt and slang 24 # binutils is required for libbfd. 25 nativeBuildInputs = [ asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt flex bison ]; 26 buildInputs = [ python perl newt slang pkgconfig libunwind binutils zlib ] ++ 27 stdenv.lib.optional withGtk gtk; 28 29 # Note: we don't add elfutils to buildInputs, since it provides a 30 # bad `ld' and other stuff. 31 NIX_CFLAGS_COMPILE = "-I${elfutils}/include -Wno-error=cpp"; 32 NIX_CFLAGS_LINK = "-L${elfutils}/lib"; 33 34 installFlags = "install install-man ASCIIDOC8=1"; 35 36 inherit elfutils; 37 38 crossAttrs = { 39 /* I don't want cross-python or cross-perl - 40 I don't know if cross-python even works */ 41 propagatedBuildInputs = [ elfutils.crossDrv newt.crossDrv ]; 42 makeFlags = "CROSS_COMPILE=${stdenv.cross.config}-"; 43 elfutils = elfutils.crossDrv; 44 inherit (kernel.crossDrv) src patches; 45 }; 46 47 meta = { 48 homepage = https://perf.wiki.kernel.org/; 49 description = "Linux tools to profile with performance counters"; 50 maintainers = with stdenv.lib.maintainers; [viric]; 51 platforms = with stdenv.lib.platforms; linux; 52 }; 53}