summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2017-09-05 13:13:02 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2017-09-05 13:45:34 -0400
commit10b2bb82882b95dcc8683bf22b313b3c2db19931 (patch)
tree96645880fc8964387f045fb66b3328cfd418d369 /pkgs
parent5de3b11960467aa2f26556ee5922a657bdd9852e (diff)
downloadnixlib-10b2bb82882b95dcc8683bf22b313b3c2db19931.tar
nixlib-10b2bb82882b95dcc8683bf22b313b3c2db19931.tar.gz
nixlib-10b2bb82882b95dcc8683bf22b313b3c2db19931.tar.bz2
nixlib-10b2bb82882b95dcc8683bf22b313b3c2db19931.tar.lz
nixlib-10b2bb82882b95dcc8683bf22b313b3c2db19931.tar.xz
nixlib-10b2bb82882b95dcc8683bf22b313b3c2db19931.tar.zst
nixlib-10b2bb82882b95dcc8683bf22b313b3c2db19931.zip
mplayer: Simplify cross, no `crossAttrs` or `crossConfig`
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/video/mplayer/default.nix111
1 files changed, 61 insertions, 50 deletions
diff --git a/pkgs/applications/video/mplayer/default.nix b/pkgs/applications/video/mplayer/default.nix
index 8e28f77ffeed..fe6090c3230e 100644
--- a/pkgs/applications/video/mplayer/default.nix
+++ b/pkgs/applications/video/mplayer/default.nix
@@ -26,7 +26,7 @@
 , libjpegSupport ? true, libjpeg ? null
 , useUnfreeCodecs ? false
 , darwin ? null
-, hostPlatform
+, buildPackages
 }:
 
 assert fontconfigSupport -> (fontconfig != null);
@@ -84,6 +84,8 @@ let
     meta.license = stdenv.lib.licenses.unfree;
   } else null;
 
