@@ -26,7 +26,7 @@
2626, libjpegSupport ? true, libjpeg ? null
2727, useUnfreeCodecs ? false
2828, darwin ? null
29−, hostPlatform
29+, buildPackages
3030}:
3131
3232assert fontconfigSupport -> (fontconfig != null);
@@ -84,6 +84,8 @@ let
8484 meta.license = stdenv.lib.licenses.unfree;
8585 } else null;
8686
87+ crossBuild = stdenv.hostPlatform != stdenv.buildPlatform;
88+
8789in
8890
8991stdenv.mkDerivation rec {
@@ -100,8 +102,10 @@ stdenv.mkDerivation rec {
100102 rm -rf ffmpeg
101103 '';
102104
105+ depsBuildBuild = [ buildPackages.stdenv.cc ];
106+ nativeBuildInputs = [ pkgconfig yasm ];
103107 buildInputs = with stdenv.lib;
104− [ pkgconfig freetype ffmpeg ]
108+ [ freetype ffmpeg ]
105109 ++ optional aalibSupport aalib
106110 ++ optional fontconfigSupport fontconfig
107111 ++ optional fribidiSupport fribidi
@@ -129,45 +133,66 @@ stdenv.mkDerivation rec {
129133 ++ (with darwin.apple_sdk.frameworks; optionals stdenv.isDarwin [ Cocoa OpenGL ])
130134 ;
131135
132− nativeBuildInputs = [ yasm ];
136+ configurePlatforms = [ ];
137+ configureFlags = with stdenv.lib; [
138+ "--enable-freetype"
139+ (if fontconfigSupport then "--enable-fontconfig" else "--disable-fontconfig")
140+ (if x11Support then "--enable-x11 --enable-gl" else "--disable-x11 --disable-gl")
141+ (if xineramaSupport then "--enable-xinerama" else "--disable-xinerama")
142+ (if xvSupport then "--enable-xv" else "--disable-xv")
143+ (if alsaSupport then "--enable-alsa" else "--disable-alsa")
144+ (if screenSaverSupport then "--enable-xss" else "--disable-xss")
145+ (if vdpauSupport then "--enable-vdpau" else "--disable-vdpau")
146+ (if cddaSupport then "--enable-cdparanoia" else "--disable-cdparanoia")
147+ (if dvdnavSupport then "--enable-dvdnav" else "--disable-dvdnav")
148+ (if bluraySupport then "--enable-bluray" else "--disable-bluray")
149+ (if amrSupport then "--enable-libopencore_amrnb" else "--disable-libopencore_amrnb")
150+ (if cacaSupport then "--enable-caca" else "--disable-caca")
151+ (if lameSupport then "--enable-mp3lame --disable-mp3lame-lavc" else "--disable-mp3lame --enable-mp3lame-lavc")
152+ (if speexSupport then "--enable-speex" else "--disable-speex")
153+ (if theoraSupport then "--enable-theora" else "--disable-theora")
154+ (if x264Support then "--enable-x264 --disable-x264-lavc" else "--disable-x264 --enable-x264-lavc")
155+ (if jackaudioSupport then "" else "--disable-jack")
156+ (if pulseSupport then "--enable-pulse" else "--disable-pulse")
157+ "--disable-xanim"
158+ "--disable-ivtv"
159+ "--disable-xvid --disable-xvid-lavc"
160+ "--disable-ossaudio"
161+ "--disable-ffmpeg_a"
162+ "--yasm=${buildPackages.yasm}/bin/yasm"
163+ # Note, the `target` vs `host` confusion is intensional.
164+ "--target=${stdenv.hostPlatform.config}"
165+ ] ++ optional
166+ (useUnfreeCodecs && codecs != null && !crossBuild)
167+ "--codecsdir=${codecs}"
168+ ++ optional
169+ ((stdenv.hostPlatform.isi686 || stdenv.hostPlatform.isx86_64) && !crossBuild)
170+ "--enable-runtime-cpudetection"
171+ ++ optional fribidiSupport "--enable-fribidi"
172+ ++ optional stdenv.isLinux "--enable-vidix"
173+ ++ optional stdenv.isLinux "--enable-fbdev"
174+ ++ optionals (crossBuild) [
175+ "--enable-cross-compile"
176+ "--disable-vidix-pcidb"
177+ "--with-vidix-drivers=no"
178+ ];
179+
180+ preConfigure = ''
181+ configureFlagsArray+=(
182+ "--cc=$CC"
183+ "--host-cc=$BUILD_CC"
184+ "--as=$AS"
185+ "--nm=$NM"
186+ "--ar=$AR"
187+ "--ranlib=$RANLIB"
188+ "--windres=$WINDRES"
189+ )
190+ '';
133191
134192 postConfigure = ''
135193 echo CONFIG_MPEGAUDIODSP=yes >> config.mak
136194 '';
137195
138− configureFlags = with stdenv.lib;
139− ''
140− --enable-freetype
141− ${if fontconfigSupport then "--enable-fontconfig" else "--disable-fontconfig"}
142− ${if x11Support then "--enable-x11 --enable-gl" else "--disable-x11 --disable-gl"}
143− ${if xineramaSupport then "--enable-xinerama" else "--disable-xinerama"}
144− ${if xvSupport then "--enable-xv" else "--disable-xv"}
145− ${if alsaSupport then "--enable-alsa" else "--disable-alsa"}
146− ${if screenSaverSupport then "--enable-xss" else "--disable-xss"}
147− ${if vdpauSupport then "--enable-vdpau" else "--disable-vdpau"}
148− ${if cddaSupport then "--enable-cdparanoia" else "--disable-cdparanoia"}
149− ${if dvdnavSupport then "--enable-dvdnav" else "--disable-dvdnav"}
150− ${if bluraySupport then "--enable-bluray" else "--disable-bluray"}
151− ${if amrSupport then "--enable-libopencore_amrnb" else "--disable-libopencore_amrnb"}
152− ${if cacaSupport then "--enable-caca" else "--disable-caca"}
153− ${if lameSupport then "--enable-mp3lame --disable-mp3lame-lavc" else "--disable-mp3lame --enable-mp3lame-lavc"}
154− ${if speexSupport then "--enable-speex" else "--disable-speex"}
155− ${if theoraSupport then "--enable-theora" else "--disable-theora"}
156− ${if x264Support then "--enable-x264 --disable-x264-lavc" else "--disable-x264 --enable-x264-lavc"}
157− ${if jackaudioSupport then "" else "--disable-jack"}
158− ${if pulseSupport then "--enable-pulse" else "--disable-pulse"}
159− ${optionalString (useUnfreeCodecs && codecs != null) "--codecsdir=${codecs}"}
160− ${optionalString (stdenv.isi686 || stdenv.isx86_64) "--enable-runtime-cpudetection"}
161− ${optionalString fribidiSupport "--enable-fribidi"}
162− --disable-xanim
163− --disable-ivtv
164− --disable-xvid --disable-xvid-lavc
165− ${optionalString stdenv.isLinux "--enable-vidix"}
166− ${optionalString stdenv.isLinux "--enable-fbdev"}
167− --disable-ossaudio
168− --disable-ffmpeg_a
169− '';
170−
171196 NIX_LDFLAGS = with stdenv.lib;
172197 optional fontconfigSupport "-lfontconfig"
173198 ++ optional fribidiSupport "-lfribidi"
@@ -188,20 +213,6 @@ stdenv.mkDerivation rec {
188213 fi
189214 '';
190215
191− crossAttrs = {
192− configurePlatforms = [];
193− # Some things (vidix) are nanonote specific. Once someone cares, we can make options from them.
194− # Note, the `target` vs `host` confusion is intensional.
195− preConfigure = ''
196− configureFlags="`echo $configureFlags |
197− sed -e 's/--codecsdir[^ ]\+//' \
198− -e 's/--enable-runtime-cpudetection//' `"
199− configureFlags="$configureFlags --target=${hostPlatform.arch}-linux
200− --enable-cross-compile --cc=$crossConfig-gcc --as=$crossConfig-as
201− --disable-vidix-pcidb --with-vidix-drivers=no --host-cc=gcc"
202− '';
203− };
204−
205216 meta = {
206217 description = "A movie player that supports many video formats";
207218 homepage = http://mplayerhq.hu;