SUMMARY="A library that defines common error values"
DESCRIPTION="This is a library that defines common error values for all GnuPG \
components. Among these are GPG, GPGSM, GPGME, GPG-Agent, libgcrypt, Libksba, \
DirMngr, Pinentry, SmartCard Daemon and more."
HOMEPAGE="https://www.gnupg.org/related_software/libraries.en.html#lib-libgpg-error"
COPYRIGHT="2003-2018 g10 Code GmbH"
LICENSE="GNU LGPL v2.1"
REVISION="2"
SOURCE_URI="https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-$portVersion.tar.bz2"
CHECKSUM_SHA256="babd98437208c163175c29453f8681094bcaf92968a15cafb1a276076b33c97c"
SOURCE_DIR="libgpg-error-$portVersion"
PATCHES="libgpg_error-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

libVersion="0.27.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
portVersionCompat="$portVersion compat >= 1"

PROVIDES="
	libgpg_error$secondaryArchSuffix = $portVersion
	cmd:gpg_error$secondaryArchSuffix = $portVersionCompat
	cmd:yat2m$secondaryArchSuffix = $portVersionCompat
	lib:libgpg_error$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libgpg_error${secondaryArchSuffix}_devel = $portVersion
	cmd:gpg_error_config$secondaryArchSuffix = $portVersionCompat
	cmd:gpgrt_config$secondaryArchSuffix = $portVersionCompat
	devel:libgpg_error$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libgpg_error$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage libgpg_error$secondaryArchSuffix \
	"$binDir"/gpg-error \
	"$binDir"/yat2m \
	"$libDir"/libgpg-error.so.$libVersion

BUILD()
{
	MAKEINFO=true runConfigure ./configure
	make LIBS="-lnetwork"
}

INSTALL()
{
	make install

	rm -f "$libDir"/libgpg-error.la

	prepareInstalledDevelLib libgpg-error

	fixPkgconfig

	if [ -n "$secondaryArchSuffix" ]; then
		maybe_manDir=
		rm -rf "$infoDir" "$manDir"
	else
		maybe_manDir="$manDir"
	fi

	packageEntries devel \
		"$developDir" \
		"$binDir"/gpg-error-config \
		"$binDir"/gpgrt-config \
		"$dataDir" \
		${maybe_manDir:+"$maybe_manDir"/man1/gpgrt-config.1}

	if [ -n "$maybe_manDir" ]; then
		rmdir "$maybe_manDir"/man1 && rmdir "$maybe_manDir" || true
	fi
}

TEST()
{
	make check
}
