# Template file for 'ffmpeg-compat'
pkgname=ffmpeg-0.10x-compat
version=0.10.6
revision=3
wrksrc="ffmpeg-${version}"
short_desc="FFmpeg 0.10.x compatibility libraries"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-3"
homepage="http://www.ffmpeg.org"
distfiles="${homepage}/releases/ffmpeg-${version}.tar.bz2"
checksum=8c67c0be9dc568a857d5542247aa4e3c1c6538fa3643b47c9deb7ff004a97626

hostmakedepends="which pkg-config perl yasm"
makedepends="alsa-lib-devel faad2-devel lame-devel libtheora-devel
 libvorbis-devel x264-devel xvidcore-devel libvpx-devel librtmp-devel
 freetype-devel"

do_configure() {
	if [ "$CROSS_BUILD" ]; then
		case "$XBPS_TARGET_MACHINE" in
			arm*) _arch="arm";;
			mips*) _arch="mips";;
			i686|x86_64) _arch="$XBPS_TARGET_MACHINE";;
		esac

		_cross="--enable-cross-compile
			--sysroot=$XBPS_CROSS_BASE
			--cross-prefix=${XBPS_CROSS_TRIPLET}-
			--target-os=linux --arch=${_arch}"

		export PKG_CONFIG_LIBDIR="$XBPS_CROSS_BASE/lib/pkgconfig"
		export PKG_CONFIG_SYSROOT_DIR="$XBPS_CROSS_BASE"
	fi

	env pkg_config=pkg-config \
		./configure --prefix=/usr --disable-debug --enable-gpl \
		--incdir=/usr/include/${pkgname} \
		--libdir=/usr/lib/${pkgname} --shlibdir=/usr/lib/${pkgname} \
		--disable-libcdio --enable-version3 --enable-runtime-cpudetect \
		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
		--enable-libx264 --enable-libvpx --enable-libtheora \
		--disable-vdpau --disable-vaapi --enable-postproc \
		--enable-shared --disable-x11grab --enable-librtmp \
		--disable-libpulse --enable-libfreetype --disable-libmodplug \
		--disable-libspeex --disable-libcelt --disable-libass \
		--disable-libopencore_amrnb --disable-libopencore_amrwb \
		--disable-libschroedinger --disable-libopenjpeg \
		--disable-static --disable-ffmpeg --disable-ffplay \
		--disable-ffprobe --disable-ffserver ${_cross}
}

do_build() {
	make ${makejobs}
}

do_install() {
	make DESTDIR=${DESTDIR} install
}

ffmpeg-0.10x-compat-devel_package() {
	depends="${sourcepkg}>=${version}"
	short_desc="${short_desc} - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/${sourcepkg}/pkgconfig
	}
}

ffmpeg-0.10x-compat_package() {
	pkg_install() {
		vmove usr
	}
}
