at 18.09-beta 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, audit, libbfd, openssl, systemtap, numactl 4, zlib, withGtk ? false, gtk2 ? null 5}: 6 7with lib; 8 9assert withGtk -> gtk2 != null; 10assert versionAtLeast kernel.version "3.12"; 11 12stdenv.mkDerivation { 13 name = "perf-linux-${kernel.version}"; 14 15 inherit (kernel) src; 16 17 preConfigure = '' 18 cd tools/perf 19 20 substituteInPlace Makefile \ 21 --replace /usr/include/elfutils $elfutils/include/elfutils 22 23 for x in util/build-id.c util/dso.c; do 24 substituteInPlace $x --replace /usr/lib/debug /run/current-system/sw/lib/debug 25 done 26 27 if [ -f bash_completion ]; then 28 sed -i 's,^have perf,_have perf,' bash_completion 29 fi 30 ''; 31 32 makeFlags = ["prefix=$(out)" "WERROR=0"] ++ kernel.makeFlags; 33 34 hardeningDisable = [ "format" ]; 35 36 # perf refers both to newt and slang 37 nativeBuildInputs = [ 38 asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt 39 flex bison libiberty audit makeWrapper pkgconfig python perl 40 ]; 41 buildInputs = [ 42 elfutils newt slang libunwind libbfd zlib openssl systemtap.stapBuild numactl 43 ] ++ stdenv.lib.optional withGtk gtk2; 44 45 # Note: we don't add elfutils to buildInputs, since it provides a 46 # bad `ld' and other stuff. 47 NIX_CFLAGS_COMPILE = 48 [ "-Wno-error=cpp" 49 "-Wno-error=bool-compare" 50 "-Wno-error=deprecated-declarations" 51 "-DOBJDUMP_PATH=\"${binutils}/bin/objdump\"" 52 ] 53 # gcc before 6 doesn't know these options 54 ++ stdenv.lib.optionals (hasPrefix "gcc-6" stdenv.cc.cc.name) [ 55 "-Wno-error=unused-const-variable" "-Wno-error=misleading-indentation" 56 ]; 57 58 doCheck = false; # requires "sparse" 59 doInstallCheck = false; # same 60 61 separateDebugInfo = true; 62 installFlags = "install install-man ASCIIDOC8=1 prefix=$(out)"; 63 64 preFixup = '' 65 wrapProgram $out/bin/perf \ 66 --prefix PATH : "${binutils}/bin" 67 ''; 68 69 meta = { 70 homepage = https://perf.wiki.kernel.org/; 71 description = "Linux tools to profile with performance counters"; 72 maintainers = with stdenv.lib.maintainers; [viric]; 73 platforms = with stdenv.lib.platforms; linux; 74 }; 75}