#### this file is sourced not run
PKGVER=3.0.6
PKGBUILD=1
PKGARCH=x86_64

# BLFS SVN 08112018
TARBALL=vlc-$PKGVER.tar.xz
MD5SUM=4ff71d262e070fd19f86a1c3542c7b4e
SRC_URL=http://download.videolan.org/vlc/$PKGVER/$TARBALL
BUNDLE=

SLACKREQ='ffmpeg alsa-lib liba52 libgnutls libgcrypt libmad lua \
libdvdread libdvdnav v4l-utils libogg libmodplug \
twolame libflac libvorbis libspeex libopus libtheora libschroedinger \
libpng libx264 libass libSDL freetype2 fontconfig libfribidi librsvg \
libportaudio libjack2 libsamplerate libfaad2 libxml2 xcb-util-keysyms libtaglib \
fluidsynth qt5-common libdvbpsi libmatroska \
libmtp microdns libupnp protobuf-cpp libdsm-vlc' # samba4-cutdown 
SLACKDESC="vlc-qt5: vlc-qt5 $PKGVER (Media player)  
vlc-qt5:  
vlc-qt5: VLC is a media player, streamer, and encoder. It can play from 
vlc-qt5: many inputs like files, network streams, capture device, desktops, 
vlc-qt5: or DVD, SVCD, VCD, and audio CD. It can play most audio and video 
vlc-qt5: codecs (MPEG 1/2/4, H264, VC-1, DivX, WMV, Vorbis, AC3, AAC, 
vlc-qt5: etc.), but can also convert to different formats and/or send 
vlc-qt5: streams through the network. This package contains both the Qt5 GUI 
vlc-qt5: version of the player and the ncurses version; it is a superset of
vlc-qt5: vlc-curses.
vlc-qt5:
"
SLACKSUG=libdvdcss

### default pkg_download
### defaulg pkg_prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/vlc* &&

	# Fix low FPS video, set default to 1 thread for FFmpeg. Can be changed in advanced preferences. 
	#patch -Np1 -i $CHROOT_DIR/tmp/pkg/vlc-avcodec-threads.patch &&  # No, Breaks high quality video playback.

	# Revert ee8c6e5d79, which causes the panel (JWM, LXQt-Panel + Compiz) to show on top of VLC in fullscreen mode
	patch -Np1 -R -i $CHROOT_DIR/tmp/pkg/prevent-fullscreen-controller-from-stealing-focus.patch &&

	true
}
### default pkg_package
### build
pkg_build() {
	# qt5
	export PATH="$PATH:/opt/qt5/bin"
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/qt5/$LIBDIR"
	export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/qt5/$LIBDIR/pkgconfig"
	export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/opt/qt5/include"
	export QT5_PATH="/opt/qt5/bin"
	export QT5_LD_LIBRARY_PATH="/opt/qt5/$LIBDIR"
	export QT5_PKG_CONFIG_PATH="/opt/qt5/$LIBDIR/pkgconfig"
	export QT5_CPLUS_INCLUDE_PATH="/opt/qt5/include" 
	export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb"	
	export QT5DIR=/opt/qt5
	export BUILDCC=gcc
	
	cd /tmp/vlc* 
	sed -i '/vlc_demux.h/a #define LUA_COMPAT_APIINTCASTS' modules/lua/vlc.h   &&
	sed -i '/DEPRECATED/s:^://:'  modules/text_renderer/freetype/text_layout.c &&
	sed -i '/#include <QString>/i#include <QButtonGroup>' \
			modules/gui/qt/components/simple_preferences.cpp                   &&
			
	MAKEINSTALLFLAGS="docdir=/usr/share/doc/vlc-$PKGVER"
	CONFFLAGS="--prefix=/usr --libdir=/usr/$LIBDIR --with-x --enable-run-as-root \
	--enable-faad --enable-bluray --enable-fluidsynth --enable-dvdread \
	--enable-gles1 --enable-gles2 --enable-dvdnav --disable-opencv \
	--disable-dbus --disable-dc1394 --disable-dv1394 --disable-live555 \
	--enable-mtp --enable-upnp --enable-microdns --enable-chromecast \
	--enable-libdsm --disable-smbclient"  
	## or --disable-libdsm and enable-smbclient
	

	pkg_build_autoconf &&
	pkg_build_slackdesc &&
	rm -f /usr/share/icons/hicolor/icon-theme.cache &&
	#/usr/lib64/vlc/vlc-cache-gen /usr/lib64/vlc/plugins &&
	rm -f /usr/lib64/vlc/plugins/plugins.dat &&

	# fix desktop file
	sed -i -e 's|^Exec=.*|Exec=/usr/bin/vlc|' /usr/share/applications/vlc.desktop	
}
