# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=x264
pkgver=20170930
pkgrel=0
pkgdesc="Free library for encoding H264/AVC video streams"
url="http://www.videolan.org/developers/x264.html"
arch="all"
license="GPL"
makedepends="libx11-dev bash yasm coreutils perl"
subpackages="$pkgname-dev $pkgname-libs"
source="ftp://ftp.videolan.org/pub/x264/snapshots/x264-snapshot-$pkgver-2245-stable.tar.bz2"
builddir="$srcdir/$pkgname-snapshot-$pkgver-2245-stable"

build() {
	cd "$builddir"

	local asmopts=
	case "$CARCH" in
		# x86 assembly contains TEXTRELs
		# arm neon assembly contains TEXTRELs
		x86 | arm*) asmopts="--disable-asm"
	esac

	# note: not autotools
	CFLAGS="${CFLAGS/-Os/}" ./configure \
		--host=$CHOST \
		--prefix=/usr \
		--enable-shared \
		--enable-static \
		$asmopts \
		--enable-pic \
		--extra-cflags=-fno-aggressive-loop-optimizations
	make
}

check() {
	cd "$builddir"

	./x264 --version
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir" \
		bindir=/usr/bin libdir=/usr/lib includedir=/usr/include \
		install
}

sha512sums="7f0d33f2955dbc8958ad739cfe69b9083ea376d21a4af469a6a44c8db8089859cf0a94018a1cdea49ce4c3b4a1b635cc304208d0492d901fd99a1337ac2c5d57  x264-snapshot-20170930-2245-stable.tar.bz2"
