SUMMARY="A groovy modbus library"
DESCRIPTION="libmodbus is a free software library to send or receive data with a \
device which respects the Modbus protocol. This library can use a serial port or \
an Ethernet connection. The functions included in the library have been derived  \
from the Modicon Modbus Protocol Reference Guide which can be obtained from  \
www.modbus.org."
HOMEPAGE="https://github.com/stephane/libmodbus"
COPYRIGHT="Stéphane Raimbault
	Tobias Doerffel
	Florian Forster
	oldfaber
	Hannu Vuolasaho
	Michael Heimpold
	Jimmy Bergström
	Jakob Bysewski"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://github.com/stephane/libmodbus/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="af8ade1eec30fe3dc6ddf8f711b37f9a931532287f39a40f54e6f475402df389"
PATCHES="libmodbus-$portVersion.patchset"

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

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

PROVIDES="
	libmodbus$secondaryArchSuffix = $portVersion
	lib:libmodbus$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	autogen.sh
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install
	rm $libDir/lib*.la

	# prepare development lib links
	prepareInstalledDevelLib libmodbus
	fixPkgconfig

	# devel package
	packageEntries devel $developDir
}

TEST()
{
	chmod +x tests/unit-tests.sh
	make check
}
