at 18.03-beta 66 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, 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 makeFlags; 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 [ -f bash_completion ] && sed -i 's,^have perf,_have perf,' bash_completion 28 export makeFlags="DESTDIR=$out WERROR=0 $makeFlags" 29 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DTIPDIR=\"$out/share/doc/perf-tip\"" 30 ''; 31 32 # perf refers both to newt and slang 33 nativeBuildInputs = [ asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt 34 flex bison libiberty libaudit makeWrapper pkgconfig python perl ]; 35 buildInputs = 36 [ elfutils newt slang libunwind libbfd zlib openssl systemtap.stapBuild numactl 37 ] ++ stdenv.lib.optional withGtk gtk2; 38 39 # Note: we don't add elfutils to buildInputs, since it provides a 40 # bad `ld' and other stuff. 41 NIX_CFLAGS_COMPILE = 42 [ "-Wno-error=cpp" 43 "-Wno-error=bool-compare" 44 "-Wno-error=deprecated-declarations" 45 "-DOBJDUMP_PATH=\"${binutils}/bin/objdump\"" 46 ] 47 # gcc before 6 doesn't know these options 48 ++ stdenv.lib.optionals (hasPrefix "gcc-6" stdenv.cc.cc.name) [ 49 "-Wno-error=unused-const-variable" "-Wno-error=misleading-indentation" 50 ]; 51 52 separateDebugInfo = true; 53 installFlags = "install install-man ASCIIDOC8=1"; 54 55 preFixup = '' 56 wrapProgram $out/bin/perf \ 57 --prefix PATH : "${binutils}/bin" 58 ''; 59 60 meta = { 61 homepage = https://perf.wiki.kernel.org/; 62 description = "Linux tools to profile with performance counters"; 63 maintainers = with stdenv.lib.maintainers; [viric]; 64 platforms = with stdenv.lib.platforms; linux; 65 }; 66}