SUMMARY="An open source MQTT broker"
DESCRIPTION="Eclipse Mosquitto is an open source (EPL/EDL licensed) message \
broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1.
Mosquitto is lightweight and is suitable for use on all devices from low \
power single board computers to full servers.
The MQTT protocol provides a lightweight method of carrying out messaging \
using a publish/subscribe model. This makes it suitable for Internet of Things \
messaging such as with low power sensors or mobile devices such as phones, \
embedded computers or microcontrollers."
HOMEPAGE="http://mosquitto.org"
COPYRIGHT="2020 Eclipse Foundation."
LICENSE="EDL"
REVISION="1"
SOURCE_URI="https://mosquitto.org/files/source/mosquitto-$portVersion.tar.gz"
CHECKSUM_SHA256="b02d8f1368c40d5779ee125c37daf9003608eb47d7fbb04c5b938c76c1230a1f"
PATCHES="mosquitto-$portVersion.patchset"

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

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

GLOBAL_WRITABLE_FILES="
	settings/mosquitto directory keep-old
	"

PROVIDES="
	mosquitto$secondaryArchSuffix = $portVersion
	cmd:mosquitto$secondaryArchSuffix = $portVersion
	cmd:mosquitto_passwd$secondaryArchSuffix = $portVersion
	cmd:mosquitto_pub$secondaryArchSuffix = $portVersion
	cmd:mosquitto_rr$secondaryArchSuffix = $portVersion
	cmd:mosquitto_sub$secondaryArchSuffix = $portVersion
	lib:libmosquitto$secondaryArchSuffix = $libVersionCompat
	lib:libmosquittopp$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	"

PROVIDES_devel="
	mosquitto${secondaryArchSuffix}_devel = $portVersion
	devel:libmosquitto$secondaryArchSuffix = $libVersionCompat
	devel:libmosquittopp$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	mosquitto$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libssl$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build && cd build
	cmake -DCMAKE_BUILD_TYPE=Release \
		$cmakeDirArgs ..
	make
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs libmosquitto libmosquittopp
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	cd build
	make test
}
