### this file is sourced not run
PKGVER=4.0
PKGBUILD=1
PKGARCH=i686

# source: post BLFS 7.8 updated 6-14-2018
TARBALL=ffmpeg-$PKGVER.tar.xz
MD5SUM=1cc9e8cb027b9fd4c54f598f51002c19
SRC_URL=http://ffmpeg.org/releases/$TARBALL
BUNDLE=

SLACKREQ='libfaac32 libvpx32 lame32 libtheora32 libxvidcore32 libx264_32 libx265_32 libass32 \
twolame32 libopencore-amr32 libopus32 librtmp32 libmodplug32 libSDL2_32 openssl32 \
freetype2_32 libopenjpeg32 libspeex32 libvorbis32 fontconfig32 v4l-utils32 alsa-lib32 \
libjack2_32 libaom32 libvdpau32' # libgsm is for compile-time only
SLACKDESC="ffmpeg32: ffmpeg32 $PKGVER (Media conversion tool and library)  
ffmpeg32:  
ffmpeg32: FFmpeg is a versatile tool and library to play, record, and mainly to 
ffmpeg32: convert audio and video streams and files; modifying them on the fly 
ffmpeg32: as needed. This library is the base for many media players.  
ffmpeg32: 
ffmpeg32: This contains 32-bit version of the library.
ffmpeg32: 
ffmpeg32: 
ffmpeg32: 
ffmpeg32:
"

### default pkg_download
### default pkg_prepare
### package - only collect the libraries
pkg_package() {
	rm -rf bin sbin usr/bin usr/sbin usr/include usr/share
	mkdir -p usr/bin &&
	mv -v tmp/*-32 usr/bin
}

### build
pkg_build() {
	cd /tmp/ffmpeg*
	sed -i 's/-lflite"/-lflite -lasound"/' configure &&
	export CFLAGS="${BUILD32} -fno-PIC -Os"
	./configure --prefix=/usr --libdir=/usr/$LIBDIR --shlibdir=/usr/$LIBDIR \
			--cc="$CC" --cxx="$CXX" --disable-doc        \
            --enable-gpl         \
            --enable-version3    \
            --enable-nonfree     \
            --disable-static     \
            --enable-shared      \
            --disable-debug      \
            --enable-libass      \
            --enable-libmp3lame  \
            --enable-libopus     \
            --enable-libtheora   \
            --enable-libvorbis   \
            --enable-libvpx      \
            --enable-libx264     \
            --enable-libx265     \
            --enable-libfdk-aac  \
		--enable-libfreetype \
		--enable-libopenjpeg \
		--enable-libspeex    \
		--enable-libxvid     \
		--enable-openssl     \
		--enable-libgsm \
		--enable-avresample \
		--enable-fontconfig      \
		--enable-libmodplug      \
		--enable-libopencore-amrnb \
		--enable-libopencore-amrwb \
		--enable-libopus         \
		--enable-librtmp         \
		--enable-libtwolame      \
		--enable-libv4l2         \
		--enable-libaom          \
		--enable-vdpau &&
#  --enable-libfdk-aac  # we use faac
#  --disable-neon
#  --enable-thumb  
#  --enable-pic # isn'this automatic?
#  --enable-lto && # lto is very slow
	make $MAKEFLAGS &&
#	gcc ../ffmpeg*/tools/qt-faststart.c -o qt-faststart &&
#	unset LD_LIBRARY_PATH &&
	make install && 
#	install -v -m755 qt-faststart /usr/bin &&
#	install -v -m755 -d /usr/share/doc/ffmpeg-$PKGVER &&
#	install -v -m644 ../ffmpeg*/doc/*.txt \
#					/usr/share/doc/ffmpeg-$PKGVER &&
	pkg_build_slackdesc &&
	
	# multilib
	mv -v /usr/bin/ffmpeg /tmp/ffmpeg-32
}

