Skip to content

Commit

Permalink
vlc: Fix build for Qt >= 5.7.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aszlig committed Apr 19, 2017
1 parent e0b0a07 commit b017935
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 15 additions & 6 deletions pkgs/applications/video/vlc/default.nix
Expand Up @@ -27,6 +27,12 @@ stdenv.mkDerivation rec {
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
Expand All @@ -50,6 +56,15 @@ stdenv.mkDerivation rec {

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"
Expand All @@ -61,8 +76,6 @@ stdenv.mkDerivation rec {
]
++ optional onlyLibVLC "--disable-vlc";

preConfigure = ''sed -e "s@/bin/echo@echo@g" -i configure'';

enableParallelBuilding = true;

preBuild = ''
Expand All @@ -76,9 +89,5 @@ stdenv.mkDerivation rec {
homepage = http://www.videolan.org/vlc/;
platforms = platforms.linux;
license = licenses.lgpl21Plus;
broken =
if withQt5
then builtins.compareVersions qtbase.version "5.7.0" >= 0
else false;
};
}
3 changes: 1 addition & 2 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -16022,8 +16022,7 @@ with pkgs;
gtk = gtk2;
};

# VLC 3.0 is needed to compile in C++11 mode (QT 5.7)
vlc_qt5 = libsForQt56.vlc;
vlc_qt5 = libsForQt5.vlc;

vmpk = callPackage ../applications/audio/vmpk { };

Expand Down

1 comment on commit b017935

@ttuegel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aszlig Sounds good to me! It was broken before, so I'm sure it's not more broken now! 😉

Please sign in to comment.