at 17.09-beta 65 lines 2.2 kB view raw
1{ lib, stdenv, kernel, elfutils, python, perl, newt, slang, asciidoc, xmlto, makeWrapper 2, docbook_xsl, docbook_xml_dtd_45, libxslt, flex, bison, pkgconfig, libunwind, binutils 3, libiberty, libaudit 4, zlib, withGtk ? false, gtk2 ? null }: 5 6with lib; 7 8assert withGtk -> gtk2 != null; 9assert versionAtLeast kernel.version "3.12"; 10 11stdenv.mkDerivation { 12 name = "perf-linux-${kernel.version}"; 13 14 inherit (kernel) src; 15 16 preConfigure = '' 17 cd tools/perf 18 sed -i s,/usr/include/elfutils,$elfutils/include/elfutils, Makefile 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 26 flex bison libiberty libaudit makeWrapper ]; 27 buildInputs = [ elfutils python perl newt slang pkgconfig libunwind binutils zlib ] ++ 28 stdenv.lib.optional withGtk gtk2; 29 30 # Note: we don't add elfutils to buildInputs, since it provides a 31 # bad `ld' and other stuff. 32 NIX_CFLAGS_COMPILE = 33 [ "-Wno-error=cpp" 34 "-Wno-error=bool-compare" 35 "-Wno-error=deprecated-declarations" 36 "-DOBJDUMP_PATH=\"${binutils}/bin/objdump\"" 37 ] 38 # gcc before 6 doesn't know these options 39 ++ stdenv.lib.optionals (hasPrefix "gcc-6" stdenv.cc.cc.name) [ 40 "-Wno-error=unused-const-variable" "-Wno-error=misleading-indentation" 41 ]; 42 43 installFlags = "install install-man ASCIIDOC8=1"; 44 45 preFixup = '' 46 wrapProgram $out/bin/perf \ 47 --prefix PATH : "${binutils}/bin" 48 ''; 49 50 crossAttrs = { 51 /* I don't want cross-python or cross-perl - 52 I don't know if cross-python even works */ 53 propagatedBuildInputs = [ elfutils.crossDrv newt.crossDrv ]; 54 makeFlags = "CROSS_COMPILE=${stdenv.cc.prefix}"; 55 elfutils = elfutils.crossDrv; 56 inherit (kernel.crossDrv) src patches; 57 }; 58 59 meta = { 60 homepage = https://perf.wiki.kernel.org/; 61 description = "Linux tools to profile with performance counters"; 62 maintainers = with stdenv.lib.maintainers; [viric]; 63 platforms = with stdenv.lib.platforms; linux; 64 }; 65}