+  crossBuild = stdenv.hostPlatform != stdenv.buildPlatform;
+
 in
 
 stdenv.mkDerivation rec {
@@ -100,8 +102,10 @@ stdenv.mkDerivation rec {
     rm -rf ffmpeg
   '';
 
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ pkgconfig yasm ];
   buildInputs = with stdenv.lib;
-    [ pkgconfig freetype ffmpeg ]
+    [ freetype ffmpeg ]
     ++ optional aalibSupport aalib
     ++ optional fontconfigSupport fontconfig
     ++ optional fribidiSupport fribidi
@@ -129,45 +133,66 @@ stdenv.mkDerivation rec {
     ++ (with darwin.apple_sdk.frameworks; optionals stdenv.isDarwin [ Cocoa OpenGL ])
     ;
 
-  nativeBuildInputs = [ yasm ];
+  configurePlatforms = [ ];
+  configureFlags = with stdenv.lib; [
+    "--enable-freetype"
+    (if fontconfigSupport then "--enable-fontconfig" else "--disable-fontconfig")
+    (if x11Support then "--enable-x11 --enable-gl" else "--disable-x11 --disable-gl")
+    (if xineramaSupport then "--enable-xinerama" else "--disable-xinerama")
+    (if xvSupport then "--enable-xv" else "--disable-xv")
+    (if alsaSupport then "--enable-alsa" else "--disable-alsa")
+    (if screenSaverSupport then "--enable-xss" else "--disable-xss")
+    (if vdpauSupport then "--enable-vdpau" else "--disable-vdpau")
+    (if cddaSupport then "--enable-cdparanoia" else "--disable-cdparanoia")
+    (if dvdnavSupport then "--enable-dvdnav" else "--disable-dvdnav")
+    (if bluraySupport then "--enable-bluray" else "--disable-bluray")
+    (if amrSupport then "--enable-libopencore_amrnb" else "--disable-libopencore_amrnb")
+    (if cacaSupport then "--enable-caca" else "--disable-caca")
+    (if lameSupport then "--enable-mp3lame --disable-mp3lame-lavc" else "--disable-mp3lame --enable-mp3lame-lavc")
+    (if speexSupport then "--enable-speex" else "--disable-speex")
+    (if theoraSupport then "--enable-theora" else "--disable-theora")
+    (if x264Support then "--enable-x264 --disable-x264-lavc" else "--disable-x264 --enable-x264-lavc")
+    (if jackaudioSupport then "" else "--disable-jack")
+    (if pulseSupport then "--enable-pulse" else "--disable-pulse")
+    "--disable-xanim"
+    "--disable-ivtv"
+    "--disable-xvid --disable-xvid-lavc"
+    "--disable-ossaudio"
+    "--disable-ffmpeg_a"
+    "--yasm=${buildPackages.yasm}/bin/yasm"
+    # Note, the `target` vs `host` confusion is intensional.
+    "--target=${stdenv.hostPlatform.config}"
+  ] ++ optional
+         (useUnfreeCodecs && codecs != null && !crossBuild)
+         "--codecsdir=${codecs}"
+    ++ optional
+         ((stdenv.hostPlatform.isi686 || stdenv.hostPlatform.isx86_64) && !crossBuild)
+         "--enable-runtime-cpudetection"
+    ++ optional fribidiSupport "--enable-fribidi"
+    ++ optional stdenv.isLinux "--enable-vidix"
+    ++ optional stdenv.isLinux "--enable-fbdev"
+    ++ optionals (crossBuild) [
+    "--enable-cross-compile"
+    "--disable-vidix-pcidb"
+    "--with-vidix-drivers=no"
+  ];
+
+  preConfigure = ''
+    configureFlagsArray+=(
+      "--cc=$CC"
+      "--host-cc=$BUILD_CC"
+      "--as=$AS"
+      "--nm=$NM"
+      "--ar=$AR"
+      "--ranlib=$RANLIB"
+      "--windres=$WINDRES"
+    )
+  '';
 
   postConfigure = ''
     echo CONFIG_MPEGAUDIODSP=yes >> config.mak
   '';
 
-  configureFlags = with stdenv.lib;
-    ''
-      --enable-freetype
-      ${if fontconfigSupport then "--enable-fontconfig" else "--disable-fontconfig"}
-      ${if x11Support then "--enable-x11 --enable-gl" else "--disable-x11 --disable-gl"}
-      ${if xineramaSupport then "--enable-xinerama" else "--disable-xinerama"}
-      ${if xvSupport then "--enable-xv" else "--disable-xv"}
-      ${if alsaSupport then "--enable-alsa" else "--disable-alsa"}
-      ${if screenSaverSupport then "--enable-xss" else "--disable-xss"}
-      ${if vdpauSupport then "--enable-vdpau" else "--disable-vdpau"}
-      ${if cddaSupport then "--enable-cdparanoia" else "--disable-cdparanoia"}
-      ${if dvdnavSupport then "--enable-dvdnav" else "--disable-dvdnav"}
-      ${if bluraySupport then "--enable-bluray" else "--disable-bluray"}
-      ${if amrSupport then "--enable-libopencore_amrnb" else "--disable-libopencore_amrnb"}
-      ${if cacaSupport then "--enable-caca" else "--disable-caca"}
-      ${if lameSupport then "--enable-mp3lame --disable-mp3lame-lavc" else "--disable-mp3lame --enable-mp3lame-lavc"}
-      ${if speexSupport then "--enable-speex" else "--disable-speex"}
-      ${if theoraSupport then "--enable-theora" else "--disable-theora"}
-      ${if x264Support then "--enable-x264 --disable-x264-lavc" else "--disable-x264 --enable-x264-lavc"}
-      ${if jackaudioSupport then "" else "--disable-jack"}
-      ${if pulseSupport then "--enable-pulse" else "--disable-pulse"}
-      ${optionalString (useUnfreeCodecs && codecs != null) "--codecsdir=${codecs}"}
-      ${optionalString (stdenv.isi686 || stdenv.isx86_64) "--enable-runtime-cpudetection"}
-      ${optionalString fribidiSupport "--enable-fribidi"}
-      --disable-xanim
-      --disable-ivtv
-      --disable-xvid --disable-xvid-lavc
-      ${optionalString stdenv.isLinux "--enable-vidix"}
-      ${optionalString stdenv.isLinux "--enable-fbdev"}
-      --disable-ossaudio
-      --disable-ffmpeg_a
-    '';
-
   NIX_LDFLAGS = with stdenv.lib;
        optional  fontconfigSupport "-lfontconfig"
     ++ optional  fribidiSupport "-lfribidi"
@@ -188,20 +213,6 @@ stdenv.mkDerivation rec {
       fi
     '';
 
-  crossAttrs = {
-    configurePlatforms = [];
-    # Some things (vidix) are nanonote specific. Once someone cares, we can make options from them.
-    # Note, the `target` vs `host` confusion is intensional.
-    preConfigure = ''
-      configureFlags="`echo $configureFlags |
-        sed -e 's/--codecsdir[^ ]\+//' \
-        -e 's/--enable-runtime-cpudetection//' `"
-      configureFlags="$configureFlags --target=${hostPlatform.arch}-linux
-        --enable-cross-compile --cc=$crossConfig-gcc --as=$crossConfig-as
-        --disable-vidix-pcidb --with-vidix-drivers=no --host-cc=gcc"
-    '';
-  };
-
   meta = {
     description = "A movie player that supports many video formats";
     homepage = http://mplayerhq.hu;