lol
1{ lib
2, stdenv
3, fetchurl
4, fetchpatch
5, autoconf
6
7# for passthru.tests
8, audacity
9, mpd
10, normalize
11, ocamlPackages
12, streamripper
13, vlc
14}:
15
16stdenv.mkDerivation rec {
17 pname = "libmad";
18 version = "0.15.1b";
19
20 src = fetchurl {
21 url = "mirror://sourceforge/mad/${pname}-${version}.tar.gz";
22 sha256 = "14460zhacxhswnzb36qfpd1f2wbk10qvksvm6wyq5hpvdgnw7ymv";
23 };
24
25 outputs = [ "out" "dev" ];
26
27 patches = [
28 (fetchpatch {
29 url = "https://github.com/openwrt/packages/raw/openwrt-19.07/libs/libmad/patches/001-mips_removal_h_constraint.patch";
30 sha256 = "0layswr6qg6axf4vyz6xrv73jwga34mkma3ifk9w9vrk41454hr5";
31 })
32 (fetchpatch {
33 url = "https://github.com/KaOSx/main/raw/1270b8080f37fb6cca562829a521991800b0a497/libmad/libmad.patch";
34 sha256 = "0rysq0sn3dfdz6pa6bfqkmk4ymc4rzk5ym7p16dyk37sldg1pbzs";
35 })
36 (fetchpatch {
37 url = "https://github.com/KaOSx/main/raw/1270b8080f37fb6cca562829a521991800b0a497/libmad/amd64-64bit.diff";
38 sha256 = "0mx56dmkbvw3zxnqd2hjng48q0d7q7473pns4n0ksdam29b0c5ar";
39 })
40 (fetchpatch {
41 name = "CVE-2017-8372-CVE-2017-8373.patch";
42 url = "https://github.com/openwrt/packages/raw/openwrt-19.07/libs/libmad/patches/102-CVE-2017-8373-CVE-2017-8372-md-size.patch";
43 sha256 = "0p6mkpn66h1ds8jvww28q4vlr58jwm58m9vb7pkvvyvy764agqnk";
44 })
45 (fetchpatch {
46 name = "CVE-2017-8374.patch";
47 url = "https://github.com/openwrt/packages/raw/openwrt-19.07/libs/libmad/patches/101-CVE-2017-8374-length-check.patch";
48 sha256 = "1j1ssxwmx9nfahzl62frbzck93xrjc2v3w30c12vmk29iflf1890";
49 })
50 ]
51 # optimize.diff is taken from https://projects.archlinux.org/svntogit/packages.git/tree/trunk/optimize.diff?h=packages/libmad
52 # It is included here in order to fix a build failure in Clang
53 # But it may be useful to fix other, currently unknown problems as well
54 ++ lib.optionals stdenv.cc.isClang [
55 (fetchpatch {
56 url = "https://github.com/KaOSx/main/raw/1270b8080f37fb6cca562829a521991800b0a497/libmad/optimize.diff";
57 sha256 = "0hcxzz9ql1fizyqbsgdchdwi7bvchfr72172j43hpyj53p0yabc6";
58 })
59 ];
60
61 # The -fforce-mem flag has been removed in GCC 4.3.
62 postPatch = ''
63 substituteInPlace configure.ac --replace "-fforce-mem" ""
64 substituteInPlace configure.ac --replace "arch=\"-march=i486\"" ""
65 '';
66
67 nativeBuildInputs = [ autoconf ];
68
69 preConfigure = "autoconf";
70
71 passthru.tests = {
72 inherit audacity mpd normalize streamripper vlc;
73 ocaml-mad = ocamlPackages.mad;
74 };
75
76 meta = with lib; {
77 homepage = "https://sourceforge.net/projects/mad/";
78 description = "A high-quality, fixed-point MPEG audio decoder supporting MPEG-1 and MPEG-2";
79 license = licenses.gpl2;
80 maintainers = with maintainers; [ lovek323 ];
81 platforms = platforms.unix;
82 };
83}