File vlc.spec of Package vlc

%define realname vlc
%define realver  3.0.8
%define srcext   tar.xz

%define vlc_so_ver  5
%define core_so_ver 9

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       GPL-2.0+ AND LGPL-2.1+
Group:         Productivity/Multimedia/Video/Players
URL:           http://www.videolan.org/vlc/
Summary:       VLC media player

# Install-time parameters
Provides:      vlc-codecs = %{version}-%{release}
Obsoletes:     vlc-codecs < %{version}-%{release}
Requires:      vlc-noX = %{version}-%{release}

# Build-time parameters
BuildRequires: xz
BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: gettext
BuildRequires: pkgconfig(libidn)
BuildRequires: pkgconfig(dbus-1) >= 1.6.0
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(libarchive)
BuildRequires: pkgconfig(zvbi-0.2) >= 0.2.28
BuildRequires: pkgconfig(dvdread) >= 4.9.0 pkgconfig(dvdnav) >= 4.9.0
BuildRequires: pkgconfig(libbluray) >= 0.6.2
BuildRequires: pkgconfig(smbclient)
BuildRequires: pkgconfig(libcddb) >= 0.9.5
BuildRequires: pkgconfig(libdvbpsi) >= 1.2.0
BuildRequires: pkgconfig(ogg) >= 1.0 pkgconfig(vorbis) >= 1.1
BuildRequires: pkgconfig(libebml) pkgconfig(libmatroska)
BuildRequires: pkgconfig(libmodplug)
BuildRequires: pkgconfig(libmpg123)
### BuildRequires: pkgconfig(libavcodec)  >= 57.37.100
### BuildRequires: pkgconfig(libavutil)   >= 52.0.0
### BuildRequires: pkgconfig(libavformat) >= 53.21.0
# Force ffmpeg 4.x
BuildRequires: pkgconfig(libavcodec)  >= 58
BuildRequires: pkgconfig(libavutil)   >= 56
BuildRequires: pkgconfig(libavformat) >= 58
BuildRequires: pkgconfig(libswscale)
BuildRequires: pkgconfig(libpostproc)
BuildRequires: pkgconfig(libva) >= 0.38 pkgconfig(libva-drm)
BuildRequires: pkgconfig(libva-x11)     pkgconfig(libva-wayland)
BuildRequires: pkgconfig(vpx) >= 1.5.0
# BuildRequires: pkgconfig(dca) >= 0.0.5
BuildRequires: pkgconfig(flac)
BuildRequires: pkgconfig(vorbisenc) >= 1.1
BuildRequires: pkgconfig(opus) >= 1.0.3
BuildRequires: pkgconfig(theoradec) >= 1.0 pkgconfig(theoraenc)
BuildRequires: pkgconfig(schroedinger-1.0) >= 1.0.10
BuildRequires: pkgconfig(x265)
BuildRequires: pkgconfig(x264) >= 0.86
BuildRequires: pkgconfig(libass) >= 0.9.8
BuildRequires: pkgconfig(egl) pkgconfig(gl)
BuildRequires: pkgconfig(xcb) >= 1.6       pkgconfig(xcb-shm)
BuildRequires: pkgconfig(xcb-composite)    pkgconfig(xcb-xv) >= 1.1.90.1
BuildRequires: pkgconfig(xcb-randr) >= 1.3 pkgconfig(xcb-keysyms) >= 0.3.4
BuildRequires: pkgconfig(xproto)
BuildRequires: pkgconfig(vdpau) >= 0.6
BuildRequires: pkgconfig(wayland-client) >= 1.5.91
BuildRequires: pkgconfig(wayland-protocols) >= 1.4
BuildRequires: pkgconfig(wayland-scanner)
BuildRequires: pkgconfig(wayland-egl)
BuildRequires: pkgconfig(SDL_image) >= 1.2.10
BuildRequires: pkgconfig(freetype2) pkgconfig(fontconfig) >= 2.11
BuildRequires: pkgconfig(fribidi)
BuildRequires: pkgconfig(harfbuzz)
BuildRequires: pkgconfig(caca) >= 0.99.beta14
BuildRequires: pkgconfig(libpulse) >= 1.0
BuildRequires: pkgconfig(alsa) >= 1.0.24
BuildRequires: pkgconfig(samplerate)
BuildRequires: pkgconfig(soxr) >= 0.1.2
BuildRequires: pkgconfig(protobuf-lite) >= 2.5.0
BuildRequires: pkgconfig(Qt5Core) >= 5.5.0 pkgconfig(Qt5Widgets)
BuildRequires: pkgconfig(Qt5Gui)           pkgconfig(Qt5Svg)
BuildRequires: pkgconfig(Qt5X11Extras)
# Note - next package is required due to header QtGui/qpa/qplatformnativeinterface.h
#BuildRequires: libqt5-qtbase-private-headers-devel
BuildRequires: libQt5Gui-private-headers-devel
BuildRequires: pkgconfig(xpm)
BuildRequires: pkgconfig(xinerama) pkgconfig(xext)
BuildRequires: pkgconfig(avahi-client) >= 0.6
BuildRequires: pkgconfig(libudev) >= 142
BuildRequires: pkgconfig(libmtp) >= 1.0.0
BuildRequires: pkgconfig(libupnp)
BuildRequires: pkgconfig(libxml-2.0) >= 2.5
BuildRequires: pkgconfig(gnutls) >= 3.3.6
BuildRequires: pkgconfig(taglib) >= 1.9
BuildRequires: zlib-devel
BuildRequires: lua-devel < 5.3
BuildRequires: libmpcdec-devel
BuildRequires: libcrystalhd-devel
BuildRequires: libmad-devel
# BuildRequires: liba52-devel
BuildRequires: libpng-devel libjpeg-devel
BuildRequires: sndio-devel
BuildRequires: libtar-devel
BuildArch:     %{_build_arch}
BuildRoot:     %{_tmppath}/%{name}-root
Source:        http://get.videolan.org/vlc/%{realver}/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
VLC is a popular libre and open source media player and multimedia engine,
used by a large number of individuals, professionals, companies and
institutions. Using open source technologies and libraries, VLC has been ported
to most computing platforms, including GNU/Linux, Windows, Mac OS X, BSD,
iOS and Android.

