# Template file for 'x264'
pkgname=x264
_snap_date=20120126
_snap_rev=2245
version="${_snap_date}.${_snap_rev}"
revision=3
wrksrc="x264-snapshot-${_snap_date}-${_snap_rev}-stable"
hostmakedepends="yasm"
short_desc="Free library for encoding H264/AVC video streams"
maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://www.videolan.org/developers/x264.html"
license="GPL-2"
distfiles="http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-${_snap_date}-${_snap_rev}-stable.tar.bz2"
checksum=6270fcc6e2ef133e4db2b2e0f4f22b5dbdd9a637e979b5697014b698f0d56baa
long_desc="
 Stable snapshot version of x264, a high quality H.264 codec."

do_configure() {
	if [ "$XBPS_TARGET_MACHINE" != "i686" -o "$XBPS_TARGET_MACHINE" != "x86_64" ]; then
		_disable_asm="--disable-asm"
	fi
	if [ "$CROSS_BUILD" ]; then
		_cross="--host=$XBPS_CROSS_TRIPLET"
	fi
	./configure --disable-swscale --enable-static --enable-pic \
		--enable-shared ${_disable_asm} ${_cross}
}

do_build() {
	make ${makejobs}
}

do_install() {
	make DESTDIR=${DESTDIR} \
		bindir=/usr/bin libdir=/usr/lib includedir=/usr/include install
	# Set version as 0.120.0 in pkg-config file.
	sed -i -e "s|0.120.x|0.120.0|g" ${DESTDIR}/usr/lib/pkgconfig/x264.pc
}

x264-devel_package() {
	depends="x264>=${version}"
	short_desc="${short_desc} -- development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.a"
	}
}

x264_package() {
	pkg_install() {
		vmove usr
	}
}
