################################################################################
#
# gstreamer.cygclass - common functions for building GStreamer components
#
# Part of cygport - Cygwin packaging application
# Copyright (C) 2006-2020 Cygport authors
# Provided by the Cygwin project <https://cygwin.com/>
#
# cygport is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cygport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <https://www.gnu.org/licenses/>.
#
################################################################################

#****h* Cygclasses/gstreamer.cygclass
#  SYNOPSIS
#  inherit gstreamer
#  DESCRIPTION
#  GStreamer is a modular multimedia framework, using plugins to support
#  a wide variety of audio and video formats, effects, and input/output.
#  Being based on GObject it is heavily used within GNOME, but it also sees
#  some use as a backend for KDE Phonon.
#
#  GStreamer components include the core libraries and command-line tools,
#  several sets of plugins, and Python bindings.  This cygclass defines
#  variables and functions which are common to all GStreamer components,
#  and is also the basis of gst-plugins.cygclass.
#****

case ${PN} in
*gstreamer*) ORIG_PN=${ORIG_PN:-gst-${PN#*gstreamer*-}} ;;
esac

#****o* gstreamer.cygclass/HOMEPAGE (gstreamer)
#  DEFINITION
HOMEPAGE="https://gstreamer.freedesktop.org/"
#****

#****o* gstreamer.cygclass/SRC_URI (gstreamer)
#  DESCRIPTION
#  Download location for the upstream source tarball.
#****
case ${PV} in
0.[0-9].*|0.10.*|0.11.?)
SRC_URI="https://gstreamer.freedesktop.org/src/${ORIG_PN}/${ORIG_PN}-${PV}.tar.bz2"
;;
*)
SRC_URI="https://gstreamer.freedesktop.org/src/${ORIG_PN}/${ORIG_PN}-${PV}.tar.xz"
;;
esac

#****o* gstreamer.cygclass/GIT_URI (gstreamer)
#  NOTE
#  git.cygclass must be inherit()ed last for this to have any effect.
#  DEFINITION
GIT_URI="git://anongit.freedesktop.org/git/gstreamer/${ORIG_PN}"
#****

DIFF_EXCLUDES="common m4 po autoregen.sh stamp-h.in"

#****d* gstreamer.cygclass/GST_PLUGINDIR
#  DESCRIPTION
#  Installation path for GStreamer plugins.
#****
case ${PV} in
0.*)		GST_PLUGINDIR="$(__host_prefix)/lib/gstreamer-${PV[1]}.${PV[2]}" ;;
*)		GST_PLUGINDIR="$(__host_prefix)/lib/gstreamer-${PV[1]}.0" ;;
esac

#****C* gstreamer.cygclass/gstreamer_autoreconf
#  SYNOPSIS
#  cd $S
#  gstreamer_autoreconf
#  DESCRIPTION
#  Updates the build system with the included autogen.sh script, which is
#  shipped in each tarball, which makes sure that all necessary steps are taken.
#  WARNING
#  Skipping this step is strongly discouraged.  Patches to configure.ac, aclocal
#  macros, or Makefile.am files will not take effect until their tools have been
#  regenerated.  Also, Cygwin's libtool package often includes patches which
#  are not yet available in the latest upstream release, so libraries may not
#  be built optimally, or even correctly, without this step having been run.
#  REQUIRES
#  autoconf, automake, gettext-devel, libtool, pkg-config
#  SEE ALSO
#  cygautoreconf
#****
gstreamer_autoreconf() {
	# gstreamer packages require a custom autogen.sh
	if [ ! -f autogen.sh ]
	then
    	error "Could not find autogen.sh"
	fi

	__config_set with_aclocal 1
	__config_set with_autoconf 1
	__config_set with_autoheader 1
	__config_set with_automake 1
	__config_set with_libtool 1

	NOCONFIGURE=1 ./autogen.sh || error "autogen.sh failed"
	gnuconfigize .
}

gst_autoreconf() { gstreamer_autoreconf ; }

readonly -f gstreamer_autoreconf gst_autoreconf
