SUMMARY="GStreamer Bad Plug-ins"
DESCRIPTION="GStreamer Bad Plug-ins is a set of plug-ins that aren't up to par compared to the \
rest. They might be close to being good quality, but they're missing something - be it a good \
code review, some documentation, a set of tests, a real live maintainer, or some actual wide use."
HOMEPAGE="https://gstreamer.freedesktop.org/"
COPYRIGHT="Erik Walthinsen"
LICENSE="GNU LGPL v2"
REVISION="1"
SOURCE_URI="https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-$portVersion.tar.xz"
CHECKSUM_SHA256="a164923b94f0d08578a6fcaeaac6e0c05da788a46903a1086870e9ca45ad678e"
SOURCE_DIR="gst-plugins-bad-$portVersion"

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

libVersion="0.1805.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	gst_plugins_bad$secondaryArchSuffix = $portVersion
	cmd:gst_transcoder_1.0$secondaryArchSuffix = $portVersion
	lib:libgstadaptivedemux_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstbadallocators_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstbadaudio_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstbadbase_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstbasecamerabinsrc_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstcodecs_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstcodecparsers_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstinsertbin_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstisoff_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstmpegts_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstphotography_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstplayer_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstsctp_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgsttranscoder_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgsturidownloader_1.0$secondaryArchSuffix = $libVersionCompat
	lib:libgstwebrtc_1.0$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libfaad$secondaryArchSuffix
	lib:libfluidsynth$secondaryArchSuffix >= 2
	lib:libfreetype$secondaryArchSuffix
	lib:libgcrypt$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgstapp_1.0$secondaryArchSuffix
	lib:libgstaudio_1.0$secondaryArchSuffix
	lib:libgstreamer_1.0$secondaryArchSuffix
	lib:libgstvideo_1.0$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libmms$secondaryArchSuffix
	lib:libnettle$secondaryArchSuffix
	lib:libnice$secondaryArchSuffix
	lib:libopus$secondaryArchSuffix
	lib:liborc_0.4$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:librtmp.1$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libsrtp$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libx265$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	gst_plugins_bad${secondaryArchSuffix}_devel = $portVersion
	devel:libgstadaptivedemux_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstbadaudio_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstbasecamerabinsrc_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstcodecs_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstcodecparsers_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstinsertbin_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstisoff_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstmpegts_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstphotography_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstplayer_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstsctp_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgsttranscoder_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgsturidownloader_1.0$secondaryArchSuffix = $libVersionCompat
	devel:libgstwebrtc_1.0$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	gst_plugins_bad${secondaryArchSuffix} == $portVersion base
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	devel:libfaad$secondaryArchSuffix
	devel:libfluidsynth$secondaryArchSuffix >= 2
	devel:libfreetype$secondaryArchSuffix
	devel:libgcrypt$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libgstapp_1.0$secondaryArchSuffix >= $libVersion
	devel:libgstaudio_1.0$secondaryArchSuffix >= $libVersion
	devel:libgstreamer_1.0$secondaryArchSuffix >= $libVersion
	devel:libgstvideo_1.0$secondaryArchSuffix >= $libVersion
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:liblcms2$secondaryArchSuffix
	devel:libmms$secondaryArchSuffix
	devel:libnettle$secondaryArchSuffix >= 8
	devel:libnice$secondaryArchSuffix
	devel:libopus$secondaryArchSuffix
	devel:liborc_0.4$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:librtmp$secondaryArchSuffix >= 1
	devel:libsndfile$secondaryArchSuffix
	devel:libsrtp$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix >= 7
	devel:libx265$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:bison
	cmd:cmake
	cmd:flex
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:meson
	cmd:ninja
	cmd:orcc$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
	cmd:python3
	cmd:which
	"

BUILD()
{
	export CFLAGS="-lnetwork"

	meson build \
		--buildtype=release \
		--prefix=$prefix \
		--bindir=$binDir \
		--libdir=$libDir \
		--libexecdir=$libDir \
		--datadir=$dataDir \
		--mandir=$manDir \
		--includedir=$includeDir \
		-D doc=disabled \
		-D examples=disabled \
		-D test=disabled \
		-D nls=disabled \
		-D orc=enabled

	ninja -C build $jobArgs
}

INSTALL()
{
	ninja -C build install

	prepareInstalledDevelLibs libgstadaptivedemux-1.0 libgstbadaudio-1.0 \
		libgstbasecamerabinsrc-1.0 libgstcodecparsers-1.0 \
		libgstinsertbin-1.0 libgstisoff-1.0 libgstmpegts-1.0 libgstphotography-1.0 \
		libgstplayer-1.0 libgsturidownloader-1.0 libgstwebrtc-1.0
	fixPkgconfig

	mv -f $includeDir/gstreamer-1.0/gst $includeDir/
	rm -rf $includeDir/gstreamer-1.0

	# devel package
	packageEntries devel $developDir
}
