1{ lib, stdenv, buildPackages
2, fetchurl, pkg-config
3, libbfd, popt, zlib, linuxHeaders, libiberty_static
4, withGUI ? false, qt4 ? null
5}:
6
7# libX11 is needed because the Qt build stuff automatically adds `-lX11'.
8assert withGUI -> qt4 != null;
9
10stdenv.mkDerivation rec {
11 pname = "oprofile";
12 version = "1.4.0";
13
14 src = fetchurl {
15 url = "mirror://sourceforge/oprofile/${pname}-${version}.tar.gz";
16 sha256 = "04m46ni0ryk4sqmzd6mahwzp7iwhwqzfbmfi42fki261sycnz83v";
17 };
18
19 postPatch = ''
20 substituteInPlace opjitconv/opjitconv.c \
21 --replace "/bin/rm" "${buildPackages.coreutils}/bin/rm" \
22 --replace "/bin/cp" "${buildPackages.coreutils}/bin/cp"
23 '';
24
25 nativeBuildInputs = [ pkg-config ];
26 buildInputs = [ libbfd zlib popt linuxHeaders libiberty_static ]
27 ++ lib.optionals withGUI [ qt4 ];
28
29 configureFlags = [
30 "--with-kernel=${linuxHeaders}"
31 "--disable-shared" # needed because only the static libbfd is available
32 ]
33 ++ lib.optional withGUI "--with-qt-dir=${qt4} --enable-gui=qt4";
34
35 meta = {
36 description = "System-wide profiler for Linux";
37 longDescription = ''
38 OProfile is a system-wide profiler for Linux systems, capable of
39 profiling all running code at low overhead. It consists of a
40 kernel driver and a daemon for collecting sample data, and
41 several post-profiling tools for turning data into information.
42
43 OProfile leverages the hardware performance counters of the CPU
44 to enable profiling of a wide variety of interesting statistics,
45 which can also be used for basic time-spent profiling. All code
46 is profiled: hardware and software interrupt handlers, kernel
47 modules, the kernel, shared libraries, and applications.
48 '';
49 license = lib.licenses.gpl2;
50 homepage = "http://oprofile.sourceforge.net/";
51
52 platforms = lib.platforms.linux;
53 maintainers = [ ];
54 };
55}