Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-19.03 211 lines 8.0 kB view raw
1{ stdenv, fetchurl, pkgconfig, perl, texinfo, yasm 2, alsaLib, bzip2, fontconfig, freetype, gnutls, libiconv, lame, libass, libogg 3, libssh, libtheora, libva, libdrm, libvorbis, libvpx, lzma, libpulseaudio, soxr 4, x264, x265, xvidcore, zlib, libopus, speex 5, openglSupport ? false, libGLU_combined ? null 6# Build options 7, runtimeCpuDetectBuild ? true # Detect CPU capabilities at runtime 8, multithreadBuild ? true # Multithreading via pthreads/win32 threads 9, sdlSupport ? !stdenv.isAarch32, SDL ? null, SDL2 ? null 10, vdpauSupport ? !stdenv.isAarch32, libvdpau ? null 11# Developer options 12, debugDeveloper ? false 13, optimizationsDeveloper ? true 14, extraWarningsDeveloper ? false 15# Darwin frameworks 16, Cocoa, darwinFrameworks ? [ Cocoa ] 17# Inherit generics 18, branch, sha256, version, patches ? [], ... 19}: 20 21/* Maintainer notes: 22 * 23 * THIS IS A MINIMAL BUILD OF FFMPEG, do not include dependencies unless 24 * a build that depends on ffmpeg requires them to be compiled into ffmpeg, 25 * see `ffmpeg-full' for an ffmpeg build with all features included. 26 * 27 * Need fixes to support Darwin: 28 * pulseaudio 29 * 30 * Known issues: 31 * 0.6 - fails to compile (unresolved) (so far, only disabling a number of 32 * features works, but that is not a feasible solution) 33 * 0.6.90 - mmx: compile errors (fix: disable for 0.6.90-rc0) 34 * 1.1 - libsoxr: compile error (fix: disable for 1.1) 35 * Support was initially added in 1.1 before soxr api change, fix 36 * would probably be to add soxr-1.0 37 * ALL - Cross-compiling will disable features not present on host OS 38 * (e.g. dxva2 support [DirectX] will not be enabled unless natively 39 * compiled on Cygwin) 40 * 41 */ 42 43let 44 inherit (stdenv) isDarwin isFreeBSD isLinux isAarch32; 45 inherit (stdenv.lib) optional optionals enableFeature; 46 47 cmpVer = builtins.compareVersions; 48 reqMin = requiredVersion: (cmpVer requiredVersion branch != 1); 49 reqMatch = requiredVersion: (cmpVer requiredVersion branch == 0); 50 51 ifMinVer = minVer: flag: if reqMin minVer then flag else null; 52 53 # Version specific fix 54 verFix = withoutFix: fixVer: withFix: if reqMatch fixVer then withFix else withoutFix; 55 56 # Disable dependency that needs fixes before it will work on Darwin or Arm 57 disDarwinOrArmFix = origArg: minVer: fixArg: if ((isDarwin || isAarch32) && reqMin minVer) then fixArg else origArg; 58 59 vaapiSupport = reqMin "0.6" && ((isLinux || isFreeBSD) && !isAarch32); 60 61 vpxSupport = reqMin "0.6" && !isAarch32; 62in 63 64assert openglSupport -> libGLU_combined != null; 65 66stdenv.mkDerivation rec { 67 68 name = "ffmpeg-${version}"; 69 inherit version; 70 71 src = fetchurl { 72 url = "https://www.ffmpeg.org/releases/${name}.tar.bz2"; 73 inherit sha256; 74 }; 75 76 postPatch = ''patchShebangs .''; 77 inherit patches; 78 79 outputs = [ "bin" "dev" "out" "man" ] 80 ++ optional (reqMin "1.0") "doc" ; # just dev-doc 81 setOutputFlags = false; # doesn't accept all and stores configureFlags in libs! 82 83 configurePlatforms = []; 84 configureFlags = [ 85 "--arch=${stdenv.hostPlatform.parsed.cpu.name}" 86 "--target_os=${stdenv.hostPlatform.parsed.kernel.name}" 87 # License 88 "--enable-gpl" 89 "--enable-version3" 90 # Build flags 91 "--enable-shared" 92 "--disable-static" 93 (ifMinVer "0.6" "--enable-pic") 94 (enableFeature runtimeCpuDetectBuild "runtime-cpudetect") 95 "--enable-hardcoded-tables" 96 (if multithreadBuild then ( 97 if stdenv.isCygwin then 98 "--disable-pthreads --enable-w32threads" 99 else # Use POSIX threads by default 100 "--enable-pthreads --disable-w32threads") 101 else 102 "--disable-pthreads --disable-w32threads") 103 (ifMinVer "0.9" "--disable-os2threads") # We don't support OS/2 104 "--enable-network" 105 (ifMinVer "2.4" "--enable-pixelutils") 106 # Executables 107 "--enable-ffmpeg" 108 "--disable-ffplay" 109 (ifMinVer "0.6" "--enable-ffprobe") 110 (if reqMin "4" then null else "--disable-ffserver") 111 # Libraries 112 (ifMinVer "0.6" "--enable-avcodec") 113 (ifMinVer "0.6" "--enable-avdevice") 114 "--enable-avfilter" 115 (ifMinVer "0.6" "--enable-avformat") 116 (ifMinVer "1.0" "--enable-avresample") 117 (ifMinVer "1.1" "--enable-avutil") 118 "--enable-postproc" 119 (ifMinVer "0.9" "--enable-swresample") 120 "--enable-swscale" 121 # Docs 122 (ifMinVer "0.6" "--disable-doc") 123 # External Libraries 124 "--enable-bzlib" 125 "--enable-gnutls" 126 (ifMinVer "1.0" "--enable-fontconfig") 127 (ifMinVer "0.7" "--enable-libfreetype") 128 "--enable-libmp3lame" 129 (ifMinVer "1.2" "--enable-iconv") 130 "--enable-libtheora" 131 (ifMinVer "2.1" "--enable-libssh") 132 (ifMinVer "0.6" (enableFeature vaapiSupport "vaapi")) 133 (ifMinVer "3.4" (enableFeature vaapiSupport "libdrm")) 134 "--enable-vdpau" 135 "--enable-libvorbis" 136 (ifMinVer "0.6" (enableFeature vpxSupport "libvpx")) 137 (ifMinVer "2.4" "--enable-lzma") 138 (ifMinVer "2.2" (enableFeature openglSupport "opengl")) 139 (disDarwinOrArmFix (ifMinVer "0.9" "--enable-libpulse") "0.9" "--disable-libpulse") 140 (ifMinVer "2.5" (if sdlSupport && reqMin "3.2" then "--enable-sdl2" else if sdlSupport then "--enable-sdl" else null)) # autodetected before 2.5, SDL1 support removed in 3.2 for SDL2 141 (ifMinVer "1.2" "--enable-libsoxr") 142 "--enable-libx264" 143 "--enable-libxvid" 144 "--enable-zlib" 145 (ifMinVer "2.8" "--enable-libopus") 146 "--enable-libspeex" 147 (ifMinVer "2.8" "--enable-libx265") 148 # Developer flags 149 (enableFeature debugDeveloper "debug") 150 (enableFeature optimizationsDeveloper "optimizations") 151 (enableFeature extraWarningsDeveloper "extra-warnings") 152 "--disable-stripping" 153 # Disable mmx support for 0.6.90 154 (verFix null "0.6.90" "--disable-mmx") 155 ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 156 "--cross-prefix=${stdenv.cc.targetPrefix}" 157 "--enable-cross-compile" 158 ] ++ optional stdenv.cc.isClang "--cc=clang"; 159 160 nativeBuildInputs = [ perl pkgconfig texinfo yasm ]; 161 162 buildInputs = [ 163 bzip2 fontconfig freetype gnutls libiconv lame libass libogg libssh libtheora 164 libvdpau libvorbis lzma soxr x264 x265 xvidcore zlib libopus speex 165 ] ++ optional openglSupport libGLU_combined 166 ++ optional vpxSupport libvpx 167 ++ optionals (!isDarwin && !isAarch32) [ libpulseaudio ] # Need to be fixed on Darwin and ARM 168 ++ optional ((isLinux || isFreeBSD) && !isAarch32) libva 169 ++ optional ((isLinux || isFreeBSD) && !isAarch32) libdrm 170 ++ optional isLinux alsaLib 171 ++ optionals isDarwin darwinFrameworks 172 ++ optional vdpauSupport libvdpau 173 ++ optional sdlSupport (if reqMin "3.2" then SDL2 else SDL); 174 175 enableParallelBuilding = true; 176 177 doCheck = false; # fails 178 179 # ffmpeg 3+ generates pkg-config (.pc) files that don't have the 180 # form automatically handled by the multiple-outputs hooks. 181 postFixup = '' 182 moveToOutput bin "$bin" 183 moveToOutput share/ffmpeg/examples "$doc" 184 for pc in ''${!outputDev}/lib/pkgconfig/*.pc; do 185 substituteInPlace $pc \ 186 --replace "includedir=$out" "includedir=''${!outputInclude}" 187 done 188 ''; 189 190 installFlags = [ "install-man" ]; 191 192 passthru = { 193 inherit vaapiSupport vdpauSupport; 194 }; 195 196 meta = with stdenv.lib; { 197 description = "A complete, cross-platform solution to record, convert and stream audio and video"; 198 homepage = http://www.ffmpeg.org/; 199 longDescription = '' 200 FFmpeg is the leading multimedia framework, able to decode, encode, transcode, 201 mux, demux, stream, filter and play pretty much anything that humans and machines 202 have created. It supports the most obscure ancient formats up to the cutting edge. 203 No matter if they were designed by some standards committee, the community or 204 a corporation. 205 ''; 206 license = licenses.gpl3; 207 platforms = platforms.all; 208 maintainers = with maintainers; [ codyopel fuuzetsu ]; 209 inherit branch; 210 }; 211}