nixpkgs/pkgs/applications/video/vlc/default.nix
aszlig b017935103
vlc: Fix build for Qt >= 5.7.0
This basically does something similar than the AUR build:

https://aur.archlinux.org/packages/vlc-qt5/

On our side, all there is to do is to force compiling using C++11 mode
and use a patch that the AUR package took from the following upstream
patchwork URL:

https://patches.videolan.org/patch/14061/

Instead of passing CXXFLAGS to the configure script, I'm using sed here
to make sure we don't override flags figured out by configure.

For example if ./configure is used with CXXFLAGS=-std=c++11 appended or
prepended, we have something like:

... -I../include   -std=c++11 -Wall -Wextra -Wsign-compare ...

While if we don't do that at all, we have something like:

... -I../include   -g -O2 -Wall -Wextra -Wsign-compare ...

Another way would be to use NIX_CFLAGS_COMPILE, but that would affect
even compilation of C code and thus resulting in a bunch of warnings
like this:

cc1: warning: command line option '-std=c++11' is valid for C++/ObjC++
              but not for C

So with our approach the flags during build look much better:

... -I../include   -std=c++11 -g -O2 -Wall -Wextra -Wsign-compare ...

Another thing I've changed is that the vlc_qt5 attribute in
all-packages.nix now uses the latest Qt 5 version, because the build for
Qt >= 5.7.0 is now no longer broken.

I've also ordered the preConfigure attribute before the configureFlags
attribute, because it makes more sense in terms of context (pre ->
configure -> post).

Tested by building on x86_64-linux with libsForQt56.vlc, libsForQt58.vlc
and vlc (the Qt 4 version, just to be sure I didn't accidentally break
it).

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Cc: @ttuegel
2017-04-19 05:09:47 +02:00

94 lines
3.2 KiB
Nix

{ stdenv, fetchurl, xz, bzip2, perl, xorg, libdvdnav, libbluray
, zlib, a52dec, libmad, faad2, ffmpeg, alsaLib
, pkgconfig, dbus, fribidi, freefont_ttf, libebml, libmatroska
, libvorbis, libtheora, speex, lua5, libgcrypt, libupnp
, libcaca, libpulseaudio, flac, schroedinger, libxml2, librsvg
, mpeg2dec, udev, gnutls, avahi, libcddb, libjack2, SDL, SDL_image
, libmtp, unzip, taglib, libkate, libtiger, libv4l, samba, liboggz
, libass, libva, libdvbpsi, libdc1394, libraw1394, libopus
, libvdpau, libsamplerate, live555, fluidsynth
, onlyLibVLC ? false
, qt4 ? null
, withQt5 ? false, qtbase ? null, qtx11extras ? null
, jackSupport ? false
}:
with stdenv.lib;
assert (withQt5 -> qtbase != null && qtx11extras != null);
assert (!withQt5 -> qt4 != null);
stdenv.mkDerivation rec {
name = "vlc-${version}";
version = "2.2.4";
src = fetchurl {
url = "http://get.videolan.org/vlc/${version}/${name}.tar.xz";
sha256 = "1gjkrwlg8ab3skzl67cxb9qzg4187ifckd1z9kpy11q058fyjchn";
};
patches = optional withQt5 (fetchurl {
name = "Fix-build-using-old-GCC-intrinsics.patch";
url = "https://patches.videolan.org/patch/14061/raw/";
sha256 = "16v4k7378a590diz11bdvdaqi9cpf6333hp5wr6v5sfrsma8qvpx";
});
# Comment-out the Qt 5.5 version check, as we do apply the relevant patch.
# https://trac.videolan.org/vlc/ticket/16497
postPatch = if (!withQt5) then null else
"sed '/I78ef29975181ee22429c9bd4b11d96d9e68b7a9c/s/^/: #/' -i configure";
buildInputs =
[ xz bzip2 perl zlib a52dec libmad faad2 ffmpeg alsaLib libdvdnav libdvdnav.libdvdread
libbluray dbus fribidi libvorbis libtheora speex lua5 libgcrypt
libupnp libcaca libpulseaudio flac schroedinger libxml2 librsvg mpeg2dec
udev gnutls avahi libcddb SDL SDL_image libmtp unzip taglib
libkate libtiger libv4l samba liboggz libass libdvbpsi libva
xorg.xlibsWrapper xorg.libXv xorg.libXvMC xorg.libXpm xorg.xcbutilkeysyms
libdc1394 libraw1394 libopus libebml libmatroska libvdpau libsamplerate live555
fluidsynth
]
++ [(if withQt5 then qtbase else qt4)]
++ optional withQt5 qtx11extras
++ optional jackSupport libjack2;
nativeBuildInputs = [ pkgconfig ];
LIVE555_PREFIX = live555;
preConfigure = ''
sed -e "s@/bin/echo@echo@g" -i configure
'' + optionalString withQt5 ''
# Make sure we only *add* "-std=c++11" to CXXFLAGS instead of overriding the
# values figured out by configure (for example "-g -O2").
sed -i -re '/^ *CXXFLAGS=("[^$"]+")? *$/s/CXXFLAGS="?/&-std=c++11 /' \
configure
'';
configureFlags =
[ "--enable-alsa"
"--with-kde-solid=$out/share/apps/solid/actions"
"--enable-dc1394"
"--enable-ncurses"
"--enable-vdpau"
"--enable-dvdnav"
"--enable-samplerate"
]
++ optional onlyLibVLC "--disable-vlc";
enableParallelBuilding = true;
preBuild = ''
substituteInPlace modules/text_renderer/freetype.c --replace \
/usr/share/fonts/truetype/freefont/FreeSerifBold.ttf \
${freefont_ttf}/share/fonts/truetype/FreeSerifBold.ttf
'';
meta = with stdenv.lib; {
description = "Cross-platform media player and streaming server";
homepage = http://www.videolan.org/vlc/;
platforms = platforms.linux;
license = licenses.lgpl21Plus;
};
}