summary refs log tree commit diff
path: root/pkgs/development/tools/profiling/oprofile/default.nix
blob: 143704126f444043198f4bc6cccf26bcae18c1e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ stdenv, fetchurl, binutils, popt, makeWrapper, gawk, which, gnugrep, zlib
, qt ? null, libX11 ? null, libXext ? null, libpng ? null }:

# libX11 is needed because the Qt build stuff automatically adds `-lX11'.
assert (qt != null) -> ((libX11 != null) && (libXext != null)
                        && (libpng != null));

stdenv.mkDerivation rec {
  name = "oprofile-0.9.6";

  src = fetchurl {
    url = "mirror://sourceforge/oprofile/${name}.tar.gz";
    sha256 = "103q0w4wr5lnhg1yfdhc67dvdwzqpzml57fp4l6nbz29fw5d839z";
  };

  patchPhase = ''
    sed -i "utils/opcontrol" \
        -e "s|OPCONTROL=.*$|OPCONTROL=\"$out/bin/opcontrol\"|g ;
            s|OPDIR=.*$|OPDIR=\"$out/bin\"|g ;
            s|^PATH=.*$||g"
  '';

  buildInputs = [ binutils zlib popt makeWrapper gawk which gnugrep ]
    ++ stdenv.lib.optionals (qt != null) [ qt libX11 libXext libpng ];

  configureFlags =
    [ "--with-kernel-support"
      "--disable-shared"   # needed because only the static libbfd is available
    ]
    ++ stdenv.lib.optional (qt != null) "--with-qt-dir=${qt}";

  postInstall = ''
    wrapProgram "$out/bin/opcontrol"					\
       --prefix PATH : "$out/bin:${gawk}/bin:${which}/bin:${gnugrep}/bin"
  '';

  meta = {
    description = "OProfile, a system-wide profiler for Linux";
    longDescription = ''
      OProfile is a system-wide profiler for Linux systems, capable of
      profiling all running code at low overhead.  It consists of a
      kernel driver and a daemon for collecting sample data, and
      several post-profiling tools for turning data into information.

      OProfile leverages the hardware performance counters of the CPU
      to enable profiling of a wide variety of interesting statistics,
      which can also be used for basic time-spent profiling. All code
      is profiled: hardware and software interrupt handlers, kernel
      modules, the kernel, shared libraries, and applications.
    '';
    license = "GPLv2";
    homepage = http://oprofile.sourceforge.net/;

    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.ludo ];
  };
}