SUMMARY="A C library for asynchronous DNS requests"
DESCRIPTION="This is c-ares, an asynchronous resolver library. It is intended \
for applications which need to perform DNS queries without blocking, or need \
to perform multiple DNS queries in parallel. The primary examples of such \
applications are servers which communicate with multiple clients and programs \
with graphical user interfaces."
HOMEPAGE="https://c-ares.haxx.se/"
COPYRIGHT="2004-2018 by Daniel Stenberg et al
	1998-2013 by the Massachusetts Institute of Technology
	1987-2001 The Regents of the University of California
	1996-2004 by Internet Software Consortium
	2009 by Jakub Hrozek
	2010 Jeremy Lal
	2012 Marko Kreen
	2005 Dominick Meglio"
LICENSE="MIT"
REVISION="2"
SOURCE_URI="https://c-ares.haxx.se/download/c-ares-$portVersion.tar.gz"
CHECKSUM_SHA256="4803c844ce20ce510ef0eb83f8ea41fa24ecaae9d280c468c582d2bb25b3913d"
SOURCE_DIR="c-ares-$portVersion"
PATCHES="c_ares-$portVersion.patchset"

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

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

PROVIDES="
	c_ares$secondaryArchSuffix = $portVersion compat >= 1
	cmd:acountry$secondaryArchSuffix = $portVersion
	cmd:adig$secondaryArchSuffix = $portVersion
	cmd:ahost$secondaryArchSuffix = $portVersion
	lib:libcares$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	c_ares${secondaryArchSuffix}_devel = $portVersion compat >= 1
	devel:libcares$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	c_ares$secondaryArchSuffix == $portVersion base
	"

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

defineDebugInfoPackage c_ares$secondaryArchSuffix \
	"$libDir"/libcares.so.$libVersion

BUILD()
{
	cmake $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE='RelWithDebInfo' \
		-Wno-dev -B build -S .
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install

	prepareInstalledDevelLibs libcares
	fixPkgconfig

	packageEntries devel \
		"$developDir" \
		"$manDir/man3"
}
