1{ stdenv, lib, fetchurl, cmake, libGLU_combined, pkgconfig, libpulseaudio
2, qt4 ? null, extra-cmake-modules ? null, qtbase ? null, qttools ? null
3, withQt5 ? false
4, debug ? false }:
5
6with lib;
7
8let
9 v = "4.9.1";
10
11 soname = if withQt5 then "phonon4qt5" else "phonon";
12 buildsystemdir = "share/cmake/${soname}";
13in
14
15assert withQt5 -> qtbase != null;
16assert withQt5 -> qttools != null;
17
18stdenv.mkDerivation rec {
19 name = "phonon-${if withQt5 then "qt5" else "qt4"}-${v}";
20
21 meta = {
22 homepage = https://phonon.kde.org/;
23 description = "Multimedia API for Qt";
24 license = stdenv.lib.licenses.lgpl2;
25 platforms = stdenv.lib.platforms.linux;
26 maintainers = with stdenv.lib.maintainers; [ ttuegel ];
27 };
28
29 src = fetchurl {
30 url = "mirror://kde/stable/phonon/${v}/phonon-${v}.tar.xz";
31 sha256 = "177647r2jqfm32hqcz2nqfqv6v48hn5ab2vc31svba2wz23fkgk7";
32 };
33
34 buildInputs =
35 [ libGLU_combined libpulseaudio ]
36 ++ (if withQt5 then [ qtbase qttools ] else [ qt4 ]);
37
38 nativeBuildInputs =
39 [ cmake pkgconfig ]
40 ++ optional withQt5 extra-cmake-modules;
41
42 outputs = [ "out" "dev" ];
43
44 NIX_CFLAGS_COMPILE = "-fPIC";
45
46 cmakeFlags =
47 [ "-DCMAKE_BUILD_TYPE=${if debug then "Debug" else "Release"}" ]
48 ++ optional withQt5 "-DPHONON_BUILD_PHONON4QT5=ON";
49
50 preConfigure = ''
51 cmakeFlags+=" -DPHONON_QT_MKSPECS_INSTALL_DIR=''${!outputDev}/mkspecs"
52 cmakeFlags+=" -DPHONON_QT_IMPORTS_INSTALL_DIR=''${!outputBin}/$qtQmlPrefix"
53 cmakeFlags+=" -DPHONON_QT_PLUGIN_INSTALL_DIR=''${!outputBin}/$qtPluginPrefix/designer"
54 '';
55
56 postPatch = ''
57 sed -i PhononConfig.cmake.in \
58 -e "/get_filename_component(rootDir/ s/^.*$//" \
59 -e "/^set(PHONON_INCLUDE_DIR/ s|\''${rootDir}/||" \
60 -e "/^set(PHONON_LIBRARY_DIR/ s|\''${rootDir}/||" \
61 -e "/^set(PHONON_BUILDSYSTEM_DIR/ s|\''${rootDir}|''${!outputDev}|"
62
63 sed -i cmake/FindPhononInternal.cmake \
64 -e "/set(INCLUDE_INSTALL_DIR/ c set(INCLUDE_INSTALL_DIR \"''${!outputDev}/include\")"
65
66 ${optionalString withQt5 ''
67 sed -i cmake/FindPhononInternal.cmake \
68 -e "/set(PLUGIN_INSTALL_DIR/ c set(PLUGIN_INSTALL_DIR \"$qtPluginPrefix/..\")"
69 ''}
70
71 sed -i CMakeLists.txt \
72 -e "/set(BUILDSYSTEM_INSTALL_DIR/ c set(BUILDSYSTEM_INSTALL_DIR \"''${!outputDev}/${buildsystemdir}\")"
73 '';
74
75 postFixup = ''
76 sed -i "''${!outputDev}/lib/pkgconfig/${soname}.pc" \
77 -e "/^exec_prefix=/ c exec_prefix=''${!outputBin}/bin"
78 '';
79}