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