SUMMARY="A C++ base UPnP library, derived from Portable UPnP, a.k.a libupnp"
DESCRIPTION="npupnp (new pupnp or not pupnp ?) is an UPnP library derived from \
the venerable pupnp."
HOMEPAGE="https://framagit.org/medoc92/npupnp"
COPYRIGHT="2000-2003 Intel Corporation
	2005-2006 Rémi Turboult
	2006 Michel Pfeiffer and others
	2020 Jean-Francois Dockes"
LICENSE="BSD (3-clause)"
REVISION="3"
SOURCE_URI="https://framagit.org/medoc92/npupnp/-/archive/libnpupnp-v${portVersion}/npupnp-libnpupnp-v${portVersion}.tar.bz2"
CHECKSUM_SHA256="20f3963f761fdf12e78e9f75ebdcd65c86d7ebd0449e1345b10387cab9b33b14"
SOURCE_DIR="npupnp-libnpupnp-v$portVersion"

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

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

PROVIDES="
	libnpupnp$secondaryArchSuffix = $portVersion
	lib:libnpupnp$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libexpat$secondaryArchSuffix
	lib:libgnutls_openssl$secondaryArchSuffix
	lib:libidn2$secondaryArchSuffix
	lib:libmicrohttpd$secondaryArchSuffix
	lib:libnettle$secondaryArchSuffix
	lib:libp11_kit$secondaryArchSuffix
	lib:libtasn1$secondaryArchSuffix
	"

PROVIDES_devel="
	libnpupnp${secondaryArchSuffix}_devel = $portVersion
	devel:libnpupnp$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libnpupnp$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libexpat$secondaryArchSuffix
	devel:libgnutls_openssl$secondaryArchSuffix
	devel:libidn2$secondaryArchSuffix
	devel:libmicrohttpd$secondaryArchSuffix
	devel:libnettle$secondaryArchSuffix
	devel:libp11_kit$secondaryArchSuffix
	devel:libtasn1$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libnpupnp$secondaryArchSuffix \
	$libDir/libnpupnp.so.$libVersion

BUILD()
{
	./autogen.sh

	CXXFLAGS="-D_DEFAULT_SOURCE" LDFLAGS="-lnetwork" runConfigure ./configure \
		--enable-client \
		--enable-debug \
		--enable-device \
		--enable-gena \
		--enable-ipv6 \
		--enable-optssdp \
		--enable-reuseaddr \
		--enable-soap \
		--enable-ssdp \
		--enable-tools \
		--enable-webserver

	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/lib*.la

	# prepare development lib links
	prepareInstalledDevelLib libnpupnp
	fixPkgconfig

	# devel package
	packageEntries devel $developDir
}

TEST()
{
	make check
}