VLC can play most multimedia files, discs, streams, allows playback from
devices, and is able to convert to or stream in various formats. The VideoLAN
project was started at the university École Centrale Paris who relicensed VLC
under the GPLv2 license in February 2001. Since then, VLC has been downloaded
close to one billion times.

%package -n libvlc%{vlc_so_ver}
Group:         System/Libraries
Summary:       VLC shared library

%description -n libvlc%{vlc_so_ver}
VLC shared library.

%package -n libvlccore%{core_so_ver}
Group:         System/Libraries
Summary:       Core VLC shared library

%description -n libvlccore%{core_so_ver}
Core VLC shared library.

%package lang
Group:         System/Localization
Summary:       Locale resources for VLC media player
BuildArch:     noarch

%description lang
Locale resources for VLC media player.

%package noX
Group:         Productivity/Multimedia/Video/Players
Summary:       VLC media player without X dependencies

%description noX
VLC media player without X dependencies.

%package qt
Group:         Productivity/Multimedia/Video/Players
Summary:       Qt GUI for VLC media player
Requires:      vlc = %{version}-%{release}
Requires:      vlc-noX = %{version}-%{release}

%description qt
Qt GUI for VLC media player.

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for the VLC media player
Requires:      libvlc%{vlc_so_ver} = %{version}-%{release}
Requires:      libvlccore%{core_so_ver} = %{version}-%{release}

%description devel
Development files for the VLC media player.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}

%build
%{configure} \
 --disable-static \
 --disable-a52 \
 BUILDCC=gcc \
 CFLAGS="%{optflags} %{?gcc_lto}" \
 CXXFLAGS="%{optflags} %{?gcc_lto}" \
 LDFLAGS="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}"
