SUMMARY="An object-oriented programming language that uses the GObject system"
DESCRIPTION="Vala is a new programming language that aims to bring modern \
programming language features to GNOME developers without imposing any \
additional runtime requirements and without using a different ABI \
compared to applications and libraries written in C."
HOMEPAGE="https://wiki.gnome.org/Projects/Vala"
COPYRIGHT="1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
	1997-2000 GLib Team and others
	1997 Sandro Sigala
	2004-2005 Novell, Inc
	2005 David Waite
	2005 Matthias Clasen
	2006-2021 Jürg Billeter
	2006-2021 Raffaele Sandrini
	2007 Johan Dahlin
	2007 Mathias Hasselmann
	2008-2012 Jamie McCracken
	2008-2011 Florian Brosch
	2008 Philip Van Hoof
	2009 Didier Villevalois
	2009 Jiří Zárevúcky
	2009 Mark Lee
	2010 Jukka-Pekka Iivonen
	2010 Marc-Andre Lureau
	2011-2014 Luca Bruno
	2011 Rodney Dawes
	2014 Richard Wiedenhöft
	2016-2021 Rico Tzschichholz"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://download.gnome.org/sources/vala/${portVersion%.*}/vala-$portVersion.tar.xz"
CHECKSUM_SHA256="ed1d5fe4cbc0cd2845d0de4f1ffefb15afb06892d230c7cca695781672e8fb60"
PATCHES="vala-$portVersion.patchset"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="0.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
portVers="${portVersion%.*}"

PROVIDES="
	vala$secondaryArchSuffix = $portVersion
	cmd:vala$commandSuffix
	cmd:vala_$portVers$commandSuffix
	cmd:vala_gen_introspect$commandSuffix
	cmd:vala_gen_introspect_$portVers$commandSuffix
	cmd:valac$commandSuffix
	cmd:valac_$portVers$commandSuffix
	cmd:valadoc$commandSuffix
	cmd:valadoc_$portVers$commandSuffix
	cmd:vapigen$commandSuffix
	cmd:vapigen_$portVers$commandSuffix
	lib:libvala_$portVers$secondaryArchSuffix = $libVersionCompat
	lib:libvaladoc_$portVers$secondaryArchSuffix = $libVersionCompat
	devel:libvala_$portVers$secondaryArchSuffix = $libVersionCompat
	devel:libvaladoc_$portVers$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcdt$secondaryArchSuffix
	lib:libcgraph$secondaryArchSuffix
#	lib:libgirepository_1.0$secondaryArchSuffix
	lib:libgio_2.0$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgmodule_2.0$secondaryArchSuffix
	lib:libgobject_2.0$secondaryArchSuffix
	lib:libgvc$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	"
REPLACES="
	vala${secondaryArchSuffix}_common
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcdt$secondaryArchSuffix
	devel:libcgraph$secondaryArchSuffix
#	devel:libgirepository_1.0$secondaryArchSuffix
	devel:libgio_2.0$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libgmodule_2.0$secondaryArchSuffix
	devel:libgobject_2.0$secondaryArchSuffix
	devel:libgvc$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:automake
	cmd:autoreconf
	cmd:awk
	cmd:bison
	cmd:cmp
	cmd:diff
	cmd:find
	cmd:flex
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage vala$secondaryArchSuffix \
	"$commandBinDir"/valac-$portVers \
	"$commandBinDir"/valadoc-$portVers \
	"$commandBinDir"/vapigen-$portVers \
	"$libDir"/libvala-$portVers.so.$libVersion \
	"$libDir"/libvaladoc-$portVers.so.$libVersion \
	"$libDir"/vala-$portVers/gen-introspect-$portVers \
	"$libDir"/vala-$portVers/libvalaccodegen.so \
	"$libDir"/valadoc-$portVers/doclets/devhelp/libdoclet.so \
	"$libDir"/valadoc-$portVers/doclets/gtkdoc/libdoclet.so \
	"$libDir"/valadoc-$portVers/doclets/html/libdoclet.so \

BUILD()
{
	autoreconf -vfi
	runConfigure --omit-dirs binDir ./configure --bindir="$commandBinDir"
	make $jobArgs
}

INSTALL()
{
	make install

	find "$libDir" -name '*.la' -delete

	prepareInstalledDevelLibs libvala-$portVers libvaladoc-$portVers
	fixPkgconfig
}

TEST()
{
	LIBRARY_PATH="$sourceDir/vala/.libs:$sourceDir/libvaladoc/.libs\
:$sourceDir/codegen/.libs${LIBRARY_PATH:+:$LIBRARY_PATH}" \
	make check
}
