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

# BLFS 2014-07-13 + kirk
TARBALL=vlc-$PKGVER.tar.xz
MD5SUM=f98d60f0f59ef72b6e3407f2ff09bda6
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 qt4-common libdvbpsi libmatroska'
SLACKDESC="vlc-qt4: vlc-qt4 $PKGVER (Media player)  
vlc-qt4:  
vlc-qt4: VLC is a media player, streamer, and encoder. It can play from 
vlc-qt4: many inputs like files, network streams, capture device, desktops, 
vlc-qt4: or DVD, SVCD, VCD, and audio CD. It can play most audio and video 
vlc-qt4: codecs (MPEG 1/2/4, H264, VC-1, DivX, WMV, Vorbis, AC3, AAC, 
vlc-qt4: etc.), but can also convert to different formats and/or send 
vlc-qt4: streams through the network. This package contains both the qt4 GUI 
vlc-qt4: version of the player and the ncurses version; it is a superset of
vlc-qt4: vlc-curses.
vlc-qt4:
"
SLACKSUG=libdvdcss

### default pkg_download
### defaulg pkg_prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/vlc* &&
	patch -Np1 -i $CHROOT_DIR/tmp/pkg/vlc-decoder-2.2.1.patch &&
	patch -Np1 -i $CHROOT_DIR/tmp/pkg/0004-implicit-function-declaration.patch
}
### default pkg_package
### build
pkg_build() {
	# qt4
	export PATH="$PATH:/opt/qt4/bin"
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/qt4/$LIBDIR"
	export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/qt4/$LIBDIR/pkgconfig"
	export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/opt/qt4/include"
	export QT4_PATH="/opt/qt4/bin"
	export QT4_LD_LIBRARY_PATH="/opt/qt4/$LIBDIR"
	export QT4_PKG_CONFIG_PATH="/opt/qt4/$LIBDIR/pkgconfig"
	export QT4_CPLUS_INCLUDE_PATH="/opt/qt4/include" 
	
	cd /tmp/vlc* #; return 1
	sed -i 's:libsmbclient.h:samba-4.0/&:' modules/access/smb.c
	./bootstrap
	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 --enable-vdpau
	--disable-dbus --disable-dc1394 --disable-dv1394 --disable-live555"

	# LIVE555 is needed for playing RTSP streams. Not needed for broadcasting RTSP.
	# Disabled for now because crashing and not working anyway	
	#export LIVE555_CFLAGS="-I/usr/include/UsageEnvironment/ -I/usr/include/liveMedia/ \
	#-I/usr/include/groupsock/ -I/usr/include/BasicUsageEnvironment/"

	pkg_build_autoconf &&
	pkg_build_slackdesc &&
	rm -f /usr/share/icons/hicolor/icon-theme.cache &&

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