1{ stdenv, fetchurl
2, nasmSupport ? true, nasm ? null # Assembly optimizations
3, cpmlSupport ? true # Compaq's fast math library
4#, efenceSupport ? false, libefence ? null # Use ElectricFence for malloc debugging
5, sndfileFileIOSupport ? false, libsndfile ? null # Use libsndfile, instead of lame's internal routines
6, analyzerHooksSupport ? true # Use analyzer hooks
7, decoderSupport ? true # mpg123 decoder
8, frontendSupport ? true # Build the lame executable
9#, mp3xSupport ? false, gtk1 ? null # Build GTK frame analyzer
10, mp3rtpSupport ? false # Build mp3rtp
11, debugSupport ? false # Debugging (disables optimizations)
12}:
13
14assert nasmSupport -> (nasm != null);
15#assert efenceSupport -> (libefence != null);
16assert sndfileFileIOSupport -> (libsndfile != null);
17#assert mp3xSupport -> (analyzerHooksSupport && (gtk1 != null));
18
19let
20 mkFlag = optSet: flag: if optSet then "--enable-${flag}" else "--disable-${flag}";
21in
22
23with stdenv.lib;
24stdenv.mkDerivation rec {
25 name = "lame-${version}";
26 version = "3.100";
27
28 src = fetchurl {
29 url = "mirror://sourceforge/lame/${name}.tar.gz";
30 sha256 = "07nsn5sy3a8xbmw1bidxnsj5fj6kg9ai04icmqw40ybkp353dznx";
31 };
32
33 outputs = [ "out" "lib" "doc" ]; # a small single header
34 outputMan = "out";
35
36 nativeBuildInputs = [ ]
37 ++ optional nasmSupport nasm;
38
39 buildInputs = [ ]
40 #++ optional efenceSupport libefence
41 #++ optional mp3xSupport gtk1
42 ++ optional sndfileFileIOSupport libsndfile;
43
44 configureFlags = [
45 (mkFlag nasmSupport "nasm")
46 (mkFlag cpmlSupport "cpml")
47 #(mkFlag efenceSupport "efence")
48 (if sndfileFileIOSupport then "--with-fileio=sndfile" else "--with-fileio=lame")
49 (mkFlag analyzerHooksSupport "analyzer-hooks")
50 (mkFlag decoderSupport "decoder")
51 (mkFlag frontendSupport "frontend")
52 (mkFlag frontendSupport "dynamic-frontends")
53 #(mkFlag mp3xSupport "mp3x")
54 (mkFlag mp3rtpSupport "mp3rtp")
55 (if debugSupport then "--enable-debug=alot" else "")
56 ];
57
58 preConfigure = ''
59 # Prevent a build failure for 3.100 due to using outdated symbol list
60 # https://hydrogenaud.io/index.php/topic,114777.msg946373.html#msg946373
61 sed -i '/lame_init_old/d' include/libmp3lame.sym
62 '';
63
64 meta = {
65 description = "A high quality MPEG Audio Layer III (MP3) encoder";
66 homepage = http://lame.sourceforge.net;
67 license = licenses.lgpl2;
68 maintainers = with maintainers; [ codyopel fpletz ];
69 platforms = platforms.all;
70 };
71}