# Contributor: Corentin Henry <corentinhenry@gmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=ostinato
pkgver=1.3.0
pkgrel=2
pkgdesc="Packet/Traffic Generator and Analyzer"
url="https://ostinato.org/"
arch="all"
license="GPL-3.0-or-later"
options="!check" # make test does nothing
makedepends="
	abseil-cpp-dev
	libnl3-dev
	libpcap-dev
	protobuf-dev
	qt5-qtbase-dev
	qt5-qtscript-dev
	qt5-qtsvg-dev
	"
subpackages="$pkgname-drone $pkgname-gui"
source="$pkgname-$pkgver.tar.gz::https://github.com/pstavirs/ostinato/archive/v$pkgver.tar.gz
	ModelTest.patch
	"
	# ModelTest::ModelTest is included and needed during linking even in release mode

build() {
	export LDFLAGS="$LDFLAGS -Wl,--copy-dt-needed-entries"
	qmake-qt5 PREFIX=/usr

	# qmake generates broken CFLAGS, demand it use ours
	# also keep DEFINES because of #11848
	# j1 because there is no correct dependency ordering for a proto header
	make -j1 CXXFLAGS="$CXXFLAGS \$(DEFINES)"
}

package() {
	make INSTALL_ROOT="$pkgdir" install
}

drone() {
	pkgdesc="$pkgdesc (agent)"

	amove usr/bin/drone
}

gui() {
	pkgdesc="$pkgdesc (controller)"
	depends="qt5-qtsvg" # 11849

	amove usr/bin/ostinato
	amove usr/share/ostinato-controller/themes
}

sha512sums="
8f94b95c8c9042960635228bb22fc12dbd28c44a66ed5b2c3296975eefeb274a341adf0d6126e8e9a13d2a9410b61ab3f35a9a58ce0bda970f1dbea8aaad6e38  ostinato-1.3.0.tar.gz
e0a3d2781c62b1898a80af8522b36d6b1a7aeae9831c33c42e4e76fe002ee7ebff50d432508a18046d7b5988f09d9a9f90a0433cfae1d2c1cbeaf664671abf6c  ModelTest.patch
"
