SUMMARY="Free video editor and encoder"
DESCRIPTION="Avidemux is a free video editor designed for simple cutting, \
filtering and encoding tasks. It supports many file types, including AVI, \
DVD compatible MPEG files, MP4 and ASF, using a variety of codecs. Tasks \
can be automated using projects, job queue and powerful scripting capabilities."
HOMEPAGE="http://fixounet.free.fr/avidemux/"
COPYRIGHT="2001–2021 Mean"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://sourceforge.net/projects/avidemux/files/avidemux/$portVersion/avidemux_$portVersion.tar.gz"
CHECKSUM_SHA256="d1ec6f5277e51228ecf0ee1ca89fae24c591f520f87ce96fabec8818d04de33b"
SOURCE_DIR="avidemux_$portVersion"
PATCHES="avidemux-$portVersion.patchset"
ADDITIONAL_FILES="
	avidemux.rdef.in
	haikuicons.zip
	"

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

PROVIDES="
	avidemux$secondaryArchSuffix = $portVersion
	app:Avidemux$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku${secondaryArchSuffix}
	lib:liba52$secondaryArchSuffix
	lib:libass$secondaryArchSuffix
	lib:libcddb$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libfaac$secondaryArchSuffix
	lib:libfaad$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libmad$secondaryArchSuffix
	lib:libmp3lame$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopus$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libtag$secondaryArchSuffix
	lib:libtwolame$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libvorbisenc$secondaryArchSuffix
	lib:libx264$secondaryArchSuffix
	lib:libx265$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:liba52$secondaryArchSuffix
	devel:libass$secondaryArchSuffix
	devel:libcddb$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libfaac$secondaryArchSuffix
	devel:libfaad$secondaryArchSuffix
	devel:libgl$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libmad$secondaryArchSuffix
	devel:libmp3lame$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libopus$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5DBus$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libtag$secondaryArchSuffix
	devel:libtwolame$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libx264$secondaryArchSuffix
	devel:libx265$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:cmake
	cmd:cmp
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:patch
	cmd:pkg_config$secondaryArchSuffix
	cmd:unzip
	cmd:yasm
	"

PATCH()
{
	unzip -o $sourceDir/../../additional-files/haikuicons.zip -d $sourceDir/avidemux/qt4/ADM_userInterfaces/ADM_gui/pics
}

BUILD()
{
	bash bootStrap.bash \
		--prefix=$appsDir/Avidemux \
		--without-cli \
		--with-qt \
		--with-system-libass \
		--with-system-liba52 \
		--with-system-libmad
}

INSTALL()
{
	mkdir -p $appsDir/Avidemux
	cp -fr $sourceDir/install/$appsDir/Avidemux/* $appsDir/Avidemux
	mv $appsDir/Avidemux/bin/avidemux3_qt5 "$appsDir/Avidemux/Avidemux"
	mv $appsDir/Avidemux/bin/avidemux3_jobs_qt5 "$appsDir/Avidemux/Avidemux Jobs"
	ln -s "$appsDir/Avidemux/Avidemux" $appsDir/Avidemux/bin/avidemux3_qt5
	ln -s "$appsDir/Avidemux/Avidemux Jobs" $appsDir/Avidemux/bin/avidemux3_jobs_qt5
	rm -rf $appsDir/Avidemux/include \
		$appsDir/Avidemux/share/ADM6_addons

	local APP_SIGNATURE="application/x-vnd.avidemux"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/avidemux.rdef.in > avidemux.rdef

	addResourcesToBinaries avidemux.rdef $appsDir/Avidemux/Avidemux
	addResourcesToBinaries avidemux.rdef "$appsDir/Avidemux/Avidemux Jobs"

	addAppDeskbarSymlink $appsDir/Avidemux/Avidemux
}
