1{ lib, stdenv, fetchurl, yasm, autoconf, automake, libtool }:
2
3stdenv.mkDerivation rec {
4 pname = "xvidcore";
5 version = "1.3.7";
6
7 src = fetchurl {
8 url = "https://downloads.xvid.com/downloads/${pname}-${version}.tar.bz2";
9 sha256 = "1xyg3amgg27zf7188kss7y248s0xhh1vv8rrk0j9bcsd5nasxsmf";
10 };
11
12 preConfigure = ''
13 # Configure script is not in the root of the source directory
14 cd build/generic
15 '' + lib.optionalString stdenv.isDarwin ''
16 # Undocumented darwin hack
17 substituteInPlace configure --replace "-no-cpp-precomp" ""
18 '';
19
20 configureFlags = [ ]
21 # Undocumented darwin hack (assembly is probably disabled due to an
22 # issue with nasm, however yasm is now used)
23 ++ lib.optional stdenv.isDarwin "--enable-macosx_module --disable-assembly";
24
25 nativeBuildInputs = [ ]
26 ++ lib.optional (!stdenv.isDarwin) yasm;
27
28 buildInputs = [ ]
29 # Undocumented darwin hack
30 ++ lib.optionals stdenv.isDarwin [ autoconf automake libtool ];
31
32 # Don't remove static libraries (e.g. 'libs/*.a') on darwin. They're needed to
33 # compile ffmpeg (and perhaps other things).
34 postInstall = lib.optionalString (!stdenv.isDarwin) ''
35 rm $out/lib/*.a
36 '';
37
38 # Dependants of xvidcore don't know to look in bin for dependecies. Link them
39 # in lib so other depedants of xvidcore can find the dlls.
40 postFixup = lib.optionalString stdenv.hostPlatform.isMinGW ''
41 ln -s $out/bin/*.dll $out/lib
42 '';
43
44 meta = with lib; {
45 description = "MPEG-4 video codec for PC";
46 homepage = "https://www.xvid.com/";
47 license = licenses.gpl2;
48 maintainers = with maintainers; [ codyopel lovek323 ];
49 platforms = platforms.all;
50 };
51}