# Contributor: Daniel Isaksen <d@duniel.no>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=yara
pkgver=4.5.1
pkgrel=0
pkgdesc="The pattern matching swiss knife for malware researchers"
url="https://virustotal.github.io/yara/"
arch="all"
license="BSD-3-Clause"
makedepends="
	autoconf
	automake
	file-dev
	flex
	libtool
	linux-headers
	openssl-dev
	"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/VirusTotal/yara/archive/v$pkgver.tar.gz
	frozen-tests.patch
	"

# secfixes:
#   4.2.0-r0:
#     - CVE-2021-45429

prepare() {
	default_prepare
	autoreconf -fiv
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--with-crypto \
		--enable-magic
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/
	install -Dm644 README.md -t "$pkgdir"/usr/share/doc/$pkgname/
	cp -r docs "$pkgdir"/usr/share/doc/$pkgname/
}

sha512sums="
8bf1df7089f9bc5a448dbae0999e04f4ecdec06b4478e2cb5f42a2a3201b99fce68379e3f8f7c67a9db201205366250d7befe5c38451cced807ed692d436422c  yara-4.5.1.tar.gz
7409cc9b10e45d49ef5def47ece19db34e18c7dada007cb8d27879b07374e57913ce4489df9d4bd6bd86706505fb29ee847362dcd3863eeaa6397277012f418f  frozen-tests.patch
"
