# Contributor: Daniel Isaksen <d@duniel.no>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=yara
pkgver=4.5.2
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="
761f3930117c35d87b0e3be1a5d61a6887006470fdf578164feb1bd56a96b2d85770ab7c3a21258a2781ff3327cb705942f4f0eb959cff4b210f0c7fbec1fc30  yara-4.5.2.tar.gz
7409cc9b10e45d49ef5def47ece19db34e18c7dada007cb8d27879b07374e57913ce4489df9d4bd6bd86706505fb29ee847362dcd3863eeaa6397277012f418f  frozen-tests.patch
"
