1{ stdenv, fetchurl, scons, pkgconfig, which, makeWrapper, python
2, expat, libraw1394, libconfig, libavc1394, libiec61883
3
4# Optional dependencies
5, libjack2 ? null, dbus ? null, dbus_cplusplus ? null, alsaLib ? null
6, pyqt4 ? null, pythonDBus ? null, xdg_utils ? null
7
8# Other Flags
9, prefix ? ""
10}:
11
12let
13
14 shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
15
16 libOnly = prefix == "lib";
17
18 optLibjack2 = shouldUsePkg libjack2;
19 optDbus = shouldUsePkg dbus;
20 optDbus_cplusplus = shouldUsePkg dbus_cplusplus;
21 optAlsaLib = shouldUsePkg alsaLib;
22 optPyqt4 = shouldUsePkg pyqt4;
23 optPythonDBus = shouldUsePkg pythonDBus;
24 optXdg_utils = shouldUsePkg xdg_utils;
25in
26stdenv.mkDerivation rec {
27 name = "${prefix}ffado-${version}";
28 version = "2.2.1";
29
30 src = fetchurl {
31 url = "http://www.ffado.org/files/libffado-${version}.tgz";
32 sha256 = "1ximic90l0av91njb123ra2zp6mg23yg5iz8xa5371cqrn79nacz";
33 };
34
35 nativeBuildInputs = [ scons pkgconfig which makeWrapper python ];
36
37 buildInputs = [
38 expat libraw1394 libconfig libavc1394 libiec61883
39 ] ++ stdenv.lib.optionals (!libOnly) [
40 optLibjack2 optDbus optDbus_cplusplus optAlsaLib optPyqt4
41 optXdg_utils
42 ];
43
44 patches = [ ./build-fix.patch ];
45
46 postPatch = ''
47 # SConstruct checks cpuinfo and an objdump of /bin/mount to determine the appropriate arch
48 # Let's just skip this and tell it which to build
49 sed '/def is_userspace_32bit(cpuinfo):/a\
50 return ${if stdenv.is64bit then "False" else "True"}' -i SConstruct
51
52 # Lots of code is missing random headers to exist
53 sed -i '1i #include <memory>' \
54 src/ffadodevice.h src/bebob/bebob_dl_mgr.cpp tests/scan-devreg.cpp
55 sed -i -e '1i #include <stdlib.h>' \
56 -e '1i #include "version.h"' \
57 src/libutil/serialize_expat.cpp
58 '';
59
60 # TODO fix ffado-diag, it doesn't seem to use PYPKGDIR
61 buildPhase = ''
62 export PYDIR=$out/lib/${python.libPrefix}/site-packages
63
64 scons PYPKGDIR=$PYDIR DEBUG=False \
65 ENABLE_ALL=True \
66 SERIALIZE_USE_EXPAT=True \
67 '';
68
69 installPhase = if libOnly then ''
70 scons PREFIX=$TMPDIR UDEVDIR=$TMPDIR \
71 LIBDIR=$out/lib INCLUDEDIR=$out/include install
72 '' else ''
73 scons PREFIX=$out PYPKGDIR=$PYDIR UDEVDIR=$out/lib/udev/rules.d install
74 '' + stdenv.lib.optionalString (optPyqt4 != null && optPythonDBus != null) ''
75 wrapProgram $out/bin/ffado-mixer --prefix PYTHONPATH : \
76 $PYTHONPATH:$PYDIR:${optPyqt4}/$LIBSUFFIX:${optPythonDBus}/$LIBSUFFIX:
77
78 wrapProgram $out/bin/ffado-diag --prefix PYTHONPATH : \
79 $PYTHONPATH:$PYDIR:$out/share/libffado/python:${optPyqt4}/$LIBSUFFIX:${optPythonDBus}/$LIBSUFFIX:
80 '';
81
82 meta = with stdenv.lib; {
83 homepage = http://www.ffado.org;
84 description = "FireWire audio drivers";
85 license = licenses.gpl3;
86 maintainers = with maintainers; [ goibhniu wkennington ];
87 platforms = platforms.linux;
88 };
89}