SUMMARY="An encoder for x264 h.264/AVC"
DESCRIPTION="x264 is a h.264/AVC encoder library."
HOMEPAGE="https://www.videolan.org/developers/x264.html"
COPYRIGHT="2003-2021 VideoLan.org"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="66a5bc1bd1563d8227d5d18440b525a09bcf17ca"
SOURCE_URI="https://github.com/mirror/x264/archive/$srcGitRev.tar.gz"
SOURCE_FILENAME="x264-$portVersion-$srcGitRev.tar.gz"
CHECKSUM_SHA256="781891aa10349f53e20c86e27d38fc730e12dabc3bcc610eb9d2650d58541739"
SOURCE_DIR="x264-$srcGitRev"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libVersion="164"
libVersionCompat="$libVersion compat >= ${libVersion}"

PROVIDES="
	x264$secondaryArchSuffix = $portVersion
	cmd:x264$secondaryArchSuffix
	lib:libx264$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	x264${secondaryArchSuffix}_devel = $portVersion
	devel:libx264$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	x264$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:nasm >= 2.13
	"

defineDebugInfoPackage x264$secondaryArchSuffix \
	"$libDir"/libx264.so.$libVersion

BUILD()
{
	CFLAGS="-fPIC" runConfigure --omit-dirs \
		"manDir oldIncludeDir sbinDir localStateDir sharedStateDir sysconfDir infoDir dataDir dataRootDir libExecDir docDir" \
		--omit-buildspec ./configure --enable-pic --enable-shared \
		--extra-ldflags='-Wl,-Bsymbolic'
	make $jobArgs
}

INSTALL()
{
	make install

	prepareInstalledDevelLibs libx264
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
