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

# source: BLFS 11.3
TARBALL=ffmpeg-$PKGVER.tar.xz
MD5SUM=fa847c43407315c27231b9f883e62c0e
SRC_URL=http://ffmpeg.org/releases/$TARBALL
BUNDLE=

SLACKREQ='libass libfdk-aac freetype2 lame libtheora libvorbis libvpx libopus \
libx264 libx265 alsa-lib libva libvdpau fontconfig libfribidi libdrm libwebp \
libopenjpeg2 libgnutls libspeex v4l-utils libxvidcore libmodplug librtmp \
libopencore-amr libschroedinger twolame libSDL2 openssl \
libbluray libaom libxml2 lcms2 freetype2 librsvg'
# libvdpau must be compiled properly
# libgsm compile time only
SLACKDESC="ffmpeg: ffmpeg $PKGVER (Media conversion tool and library)  
ffmpeg:  
ffmpeg: FFmpeg is a versatile tool and library to play, record, and mainly to 
ffmpeg: convert audio and video streams and files; modifying them on the fly 
ffmpeg: as needed. This library is the base for many media players.  
ffmpeg: 
ffmpeg: 
ffmpeg: 
ffmpeg: 
ffmpeg: 
ffmpeg:
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/ffmpeg* &&
	patch -Np1 -i ../pkg/ffmpeg-5.1.2-chromium_method-1.patch
}

### default pkg_package
### build
pkg_build() {
	cp tmp/pkg/ladspa.h /usr/include &&
	cd /tmp/ffmpeg* &&
	sed -i 's/-lflite"/-lflite -lasound"/' configure &&
	./configure --prefix=/usr --libdir=/usr/$LIBDIR --shlibdir=/usr/$LIBDIR \
            --enable-gpl         \
            --enable-version3    \
            --enable-nonfree     \
            --disable-static     \
            --enable-shared      \
            --disable-debug      \
            --enable-libass      \
            --enable-libfdk-aac  \
			--enable-libfreetype \
            --enable-libmp3lame  \
            --enable-libopus     \
            --enable-libtheora   \
            --enable-libvorbis   \
            --enable-libvpx      \
            --enable-libx264     \
            --enable-libx265     \
            --enable-openssl     \
			--enable-libopenjpeg       \
			--enable-libspeex          \
			--enable-libxvid           \
			--enable-libgsm            \
			--enable-libfontconfig     \
			--enable-libfreetype       \
			--enable-libfribidi        \
			--enable-libmodplug        \
			--enable-libopencore-amrnb \
			--enable-libopencore-amrwb \
			--enable-librtmp           \
			--enable-libtwolame        \
			--enable-libv4l2           \
			--enable-libaom            \
			--enable-libxml2           \
			--enable-ladspa            \
			--enable-lcms2             \
			--enable-libbluray         \
			--enable-librsvg           \
			--enable-libwebp           \
			--enable-vdpau &&
#  --enable-chromaprint - circular dependency
#  --disable-neon
#  --enable-thumb  
#  --enable-pic # isn'this automatic?
#  --enable-lto && # lto is very slow

	make $MAKEFLAGS &&
	gcc tools/qt-faststart.c -o tools/qt-faststart &&

	make install && 
	install -v -m755  tools/qt-faststart /usr/bin &&
	install -v -m755 -d /usr/share/doc/ffmpeg-$PKGVER &&
	install -v -m644 doc/*.txt /usr/share/doc/ffmpeg-$PKGVER &&
	pkg_build_slackdesc &&
	rm -f /usr/include/ladspa.h &&
	
	# multilib
	mv -v /usr/bin/ffmpeg{,-64} &&
	ln -sfv multiarch_wrapper /usr/bin/ffmpeg
}

