SUMMARY="A lightweight messaging kernel"
DESCRIPTION="The ZeroMQ lightweight messaging kernel is a library which \
extends the standard socket interfaces with features traditionally provided by \
specialised messaging middleware products. ZeroMQ sockets provide an \
abstraction of asynchronous message queues, multiple messaging patterns, \
message filtering (subscriptions), seamless access to multiple transport \
protocols and more."
HOMEPAGE="http://www.zeromq.org/"
COPYRIGHT="2007-2014 iMatix Corporation
	2009-2011 250bpm s.r.o.
	2010-2011 Miru Limited
	2011 VMware, Inc.
	2012 Spotify AB
	2013 Ericsson AB
	2014 AppDynamics Inc.
	2015 Google, Inc.
	2015-2016 Brocade Communications Systems Inc."
LICENSE="GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://github.com/zeromq/libzmq/releases/download/v$portVersion/zeromq-$portVersion.tar.gz"
CHECKSUM_SHA256="c593001a89f5a85dd2ddf564805deb860e02471171b3f204944857336295c3e5"
SOURCE_URI_2="https://raw.githubusercontent.com/zeromq/cppzmq/e08ab12de2a7c3e21b0004a6b3d4a802c809d3d9/zmq.hpp#noarchive"
CHECKSUM_SHA256_2="e47f44bce9a77ba0413828dbe91bfd510aaf16c08343cb70a33f7c34cd194191"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	zeromq$secondaryArchSuffix = $portVersion
	cmd:curve_keygen$commandSuffix
	lib:libzmq$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

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

defineDebugInfoPackage zeromq$secondaryArchSuffix \
	"$commandBinDir"/curve_keygen \
	"$libDir"/libzmq.so.$libVersion

PATCH()
{
	sed \
		-e '/libzmq_werror=/s:yes:no:g' \
		-i configure.ac || die
}

BUILD()
{
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure --bindir="$commandBinDir"
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libzmq.la

	cp $sourceDir2/zmq.hpp $includeDir

	# prepare development lib links
	prepareInstalledDevelLib libzmq
	fixPkgconfig

	# devel package
	packageEntries devel $developDir $manDir
}

TEST()
{
	make check
}