%{__make} %{?_smp_mflags}

%install
%{__make} install DESTDIR=%{buildroot}
[ "%{buildroot}" != "/" ] && rm -f %{buildroot}%{_libdir}/vlc/plugins/plugins.dat
find %{buildroot}%{_libdir} -name \*.la -delete
%{find_lang} %{name}
# Find plugins dependent on X11
# Get directories for noX package
find %{buildroot}%{_libdir}/vlc/plugins -depth -type d >> plugins-nox11.lst
sed -i 's|^%{buildroot}|%%dir |' plugins-nox11.lst
# Get plugins into two files
find %{buildroot}%{_libdir}/vlc/plugins -type f -name \*.so \
  | while read -r m; do
      if ldd $m 2>&1 | grep -qE 'lib(X11|xcb)'; then
        echo $m >> plugins-x11.lst
      else
        echo $m >> plugins-nox11.lst
      fi
    done
# Remove leading %{buildroot}
sed -i 's|^%{buildroot}||' plugins-x11.lst plugins-nox11.lst

%files -f plugins-x11.lst
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LIB NEWS README THANKS
%{_bindir}/svlc
%{_libdir}/vlc/libvlc_*
%{_datadir}/applications/vlc.desktop
%{_datadir}/icons/hicolor/*/apps/vlc*
%dir %{_datadir}/kde4/apps/solid/actions/
%dir %{_datadir}/kde4/apps/solid/
%dir %{_datadir}/kde4/apps/
%dir %{_datadir}/kde4/
%{_datadir}/kde4/apps/solid/actions/*.desktop
%dir %{_datadir}/metainfo/
%{_datadir}/metainfo/vlc.appdata.xml
%{_datadir}/vlc/skins2/
%exclude %{_libdir}/vlc/plugins/gui/libqt_plugin.so
%exclude %{_datadir}/doc

%files lang -f %{name}.lang
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LIB NEWS README THANKS

%files noX -f plugins-nox11.lst
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LIB NEWS README THANKS
%{_bindir}/cvlc
%{_bindir}/rvlc
%{_bindir}/vlc
%{_bindir}/vlc-wrapper
%{_libdir}/vlc/lua/
%ghost %{_libdir}/vlc/plugins/plugins.dat
%{_libdir}/vlc/vlc-cache-gen
%{_datadir}/vlc/
%doc %{_mandir}/man1/*
%exclude %{_libdir}/vlc/libvlc_*
%exclude %{_libdir}/vlc/libcompat.a
%exclude %{_datadir}/vlc/skins2/

%files qt
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LIB NEWS README THANKS
%{_bindir}/qvlc
%dir %{_libdir}/vlc/plugins/gui/
%{_libdir}/vlc/plugins/gui/libqt_plugin.so

%files -n libvlc%{vlc_so_ver}
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LIB NEWS README THANKS
%{_libdir}/libvlc.so.%{vlc_so_ver}*

%files -n libvlccore%{core_so_ver}
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LIB NEWS README THANKS
%{_libdir}/libvlccore.so.%{core_so_ver}*

%files devel
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LIB NEWS README THANKS
%{_includedir}/vlc/
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

%post
%{_libdir}/vlc/vlc-cache-gen %{_libdir}/vlc/plugins/

%post noX
%{_libdir}/vlc/vlc-cache-gen %{_libdir}/vlc/plugins/

%post qt
%{_libdir}/vlc/vlc-cache-gen %{_libdir}/vlc/plugins/

%post   -n libvlc%{vlc_so_ver} -p /sbin/ldconfig
%postun -n libvlc%{vlc_so_ver} -p /sbin/ldconfig

%post   -n libvlccore%{core_so_ver} -p /sbin/ldconfig
%postun -n libvlccore%{core_so_ver} -p /sbin/ldconfig

%changelog